Nathaniel Smith wrote:
> On Tue, Mar 10, 2009 at 12:33 AM, Antoine Martin <[email protected]> 
> wrote:
>>>>                pixbuf = gtk.gdk.pixbuf_new_from_data(data,
>>>> gtk.gdk.COLORSPACE_RGB, True, 8, width, height, rowstride)
>>> Does it help to put 'False' as the 3rd argument instead?
>> OMG... it does!
>>
>> We lose transparency, but I think it's good enough as it is (better than
>> nothing)
>> Will send a patch shortly.
> 
> Transparency is easy... the problem is just that _get_rgb or whatever
> it's called is fetching the pixmap data without transparency (b/c for
> ordinary windows alpha is a waste of space) -- you can tell because it
> passes False as the 3rd argument -- and the two calls have to match.
> Just use True on both sides and transparency will work.
Hah, yes, pretty obvious really!

Except... it doesn't seem to work!
Cumulative patch attached (adds has_alpha flag to _get_rgb)
Looks like the server is not sending the alpha channel??

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
 
diff -ur parti-all-0.0.5-icon/xpra/client.py parti-all-0.0.5-icon-trans/xpra/client.py
--- parti-all-0.0.5-icon/xpra/client.py	2009-03-10 15:23:31.000000000 +0700
+++ parti-all-0.0.5-icon-trans/xpra/client.py	2009-03-10 15:23:22.000000000 +0700
@@ -112,7 +112,7 @@
 	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)
+		pixbuf = gtk.gdk.pixbuf_new_from_data(data, gtk.gdk.COLORSPACE_RGB, True, 8, width, height, rowstride)
 		self.set_icon(pixbuf)
 
     def _new_backing(self, w, h):
diff -ur parti-all-0.0.5-icon/xpra/server.py parti-all-0.0.5-icon-trans/xpra/server.py
--- parti-all-0.0.5-icon/xpra/server.py	2009-03-10 15:23:31.000000000 +0700
+++ parti-all-0.0.5-icon-trans/xpra/server.py	2009-03-10 15:23:09.000000000 +0700
@@ -31,7 +31,7 @@
 from xpra.protocol import Protocol
 from xpra.keys import mask_to_names
 
-def _get_rgb_data(pixmap, x, y, width, height):
+def _get_rgb_data(pixmap, alpha_channel, 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
@@ -45,7 +45,7 @@
         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 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, alpha_channel, 8, width, height)
     pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
                                  x, y, 0, 0, width, height)
     raw_data = pixbuf.get_pixels()
@@ -185,7 +185,7 @@
                 log.error("wtf, pixmap is None?")
                 packet = None
             else:
-                (x2, y2, w2, h2, data) = _get_rgb_data(pixmap, x, y, w, h)
+                (x2, y2, w2, h2, data) = _get_rgb_data(pixmap, False, x, y, w, h)
                 if not w2 or not h2:
                     packet = None
                 else:
@@ -390,7 +390,7 @@
             pixmap=window.get_property("icon")
             if pixmap:
                 w, h = pixmap.get_size()
-                icon_data = _get_rgb_data(pixmap, 0, 0, w, h)
+                icon_data = _get_rgb_data(pixmap, True, 0, 0, w, h)
             	return {"icon":icon_data}
             else:
                 return {}

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