From 9ffeef76975579e0d838ea781a64ec66b92c9851 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Tue, 2 May 2023 17:59:08 +0200 Subject: Wayland: problem with menus on secondary monitor - cont'd (#724) --- src/Fl_Menu.cxx | 6 ++++++ src/Fl_Window_Driver.H | 1 + src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 22 ++++++++++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 91dda87b9..d67b116d0 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -186,6 +186,12 @@ static menuwindow *to_menuwindow(Fl_Window *win) { return ((window_with_items*)win)->as_menuwindow(); } +/** Returns whether win is a menutitle window */ +bool Fl_Window_Driver::is_menutitle(Fl_Window *win) { + if (!win->menu_window()) return false; + return (((window_with_items*)win)->as_menuwindow() == NULL); +} + /** Accessor to the "origin" member variable of class menuwindow. Variable origin is not NULL when 2 menuwindow's occur, one being a submenu of the other; it links the menuwindow at right to the one at left. */ diff --git a/src/Fl_Window_Driver.H b/src/Fl_Window_Driver.H index a4240cdcf..0149d28b0 100644 --- a/src/Fl_Window_Driver.H +++ b/src/Fl_Window_Driver.H @@ -202,6 +202,7 @@ public: static int menu_selected(Fl_Window*); static bool is_floating_title(Fl_Window *); static void scroll_to_selected_item(Fl_Window *); + static bool is_menutitle(Fl_Window *); virtual fl_uintptr_t os_id() { return 0; } }; diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index eb7915e0e..cedd04502 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1277,13 +1277,23 @@ void Fl_Wayland_Window_Driver::makeWindow() Fl::e_number = old_event; // make sure each popup is mapped with its constraints before mapping next popup if (pWindow->menu_window() && !is_floatingtitle) { - int count = 0; // attempt to map the menuwindow (i.e., until it appears on a screen) - while (!new_window->output && count <= 5) { - wl_display_roundtrip(scr_driver->wl_display); - count++; + int HH; + Fl_Window_Driver::menu_parent(&HH); + bool simple = (menu_bartitle(pWindow) || is_menutitle(pWindow) || pWindow->h() > HH); + if (!simple) { + simple = (menu_leftorigin(pWindow) != NULL); } - if (!new_window->output) { -//printf("menuwindow doesn't map: count=%d\n",count); + if (simple) { + pWindow->wait_for_expose(); + } else { + int count = 0; // attempt to map the menuwindow (i.e., until it appears on a screen) + while (!new_window->output && count <= 5) { + wl_display_roundtrip(scr_driver->wl_display); + count++; + } + } + if (!new_window->output && !simple) { +//printf("menuwindow doesn't map: pWindow=%p\n",pWindow); // On a secondary display, the menuwindow may fail to map in what looks like // a bug in the compositor. Bypass this problem by attempting again to create // the menuwindow with another constraint: XDG_POSITIONER_GRAVITY_TOP_RIGHT -- cgit v1.2.3