Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[X11] Fix mouse events triggered by non-popup or non-focused window #94688

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Cliear
Copy link

@Cliear Cliear commented Jul 24, 2024

Fix: #94615
There are several issues here:

  1. By default, the focused property of windows created by X11 is set to true:


    And it is only modified after a focus event occurs:
    case FocusIn: {
    DEBUG_LOG_X11("[%u] FocusIn window=%lu (%u), mode='%u' \n", frame, event.xfocus.window, window_id, event.xfocus.mode);
    if (ime_window_event || (event.xfocus.detail == NotifyInferior)) {
    break;
    }
    WindowData &wd = windows[window_id];
    last_focused_window = window_id;
    wd.focused = true;

    case FocusOut: {
    DEBUG_LOG_X11("[%u] FocusOut window=%lu (%u), mode='%u' \n", frame, event.xfocus.window, window_id, event.xfocus.mode);
    WindowData &wd = windows[window_id];
    if (ime_window_event || (event.xfocus.detail == NotifyInferior)) {
    break;
    }
    if (wd.ime_active) {
    MutexLock mutex_lock(events_mutex);
    XUnsetICFocus(wd.xic);
    XUnmapWindow(x11_display, wd.x11_xim_window);
    wd.ime_active = false;
    im_text = String();
    im_selection = Vector2i();
    OS_Unix::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE);
    }
    wd.focused = false;

  2. That leads to a situation where the focued of main window is true, and the newly created popup window also has a focused property of true, resulting in multiple windows with a true focused property.

  3. When a mouse movement event occurs, if the event happens on the main window and the main window's focued property is true, even if the popup window's focused property is also true, the event will be handled by the main window, During the main window' event handling process, it will close the popop window.

And I am not sure whether to modify the default focused property.

@Cliear Cliear requested a review from a team as a code owner July 24, 2024 08:22
@AThousandShips AThousandShips added this to the 4.3 milestone Jul 24, 2024
@akien-mga akien-mga changed the title [X11] fix the issue where mouse events are triggered by non-popup or non-focued window [X11] Fix mouse events triggered by non-popup or non-focused window Jul 24, 2024
@akien-mga akien-mga requested a review from bruvzg July 24, 2024 08:54
@kitbdev
Copy link
Contributor

kitbdev commented Jul 24, 2024

Would this introduce either of these issues on X11:

@Cliear
Copy link
Author

Cliear commented Jul 25, 2024

Here indeed introduces a problem
tooltip_stuck——1
When The mouse moves quickly, it ignores the event.
When the mouse enters anther block and stops immediately, this event will be captured by the popup window.
To ensure consistency with behavior on other platforms, the condition can be changed to "windows[focused_window_id].mpass || wd.is_popup"

@Cliear
Copy link
Author

Cliear commented Jul 25, 2024

Here is an issue in 4.3 bata 3
popup_no_pop
The issue have become more apparent after this update

@akien-mga akien-mga modified the milestones: 4.3, 4.4 Jul 31, 2024
@akien-mga akien-mga added the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release platform:linuxbsd regression topic:gui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Popup window is closed by tooltips of other components on X11
4 participants