From 7b43e5e2b6e827e723c5ae678fdbba20aa8d4f71 Mon Sep 17 00:00:00 2001 From: hordepfo Date: Thu, 1 May 2014 18:13:17 +0100 Subject: [PATCH 1/3] Fixes reported issues with the mouse pointer. --- usr/lib/linuxmint/mintMenu/pointerMonitor.py | 23 +++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/pointerMonitor.py b/usr/lib/linuxmint/mintMenu/pointerMonitor.py index 38291b6..642a122 100644 --- a/usr/lib/linuxmint/mintMenu/pointerMonitor.py +++ b/usr/lib/linuxmint/mintMenu/pointerMonitor.py @@ -25,20 +25,11 @@ class PointerMonitor(GObject.GObject, threading.Thread): self.display = Display() self.root = self.display.screen().root self.windows = [] - self.topWindows = [] # Receives GDK windows def addWindowToMonitor(self, window): xWindow = self.display.create_resource_object("window", gdk.gdk_x11_drawable_get_xid(hash(window))) self.windows.append(xWindow) - self.topWindows.append(self.getToplevelParent(xWindow)) - - def getToplevelParent(self, window): - parent = window.query_tree().parent - if parent == self.root: - return window - else: - return self.getToplevelParent(parent) def grabPointer(self): self.root.grab_button(X.AnyButton, X.AnyModifier, True, X.ButtonPressMask, X.GrabModeSync, X.GrabModeAsync, 0, 0) @@ -62,15 +53,11 @@ class PointerMonitor(GObject.GObject, threading.Thread): try: if event.type == X.ButtonPress: # Check if pointer is inside monitored windows - for w, topW in zip(self.windows, self.topWindows): - if event.child == topW: - if topW == w: - break - else: - p = w.query_pointer() - g = w.get_geometry() - if p.win_x >= 0 and p.win_y >= 0 and p.win_x <= g.width and p.win_y <= g.height: - break + for w in self.windows: + p = w.query_pointer() + g = w.get_geometry() + if p.win_x >= 0 and p.win_y >= 0 and p.win_x <= g.width and p.win_y <= g.height: + break else: # Is outside, so activate GLib.idle_add(self.idle) From 200653975ff8da5cc558e69972dd10020d9a7c41 Mon Sep 17 00:00:00 2001 From: hordepfo Date: Thu, 1 May 2014 20:54:43 +0100 Subject: [PATCH 2/3] Use current time for events that might not have a timestamp. --- usr/lib/linuxmint/mintMenu/pointerMonitor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/pointerMonitor.py b/usr/lib/linuxmint/mintMenu/pointerMonitor.py index 642a122..1229576 100644 --- a/usr/lib/linuxmint/mintMenu/pointerMonitor.py +++ b/usr/lib/linuxmint/mintMenu/pointerMonitor.py @@ -61,8 +61,9 @@ class PointerMonitor(GObject.GObject, threading.Thread): else: # Is outside, so activate GLib.idle_add(self.idle) - - self.display.allow_events(X.ReplayPointer, event.time) + self.display.allow_events(X.ReplayPointer, event.time) + else: + self.display.allow_events(X.ReplayPointer, X.CurrentTime) except Exception as e: print "Unexpected error: " + str(e) From 5a7b246b7e0966d23974584ea83beee686137a96 Mon Sep 17 00:00:00 2001 From: hordepfo Date: Tue, 6 May 2014 22:05:14 +0100 Subject: [PATCH 3/3] Simple fix for the flickering. --- usr/lib/linuxmint/mintMenu/mintMenu.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/usr/lib/linuxmint/mintMenu/mintMenu.py b/usr/lib/linuxmint/mintMenu/mintMenu.py index 1121fd5..5b2f215 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenu.py +++ b/usr/lib/linuxmint/mintMenu/mintMenu.py @@ -506,6 +506,8 @@ class MenuWin( object ): self.mainwin = MainWindow( self.button_box, self.settings, self.keybinder ) self.mainwin.window.connect( "map-event", self.onWindowMap ) self.mainwin.window.connect( "unmap-event", self.onWindowUnmap ) + self.mainwin.window.connect( "enter-notify-event", self.onWindowEnter ) + self.mainwin.window.connect( "leave-notify-event", self.onWindowLeave ) self.mainwin.window.connect( "realize", self.onRealize ) self.mainwin.window.connect( "size-allocate", lambda *args: self.positionMenu() ) @@ -534,6 +536,14 @@ class MenuWin( object ): self.pointerMonitor.ungrabPointer() return False + def onWindowEnter(self, applet, event): + self.pointerMonitor.ungrabPointer() + return False + + def onWindowLeave(self, applet, event): + self.pointerMonitor.grabPointer() + return False + def onRealize( self, *args): self.pointerMonitor.addWindowToMonitor( self.mainwin.window.window ) self.pointerMonitor.addWindowToMonitor( self.applet.window )