xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window, const char* name, DWORD flags) { xfFloatbar* floatbar; /* Floatbar not enabled */ if ((flags & 0x0001) == 0) return NULL; if (!xfc) return NULL; /* Force disable with remote app */ if (xfc->remote_app) return NULL; floatbar = (xfFloatbar*) calloc(1, sizeof(xfFloatbar)); if (!floatbar) return NULL; floatbar->title = _strdup(name); if (!floatbar->title) goto fail; floatbar->root_window = window; floatbar->flags = flags; floatbar->xfc = xfc; floatbar->locked = flags & 0x0002; xf_floatbar_toggle_fullscreen(floatbar, FALSE); return floatbar; fail: xf_floatbar_free(floatbar); return NULL; }
void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) { UINT32 i; rdpSettings* settings = xfc->context.settings; int startX, startY; UINT32 width = window->width; UINT32 height = window->height; /* xfc->decorations is set by caller depending on settings and whether it is fullscreen or not */ window->decorations = xfc->decorations; /* show/hide decorations (e.g. title bar) as guided by xfc->decorations */ xf_SetWindowDecorations(xfc, window->handle, window->decorations); DEBUG_X11(TAG, "X window decoration set to %d", (int)window->decorations); xf_floatbar_toggle_fullscreen(xfc->window->floatbar, fullscreen); if (fullscreen) { xfc->savedWidth = xfc->window->width; xfc->savedHeight = xfc->window->height; xfc->savedPosX = xfc->window->left; xfc->savedPosY = xfc->window->top; startX = (settings->DesktopPosX != UINT32_MAX) ? settings->DesktopPosX : 0; startY = (settings->DesktopPosY != UINT32_MAX) ? settings->DesktopPosY : 0; } else { width = xfc->savedWidth; height = xfc->savedHeight; startX = xfc->savedPosX; startY = xfc->savedPosY; } /* Determine the x,y starting location for the fullscreen window */ if (fullscreen) { /* Initialize startX and startY with reasonable values */ startX = xfc->context.settings->MonitorDefArray[0].x; startY = xfc->context.settings->MonitorDefArray[0].y; /* Search all monitors to find the lowest startX and startY values */ for (i = 0; i < xfc->context.settings->MonitorCount; i++) { startX = MIN(startX, xfc->context.settings->MonitorDefArray[i].x); startY = MIN(startY, xfc->context.settings->MonitorDefArray[i].y); } /* Lastly apply any monitor shift(translation from remote to local coordinate system) * to startX and startY values */ startX += xfc->context.settings->MonitorLocalShiftX; startY += xfc->context.settings->MonitorLocalShiftY; } /* It is safe to proceed with simply toogling _NET_WM_STATE_FULLSCREEN window state on the following conditions: - The window manager supports multiple monitor full screen - The user requested to use a single monitor to render the remote desktop */ if (xfc->_NET_WM_FULLSCREEN_MONITORS != None || settings->MonitorCount == 1) { xf_ResizeDesktopWindow(xfc, window, width, height); if (fullscreen) { /* enter full screen: move the window before adding NET_WM_STATE_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); if (!fullscreen) { /* leave full screen: move the window after removing NET_WM_STATE_FULLSCREEN */ XMoveWindow(xfc->display, window->handle, startX, startY); } /* Set monitor bounds */ if (settings->MonitorCount > 1) { xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_FULLSCREEN_MONITORS, 5, xfc->fullscreenMonitors.top, xfc->fullscreenMonitors.bottom, xfc->fullscreenMonitors.left, xfc->fullscreenMonitors.right, 1); } } else { if (fullscreen) { xf_SetWindowDecorations(xfc, window->handle, FALSE); if (xfc->fullscreenMonitors.top) { xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_ADD, xfc->fullscreenMonitors.top, 0, 0); } else { XSetWindowAttributes xswa; xswa.override_redirect = True; XChangeWindowAttributes(xfc->display, window->handle, CWOverrideRedirect, &xswa); XRaiseWindow(xfc->display, window->handle); xswa.override_redirect = False; XChangeWindowAttributes(xfc->display, window->handle, CWOverrideRedirect, &xswa); } /* if window is in maximized state, save and remove */ if (xfc->_NET_WM_STATE_MAXIMIZED_VERT != None) { BYTE state; unsigned long nitems; unsigned long bytes; BYTE* prop; if (xf_GetWindowProperty(xfc, window->handle, xfc->_NET_WM_STATE, 255, &nitems, &bytes, &prop)) { state = 0; while (nitems-- > 0) { if (((Atom*) prop)[nitems] == xfc->_NET_WM_STATE_MAXIMIZED_VERT) state |= 0x01; if (((Atom*) prop)[nitems] == xfc->_NET_WM_STATE_MAXIMIZED_HORZ) state |= 0x02; } if (state) { xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_REMOVE, xfc->_NET_WM_STATE_MAXIMIZED_VERT, 0, 0); xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_REMOVE, xfc->_NET_WM_STATE_MAXIMIZED_HORZ, 0, 0); xfc->savedMaximizedState = state; } XFree(prop); } } width = xfc->vscreen.area.right - xfc->vscreen.area.left + 1; height = xfc->vscreen.area.bottom - xfc->vscreen.area.top + 1; DEBUG_X11("X window move and resize %dx%d@%dx%d", startX, startY, width, height); xf_ResizeDesktopWindow(xfc, window, width, height); XMoveWindow(xfc->display, window->handle, startX, startY); } else { xf_SetWindowDecorations(xfc, window->handle, window->decorations); xf_ResizeDesktopWindow(xfc, window, width, height); XMoveWindow(xfc->display, window->handle, startX, startY); if (xfc->fullscreenMonitors.top) { xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_REMOVE, xfc->fullscreenMonitors.top, 0, 0); } /* restore maximized state, if the window was maximized before setting fullscreen */ if (xfc->savedMaximizedState & 0x01) { xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_ADD, xfc->_NET_WM_STATE_MAXIMIZED_VERT, 0, 0); } if (xfc->savedMaximizedState & 0x02) { xf_SendClientEvent(xfc, window->handle, xfc->_NET_WM_STATE, 4, _NET_WM_STATE_ADD, xfc->_NET_WM_STATE_MAXIMIZED_HORZ, 0, 0); } xfc->savedMaximizedState = 0; } } }