Repository: godotengine/godot (language: cpp)

Issue:
Persistent window state does not work for linux X11 gnome-shell 'tiled/docked/snapped' editor windows
### Tested versions

- Reproducible on Godot 4.4-stable

### System information

Godot v4.4.stable - Ubuntu 22.04.5 LTS 22.04 on X11 - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3050 Laptop GPU - 12th Gen Intel(R) Core(TM) i7-12700H (14 threads)

### Issue description

[Persistent window state](https://godotengine.org/releases/4.4/#persistent-window-state) doesn't work if your window is 'tiled' in X11 gnome.

Tested on X11 GNOME Shell 42.9  Xorg: 1:7.7+23ubuntu2


It looks like `_NET_WM_STATE` is `..._MAXIMIZED_VERT` which isn't the same as maximized..

The window geometry is `0,65+2558x1375`

But when I re-open it becomes `..._MAXIMIZED_VERT | ..._MAXIMIZED_HORIZ`
and the window geometry is  `0,64+5120x1376`

BEFORE closing
```
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_VERT
WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 1
_GTK_EDGE_CONSTRAINTS(CARDINAL) = 89
_NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 37, 0
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_MOVE, _NET_WM_ACTION_RESIZE, _NET_WM_ACTION_FULLSCREEN, _NET_WM_ACTION_MINIMIZE, _NET_WM_ACTION_SHADE, _NET_WM_ACTION_MAXIMIZE_HORZ, _NET_WM_ACTION_MAXIMIZE_VERT, _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_CLOSE, _NET_WM_ACTION_ABOVE, _NET_WM_ACTION_BELOW
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified location: 0, 65
                program specified size: 2558 by 1375
                program specified minimum size: 1024 by 600
                program specified maximum size: 32768 by 32768
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
WM_CLASS(STRING) = "Godot_Editor", "Godot"
XdndAware(ATOM) = BITMAP
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW
WM_NAME(STRING) = "(*) main.tscn - Ultimate Fabric Challenge - Godot Engine"
_NET_WM_PID(CARDINAL) = 4045156
```

AFTER re-opening
```_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT
WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 1
_GTK_EDGE_CONSTRAINTS(CARDINAL) = 85
_NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 37, 0
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_MOVE, _NET_WM_ACTION_RESIZE, _NET_WM_ACTION_FULLSCREEN, _NET_WM_ACTION_MINIMIZE, _NET_WM_ACTION_SHADE, _NET_WM_ACTION_MAXIMIZE_HORZ, _NET_WM_ACTION_MAXIMIZE_VERT, _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_CLOSE, _NET_WM_ACTION_ABOVE, _NET_WM_ACTION_BELOW
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified location: 0, 64
                program specified size: 5120 by 1376
                program specified minimum size: 1024 by 600
                program specified maximum size: 32768 by 32768
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
WM_CLASS(STRING) = "Godot_Editor", "Godot"
XdndAware(ATOM) = BITMAP
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW
WM_NAME(STRING) = "(*) main.tscn - Ultimate Fabric Challenge - Godot Engine"
_NET_WM_PID(CARDINAL) = 4048202
```

### Steps to reproduce

Re-open the window in gnome window manager after snapping to the left or right

### Minimal reproduction project (MRP)

no MRP possible?


Discussion / hints:

Fix patch:
diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp
index 26c94bf25cf1..ead01551939f 100644
--- a/platform/linuxbsd/x11/display_server_x11.cpp
+++ b/platform/linuxbsd/x11/display_server_x11.cpp
@@ -2563,7 +2563,8 @@ bool DisplayServerX11::_window_maximize_check(WindowID p_window, const char *p_a
 		Atom *atoms = (Atom *)data;
 		Atom wm_act_max_horz;
 		Atom wm_act_max_vert;
-		if (strcmp(p_atom_name, "_NET_WM_STATE") == 0) {
+		bool checking_state = strcmp(p_atom_name, "_NET_WM_STATE") == 0;
+		if (checking_state) {
 			wm_act_max_horz = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
 			wm_act_max_vert = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
 		} else {
@@ -2581,9 +2582,16 @@ bool DisplayServerX11::_window_maximize_check(WindowID p_window, const char *p_a
 				found_wm_act_max_vert = true;
 			}
 
-			if (found_wm_act_max_horz || found_wm_act_max_vert) {
-				retval = true;
-				break;
+			if (checking_state) {
+				if (found_wm_act_max_horz && found_wm_act_max_vert) {
+					retval = true;
+					break;
+				}
+			} else {
+				if (found_wm_act_max_horz || found_wm_act_max_vert) {
+					retval = true;
+					break;
+				}
 			}
 		}
 


Test patch: