Skip to content

Commit

Permalink
#1995 split pure-X11 event parsing into a new module
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed May 21, 2023
1 parent 70323c0 commit 5f2634d
Show file tree
Hide file tree
Showing 27 changed files with 677 additions and 718 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ tests/unittests/test-file*
/xpra/x11/bindings/xwayland.c
/xpra/x11/bindings/posix_display_source.c
/xpra/x11/bindings/xi2_bindings.c
/xpra/x11/bindings/events.c
/xpra/x11/gtk3/gdk_display_source.c
/xpra/x11/gtk3/gdk_bindings.c
/xpra/x11/gtk_x11/gdk_display_source.c
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ def clean():
"xpra/x11/bindings/wait_for_x_server.c",
"xpra/x11/bindings/keyboard_bindings.c",
"xpra/x11/bindings/display_source.c",
"xpra/x11/bindings/events.c",
"xpra/x11/bindings/window_bindings.c",
"xpra/x11/bindings/randr_bindings.c",
"xpra/x11/bindings/res_bindings.c",
Expand Down Expand Up @@ -2074,6 +2075,7 @@ def add_cython_ext(*_args, **_kwargs): # pylint: disable=function-redefined

toggle_packages(x11_ENABLED, "xpra.x11", "xpra.x11.bindings")
if x11_ENABLED:
ace("xpra.x11.bindings.events", "x11")
ace("xpra.x11.bindings.xwait", "x11")
ace("xpra.x11.bindings.wait_for_x_server", "x11")
ace("xpra.x11.bindings.display_source", "x11")
Expand Down
2 changes: 1 addition & 1 deletion xpra/client/gtk_base/example/window_focus.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def has_toplevel_focus(window, _event):
if POSIX and not OSX:
from xpra.gtk_common.error import xlog
from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source
from xpra.x11.gtk_x11.gdk_bindings import init_x11_filter
from xpra.x11.gtk3.gdk_bindings import init_x11_filter
from xpra.x11.bindings.window_bindings import X11WindowBindings #pylint: disable=no-name-in-module
from xpra.os_util import is_Wayland
if not is_Wayland():
Expand Down
2 changes: 1 addition & 1 deletion xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def do_init_focus(self):
#hook up the X11 gdk event notifications so we can get focus-out when grabs are active:
if is_X11():
try:
from xpra.x11.gtk_x11.gdk_bindings import add_event_receiver
from xpra.x11.gtk3.gdk_bindings import add_event_receiver
except ImportError as e:
log("do_init_focus()", exc_info=True)
if not ds_inited():
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk_common/gtk3/gdk_bindings.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cdef extern from "pygobject-3.0/pygobject.h":
GType gtype


def get_display_for(obj):
def get_display_for(obj) -> Gtk.Display:
if obj is None:
raise TypeError("Cannot get a display: instance is None!")
if isinstance(obj, Gdk.Display):
Expand Down
4 changes: 2 additions & 2 deletions xpra/platform/posix/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def init_x11_filter(self):
if self.x11_filter:
return
try:
from xpra.x11.gtk_x11.gdk_bindings import init_x11_filter #@UnresolvedImport, @UnusedImport
from xpra.x11.gtk3.gdk_bindings import init_x11_filter #@UnresolvedImport, @UnusedImport
self.x11_filter = init_x11_filter()
log("x11_filter=%s", self.x11_filter)
except Exception as e:
Expand All @@ -644,7 +644,7 @@ def cleanup(self):
log("cleanup() xsettings_watcher=%s, root_props_watcher=%s", self._xsettings_watcher, self._root_props_watcher)
if self.x11_filter:
self.x11_filter = None
from xpra.x11.gtk_x11.gdk_bindings import cleanup_x11_filter #@UnresolvedImport, @UnusedImport
from xpra.x11.gtk3.gdk_bindings import cleanup_x11_filter #@UnresolvedImport, @UnusedImport
cleanup_x11_filter()
if self._xsettings_watcher:
self._xsettings_watcher.cleanup()
Expand Down
6 changes: 3 additions & 3 deletions xpra/x11/bindings/core_bindings.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ cdef class X11CoreBindingsInstance:
free(atoms_return)
assert s!=0, "failed to intern some atoms"

def get_xatom(self, str_or_int):
def get_xatom(self, str_or_int) -> Atom:
return self.xatom(str_or_int)

def XGetAtomName(self, Atom atom):
Expand All @@ -123,10 +123,10 @@ cdef class X11CoreBindingsInstance:
XFree(v)
return r

def get_error_text(self, code):
def get_error_text(self, code) -> str:
assert self.display!=NULL, "display is closed"
if type(code)!=int:
return code
return str(code)
cdef char[128] buffer
XGetErrorText(self.display, code, buffer, 128)
return (bytes(buffer[:128]).split(b"\0", 1)[0]).decode("latin1")
Expand Down
10 changes: 10 additions & 0 deletions xpra/x11/bindings/events.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file is part of Xpra.
# Copyright (C) 2023 Antoine Martin <[email protected]>
# 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 xpra.x11.bindings.xlib cimport Display, XEvent

cdef parse_xevent(Display *d, XEvent *e)
cdef init_x11_events(Display *display)
Loading

0 comments on commit 5f2634d

Please sign in to comment.