Python Xlib.X.CurrentTime() Examples

The following are 23 code examples of Xlib.X.CurrentTime(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module Xlib.X , or try the search function .
Example #1
Source File: main.py    From inkscape-shortcut-manager with MIT License 6 votes vote down vote up
def listen(self):
        self.grab()
        while True:
            evt = self.disp.next_event()
            if evt.type in [X.KeyPress, X.KeyRelease]:
                keycode = evt.detail
                keysym = self.disp.keycode_to_keysym(keycode, 0)
                char = XK.keysym_to_string(keysym)
                self.disp.allow_events(X.ReplayKeyboard, X.CurrentTime)

                self.mode(self, evt, char)

            if evt.type == X.DestroyNotify:
                if evt.window.id == self.id:
                    self.ungrab()
                    return 
Example #2
Source File: randr.py    From python-xlib with GNU Lesser General Public License v2.1 6 votes vote down vote up
def set_screen_config(self, size_id, rotation, config_timestamp, rate=0, timestamp=X.CurrentTime):
    """Sets the screen to the specified size, rate, rotation and reflection.

    rate can be 0 to have the server select an appropriate rate.

    """
    return SetScreenConfig(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        drawable=self,
        timestamp=timestamp,
        config_timestamp=config_timestamp,
        size_id=size_id,
        rotation=rotation,
        rate=rate,
        ) 
Example #3
Source File: randr.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 6 votes vote down vote up
def set_panning(self, crtc, left, top, width, height, track_left, track_top, track_width, track_height, border_left, border_top, border_width, border_height, timestamp=X.CurrentTime):
    return SetPanning (
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        crtc=crtc,
        left=left,
        top=top,
        width=width,
        height=height,
        track_left=track_left,
        track_top=track_top,
        track_width=track_width,
        track_height=track_height,
        border_left=border_left,
        border_top=border_top,
        border_width=border_width,
        border_height=border_height,
        timestamp=timestamp,
        ) 
Example #4
Source File: randr.py    From python-xlib with GNU Lesser General Public License v2.1 6 votes vote down vote up
def set_panning(self, crtc, left, top, width, height, track_left, track_top, track_width, track_height, border_left, border_top, border_width, border_height, timestamp=X.CurrentTime):
    return SetPanning (
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        crtc=crtc,
        left=left,
        top=top,
        width=width,
        height=height,
        track_left=track_left,
        track_top=track_top,
        track_width=track_width,
        track_height=track_height,
        border_left=border_left,
        border_top=border_top,
        border_width=border_width,
        border_height=border_height,
        timestamp=timestamp,
        ) 
Example #5
Source File: randr.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 6 votes vote down vote up
def set_screen_config(self, size_id, rotation, config_timestamp, rate=0, timestamp=X.CurrentTime):
    """Sets the screen to the specified size, rate, rotation and reflection.

    rate can be 0 to have the server select an appropriate rate.

    """
    return SetScreenConfig(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        drawable=self,
        timestamp=timestamp,
        config_timestamp=config_timestamp,
        size_id=size_id,
        rotation=rotation,
        rate=rate,
        ) 
Example #6
Source File: interface.py    From autokey with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #7
Source File: interface.py    From autokey with GNU General Public License v3.0 6 votes vote down vote up
def __sendKeyReleaseEvent(self, keyCode, modifiers, theWindow=None):
        if theWindow is None:
            focus = self.localDisplay.get_input_focus().focus
        else:
            focus = theWindow
        keyEvent = event.KeyRelease(
                                  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) 
Example #8
Source File: x11.py    From darkc0de-old-stuff with GNU General Public License v3.0 6 votes vote down vote up
def sendKey(window, keycode, modifiers=0, released=True):
    if released:
        type = KeyRelease
        event_class = KeyReleaseEvent
    else:
        type = KeyPress
        event_class = KeyPressEvent
    event = event_class(
        type=type,
        detail=keycode,
        time=CurrentTime,
        root=NONE,
        window=window,
        child=NONE,
        root_x=0,
        root_y=0,
        event_x=0,
        event_y=0,
        state=modifiers,
        same_screen=1)
    window.send_event(event)
    window.display.flush() 
Example #9
Source File: viberwrapper-indicator.py    From viberwrapper-indicator with GNU General Public License v2.0 5 votes vote down vote up
def mousebutton(self, window, button=1, is_press=True):
        XButtons = {
            1: X.Button1,
            2: X.Button2,
            3: X.Button3,
            4: X.Button4,
            5: X.Button5
        }

        XButtonMasks = {
            1: X.Button1MotionMask,
            2: X.Button2MotionMask,
            3: X.Button3MotionMask,
            4: X.Button4MotionMask,
            5: X.Button5MotionMask
        }

        XEvent = {
            True: Xlib.protocol.event.ButtonPress,
            False: Xlib.protocol.event.ButtonRelease
        }

        root_x, root_y = self.get_mouse_location()
        state = self.get_input_state()
        x, y = self.translate_coordinates(window, self.root, root_x, root_y)

        if not is_press:
            state |= XButtonMasks[button]


        XEventFunction = XEvent[is_press]
        mouse_event = XEventFunction(detail=XButtons[button],
                                     root=self.root, root_x=root_x, root_y=root_y,
                                     window=window, event_x=x, event_y=y,
                                     same_screen=1, state=state,
                                     time=X.CurrentTime, child=0)

        window.send_event(event=mouse_event, event_mask=X.ButtonPressMask, propagate=1) 
Example #10
Source File: main.py    From inkscape-shortcut-manager with MIT License 5 votes vote down vote up
def event(self, name, detail, state):
        return name(
            time=X.CurrentTime,
            root=self.root,
            window=self.inkscape,
            same_screen=0, child=Xlib.X.NONE,
            root_x=0, root_y=0, event_x=0, event_y=0,
            state=state,
            detail=detail
        ) 
Example #11
Source File: ewmh.py    From deepin-remote-assistance with GNU General Public License v3.0 5 votes vote down vote up
def setActiveWindow(self, win):
		"""Set the given window active (property _NET_ACTIVE_WINDOW)
		
		:param win: the window object"""
		self._setProperty('_NET_ACTIVE_WINDOW', [1, X.CurrentTime, win.id], win) 
Example #12
Source File: ewmh.py    From deepin-remote-assistance with GNU General Public License v3.0 5 votes vote down vote up
def setCurrentDesktop(self, i):
		"""Set the current desktop (property _NET_CURRENT_DESKTOP).
		
		:param i: the desired desktop number"""
		self._setProperty('_NET_CURRENT_DESKTOP', [i, X.CurrentTime]) 
Example #13
Source File: xtest.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 5 votes vote down vote up
def fake_input(self, event_type, detail = 0, time = X.CurrentTime,
               root = X.NONE, x = 0, y = 0):

    FakeInput(display = self.display,
              opcode = self.display.get_extension_major(extname),
              event_type = event_type,
              detail = detail,
              time = time,
              root = root,
              x = x,
              y = y) 
Example #14
Source File: randr.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 5 votes vote down vote up
def set_crtc_config(self, crtc, config_timestamp, x, y, mode, rotation, outputs, timestamp=X.CurrentTime):
    return SetCrtcConfig (
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        crtc=crtc,
        config_timestamp=config_timestamp,
        x=x,
        y=y,
        mode=mode,
        rotation=rotation,
        outputs=outputs,
        timestamp=timestamp,
        ) 
Example #15
Source File: randr.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 5 votes vote down vote up
def _1_0set_screen_config(self, size_id, rotation, config_timestamp, timestamp=X.CurrentTime):
    """Sets the screen to the specified size and rotation.

    """
    return _1_0SetScreenConfig(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        drawable=self,
        timestamp=timestamp,
        config_timestamp=config_timestamp,
        size_id=size_id,
        rotation=rotation,
        ) 
Example #16
Source File: interface.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def __ungrabKeyboard(self):
        self.localDisplay.ungrab_keyboard(X.CurrentTime)
        self.localDisplay.flush() 
Example #17
Source File: interface.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def __grab_keyboard(self):
        focus = self.localDisplay.get_input_focus().focus
        focus.grab_keyboard(True, X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)
        self.localDisplay.flush() 
Example #18
Source File: xtest.py    From python-xlib with GNU Lesser General Public License v2.1 5 votes vote down vote up
def fake_input(self, event_type, detail = 0, time = X.CurrentTime,
               root = X.NONE, x = 0, y = 0):

    FakeInput(display = self.display,
              opcode = self.display.get_extension_major(extname),
              event_type = event_type,
              detail = detail,
              time = time,
              root = root,
              x = x,
              y = y) 
Example #19
Source File: randr.py    From python-xlib with GNU Lesser General Public License v2.1 5 votes vote down vote up
def set_crtc_config(self, crtc, config_timestamp, x, y, mode, rotation, outputs, timestamp=X.CurrentTime):
    return SetCrtcConfig (
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        crtc=crtc,
        config_timestamp=config_timestamp,
        x=x,
        y=y,
        mode=mode,
        rotation=rotation,
        outputs=outputs,
        timestamp=timestamp,
        ) 
Example #20
Source File: randr.py    From python-xlib with GNU Lesser General Public License v2.1 5 votes vote down vote up
def _1_0set_screen_config(self, size_id, rotation, config_timestamp, timestamp=X.CurrentTime):
    """Sets the screen to the specified size and rotation.

    """
    return _1_0SetScreenConfig(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        drawable=self,
        timestamp=timestamp,
        config_timestamp=config_timestamp,
        size_id=size_id,
        rotation=rotation,
        ) 
Example #21
Source File: _pyautogui_x11.py    From Dindo-Bot with MIT License 5 votes vote down vote up
def _getMouseEvent():
    screen = _display.screen()
    window = screen.root
    window.grab_pointer(1, X.PointerMotionMask|X.ButtonReleaseMask|X.ButtonPressMask, X.GrabModeAsync, X.GrabModeAsync, X.NONE, X.NONE, X.CurrentTime)
    e = _display.next_event()
    _display.ungrab_pointer(X.CurrentTime)

    if e.type == X.ButtonPress:
        e = MOUSE_EVENT[e.detail] + '_down'
    elif e.type == X.ButtonRelease:
        e = MOUSE_EVENT[e.detail] + '_up'
    else:
        e = 'moving'
    return e 
Example #22
Source File: ewmh.py    From pyewmh with GNU Lesser General Public License v3.0 5 votes vote down vote up
def setActiveWindow(self, win):
        """
        Set the given window active (property _NET_ACTIVE_WINDOW)

        :param win: the window object"""
        self._setProperty('_NET_ACTIVE_WINDOW', [1, X.CurrentTime, win.id],
                          win) 
Example #23
Source File: ewmh.py    From pyewmh with GNU Lesser General Public License v3.0 5 votes vote down vote up
def setCurrentDesktop(self, i):
        """
        Set the current desktop (property _NET_CURRENT_DESKTOP).

        :param i: the desired desktop number"""
        self._setProperty('_NET_CURRENT_DESKTOP', [i, X.CurrentTime])