diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index c5c5e8c05..0b2ce2a59 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1281,6 +1281,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar lParam_rect->right - lParam_rect->left, lParam_rect->bottom - lParam_rect->top, flags); if (ns >= 0) { + if (Fl::modal() && Fl::modal()->menu_window()) { // is a menu window active? + Fl::e_x_root = 1000000; + Fl::modal()->handle(FL_PUSH); // simulate a distant click to close menus + } scale = Fl::screen_driver()->scale(ns); EnumChildWindows(hWnd, child_window_cb, (LPARAM)&scale); } diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 19d790f6e..4fd4831db 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -2221,6 +2221,10 @@ int fl_handle(const XEvent& thisevent) if (num == -1) num = olds; float s = d->scale(num); if (num != olds && !window->menu_window()) { + if (Fl::modal() && Fl::modal()->menu_window()) { // is a menu window active? + Fl::e_x_root = 1000000; + Fl::modal()->handle(FL_PUSH); // simulate a distant click to close menus + } if (s != d->scale(olds) && !Fl_X11_Window_Driver::data_for_resize_window_between_screens_.busy && window->user_data() != &Fl_X11_Screen_Driver::transient_scale_display) { diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 0495fb7bc..4fc6df25d 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -719,6 +719,13 @@ static void surface_enter(void *data, struct wl_surface *wl_surface, (Fl_Wayland_Screen_Driver::output*)wl_output_get_user_data(wl_output); if (output == NULL) return; + // Detect when the parent window of an active menu window enters a screen. If so, we are + // moving a window with active menus to a new screen. We want to close all menus. + if (Fl::modal() && Fl::modal()->menu_window() && + Fl_Window_Driver::menu_parent() == window->fl_win) { + Fl::e_x_root = 1000000; + Fl::modal()->handle(FL_PUSH); // simulate a distant click to close menus + } bool list_was_empty = wl_list_empty(&window->outputs); struct Fl_Wayland_Window_Driver::surface_output *surface_output =