def release(self, x, y, button = 1): focus = display.get_input_focus().focus rel = focus.translate_coords(root, x, y) button_list = [None, X.Button1, X.Button3, X.Button2] try: mouseRealease = event.ButtonRelease( time=X.CurrentTime, root=root, window=focus, same_screen=1, child=X.NONE, root_x=x, root_y=y, event_x=rel.x, event_y=rel.y, state=1, detail=button_list[button] ) focus.send_event(mouseRealease) except: pass display.sync()
def send_button(self, position, button, state, mask): if state is KeyState.PRESSED: ev = xevent.ButtonPress(time=X.CurrentTime, root=self.root, window=self.xwindow, same_screen=True, child=X.NONE, root_x=0, root_y=0, event_x=position.x, event_y=position.y, state=mask, detail=self.rebuttonmap[button]) self.xwindow.send_event(ev) elif state is KeyState.RELEASED: ev = xevent.ButtonRelease(time=X.CurrentTime, root=self.root, window=self.xwindow, same_screen=True, child=X.NONE, root_x=0, root_y=0, event_x=position.x, event_y=position.y, state=mask, detail=self.rebuttonmap[button]) self.xwindow.send_event(ev) else: raise TypeError('Unsupported state') self.disp.flush()
def send_axis(self, position, value, axis, mask): if axis is PointerAxis.VERTICAL: if value < 0: button = 4 else: button = 5 elif axis is PointerAxis.HORIZONTAL: if value < 0: button = 6 else: button = 7 else: raise TypeError('Unsupported axis') pev = xevent.ButtonPress(time=X.CurrentTime, root=self.root, window=self.xwindow, same_screen=True, child=X.NONE, root_x=0, root_y=0, event_x=position.x, event_y=position.y, state=mask, detail=button) rev = xevent.ButtonRelease(time=X.CurrentTime, root=self.root, window=self.xwindow, same_screen=True, child=X.NONE, root_x=0, root_y=0, event_x=position.x, event_y=position.y, state=mask, detail=button) for i in range(abs(value)): self.xwindow.send_event(pev) self.xwindow.send_event(rev) self.disp.flush()