Skip to content

Commit 0f81e8c

Browse files
committed
X11: Fix fullscreen exit behavior
1 parent 7680190 commit 0f81e8c

File tree

2 files changed

+8
-41
lines changed

2 files changed

+8
-41
lines changed

platform/linuxbsd/x11/display_server_x11.cpp

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,11 +2394,12 @@ void DisplayServerX11::_update_size_hints(WindowID p_window) {
23942394
XSizeHints *xsh = XAllocSizeHints();
23952395

23962396
// Always set the position and size hints - they should be synchronized with the actual values after the window is mapped anyway
2397-
xsh->flags |= PPosition | PSize;
2397+
xsh->flags |= PPosition | PSize | PWinGravity;
23982398
xsh->x = wd.position.x;
23992399
xsh->y = wd.position.y;
24002400
xsh->width = wd.size.width;
24012401
xsh->height = wd.size.height;
2402+
xsh->win_gravity = StaticGravity;
24022403

24032404
if (window_mode == WINDOW_MODE_FULLSCREEN || window_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
24042405
// Do not set any other hints to prevent the window manager from ignoring the fullscreen flags
@@ -2562,29 +2563,7 @@ void DisplayServerX11::window_set_position(const Point2i &p_position, WindowID p
25622563
}
25632564

25642565
wd.position = p_position;
2565-
int x = 0;
2566-
int y = 0;
2567-
if (!window_get_flag(WINDOW_FLAG_BORDERLESS, p_window)) {
2568-
//exclude window decorations
2569-
XSync(x11_display, False);
2570-
Atom prop = XInternAtom(x11_display, "_NET_FRAME_EXTENTS", True);
2571-
if (prop != None) {
2572-
Atom type;
2573-
int format;
2574-
unsigned long len;
2575-
unsigned long remaining;
2576-
unsigned char *data = nullptr;
2577-
if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
2578-
if (format == 32 && len == 4 && data) {
2579-
long *extents = (long *)data;
2580-
x = extents[0];
2581-
y = extents[2];
2582-
}
2583-
XFree(data);
2584-
}
2585-
}
2586-
}
2587-
XMoveWindow(x11_display, wd.x11_window, p_position.x - x, p_position.y - y);
2566+
XMoveWindow(x11_display, wd.x11_window, p_position.x, p_position.y);
25882567
_update_real_mouse_position(wd);
25892568
}
25902569

@@ -3100,21 +3079,12 @@ void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
31003079
} break;
31013080
case WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
31023081
case WINDOW_MODE_FULLSCREEN: {
3103-
//Remove full-screen
3104-
wd.fullscreen = false;
3105-
wd.exclusive_fullscreen = false;
3106-
3107-
_set_wm_fullscreen(p_window, false, false);
3108-
3109-
//un-maximize required for always on top
3110-
bool on_top = window_get_flag(WINDOW_FLAG_ALWAYS_ON_TOP, p_window);
3111-
3112-
window_set_position(wd.last_position_before_fs, p_window);
3113-
3114-
if (on_top) {
3115-
_set_wm_maximized(p_window, false);
3082+
// Only remove fullscreen when necessary.
3083+
if (p_mode == WINDOW_MODE_WINDOWED || p_mode == WINDOW_MODE_MAXIMIZED) {
3084+
wd.fullscreen = false;
3085+
wd.exclusive_fullscreen = false;
3086+
_set_wm_fullscreen(p_window, false, false);
31163087
}
3117-
31183088
} break;
31193089
case WINDOW_MODE_MAXIMIZED: {
31203090
// Varies between target modes, so do nothing here.
@@ -3132,8 +3102,6 @@ void DisplayServerX11::window_set_mode(WindowMode p_mode, WindowID p_window) {
31323102
} break;
31333103
case WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
31343104
case WINDOW_MODE_FULLSCREEN: {
3135-
wd.last_position_before_fs = wd.position;
3136-
31373105
if (window_get_flag(WINDOW_FLAG_ALWAYS_ON_TOP, p_window)) {
31383106
_set_wm_maximized(p_window, true);
31393107
}

platform/linuxbsd/x11/display_server_x11.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ class DisplayServerX11 : public DisplayServer {
200200
bool resize_disabled = false;
201201
bool no_min_btn = false;
202202
bool no_max_btn = false;
203-
Vector2i last_position_before_fs;
204203
bool focused = true;
205204
bool minimized = false;
206205
bool maximized = false;

0 commit comments

Comments
 (0)