From 720b3a40ced820195ba64ddbaf9d77eb5a0a9d65 Mon Sep 17 00:00:00 2001 From: "Wilson E. Alvarez" Date: Wed, 29 Jun 2022 21:55:40 -0400 Subject: [PATCH] Properly check for fullscreen toggle made through the Window Manager (cherry picked from commit cf38b6f18768afe0ce964bd72de35174016c387f) --- platform/x11/os_x11.cpp | 45 +++++++++++++++++++++++++++++++++++++++++ platform/x11/os_x11.h | 1 + 2 files changed, 46 insertions(+) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index fce43a4fe28..344b47a7cbb 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1701,6 +1701,49 @@ bool OS_X11::window_maximize_check(const char *p_atom_name) const { return retval; } +bool OS_X11::window_fullscreen_check() const { + // Using EWMH -- Extended Window Manager Hints + Atom property = XInternAtom(x11_display, "_NET_WM_STATE", False); + Atom type; + int format; + unsigned long len; + unsigned long remaining; + unsigned char *data = nullptr; + bool retval = false; + + if (property == None) { + return retval; + } + + 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_fullscreen = XInternAtom(x11_display, "_NET_WM_STATE_FULLSCREEN", False); + for (uint64_t i = 0; i < len; i++) { + if (atoms[i] == wm_fullscreen) { + retval = true; + break; + } + } + XFree(data); + } + + return retval; +} + bool OS_X11::is_window_maximize_allowed() const { return window_maximize_check("_NET_WM_ALLOWED_ACTIONS"); } @@ -2538,6 +2581,8 @@ void OS_X11::process_xevents() { switch (event.type) { case Expose: + current_videomode.fullscreen = window_fullscreen_check(); + Main::force_redraw(); break; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 61146438fcf..5df5f1729c3 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -244,6 +244,7 @@ protected: void _window_changed(XEvent *event); bool window_maximize_check(const char *p_atom_name) const; + bool window_fullscreen_check() const; bool is_window_maximize_allowed() const; public: