Skip to content

Commit f476037

Browse files
committed
Merge pull request #109109 from bruvzg/moue_no_focus
Forward mouse events to embedded no-focus windows.
2 parents b7f5ddd + 3b12b34 commit f476037

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

editor/doc/editor_help.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4686,7 +4686,7 @@ void EditorHelpBitTooltip::popup_under_cursor() {
46864686
// When `FLAG_POPUP` is false, it prevents the editor from losing focus when displaying the tooltip.
46874687
// This way, clicks and double-clicks are still available outside the tooltip.
46884688
set_flag(Window::FLAG_POPUP, false);
4689-
set_flag(Window::FLAG_NO_FOCUS, !is_embedded());
4689+
set_flag(Window::FLAG_NO_FOCUS, true);
46904690
popup(r);
46914691
}
46924692

scene/main/viewport.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,6 +3092,24 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
30923092
}
30933093

30943094
if (!gui.subwindow_focused) {
3095+
// No window focus, check for unfocusable windows under the cursor.
3096+
Ref<InputEventMouse> me = p_event;
3097+
if (me.is_valid()) {
3098+
for (int i = gui.sub_windows.size() - 1; i >= 0; i--) {
3099+
const SubWindow &sw = gui.sub_windows[i];
3100+
if (!sw.window->get_flag(Window::FLAG_NO_FOCUS) || sw.window->get_flag(Window::FLAG_MOUSE_PASSTHROUGH)) {
3101+
continue;
3102+
}
3103+
Rect2i r = Rect2i(sw.window->get_position(), sw.window->get_size());
3104+
if (r.has_point(me->get_position())) {
3105+
Transform2D window_ofs;
3106+
window_ofs.set_origin(-sw.window->get_position());
3107+
Ref<InputEvent> ev = p_event->xformed_by(window_ofs);
3108+
sw.window->_window_input(ev);
3109+
return true;
3110+
}
3111+
}
3112+
}
30953113
return false;
30963114
}
30973115

0 commit comments

Comments
 (0)