Skip to content

Commit

Permalink
scale window icons down to max 64x64 (keeping aspect ratio), also ena…
Browse files Browse the repository at this point in the history
…ble png icons in client by default now as png is used by the scaling code.

git-svn-id: https://xpra.org/svn/Xpra/trunk@184 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 23, 2011
1 parent 4ca6470 commit e0b3ae0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/xpra/client.py
Expand Up @@ -580,6 +580,7 @@ def send_hello(self, hash=None):
capabilities_request["modifiers"] = modifiers
root_w, root_h = gtk.gdk.get_default_root_window().get_size()
capabilities_request["desktop_size"] = [root_w, root_h]
capabilities_request["png_window_icons"] = True
self.send(["hello", capabilities_request])

def send_jpeg_quality(self):
Expand Down
11 changes: 11 additions & 0 deletions src/xpra/server.py
Expand Up @@ -596,6 +596,17 @@ def _make_metadata(self, window, propname):
log("found new window icon: %sx%s, sending as png=%s" % (w,h,self.png_window_icons))
if self.png_window_icons:
img = Image.frombuffer("RGBA", (w,h), surf.get_data(), "raw", "RGBA", 0, 1)
MAX_SIZE = 64
if w>MAX_SIZE or h>MAX_SIZE:
#scale icon down
if w>=h:
h = int(h*MAX_SIZE/w)
w = MAX_SIZE
else:
w = int(w*MAX_SIZE/h)
h = MAX_SIZE
log("scaling window icon down to %sx%s" % (w,h))
img = img.resize((w,h), Image.ANTIALIAS)
output = StringIO.StringIO()
img.save(output, 'PNG')
raw_data = output.getvalue()
Expand Down

0 comments on commit e0b3ae0

Please sign in to comment.