From 4571af24abdac6f79143b4db19b103cf6499ef07 Mon Sep 17 00:00:00 2001
From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
Date: Thu, 12 Dec 2024 12:09:53 +0100
Subject: [PATCH] Fix:  Window can be moved while menu is open (#1166)

---
 src/Fl_win32.cxx | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 6ba193f3c..509f76767 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -1398,6 +1398,11 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
         break;
 
       case WM_SETFOCUS:
+        if (Fl::grab() && (Fl::grab() != window) && Fl::grab()->menu_window()) {
+          // simulate click at remote location (see issue #1166)
+          mouse_event(Fl::grab(), 0, 1, MK_LBUTTON, MAKELPARAM(100000, 0));
+          return 0;
+        }
         if ((Fl::modal_) && (Fl::modal_ != window)) {
           SetFocus(fl_xid(Fl::modal_));
           return 0;
-- 
GitLab