X Tutup
Skip to content

X11: Fix minimization of maximized windows#110990

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
timothyqiu:x11-min-max
Oct 10, 2025
Merged

X11: Fix minimization of maximized windows#110990
Repiteo merged 1 commit intogodotengine:masterfrom
timothyqiu:x11-min-max

Conversation

@timothyqiu
Copy link
Member

@timothyqiu timothyqiu commented Sep 28, 2025

Currently, when a maximized window is minimized by...

  • Clicking the minimize button on the title bar or the window button on task bar:
    get_window().mode still returns WINDOW_MODE_MAXIMIZED.
  • Changing the window mode via code:
    Unminimizing the window by clicking the window button on task bar does not work for the first time, i.e., you have to click the button twice to see the window.

The first case is simple: "minimized" currently has less priority than other modes. Maximized and minimized are independent states for window managers and are not mutually exclusive. So reordering the checks solves the problem.

const WindowData &wd = windows[p_window];
if (wd.fullscreen) { //if fullscreen, it's not in another mode
if (wd.exclusive_fullscreen) {
return WINDOW_MODE_EXCLUSIVE_FULLSCREEN;
} else {
return WINDOW_MODE_FULLSCREEN;
}
}
// Test maximized.
// Using EWMH -- Extended Window Manager Hints
if (_window_maximize_check(p_window, "_NET_WM_STATE")) {
return WINDOW_MODE_MAXIMIZED;
}
{
if (_window_minimize_check(p_window)) {
return WINDOW_MODE_MINIMIZED;
}
}

The second case is more or less messed up I think. I reverted some of the modifications in:

  • Linux: Ensure WindowData minimized/maximized are mutually exclusive #76868
    This one confuses window states stored in WindowData (minimized, maximized, fullscreen, etc.) with window modes. The former models states in window managers, while the latter is a Godot concept. It's a wrong fix for the issue it trys to solve, the problem still exists in another form.
  • Fix minimize/maximize not taking effect in X11. #65107
    This one is trying to fix the problem of initial window state not being honoured. But it's done by changing window states in MapNotify, i.e., whenever the window appears on the screen. This includes when the window is unminimized. This is the root cause of the problem.

The minimize / maximize states should use _NET_WM_STATE:

  • Initial values are set using XChangeProperty before XMapWindow.
  • Updates are received in PropertyNotify. We don't need to remember the window's state before minimization ourselves. After the user manually cancels minimization, the window manager will update the _NET_WM_STATE to the correct state, be it maximized or fullscreen.

I also removed the minimization state update logic in NoExpose and VisibilityNotify. These two events are not related to window states at all. The former can only be received during XCopyArea or XCopyPlane calls which Godot does not use. The latter is about the window being obscured by other windows instead of the "visibility" in Godot term.

p.s. The fullscreen state may also have similar problems that have accumulated over the years. I took a quick look and it seems to be more complex, with mixed old and new code. Let's fix the problems one step at a time.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected (I could reproduce both issues mentioned on master). Code looks good to me.

Testing project: test_minimize.zip

Operating System: Fedora Linux 42
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.18.0
Qt Version: 6.9.2
Kernel Version: 6.16.9-200.fc42.x86_64 (64-bit)
Graphics Platform: X11

Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and seems to be working as expected.

@Repiteo Repiteo merged commit 4ea49ae into godotengine:master Oct 10, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 10, 2025

Thanks!

@timothyqiu timothyqiu deleted the x11-min-max branch October 10, 2025 16:15
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.

5 participants

X Tutup