Skip to content

Commit

Permalink
X11: Use XFixesSetWindowShape to hide windows and disallow input
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Dec 6, 2024
1 parent 3cf1cbd commit 02e2cb2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -400,5 +400,50 @@ namespace Gala {

return texture;
}

private static HashTable<Meta.Window, X.XserverRegion?> regions = new HashTable<Meta.Window, X.XserverRegion?> (null, null);

public static void x11_set_window_pass_through (Meta.Display display, Meta.Window window) {
unowned var x11_display = display.get_x11_display ();

#if HAS_MUTTER46
var x_window = x11_display.lookup_xwindow (window);
#else
var x_window = window.get_xwindow ();
#endif
unowned var xdisplay = x11_display.get_xdisplay ();

regions[window] = X.Fixes.create_region_from_window (xdisplay, x_window, 0);

X.Xrectangle rect = {};

var region = X.Fixes.create_region (xdisplay, {rect});

X.Fixes.set_window_shape_region (xdisplay, x_window, 2, 0, 0, region);

X.Fixes.destroy_region (xdisplay, region);
}

public static void x11_unset_window_pass_through (Meta.Display display, Meta.Window window) {
unowned var x11_display = display.get_x11_display ();

#if HAS_MUTTER46
var x_window = x11_display.lookup_xwindow (window);
#else
var x_window = window.get_xwindow ();
#endif
unowned var xdisplay = x11_display.get_xdisplay ();

var region = regions[window];

if (region == null) {
return;
}

X.Fixes.set_window_shape_region (xdisplay, x_window, 2, 0, 0, region);

regions.remove (window);
X.Fixes.destroy_region (xdisplay, region);
}
}
}
8 changes: 8 additions & 0 deletions src/ShellClients/PanelClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ public class Gala.PanelClone : Object {

panel_hidden = true;

if (!Meta.Util.is_wayland_compositor ()) {
Utils.x11_set_window_pass_through (wm.get_display (), panel.window);
}

if (panel.anchor != TOP && panel.anchor != BOTTOM) {
warning ("Animated hide not supported for side yet.");
return;
Expand All @@ -146,6 +150,10 @@ public class Gala.PanelClone : Object {
return;
}

if (!Meta.Util.is_wayland_compositor ()) {
Utils.x11_unset_window_pass_through (wm.get_display (), panel.window);
}

clone.save_easing_state ();
clone.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
clone.set_easing_duration (get_animation_duration ());
Expand Down
4 changes: 4 additions & 0 deletions vapi/xfixes-4.0.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ namespace X {
namespace Fixes {
[CCode (cheader_filename = "X11/extensions/Xfixes.h", cname = "XFixesCreateRegion")]
public static X.XserverRegion create_region (X.Display display, [CCode (array_length = true)] X.Xrectangle[] rectangles);
[CCode (cheader_filename = "X11/extensions/Xfixes.h", cname = "XFixesCreateRegionFromWindow")]
public static X.XserverRegion create_region_from_window (X.Display display, X.Window window, int shape_kind);
[CCode (cheader_filename = "X11/extensions/Xfixes.h", cname = "XFixesDestroyRegion")]
public static void destroy_region (X.Display display, X.XserverRegion region);
[CCode (cheader_filename = "X11/extensions/Xfixes.h", cname = "XFixesSetWindowShapeRegion")]
public static void set_window_shape_region (X.Display display, X.Window win, int shape_kind, int x_off, int y_off, XserverRegion region);
}
[SimpleType]
[CCode (cheader_filename = "X11/extensions/Xfixes.h", cname = "XserverRegion", has_type_id = false)]
Expand Down

0 comments on commit 02e2cb2

Please sign in to comment.