[X11] Add window borderless state detection, fix borderless state restoration after exiting fullscreen.
(cherry picked from commit 2a950f3a7c
)
This commit is contained in:
parent
e23bde4358
commit
9e2f76f17d
|
@ -1015,12 +1015,12 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) {
|
|||
XFree(xsh);
|
||||
}
|
||||
|
||||
if (!p_enabled && !get_borderless_window()) {
|
||||
// put decorations back if the window wasn't suppoesed to be borderless
|
||||
if (!p_enabled) {
|
||||
// put back or remove decorations according to the last set borderless state
|
||||
Hints hints;
|
||||
Atom property;
|
||||
hints.flags = 2;
|
||||
hints.decorations = 1;
|
||||
hints.decorations = current_videomode.borderless_window ? 0 : 1;
|
||||
property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
|
||||
XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
|
||||
}
|
||||
|
@ -1509,7 +1509,7 @@ bool OS_X11::is_window_always_on_top() const {
|
|||
|
||||
void OS_X11::set_borderless_window(bool p_borderless) {
|
||||
|
||||
if (current_videomode.borderless_window == p_borderless)
|
||||
if (get_borderless_window() == p_borderless)
|
||||
return;
|
||||
|
||||
if (!p_borderless && layered_window)
|
||||
|
@ -1529,7 +1529,24 @@ void OS_X11::set_borderless_window(bool p_borderless) {
|
|||
}
|
||||
|
||||
bool OS_X11::get_borderless_window() {
|
||||
return current_videomode.borderless_window;
|
||||
|
||||
bool borderless = current_videomode.borderless_window;
|
||||
Atom prop = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
|
||||
if (prop != None) {
|
||||
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long len;
|
||||
unsigned long remaining;
|
||||
unsigned char *data = NULL;
|
||||
if (XGetWindowProperty(x11_display, x11_window, prop, 0, sizeof(Hints), False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
|
||||
if (data && (format == 32) && (len >= 5)) {
|
||||
borderless = !((Hints *)data)->decorations;
|
||||
}
|
||||
XFree(data);
|
||||
}
|
||||
}
|
||||
return borderless;
|
||||
}
|
||||
|
||||
void OS_X11::request_attention() {
|
||||
|
|
Loading…
Reference in New Issue