diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-01-03 11:41:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-03 11:41:38 +0100 |
commit | 5019f5e29892638e1aa6a8f83b716de59799b7d9 (patch) | |
tree | 85322b9516cd1f9debb099f6193d4df3c63cc3f4 | |
parent | e3c744f9f14e29ec0c8ac4489d590414a24ab0bb (diff) | |
parent | 2a6035dff45d5dcbbecf5343d22af0c264a75701 (diff) |
Merge pull request #15092 from guilhermefelipecgs/fix_infinite_loop_on_splash_screen
Fix infinite loop on splash screen on tiling windows managers
-rw-r--r-- | platform/x11/os_x11.cpp | 50 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 2 |
2 files changed, 50 insertions, 2 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 8e3f24b0be..e9920b18a4 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1050,13 +1050,59 @@ void OS_X11::set_window_maximized(bool p_enabled) { XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); - while (p_enabled && !is_window_maximized()) { - // Wait for effective resizing (so the GLX context is too). + if (is_window_maximize_allowed()) { + while (p_enabled && !is_window_maximized()) { + // Wait for effective resizing (so the GLX context is too). + } } maximized = p_enabled; } +bool OS_X11::is_window_maximize_allowed() { + Atom property = XInternAtom(x11_display, "_NET_WM_ALLOWED_ACTIONS", False); + Atom type; + int format; + unsigned long len; + unsigned long remaining; + unsigned char *data = NULL; + + int result = XGetWindowProperty( + x11_display, + x11_window, + property, + 0, + 1024, + False, + XA_ATOM, + &type, + &format, + &len, + &remaining, + &data); + + if (result == Success) { + Atom *atoms = (Atom *)data; + Atom wm_act_max_horz = XInternAtom(x11_display, "_NET_WM_ACTION_MAXIMIZE_HORZ", False); + Atom wm_act_max_vert = XInternAtom(x11_display, "_NET_WM_ACTION_MAXIMIZE_VERT", False); + bool found_wm_act_max_horz = false; + bool found_wm_act_max_vert = false; + + for (unsigned int i = 0; i < len; i++) { + if (atoms[i] == wm_act_max_horz) + found_wm_act_max_horz = true; + if (atoms[i] == wm_act_max_vert) + found_wm_act_max_vert = true; + + if (found_wm_act_max_horz || found_wm_act_max_vert) + return true; + } + XFree(atoms); + } + + return false; +} + bool OS_X11::is_window_maximized() const { // Using EWMH -- Extended Window Manager Hints Atom property = XInternAtom(x11_display, "_NET_WM_STATE", False); diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 1a5a853fdc..04243a9b36 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -200,6 +200,8 @@ protected: void _window_changed(XEvent *xevent); + bool is_window_maximize_allowed(); + public: virtual String get_name(); |