Skip to content

Commit

Permalink
#1707: also shrink the application icon to make more space
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@17836 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jan 3, 2018
1 parent d7e0b8c commit 81e1cd2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 17 additions & 7 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit 81e1cd2

Please sign in to comment.