Merge pull request #69678 from Sauermann/fix-slider-button-up

Fix colorpicker slider bug with mouse-up outside of popup
This commit is contained in:
Rémi Verschelde 2022-12-16 13:47:53 +01:00
commit f8f496ec3b
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 24 additions and 12 deletions

View File

@ -3985,29 +3985,41 @@ void DisplayServerX11::process_events() {
} else { } else {
DEBUG_LOG_X11("[%u] ButtonRelease window=%lu (%u), button_index=%u \n", frame, event.xbutton.window, window_id, mb->get_button_index()); DEBUG_LOG_X11("[%u] ButtonRelease window=%lu (%u), button_index=%u \n", frame, event.xbutton.window, window_id, mb->get_button_index());
if (!wd.focused) { WindowID window_id_other = INVALID_WINDOW_ID;
Window wd_other_x11_window;
if (wd.focused) {
// Handle cases where an unfocused popup is open that needs to receive button-up events.
WindowID popup_id = _get_focused_window_or_popup();
if (popup_id != INVALID_WINDOW_ID && popup_id != window_id) {
window_id_other = popup_id;
wd_other_x11_window = windows[popup_id].x11_window;
}
} else {
// Propagate the event to the focused window, // Propagate the event to the focused window,
// because it's received only on the topmost window. // because it's received only on the topmost window.
// Note: This is needed for drag & drop to work between windows, // Note: This is needed for drag & drop to work between windows,
// because the engine expects events to keep being processed // because the engine expects events to keep being processed
// on the same window dragging started. // on the same window dragging started.
for (const KeyValue<WindowID, WindowData> &E : windows) { for (const KeyValue<WindowID, WindowData> &E : windows) {
const WindowData &wd_other = E.value; if (E.value.focused) {
WindowID window_id_other = E.key; if (E.key != window_id) {
if (wd_other.focused) { window_id_other = E.key;
if (window_id_other != window_id) { wd_other_x11_window = E.value.x11_window;
int x, y;
Window child;
XTranslateCoordinates(x11_display, wd.x11_window, wd_other.x11_window, event.xbutton.x, event.xbutton.y, &x, &y, &child);
mb->set_window_id(window_id_other);
mb->set_position(Vector2(x, y));
mb->set_global_position(mb->get_position());
} }
break; break;
} }
} }
} }
if (window_id_other != INVALID_WINDOW_ID) {
int x, y;
Window child;
XTranslateCoordinates(x11_display, wd.x11_window, wd_other_x11_window, event.xbutton.x, event.xbutton.y, &x, &y, &child);
mb->set_window_id(window_id_other);
mb->set_position(Vector2(x, y));
mb->set_global_position(mb->get_position());
}
} }
Input::get_singleton()->parse_input_event(mb); Input::get_singleton()->parse_input_event(mb);