From 6b7b60237042a891221d71a596fc683d850bcb4e Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 14 Aug 2017 10:10:53 +0200 Subject: [PATCH] Possible fix for #4081 and #2707 (#4087) * detect openbox automatically * format code * copyright update * free prop at the end of the function --- client/X11/xf_window.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 76a64f461..b4b9f981c 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -6,6 +6,7 @@ * Copyright 2012 HP Development Company, LLC * Copyright 2016 Thincast Technologies GmbH * Copyright 2016 Armin Novak + * Copyright 2017 Kai Harms * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -145,6 +146,9 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) UINT32 height = window->height; window->decorations = xfc->decorations; xf_SetWindowDecorations(xfc, window->handle, window->decorations); + unsigned long nitems, bytes; + BYTE* prop; + BOOL status; if (fullscreen) { @@ -203,16 +207,24 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) XMoveWindow(xfc->display, window->handle, startX, startY); } - /* Set the fullscreen state */ - xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, - fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE, - xfc->_NET_WM_STATE_FULLSCREEN, 0, 0); + status = xf_GetWindowProperty(xfc, DefaultRootWindow(xfc->display), + xfc->_NET_WM_FULLSCREEN_MONITORS, 1, &nitems, &bytes, &prop); + + if (status) + { + /* Set the fullscreen state */ + xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, + fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE, + xfc->_NET_WM_STATE_FULLSCREEN, 0, 0); + } if (!fullscreen) { /* leave full screen: move the window after removing NET_WM_STATE_FULLSCREEN */ XMoveWindow(xfc->display, window->handle, startX, startY); } + + free(prop); } /* http://tronche.com/gui/x/xlib/window-information/XGetWindowProperty.html */ @@ -336,13 +348,13 @@ static const char* get_shm_id() return shm_id; } -Window xf_CreateDummyWindow(xfContext *xfc) +Window xf_CreateDummyWindow(xfContext* xfc) { return XCreateSimpleWindow(xfc->display, DefaultRootWindow(xfc->display), - 0, 0, 1, 1, 0, 0, 0); + 0, 0, 1, 1, 0, 0, 0); } -void xf_DestroyDummyWindow(xfContext *xfc, Window window) +void xf_DestroyDummyWindow(xfContext* xfc, Window window) { if (window) XDestroyWindow(xfc->display, window); @@ -958,7 +970,7 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, { int ax, ay; - if (appWindow == NULL) + if (appWindow == NULL) return; ax = x + appWindow->windowOffsetX;