diff -up libs/video/targets/context_x11.c.no-border libs/video/targets/context_x11.c --- libs/video/targets/context_x11.c.no-border 2016-09-13 17:23:38.603333345 +0000 +++ libs/video/targets/context_x11.c 2016-09-13 17:34:03.423333337 +0000 @@ -124,30 +124,61 @@ static int accel_threshold; #define _NET_WM_STATE_TOGGLE 2 static Atom x_net_state; static Atom x_net_fullscreen; +static Atom x_motif_hints; static void set_fullscreen (int full) { - XEvent xev; + static int sendEventResult = Success; + // Try Send Event, if failed - always use the simulation + if (Success == sendEventResult) + { + XEvent xev; + + xev.xclient.type = ClientMessage; + xev.xclient.serial = 0; + xev.xclient.send_event = True; + xev.xclient.window = x_win; + xev.xclient.message_type = x_net_state; + xev.xclient.format = 32; + + if (full) + xev.xclient.data.l[0] = _NET_WM_STATE_ADD; + else + xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE; + + xev.xclient.data.l[1] = x_net_fullscreen; + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 0; + xev.xclient.data.l[4] = 0; + sendEventResult = XSendEvent (x_disp, x_root, False, + SubstructureRedirectMask | SubstructureNotifyMask, &xev); + } + + if (Success != sendEventResult) + { + // The FULLSCREEN Event is not supported by XWindow, try to simulate it + // * disable border + // * resize window to whole screen + long prop[5] = {0, 1, 1, 0, 0}; + if (full) + { + prop[0] |= 2; // MWM_HINTS_DECORATIONS + prop[2] = 0; // no decorations + } + XChangeProperty(x_disp, x_win, x_motif_hints, x_motif_hints, 32, 0, (unsigned char *)prop, 5); - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = x_win; - xev.xclient.message_type = x_net_state; - xev.xclient.format = 32; - - if (full) - xev.xclient.data.l[0] = _NET_WM_STATE_ADD; - else - xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE; - - xev.xclient.data.l[1] = x_net_fullscreen; - xev.xclient.data.l[2] = 0; - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; - XSendEvent (x_disp, x_root, False, - SubstructureRedirectMask | SubstructureNotifyMask, &xev); + if (full) + { + const int cx = DisplayWidth(x_disp, x_screen), + cy = DisplayHeight(x_disp, x_screen); + XMoveResizeWindow(x_disp, x_win, 0, 0, cx, cy); + } + else + { + XResizeWindow(x_disp, x_win, viddef.width, viddef.height); + } + } } static void @@ -270,6 +301,7 @@ X11_OpenDisplay (void) x_net_state = XInternAtom (x_disp, "_NET_WM_STATE", False); x_net_fullscreen = XInternAtom (x_disp, "_NET_WM_STATE_FULLSCREEN", False); + x_motif_hints = XInternAtom(x_disp, "_MOTIF_WM_HINTS", 0); x_screen = DefaultScreen (x_disp); x_root = RootWindow (x_disp, x_screen);