]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xdg-shell: fix popup on wrong output
authorJohan Malm <jgm323@gmail.com>
Sun, 6 Oct 2024 18:51:59 +0000 (19:51 +0100)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Mon, 7 Oct 2024 22:34:25 +0000 (07:34 +0900)
src/xdg-popup.c

index dd17b990a5d6070205133090baf1c311f04f59d8..468a303cf417d7cdc76a9c8b1da446f6661a8fc2 100644 (file)
@@ -7,6 +7,7 @@
  *     - keeping non-layer-shell xdg-popups outside the layers.c code
  */
 
+#include "common/macros.h"
 #include "common/mem.h"
 #include "labwc.h"
 #include "node.h"
@@ -33,11 +34,18 @@ popup_unconstrain(struct xdg_popup *popup)
        struct wlr_scene_tree *parent_tree = popup->wlr_popup->parent->data;
        wlr_scene_node_coords(&parent_tree->node, &parent_lx, &parent_ly);
 
-       /* Get usable area to constrain by */
+       /*
+        * Get usable area to constrain by
+        *
+        * The scheduled top-left corner (x, y) of the popup is sometimes less
+        * than zero, typically with Qt apps. We therefore clamp it to avoid for
+        * example the 'File' menu of a maximized window to end up on an another
+        * output.
+        */
        struct wlr_box *popup_box = &popup->wlr_popup->scheduled.geometry;
        struct output *output = output_nearest_to(server,
-               parent_lx + popup_box->x,
-               parent_ly + popup_box->y);
+               parent_lx + MAX(popup_box->x, 0),
+               parent_ly + MAX(popup_box->y, 0));
        struct wlr_box usable = output_usable_area_in_layout_coords(output);
 
        /* Get offset of toplevel window from its surface */