Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@laptop.org>2012-12-13 18:50:56 (GMT)
committer Simon Schampijer <simon@laptop.org>2012-12-14 12:40:40 (GMT)
commitaf7b783866fb92d715d128f777ba3ae802949f7e (patch)
tree78bc98587b65a48b52b9154dc7c9e50c114b5952
parente4dc51fac12cbd62d3fb8fcf511795ace86cc247 (diff)
Tabbinghandler: port the tabbinghandler to the new GTK+3 API, SL #3895
gdk-keyboard-grab [1] and gdk-pointer-grab [2] have been deprecated, we have to use gdk_device_grab [3] now in order to grab the events. This patch does the port to the new API. We also switch to gdk_window_get_device_position instead of gdk_window_get_pointer [4]. This patch needs as well a fix for the keygrabber (toolkit) to handle XI2 key events in order to work. [1] http://developer.gnome.org/gdk3/stable/gdk3-General.html#gdk-keyboard-grab [2] http://developer.gnome.org/gdk3/stable/gdk3-General.html#gdk-pointer-grab [3] http://developer.gnome.org/gdk3/stable/GdkDevice.html#gdk-device-grab [4] http://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-get-pointer Signed-off-by: Simon Schampijer <simon@laptop.org> Reviewed-by: Gonzalo Odiard <gonzalo@laptop.org> Tested-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--src/jarabe/view/tabbinghandler.py51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/jarabe/view/tabbinghandler.py b/src/jarabe/view/tabbinghandler.py
index 0d42c3f..66dd7ca 100644
--- a/src/jarabe/view/tabbinghandler.py
+++ b/src/jarabe/view/tabbinghandler.py
@@ -32,30 +32,55 @@ class TabbingHandler(object):
self._tabbing = False
self._modifier = modifier
self._timeout = None
-
- def _start_tabbing(self):
+ self._keyboard = None
+ self._mouse = None
+
+ display = Gdk.Display.get_default()
+ device_manager = display.get_device_manager()
+ devices = device_manager.list_devices(Gdk.DeviceType.MASTER)
+ for device in devices:
+ if device.get_source() == Gdk.InputSource.KEYBOARD:
+ self._keyboard = device
+ if device.get_source() == Gdk.InputSource.MOUSE:
+ self._mouse = device
+
+ def _start_tabbing(self, event_time):
if not self._tabbing:
logging.debug('Grabing the input.')
screen = Gdk.Screen.get_default()
window = screen.get_root_window()
- keyboard_grab_result = Gdk.keyboard_grab(window, False)
- pointer_grab_result = Gdk.pointer_grab(window)
+
+ keyboard_grab_result = self._keyboard.grab(window,
+ Gdk.GrabOwnership.WINDOW,
+ False,
+ Gdk.EventMask.KEY_PRESS_MASK |
+ Gdk.EventMask.KEY_RELEASE_MASK,
+ None,
+ event_time)
+
+ mouse_grab_result = self._mouse.grab(window,
+ Gdk.GrabOwnership.WINDOW,
+ False,
+ Gdk.EventMask.BUTTON_PRESS_MASK |
+ Gdk.EventMask.BUTTON_RELEASE_MASK,
+ None,
+ event_time)
self._tabbing = (keyboard_grab_result == Gdk.GrabStatus.SUCCESS and
- pointer_grab_result == Gdk.GrabStatus.SUCCESS)
+ mouse_grab_result == Gdk.GrabStatus.SUCCESS)
# Now test that the modifier is still active to prevent race
# conditions. We also test if one of the grabs failed.
- mask = window.get_pointer()[2]
+ mask = window.get_device_position(self._mouse)[3]
if not self._tabbing or not (mask & self._modifier):
logging.debug('Releasing grabs again.')
# ungrab keyboard/pointer if the grab was successfull.
if keyboard_grab_result == Gdk.GrabStatus.SUCCESS:
- Gdk.keyboard_ungrab()
- if pointer_grab_result == Gdk.GrabStatus.SUCCESS:
- Gdk.pointer_ungrab()
+ self._keyboard.ungrab(event_time)
+ if mouse_grab_result == Gdk.GrabStatus.SUCCESS:
+ self._mouse.ungrab(event_time)
self._tabbing = False
else:
@@ -85,7 +110,7 @@ class TabbingHandler(object):
def next_activity(self, event_time):
if not self._tabbing:
first_switch = True
- self._start_tabbing()
+ self._start_tabbing(event_time)
else:
first_switch = False
@@ -108,7 +133,7 @@ class TabbingHandler(object):
def previous_activity(self, event_time):
if not self._tabbing:
first_switch = True
- self._start_tabbing()
+ self._start_tabbing(event_time)
else:
first_switch = False
@@ -134,8 +159,8 @@ class TabbingHandler(object):
next_activity.get_window().activate(event_time)
def stop(self, event_time):
- Gdk.keyboard_ungrab()
- Gdk.pointer_ungrab()
+ self._keyboard.ungrab(event_time)
+ self._mouse.ungrab(event_time)
self._tabbing = False
self._frame.hide()