GNOME Bugzilla – Bug 702831
Shaped GDK windows do not work
Last modified: 2013-07-01 13:34:54 UTC
Created attachment 247479 [details] simple demo--for maximum clarity disable compositing managers under X This problem is clearly present but a little complex in how it's manifested: Under the X11 backend, calls to gdk_window_shape_combine_region never result in a call to XShapeCombineRectangles (i.e. they are no-ops from the windowing-system perspective), and drawing with GDK is not always cropped to the shape region. Calls to gdk_window_input_shape_combine_region work fine under X11. The former problem is not necessarily easy to see when using GTK, as it seems to limit its drawing and stay within the region. Disabling any compositing managers and then minimizing and unminimizing a window helps with this, as it will leave bad contents in the window's "shaped-away" regions. Under the Wayland backend, the input mask is not set by calls to gdk_window_shape_combine_region *or* gdk_window_input_shape_combine_region. The pertinent functions in gdk/wayland/gdkwindow-wayland.c are empty. This is a regression from GTK2, where shaping windows via a call to gdk_window_shape_combine_region always bounds the contents and sets the input region. The expected behavior is that calls to gdk_window_shape_combine_region will bound the input and output regions--the X call looks like it should set the Bounding region, which has these semantics (modulo some X11 window-border nonsense). Calls to gdk_window_input_shape_combine_region should (presumably, based on X Shape semantics) intersect with the region from gdk_window_shape_combine_region to determine the effective input region. Attached is a demo program that can be used to contrast GTK2 and GTK3 behavior.
I've found a patch that seems to fix the bulk of the problem locally by comparing the GTK2 and GTK3 codebases. Commit a60ccd3672467efb454b121993febc36f33cbc79 removed the lines: if (gdk_window_has_impl (window) && !should_apply_clip_as_shape (window)) apply_shape (window, window->shape); from gdk_window_shape_combine_region in gdkwindow.c. Restoring them (like GTK2 has) makes the output shape update properly under X11. Apparently Wayland is just lacking implementations so I expect once those are written things will work okay on that end as well.
Created attachment 248142 [details] [review] gdk: Fix shaped toplevels We need to apply the shape for toplevels that have a shape.
Attachment 248142 [details] pushed as 09a975a - gdk: Fix shaped toplevels