summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-12-26 08:13:27 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-12-26 08:13:27 +0100
commit694df9d7e656c4638430c76c83aa4c81b03ae1bb (patch)
treeac044c143a6d8b3b59a233f7bc26d91b598b2c2d
parentb26db74dd0be8e4f4728e976144cb15e64b677a5 (diff)
Wayland: Fix for "Dropdown menu moves when navigated" (#613)
This commit uses Wayland popup positionning methods to handle common menu windows and prevents them from expanding below display bottom or above top. The previous algorithm remains in place for menu windows higher than the display height. Further changes for these big menus may come later.
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index 09a0feb1a..f5399af0c 100644
--- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -1005,6 +1005,13 @@ Fl_X *Fl_Wayland_Window_Driver::makeWindow()
xdg_positioner_set_size(positioner, pWindow->w() * f , pWindow->h() * f );
xdg_positioner_set_anchor(positioner, XDG_POSITIONER_ANCHOR_TOP_LEFT);
xdg_positioner_set_gravity(positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
+ int XX, YY, WW, HH;
+ Fl::screen_xywh(XX, YY, WW, HH, parent_win->screen_num());
+ if (pWindow->h() <= HH) {
+ // prevent menuwindow from expanding beyond display bottom
+ xdg_positioner_set_constraint_adjustment(positioner,
+ XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y);
+ }
new_window->xdg_popup = xdg_surface_get_popup(new_window->xdg_surface, parent_xdg, positioner);
xdg_positioner_destroy(positioner);
xdg_popup_add_listener(new_window->xdg_popup, &popup_listener, new_window);
@@ -1550,10 +1557,19 @@ void Fl_Wayland_Window_Driver::reposition_menu_window(int x, int y) {
void Fl_Wayland_Window_Driver::menu_window_area(int &X, int &Y, int &W, int &H, int nscreen) {
Fl_Window *parent = Fl_Window_Driver::menu_parent();
if (parent) {
- X = parent->x();
- Y = parent->y();
- W = parent->w();
- H = parent->h();
+ int XX,YY,WW,HH;
+ Fl::screen_xywh(XX, YY, WW, HH, parent->screen_num());
+ if (pWindow->h() > HH) { // the menu window is higher than the display
+ X = parent->x();
+ Y = parent->y();
+ W = parent->w();
+ H = parent->h();
+ } else { // position the menu window by wayland constraints
+ X = -50000;
+ Y = -50000;
+ W = 1000000;
+ H = 1000000;
+ }
//printf("menu_window_area: %dx%d - %dx%d\n",X,Y,W,H);
} else Fl_Window_Driver::menu_window_area(X, Y, W, H, nscreen);
}