aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2022-01-12 14:50:55 +0100
committerIsaac Freund <mail@isaacfreund.com>2022-01-12 14:50:55 +0100
commitc9fd8b3f37bb8e8432b83b72776026cfb9bf7c5a (patch)
tree91c3f944ae292897c0bfd01f791b18a1985c48bc
parent0c3a581f54a530b8001cb46fea134071e7b3a32f (diff)
downloadriver-c9fd8b3f37bb8e8432b83b72776026cfb9bf7c5a.tar.gz
river-c9fd8b3f37bb8e8432b83b72776026cfb9bf7c5a.tar.xz
XdgPopup: fix unconstrain from box coords
We currently don't properly handle xdg surface geometry of the parent, which causes popups to render partially off-screen in some cases. GTK4 clients such as easyeffects seem to trigger this issue reliably.
-rw-r--r--river/XdgPopup.zig42
1 files changed, 24 insertions, 18 deletions
diff --git a/river/XdgPopup.zig b/river/XdgPopup.zig
index 864d69d..95e504b 100644
--- a/river/XdgPopup.zig
+++ b/river/XdgPopup.zig
@@ -54,25 +54,31 @@ pub fn create(wlr_xdg_popup: *wlr.XdgPopup, parent: Parent) void {
assert(wlr_xdg_popup.base.data == 0);
wlr_xdg_popup.base.data = @ptrToInt(xdg_popup);
- const parent_box = switch (parent) {
- .xdg_toplevel => |xdg_toplevel| &xdg_toplevel.view.pending.box,
- .layer_surface => |layer_surface| &layer_surface.box,
+ switch (parent) {
+ .xdg_toplevel => |xdg_toplevel| {
+ const output_dimensions = xdg_toplevel.view.output.getEffectiveResolution();
+ // The output box relative to the parent of the xdg_popup
+ var box = wlr.Box{
+ .x = xdg_toplevel.view.surface_box.x - xdg_toplevel.view.pending.box.x,
+ .y = xdg_toplevel.view.surface_box.y - xdg_toplevel.view.pending.box.y,
+ .width = @intCast(c_int, output_dimensions.width),
+ .height = @intCast(c_int, output_dimensions.height),
+ };
+ wlr_xdg_popup.unconstrainFromBox(&box);
+ },
+ .layer_surface => |layer_surface| {
+ const output_dimensions = layer_surface.output.getEffectiveResolution();
+ // The output box relative to the parent of the xdg_popup
+ var box = wlr.Box{
+ .x = layer_surface.box.x,
+ .y = layer_surface.box.y,
+ .width = @intCast(c_int, output_dimensions.width),
+ .height = @intCast(c_int, output_dimensions.height),
+ };
+ wlr_xdg_popup.unconstrainFromBox(&box);
+ },
.drag_icon => unreachable,
- };
- const output_dimensions = switch (parent) {
- .xdg_toplevel => |xdg_toplevel| xdg_toplevel.view.output.getEffectiveResolution(),
- .layer_surface => |layer_surface| layer_surface.output.getEffectiveResolution(),
- .drag_icon => unreachable,
- };
-
- // The output box relative to the parent of the xdg_popup
- var box = wlr.Box{
- .x = -parent_box.x,
- .y = -parent_box.y,
- .width = @intCast(c_int, output_dimensions.width),
- .height = @intCast(c_int, output_dimensions.height),
- };
- wlr_xdg_popup.unconstrainFromBox(&box);
+ }
wlr_xdg_popup.base.events.destroy.add(&xdg_popup.surface_destroy);
wlr_xdg_popup.base.events.map.add(&xdg_popup.map);