Skip to content

Commit

Permalink
#4403 use visual with transparency for the tray
Browse files Browse the repository at this point in the history
but not for the docking window
  • Loading branch information
totaam committed Oct 26, 2024
1 parent 6f5f514 commit ce124c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 8 additions & 2 deletions xpra/x11/bindings/window.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from xpra.gtk.error import XError
from xpra.x11.bindings.xlib cimport (
Display, Drawable, Visual, Window, Bool, Pixmap, XID, Status, Atom, Time, CurrentTime, Cursor, XPointer,
VisualID, XVisualInfo,
XGetVisualInfo, VisualIDMask,
XGetVisualInfo, VisualIDMask, XDefaultVisual,
GrabModeAsync, XGrabPointer,
Expose,
XRectangle, XEvent, XClassHint,
Expand Down Expand Up @@ -998,7 +998,13 @@ cdef class X11WindowBindingsInstance(X11CoreBindingsInstance):
XFree(vinfo)
return visual

def get_rgba_visualid(self, depth=32):
def get_default_visualid(self) -> int:
cdef Visual *visual = XDefaultVisual(self.display, 0)
if not visual:
return 0
return visual.visualid

def get_rgba_visualid(self, depth=32) -> int:
cdef XVisualInfo vinfo_template
cdef int count
cdef XVisualInfo *vinfo = XGetVisualInfo(self.display, 0, &vinfo_template, &count)
Expand Down
3 changes: 2 additions & 1 deletion xpra/x11/bindings/xlib.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ cdef extern from "X11/Xlib.h":
VisualID visualid
int screen
unsigned int depth
int c_class
int c_class "class"
unsigned long red_mask
unsigned long green_mask
unsigned long blue_mask
Expand Down Expand Up @@ -301,6 +301,7 @@ cdef extern from "X11/Xlib.h":
int XAddToSaveSet(Display *, Window w)
int XRemoveFromSaveSet(Display *, Window w)

Visual *XDefaultVisual(Display *display, int screen_number)
XVisualInfo *XGetVisualInfo(Display *display, long vinfo_mask, XVisualInfo *vinfo_template, int *nitems_return)

# windows:
Expand Down
12 changes: 8 additions & 4 deletions xpra/x11/gtk/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,15 @@ def setup_tray_window(self) -> None:
if owner != XNone:
raise RuntimeError(f"{SELECTION} already owned by {owner:x}")
root_xid = X11Window.get_root_xid()
depth = X11Window.get_depth(root_xid)
visualid = X11Window.get_rgba_visualid(depth) if TRANSPARENCY else 0
root_depth = X11Window.get_depth(root_xid)
visualid = 0
if TRANSPARENCY:
depth = root_depth if root_depth != 24 else 32
visualid = X11Window.get_rgba_visualid(depth)
event_mask = PropertyChangeMask
self.xid = X11Window.CreateWindow(root_xid, depth=depth, event_mask=event_mask, visualid=visualid)
log("tray dock window: {visualid=} geometry=%s", X11Window.getGeometry(self.xid))
win_vid = X11Window.get_default_visualid()
self.xid = X11Window.CreateWindow(root_xid, depth=root_depth, event_mask=event_mask, visualid=win_vid)
log(f"tray dock window: visualid=0x{visualid:x} geometry=%s", X11Window.getGeometry(self.xid))
prop_set(self.xid, "WM_TITLE", "latin1", "Xpra-SystemTray")
set_tray_visual(self.xid, visualid)
set_tray_orientation(self.xid, TRAY_ORIENTATION.HORZ)
Expand Down

0 comments on commit ce124c6

Please sign in to comment.