Hi,

As discussed earlier, this is the patch to add window icon support.

Known limitations:
* Transparency
* Not sure what happens if the icon changes often...

Cheers
Antoine
diff -ur parti-all-0.0.5-icon/xpra/client.py parti-all-0.0.5/xpra/client.py
--- parti-all-0.0.5-icon/xpra/client.py	2008-11-02 15:29:13.000000000 +0700
+++ parti-all-0.0.5/xpra/client.py	2009-03-10 14:35:26.000000000 +0700
@@ -109,6 +110,12 @@
         self.set_wmclass(*self._metadata.get("class-instance",
                                              ("xpra", "Xpra")))
 
+	if "icon" in self._metadata:
+		(x, y, width, height, data) = self._metadata["icon"]
+		rowstride = width*3
+		pixbuf = gtk.gdk.pixbuf_new_from_data(data, gtk.gdk.COLORSPACE_RGB, False, 8, width, height, rowstride)
+		self.set_icon(pixbuf)
+
     def _new_backing(self, w, h):
         old_backing = self._backing
         self._backing = gtk.gdk.Pixmap(gtk.gdk.get_default_root_window(),
diff -ur parti-all-0.0.5-icon/xpra/server.py parti-all-0.0.5/xpra/server.py
--- parti-all-0.0.5-icon/xpra/server.py	2009-03-10 13:21:25.000000000 +0700
+++ parti-all-0.0.5/xpra/server.py	2009-03-10 14:35:53.000000000 +0700
@@ -31,6 +31,35 @@
 from xpra.protocol import Protocol
 from xpra.keys import mask_to_names
 
+def _get_rgb_data(pixmap, x, y, width, height):
+    pixmap_w, pixmap_h = pixmap.get_size()
+    # Just in case we somehow end up with damage larger than the pixmap,
+    # we don't want to start requesting random chunks of memory (this
+    # could happen if a window is resized but we don't throw away our
+    # existing damage map):
+    assert x >= 0
+    assert y >= 0
+    if x + width > pixmap_w:
+        width = pixmap_w - x
+    if y + height > pixmap_h:
+        height = pixmap_h - y
+    if width <= 0 or height <= 0:
+        return (0, 0, 0, 0, "")
+    pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
+    pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
+                                 x, y, 0, 0, width, height)
+    raw_data = pixbuf.get_pixels()
+    rowwidth = width * 3
+    rowstride = pixbuf.get_rowstride()
+    if rowwidth == rowstride:
+        data = raw_data
+    else:
+        rows = []
+        for i in xrange(height):
+            rows.append(raw_data[i*rowstride : i*rowstride+rowwidth])
+        data = "".join(rows)
+    return (x, y, width, height, data)
+
 class DesktopManager(gtk.Widget):
     def __init__(self):
         gtk.Widget.__init__(self)
@@ -156,7 +185,7 @@
                 log.error("wtf, pixmap is None?")
                 packet = None
             else:
-                (x2, y2, w2, h2, data) = self._get_rgb_data(pixmap, x, y, w, h)
+                (x2, y2, w2, h2, data) = _get_rgb_data(pixmap, x, y, w, h)
                 if not w2 or not h2:
                     packet = None
                 else:
@@ -165,34 +194,6 @@
             packet = None
         return packet, self._have_more()
 
-    def _get_rgb_data(self, pixmap, x, y, width, height):
-        pixmap_w, pixmap_h = pixmap.get_size()
-        # Just in case we somehow end up with damage larger than the pixmap,
-        # we don't want to start requesting random chunks of memory (this
-        # could happen if a window is resized but we don't throw away our
-        # existing damage map):
-        assert x >= 0
-        assert y >= 0
-        if x + width > pixmap_w:
-            width = pixmap_w - x
-        if y + height > pixmap_h:
-            height = pixmap_h - y
-        if width <= 0 or height <= 0:
-            return (0, 0, 0, 0, "")
-        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
-        pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
-                                 x, y, 0, 0, width, height)
-        raw_data = pixbuf.get_pixels()
-        rowwidth = width * 3
-        rowstride = pixbuf.get_rowstride()
-        if rowwidth == rowstride:
-            data = raw_data
-        else:
-            rows = []
-            for i in xrange(height):
-                rows.append(raw_data[i*rowstride : i*rowstride+rowwidth])
-            data = "".join(rows)
-        return (x, y, width, height, data)
 
 class XpraServer(gobject.GObject):
     __gsignals__ = {
@@ -356,7 +388,7 @@
         id = self._window_to_id[window]
         self._send(["configure-override-redirect", id, x, y, w, h])
 
-    _all_metadata = ("title", "size-hints", "class-instance")
+    _all_metadata = ("title", "size-hints", "class-instance", "icon")
 
     def _make_metadata(self, window, propname):
         assert propname in self._all_metadata
@@ -385,6 +417,14 @@
                 return {"class-instance": [x.encode("utf-8") for x in c_i]}
             else:
                 return {}
+        elif propname == "icon":
+            pixmap=window.get_property("icon")
+            if pixmap:
+                w, h = pixmap.get_size()
+                icon_data = _get_rgb_data(pixmap, 0, 0, w, h)
+            	return {"icon":icon_data}
+            else:
+                return {}
         else:
             assert False
 

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Parti-discuss mailing list
[email protected]
http://lists.partiwm.org/cgi-bin/mailman/listinfo/parti-discuss

Reply via email to