Last active
December 20, 2015 18:39
-
-
Save jdrouhard/6177817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c | |
index 036ce24..5ca96d4 100644 | |
--- a/client/X11/xf_client.c | |
+++ b/client/X11/xf_client.c | |
@@ -803,6 +803,8 @@ BOOL xf_pre_connect(freerdp* instance) | |
xfc->_NET_WM_MOVERESIZE = XInternAtom(xfc->display, "_NET_WM_MOVERESIZE", False); | |
xfc->_NET_MOVERESIZE_WINDOW = XInternAtom(xfc->display, "_NET_MOVERESIZE_WINDOW", False); | |
xfc->_NET_WM_FULLSCREEN_MONITORS = XInternAtom(xfc->display, "_NET_WM_FULLSCREEN_MONITORS", False); | |
+ xfc->_NET_WM_ALLOWED_ACTIONS = XInternAtom(xfc->display, "_NET_WM_ALLOWED_ACTIONS", False); | |
+ xfc->_NET_WM_ACTION_FULLSCREEN = XInternAtom(xfc->display, "_NET_WM_ACTION_FULLSCREEN", False); | |
xfc->WM_PROTOCOLS = XInternAtom(xfc->display, "WM_PROTOCOLS", False); | |
xfc->WM_DELETE_WINDOW = XInternAtom(xfc->display, "WM_DELETE_WINDOW", False); | |
diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c | |
index d63ca0b..b96ba29 100644 | |
--- a/client/X11/xf_window.c | |
+++ b/client/X11/xf_window.c | |
@@ -141,6 +141,25 @@ void xf_SendClientEvent(xfContext* xfc, xfWindow* window, Atom atom, unsigned in | |
void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) | |
{ | |
- xf_SendClientEvent(xfc, window, xfc->_NET_WM_STATE, 2, | |
- fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE, | |
+ if (!xf_IsActionAllowed(xfc, window, xfc->_NET_WM_ACTION_FULLSCREEN)) | |
+ { | |
+ XSizeHints *sizehints = XAllocSizeHints(); | |
+ long flags = 0; | |
+ XGetWMNormalHints(xfc->display, window->handle, sizehints, &flags); | |
+ sizehints->flags |= PMinSize | PMaxSize; | |
+ if (fullscreen) | |
+ { | |
+ sizehints->flags ^= (PMinSize | PMaxSize); | |
+ } | |
+ else | |
+ { | |
+ sizehints->min_width = sizehints->max_width = xfc->settings->DesktopWidth; | |
+ sizehints->min_height = sizehints->max_height = xfc->settings->DesktopHeight; | |
+ } | |
+ XSetWMNormalHints(xfc->display, window->handle, sizehints); | |
+ XFree(sizehints); | |
+ } | |
+ | |
+ xf_SendClientEvent(xfc, window, xfc->_NET_WM_STATE, 2, | |
+ fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE, | |
xfc->_NET_WM_STATE_FULLSCREEN); | |
xf_SendClientEvent(xfc, window, xfc->_NET_WM_FULLSCREEN_MONITORS, 5, | |
@@ -184,6 +203,28 @@ BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property, int leng | |
return TRUE; | |
} | |
+BOOL xf_IsActionAllowed(xfContext* xfc, xfWindow* window, Atom action) | |
+{ | |
+ Atom _NET_WM_ALLOWED_ACTIONS = xfc->_NET_WM_ALLOWED_ACTIONS; | |
+ unsigned long remain; | |
+ unsigned long len, i; | |
+ Atom *list; | |
+ Bool ret = False; | |
+ if (xf_GetWindowProperty(xfc, window->handle, _NET_WM_ALLOWED_ACTIONS, 1024, &len, &remain, (unsigned char **)&list)) | |
+ { | |
+ for (i=0; i < len; ++i) | |
+ { | |
+ if (list[i] == action) | |
+ { | |
+ ret = True; | |
+ break; | |
+ } | |
+ } | |
+ XFree(list); | |
+ } | |
+ return ret; | |
+} | |
+ | |
BOOL xf_GetCurrentDesktop(xfContext* xfc) | |
{ | |
BOOL status; | |
diff --git a/client/X11/xf_window.h b/client/X11/xf_window.h | |
index 3bfa4a0..5fde381 100644 | |
--- a/client/X11/xf_window.h | |
+++ b/client/X11/xf_window.h | |
@@ -113,6 +113,7 @@ rdpWindow* xf_rdpWindowFromWindow(xfContext* xfc, Window wnd); | |
BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property, int length, | |
unsigned long* nitems, unsigned long* bytes, BYTE** prop); | |
+BOOL xf_IsActionAllowed(xfContext* xfc, xfWindow* window, Atom action); | |
void xf_SetWindowMinMaxInfo(xfContext* xfc, xfWindow* window, int maxWidth, int maxHeight, | |
int maxPosX, int maxPosY, int minTrackWidth, int minTrackHeight, int maxTrackWidth, int maxTrackHeight); | |
diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h | |
index 107455e..a36f22f 100644 | |
--- a/client/X11/xfreerdp.h | |
+++ b/client/X11/xfreerdp.h | |
@@ -152,6 +152,8 @@ struct xf_context | |
Atom _NET_WM_STATE; | |
Atom _NET_WM_STATE_FULLSCREEN; | |
+ Atom _NET_WM_ALLOWED_ACTIONS; | |
+ Atom _NET_WM_ACTION_FULLSCREEN; | |
Atom _NET_WM_FULLSCREEN_MONITORS; | |
Atom _NET_WM_STATE_SKIP_TASKBAR; | |
Atom _NET_WM_STATE_SKIP_PAGER; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment