From 81e1cd2a23598fc9635c4aba4aa0348e602a97ce Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 3 Jan 2018 06:07:07 +0000 Subject: [PATCH] #1707: also shrink the application icon to make more space git-svn-id: https://xpra.org/svn/Xpra/trunk@17836 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- .../client/gtk_base/gtk_client_window_base.py | 1 - src/xpra/client/ui_client_base.py | 24 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/xpra/client/gtk_base/gtk_client_window_base.py b/src/xpra/client/gtk_base/gtk_client_window_base.py index d2c1c79333..d5dc29341e 100644 --- a/src/xpra/client/gtk_base/gtk_client_window_base.py +++ b/src/xpra/client/gtk_base/gtk_client_window_base.py @@ -82,7 +82,6 @@ BREAK_MOVERESIZE = os.environ.get("XPRA_BREAK_MOVERESIZE", "Escape").split(",") MOVERESIZE_X11 = envbool("XPRA_MOVERESIZE_X11", POSIX) -ICON_OVERLAY = envbool("XPRA_ICON_OVERLAY", True) OSX_FOCUS_WORKAROUND = envbool("XPRA_OSX_FOCUS_WORKAROUND", True) SAVE_WINDOW_ICONS = envbool("XPRA_SAVE_WINDOW_ICONS", False) UNDECORATED_TRANSIENT_IS_OR = envint("XPRA_UNDECORATED_TRANSIENT_IS_OR", 1) diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index 8328bc330d..1cee899753 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -113,6 +113,7 @@ def add_legacy_names(codecs): DYNAMIC_TRAY_ICON = envbool("XPRA_DYNAMIC_TRAY_ICON", not OSX and not is_Ubuntu()) ICON_OVERLAY = envint("XPRA_ICON_OVERLAY", 50) +ICON_SHRINKAGE = envint("XPRA_ICON_SHRINKAGE", 75) SAVE_WINDOW_ICONS = envbool("XPRA_SAVE_WINDOW_ICONS", False) WEBCAM_ALLOW_VIRTUAL = envbool("XPRA_WEBCAM_ALLOW_VIRTUAL", False) @@ -3539,7 +3540,7 @@ def _window_icon_image(self, wid, width, height, coding, data): #adding the icon overlay (if enabled) from PIL import Image coding = bytestostr(coding) - iconlog("%s.update_icon(%s, %s, %s, %s bytes)", self, width, height, coding, len(data)) + iconlog("%s.update_icon(%s, %s, %s, %s bytes) ICON_SHRINKAGE=%s, ICON_OVERLAY=%s", self, width, height, coding, len(data), ICON_SHRINKAGE, ICON_OVERLAY) if coding == "premult_argb32": #we usually cannot do in-place and this is not performance critical from xpra.codecs.argb.argb import unpremultiply_argb #@UnresolvedImport data = unpremultiply_argb(data) @@ -3552,20 +3553,29 @@ def _window_icon_image(self, wid, width, height, coding, data): assert img.mode in ("RGB", "RGBA"), "invalid image mode: %s" % img.mode has_alpha = img.mode=="RGBA" rowstride = width * (3+int(has_alpha)) + icon = img if self.overlay_image: + if ICON_SHRINKAGE>0 and ICON_SHRINKAGE<100: + #paste the application icon in the top-left corner, + #shrunk by ICON_SHRINKAGE pct + shrunk_width = max(1, width*ICON_SHRINKAGE//100) + shrunk_height = max(1, height*ICON_SHRINKAGE//100) + icon_resized = icon.resize((shrunk_width, shrunk_height), Image.ANTIALIAS) + icon = Image.new("RGBA", (width, height)) + icon.paste(icon_resized, (0, 0, shrunk_width, shrunk_height)) assert ICON_OVERLAY>0 and ICON_OVERLAY<=100 overlay_width = max(1, width*ICON_OVERLAY//100) overlay_height = max(1, height*ICON_OVERLAY//100) - half = self.overlay_image.resize((overlay_width, overlay_height), Image.ANTIALIAS) + xpra_resized = self.overlay_image.resize((overlay_width, overlay_height), Image.ANTIALIAS) xpra_corner = Image.new("RGBA", (width, height)) - xpra_corner.paste(half, (width-overlay_width, height-overlay_height, width, height)) - composite = Image.alpha_composite(img, xpra_corner) - img = composite + xpra_corner.paste(xpra_resized, (width-overlay_width, height-overlay_height, width, height)) + composite = Image.alpha_composite(icon, xpra_corner) + icon = composite if SAVE_WINDOW_ICONS: filename = "client-window-%i-icon-%i.png" % (wid, int(time.time())) - img.save(filename, "png") + icon.save(filename, "png") iconlog("client window icon saved to %s", filename) - return img + return icon def _process_configure_override_redirect(self, packet):