From 0e59b26c69ff2ce49f9d80292202182c72acd1ae Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Fri, 22 May 2020 10:09:31 +0000 Subject: [PATCH] #2539 set the visual on the widget, not the window, only set it on the window if we do need transparency git-svn-id: https://xpra.org/svn/Xpra/trunk@26449 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gl/gtk3/gl_client_window.py | 5 ++++- .../client/gtk_base/gtk_client_window_base.py | 20 ++++++++++--------- src/xpra/gtk_common/gtk_util.py | 20 +++++++++++-------- src/xpra/platform/xposix/gl_context.py | 6 ++++-- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/xpra/client/gl/gtk3/gl_client_window.py b/src/xpra/client/gl/gtk3/gl_client_window.py index 2b9ed21aa4..fc845abdc6 100644 --- a/src/xpra/client/gl/gtk3/gl_client_window.py +++ b/src/xpra/client/gl/gtk3/gl_client_window.py @@ -1,12 +1,13 @@ # This file is part of Xpra. # Copyright (C) 2012 Serviware (Arthur Huillet, ) -# Copyright (C) 2012-2019 Antoine Martin +# Copyright (C) 2012-2020 Antoine Martin # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from collections import namedtuple from xpra.client.gtk3.gtk3_client_window import GTK3ClientWindow +from xpra.gtk_common.gtk_util import set_visual from xpra.log import Logger log = Logger("opengl", "window") @@ -87,6 +88,8 @@ def new_backing(self, bw, bh): widget = super().new_backing(bw, bh) if self.drawing_area: self.remove(self.drawing_area) + set_visual(widget, self._has_alpha) + widget.show() self.init_widget_events(widget) self.add(widget) self.drawing_area = widget diff --git a/src/xpra/client/gtk_base/gtk_client_window_base.py b/src/xpra/client/gtk_base/gtk_client_window_base.py index 9f00c1fc33..eeb9a1a3f8 100644 --- a/src/xpra/client/gtk_base/gtk_client_window_base.py +++ b/src/xpra/client/gtk_base/gtk_client_window_base.py @@ -24,7 +24,7 @@ from xpra.gtk_common.gobject_util import no_arg_signal, one_arg_signal from xpra.gtk_common.gtk_util import ( get_pixbuf_from_data, get_default_root_window, - enable_alpha, + set_visual, BUTTON_MASK, GRAB_STATUS_STRING, WINDOW_EVENT_MASK, @@ -737,17 +737,19 @@ def set_alpha(self): #by default, only RGB (no transparency): #rgb_formats = tuple(BACKING_CLASS.RGB_MODES) self._client_properties["encodings.rgb_formats"] = ["RGB", "RGBX"] - if not self._has_alpha or not bc.HAS_ALPHA: - self._client_properties["encoding.transparency"] = False - return - if self._has_alpha and not self.get_realized(): - if enable_alpha(self): - self._client_properties["encodings.rgb_formats"] = ["RGBA", "RGB", "RGBX"] - self._window_alpha = True + #only set the visual if we need to enable alpha: + #(breaks the headerbar otherwise!) + if not self.get_realized() and self._has_alpha: + if set_visual(self, True): + if self._has_alpha: + self._client_properties["encodings.rgb_formats"] = ["RGBA", "RGB", "RGBX"] + self._window_alpha = self._has_alpha else: - alphalog("enable_alpha()=False") + alphalog("failed to set RGBA visual") self._has_alpha = False self._client_properties["encoding.transparency"] = False + if not self._has_alpha or not bc.HAS_ALPHA: + self._client_properties["encoding.transparency"] = False def freeze(self): diff --git a/src/xpra/gtk_common/gtk_util.py b/src/xpra/gtk_common/gtk_util.py index 4331671e63..ff050dac96 100644 --- a/src/xpra/gtk_common/gtk_util.py +++ b/src/xpra/gtk_common/gtk_util.py @@ -116,27 +116,31 @@ def GDKWindow(parent=None, width=1, height=1, window_type=Gdk.WindowType.TOPLEVE mask = Gdk.WindowAttributesType(attributes_mask) return Gdk.Window(parent, attributes, mask) -def enable_alpha(window) -> bool: +def set_visual(window, alpha : bool=True) -> bool: screen = window.get_screen() - visual = screen.get_rgba_visual() - alphalog("enable_alpha(%s) screen=%s, visual=%s", window, screen, visual) + if alpha: + visual = screen.get_rgba_visual() + else: + visual = screen.get_system_visual() + alphalog("set_visual(%s, %s) screen=%s, visual=%s", window, alpha, screen, visual) #we can't do alpha on win32 with plain GTK, #(though we handle it in the opengl backend) if WIN32: l = alphalog else: l = alphalog.warn - if visual is None or (not WIN32 and not screen.is_composited()): + if alpha and visual is None or (not WIN32 and not screen.is_composited()): l("Warning: cannot handle window transparency") if visual is None: l(" no RGBA visual") else: assert not screen.is_composited() l(" screen is not composited") - return False - alphalog("enable_alpha(%s) using rgba visual %s", window, visual) - window.set_visual(visual) - return True + return None + alphalog("set_visual(%s, %s) using visual %s", window, alpha, visual) + if visual: + window.set_visual(visual) + return visual def get_pixbuf_from_data(rgb_data, has_alpha : bool, w : int, h : int, rowstride : int) -> GdkPixbuf.Pixbuf: diff --git a/src/xpra/platform/xposix/gl_context.py b/src/xpra/platform/xposix/gl_context.py index ec6fad3884..6987c146be 100644 --- a/src/xpra/platform/xposix/gl_context.py +++ b/src/xpra/platform/xposix/gl_context.py @@ -11,7 +11,7 @@ from xpra.client.gl.gl_check import check_PyOpenGL_support from xpra.x11.bindings.display_source import get_display_ptr #@UnresolvedImport from xpra.gtk_common.error import xsync -from xpra.gtk_common.gtk_util import enable_alpha +from xpra.gtk_common.gtk_util import set_visual from xpra.log import Logger log = Logger("opengl") @@ -183,7 +183,9 @@ def check_support(self, force_enable=False): tmp.resize(1, 1) tmp.set_decorated(False) tmp.realize() - enable_alpha(tmp) + da = Gtk.DrawingArea() + tmp.add(da) + set_visual(da, True) win = tmp.get_window() log("check_support(%s) using temporary window=%s", force_enable, tmp) with self.get_paint_context(win):