FreeRDP
Loading...
Searching...
No Matches
xf_event.c
1
21#include <freerdp/config.h>
22
23#include <X11/Xlib.h>
24#include <X11/Xutil.h>
25
26#include <string.h>
27#include <math.h>
28
29#include <winpr/assert.h>
30#include <winpr/path.h>
31
32#include <freerdp/log.h>
33#include <freerdp/locale/keyboard.h>
34
35#include "xf_rail.h"
36#include "xf_window.h"
37#include "xf_cliprdr.h"
38#include "xf_disp.h"
39#include "xf_input.h"
40#include "xf_gfx.h"
41#include "xf_graphics.h"
42#include "xf_utils.h"
43
44#include "xf_debug.h"
45#include "xf_event.h"
46
47#define CLAMP_COORDINATES(x, y) \
48 do \
49 { \
50 if ((x) < 0) \
51 (x) = 0; \
52 if ((y) < 0) \
53 (y) = 0; \
54 } while (0)
55
56static const DWORD mouseLogLevel = WLOG_TRACE;
57
58const char* x11_event_string(int event)
59{
60 switch (event)
61 {
62 case KeyPress:
63 return "KeyPress";
64
65 case KeyRelease:
66 return "KeyRelease";
67
68 case ButtonPress:
69 return "ButtonPress";
70
71 case ButtonRelease:
72 return "ButtonRelease";
73
74 case MotionNotify:
75 return "MotionNotify";
76
77 case EnterNotify:
78 return "EnterNotify";
79
80 case LeaveNotify:
81 return "LeaveNotify";
82
83 case FocusIn:
84 return "FocusIn";
85
86 case FocusOut:
87 return "FocusOut";
88
89 case KeymapNotify:
90 return "KeymapNotify";
91
92 case Expose:
93 return "Expose";
94
95 case GraphicsExpose:
96 return "GraphicsExpose";
97
98 case NoExpose:
99 return "NoExpose";
100
101 case VisibilityNotify:
102 return "VisibilityNotify";
103
104 case CreateNotify:
105 return "CreateNotify";
106
107 case DestroyNotify:
108 return "DestroyNotify";
109
110 case UnmapNotify:
111 return "UnmapNotify";
112
113 case MapNotify:
114 return "MapNotify";
115
116 case MapRequest:
117 return "MapRequest";
118
119 case ReparentNotify:
120 return "ReparentNotify";
121
122 case ConfigureNotify:
123 return "ConfigureNotify";
124
125 case ConfigureRequest:
126 return "ConfigureRequest";
127
128 case GravityNotify:
129 return "GravityNotify";
130
131 case ResizeRequest:
132 return "ResizeRequest";
133
134 case CirculateNotify:
135 return "CirculateNotify";
136
137 case CirculateRequest:
138 return "CirculateRequest";
139
140 case PropertyNotify:
141 return "PropertyNotify";
142
143 case SelectionClear:
144 return "SelectionClear";
145
146 case SelectionRequest:
147 return "SelectionRequest";
148
149 case SelectionNotify:
150 return "SelectionNotify";
151
152 case ColormapNotify:
153 return "ColormapNotify";
154
155 case ClientMessage:
156 return "ClientMessage";
157
158 case MappingNotify:
159 return "MappingNotify";
160
161 case GenericEvent:
162 return "GenericEvent";
163
164 default:
165 return "UNKNOWN";
166 }
167}
168
169static BOOL xf_action_script_append(xfContext* xfc, const char* buffer, size_t size,
170 WINPR_ATTR_UNUSED void* user, const char* what, const char* arg)
171{
172 WINPR_ASSERT(xfc);
173 WINPR_UNUSED(what);
174 WINPR_UNUSED(arg);
175
176 if (!buffer || (size == 0))
177 return TRUE;
178
179 if (!ArrayList_Append(xfc->xevents, buffer))
180 {
181 ArrayList_Clear(xfc->xevents);
182 return FALSE;
183 }
184 return TRUE;
185}
186
187BOOL xf_event_action_script_init(xfContext* xfc)
188{
189 WINPR_ASSERT(xfc);
190
191 xf_event_action_script_free(xfc);
192
193 char* val = getConfigOption(TRUE, "isActionScriptAllowed");
194
195 /* We default to enabled if there is no global config file. */
196 xfc->isActionScriptAllowed = !val || (_stricmp(val, "true") == 0);
197 free(val);
198
199 if (!xfc->isActionScriptAllowed)
200 return TRUE;
201
202 xfc->xevents = ArrayList_New(TRUE);
203
204 if (!xfc->xevents)
205 return FALSE;
206
207 wObject* obj = ArrayList_Object(xfc->xevents);
208 WINPR_ASSERT(obj);
209 obj->fnObjectNew = winpr_ObjectStringClone;
210 obj->fnObjectFree = winpr_ObjectStringFree;
211
212 return run_action_script(xfc, "xevent", nullptr, xf_action_script_append, nullptr);
213}
214
215void xf_event_action_script_free(xfContext* xfc)
216{
217 if (xfc->xevents)
218 {
219 ArrayList_Free(xfc->xevents);
220 xfc->xevents = nullptr;
221 }
222}
223
224static BOOL action_script_run(xfContext* xfc, const char* buffer, size_t size, void* user,
225 const char* what, const char* arg)
226{
227 WINPR_UNUSED(xfc);
228 if (!xfc->isActionScriptAllowed)
229 return TRUE;
230
231 WINPR_UNUSED(what);
232 WINPR_UNUSED(arg);
233 WINPR_ASSERT(user);
234 int* pstatus = user;
235
236 if (size == 0)
237 {
238 WLog_Print(xfc->log, WLOG_WARN, "ActionScript xevent: script did not return data");
239 return FALSE;
240 }
241
242 if (winpr_PathFileExists(buffer))
243 {
244 char* cmd = nullptr;
245 size_t cmdlen = 0;
246 winpr_asprintf(&cmd, &cmdlen, "%s %s %s", buffer, what, arg);
247 if (!cmd)
248 return FALSE;
249
250 // NOLINTNEXTLINE(bugprone-command-processor)
251 FILE* fp = popen(cmd, "w");
252 free(cmd);
253 if (!fp)
254 {
255 WLog_Print(xfc->log, WLOG_ERROR, "Failed to execute '%s'", buffer);
256 return FALSE;
257 }
258
259 *pstatus = pclose(fp);
260 if (*pstatus < 0)
261 {
262 WLog_Print(xfc->log, WLOG_ERROR, "Command '%s' returned %d", buffer, *pstatus);
263 return FALSE;
264 }
265 }
266 else
267 {
268 WLog_Print(xfc->log, WLOG_WARN, "ActionScript xevent: No such file '%s'", buffer);
269 return FALSE;
270 }
271
272 return TRUE;
273}
274
275static BOOL xf_event_execute_action_script(xfContext* xfc, const XEvent* event)
276{
277 size_t count = 0;
278 char* name = nullptr;
279 BOOL match = FALSE;
280 const char* xeventName = nullptr;
281
282 if (!xfc->actionScriptExists || !xfc->xevents || !xfc->window)
283 return FALSE;
284
285 if (event->type > LASTEvent)
286 return FALSE;
287
288 xeventName = x11_event_string(event->type);
289 count = ArrayList_Count(xfc->xevents);
290
291 for (size_t index = 0; index < count; index++)
292 {
293 name = (char*)ArrayList_GetItem(xfc->xevents, index);
294
295 if (_stricmp(name, xeventName) == 0)
296 {
297 match = TRUE;
298 break;
299 }
300 }
301
302 if (!match)
303 return FALSE;
304
305 char command[2048] = WINPR_C_ARRAY_INIT;
306 char arg[2048] = WINPR_C_ARRAY_INIT;
307 (void)_snprintf(command, sizeof(command), "xevent %s", xeventName);
308 (void)_snprintf(arg, sizeof(arg), "%lu", (unsigned long)xfc->window->handle);
309 return run_action_script(xfc, command, arg, action_script_run, nullptr);
310}
311
312void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y)
313{
314 if (!xfc || !xfc->common.context.settings || !y || !x)
315 return;
316
317 rdpSettings* settings = xfc->common.context.settings;
318 INT64 tx = *x;
319 INT64 ty = *y;
320 if (!xfc->remote_app)
321 {
322#ifdef WITH_XRENDER
323
324 if (xf_picture_transform_required(xfc))
325 {
326 const double dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
327 const double dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
328 double xScalingFactor = xfc->scaledWidth / dw;
329 double yScalingFactor = xfc->scaledHeight / dh;
330 tx = (INT64)lround((1.0 * (*x) + xfc->offset_x) * xScalingFactor);
331 ty = (INT64)lround((1.0 * (*y) + xfc->offset_y) * yScalingFactor);
332 }
333
334#endif
335 }
336
337 CLAMP_COORDINATES(tx, ty);
338 *x = (UINT32)tx;
339 *y = (UINT32)ty;
340}
341
342void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y)
343{
344 if (!xfc || !xfc->common.context.settings || !y || !x)
345 return;
346
347 if (!xfc->remote_app)
348 {
349#ifdef WITH_XRENDER
350 rdpSettings* settings = xfc->common.context.settings;
351 if (xf_picture_transform_required(xfc))
352 {
353 double xScalingFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) /
354 (double)xfc->scaledWidth;
355 double yScalingFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) /
356 (double)xfc->scaledHeight;
357 *x = (int)((*x - xfc->offset_x) * xScalingFactor);
358 *y = (int)((*y - xfc->offset_y) * yScalingFactor);
359 }
360
361#endif
362 }
363
364 CLAMP_COORDINATES(*x, *y);
365}
366
367static BOOL xf_event_Expose(xfContext* xfc, const XExposeEvent* event, BOOL app)
368{
369 WINPR_ASSERT(xfc);
370 WINPR_ASSERT(event);
371
372 rdpSettings* settings = xfc->common.context.settings;
373 WINPR_ASSERT(settings);
374
375 if (!app && (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
376 freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures)))
377 {
378 xfc->exposedArea.x = 0;
379 xfc->exposedArea.y = 0;
380 xfc->exposedArea.w = WINPR_ASSERTING_INT_CAST(
381 int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth));
382 xfc->exposedArea.h = WINPR_ASSERTING_INT_CAST(
383 int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
384 }
385 else
386 {
387 xfc->exposedArea.x = event->x;
388 xfc->exposedArea.y = event->y;
389 xfc->exposedArea.w = event->width;
390 xfc->exposedArea.h = event->height;
391 }
392
393 xfc->exposedWindow = event->window;
394 xfc->exposeRequested = true;
395
396 return TRUE;
397}
398
399static BOOL xf_event_VisibilityNotify(xfContext* xfc, const XVisibilityEvent* event, BOOL app)
400{
401 WINPR_UNUSED(app);
402 xfc->unobscured = event->state == VisibilityUnobscured;
403 return TRUE;
404}
405
406BOOL xf_generic_MotionNotify_(xfContext* xfc, int x, int y, Window window, BOOL app,
407 const char* file, const char* fkt, size_t line)
408{
409 Window childWindow = None;
410
411 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
412 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
413 "%s: x=%d, y=%d, window=0x%08lx, app=%d", __func__, x, y, window,
414 app);
415
416 WINPR_ASSERT(xfc);
417 WINPR_ASSERT(xfc->common.context.settings);
418
419 if (app)
420 {
421 /* make sure window exists */
422 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, window);
423 xf_rail_return_window(appWindow, FALSE);
424 if (!appWindow)
425 return TRUE;
426
427 /* Translate to desktop coordinates */
428 XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y, &x, &y,
429 &childWindow);
430 }
431
432 xf_event_adjust_coordinates(xfc, &x, &y);
433 freerdp_client_send_button_event(&xfc->common, FALSE, PTR_FLAGS_MOVE, x, y);
434
435 if (xfc->fullscreen && !app)
436 {
437 if (xfc->window)
438 XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
439 }
440
441 return TRUE;
442}
443
444BOOL xf_generic_RawMotionNotify_(xfContext* xfc, int x, int y, WINPR_ATTR_UNUSED Window window,
445 BOOL app, const char* file, const char* fkt, size_t line)
446{
447 WINPR_ASSERT(xfc);
448
449 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
450 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
451 "%s: x=%d, y=%d, window=0x%08lx, app=%d", __func__, x, y, window,
452 app);
453
454 if (app)
455 {
456 WLog_Print(xfc->log, WLOG_ERROR,
457 "Relative mouse input is not supported with remoate app mode!");
458 return FALSE;
459 }
460
461 return freerdp_client_send_button_event(&xfc->common, TRUE, PTR_FLAGS_MOVE, x, y);
462}
463
464static BOOL xf_event_MotionNotify(xfContext* xfc, const XMotionEvent* event, BOOL app)
465{
466 WINPR_ASSERT(xfc);
467
468 if (xfc->window)
469 xf_floatbar_set_root_y(xfc->window->floatbar, event->y);
470
471 if (xfc->xi_event || xfc->xi_rawevent || (xfc->common.mouse_grabbed && xf_use_rel_mouse(xfc)))
472 return TRUE;
473
474 return xf_generic_MotionNotify(xfc, event->x, event->y, event->window, app);
475}
476
477BOOL xf_generic_ButtonEvent_(xfContext* xfc, int x, int y, int button, Window window, BOOL app,
478 BOOL down, const char* file, const char* fkt, size_t line)
479{
480 UINT16 flags = 0;
481 Window childWindow = None;
482
483 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
484 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
485 "%s: x=%d, y=%d, button=%d, window=0x%08lx, app=%d, down=%d",
486 __func__, x, y, button, window, app, down);
487
488 WINPR_ASSERT(xfc);
489 if (button < 0)
490 return FALSE;
491
492 for (size_t i = 0; i < ARRAYSIZE(xfc->button_map); i++)
493 {
494 const button_map* cur = &xfc->button_map[i];
495
496 if (cur->button == (UINT32)button)
497 {
498 flags = cur->flags;
499 break;
500 }
501 }
502
503 if (flags != 0)
504 {
505 if (flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL))
506 {
507 if (down)
508 freerdp_client_send_wheel_event(&xfc->common, flags);
509 }
510 else
511 {
512 BOOL extended = FALSE;
513
514 if (flags & (PTR_XFLAGS_BUTTON1 | PTR_XFLAGS_BUTTON2))
515 {
516 extended = TRUE;
517
518 if (down)
519 flags |= PTR_XFLAGS_DOWN;
520 }
521 else if (flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3))
522 {
523 if (down)
524 flags |= PTR_FLAGS_DOWN;
525 }
526
527 if (app)
528 {
529 /* make sure window exists */
530 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, window);
531 xf_rail_return_window(appWindow, FALSE);
532 if (!appWindow)
533 return TRUE;
534
535 /* Translate to desktop coordinates */
536 XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y,
537 &x, &y, &childWindow);
538 }
539
540 xf_event_adjust_coordinates(xfc, &x, &y);
541
542 if (extended)
543 freerdp_client_send_extended_button_event(&xfc->common, FALSE, flags, x, y);
544 else
545 freerdp_client_send_button_event(&xfc->common, FALSE, flags, x, y);
546 }
547 }
548
549 return TRUE;
550}
551
552static BOOL xf_grab_mouse(xfContext* xfc)
553{
554 WINPR_ASSERT(xfc);
555
556 if (!xfc->window)
557 return FALSE;
558
559 if (freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_GrabMouse))
560 {
561 XGrabPointer(xfc->display, xfc->window->handle, False,
562 ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask |
563 EnterWindowMask | LeaveWindowMask,
564 GrabModeAsync, GrabModeAsync, xfc->window->handle, None, CurrentTime);
565 xfc->common.mouse_grabbed = TRUE;
566 }
567 return TRUE;
568}
569
570static BOOL xf_grab_kbd(xfContext* xfc)
571{
572 WINPR_ASSERT(xfc);
573
574 if (!xfc->window)
575 return FALSE;
576
577 XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync, GrabModeAsync,
578 CurrentTime);
579 return TRUE;
580}
581
582static BOOL xf_event_ButtonPress(xfContext* xfc, const XButtonEvent* event, BOOL app)
583{
584 xf_grab_mouse(xfc);
585
586 if (xfc->xi_event || xfc->xi_rawevent || (xfc->common.mouse_grabbed && xf_use_rel_mouse(xfc)))
587 return TRUE;
588 if (!app && xfc_is_floatbar_window(xfc, event->window))
589 return TRUE;
590 return xf_generic_ButtonEvent(xfc, event->x, event->y,
591 WINPR_ASSERTING_INT_CAST(int, event->button), event->window, app,
592 TRUE);
593}
594
595static BOOL xf_event_ButtonRelease(xfContext* xfc, const XButtonEvent* event, BOOL app)
596{
597 xf_grab_mouse(xfc);
598
599 if (xfc->xi_event || xfc->xi_rawevent || (xfc->common.mouse_grabbed && xf_use_rel_mouse(xfc)))
600 return TRUE;
601 return xf_generic_ButtonEvent(xfc, event->x, event->y,
602 WINPR_ASSERTING_INT_CAST(int, event->button), event->window, app,
603 FALSE);
604}
605
606static BOOL xf_event_KeyPress(xfContext* xfc, const XKeyEvent* event, BOOL app)
607{
608 KeySym keysym = 0;
609 char str[256] = WINPR_C_ARRAY_INIT;
610 union
611 {
612 const XKeyEvent* cev;
613 XKeyEvent* ev;
614 } cnv;
615 cnv.cev = event;
616 WINPR_UNUSED(app);
617 XLookupString(cnv.ev, str, sizeof(str), &keysym, nullptr);
618 xf_keyboard_key_press(xfc, event, keysym);
619 return TRUE;
620}
621
622static BOOL xf_event_KeyRelease(xfContext* xfc, const XKeyEvent* event, BOOL app)
623{
624 KeySym keysym = 0;
625 char str[256] = WINPR_C_ARRAY_INIT;
626 union
627 {
628 const XKeyEvent* cev;
629 XKeyEvent* ev;
630 } cnv;
631 cnv.cev = event;
632
633 WINPR_UNUSED(app);
634 XLookupString(cnv.ev, str, sizeof(str), &keysym, nullptr);
635 xf_keyboard_key_release(xfc, event, keysym);
636 return TRUE;
637}
638
639/* Release a key, but ignore the event in case of autorepeat.
640 */
641static BOOL xf_event_KeyReleaseOrIgnore(xfContext* xfc, const XKeyEvent* event, BOOL app)
642{
643 WINPR_ASSERT(xfc);
644 WINPR_ASSERT(event);
645
646 if ((event->type == KeyRelease) && XEventsQueued(xfc->display, QueuedAfterReading))
647 {
648 XEvent nev = WINPR_C_ARRAY_INIT;
649 XPeekEvent(xfc->display, &nev);
650
651 if ((nev.type == KeyPress) && (nev.xkey.time == event->time) &&
652 (nev.xkey.keycode == event->keycode))
653 {
654 /* Key wasn’t actually released */
655 return TRUE;
656 }
657 }
658
659 return xf_event_KeyRelease(xfc, event, app);
660}
661
662static BOOL xf_event_FocusIn(xfContext* xfc, const XFocusInEvent* event, BOOL app)
663{
664 if (event->mode == NotifyGrab)
665 return TRUE;
666
667 xfc->focused = TRUE;
668
669 if (xfc->mouse_active && !app)
670 {
671 xf_grab_mouse(xfc);
672 if (!xf_grab_kbd(xfc))
673 return FALSE;
674 }
675
676 /* Release all keys, should already be done at FocusOut but might be missed
677 * if the WM decided to use an alternate event order */
678 if (!app)
679 xf_keyboard_release_all_keypress(xfc);
680 else
681 {
682 if (!xf_rail_send_activate(xfc, event->window, TRUE))
683 return FALSE;
684 }
685
686 xf_pointer_update_scale(xfc);
687
688 if (app)
689 {
690 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
691
692 /* Update the server with any window changes that occurred while the window was not focused.
693 */
694 if (appWindow)
695 xf_rail_adjust_position(xfc, appWindow);
696 xf_rail_return_window(appWindow, FALSE);
697 }
698
699 xf_keyboard_focus_in(xfc);
700 return TRUE;
701}
702
703static BOOL xf_event_FocusOut(xfContext* xfc, const XFocusOutEvent* event, BOOL app)
704{
705 if (event->mode == NotifyUngrab)
706 return TRUE;
707
708 xfc->focused = FALSE;
709
710 if (event->mode == NotifyWhileGrabbed)
711 XUngrabKeyboard(xfc->display, CurrentTime);
712
713 xf_keyboard_release_all_keypress(xfc);
714 if (app)
715 return xf_rail_send_activate(xfc, event->window, FALSE);
716
717 return TRUE;
718}
719
720static BOOL xf_event_MappingNotify(xfContext* xfc, const XMappingEvent* event, BOOL app)
721{
722 WINPR_UNUSED(app);
723
724 switch (event->request)
725 {
726 case MappingModifier:
727 return xf_keyboard_update_modifier_map(xfc);
728 case MappingKeyboard:
729 WLog_Print(xfc->log, WLOG_TRACE, "[%d] MappingKeyboard", event->request);
730 return xf_keyboard_init(xfc);
731 case MappingPointer:
732 WLog_Print(xfc->log, WLOG_TRACE, "[%d] MappingPointer", event->request);
733 xf_button_map_init(xfc);
734 return TRUE;
735 default:
736 WLog_Print(xfc->log, WLOG_WARN,
737 "[%d] Unsupported MappingNotify::request, must be one "
738 "of[MappingModifier(%d), MappingKeyboard(%d), MappingPointer(%d)]",
739 event->request, MappingModifier, MappingKeyboard, MappingPointer);
740 return FALSE;
741 }
742}
743
744static BOOL xf_event_ClientMessage(xfContext* xfc, const XClientMessageEvent* event, BOOL app)
745{
746 if ((event->message_type == xfc->WM_PROTOCOLS) &&
747 ((Atom)event->data.l[0] == xfc->WM_DELETE_WINDOW))
748 {
749 if (app)
750 {
751 BOOL rc = TRUE;
752 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
753
754 if (appWindow)
755 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_CLOSE);
756 xf_rail_return_window(appWindow, FALSE);
757 return rc;
758 }
759 else
760 {
761 WLog_Print(xfc->log, WLOG_TRACE, "Main window closed");
762 return FALSE;
763 }
764 }
765
766 return TRUE;
767}
768
769static BOOL xf_event_EnterNotify(xfContext* xfc, const XEnterWindowEvent* event, BOOL app)
770{
771 if (!app)
772 {
773 if (!xfc->window)
774 return FALSE;
775
776 xfc->mouse_active = TRUE;
777
778 if (xfc->fullscreen)
779 XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
780
781 if (xfc->focused)
782 xf_grab_kbd(xfc);
783 }
784 else
785 {
786 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
787
788 /* keep track of which window has focus so that we can apply pointer updates */
789 xfc->appWindow = appWindow;
790 xf_rail_return_window(appWindow, FALSE);
791 }
792
793 return TRUE;
794}
795
796static BOOL xf_event_LeaveNotify(xfContext* xfc, const XLeaveWindowEvent* event, BOOL app)
797{
798 if (event->mode == NotifyGrab || event->mode == NotifyUngrab)
799 return TRUE;
800 if (!app)
801 {
802 xfc->mouse_active = FALSE;
803 XUngrabKeyboard(xfc->display, CurrentTime);
804 }
805 else
806 {
807 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
808
809 /* keep track of which window has focus so that we can apply pointer updates */
810 if (xfc->appWindow == appWindow)
811 xfc->appWindow = nullptr;
812 xf_rail_return_window(appWindow, FALSE);
813 }
814 return TRUE;
815}
816
817static BOOL xf_event_ConfigureNotify(xfContext* xfc, const XConfigureEvent* event, BOOL app)
818{
819 Window childWindow = None;
820 xfAppWindow* appWindow = nullptr;
821
822 WINPR_ASSERT(xfc);
823 WINPR_ASSERT(event);
824
825 const rdpSettings* settings = xfc->common.context.settings;
826 WINPR_ASSERT(settings);
827
828 WLog_Print(xfc->log, WLOG_DEBUG, "x=%" PRId32 ", y=%" PRId32 ", w=%" PRId32 ", h=%" PRId32,
829 event->x, event->y, event->width, event->height);
830
831 if (!app)
832 {
833 if (!xfc->window)
834 return FALSE;
835
836 if (xfc->window->left != event->x)
837 xfc->window->left = event->x;
838
839 if (xfc->window->top != event->y)
840 xfc->window->top = event->y;
841
842 if (xfc->window->width != event->width || xfc->window->height != event->height)
843 {
844 xfc->window->width = event->width;
845 xfc->window->height = event->height;
846#ifdef WITH_XRENDER
847 xfc->offset_x = 0;
848 xfc->offset_y = 0;
849
850 if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
851 freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
852 {
853 xfc->scaledWidth = xfc->window->width;
854 xfc->scaledHeight = xfc->window->height;
855 xf_draw_screen(
856 xfc, 0, 0,
857 WINPR_ASSERTING_INT_CAST(
858 int32_t, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)),
859 WINPR_ASSERTING_INT_CAST(
860 int32_t, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)));
861 }
862 else
863 {
864 xfc->scaledWidth = WINPR_ASSERTING_INT_CAST(
865 int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth));
866 xfc->scaledHeight = WINPR_ASSERTING_INT_CAST(
867 int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
868 }
869
870#endif
871 }
872
873 if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
874 {
875 const int alignedWidth = (xfc->window->width / 2) * 2;
876 const int alignedHeight = (xfc->window->height / 2) * 2;
877 /* ask the server to resize using the display channel */
878 xf_disp_handle_configureNotify(xfc, alignedWidth, alignedHeight);
879 }
880 }
881 else
882 {
883 appWindow = xf_AppWindowFromX11Window(xfc, event->window);
884
885 if (appWindow)
886 {
887 /*
888 * ConfigureNotify coordinates are expressed relative to the window parent.
889 * Translate these to root window coordinates.
890 */
891 XTranslateCoordinates(xfc->display, appWindow->handle, RootWindowOfScreen(xfc->screen),
892 0, 0, &appWindow->x, &appWindow->y, &childWindow);
893 appWindow->width = event->width;
894 appWindow->height = event->height;
895
896 xf_AppWindowResize(xfc, appWindow);
897
898 /*
899 * Additional checks for not in a local move and not ignoring configure to send
900 * position update to server, also should the window not be focused then do not
901 * send to server yet (i.e. resizing using window decoration).
902 * The server will be updated when the window gets refocused.
903 */
904 if (appWindow->decorations)
905 {
906 /* moving resizing using window decoration */
907 xf_rail_adjust_position(xfc, appWindow);
908 }
909 else
910 {
911 if ((!event->send_event || appWindow->local_move.state == LMS_NOT_ACTIVE) &&
912 !appWindow->rail_ignore_configure && xfc->focused)
913 xf_rail_adjust_position(xfc, appWindow);
914 }
915 }
916 xf_rail_return_window(appWindow, FALSE);
917 }
918 return xf_pointer_update_scale(xfc);
919}
920
921static BOOL xf_event_MapNotify(xfContext* xfc, const XMapEvent* event, BOOL app)
922{
923 WINPR_ASSERT(xfc);
924 if (!app)
925 {
926 if (!gdi_send_suppress_output(xfc->common.context.gdi, FALSE))
927 return FALSE;
928 }
929 else
930 {
931 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
932
933 if (appWindow)
934 {
935 /* local restore event */
936 /* This is now handled as part of the PropertyNotify
937 * Doing this here would inhibit the ability to restore a maximized window
938 * that is minimized back to the maximized state
939 */
940 // xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
941 appWindow->is_mapped = TRUE;
942 }
943 xf_rail_return_window(appWindow, FALSE);
944 }
945
946 return TRUE;
947}
948
949static BOOL xf_event_UnmapNotify(xfContext* xfc, const XUnmapEvent* event, BOOL app)
950{
951 WINPR_ASSERT(xfc);
952 WINPR_ASSERT(event);
953
954 if (!app)
955 xf_keyboard_release_all_keypress(xfc);
956
957 if (!app)
958 return gdi_send_suppress_output(xfc->common.context.gdi, TRUE);
959
960 {
961 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
962
963 if (appWindow)
964 appWindow->is_mapped = FALSE;
965 xf_rail_return_window(appWindow, FALSE);
966 }
967
968 return TRUE;
969}
970
971static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, BOOL app)
972{
973 BOOL rc = TRUE;
974 WINPR_ASSERT(xfc);
975 WINPR_ASSERT(event);
976
977 const Window root = DefaultRootWindow(xfc->display);
978 if ((event->window == root) &&
979 ((event->atom == xfc->NET_WORKAREA) || (event->atom == xfc->NET_CURRENT_DESKTOP)))
980 {
981 if (xfc->remote_app && xfc->rail)
982 return xf_rail_schedule_workarea(xfc);
983 }
984
985 /*
986 * This section handles sending the appropriate commands to the rail server
987 * when the window has been minimized, maximized, restored locally
988 * ie. not using the buttons on the rail window itself
989 */
990 if (((event->atom == xfc->NET_WM_STATE) && (event->state != PropertyDelete)) ||
991 ((event->atom == xfc->WM_STATE) && (event->state != PropertyDelete)))
992 {
993 BOOL status = FALSE;
994 BOOL minimized = FALSE;
995 BOOL minimizedChanged = FALSE;
996 BOOL fullscreen = FALSE;
997 unsigned long nitems = 0;
998 unsigned long bytes = 0;
999 unsigned char* prop = nullptr;
1000 xfAppWindow* appWindow = nullptr;
1001
1002 if (app)
1003 {
1004 appWindow = xf_AppWindowFromX11Window(xfc, event->window);
1005
1006 if (!appWindow)
1007 goto fail;
1008 }
1009
1010 if (event->atom == xfc->NET_WM_STATE)
1011 {
1012 status = xf_GetWindowProperty(xfc, event->window, xfc->NET_WM_STATE, 12, &nitems,
1013 &bytes, &prop);
1014
1015 if (status)
1016 {
1017 if (appWindow)
1018 {
1019 appWindow->maxVert = FALSE;
1020 appWindow->maxHorz = FALSE;
1021 }
1022 for (unsigned long i = 0; i < nitems; i++)
1023 {
1024 if ((Atom)WINPR_PACKED_ALIGN_CAST(UINT16**, prop)[i] ==
1025 xfc->NET_WM_STATE_FULLSCREEN)
1026 fullscreen = TRUE;
1027 if ((Atom)(WINPR_PACKED_ALIGN_CAST(UINT16**, prop))[i] ==
1028 Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT",
1029 False))
1030 {
1031 if (appWindow)
1032 appWindow->maxVert = TRUE;
1033 }
1034
1035 if ((Atom)(WINPR_PACKED_ALIGN_CAST(UINT16**, prop)[i]) ==
1036 Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ",
1037 False))
1038 {
1039 if (appWindow)
1040 appWindow->maxHorz = TRUE;
1041 }
1042 }
1043
1044 XFree(prop);
1045
1046 if (appWindow && appWindow->rail_fullscreen_normalizing)
1047 {
1048 if (!fullscreen && appWindow->maxVert && appWindow->maxHorz)
1049 {
1050 /* Normal maximized state has been restored. */
1051 appWindow->rail_fullscreen_normalizing = FALSE;
1052 }
1053 else
1054 {
1055 /* Ignore all transient WM states produced while Cinnamon
1056 * transitions from legacy fullscreen back to maximized. */
1057 if (fullscreen)
1058 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1059 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_FULLSCREEN, 0,
1060 0);
1061
1062 if (!appWindow->maxVert || !appWindow->maxHorz)
1063 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1064 NET_WM_STATE_ADD, xfc->NET_WM_STATE_MAXIMIZED_VERT,
1065 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0);
1066
1067 goto fail;
1068 }
1069 }
1070 else if (appWindow && fullscreen &&
1071 (appWindow->rail_state == WINDOW_SHOW_MAXIMIZED))
1072 {
1073 /* Cinnamon/Muffin incorrectly turns the server-driven RAIL
1074 * maximize resize into fullscreen. Normalize this over the
1075 * following PropertyNotify events without feeding transient
1076 * states back to the RAIL server. */
1077 appWindow->rail_fullscreen_normalizing = TRUE;
1078
1079 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1080 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_FULLSCREEN, 0, 0);
1081
1082 if (!appWindow->maxVert || !appWindow->maxHorz)
1083 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1084 NET_WM_STATE_ADD, xfc->NET_WM_STATE_MAXIMIZED_VERT,
1085 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0);
1086
1087 goto fail;
1088 }
1089 }
1090 }
1091
1092 if (event->atom == xfc->WM_STATE)
1093 {
1094 status =
1095 xf_GetWindowProperty(xfc, event->window, xfc->WM_STATE, 1, &nitems, &bytes, &prop);
1096
1097 if (status)
1098 {
1099 /* If the window is in the iconic state */
1100 if (((UINT32)*prop == 3) && !IsGnome())
1101 {
1102 minimized = TRUE;
1103 if (appWindow)
1104 appWindow->minimized = TRUE;
1105 }
1106 else
1107 {
1108 minimized = FALSE;
1109 if (appWindow)
1110 appWindow->minimized = FALSE;
1111 }
1112
1113 minimizedChanged = TRUE;
1114 XFree(prop);
1115 }
1116 }
1117
1118 if (app)
1119 {
1120 WINPR_ASSERT(appWindow);
1121 if (appWindow->maxVert && appWindow->maxHorz && !appWindow->minimized)
1122 {
1123 if (appWindow->rail_state != WINDOW_SHOW_MAXIMIZED)
1124 {
1125 appWindow->rail_state = WINDOW_SHOW_MAXIMIZED;
1126 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MAXIMIZE);
1127 }
1128 }
1129 else if (appWindow->minimized)
1130 {
1131 if (appWindow->rail_state != WINDOW_SHOW_MINIMIZED)
1132 {
1133 appWindow->rail_state = WINDOW_SHOW_MINIMIZED;
1134 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MINIMIZE);
1135 }
1136 }
1137 else
1138 {
1139 if (appWindow->rail_state != WINDOW_SHOW && appWindow->rail_state != WINDOW_HIDE)
1140 {
1141 appWindow->rail_state = WINDOW_SHOW;
1142 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
1143 }
1144 }
1145 }
1146 else if (minimizedChanged)
1147 rc = gdi_send_suppress_output(xfc->common.context.gdi, minimized);
1148
1149 fail:
1150 xf_rail_return_window(appWindow, FALSE);
1151 }
1152
1153 return rc;
1154}
1155
1156static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, const XEvent* event)
1157{
1158 if (!xfc->remote_app)
1159 return FALSE;
1160
1161 switch (appWindow->local_move.state)
1162 {
1163 case LMS_NOT_ACTIVE:
1164
1165 /* No local move in progress, nothing to do */
1166
1167 /* Prevent Configure from happening during indeterminant state of Horz or Vert Max only
1168 */
1169 if ((event->type == ConfigureNotify) && appWindow->rail_ignore_configure)
1170 {
1171 appWindow->rail_ignore_configure = FALSE;
1172 return TRUE;
1173 }
1174
1175 break;
1176
1177 case LMS_STARTING:
1178
1179 /* Local move initiated by RDP server, but we have not yet seen any updates from the X
1180 * server */
1181 switch (event->type)
1182 {
1183 case ConfigureNotify:
1184 /* Starting to see move events from the X server. Local move is now in progress.
1185 */
1186 appWindow->local_move.state = LMS_ACTIVE;
1187 /* Allow these events to be processed during move to keep our state up to date.
1188 */
1189 break;
1190
1191 case ButtonPress:
1192 case ButtonRelease:
1193 case KeyPress:
1194 case KeyRelease:
1195 case UnmapNotify:
1196 /*
1197 * A button release event means the X window server did not grab the
1198 * mouse before the user released it. In this case we must cancel the
1199 * local move. The event will be processed below as normal, below.
1200 */
1201 break;
1202
1203 case VisibilityNotify:
1204 case PropertyNotify:
1205 case Expose:
1206 /* Allow these events to pass */
1207 break;
1208
1209 default:
1210 /* Eat any other events */
1211 return TRUE;
1212 }
1213
1214 break;
1215
1216 case LMS_ACTIVE:
1217
1218 /* Local move is in progress */
1219 switch (event->type)
1220 {
1221 case ConfigureNotify:
1222 case VisibilityNotify:
1223 case PropertyNotify:
1224 case Expose:
1225 case GravityNotify:
1226 /* Keep us up to date on position */
1227 break;
1228
1229 default:
1230 /* Any other event terminates move */
1231 xf_rail_end_local_move(xfc, appWindow);
1232 break;
1233 }
1234
1235 break;
1236
1237 case LMS_TERMINATING:
1238 /* Already sent RDP end move to server. Allow events to pass. */
1239 break;
1240 default:
1241 break;
1242 }
1243
1244 return FALSE;
1245}
1246
1247BOOL xf_event_process(freerdp* instance, const XEvent* event)
1248{
1249 BOOL status = TRUE;
1250
1251 WINPR_ASSERT(instance);
1252 WINPR_ASSERT(event);
1253
1254 xfContext* xfc = (xfContext*)instance->context;
1255 WINPR_ASSERT(xfc);
1256
1257 rdpSettings* settings = xfc->common.context.settings;
1258 WINPR_ASSERT(settings);
1259
1260 if (xfc->remote_app)
1261 {
1262 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
1263
1264 if (appWindow)
1265 {
1266 /* Update "current" window for cursor change orders */
1267 xfc->appWindow = appWindow;
1268
1269 const BOOL rc = xf_event_suppress_events(xfc, appWindow, event);
1270 xf_rail_return_window(appWindow, FALSE);
1271 if (rc)
1272 return TRUE;
1273 }
1274 }
1275
1276 if (xfc->window)
1277 {
1278 xfFloatbar* floatbar = xfc->window->floatbar;
1279 if (xf_floatbar_check_event(floatbar, event))
1280 {
1281 xf_floatbar_event_process(floatbar, event);
1282 return TRUE;
1283 }
1284
1285 if (xf_floatbar_is_locked(floatbar))
1286 {
1287 /* Filter input events, floatbar is locked do not forward anything to the session */
1288 switch (event->type)
1289 {
1290 case MotionNotify:
1291 case ButtonPress:
1292 case ButtonRelease:
1293 case KeyPress:
1294 case KeyRelease:
1295 case FocusIn:
1296 case FocusOut:
1297 case EnterNotify:
1298 case LeaveNotify:
1299 return TRUE;
1300 default:
1301 break;
1302 }
1303 }
1304 }
1305
1306 xf_event_execute_action_script(xfc, event);
1307
1308 if (event->type != MotionNotify)
1309 {
1310 WLog_Print(xfc->log, WLOG_TRACE, "%s Event(%d): wnd=0x%08lX", x11_event_string(event->type),
1311 event->type, (unsigned long)event->xany.window);
1312 }
1313
1314 switch (event->type)
1315 {
1316 case Expose:
1317 status = xf_event_Expose(xfc, &event->xexpose, xfc->remote_app);
1318 break;
1319
1320 case VisibilityNotify:
1321 status = xf_event_VisibilityNotify(xfc, &event->xvisibility, xfc->remote_app);
1322 break;
1323
1324 case MotionNotify:
1325 status = xf_event_MotionNotify(xfc, &event->xmotion, xfc->remote_app);
1326 break;
1327
1328 case ButtonPress:
1329 status = xf_event_ButtonPress(xfc, &event->xbutton, xfc->remote_app);
1330 break;
1331
1332 case ButtonRelease:
1333 status = xf_event_ButtonRelease(xfc, &event->xbutton, xfc->remote_app);
1334 break;
1335
1336 case KeyPress:
1337 status = xf_event_KeyPress(xfc, &event->xkey, xfc->remote_app);
1338 break;
1339
1340 case KeyRelease:
1341 status = xf_event_KeyReleaseOrIgnore(xfc, &event->xkey, xfc->remote_app);
1342 break;
1343
1344 case FocusIn:
1345 status = xf_event_FocusIn(xfc, &event->xfocus, xfc->remote_app);
1346 break;
1347
1348 case FocusOut:
1349 status = xf_event_FocusOut(xfc, &event->xfocus, xfc->remote_app);
1350 break;
1351
1352 case EnterNotify:
1353 status = xf_event_EnterNotify(xfc, &event->xcrossing, xfc->remote_app);
1354 break;
1355
1356 case LeaveNotify:
1357 status = xf_event_LeaveNotify(xfc, &event->xcrossing, xfc->remote_app);
1358 break;
1359
1360 case NoExpose:
1361 break;
1362
1363 case GraphicsExpose:
1364 break;
1365
1366 case ConfigureNotify:
1367 status = xf_event_ConfigureNotify(xfc, &event->xconfigure, xfc->remote_app);
1368 break;
1369
1370 case MapNotify:
1371 status = xf_event_MapNotify(xfc, &event->xmap, xfc->remote_app);
1372 break;
1373
1374 case UnmapNotify:
1375 status = xf_event_UnmapNotify(xfc, &event->xunmap, xfc->remote_app);
1376 break;
1377
1378 case ReparentNotify:
1379 break;
1380
1381 case MappingNotify:
1382 status = xf_event_MappingNotify(xfc, &event->xmapping, xfc->remote_app);
1383 break;
1384
1385 case ClientMessage:
1386 status = xf_event_ClientMessage(xfc, &event->xclient, xfc->remote_app);
1387 break;
1388
1389 case PropertyNotify:
1390 status = xf_event_PropertyNotify(xfc, &event->xproperty, xfc->remote_app);
1391 break;
1392
1393 default:
1394 if (freerdp_settings_get_bool(settings, FreeRDP_SupportDisplayControl))
1395 xf_disp_handle_xevent(xfc, event);
1396
1397 break;
1398 }
1399
1400 xfWindow* window = xfc->window;
1401 xfFloatbar* floatbar = nullptr;
1402 if (window)
1403 floatbar = window->floatbar;
1404
1405 xf_cliprdr_handle_xevent(xfc, event);
1406 if (!xf_floatbar_check_event(floatbar, event) && !xf_floatbar_is_locked(floatbar))
1407 {
1408 if (xf_input_handle_event(xfc, event) < 0)
1409 return FALSE;
1410 }
1411
1412 LogDynAndXSync(xfc->log, xfc->display, FALSE);
1413 return status;
1414}
1415
1416BOOL xf_generic_RawButtonEvent_(xfContext* xfc, int button, BOOL app, BOOL down, const char* file,
1417 const char* fkt, size_t line)
1418{
1419 UINT16 flags = 0;
1420
1421 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
1422 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
1423 "%s: button=%d, app=%d, down=%d", __func__, button, app, down);
1424
1425 if (app || (button < 0))
1426 return FALSE;
1427
1428 for (size_t i = 0; i < ARRAYSIZE(xfc->button_map); i++)
1429 {
1430 const button_map* cur = &xfc->button_map[i];
1431
1432 if (cur->button == (UINT32)button)
1433 {
1434 flags = cur->flags;
1435 break;
1436 }
1437 }
1438
1439 if (flags != 0)
1440 {
1441 if (flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL))
1442 {
1443 if (down)
1444 freerdp_client_send_wheel_event(&xfc->common, flags);
1445 }
1446 else
1447 {
1448 BOOL extended = FALSE;
1449
1450 if (flags & (PTR_XFLAGS_BUTTON1 | PTR_XFLAGS_BUTTON2))
1451 {
1452 extended = TRUE;
1453
1454 if (down)
1455 flags |= PTR_XFLAGS_DOWN;
1456 }
1457 else if (flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3))
1458 {
1459 if (down)
1460 flags |= PTR_FLAGS_DOWN;
1461 }
1462
1463 if (extended)
1464 freerdp_client_send_extended_button_event(&xfc->common, TRUE, flags, 0, 0);
1465 else
1466 freerdp_client_send_button_event(&xfc->common, TRUE, flags, 0, 0);
1467 }
1468 }
1469
1470 return TRUE;
1471}
1472
1473BOOL xf_event_update_screen(freerdp* instance)
1474{
1475 WINPR_ASSERT(instance);
1476
1477 xfContext* xfc = (xfContext*)instance->context;
1478 WINPR_ASSERT(xfc);
1479
1480 if (!xfc->exposeRequested)
1481 return TRUE;
1482 xfc->exposeRequested = false;
1483
1484 if (!xfc->remote_app)
1485 {
1486 if (xfc->common.context.gdi->gfx)
1487 {
1488 xf_OutputExpose(xfc, WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.x),
1489 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.y),
1490 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.w),
1491 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.h));
1492 return TRUE;
1493 }
1494 xf_draw_screen(xfc, xfc->exposedArea.x, xfc->exposedArea.y, xfc->exposedArea.w,
1495 xfc->exposedArea.h);
1496 }
1497 else
1498 {
1499 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, xfc->exposedWindow);
1500 if (appWindow)
1501 xf_UpdateWindowArea(xfc, appWindow, xfc->exposedArea.x, xfc->exposedArea.y,
1502 xfc->exposedArea.w, xfc->exposedArea.h);
1503 xf_rail_return_window(appWindow, FALSE);
1504 }
1505 return TRUE;
1506}
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.
This struct contains function pointer to initialize/free objects.
Definition collections.h:52
OBJECT_FREE_FN fnObjectFree
Definition collections.h:59
WINPR_ATTR_NODISCARD OBJECT_NEW_FN fnObjectNew
Definition collections.h:54