Ticket #3895: tabbinghandler.patch

File tabbinghandler.patch, 2.5 KB (added by manuq, 9 years ago)

Partial, unfinished patch.

  • src/jarabe/view/tabbinghandler.py

    diff --git a/src/jarabe/view/tabbinghandler.py b/src/jarabe/view/tabbinghandler.py
    index 0d42c3f..6aefa06 100644
    a b class TabbingHandler(object): 
    3333        self._modifier = modifier
    3434        self._timeout = None
    3535
     36        display = Gdk.Display.get_default()
     37        device_manager = display.get_device_manager()
     38        self._devices = device_manager.list_devices(Gdk.DeviceType.MASTER)
     39
    3640    def _start_tabbing(self):
    3741        if not self._tabbing:
    3842            logging.debug('Grabing the input.')
    3943
    4044            screen = Gdk.Screen.get_default()
    4145            window = screen.get_root_window()
    42             keyboard_grab_result = Gdk.keyboard_grab(window, False)
    43             pointer_grab_result = Gdk.pointer_grab(window)
    4446
    45             self._tabbing = (keyboard_grab_result == Gdk.GrabStatus.SUCCESS and
    46                              pointer_grab_result == Gdk.GrabStatus.SUCCESS)
     47            self._tabbing = True
     48            for device in self._devices:
     49                result = device.grab(window, Gdk.GrabOwnership.WINDOW, False,
     50                                     Gdk.EventMask.ALL_EVENTS_MASK, None,
     51                                     Gdk.CURRENT_TIME)
     52                if result != Gdk.GrabStatus.SUCCESS:
     53                    self._tabbing = False
     54                    break
    4755
    4856            # Now test that the modifier is still active to prevent race
    4957            # conditions. We also test if one of the grabs failed.
    50             mask = window.get_pointer()[2]
     58            mask = window.get_pointer()[3]
    5159            if not self._tabbing or not (mask & self._modifier):
    5260                logging.debug('Releasing grabs again.')
    5361
    5462                # ungrab keyboard/pointer if the grab was successfull.
    55                 if keyboard_grab_result == Gdk.GrabStatus.SUCCESS:
    56                     Gdk.keyboard_ungrab()
    57                 if pointer_grab_result == Gdk.GrabStatus.SUCCESS:
    58                     Gdk.pointer_ungrab()
     63                for device in self._devices:
     64                    device.ungrab(Gdk.CURRENT_TIME)
    5965
    6066                self._tabbing = False
    6167            else:
    class TabbingHandler(object): 
    134140            next_activity.get_window().activate(event_time)
    135141
    136142    def stop(self, event_time):
    137         Gdk.keyboard_ungrab()
    138         Gdk.pointer_ungrab()
     143        for device in self._devices:
     144            device.ungrab(event_time)
    139145        self._tabbing = False
    140146
    141147        self._frame.hide()