mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 22:21:18 +00:00
Merge pull request #65496 from MinusKube/popup-capture-mouse-bug
Fix MOUSE_MODE_CAPTURED not working correctly with popups
This commit is contained in:
commit
d79040e7eb
9 changed files with 92 additions and 37 deletions
|
|
@ -397,7 +397,10 @@ void DisplayServerX11::mouse_set_mode(MouseMode p_mode) {
|
|||
if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED || mouse_mode == MOUSE_MODE_CONFINED_HIDDEN) {
|
||||
//flush pending motion events
|
||||
_flush_mouse_motion();
|
||||
WindowID window_id = windows.has(last_focused_window) ? last_focused_window : MAIN_WINDOW_ID;
|
||||
WindowID window_id = _get_focused_window_or_popup();
|
||||
if (!windows.has(window_id)) {
|
||||
window_id = MAIN_WINDOW_ID;
|
||||
}
|
||||
WindowData &window = windows[window_id];
|
||||
|
||||
if (XGrabPointer(
|
||||
|
|
@ -433,7 +436,11 @@ void DisplayServerX11::warp_mouse(const Point2i &p_position) {
|
|||
if (mouse_mode == MOUSE_MODE_CAPTURED) {
|
||||
last_mouse_pos = p_position;
|
||||
} else {
|
||||
WindowID window_id = windows.has(last_focused_window) ? last_focused_window : MAIN_WINDOW_ID;
|
||||
WindowID window_id = _get_focused_window_or_popup();
|
||||
if (!windows.has(window_id)) {
|
||||
window_id = MAIN_WINDOW_ID;
|
||||
}
|
||||
|
||||
XWarpPointer(x11_display, None, windows[window_id].x11_window,
|
||||
0, 0, 0, 0, (int)p_position.x, (int)p_position.y);
|
||||
}
|
||||
|
|
@ -3181,6 +3188,15 @@ void DisplayServerX11::_window_changed(XEvent *event) {
|
|||
}
|
||||
}
|
||||
|
||||
DisplayServer::WindowID DisplayServerX11::_get_focused_window_or_popup() const {
|
||||
const List<WindowID>::Element *E = popup_list.back();
|
||||
if (E) {
|
||||
return E->get();
|
||||
}
|
||||
|
||||
return last_focused_window;
|
||||
}
|
||||
|
||||
void DisplayServerX11::_dispatch_input_events(const Ref<InputEvent> &p_event) {
|
||||
static_cast<DisplayServerX11 *>(get_singleton())->_dispatch_input_event(p_event);
|
||||
}
|
||||
|
|
@ -3936,7 +3952,11 @@ void DisplayServerX11::process_events() {
|
|||
// The X11 API requires filtering one-by-one through the motion
|
||||
// notify events, in order to figure out which event is the one
|
||||
// generated by warping the mouse pointer.
|
||||
WindowID focused_window_id = windows.has(last_focused_window) ? last_focused_window : MAIN_WINDOW_ID;
|
||||
WindowID focused_window_id = _get_focused_window_or_popup();
|
||||
if (!windows.has(focused_window_id)) {
|
||||
focused_window_id = MAIN_WINDOW_ID;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (mouse_mode == MOUSE_MODE_CAPTURED && event.xmotion.x == windows[focused_window_id].size.width / 2 && event.xmotion.y == windows[focused_window_id].size.height / 2) {
|
||||
//this is likely the warp event since it was warped here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue