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

Use EWMH for DisplayServerX11::_window_minimize_check() implementation #80036

Merged
Merged
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
26 changes: 14 additions & 12 deletions platform/linuxbsd/x11/display_server_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2096,17 +2096,18 @@ bool DisplayServerX11::_window_maximize_check(WindowID p_window, const char *p_a
bool DisplayServerX11::_window_minimize_check(WindowID p_window) const {
const WindowData &wd = windows[p_window];

// Using ICCCM -- Inter-Client Communication Conventions Manual
Atom property = XInternAtom(x11_display, "WM_STATE", True);
if (property == None) {
// Using EWMH instead of ICCCM, might work better for Wayland users.
Atom property = XInternAtom(x11_display, "_NET_WM_STATE", True);
Atom hidden = XInternAtom(x11_display, "_NET_WM_STATE_HIDDEN", True);
if (property == None || hidden == None) {
return false;
}

Atom type;
int format;
unsigned long len;
unsigned long remaining;
unsigned char *data = nullptr;
Atom *atoms = nullptr;

int result = XGetWindowProperty(
x11_display,
Expand All @@ -2115,20 +2116,21 @@ bool DisplayServerX11::_window_minimize_check(WindowID p_window) const {
0,
32,
False,
AnyPropertyType,
XA_ATOM,
&type,
&format,
&len,
&remaining,
&data);
(unsigned char **)&atoms);

if (result == Success && data) {
long *state = (long *)data;
if (state[0] == WM_IconicState) {
XFree(data);
return true;
if (result == Success && atoms) {
for (unsigned int i = 0; i < len; i++) {
if (atoms[i] == hidden) {
XFree(atoms);
return true;
}
}
XFree(data);
XFree(atoms);
}

return false;
Expand Down
Loading