Skip to content

Commit

Permalink
#3089 check that the client supports the function before calling it
Browse files Browse the repository at this point in the history
ie: the 'xpra top' doesn't support any windowing functions
  • Loading branch information
totaam committed Apr 12, 2021
1 parent b2bf7d2 commit 02b3865
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion xpra/server/shadow/shadow_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ def cmpv(lcd):
img = Image.frombuffer("RGBA", (w, h), pixels, "raw", "BGRA", 0, 1)
img.save("cursor-%#x.png" % serial, format="PNG")
for ss in self._server_sources.values():
ss.send_cursor()
if hasattr(ss, "send_cursor"):
ss.send_cursor()

def do_get_cursor_data(self):
#this method is overriden in subclasses with platform specific code
Expand Down
6 changes: 4 additions & 2 deletions xpra/x11/desktop_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from xpra.platform.paths import get_icon, get_icon_filename
from xpra.platform.gui import get_wm_name
from xpra.server import server_features
from xpra.server.source.windows_mixin import WindowsMixin
from xpra.gtk_common.gobject_util import one_arg_signal, no_arg_signal
from xpra.gtk_common.error import XError
from xpra.gtk_common.gtk_util import get_screen_sizes, get_root_size
Expand Down Expand Up @@ -489,8 +490,9 @@ def _window_resized_signaled(self, window):
x, y, w, h = window.get_geometry()
geomlog("window_resized_signaled(%s) geometry=%s", window, (x, y, w, h))
for ss in self._server_sources.values():
ss.resize_window(wid, window, w, h)
ss.damage(wid, window, 0, 0, w, h)
if isinstance(ss, WindowsMixin):
ss.resize_window(wid, window, w, h)
ss.damage(wid, window, 0, 0, w, h)


def send_initial_windows(self, ss, sharing=False):
Expand Down
17 changes: 12 additions & 5 deletions xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ def _x11_property_changed(self, window, event):
metadata = {"x11-property" : event}
wid = self._window_to_id[window]
for ss in self._server_sources.values():
if not isinstance(ss, WindowsMixin):
continue
ms = getattr(ss, "metadata_supported", ())
if "x11-property" in ms:
ss.send("window-metadata", wid, metadata)
Expand Down Expand Up @@ -702,7 +704,8 @@ def _or_window_geometry_changed(self, window, _pspec=None):
geomlog("or_window_geometry_changed: %s (window=%s)", geom, window)
wid = self._window_to_id[window]
for ss in self._server_sources.values():
ss.or_window_geometry(wid, window, x, y, w, h)
if isinstance(ss, WindowsMixin):
ss.or_window_geometry(wid, window, x, y, w, h)


def add_control_commands(self):
Expand All @@ -723,7 +726,8 @@ def show_all_windows(self):
def _show_desktop(self, wm, show):
log("show_desktop(%s, %s)", wm, show)
for ss in self._server_sources.values():
ss.show_desktop(show)
if isinstance(ss, WindowsMixin):
ss.show_desktop(show)


def _focus(self, server_source, wid, modifiers):
Expand Down Expand Up @@ -789,7 +793,8 @@ def _send_new_or_window_packet(self, window):
def _send_new_tray_window_packet(self, wid, window):
ww, wh = window.get_dimensions()
for ss in self._server_sources.values():
ss.new_tray(wid, window, ww, wh)
if isinstance(ss, WindowsMixin):
ss.new_tray(wid, window, ww, wh)
self.refresh_window(window)


Expand All @@ -812,7 +817,8 @@ def _window_grab(self, window, event):
return
self._has_grab = grab_id
for ss in self._server_sources.values():
ss.pointer_grab(self._has_grab)
if isinstance(ss, WindowsMixin):
ss.pointer_grab(self._has_grab)

def _window_ungrab(self, window, event):
grab_id = self._window_to_id.get(window, -1)
Expand All @@ -822,7 +828,8 @@ def _window_ungrab(self, window, event):
return
self._has_grab = 0
for ss in self._server_sources.values():
ss.pointer_ungrab(grab_id)
if isinstance(ss, WindowsMixin):
ss.pointer_ungrab(grab_id)


def _initiate_moveresize(self, window, event):
Expand Down
8 changes: 4 additions & 4 deletions xpra/x11/x11_server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from xpra.gtk_common.error import XError, xswallow, xsync, xlog, trap, verify_sync
from xpra.gtk_common.gtk_util import get_default_root_window
from xpra.server.server_uuid import save_uuid, get_uuid
from xpra.server.source.windows_mixin import WindowsMixin
from xpra.x11.vfb_util import parse_resolution
from xpra.x11.fakeXinerama import find_libfakeXinerama, save_fakeXinerama_config, cleanup_fakeXinerama
from xpra.x11.gtk_x11.prop import prop_get, prop_set
Expand Down Expand Up @@ -787,7 +788,6 @@ def do_xpra_cursor_event(self, event):
return
cursorlog("cursor_event: %s", event)
self.last_cursor_serial = event.cursor_serial
from xpra.server.source.windows_mixin import WindowsMixin
for ss in self._server_sources.values():
if isinstance(ss, WindowsMixin):
ss.send_cursor()
Expand Down Expand Up @@ -816,8 +816,9 @@ def do_xpra_xkb_event(self, event):
#so we use wid=0 for that:
wid = 0
for ss in self._server_sources.values():
name = strtobytes(event.bell_name or "")
ss.bell(wid, event.device, event.percent, event.pitch, event.duration, event.bell_class, event.bell_id, name)
if isinstance(ss, WindowsMixin):
name = strtobytes(event.bell_name or "")
ss.bell(wid, event.device, event.percent, event.pitch, event.duration, event.bell_class, event.bell_id, name)


def _bell_signaled(self, wm, event):
Expand All @@ -828,7 +829,6 @@ def _bell_signaled(self, wm, event):
if event.window!=get_default_root_window() and event.window_model is not None:
wid = self._window_to_id.get(event.window_model, 0)
log("_bell_signaled(%s,%r) wid=%s", wm, event, wid)
from xpra.server.source.windows_mixin import WindowsMixin
for ss in self._server_sources.values():
if isinstance(ss, WindowsMixin):
name = strtobytes(event.bell_name or "")
Expand Down

0 comments on commit 02b3865

Please sign in to comment.