Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] X11: Properly check for fullscreen toggle made through the Window Manager #62543

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions platform/x11/os_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,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");
}
Expand Down Expand Up @@ -2663,6 +2706,7 @@ void OS_X11::process_xevents() {
switch (event.type) {
case Expose: {
DEBUG_LOG_X11("[%u] Expose window=%lu, count='%u' \n", frame, event.xexpose.window, event.xexpose.count);
current_videomode.fullscreen = window_fullscreen_check();

Main::force_redraw();
} break;
Expand Down
1 change: 1 addition & 0 deletions platform/x11/os_x11.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class OS_X11 : public OS_Unix {
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:
Expand Down