def setup_xi(self): if self.client.server_input_devices not in ("xi", "uinput"): log.info("server does not support xi input devices") if self.client.server_input_devices: log.info(" server uses: %s", self.client.server_input_devices) return try: from xpra.gtk_common.error import xsync with xsync: assert X11WindowBindings, "no X11 window bindings" assert X11XI2Bindings, "no XI2 window bindings" X11XI2Bindings().gdk_inject() self.init_x11_filter() XI2 = X11XI2Bindings() XI2.select_xi2_events() if self.client.server_input_devices: XI2.connect(0, "XI_HierarchyChanged", self.do_xi_devices_changed) devices = XI2.get_devices() if devices: self.client.send_input_devices("xi", devices) except Exception as e: log("enable_xi2()", exc_info=True) log.error("Error: cannot enable XI2 events") log.error(" %s", e) else: #register our enhanced event handlers: self.add_xi2_method_overrides()
def __init__(self, device, device_path): self.device = device self.device_path = bytestostr(device_path) self.wheel_delta = {} #the first event always goes MIA: #http://who-t.blogspot.co.at/2012/06/xi-21-protocol-design-issues.html #so synthesize a dummy one now: with xlog: from xpra.x11.bindings.xi2_bindings import X11XI2Bindings #pylint: disable=no-name-in-module xi2 = X11XI2Bindings() v = xi2.get_xi_version() log("XInput version %s", ".".join(str(x) for x in v)) if v <= (2, 2): self.wheel_motion(4, 1)
def __init__(self, window): log("XI2_Window(%s)", window) self.XI2 = X11XI2Bindings() self.X11Window = X11WindowBindings() self.window = window self.xid = window.get_window().xid self.windows = () window.connect("configure-event", self.configured) self.configured() #replace event handlers with XI2 version: self.do_motion_notify_event = window.do_motion_notify_event window.do_motion_notify_event = self.noop window.do_button_press_event = self.noop window.do_button_release_event = self.noop window.do_scroll_event = self.noop window.connect("destroy", self.cleanup)
def __init__(self, device, device_path): self.device = device self.device_path = device_path self.wheel_delta = {} #the first event always goes MIA: #http://who-t.blogspot.co.at/2012/06/xi-21-protocol-design-issues.html #so synthesize a dummy one now: try: with xsync: from xpra.x11.bindings.xi2_bindings import X11XI2Bindings xi2 = X11XI2Bindings() v = xi2.get_xi_version() log("XInput version %s", ".".join(str(x) for x in v)) if v<=(2, 2): self.wheel_motion(4, 1) except: log.warn("cannot query XInput protocol version", exc_info=True)
def do_setup_xi(self): if self.client.server_input_devices not in ("xi", "uinput"): xinputlog.info("server does not support xi input devices") if self.client.server_input_devices: log.info(" server uses: %s", self.client.server_input_devices) return False try: from xpra.gtk_common.error import xsync, XError assert X11WindowBindings, "no X11 window bindings" assert X11XI2Bindings, "no XI2 window bindings" XI2 = X11XI2Bindings() #this may fail when windows are being destroyed, #ie: when another client disconnects because we are stealing the session try: with xsync: XI2.select_xi2_events() except XError: self.xi_setup_failures += 1 xinputlog("select_xi2_events() failed, attempt %i", self.xi_setup_failures, exc_info=True) return self.xi_setup_failures < 10 #try again with xsync: XI2.gdk_inject() self.init_x11_filter() if self.client.server_input_devices: XI2.connect(0, "XI_HierarchyChanged", self.do_xi_devices_changed) devices = XI2.get_devices() if devices: self.client.send_input_devices("xi", devices) except Exception as e: xinputlog("enable_xi2()", exc_info=True) xinputlog.error("Error: cannot enable XI2 events") xinputlog.error(" %s", e) else: #register our enhanced event handlers: self.add_xi2_method_overrides() return False
def do_xi_devices_changed(self, event): log("do_xi_devices_changed(%s)", event) XI2 = X11XI2Bindings() devices = XI2.get_devices() if devices: self.client.send_input_devices("xi", devices)