Skip to content

Commit

Permalink
also scale cursors we load by name
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@24131 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 14, 2019
1 parent df1cdce commit 524fcf7
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/xpra/client/gtk_base/gtk_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,16 +812,17 @@ def make_cursor(self, cursor_data):
display = Gdk.Display.get_default()
cursorlog("make_cursor: has-name=%s, has-cursor-types=%s, xscale=%s, yscale=%s, USE_LOCAL_CURSORS=%s",
len(cursor_data)>=10, bool(cursor_types), self.xscale, self.yscale, USE_LOCAL_CURSORS)
#named cursors cannot be scaled
#(round to 10 to compare so 0.95 and 1.05 are considered the same as 1.0, no scaling):
if len(cursor_data)>=10 and cursor_types and iround(self.xscale*10)==10 and iround(self.yscale*10)==10:
pixbuf = None
if len(cursor_data)>=10 and cursor_types:
cursor_name = bytestostr(cursor_data[9])
if cursor_name and USE_LOCAL_CURSORS:
gdk_cursor = cursor_types.get(cursor_name.upper())
if gdk_cursor is not None:
cursorlog("setting new cursor by name: %s=%s", cursor_name, gdk_cursor)
try:
return Gdk.Cursor.new_for_display(display, gdk_cursor)
cursor = Gdk.Cursor.new_for_display(display, gdk_cursor)
cursorlog("Cursor.new_for_display(%s, %s)=%s", display, gdk_cursor, cursor)
pixbuf = cursor.get_image()
cursorlog("image=%s", pixbuf)
except TypeError as e:
log("new_Cursor_for_display(%s, %s)", display, gdk_cursor, exc_info=True)
if first_time("cursor:%s" % cursor_name.upper()):
Expand All @@ -836,12 +837,17 @@ def make_cursor(self, cursor_data):
if encoding!="raw":
cursorlog.warn("Warning: invalid cursor encoding: %s", encoding)
return None
if len(pixels)<w*h*4:
cursorlog.warn("Warning: not enough pixels provided in cursor data")
cursorlog.warn(" %s needed and only %s bytes found:", w*h*4, len(pixels))
cursorlog.warn(" '%s')", repr_ellipsized(hexstr(pixels)))
return None
pixbuf = get_pixbuf_from_data(pixels, True, w, h, w*4)
if not pixbuf:
if len(pixels)<w*h*4:
cursorlog.warn("Warning: not enough pixels provided in cursor data")
cursorlog.warn(" %s needed and only %s bytes found:", w*h*4, len(pixels))
cursorlog.warn(" '%s')", repr_ellipsized(hexstr(pixels)))
return None
pixbuf = get_pixbuf_from_data(pixels, True, w, h, w*4)
else:
w = pixbuf.get_width()
h = pixbuf.get_height()
pixels = pixbuf.get_pixels()
x = max(0, min(xhot, w-1))
y = max(0, min(yhot, h-1))
csize = display.get_default_cursor_size()
Expand Down

0 comments on commit 524fcf7

Please sign in to comment.