RGBA visual by default
Currently, in GTK3, applications will use the ARGB visual if the screen is composited, the window manager supports _GTK_FRAME_EXTENTS
and the application uses CSD (client side decorations). This works perfectly fine in the GNOME desktop environment, but hard coupling the usage of the ARGB visual to both _GTK_FRAME_EXTENTS
and CSD is unnecessary.
If a window manager does not support _GTK_FRAME_EXTENTS
, GTK windows will not automatically use the ARGB visual. Even though GTK should only just not draw the windows shadow if _GTK_FRAME_EXTENTS
is not supported by the window manager.
Here is a table that shows the current outcome for all possible scenarios:
composited | using CSD | WM supports _GTK_FRAME_EXTENTS | results in using ARGB visual? |
---|---|---|---|
no | |||
no | |||
no | |||
no | |||
no (but why?) | |||
no (but why?) | |||
no (but why?) | |||
yes |
In the first 4 cases, it is very clear that it does not make sense to use the RGBA visual, since it would just not do anything when there is no compositor.
The cases marked with "but why" are the cases I want to talk about.
So I would like to figure out why no ARGB visual is used when either the application doesn't use CSD, or the window manager doesn't support _GTK_FRAME_EXTENTS.
As a workaround for a window manager that does not support _GTK_FRAME_EXTENTS
, I have implemented it that the window manager just reports that it supports it, without actually respecting the frame extents. But since this makes the GTK application have a shadow, and people with window managers that don't support _GTK_FRAME_EXTENTS
usually use their own compositor that renders shadows, this leads to the application having multiple shadows.
Being in a window manager that supports _GTK_FRAME_EXTENTS
should not be a requirement for using the ARGB visual.
Here are some pointers towards the general direction of the implementation of this:
- https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtkwindow.c#L4146
- https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtkwindow.c#L4104
GTK4 already uses the ARGB visual by default. So the question is, what could be potential issues if this would also be used by default in GTK3?
Regarding non CSD applications, there has been made some effort to also use the RGBA visual in such applications. One example would be Thunar: https://gitlab.xfce.org/xfce/thunar/-/merge_requests/31
If the RGBA visual would be used regardless if CSD is enabled or not, this would also make such efforts unnecessary.
As a little side-note, GTK3 applications already support transparency on Wayland by default, and this is just inconsistent to how GTK3 applications behave on X11.