Skip to content

Commit

Permalink
#1658: don't process pointer events if they fall outside the window: …
Browse files Browse the repository at this point in the history
…used by desktop and shadow servers to ignore events that land on the edge when the pointer events are clipped to the vfb

git-svn-id: https://xpra.org/svn/Xpra/trunk@19615 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 11, 2018
1 parent d70c272 commit 7ad593e
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/xpra/platform/darwin/shadow_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def do_process_mouse_common(self, proto, wid, pointer, *args):
assert proto in self._server_sources
assert wid in self._id_to_window
CG.CGWarpMouseCursorPosition(pointer)
return pointer

def fake_key(self, keycode, press):
e = CG.CGEventCreateKeyboardEvent(None, keycode, press)
Expand All @@ -176,7 +177,8 @@ def fake_key(self, keycode, press):
def do_process_button_action(self, proto, wid, button, pressed, pointer, modifiers, *args):
self._update_modifiers(proto, wid, modifiers)
pointer = self._process_mouse_common(proto, wid, pointer)
self.button_action(pointer, button, pressed, -1, *args)
if pointer:
self.button_action(pointer, button, pressed, -1, *args)

def button_action(self, pointer, button, pressed, _deviceid=-1, *args):
if button<=3:
Expand Down
6 changes: 4 additions & 2 deletions src/xpra/platform/win32/shadow_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ def do_process_mouse_common(self, proto, wid, pointer, *_args):
log("SetPhysicalCursorPos%s failed", pointer, exc_info=True)
log.error("Error: failed to move the cursor:")
log.error(" %s", e)
return pointer

def clear_keys_pressed(self):
keystate = (BYTE*256)()
Expand Down Expand Up @@ -500,8 +501,9 @@ def fake_key(self, keycode, press):
def do_process_button_action(self, proto, wid, button, pressed, pointer, modifiers, *args):
self._update_modifiers(proto, wid, modifiers)
pointer = self._process_mouse_common(proto, wid, pointer)
self._server_sources.get(proto).user_event()
self.button_action(pointer, button, pressed, -1, *args)
if pointer:
self._server_sources.get(proto).user_event()
self.button_action(pointer, button, pressed, -1, *args)

def button_action(self, pointer, button, pressed, deviceid=-1, *args):
event = BUTTON_EVENTS.get((button, pressed))
Expand Down
13 changes: 8 additions & 5 deletions src/xpra/server/mixins/input_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,15 @@ def _adjust_pointer(self, proto, wid, pointer):

def _process_mouse_common(self, proto, wid, pointer, *args):
pointer = self._adjust_pointer(proto, wid, pointer)
if not pointer:
return None
#TODO: adjust args too
self.do_process_mouse_common(proto, wid, pointer, *args)
return pointer
if self.do_process_mouse_common(proto, wid, pointer, *args):
return pointer
return None

def do_process_mouse_common(self, proto, wid, pointer, *args):
pass
return pointer

def _process_button_action(self, proto, packet):
mouselog("process_button_action(%s, %s)", proto, packet)
Expand Down Expand Up @@ -375,8 +378,8 @@ def _process_pointer_position(self, proto, packet):
ss.mouse_last_position = pointer
if self.ui_driver and self.ui_driver!=ss.uuid:
return
self._update_modifiers(proto, wid, modifiers)
self._process_mouse_common(proto, wid, pointer, *packet[5:])
if self._process_mouse_common(proto, wid, pointer, *packet[5:]):
self._update_modifiers(proto, wid, modifiers)


######################################################################
Expand Down
17 changes: 11 additions & 6 deletions src/xpra/server/shadow/gtk_shadow_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,19 @@ def makeRootWindowModels(self):


def _adjust_pointer(self, proto, wid, pointer):
window = self._id_to_window.get(wid)
if not window:
return None
pointer = super(GTKShadowServerBase, self)._adjust_pointer(proto, wid, pointer)
#the window may be at an offset (multi-window for multi-monitor):
window = self._id_to_window.get(wid)
if window:
ox, oy = window.geometry[:2]
x, y = pointer
return x+ox, y+oy
return pointer
wx, wy, ww, wh = window.geometry
#or maybe the pointer is off-screen:
x, y = pointer
ax = x+wx
ay = y+wy
if ax<0 or ax>=ww or ay<0 or ay>=wh:
return None
return ax, ay

def get_pointer_position(self):
return self.root.get_pointer()[-3:-1]
Expand Down
1 change: 1 addition & 0 deletions src/xpra/x11/bindings/randr_bindings.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ cdef class _RandRBindings(_X11CoreBindings):
return False

def check_randr_sizes(self):
return True
#check for wayland, which has no sizes:
#(and we wouldn't be able to set screen resolutions)
cdef Window window
Expand Down
16 changes: 14 additions & 2 deletions src/xpra/x11/desktop_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ def _process_configure_window(self, proto, packet):
pwid = packet[10]
pointer = packet[11]
modifiers = packet[12]
self._update_modifiers(proto, wid, modifiers)
self._process_mouse_common(proto, pwid, pointer)
if self._process_mouse_common(proto, pwid, pointer):
self._update_modifiers(proto, wid, modifiers)
#some "configure-window" packets are only meant for metadata updates:
skip_geometry = len(packet)>=10 and packet[9]
window = self._id_to_window.get(wid)
Expand All @@ -539,6 +539,18 @@ def _process_configure_window(self, proto, packet):
self._damage(window, 0, 0, w, h)


def _adjust_pointer(self, proto, wid, pointer):
window = self._id_to_window.get(wid)
if not window:
return None
pointer = super(XpraDesktopServer, self)._adjust_pointer(proto, wid, pointer)
#maybe the pointer is off-screen:
ww, wh = window.get_dimensions()
x, y = pointer
if x<0 or x>=ww or y<0 or y>=wh:
return None
return pointer

def _move_pointer(self, wid, pos, *args):
if wid>=0:
window = self._id_to_window.get(wid)
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,10 @@ def _process_configure_window(self, proto, packet):
pwid = packet[10]
pointer = packet[11]
modifiers = packet[12]
#only update modifiers if the window is in focus:
if self._has_focus==wid:
self._update_modifiers(proto, wid, modifiers)
self._process_mouse_common(proto, pwid, pointer)
if self._process_mouse_common(proto, pwid, pointer):
#only update modifiers if the window is in focus:
if self._has_focus==wid:
self._update_modifiers(proto, wid, modifiers)
if window.is_tray():
assert self._tray
if not skip_geometry:
Expand Down
13 changes: 7 additions & 6 deletions src/xpra/x11/x11_server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,9 @@ def _process_wheel_motion(self, proto, packet):
assert self.pointer_device.has_precise_wheel()
wid, button, distance, pointer, modifiers, _buttons = packet[1:7]
with xsync:
self._update_modifiers(proto, wid, modifiers)
self.do_process_mouse_common(proto, wid, pointer)
self.pointer_device.wheel_motion(button, distance/1000.0)
if self.do_process_mouse_common(proto, wid, pointer):
self._update_modifiers(proto, wid, modifiers)
self.pointer_device.wheel_motion(button, distance/1000.0)

def get_pointer_device(self, deviceid):
#mouselog("get_pointer_device(%i) input_devices_data=%s", deviceid, self.input_devices_data)
Expand All @@ -882,7 +882,7 @@ def _move_pointer(self, wid, pos, deviceid=-1, *args):
def do_process_mouse_common(self, proto, wid, pointer, deviceid=-1, *args):
log("do_process_mouse_common%s", tuple([proto, wid, pointer, deviceid]+list(args)))
if self.readonly:
return
return None
pos = self.root_window.get_pointer()[-3:-1]
uuid = None
if proto:
Expand All @@ -893,6 +893,7 @@ def do_process_mouse_common(self, proto, wid, pointer, deviceid=-1, *args):
self.last_mouse_user = uuid
with xswallow:
self._move_pointer(wid, pointer, deviceid, *args)
return pointer

def _update_modifiers(self, proto, wid, modifiers):
if self.readonly:
Expand All @@ -908,8 +909,8 @@ def _update_modifiers(self, proto, wid, modifiers):
def do_process_button_action(self, proto, wid, button, pressed, pointer, modifiers, _buttons=[], deviceid=-1, *_args):
self._update_modifiers(proto, wid, modifiers)
#TODO: pass extra args
self._process_mouse_common(proto, wid, pointer, deviceid)
self.button_action(pointer, button, pressed, deviceid)
if self._process_mouse_common(proto, wid, pointer, deviceid):
self.button_action(pointer, button, pressed, deviceid)

def button_action(self, _pointer, button, pressed, deviceid=-1, *args):
device = self.get_pointer_device(deviceid)
Expand Down

0 comments on commit 7ad593e

Please sign in to comment.