From 6cb71dd6f94c8df2f64f307c76f8d7fbf2717a27 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 29 Jan 2018 12:09:08 +0000 Subject: [PATCH] tell the client if this is the default icon so it can skip overlaying xpra's default icon on top of itself git-svn-id: https://xpra.org/svn/Xpra/trunk@18189 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/ui_client_base.py | 7 ++++--- src/xpra/server/window/window_source.py | 15 ++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index a5b4f2ff3c..2038469485 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -3566,7 +3566,8 @@ def _process_window_metadata(self, packet): def _process_window_icon(self, packet): wid, w, h, coding, data = packet[1:6] - img = self._window_icon_image(wid, w, h, coding, data) + isdefault = len(packet)>=7 and packet[6] + img = self._window_icon_image(wid, w, h, coding, data, isdefault) window = self._id_to_window.get(wid) iconlog("_process_window_icon(%s, %s, %s, %s, %s bytes) image=%s, window=%s", wid, w, h, coding, len(data), img, window) if window and img: @@ -3609,7 +3610,7 @@ def set_tray_icon(self): traylog("set_tray_icon() using default icon") self.tray.set_icon() - def _window_icon_image(self, wid, width, height, coding, data): + def _window_icon_image(self, wid, width, height, coding, data, isdefault): #convert the data into a pillow image, #adding the icon overlay (if enabled) from PIL import Image @@ -3628,7 +3629,7 @@ def _window_icon_image(self, wid, width, height, coding, data): has_alpha = img.mode=="RGBA" rowstride = width * (3+int(has_alpha)) icon = img - if self.overlay_image: + if self.overlay_image and not isdefault: if ICON_SHRINKAGE>0 and ICON_SHRINKAGE<100: #paste the application icon in the top-left corner, #shrunk by ICON_SHRINKAGE pct diff --git a/src/xpra/server/window/window_source.py b/src/xpra/server/window/window_source.py index 49883cfcf5..0b6cfd364f 100644 --- a/src/xpra/server/window/window_source.py +++ b/src/xpra/server/window/window_source.py @@ -471,13 +471,14 @@ def get_info(self): info["pixel-format"] = self.pixel_format idata = self.window_icon_data if idata: - pixel_data, pixel_format, stride, w, h = idata + pixel_data, pixel_format, stride, w, h, isdefault = idata info["icon"] = { "pixel_format" : pixel_format, "width" : w, "height" : h, "stride" : stride, "bytes" : len(pixel_data), + "default" : bool(isdefault), } return info @@ -589,23 +590,27 @@ def send_window_icon(self): #try to load the icon for this class-instance from the theme: surf = self.window.get_default_window_icon() iconlog("send_window_icon window %s using default window icon=%s", self.window, surf) + #TODO: clients could expose a "default-icon" capabitlity, + # then we wouldn't even need to send any icon data, just the flag + isdefault = False if not surf and self.window_icon_greedy: #client does not set a default icon, so we must provide one every time #to make sure that the window icon does get set to something #(our icon is at least better than the window manager's default) surf = WindowSource.get_fallback_window_icon_surface() + isdefault = True iconlog("using fallback window icon") if surf: if hasattr(surf, "get_pixels"): #looks like a gdk.Pixbuf: - self.window_icon_data = (surf.get_pixels(), "RGBA", surf.get_rowstride(), surf.get_width(), surf.get_height()) + self.window_icon_data = (surf.get_pixels(), "RGBA", surf.get_rowstride(), surf.get_width(), surf.get_height(), isdefault) else: #for debugging, save to a file so we can see it: #surf.write_to_png("S-%s-%s.png" % (self.wid, int(time.time()))) #extract the data from the cairo surface import cairo assert surf.get_format() == cairo.FORMAT_ARGB32 - self.window_icon_data = (surf.get_data(), "BGRA", surf.get_stride(), surf.get_width(), surf.get_height()) + self.window_icon_data = (surf.get_data(), "BGRA", surf.get_stride(), surf.get_width(), surf.get_height(), isdefault) if not self.send_window_icon_due: self.send_window_icon_due = True #call compress_clibboard via the work queue @@ -620,7 +625,7 @@ def compress_and_send_window_icon(self): idata = self.window_icon_data if not idata: return - pixel_data, pixel_format, stride, w, h = idata + pixel_data, pixel_format, stride, w, h, isdefault = idata PIL = get_codec("PIL") max_w, max_h = self.window_icon_max_size if stride!=w*4: @@ -662,7 +667,7 @@ def compress_and_send_window_icon(self): iconlog("cannot send window icon, supported encodings: %s", self.window_icon_encodings) return assert wrapper.datatype in ("premult_argb32", "png"), "invalid wrapper datatype %s" % wrapper.datatype - packet = ("window-icon", self.wid, w, h, wrapper.datatype, wrapper) + packet = ("window-icon", self.wid, w, h, wrapper.datatype, wrapper, isdefault) iconlog("queuing window icon update: %s", packet) self.queue_packet(packet, wait_for_more=True)