diff options
author | Guilherme Silva <guilhermefelipecgs@gmail.com> | 2017-12-27 08:25:57 -0200 |
---|---|---|
committer | Guilherme Silva <guilhermefelipecgs@gmail.com> | 2017-12-27 08:44:18 -0200 |
commit | 2a6035dff45d5dcbbecf5343d22af0c264a75701 (patch) | |
tree | 668f1026efc887262a71d445ac3cd7276003e2aa | |
parent | 5c636875e418fbf055ddcff8d682639d1f096d05 (diff) |
Fix infinite loop introduced by 6f3486c4 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 f3f4b1f217..b5006c41cc 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 86f25918fd..43b4bb08c1 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(); |