Skip to content

Commit

Permalink
rate limit SetPhysicalCursorPos warnings
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@26239 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 3, 2020
1 parent 277c03b commit b95a62b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/xpra/platform/win32/shadow_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
from ctypes.wintypes import RECT, POINT, BYTE, MAX_PATH

from xpra.os_util import strtobytes
from xpra.os_util import strtobytes, monotonic_time
from xpra.util import envbool, prettify_plug_name, csv, XPRA_APP_ID, XPRA_IDLE_NOTIFICATION_ID
from xpra.scripts.config import InitException
from xpra.server.gtk_server_base import GTKServerBase
Expand Down Expand Up @@ -345,6 +345,7 @@ def __init__(self):
self.keycodes = {}
self.cursor_handle = None
self.cursor_data = None
self.cursor_errors = [0, 0]
if GetSystemMetrics(win32con.SM_SAMEDISPLAYFORMAT)==0:
raise InitException("all the monitors must use the same display format")
el = get_win32_event_listener()
Expand Down Expand Up @@ -472,14 +473,22 @@ def do_process_mouse_common(self, proto, wid, pointer, *_args):
#adjust pointer position for offset in client:
try:
x, y = pointer[:2]
assert SetPhysicalCursorPos(x, y)
if not SetPhysicalCursorPos(x, y):
#rate limit the warnings:
start, count = self.cursor_errors
now = monotonic_time()
elapsed = now-start
if count==0 or (count>1 and elapsed>10):
log.warn("Warning: cannot move cursor")
log.warn(" (%i events)", count+1)
self.cursor_errors = [now, 1]
else:
self.cursor_errors[1] = count+1

except Exception as e:
log("SetPhysicalCursorPos%s failed", pointer, exc_info=True)
log.error("Error: failed to move the cursor:")
if str(e).strip():
log.error(" %s", e)
else:
log.error(" %s", type(e))
log.error(" %s", e)
return pointer

def clear_keys_pressed(self):
Expand Down

0 comments on commit b95a62b

Please sign in to comment.