Ejemplo n.º 1
0
    def paste_xlib(self):

        window = self.display.get_input_focus().focus
        window.grab_keyboard(False, X.GrabModeAsync, X.GrabModeAsync,
                             X.CurrentTime)
        self.display.flush()
        key_press = event.KeyPress(detail=shared.keycode,
                                   time=X.CurrentTime,
                                   root=self.root,
                                   window=window,
                                   child=X.NONE,
                                   root_x=0,
                                   root_y=0,
                                   event_x=0,
                                   event_y=0,
                                   state=X.ControlMask,
                                   same_screen=1)
        key_release = event.KeyRelease(detail=shared.keycode,
                                       time=X.CurrentTime,
                                       root=self.root,
                                       window=window,
                                       child=X.NONE,
                                       root_x=0,
                                       root_y=0,
                                       event_x=0,
                                       event_y=0,
                                       state=X.ControlMask,
                                       same_screen=1)
        window.send_event(key_press)
        window.send_event(key_release)
        self.display.ungrab_keyboard(X.CurrentTime)
        self.display.flush()
Ejemplo n.º 2
0
    def send_key(self, key, state, mask):

        if state is KeyState.PRESSED:
            ev = xevent.KeyPress(time=X.CurrentTime,
                                 root=self.root,
                                 window=self.xwindow,
                                 same_screen=True,
                                 child=X.NONE,
                                 root_x=0,
                                 root_y=0,
                                 event_x=0,
                                 event_y=0,
                                 state=mask,
                                 detail=key.ec + self.translate.min_keycode)
            self.xwindow.send_event(ev)
        elif state is KeyState.RELEASED:
            ev = xevent.KeyRelease(time=X.CurrentTime,
                                   root=self.root,
                                   window=self.xwindow,
                                   same_screen=True,
                                   child=X.NONE,
                                   root_x=0,
                                   root_y=0,
                                   event_x=0,
                                   event_y=0,
                                   state=mask,
                                   detail=key.ec + self.translate.min_keycode)
            self.xwindow.send_event(ev)
        else:
            raise TypeError('Unsupported state')
        self.disp.flush()
Ejemplo n.º 3
0
    def press_button(self, keycode):
        #Search for the focused window
        self.wnd = self.disp.get_input_focus().focus

        if (self.wnd) == None:
            print 'Error assigning the focused window! Existing...'
            os._exit(0)

        self.keyevtpress = event.KeyPress(
            type=X.KeyPress,
            display=self.disp,
            detail=keycode,
            time=X.CurrentTime,
            root=self.root,
            window=self.wnd,
            child=X.NONE,
            root_x=1,
            root_y=1,
            event_x=1,
            event_y=1,
            state=0,
            same_screen=1,
        )
        self.disp.send_event(self.wnd, self.keyevtpress, propagate=True)
        self.disp.flush()
Ejemplo n.º 4
0
 def _send_key_press(self, keycode, state):
     key_press = event.KeyPress(detail=keycode,
                                time=X.CurrentTime,
                                root=self.static_root,
                                window=self.static_window,
                                child=X.NONE,
                                root_x=0,
                                root_y=0,
                                event_x=0,
                                event_y=0,
                                state=state,
                                same_screen=1)
     self.static_window.send_event(key_press)
Ejemplo n.º 5
0
 def __sendKeyPressEvent(self, keyCode, modifiers, theWindow=None):
     if theWindow is None:
         focus = self.localDisplay.get_input_focus().focus
     else:
         focus = theWindow
     keyEvent = event.KeyPress(detail=keyCode,
                               time=X.CurrentTime,
                               root=self.rootWindow,
                               window=focus,
                               child=X.NONE,
                               root_x=1,
                               root_y=1,
                               event_x=1,
                               event_y=1,
                               state=modifiers,
                               same_screen=1)
     focus.send_event(keyEvent)
Ejemplo n.º 6
0
class Command(ipc.Server):
    def __init__(self, fname, qtile):
        ipc.Server.__init__(self, fname, self.call)
        self.qtile = qtile

    def call(self, data):
        name, args, kwargs = data
        cmd = getattr(self, "cmd_" + name, None)
        if cmd:
            return cmd(self.qtile, *args, **kwargs)
        else:
            return "Unknown command: %s" % cmd

    def cmd_status(self, qtile):
        """
            Return "OK" if Qtile is running.
        """
        return "OK"

    def cmd_clientcount(self, qtile):
        """
            Return number of clients in all groups.
        """
        return len(qtile.clientMap)

    def cmd_groupinfo(self, qtile, name):
        """
            Return group information.
        """
        for i in qtile.groups:
            if i.name == name:
                return i.info()
        else:
            return None

    def cmd_focusnext(self, qtile):
        qtile.currentScreen.group.focusNext()

    def cmd_focusprevious(self, qtile):
        qtile.currentScreen.group.focusPrevious()

    def cmd_screencount(self, qtile):
        return len(qtile.screens)

    def cmd_pullgroup(self, qtile, group, screen=None):
        if not screen:
            screen = qtile.currentScreen
        group = qtile.groupMap.get(group)
        if not group:
            return "No such group"
        elif group.screen == screen:
            return
        elif group.screen:
            g = screen.group
            s = group.screen
            s.setGroup(g)
            screen.setGroup(group)
        else:
            screen.setGroup(group)

    def cmd_simulate_keypress(self, qtile, modifiers, key):
        """
            Simulates a keypress on the focused window.
        """
        keysym = XK.string_to_keysym(key)
        if keysym == 0:
            return "Unknown key: %s" % key
        keycode = qtile.display.keysym_to_keycode(keysym)
        try:
            mask = utils.translateMasks(modifiers)
        except manager.QTileError, v:
            return str(v)
        if qtile.currentScreen.group.focusClient:
            win = qtile.currentScreen.group.focusClient.window
        else:
            win = qtile.root
        e = event.KeyPress(
            type=X.KeyPress,
            state=mask,
            detail=keycode,
            root=qtile.root,
            window=win,
            child=X.NONE,
            time=X.CurrentTime,
            root_x=1,
            root_y=1,
            event_x=1,
            event_y=1,
            same_screen=1,
        )
        win.send_event(e,
                       X.KeyPressMask | X.SubstructureNotifyMask,
                       propagate=True)
        # I guess we could abstract this out into a cmd_sync command to
        # facilitate testing...
        qtile.display.sync()