Skip to content

Commit

Permalink
#173 preparatory work:
Browse files Browse the repository at this point in the history
* move x11 filter intialization to xposix platform gui module
* move X11Event to common module we can import in other extensions
* add hooks to gdk_bindings so other modules can inject their event parsers (will be used by XInput2)
* make sure we check the return code of all extension query functions
* provide utility functions so other modules can inject event mappings and event names
* make sure we only add events if the event base is valid

git-svn-id: https://xpra.org/svn/Xpra/trunk@15792 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 3, 2017
1 parent 04b22af commit ee8c833
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 84 deletions.
16 changes: 16 additions & 0 deletions src/xpra/platform/xposix/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,30 @@ def __init__(self, client, opts):
self.upower_resuming_match = None
self.upower_sleeping_match = None
self.login1_match = None
self.x11_filter = None
if client.xsettings_enabled:
self.setup_xprops()
self.setup_dbus_signals()

def ready(self):
pass

def init_x11_filter(self):
if self.x11_filter:
return
try:
from xpra.x11.gtk2.gdk_bindings import init_x11_filter #@UnresolvedImport
self.x11_filter = init_x11_filter()
log("x11_filter=%s", self.x11_filter)
except:
self.x11_filter = None

def cleanup(self):
log("cleanup() xsettings_watcher=%s, root_props_watcher=%s", self._xsettings_watcher, self._root_props_watcher)
if self.x11_filter:
from xpra.x11.gtk2.gdk_bindings import cleanup_x11_filter #@UnresolvedImport
self.x11_filter = None
cleanup_x11_filter()
if self._xsettings_watcher:
self._xsettings_watcher.cleanup()
self._xsettings_watcher = None
Expand Down Expand Up @@ -617,6 +632,7 @@ def do_setup_xprops(self, *args):
return
ROOT_PROPS = ["RESOURCE_MANAGER", "_NET_WORKAREA", "_NET_CURRENT_DESKTOP"]
try:
self.init_x11_filter()
from xpra.x11.xsettings import XSettingsWatcher
from xpra.x11.xroot_props import XRootPropWatcher
if self._xsettings_watcher is None:
Expand Down
27 changes: 27 additions & 0 deletions src/xpra/x11/gtk2/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file is part of Xpra.
# Copyright (C) 2017 Antoine Martin <antoine@devloop.org.uk>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

from gtk import gdk

# Just to make it easier to pass around and have a helpful debug logging.
# Really, just a python objects where we can stick random bags of attributes.
class X11Event(object):
def __init__(self, name):
self.name = name

def __repr__(self):
d = {}
for k,v in self.__dict__.items():
if k=="name":
continue
elif k=="serial":
d[k] = "%#x" % v
elif v and type(v)==gdk.Window:
d[k] = "%#x" % v.xid
elif v and type(v)==gdk.Display:
d[k] = "%s" % v.get_name()
else:
d[k] = v
return "<X11:%s %r>" % (self.name, d)
Loading

0 comments on commit ee8c833

Please sign in to comment.