Merge pull request #306 from rdesktop/uglym8-ewmh-fullscreen

Change the way we do fullscreen
This commit is contained in:
Karl Mikaelsson 2019-01-28 16:21:21 +01:00 committed by GitHub
commit e92916eaae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

79
xwin.c
View File

@ -86,6 +86,8 @@ static int g_x_socket;
static Screen *g_screen; static Screen *g_screen;
Window g_wnd; Window g_wnd;
static RD_BOOL g_has_wm = False;
RD_BOOL g_dynamic_session_resize = True; RD_BOOL g_dynamic_session_resize = True;
/* These are the last known window sizes. They are updated whenever the window size is changed. */ /* These are the last known window sizes. They are updated whenever the window size is changed. */
@ -1897,6 +1899,67 @@ set_wm_client_machine(Display * dpy, Window win)
XSetWMClientMachine(dpy, win, &tp); XSetWMClientMachine(dpy, win, &tp);
} }
RD_BOOL is_wm_active(void)
{
Atom prop, actual_type;
int actual_fmt;
unsigned long nitems, bytes_left;
unsigned char *data;
Window wid;
prop = XInternAtom(g_display, "_NET_SUPPORTING_WM_CHECK", True);
if (prop == None) return False;
if (XGetWindowProperty(g_display, DefaultRootWindow(g_display), prop, 0, 1, False,
XA_WINDOW, &actual_type, &actual_fmt, &nitems, &bytes_left, &data) != Success) {
return False;
}
if (!nitems) {
XFree(data);
return False;
}
wid = ((Window *)data)[0];
XFree(data);
if (XGetWindowProperty(g_display, wid, prop, 0, 1, False,
XA_WINDOW, &actual_type, &actual_fmt, &nitems, &bytes_left, &data) != Success) {
return False;
}
if (!nitems) {
XFree(data);
return False;
}
if (wid != ((Window *)data)[0]) {
XFree(data);
return False;
}
XFree(data);
/* Just for the curious minds */
prop = XInternAtom(g_display, "_NET_WM_NAME", True);
if (prop == None) return False;
if (XGetWindowProperty(g_display, wid, prop, 0, 1, False,
AnyPropertyType, &actual_type, &actual_fmt, &nitems, &bytes_left, &data) == Success) {
if (nitems) {
logger(GUI, Verbose, "%s(): WM name: %s", __func__, data);
}
XFree(data);
}
return True;
}
/* Initialize the UI. This is done once per process. */ /* Initialize the UI. This is done once per process. */
RD_BOOL RD_BOOL
ui_init(void) ui_init(void)
@ -1974,6 +2037,8 @@ ui_init(void)
seamless_init(); seamless_init();
} }
g_has_wm = is_wm_active();
return True; return True;
} }
@ -2041,7 +2106,11 @@ get_window_attribs(XSetWindowAttributes * attribs)
attribs->background_pixel = BlackPixelOfScreen(g_screen); attribs->background_pixel = BlackPixelOfScreen(g_screen);
attribs->border_pixel = WhitePixelOfScreen(g_screen); attribs->border_pixel = WhitePixelOfScreen(g_screen);
attribs->backing_store = g_ownbackstore ? NotUseful : Always; attribs->backing_store = g_ownbackstore ? NotUseful : Always;
if (g_has_wm) {
attribs->override_redirect = 0;
} else {
attribs->override_redirect = g_fullscreen; attribs->override_redirect = g_fullscreen;
}
attribs->colormap = g_xcolmap; attribs->colormap = g_xcolmap;
return vmask; return vmask;
@ -2112,6 +2181,13 @@ ui_update_window_sizehints(uint32 width, uint32 height)
} }
} }
void request_wm_fullscreen(Display *dpy, Window win)
{
Atom atom = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_STATE", False), XA_ATOM, 32, PropModeReplace, (unsigned char *)&atom, 1);
XFlush(dpy);
}
RD_BOOL RD_BOOL
ui_create_window(uint32 width, uint32 height) ui_create_window(uint32 width, uint32 height)
{ {
@ -2206,6 +2282,9 @@ ui_create_window(uint32 width, uint32 height)
#ifdef HAVE_XRANDR #ifdef HAVE_XRANDR
XSelectInput(g_display, RootWindowOfScreen(g_screen), StructureNotifyMask); XSelectInput(g_display, RootWindowOfScreen(g_screen), StructureNotifyMask);
#endif #endif
if (g_fullscreen && g_has_wm) {
request_wm_fullscreen(g_display, g_wnd);
}
XMapWindow(g_display, g_wnd); XMapWindow(g_display, g_wnd);
/* wait for VisibilityNotify */ /* wait for VisibilityNotify */