diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 8cce19c9a..b3319f62b 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1267,6 +1267,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 b286682d2..351a0bb4e 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -2216,6 +2216,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 79bed5a28..08f3f83d0 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -703,6 +703,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 + } Fl_Wayland_Window_Driver *win_driver = Fl_Wayland_Window_Driver::driver(window->fl_win); float pre_scale = Fl::screen_scale(win_driver->screen_num()) * win_driver->wld_scale();