mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
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>
This commit is contained in:
parent
1f51dfa112
commit
07e1f87e3b
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user