From f8e98d5ff3035b5662f6de0ec9fe8bd0fa4e1cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anni=20Ryyn=C3=A4nen?= Date: Thu, 6 Jun 2024 20:00:05 +0300 Subject: [PATCH] Stop color picker tooltip from stealing input events Input events go to the tooltip because it's added to `popup_list` in DisplayServer `popup_open`. I think there's no harm in tooltips being omitted from the list, so this commit blocks non-popup windows from being added if they have `FLAG_NO_FOCUS` and `FLAG_MOUSE_PASSTHROUGH`. I'm not happy with this way of detecting tooltips. It'll also catch other windows where this behavior may or may not be wanted. I thought about adding `FLAG_TOOLTIP`, but went with the smaller change for now. Fixes #79500. --- platform/linuxbsd/x11/display_server_x11.cpp | 5 ++++- platform/macos/display_server_macos.mm | 5 ++++- platform/windows/display_server_windows.cpp | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index 4ca1b1109440..0e4c723a87db 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -4184,8 +4184,11 @@ void DisplayServerX11::popup_open(WindowID p_window) { } } + // Detect tooltips and other similar popups that shouldn't block input to their parent. + bool ignores_input = window_get_flag(WINDOW_FLAG_NO_FOCUS, p_window) && window_get_flag(WINDOW_FLAG_MOUSE_PASSTHROUGH, p_window); + WindowData &wd = windows[p_window]; - if (wd.is_popup || has_popup_ancestor) { + if (wd.is_popup || (has_popup_ancestor && !ignores_input)) { // Find current popup parent, or root popup if new window is not transient. List::Element *C = nullptr; List::Element *E = popup_list.back(); diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 1032766480d3..a1a91345ac4f 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -3366,8 +3366,11 @@ } } + // Detect tooltips and other similar popups that shouldn't block input to their parent. + bool ignores_input = window_get_flag(WINDOW_FLAG_NO_FOCUS, p_window) && window_get_flag(WINDOW_FLAG_MOUSE_PASSTHROUGH, p_window); + WindowData &wd = windows[p_window]; - if (wd.is_popup || has_popup_ancestor) { + if (wd.is_popup || (has_popup_ancestor && !ignores_input)) { bool was_empty = popup_list.is_empty(); // Find current popup parent, or root popup if new window is not transient. List::Element *C = nullptr; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 73987c44db1b..10cec9f5ed8a 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -3575,8 +3575,11 @@ void DisplayServerWindows::popup_open(WindowID p_window) { } } + // Detect tooltips and other similar popups that shouldn't block input to their parent. + bool ignores_input = window_get_flag(WINDOW_FLAG_NO_FOCUS, p_window) && window_get_flag(WINDOW_FLAG_MOUSE_PASSTHROUGH, p_window); + WindowData &wd = windows[p_window]; - if (wd.is_popup || has_popup_ancestor) { + if (wd.is_popup || (has_popup_ancestor && !ignores_input)) { // Find current popup parent, or root popup if new window is not transient. List::Element *C = nullptr; List::Element *E = popup_list.back();