23#include <freerdp/config.h>
38#include <winpr/assert.h>
39#include <winpr/thread.h>
41#include <winpr/string.h>
43#include <freerdp/rail.h>
44#include <freerdp/log.h>
47#include <X11/extensions/shape.h>
51#include <X11/extensions/XInput2.h>
57#include "xf_keyboard.h"
61#define TAG CLIENT_TAG("x11")
63#include <FreeRDP_Icon_256px.h>
64#define xf_icon_prop FreeRDP_Icon_256px_prop
71#define MWM_HINTS_FUNCTIONS (1L << 0)
72#define MWM_HINTS_DECORATIONS (1L << 1)
77#define MWM_FUNC_ALL (1L << 0)
85#define MWM_DECOR_ALL (1L << 0)
93#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
102 unsigned long functions;
103 unsigned long decorations;
105 unsigned long status;
108static void xf_XSetTransientForHint(xfContext* xfc, xfAppWindow* window);
110static const char* window_style_to_string(UINT32 style)
118 ENTRY(WS_CLIPCHILDREN);
119 ENTRY(WS_CLIPSIBLINGS);
125 ENTRY(WS_MAXIMIZEBOX);
127 ENTRY(WS_OVERLAPPEDWINDOW);
129 ENTRY(WS_POPUPWINDOW);
139const char* window_styles_to_string(UINT32 style,
char* buffer,
size_t length)
141 (void)_snprintf(buffer, length,
"style[0x%08" PRIx32
"] {", style);
142 const char* sep =
"";
143 for (
size_t x = 0; x < 32; x++)
145 const UINT32 val = 1u << x;
146 if ((style & val) != 0)
148 const char* str = window_style_to_string(val);
151 winpr_str_append(str, buffer, length, sep);
156 winpr_str_append(
"}", buffer, length,
"");
161static const char* window_style_ex_to_string(UINT32 styleEx)
165 ENTRY(WS_EX_ACCEPTFILES);
166 ENTRY(WS_EX_APPWINDOW);
167 ENTRY(WS_EX_CLIENTEDGE);
168 ENTRY(WS_EX_COMPOSITED);
169 ENTRY(WS_EX_CONTEXTHELP);
170 ENTRY(WS_EX_CONTROLPARENT);
171 ENTRY(WS_EX_DLGMODALFRAME);
172 ENTRY(WS_EX_LAYERED);
173 ENTRY(WS_EX_LAYOUTRTL);
174 ENTRY(WS_EX_LEFTSCROLLBAR);
175 ENTRY(WS_EX_MDICHILD);
176 ENTRY(WS_EX_NOACTIVATE);
177 ENTRY(WS_EX_NOINHERITLAYOUT);
178 ENTRY(WS_EX_NOPARENTNOTIFY);
179 ENTRY(WS_EX_OVERLAPPEDWINDOW);
180 ENTRY(WS_EX_PALETTEWINDOW);
182 ENTRY(WS_EX_RIGHTSCROLLBAR);
183 ENTRY(WS_EX_RTLREADING);
184 ENTRY(WS_EX_STATICEDGE);
185 ENTRY(WS_EX_TOOLWINDOW);
186 ENTRY(WS_EX_TOPMOST);
187 ENTRY(WS_EX_TRANSPARENT);
188 ENTRY(WS_EX_WINDOWEDGE);
194const char* window_styles_ex_to_string(UINT32 styleEx,
char* buffer,
size_t length)
196 (void)_snprintf(buffer, length,
"styleEx[0x%08" PRIx32
"] {", styleEx);
197 const char* sep =
"";
198 for (
size_t x = 0; x < 32; x++)
200 const UINT32 val = (UINT32)(1UL << x);
201 if ((styleEx & val) != 0)
203 const char* str = window_style_ex_to_string(val);
206 winpr_str_append(str, buffer, length, sep);
211 winpr_str_append(
"}", buffer, length,
"");
216static void xf_SetWindowTitleText(xfContext* xfc, Window window,
const char* name)
221 const size_t i = strnlen(name, MAX_PATH);
222 XStoreName(xfc->display, window, name);
223 Atom wm_Name = xfc->NET_WM_NAME;
224 Atom utf8Str = xfc->UTF8_STRING;
225 LogDynAndXChangeProperty(xfc->log, xfc->display, window, wm_Name, utf8Str, 8, PropModeReplace,
226 (
const unsigned char*)name, (
int)i);
232void xf_SendClientEvent(xfContext* xfc, Window window, Atom atom,
unsigned int numArgs, ...)
234 XEvent xevent = WINPR_C_ARRAY_INIT;
235 va_list argp = WINPR_C_ARRAY_INIT;
236 va_start(argp, numArgs);
238 xevent.xclient.type = ClientMessage;
239 xevent.xclient.serial = 0;
240 xevent.xclient.send_event = False;
241 xevent.xclient.display = xfc->display;
242 xevent.xclient.window = window;
243 xevent.xclient.message_type = atom;
244 xevent.xclient.format = 32;
246 for (
size_t i = 0; i < numArgs; i++)
248 xevent.xclient.data.l[i] = va_arg(argp,
int);
251 WLog_Print(xfc->log, WLOG_TRACE,
"Send ClientMessage Event: wnd=0x%04lX",
252 (
unsigned long)xevent.xclient.window);
253 LogDynAndXSendEvent(xfc->log, xfc->display, RootWindowOfScreen(xfc->screen), False,
254 SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
255 LogDynAndXSync(xfc->log, xfc->display, False);
259void xf_SetWindowMinimized(xfContext* xfc, xfWindow* window)
261 XIconifyWindow(xfc->display, window->handle, xfc->screen_number);
264void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen)
266 const rdpSettings* settings =
nullptr;
269 UINT32 width = WINPR_ASSERTING_INT_CAST(uint32_t, window->width);
270 UINT32 height = WINPR_ASSERTING_INT_CAST(uint32_t, window->height);
274 settings = xfc->common.context.settings;
275 WINPR_ASSERT(settings);
279 window->decorations = xfc->decorations;
281 xf_SetWindowDecorations(xfc, window->handle, window->decorations);
282 WLog_Print(xfc->log, WLOG_TRACE,
"X window decoration set to %d", (
int)window->decorations);
283 xf_floatbar_toggle_fullscreen(xfc->window->floatbar, fullscreen);
287 xfc->savedWidth = xfc->window->width;
288 xfc->savedHeight = xfc->window->height;
289 xfc->savedPosX = xfc->window->left;
290 xfc->savedPosY = xfc->window->top;
293 ? WINPR_ASSERTING_INT_CAST(
297 ? WINPR_ASSERTING_INT_CAST(
303 width = WINPR_ASSERTING_INT_CAST(uint32_t, xfc->savedWidth);
304 height = WINPR_ASSERTING_INT_CAST(uint32_t, xfc->savedHeight);
305 startX = xfc->savedPosX;
306 startY = xfc->savedPosY;
313 freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, 0);
315 startX = firstMonitor->x;
316 startY = firstMonitor->y;
322 freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, i);
323 startX = MIN(startX, monitor->x);
324 startY = MIN(startY, monitor->y);
340 if (xfc->NET_WM_FULLSCREEN_MONITORS != None ||
343 xf_ResizeDesktopWindow(xfc, window, WINPR_ASSERTING_INT_CAST(
int, width),
344 WINPR_ASSERTING_INT_CAST(
int, height));
349 LogDynAndXMoveWindow(xfc->log, xfc->display, window->handle, startX, startY);
353 xf_SendClientEvent(xfc, window->handle, xfc->NET_WM_STATE, 4,
354 fullscreen ? NET_WM_STATE_ADD : NET_WM_STATE_REMOVE,
355 xfc->NET_WM_STATE_FULLSCREEN, 0, 0);
363 xf_ResizeDesktopWindow(xfc, window, WINPR_ASSERTING_INT_CAST(
int, width),
364 WINPR_ASSERTING_INT_CAST(
int, height));
365 LogDynAndXMoveWindow(xfc->log, xfc->display, window->handle, startX, startY);
371 xf_SendClientEvent(xfc, window->handle, xfc->NET_WM_FULLSCREEN_MONITORS, 5,
372 xfc->fullscreenMonitors.top, xfc->fullscreenMonitors.bottom,
373 xfc->fullscreenMonitors.left, xfc->fullscreenMonitors.right, 1);
380 xf_SetWindowDecorations(xfc, window->handle, FALSE);
382 if (xfc->fullscreenMonitors.top)
384 xf_SendClientEvent(xfc, window->handle, xfc->NET_WM_STATE, 4, NET_WM_STATE_ADD,
385 xfc->fullscreenMonitors.top, 0, 0);
389 XSetWindowAttributes xswa = WINPR_C_ARRAY_INIT;
390 xswa.override_redirect = True;
391 LogDynAndXChangeWindowAttributes(xfc->log, xfc->display, window->handle,
392 CWOverrideRedirect, &xswa);
393 LogDynAndXRaiseWindow(xfc->log, xfc->display, window->handle);
394 xswa.override_redirect = False;
395 LogDynAndXChangeWindowAttributes(xfc->log, xfc->display, window->handle,
396 CWOverrideRedirect, &xswa);
400 if (xfc->NET_WM_STATE_MAXIMIZED_VERT != None)
403 unsigned long nitems = 0;
404 unsigned long bytes = 0;
405 BYTE* prop =
nullptr;
407 if (xf_GetWindowProperty(xfc, window->handle, xfc->NET_WM_STATE, 255, &nitems,
410 const Atom* aprop = WINPR_PACKED_ALIGN_CAST(
const Atom*, prop);
413 for (
size_t x = 0; x < nitems; x++)
415 if (aprop[x] == xfc->NET_WM_STATE_MAXIMIZED_VERT)
418 if (aprop[x] == xfc->NET_WM_STATE_MAXIMIZED_HORZ)
424 xf_SendClientEvent(xfc, window->handle, xfc->NET_WM_STATE, 4,
425 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_MAXIMIZED_VERT, 0,
427 xf_SendClientEvent(xfc, window->handle, xfc->NET_WM_STATE, 4,
428 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0,
430 xfc->savedMaximizedState = state;
437 width = xfc->vscreen.area.right - xfc->vscreen.area.left + 1;
438 height = xfc->vscreen.area.bottom - xfc->vscreen.area.top + 1;
439 WLog_Print(xfc->log, WLOG_TRACE,
440 "X window move and resize %dx%d@%" PRIu32
"x%" PRIu32
"", startX, startY,
442 xf_ResizeDesktopWindow(xfc, window, WINPR_ASSERTING_INT_CAST(
int, width),
443 WINPR_ASSERTING_INT_CAST(
int, height));
444 LogDynAndXMoveWindow(xfc->log, xfc->display, window->handle, startX, startY);
448 xf_SetWindowDecorations(xfc, window->handle, window->decorations);
449 xf_ResizeDesktopWindow(xfc, window, WINPR_ASSERTING_INT_CAST(
int, width),
450 WINPR_ASSERTING_INT_CAST(
int, height));
451 LogDynAndXMoveWindow(xfc->log, xfc->display, window->handle, startX, startY);
453 if (xfc->fullscreenMonitors.top)
455 xf_SendClientEvent(xfc, window->handle, xfc->NET_WM_STATE, 4, NET_WM_STATE_REMOVE,
456 xfc->fullscreenMonitors.top, 0, 0);
460 if (xfc->savedMaximizedState & 0x01)
462 xf_SendClientEvent(xfc, window->handle, xfc->NET_WM_STATE, 4, NET_WM_STATE_ADD,
463 xfc->NET_WM_STATE_MAXIMIZED_VERT, 0, 0);
466 if (xfc->savedMaximizedState & 0x02)
468 xf_SendClientEvent(xfc, window->handle, xfc->NET_WM_STATE, 4, NET_WM_STATE_ADD,
469 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0, 0);
472 xfc->savedMaximizedState = 0;
479BOOL xf_GetWindowProperty(xfContext* xfc, Window window, Atom property,
int length,
480 unsigned long* nitems,
unsigned long* bytes, BYTE** prop)
483 Atom actual_type = None;
484 int actual_format = 0;
488 if (property == None)
491 status = LogDynAndXGetWindowProperty(xfc->log, xfc->display, window, property, 0, length, False,
492 AnyPropertyType, &actual_type, &actual_format, nitems,
495 if (status != Success)
498 if (actual_type == None)
500 WLog_DBG(TAG,
"Property %lu does not exist", (
unsigned long)property);
510static BOOL xf_GetNumberOfDesktops(xfContext* xfc, Window root,
unsigned* pval)
512 unsigned long nitems = 0;
513 unsigned long bytes = 0;
514 BYTE* bprop =
nullptr;
520 xf_GetWindowProperty(xfc, root, xfc->NET_NUMBER_OF_DESKTOPS, 1, &nitems, &bytes, &bprop);
522 long* prop = WINPR_PACKED_ALIGN_CAST(
long*, bprop);
528 if ((*prop >= 0) && (*prop <= UINT32_MAX))
530 *pval = (UINT32)*prop;
539static BOOL xf_GetCurrentDesktop(xfContext* xfc, Window root)
541 unsigned long nitems = 0;
542 unsigned long bytes = 0;
543 BYTE* bprop =
nullptr;
546 if (!xf_GetNumberOfDesktops(xfc, root, &max))
552 xf_GetWindowProperty(xfc, root, xfc->NET_CURRENT_DESKTOP, 1, &nitems, &bytes, &bprop);
554 long* prop = WINPR_PACKED_ALIGN_CAST(
long*, bprop);
555 xfc->current_desktop = 0;
557 xfc->current_desktop = (int)MIN(max - 1, *prop);
563static BOOL xf_GetWorkArea_NET_WORKAREA(xfContext* xfc, Window root)
566 unsigned long nitems = 0;
567 unsigned long bytes = 0;
568 BYTE* bprop =
nullptr;
571 xf_GetWindowProperty(xfc, root, xfc->NET_WORKAREA, INT_MAX, &nitems, &bytes, &bprop);
572 long* prop = WINPR_PACKED_ALIGN_CAST(
long*, bprop);
577 if ((xfc->current_desktop * 4 + 3) >= (INT64)nitems)
580 xfc->workArea.x = (INT32)MIN(INT32_MAX, prop[xfc->current_desktop * 4 + 0]);
581 xfc->workArea.y = (INT32)MIN(INT32_MAX, prop[xfc->current_desktop * 4 + 1]);
582 xfc->workArea.width = (UINT32)MIN(UINT32_MAX, prop[xfc->current_desktop * 4 + 2]);
583 xfc->workArea.height = (UINT32)MIN(UINT32_MAX, prop[xfc->current_desktop * 4 + 3]);
591BOOL xf_GetWorkArea(xfContext* xfc)
595 Window root = DefaultRootWindow(xfc->display);
596 (void)xf_GetCurrentDesktop(xfc, root);
597 return xf_GetWorkArea_NET_WORKAREA(xfc, root);
600void xf_SetWindowDecorations(xfContext* xfc, Window window, BOOL show)
602 PropMotifWmHints hints = { .decorations = (show) ? MWM_DECOR_ALL : 0,
603 .functions = MWM_FUNC_ALL,
604 .flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS,
608 LogDynAndXChangeProperty(xfc->log, xfc->display, window, xfc->MOTIF_WM_HINTS,
609 xfc->MOTIF_WM_HINTS, 32, PropModeReplace, (BYTE*)&hints,
610 PROP_MOTIF_WM_HINTS_ELEMENTS);
613void xf_SetWindowUnlisted(xfContext* xfc, Window window)
616 Atom window_state[] = { xfc->NET_WM_STATE_SKIP_PAGER, xfc->NET_WM_STATE_SKIP_TASKBAR };
617 LogDynAndXChangeProperty(xfc->log, xfc->display, window, xfc->NET_WM_STATE, XA_ATOM, 32,
618 PropModeReplace, (BYTE*)window_state, 2);
621static void xf_SetWindowPID(xfContext* xfc, Window window, pid_t pid)
629 am_wm_pid = xfc->NET_WM_PID;
630 LogDynAndXChangeProperty(xfc->log, xfc->display, window, am_wm_pid, XA_CARDINAL, 32,
631 PropModeReplace, (BYTE*)&pid, 1);
634static const char* get_shm_id(
void)
636 static char shm_id[64];
637 (void)sprintf_s(shm_id,
sizeof(shm_id),
"/com.freerdp.xfreerdp.tsmf_%016X",
638 GetCurrentProcessId());
642Window xf_CreateDummyWindow(xfContext* xfc)
644 return LogDynAndXCreateWindow(
645 xfc->log, xfc->display, RootWindowOfScreen(xfc->screen),
646 WINPR_ASSERTING_INT_CAST(
int, xfc->workArea.x),
647 WINPR_ASSERTING_INT_CAST(
int, xfc->workArea.y), 1, 1, 0, xfc->depth, InputOutput,
648 xfc->visual, WINPR_ASSERTING_INT_CAST(uint32_t, xfc->attribs_mask), &xfc->attribs);
651void xf_DestroyDummyWindow(xfContext* xfc, Window window)
654 LogDynAndXDestroyWindow(xfc->log, xfc->display, window);
657xfWindow* xf_CreateDesktopWindow(xfContext* xfc,
char* name,
int width,
int height)
659 XEvent xevent = WINPR_C_ARRAY_INIT;
661 XClassHint* classHints =
nullptr;
662 xfWindow* window = (xfWindow*)calloc(1,
sizeof(xfWindow));
667 rdpSettings* settings = xfc->common.context.settings;
668 WINPR_ASSERT(settings);
671 window->width = width;
672 window->height = height;
673 window->decorations = xfc->decorations;
674 window->is_mapped = FALSE;
675 window->is_transient = FALSE;
677 WINPR_ASSERT(xfc->depth != 0);
678 window->handle = LogDynAndXCreateWindow(
679 xfc->log, xfc->display, RootWindowOfScreen(xfc->screen),
680 WINPR_ASSERTING_INT_CAST(
int, xfc->workArea.x),
681 WINPR_ASSERTING_INT_CAST(
int, xfc->workArea.y), xfc->workArea.width, xfc->workArea.height,
682 0, xfc->depth, InputOutput, xfc->visual,
683 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->attribs_mask), &xfc->attribs);
684 window->shmid = shm_open(get_shm_id(), (O_CREAT | O_RDWR), (S_IREAD | S_IWRITE));
686 if (window->shmid < 0)
688 WLog_Print(xfc->log, WLOG_TRACE,
689 "xf_CreateDesktopWindow: failed to get access to shared memory - shmget()\n");
693 int rc = ftruncate(window->shmid,
sizeof(window->handle));
696 char ebuffer[256] = WINPR_C_ARRAY_INIT;
697 WLog_Print(xfc->log, WLOG_TRACE,
"ftruncate failed with %s [%d]",
698 winpr_strerror(rc, ebuffer,
sizeof(ebuffer)), rc);
702 void* mem = mmap(
nullptr,
sizeof(window->handle), PROT_READ | PROT_WRITE, MAP_SHARED,
705 if (mem == MAP_FAILED)
708 xfc->log, WLOG_TRACE,
709 "xf_CreateDesktopWindow: failed to assign pointer to the memory address - "
715 *window->xfwin = window->handle;
720 classHints = XAllocClassHint();
724 classHints->res_name =
"xfreerdp";
726 char* res_class =
nullptr;
729 res_class = _strdup(WmClass);
731 res_class = _strdup(
"xfreerdp");
733 classHints->res_class = res_class;
734 XSetClassHint(xfc->display, window->handle, classHints);
739 xf_ResizeDesktopWindow(xfc, window, width, height);
740 xf_SetWindowDecorations(xfc, window->handle, window->decorations);
741 xf_SetWindowPID(xfc, window->handle, 0);
742 input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
743 VisibilityChangeMask | FocusChangeMask | StructureNotifyMask | PointerMotionMask |
744 ExposureMask | PropertyChangeMask;
746 if (xfc->grab_keyboard)
747 input_mask |= EnterWindowMask | LeaveWindowMask;
749 LogDynAndXChangeProperty(xfc->log, xfc->display, window->handle, xfc->NET_WM_ICON, XA_CARDINAL,
750 32, PropModeReplace, (BYTE*)xf_icon_prop, ARRAYSIZE(xf_icon_prop));
753 LogDynAndXReparentWindow(xfc->log, xfc->display, window->handle, parentWindow, 0, 0);
755 XSelectInput(xfc->display, window->handle, input_mask);
756 LogDynAndXClearWindow(xfc->log, xfc->display, window->handle);
757 xf_SetWindowTitleText(xfc, window->handle, name);
758 LogDynAndXMapWindow(xfc->log, xfc->display, window->handle);
759 if (xf_input_init(xfc, window->handle) < 0)
761 xf_DestroyDesktopWindow(xfc, window);
771 XMaskEvent(xfc->display, VisibilityChangeMask, &xevent);
772 }
while (xevent.type != VisibilityNotify);
781 LogDynAndXMoveWindow(xfc->log, xfc->display, window->handle, 0, 0);
786 LogDynAndXMoveWindow(xfc->log, xfc->display, window->handle,
787 WINPR_ASSERTING_INT_CAST(
789 WINPR_ASSERTING_INT_CAST(
793 window->floatbar = xf_floatbar_new(xfc, window->handle, name,
796 if (xfc->XWAYLAND_MAY_GRAB_KEYBOARD)
797 xf_SendClientEvent(xfc, window->handle, xfc->XWAYLAND_MAY_GRAB_KEYBOARD, 1, 1);
802void xf_ResizeDesktopWindow(xfContext* xfc, xfWindow* window,
int width,
int height)
804 XSizeHints* size_hints =
nullptr;
805 rdpSettings* settings =
nullptr;
810 settings = xfc->common.context.settings;
811 WINPR_ASSERT(settings);
813 if (!(size_hints = XAllocSizeHints()))
816 size_hints->flags = PMinSize | PMaxSize | PWinGravity;
817 size_hints->win_gravity = NorthWestGravity;
818 size_hints->min_width = size_hints->min_height = 1;
819 size_hints->max_width = size_hints->max_height = 16384;
820 LogDynAndXResizeWindow(xfc->log, xfc->display, window->handle,
821 WINPR_ASSERTING_INT_CAST(uint32_t, width),
822 WINPR_ASSERTING_INT_CAST(uint32_t, height));
829 if (!xfc->fullscreen)
833 size_hints->min_width = size_hints->max_width = width;
834 size_hints->min_height = size_hints->max_height = height;
838 XSetWMNormalHints(xfc->display, window->handle, size_hints);
842void xf_DestroyDesktopWindow(xfContext* xfc, xfWindow* window)
849 if (xfc->window == window)
850 xfc->window =
nullptr;
855 xfc->xi_event =
false;
856 xfc->xi_rawevent =
false;
859 xf_floatbar_free(window->floatbar);
862 LogDynAndXFreeGC(xfc->log, xfc->display, window->gc);
866 LogDynAndXUnmapWindow(xfc->log, xfc->display, window->handle);
867 LogDynAndXDestroyWindow(xfc->log, xfc->display, window->handle);
871 munmap(window->xfwin,
sizeof(*window->xfwin));
873 if (window->shmid >= 0)
874 close(window->shmid);
876 shm_unlink(get_shm_id());
877 window->xfwin = (Window*)-1;
882void xf_SetWindowStyle(xfContext* xfc, xfAppWindow* appWindow, UINT32 style, UINT32 ex_style)
884 Atom window_type = 0;
885 BOOL redirect = FALSE;
887 window_type = xfc->NET_WM_WINDOW_TYPE_NORMAL;
889 if ((ex_style & WS_EX_NOACTIVATE) || (ex_style & WS_EX_TOOLWINDOW))
892 appWindow->is_transient = TRUE;
893 xf_SetWindowUnlisted(xfc, appWindow->handle);
894 window_type = xfc->NET_WM_WINDOW_TYPE_DROPDOWN_MENU;
900 else if (ex_style & WS_EX_TOPMOST)
902 window_type = xfc->NET_WM_WINDOW_TYPE_NORMAL;
905 if (style & WS_POPUP)
907 window_type = xfc->NET_WM_WINDOW_TYPE_DIALOG;
910 if (!((ex_style & WS_EX_DLGMODALFRAME) || (ex_style & WS_EX_LAYERED) ||
911 (style & WS_SYSMENU)))
913 appWindow->is_transient = TRUE;
916 xf_SetWindowUnlisted(xfc, appWindow->handle);
920 if (!(style == 0 && ex_style == 0))
922 xf_SetWindowActions(xfc, appWindow);
935 XSetWindowAttributes attrs = WINPR_C_ARRAY_INIT;
936 attrs.override_redirect = redirect ? True : False;
937 LogDynAndXChangeWindowAttributes(xfc->log, xfc->display, appWindow->handle,
938 CWOverrideRedirect, &attrs);
941 LogDynAndXChangeProperty(xfc->log, xfc->display, appWindow->handle, xfc->NET_WM_WINDOW_TYPE,
942 XA_ATOM, 32, PropModeReplace, (BYTE*)&window_type, 1);
944 const BOOL above = (ex_style & WS_EX_TOPMOST) != 0;
945 const BOOL transient = (style & WS_CHILD) == 0;
948 xf_XSetTransientForHint(
951 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
952 above ? NET_WM_STATE_ADD : NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_ABOVE, 0,
956void xf_SetWindowActions(xfContext* xfc, xfAppWindow* appWindow)
958 Atom allowed_actions[] = {
959 xfc->NET_WM_ACTION_CLOSE, xfc->NET_WM_ACTION_MINIMIZE,
960 xfc->NET_WM_ACTION_MOVE, xfc->NET_WM_ACTION_RESIZE,
961 xfc->NET_WM_ACTION_MAXIMIZE_HORZ, xfc->NET_WM_ACTION_MAXIMIZE_VERT,
962 xfc->NET_WM_ACTION_FULLSCREEN, xfc->NET_WM_ACTION_CHANGE_DESKTOP
965 if (!(appWindow->dwStyle & WS_SYSMENU))
966 allowed_actions[0] = 0;
968 if (!(appWindow->dwStyle & WS_MINIMIZEBOX))
969 allowed_actions[1] = 0;
971 if (!(appWindow->dwStyle & WS_SIZEBOX))
972 allowed_actions[3] = 0;
974 if (!(appWindow->dwStyle & WS_MAXIMIZEBOX))
976 allowed_actions[4] = 0;
977 allowed_actions[5] = 0;
978 allowed_actions[6] = 0;
981 LogDynAndXChangeProperty(xfc->log, xfc->display, appWindow->handle, xfc->NET_WM_ALLOWED_ACTIONS,
982 XA_ATOM, 32, PropModeReplace, (
unsigned char*)&allowed_actions, 8);
985void xf_SetWindowText(xfContext* xfc, xfAppWindow* appWindow,
const char* name)
987 xf_SetWindowTitleText(xfc, appWindow->handle, name);
990static void xf_FixWindowCoordinates(xfContext* xfc,
int* x,
int* y,
int* width,
int* height)
992 int vscreen_width = 0;
993 int vscreen_height = 0;
994 vscreen_width = xfc->vscreen.area.right - xfc->vscreen.area.left + 1;
995 vscreen_height = xfc->vscreen.area.bottom - xfc->vscreen.area.top + 1;
997 if (*x < xfc->vscreen.area.left)
1004 const int shift = xfc->vscreen.area.left - *x;
1006 if (*width - shift >= 64)
1009 *x = xfc->vscreen.area.left;
1012 if (*y < xfc->vscreen.area.top)
1015 const int shift = xfc->vscreen.area.top - *y;
1017 if (*height - shift >= 64)
1020 *y = xfc->vscreen.area.top;
1023 if (*width > vscreen_width)
1025 *width = vscreen_width;
1028 if (*height > vscreen_height)
1030 *height = vscreen_height;
1044int xf_AppWindowInit(xfContext* xfc, xfAppWindow* appWindow)
1046 if (!xfc || !appWindow)
1049 xf_SetWindowDecorations(xfc, appWindow->handle, appWindow->decorations);
1050 xf_SetWindowStyle(xfc, appWindow, appWindow->dwStyle, appWindow->dwExStyle);
1051 xf_SetWindowPID(xfc, appWindow->handle, 0);
1052 xf_ShowWindow(xfc, appWindow, WINDOW_SHOW);
1053 LogDynAndXClearWindow(xfc->log, xfc->display, appWindow->handle);
1054 LogDynAndXMapWindow(xfc->log, xfc->display, appWindow->handle);
1056 xf_MoveWindow(xfc, appWindow, appWindow->x, appWindow->y, appWindow->width, appWindow->height);
1057 xf_SetWindowText(xfc, appWindow, appWindow->title);
1061BOOL xf_AppWindowCreate(xfContext* xfc, xfAppWindow* appWindow)
1063 XGCValues gcv = WINPR_C_ARRAY_INIT;
1065 XWMHints* InputModeHint =
nullptr;
1066 XClassHint* class_hints =
nullptr;
1067 const rdpSettings* settings =
nullptr;
1070 WINPR_ASSERT(appWindow);
1072 settings = xfc->common.context.settings;
1073 WINPR_ASSERT(settings);
1075 xf_FixWindowCoordinates(xfc, &appWindow->x, &appWindow->y, &appWindow->width,
1076 &appWindow->height);
1077 appWindow->shmid = -1;
1078 appWindow->decorations = xfc->decorations;
1079 appWindow->fullscreen = FALSE;
1080 appWindow->local_move.state = LMS_NOT_ACTIVE;
1081 appWindow->is_mapped = FALSE;
1082 appWindow->is_transient = FALSE;
1083 appWindow->rail_state = 0;
1084 appWindow->maxVert = FALSE;
1085 appWindow->maxHorz = FALSE;
1086 appWindow->minimized = FALSE;
1087 appWindow->rail_ignore_configure = FALSE;
1088 appWindow->rail_fullscreen_normalizing = FALSE;
1089 appWindow->lastWndSizeUpdate = 0;
1091 WINPR_ASSERT(xfc->depth != 0);
1092 appWindow->handle = LogDynAndXCreateWindow(
1093 xfc->log, xfc->display, RootWindowOfScreen(xfc->screen), appWindow->x, appWindow->y,
1094 WINPR_ASSERTING_INT_CAST(uint32_t, appWindow->width),
1095 WINPR_ASSERTING_INT_CAST(uint32_t, appWindow->height), 0, xfc->depth, InputOutput,
1096 xfc->visual, WINPR_ASSERTING_INT_CAST(uint32_t, xfc->attribs_mask), &xfc->attribs);
1098 if (!appWindow->handle)
1102 LogDynAndXCreateGC(xfc->log, xfc->display, appWindow->handle, GCGraphicsExposures, &gcv);
1104 if (!xf_AppWindowResize(xfc, appWindow))
1107 class_hints = XAllocClassHint();
1111 char* strclass =
nullptr;
1115 strclass = _strdup(WmClass);
1119 winpr_asprintf(&strclass, &size,
"RAIL:%08" PRIX64
"", appWindow->windowId);
1121 class_hints->res_class = strclass;
1122 class_hints->res_name =
"RAIL";
1123 XSetClassHint(xfc->display, appWindow->handle, class_hints);
1129 InputModeHint = XAllocWMHints();
1130 InputModeHint->flags = (1L << 0);
1131 InputModeHint->input = True;
1132 XSetWMHints(xfc->display, appWindow->handle, InputModeHint);
1133 XFree(InputModeHint);
1134 XSetWMProtocols(xfc->display, appWindow->handle, &(xfc->WM_DELETE_WINDOW), 1);
1135 input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
1136 EnterWindowMask | LeaveWindowMask | PointerMotionMask | Button1MotionMask |
1137 Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask |
1138 ButtonMotionMask | KeymapStateMask | ExposureMask | VisibilityChangeMask |
1139 StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask |
1140 FocusChangeMask | PropertyChangeMask | ColormapChangeMask | OwnerGrabButtonMask;
1141 XSelectInput(xfc->display, appWindow->handle, input_mask);
1143 if (xfc->XWAYLAND_MAY_GRAB_KEYBOARD)
1144 xf_SendClientEvent(xfc, appWindow->handle, xfc->XWAYLAND_MAY_GRAB_KEYBOARD, 1, 1);
1149void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow, WINPR_ATTR_UNUSED
int maxWidth,
1150 WINPR_ATTR_UNUSED
int maxHeight, WINPR_ATTR_UNUSED
int maxPosX,
1151 WINPR_ATTR_UNUSED
int maxPosY,
int minTrackWidth,
int minTrackHeight,
1152 int maxTrackWidth,
int maxTrackHeight)
1154 XSizeHints* size_hints =
nullptr;
1155 size_hints = XAllocSizeHints();
1159 size_hints->flags = PMinSize | PMaxSize | PResizeInc;
1160 size_hints->min_width = minTrackWidth;
1161 size_hints->min_height = minTrackHeight;
1162 size_hints->max_width = maxTrackWidth;
1163 size_hints->max_height = maxTrackHeight;
1165 size_hints->width_inc = size_hints->height_inc = 1;
1166 XSetWMNormalHints(xfc->display, appWindow->handle, size_hints);
1171void xf_StartLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow,
int direction,
int x,
int y)
1173 if (appWindow->local_move.state != LMS_NOT_ACTIVE)
1180 appWindow->local_move.root_x = x;
1181 appWindow->local_move.root_y = y;
1182 appWindow->local_move.state = LMS_STARTING;
1183 appWindow->local_move.direction = direction;
1188 xfc, appWindow->handle,
1189 xfc->NET_WM_MOVERESIZE,
1198void xf_EndLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow)
1200 if (appWindow->local_move.state == LMS_NOT_ACTIVE)
1203 if (appWindow->local_move.state == LMS_STARTING)
1212 xfc, appWindow->handle,
1213 xfc->NET_WM_MOVERESIZE,
1215 appWindow->local_move.root_x,
1216 appWindow->local_move.root_y,
1217 NET_WM_MOVERESIZE_CANCEL,
1222 appWindow->local_move.state = LMS_NOT_ACTIVE;
1225void xf_MoveWindow(xfContext* xfc, xfAppWindow* appWindow,
int x,
int y,
int width,
int height)
1227 BOOL resize = FALSE;
1229 if ((width * height) < 1)
1232 if ((appWindow->width != width) || (appWindow->height != height))
1235 if (appWindow->local_move.state == LMS_STARTING || appWindow->local_move.state == LMS_ACTIVE)
1240 appWindow->width = width;
1241 appWindow->height = height;
1245 if (!xf_AppWindowResize(xfc, appWindow))
1248 LogDynAndXMoveResizeWindow(xfc->log, xfc->display, appWindow->handle, x, y,
1249 WINPR_ASSERTING_INT_CAST(uint32_t, width),
1250 WINPR_ASSERTING_INT_CAST(uint32_t, height));
1253 LogDynAndXMoveWindow(xfc->log, xfc->display, appWindow->handle, x, y);
1255 xf_UpdateWindowArea(xfc, appWindow, 0, 0, width, height);
1258void xf_ShowWindow(xfContext* xfc, xfAppWindow* appWindow, BYTE state)
1261 WINPR_ASSERT(appWindow);
1266 LogDynAndXWithdrawWindow(xfc->log, xfc->display, appWindow->handle, xfc->screen_number);
1269 case WINDOW_SHOW_MINIMIZED:
1270 appWindow->minimized = TRUE;
1271 XIconifyWindow(xfc->display, appWindow->handle, xfc->screen_number);
1274 case WINDOW_SHOW_MAXIMIZED:
1276 appWindow->maxHorz = TRUE;
1277 appWindow->maxVert = TRUE;
1278 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4, NET_WM_STATE_ADD,
1279 xfc->NET_WM_STATE_MAXIMIZED_VERT, xfc->NET_WM_STATE_MAXIMIZED_HORZ,
1290 if (appWindow->rail_state == WINDOW_SHOW_MAXIMIZED)
1292 xf_UpdateWindowArea(xfc, appWindow, 0, 0,
1293 WINPR_ASSERTING_INT_CAST(
int, appWindow->windowWidth),
1294 WINPR_ASSERTING_INT_CAST(
int, appWindow->windowHeight));
1301 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4, NET_WM_STATE_REMOVE,
1302 xfc->NET_WM_STATE_MAXIMIZED_VERT, xfc->NET_WM_STATE_MAXIMIZED_HORZ,
1311 if (appWindow->rail_state == WINDOW_SHOW_MAXIMIZED)
1312 appWindow->rail_ignore_configure = TRUE;
1314 if (appWindow->is_transient)
1315 xf_SetWindowUnlisted(xfc, appWindow->handle);
1317 LogDynAndXMapWindow(xfc->log, xfc->display, appWindow->handle);
1324 appWindow->rail_state = state;
1325 LogDynAndXFlush(xfc->log, xfc->display);
1328void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow,
RECTANGLE_16* rects,
int nrects)
1330 XRectangle* xrects =
nullptr;
1336 xrects = (XRectangle*)calloc(WINPR_ASSERTING_INT_CAST(uint32_t, nrects),
sizeof(XRectangle));
1338 for (
int i = 0; i < nrects; i++)
1341 xrects[i].x = WINPR_CXX_COMPAT_CAST(
short, rects[i].left);
1342 xrects[i].y = WINPR_CXX_COMPAT_CAST(
short, rects[i].top);
1343 xrects[i].width = WINPR_CXX_COMPAT_CAST(
unsigned short, rects[i].right - rects[i].left);
1344 xrects[i].height = WINPR_CXX_COMPAT_CAST(
unsigned short, rects[i].bottom - rects[i].top);
1347 XShapeCombineRectangles(xfc->display, appWindow->handle, ShapeBounding, 0, 0, xrects, nrects,
1353void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow, UINT32 rectsOffsetX,
1356 XRectangle* xrects =
nullptr;
1362 xrects = (XRectangle*)calloc(WINPR_ASSERTING_INT_CAST(uint32_t, nrects),
sizeof(XRectangle));
1364 for (
int i = 0; i < nrects; i++)
1367 xrects[i].x = WINPR_CXX_COMPAT_CAST(
short, rects[i].left);
1368 xrects[i].y = WINPR_CXX_COMPAT_CAST(
short, rects[i].top);
1369 xrects[i].width = WINPR_CXX_COMPAT_CAST(
unsigned short, rects[i].right - rects[i].left);
1370 xrects[i].height = WINPR_CXX_COMPAT_CAST(
unsigned short, rects[i].bottom - rects[i].top);
1373 XShapeCombineRectangles(
1374 xfc->display, appWindow->handle, ShapeBounding, WINPR_ASSERTING_INT_CAST(
int, rectsOffsetX),
1375 WINPR_ASSERTING_INT_CAST(
int, rectsOffsetY), xrects, nrects, ShapeSet, 0);
1380void xf_ClearWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow)
1383 WINPR_ASSERT(appWindow);
1386 XShapeCombineMask(xfc->display, appWindow->handle, ShapeBounding, 0, 0, None, ShapeSet);
1390void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow,
int x,
int y,
int width,
1395 const rdpSettings* settings =
nullptr;
1399 settings = xfc->common.context.settings;
1400 WINPR_ASSERT(settings);
1402 if (appWindow ==
nullptr)
1405 if (appWindow->surfaceId < UINT16_MAX)
1408 ax = x + appWindow->windowOffsetX;
1409 ay = y + appWindow->windowOffsetY;
1411 if (ax + width > appWindow->windowOffsetX + appWindow->width)
1412 width = (appWindow->windowOffsetX + appWindow->width - 1) - ax;
1414 if (ay + height > appWindow->windowOffsetY + appWindow->height)
1415 height = (appWindow->windowOffsetY + appWindow->height - 1) - ay;
1419 LogDynAndXPutImage(xfc->log, xfc->display, appWindow->pixmap, appWindow->gc, xfc->image, ax,
1420 ay, x, y, WINPR_ASSERTING_INT_CAST(uint32_t, width),
1421 WINPR_ASSERTING_INT_CAST(uint32_t, height));
1424 LogDynAndXCopyArea(xfc->log, xfc->display, appWindow->pixmap, appWindow->handle, appWindow->gc,
1425 x, y, WINPR_ASSERTING_INT_CAST(uint32_t, width),
1426 WINPR_ASSERTING_INT_CAST(uint32_t, height), x, y);
1427 LogDynAndXFlush(xfc->log, xfc->display);
1430void xf_AppWindowDestroyImage(xfAppWindow* appWindow)
1432 WINPR_ASSERT(appWindow);
1433 if (appWindow->image)
1435 appWindow->image->data =
nullptr;
1436 XDestroyImage(appWindow->image);
1437 appWindow->image =
nullptr;
1441void xf_DestroyWindow(xfContext* xfc, xfAppWindow* appWindow)
1446 if (xfc->appWindow == appWindow)
1447 xfc->appWindow =
nullptr;
1450 LogDynAndXFreeGC(xfc->log, xfc->display, appWindow->gc);
1452 if (appWindow->pixmap)
1453 LogDynAndXFreePixmap(xfc->log, xfc->display, appWindow->pixmap);
1455 xf_AppWindowDestroyImage(appWindow);
1457 if (appWindow->handle)
1459 LogDynAndXUnmapWindow(xfc->log, xfc->display, appWindow->handle);
1460 LogDynAndXDestroyWindow(xfc->log, xfc->display, appWindow->handle);
1463 if (appWindow->xfwin)
1464 munmap(
nullptr,
sizeof(*appWindow->xfwin));
1466 if (appWindow->shmid >= 0)
1467 close(appWindow->shmid);
1469 shm_unlink(get_shm_id());
1470 appWindow->xfwin = (Window*)-1;
1471 appWindow->shmid = -1;
1472 free(appWindow->title);
1473 free(appWindow->windowRects);
1474 free(appWindow->visibilityRects);
1478static xfAppWindow* get_windowUnlocked(xfContext* xfc, UINT64
id)
1481 return HashTable_GetItemValue(xfc->railWindows, &
id);
1484xfAppWindow* xf_rail_get_windowFrom(xfContext* xfc, UINT64
id, BOOL alreadyLocked,
const char* file,
1485 const char* fkt,
size_t line)
1490 if (!xfc->railWindows)
1494 xfAppWindowsLockFrom(xfc, file, fkt, line);
1496 xfAppWindow* window = get_windowUnlocked(xfc,
id);
1498 if (!window && !alreadyLocked)
1499 xfAppWindowsUnlockFrom(xfc, file, fkt, line);
1504xfAppWindow* xf_AppWindowFromX11WindowFrom(xfContext* xfc, Window wnd,
const char* file,
1505 const char* fkt,
size_t line)
1507 ULONG_PTR* pKeys =
nullptr;
1510 if (!xfc->railWindows)
1513 xfAppWindowsLockFrom(xfc, file, fkt, line);
1514 size_t count = HashTable_GetKeys(xfc->railWindows, &pKeys);
1516 for (
size_t index = 0; index < count; index++)
1518 xfAppWindow* appWindow = get_windowUnlocked(xfc, *(UINT64*)pKeys[index]);
1522 xfAppWindowsUnlockFrom(xfc, file, fkt, line);
1527 if (appWindow->handle == wnd)
1534 xfAppWindowsUnlockFrom(xfc, file, fkt, line);
1539UINT xf_AppUpdateWindowFromSurface(xfContext* xfc, gdiGfxSurface* surface)
1541 XImage* image =
nullptr;
1542 UINT rc = ERROR_INTERNAL_ERROR;
1545 WINPR_ASSERT(surface);
1547 xfAppWindow* appWindow = xf_rail_get_window(xfc, surface->windowId, FALSE);
1550 WLog_VRB(TAG,
"Failed to find a window for id=0x%08" PRIx64, surface->windowId);
1551 return CHANNEL_RC_OK;
1554 const BOOL surfaceChanged = (appWindow->surfaceId != surface->surfaceId);
1556 appWindow->surfaceId = surface->surfaceId;
1558 const BOOL maximized = (appWindow->dwStyle & WS_MAXIMIZE) != 0;
1559 const UINT32 winW = WINPR_ASSERTING_INT_CAST(uint32_t, appWindow->width);
1560 const UINT32 winH = WINPR_ASSERTING_INT_CAST(uint32_t, appWindow->height);
1564 const RECTANGLE_16* rects = region16_rects(&surface->invalidRegion, &nrects);
1569 fullRect.right = WINPR_ASSERTING_INT_CAST(UINT16, MIN(winW, surface->width));
1570 fullRect.bottom = WINPR_ASSERTING_INT_CAST(UINT16, MIN(winH, surface->height));
1571 if ((fullRect.right > 0) && (fullRect.bottom > 0))
1580 if (surfaceChanged || (appWindow->width != (INT64)surface->width) ||
1581 (appWindow->height != (INT64)surface->height))
1582 xf_AppWindowDestroyImage(appWindow);
1584 if (!appWindow->image)
1586 WINPR_ASSERT(xfc->depth != 0);
1587 appWindow->image = LogDynAndXCreateImage(
1588 xfc->log, xfc->display, xfc->visual, WINPR_ASSERTING_INT_CAST(uint32_t, xfc->depth),
1589 ZPixmap, 0, (
char*)surface->data, surface->width, surface->height,
1590 xfc->scanline_pad, WINPR_ASSERTING_INT_CAST(
int, surface->scanline));
1591 if (!appWindow->image)
1594 "Failed create a XImage[%" PRIu32
"x%" PRIu32
", scanline=%" PRIu32
1595 ", bpp=%" PRId32
"] for window id=0x%08" PRIx64,
1596 surface->width, surface->height, surface->scanline, xfc->depth,
1600 appWindow->image->byte_order = LSBFirst;
1601 appWindow->image->bitmap_bit_order = LSBFirst;
1604 image = appWindow->image;
1608 xfGfxSurface* xfSurface = (xfGfxSurface*)surface;
1609 image = xfSurface->image;
1615 (maximized && (surface->mappedWidth > winW)) ? (int)appWindow->resizeMarginLeft : 0;
1617 (maximized && (surface->mappedHeight > winH)) ? (int)appWindow->resizeMarginTop : 0;
1619 for (UINT32 x = 0; x < nrects; x++)
1622 int srcX = rect->left;
1623 int srcY = rect->top;
1624 int dstX = (int)rect->left - insetX;
1625 int dstY = (int)rect->top - insetY;
1626 int w = (int)rect->right - rect->left;
1627 int h = (int)rect->bottom - rect->top;
1641 if ((w <= 0) || (h <= 0))
1644 LogDynAndXPutImage(xfc->log, xfc->display, appWindow->pixmap, appWindow->gc, image, srcX,
1645 srcY, dstX, dstY, WINPR_ASSERTING_INT_CAST(uint32_t, w),
1646 WINPR_ASSERTING_INT_CAST(uint32_t, h));
1648 LogDynAndXCopyArea(xfc->log, xfc->display, appWindow->pixmap, appWindow->handle,
1649 appWindow->gc, dstX, dstY, WINPR_ASSERTING_INT_CAST(uint32_t, w),
1650 WINPR_ASSERTING_INT_CAST(uint32_t, h), dstX, dstY);
1655 xf_rail_return_window(appWindow, FALSE);
1656 LogDynAndXFlush(xfc->log, xfc->display);
1661BOOL xf_AppWindowResize(xfContext* xfc, xfAppWindow* appWindow)
1664 WINPR_ASSERT(appWindow);
1666 if (appWindow->pixmap != 0)
1667 LogDynAndXFreePixmap(xfc->log, xfc->display, appWindow->pixmap);
1669 WINPR_ASSERT(xfc->depth != 0);
1670 appWindow->pixmap = LogDynAndXCreatePixmap(
1671 xfc->log, xfc->display, xfc->drawable, WINPR_ASSERTING_INT_CAST(uint32_t, appWindow->width),
1672 WINPR_ASSERTING_INT_CAST(uint32_t, appWindow->height),
1673 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->depth));
1674 xf_AppWindowDestroyImage(appWindow);
1676 return appWindow->pixmap != 0;
1679void xf_XSetTransientForHint(xfContext* xfc, xfAppWindow* window)
1682 WINPR_ASSERT(window);
1684 if (window->ownerWindowId == 0)
1687 xfAppWindow* parent = xf_rail_get_window(xfc, window->ownerWindowId, TRUE);
1691 (void)LogDynAndXSetTransientForHint(xfc->log, xfc->display, window->handle, parent->handle);
1692 xf_rail_return_window(parent, TRUE);
1695void xfAppWindowsLockFrom(xfContext* xfc, WINPR_ATTR_UNUSED
const char* file,
1696 WINPR_ATTR_UNUSED
const char* fkt, WINPR_ATTR_UNUSED
size_t line)
1700#if defined(WITH_VERBOSE_WINPR_ASSERT)
1701 const DWORD level = WLOG_TRACE;
1702 if (WLog_IsLevelActive(xfc->log, level))
1703 WLog_PrintTextMessage(xfc->log, level, line, file, fkt,
"[rails] locking [%s]", fkt);
1707 if (xfc->railWindows)
1708 HashTable_Lock(xfc->railWindows);
1710#if defined(WITH_VERBOSE_WINPR_ASSERT)
1711 WINPR_ASSERT(!xfc->isRailWindowsLocked);
1712 xfc->isRailWindowsLocked = TRUE;
1716void xfAppWindowsUnlockFrom(xfContext* xfc, WINPR_ATTR_UNUSED
const char* file,
1717 WINPR_ATTR_UNUSED
const char* fkt, WINPR_ATTR_UNUSED
size_t line)
1721#if defined(WITH_VERBOSE_WINPR_ASSERT)
1722 const DWORD level = WLOG_TRACE;
1723 if (WLog_IsLevelActive(xfc->log, level))
1724 WLog_PrintTextMessage(xfc->log, level, line, file, fkt,
"[rails] unocking [%s]", fkt);
1726 WINPR_ASSERT(xfc->isRailWindowsLocked);
1727 xfc->isRailWindowsLocked = FALSE;
1730 if (xfc->railWindows)
1731 HashTable_Unlock(xfc->railWindows);
WINPR_ATTR_NODISCARD FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
WINPR_ATTR_NODISCARD FREERDP_API INT32 freerdp_settings_get_int32(const rdpSettings *settings, FreeRDP_Settings_Keys_Int32 id)
Returns a INT32 settings value.
WINPR_ATTR_NODISCARD FREERDP_API UINT64 freerdp_settings_get_uint64(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt64 id)
Returns a UINT64 settings value.
WINPR_ATTR_NODISCARD FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.