Skip to content

Commit

Permalink
#2539 set the visual on the widget, not the window, only set it on th…
Browse files Browse the repository at this point in the history
…e window if we do need transparency

git-svn-id: https://xpra.org/svn/Xpra/trunk@26449 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 22, 2020
1 parent 0204a6f commit 0e59b26
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
5 changes: 4 additions & 1 deletion src/xpra/client/gl/gtk3/gl_client_window.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# This file is part of Xpra.
# Copyright (C) 2012 Serviware (Arthur Huillet, <[email protected]>)
# Copyright (C) 2012-2019 Antoine Martin <[email protected]>
# Copyright (C) 2012-2020 Antoine Martin <[email protected]>
# 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")
Expand Down Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down
20 changes: 12 additions & 8 deletions src/xpra/gtk_common/gtk_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions src/xpra/platform/xposix/gl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 0e59b26

Please sign in to comment.