Skip to content

Fix close dropdown popups correctly on focus loss (X11)#118075

Open
MWRAlves wants to merge 1 commit intogodotengine:masterfrom
MWRAlves:fix-104267
Open

Fix close dropdown popups correctly on focus loss (X11)#118075
MWRAlves wants to merge 1 commit intogodotengine:masterfrom
MWRAlves:fix-104267

Conversation

@MWRAlves
Copy link
Copy Markdown

@MWRAlves MWRAlves commented Apr 1, 2026

Fixes #104267
Fixes an X11 issue where dropdown menus and similar popups could remain open after switching to another window or workspace.

On X11, some no_focus popup windows could remain internally marked as focused even after the application had actually lost focus. This stale focus state prevented the normal application focus loss path from fully updating popup state, which could leave dropdowns visible after Alt-Tab or workspace switching.

This change keeps the fix X11-specific, the only place I verified the bug occurred in my system as opposed to Wayland, by:

using _window_focus_check() to determine whether the application still has focus
clearing stale focused state for is_popup && no_focus windows only when the application has actually lost focus

Manual Testing:
(On X11 display server)
Open an editor dropdown menu, Alt-Tab away: popup no longer persists
Open an editor dropdown menu, switch workspace: popup no longer persists
Verify normal popup dismissal still works inside the editor

On X11, dropdown menus and similar no-focus popups could remain open
after switching to another window or workspace. This happened because
some popup windows could stay internally marked as focused even after
the application had actually lost focus.

Use the X11 input focus state to detect real application focus loss,
and when that happens, clear stale focused state from popup windows
marked as both popup and no-focus.
@MWRAlves MWRAlves requested a review from a team as a code owner April 1, 2026 14:24
@dsnopek
Copy link
Copy Markdown
Contributor

dsnopek commented Apr 1, 2026

Thanks!

Can you give concrete steps to reproduce the bug (without your PR), as well as which windowing manager you're testing with?

In the past, we've issues with window focus, where a change to fix one WM broke another WM, and so we'll need to test this across several WM's to ensure there are no regressions

@MWRAlves
Copy link
Copy Markdown
Author

MWRAlves commented Apr 1, 2026

The bug was tested on Ubuntu 24.04, GNOME Shell (Mutter), Wayland session.
An important point to consider is that, even though I was in a Wayland session, Godot defaulted to the X11 display driver.
I managed to reproduce the bug in that environment without issue.
However I still attempted to reproduce the bug with the Wayland display driver but, when I switched to it, the bug was resolved.
That's how I narrowed it down to an X11 only problem.

I tested the bug in two ways: using a regular menu in the editor and right-clicking on a node.
Both these methods produce a dropdown menu which is a popup.

On an unpatched build, I can reproduce the bug with these steps, for each method:

For the editor menu case:

  1. Start the editor with the X11 display backend.
  2. Open or create a project, it can be empty.
  3. Open a dropdown menu such as Scene in the editor.
  4. While the popup is still open, switch to another workspace or alt-tab away to another application.
  5. The popup persists even though the application had already lost focus.

For the right-click case:

  1. Start the editor with the X11 display backend.
  2. Create an empty project.
  3. Click 2D Scene which creates a 2D scene with a Node2D.
  4. Right-click on Node2D, opening a dropdown menu.
  5. While the popup is still open, switch to another workspace or alt-tab away to another application.
  6. The popup persists even though the application had already lost focus.

I can also include a video of the bug if that would help. I'm eager to solve this as well as possible.

@Nintorch Nintorch added this to the 4.x milestone Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dropdown menu is persistent through workspaces or after alt-tabbing

3 participants