Browse Source

Merge pull request #15092 from guilhermefelipecgs/fix_infinite_loop_on_splash_screen

Fix infinite loop on splash screen on tiling windows managers
Rémi Verschelde 7 years ago
parent
commit
5019f5e298
2 changed files with 50 additions and 2 deletions
  1. 48 2
      platform/x11/os_x11.cpp
  2. 2 0
      platform/x11/os_x11.h

+ 48 - 2
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);

+ 2 - 0
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();