Skip to content

Commit

Permalink
expose current shadow pointer position to clients - can be disabled w…
Browse files Browse the repository at this point in the history
…ith XPRA_POLL_POINTER=0

git-svn-id: https://xpra.org/svn/Xpra/trunk@15562 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 11, 2017
1 parent 863dade commit 9287df0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/xpra/server/shadow/gtk_shadow_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

from xpra.log import Logger
traylog = Logger("tray")
mouselog = Logger("mouse")

from xpra.util import envbool
from xpra.server.gtk_server_base import GTKServerBase
from xpra.server.shadow.shadow_server_base import ShadowServerBase

POLL_POINTER = envbool("XPRA_POLL_POINTER", True)


class GTKShadowServerBase(ShadowServerBase, GTKServerBase):

Expand All @@ -25,6 +29,12 @@ def __init__(self):
self.tray_widget = None
self.tray = False
self.tray_icon = None
#the pointer position timer:
self.last_pointer_position = None
self.pointer_position_timer = None
if POLL_POINTER:
self.pointer_position_timer = self.timeout_add(20, self.poll_pointer_position)


def init(self, opts):
GTKServerBase.init(self, opts)
Expand All @@ -39,6 +49,10 @@ def cleanup(self):
if tw:
self.tray_widget = None
tw.cleanup()
ppt = self.pointer_position_timer
if ppt:
self.pointer_position_timer = None
self.source_remove(ppt)
GTKServerBase.cleanup(self)


Expand All @@ -55,6 +69,20 @@ def last_client_exited(self):
GTKServerBase.last_client_exited(self)


def poll_pointer_position(self):
wid = self._window_to_id.get(self.root_window_model)
if not wid:
self.pointer_position_timer = None
return False
x, y, _ = self.root.get_pointer()
mouselog("poll_pointer_position() wid=%i, position=%s", wid, (x, y))
if self.last_pointer_position!=(x, y):
self.last_pointer_position = (x, y)
for ss in self._server_sources.values():
ss.update_mouse(wid, x, y, x, y)
return True


############################################################################
# system tray methods, mostly copied from the gtk client...
# (most of these should probably be moved to a common location instead)
Expand Down

0 comments on commit 9287df0

Please sign in to comment.