summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2025-05-30 16:44:26 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2025-05-30 16:44:26 +0200
commit86a8d138f2f3e366ccaa185fa86b97e49534dfd8 (patch)
treeb357334b3c67fdd6406335d16bfb0d324407261c /src/drivers
parentac0a5d52cbcef9b6cda8b6a2494b33523362cd9c (diff)
Fix for #1260 - part2: improve position of menu button window under Wayland
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index 9ddf78b72..c0963fa66 100644
--- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -30,6 +30,7 @@
#include <FL/fl_ask.H>
#include <FL/Fl.H>
#include <FL/Fl_Image_Surface.H>
+#include <FL/Fl_Menu_Button.H>
#include <string.h>
#include <math.h> // for ceil()
#include <sys/types.h> // for pid_t
@@ -1325,7 +1326,18 @@ bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_wi
struct xdg_positioner *positioner = xdg_wm_base_create_positioner(scr_driver->xdg_wm_base);
//xdg_positioner_get_version(positioner) <== gives 1 under Debian and Sway
int popup_x, popup_y;
- if (Fl_Window_Driver::menu_title(pWindow) && Fl_Window_Driver::menu_bartitle(pWindow)) {
+ if (Fl_Window_Driver::current_menu_button && !Fl_Window_Driver::menu_leftorigin(pWindow)) {
+ xdg_positioner_set_anchor_rect(positioner,
+ Fl_Window_Driver::current_menu_button->x() * f,
+ Fl_Window_Driver::current_menu_button->y() * f,
+ Fl_Window_Driver::current_menu_button->w() * f,
+ Fl_Window_Driver::current_menu_button->h() * f);
+ popup_x = Fl_Window_Driver::current_menu_button->x() * f;
+ popup_y = 0;
+ if (parent_xid->kind == Fl_Wayland_Window_Driver::DECORATED && !origin_win->fullscreen_active())
+ libdecor_frame_translate_coordinate(parent_xid->frame, popup_x, popup_y,
+ &popup_x, &popup_y);
+ } else if (Fl_Window_Driver::menu_title(pWindow) && Fl_Window_Driver::menu_bartitle(pWindow)) {
xdg_positioner_set_anchor_rect(positioner, 0, 0,
Fl_Window_Driver::menu_title(pWindow)->w() * f,
Fl_Window_Driver::menu_title(pWindow)->h() * f);
@@ -1344,7 +1356,7 @@ bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_wi
// prevent first popup from going above the permissible source window
popup_y = fl_max(popup_y, - pWindow->h() * f);
}
- if (parent_xid->kind == Fl_Wayland_Window_Driver::DECORATED)
+ if (parent_xid->kind == Fl_Wayland_Window_Driver::DECORATED && !origin_win->fullscreen_active())
libdecor_frame_translate_coordinate(parent_xid->frame, popup_x, popup_y,
&popup_x, &popup_y);
xdg_positioner_set_anchor_rect(positioner, popup_x, 0, 1, 1);
@@ -1371,11 +1383,12 @@ bool Fl_Wayland_Window_Driver::process_menu_or_tooltip(struct wld_window *new_wi
if ( !(parent_win->fullscreen_active() &&
Fl_Wayland_Screen_Driver::compositor == Fl_Wayland_Screen_Driver::MUTTER &&
((!Fl_Window_Driver::menu_title(pWindow) && !Fl_Window_Driver::menu_leftorigin(pWindow)) ||
- Fl_Window_Driver::menu_bartitle(pWindow)) && pWindow->y() < 10)
+ Fl_Window_Driver::menu_bartitle(pWindow)) && pWindow->y() < 10 && !Fl_Window_Driver::current_menu_button)
) {
// Condition above is only to bypass Mutter bug for fullscreen windows (see #1061)
constraint |= (XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y);
- if (Fl_Window_Driver::menu_bartitle(pWindow) && !Fl_Window_Driver::menu_leftorigin(pWindow)) {
+ if ((Fl_Window_Driver::current_menu_button || Fl_Window_Driver::menu_bartitle(pWindow)) &&
+ !Fl_Window_Driver::menu_leftorigin(pWindow)) {
constraint |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y;
}
xdg_positioner_set_constraint_adjustment(positioner, constraint);