Skip to content

Commit

Permalink
#4318 backport poll-pointer support
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Sep 27, 2024
1 parent aa10de5 commit 83b53e4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions xpra/client/mixins/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
ICON_SHRINKAGE: int = envint("XPRA_ICON_SHRINKAGE", 75)
SAVE_WINDOW_ICONS: bool = envbool("XPRA_SAVE_WINDOW_ICONS", False)
SAVE_CURSORS: bool = envbool("XPRA_SAVE_CURSORS", False)
POLL_POINTER = envint("XPRA_POLL_POINTER", 0)

DRAW_LOG_FMT = "process_draw: %7i %8s for window %3i, sequence %8i, %4ix%-4i at %4i,%-4i" \
" using %6s encoding with options=%s"
Expand Down Expand Up @@ -237,6 +238,9 @@ def __init__(self):
self._suspended_at: float = 0
self._button_state = {}

self.poll_pointer_timer = 0
self.poll_pointer_position = -1, -1

def init(self, opts) -> None:
if opts.system_tray:
try:
Expand Down Expand Up @@ -340,6 +344,7 @@ def cleanup(self) -> None:
# (cleaner and needed when we run embedded in the client launcher)
self.destroy_all_windows()
self.cancel_lost_focus_timer()
self.cancel_poll_pointer_timer()
if dq:
dq.put(None)
dt = self._draw_thread
Expand Down Expand Up @@ -440,6 +445,11 @@ def parse_server_capabilities(self, c: typedict) -> bool:
# input devices:
self.server_input_devices = c.strget("input-devices")
self.server_precise_wheel = c.boolget("wheel.precise", False)
if POLL_POINTER:
if is_Wayland():
log.warn("Warning: pointer polling is unlikely to work under Wayland")
log.warn(" and may cause problems")
self.poll_pointer_timer = GLib.timeout_add(POLL_POINTER, self.poll_pointer)
return True

######################################################################
Expand Down Expand Up @@ -562,6 +572,22 @@ def send_input_devices(self, fmt, input_devices) -> None:
assert self.server_input_devices
self.send("input-devices", fmt, input_devices)

def poll_pointer(self) -> bool:
pos = self.get_mouse_position()
if pos != self.poll_pointer_position:
self.poll_pointer_position = pos
device_id = -1
wid = 0
mouselog(f"poll_pointer() updated position: {pos}")
self.send_mouse_position(device_id, wid, pos)
return True
def cancel_poll_pointer_timer(self) -> None:
ppt = self.poll_pointer_timer
if ppt:
self.poll_pointer_timer = 0
GLib.source_remove(ppt)


######################################################################
# cursor:
def _process_cursor(self, packet: PacketType) -> None:
Expand Down

0 comments on commit 83b53e4

Please sign in to comment.