summaryrefslogtreecommitdiff
path: root/src/x11
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-12-13 13:41:22 +0100
committerCarlos Garnacho <carlosg@gnome.org>2023-01-20 22:23:55 +0000
commit07e1f87e3bb08f9f562424adf86a569050850567 (patch)
treed2e3f9d40abca5200ba0ba793562d7b4f14ff163 /src/x11
parent1f51dfa1126bcb9365bd7581376f871146aebe41 (diff)
downloadmutter-07e1f87e3bb08f9f562424adf86a569050850567.tar.gz
x11: Add function to know whether a client X11 window has an alpha channel
Since the windows created by the frames client will have a RGBA visual, we no longer can perform simple tests about whether the window is opaque. For that, we will need to additionally know whether the client-side window has a visual with an alpha channel. Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
Diffstat (limited to 'src/x11')
-rw-r--r--src/x11/window-x11.c27
-rw-r--r--src/x11/window-x11.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index a21be1fff..8025e8444 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -4331,3 +4331,30 @@ meta_window_x11_check_update_resize (MetaWindow *window)
window->display->grab_latest_motion_x,
window->display->grab_latest_motion_y);
}
+
+gboolean
+meta_window_x11_has_alpha_channel (MetaWindow *window)
+{
+ MetaX11Display *x11_display = window->display->x11_display;
+ int n_xvisuals;
+ gboolean has_alpha;
+ XVisualInfo *xvisual_info;
+ XVisualInfo template = {
+ .visualid = XVisualIDFromVisual (window->xvisual),
+ };
+
+ xvisual_info = XGetVisualInfo (meta_x11_display_get_xdisplay (x11_display),
+ VisualIDMask,
+ &template,
+ &n_xvisuals);
+ if (!xvisual_info)
+ return FALSE;
+
+ has_alpha = (xvisual_info->depth >
+ __builtin_popcount (xvisual_info->red_mask |
+ xvisual_info->green_mask |
+ xvisual_info->blue_mask));
+ XFree (xvisual_info);
+
+ return has_alpha;
+}
diff --git a/src/x11/window-x11.h b/src/x11/window-x11.h
index f0e0b9a64..c00438c42 100644
--- a/src/x11/window-x11.h
+++ b/src/x11/window-x11.h
@@ -107,4 +107,6 @@ gboolean meta_window_x11_is_awaiting_sync_response (MetaWindow *window);
void meta_window_x11_check_update_resize (MetaWindow *window);
+gboolean meta_window_x11_has_alpha_channel (MetaWindow *window);
+
#endif