From c88d5d2d851656017ea93b151eb68f0ee1c9b841 Mon Sep 17 00:00:00 2001
From: Gonzalo Odiard <godiard@gmail.com>
Date: Wed, 12 Dec 2012 17:03:02 -0300
Subject: [PATCH] Fix Tabbinghandler not working - SL #3895
The methods to grab/ungrab keyboard and mouse in Gdk3 [1] has changed,
this patch update the code.
Also the mask returned by window.get_pointer() can return as 0,
then the code was changed to ungrab in that situation.
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
[1] http://developer.gnome.org/gdk3/stable/gdk3-General.html
---
src/jarabe/view/tabbinghandler.py | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/jarabe/view/tabbinghandler.py b/src/jarabe/view/tabbinghandler.py
index 0d42c3f..755a8ee 100644
a
|
b
|
from jarabe.model import shell |
25 | 25 | |
26 | 26 | _RAISE_DELAY = 250 |
27 | 27 | |
| 28 | _MOUSE_MASK = Gdk.EventMask.POINTER_MOTION_MASK | \ |
| 29 | Gdk.EventMask.POINTER_MOTION_HINT_MASK | \ |
| 30 | Gdk.EventMask.BUTTON_PRESS_MASK | \ |
| 31 | Gdk.EventMask.BUTTON_RELEASE_MASK | \ |
| 32 | Gdk.EventMask.BUTTON_MOTION_MASK |
28 | 33 | |
29 | 34 | class TabbingHandler(object): |
30 | 35 | def __init__(self, frame, modifier): |
… |
… |
class TabbingHandler(object): |
39 | 44 | |
40 | 45 | screen = Gdk.Screen.get_default() |
41 | 46 | window = screen.get_root_window() |
42 | | keyboard_grab_result = Gdk.keyboard_grab(window, False) |
43 | | pointer_grab_result = Gdk.pointer_grab(window) |
| 47 | keyboard_grab_result = Gdk.keyboard_grab(window, False, Gdk.CURRENT_TIME) |
| 48 | # TODO: why we need grab the pointer? |
| 49 | pointer_grab_result = Gdk.pointer_grab(window, False, |
| 50 | _MOUSE_MASK, None, None, Gdk.CURRENT_TIME) |
44 | 51 | |
45 | 52 | self._tabbing = (keyboard_grab_result == Gdk.GrabStatus.SUCCESS and |
46 | 53 | pointer_grab_result == Gdk.GrabStatus.SUCCESS) |
47 | 54 | |
48 | 55 | # Now test that the modifier is still active to prevent race |
49 | 56 | # conditions. We also test if one of the grabs failed. |
50 | | mask = window.get_pointer()[2] |
51 | | if not self._tabbing or not (mask & self._modifier): |
| 57 | _pointer = window.get_pointer() |
| 58 | # mask is in position 3 now |
| 59 | mask = _pointer[3] |
| 60 | if not self._tabbing or (mask in (0, self._modifier)): |
52 | 61 | logging.debug('Releasing grabs again.') |
53 | 62 | |
54 | 63 | # ungrab keyboard/pointer if the grab was successfull. |
55 | 64 | if keyboard_grab_result == Gdk.GrabStatus.SUCCESS: |
56 | | Gdk.keyboard_ungrab() |
| 65 | Gdk.keyboard_ungrab(Gdk.CURRENT_TIME) |
57 | 66 | if pointer_grab_result == Gdk.GrabStatus.SUCCESS: |
58 | | Gdk.pointer_ungrab() |
| 67 | Gdk.pointer_ungrab(Gdk.CURRENT_TIME) |
59 | 68 | |
60 | 69 | self._tabbing = False |
61 | 70 | else: |