Skip to content

Commit 05c56e8

Browse files
committed
Merge pull request #103052 from Hilderin/fix-embedded-game-mouse-over-not-focused-windows
Fix Embedded Game does not focus when mouse over on Windows
2 parents 54545d7 + c7bc322 commit 05c56e8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

editor/plugins/embedded_process.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,15 @@ void EmbeddedProcess::_check_mouse_over() {
321321
return;
322322
}
323323

324-
// When there's a modal window, we don't want to grab the focus to prevent
325-
// the game window to go in front of the modal window.
326-
if (_get_current_modal_window()) {
327-
return;
324+
// Check if there's an exclusive popup, an open menu, or a tooltip.
325+
// We don't want to grab focus to prevent the game window from coming to the front of the modal window
326+
// or the open menu from closing when the mouse cursor moves outside the menu and over the embedded game.
327+
Vector<DisplayServer::WindowID> wl = DisplayServer::get_singleton()->get_window_list();
328+
for (const DisplayServer::WindowID &window_id : wl) {
329+
Window *w = Window::get_from_id(window_id);
330+
if (w && (w->is_exclusive() || w->get_flag(Window::FLAG_POPUP))) {
331+
return;
332+
}
328333
}
329334

330335
// Force "regrabbing" the game window focus.

platform/windows/display_server_windows.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -3000,6 +3000,7 @@ Error DisplayServerWindows::embed_process(WindowID p_window, OS::ProcessID p_pid
30003000
}
30013001

30023002
if (p_grab_focus) {
3003+
SetForegroundWindow(ep->window_handle);
30033004
SetFocus(ep->window_handle);
30043005
}
30053006

0 commit comments

Comments
 (0)