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 {
716 /* A pointer grab belongs to the previously focused RemoteApp window.
717 * Keeping it would route clicks on local foreground windows back to it. */
718 xf_ungrab(xfc);
719 return xf_rail_send_activate(xfc, event->window, FALSE);
720 }
721
722 return TRUE;
723}
724
725static BOOL xf_event_MappingNotify(xfContext* xfc, const XMappingEvent* event, BOOL app)
726{
727 WINPR_UNUSED(app);
728
729 switch (event->request)
730 {
731 case MappingModifier:
732 return xf_keyboard_update_modifier_map(xfc);
733 case MappingKeyboard:
734 WLog_Print(xfc->log, WLOG_TRACE, "[%d] MappingKeyboard", event->request);
735 return xf_keyboard_init(xfc);
736 case MappingPointer:
737 WLog_Print(xfc->log, WLOG_TRACE, "[%d] MappingPointer", event->request);
738 xf_button_map_init(xfc);
739 return TRUE;
740 default:
741 WLog_Print(xfc->log, WLOG_WARN,
742 "[%d] Unsupported MappingNotify::request, must be one "
743 "of[MappingModifier(%d), MappingKeyboard(%d), MappingPointer(%d)]",
744 event->request, MappingModifier, MappingKeyboard, MappingPointer);
745 return FALSE;
746 }
747}
748
749static BOOL xf_event_ClientMessage(xfContext* xfc, const XClientMessageEvent* event, BOOL app)
750{
751 if ((event->message_type == xfc->WM_PROTOCOLS) &&
752 ((Atom)event->data.l[0] == xfc->WM_DELETE_WINDOW))
753 {
754 if (app)
755 {
756 BOOL rc = TRUE;
757 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
758
759 if (appWindow)
760 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_CLOSE);
761 xf_rail_return_window(appWindow, FALSE);
762 return rc;
763 }
764 else
765 {
766 WLog_Print(xfc->log, WLOG_TRACE, "Main window closed");
767 return FALSE;
768 }
769 }
770
771 return TRUE;
772}
773
774static BOOL xf_event_EnterNotify(xfContext* xfc, const XEnterWindowEvent* event, BOOL app)
775{
776 if (!app)
777 {
778 if (!xfc->window)
779 return FALSE;
780
781 xfc->mouse_active = TRUE;
782
783 if (xfc->fullscreen)
784 XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
785
786 if (xfc->focused)
787 xf_grab_kbd(xfc);
788 }
789 else
790 {
791 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
792
793 /* keep track of which window has focus so that we can apply pointer updates */
794 xfc->appWindow = appWindow;
795 xf_rail_return_window(appWindow, FALSE);
796 }
797
798 return TRUE;
799}
800
801static BOOL xf_event_LeaveNotify(xfContext* xfc, const XLeaveWindowEvent* event, BOOL app)
802{
803 if (event->mode == NotifyGrab || event->mode == NotifyUngrab)
804 return TRUE;
805 if (!app)
806 {
807 xfc->mouse_active = FALSE;
808 XUngrabKeyboard(xfc->display, CurrentTime);
809 }
810 else
811 {
812 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
813
814 /* keep track of which window has focus so that we can apply pointer updates */
815 if (xfc->appWindow == appWindow)
816 xfc->appWindow = nullptr;
817 xf_rail_return_window(appWindow, FALSE);
818 }
819 return TRUE;
820}
821
822static BOOL xf_event_ConfigureNotify(xfContext* xfc, const XConfigureEvent* event, BOOL app)
823{
824 Window childWindow = None;
825 xfAppWindow* appWindow = nullptr;
826
827 WINPR_ASSERT(xfc);
828 WINPR_ASSERT(event);
829
830 const rdpSettings* settings = xfc->common.context.settings;
831 WINPR_ASSERT(settings);
832
833 WLog_Print(xfc->log, WLOG_DEBUG, "x=%" PRId32 ", y=%" PRId32 ", w=%" PRId32 ", h=%" PRId32,
834 event->x, event->y, event->width, event->height);
835
836 if (!app)
837 {
838 if (!xfc->window)
839 return FALSE;
840
841 if (xfc->window->left != event->x)
842 xfc->window->left = event->x;
843
844 if (xfc->window->top != event->y)
845 xfc->window->top = event->y;
846
847 if (xfc->window->width != event->width || xfc->window->height != event->height)
848 {
849 xfc->window->width = event->width;
850 xfc->window->height = event->height;
851#ifdef WITH_XRENDER
852 xfc->offset_x = 0;
853 xfc->offset_y = 0;
854
855 if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
856 freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
857 {
858 xfc->scaledWidth = xfc->window->width;
859 xfc->scaledHeight = xfc->window->height;
860 xf_draw_screen(
861 xfc, 0, 0,
862 WINPR_ASSERTING_INT_CAST(
863 int32_t, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth)),
864 WINPR_ASSERTING_INT_CAST(
865 int32_t, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)));
866 }
867 else
868 {
869 xfc->scaledWidth = WINPR_ASSERTING_INT_CAST(
870 int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth));
871 xfc->scaledHeight = WINPR_ASSERTING_INT_CAST(
872 int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
873 }
874
875#endif
876 }
877
878 if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
879 {
880 const int alignedWidth = (xfc->window->width / 2) * 2;
881 const int alignedHeight = (xfc->window->height / 2) * 2;
882 /* ask the server to resize using the display channel */
883 xf_disp_handle_configureNotify(xfc, alignedWidth, alignedHeight);
884 }
885 }
886 else
887 {
888 appWindow = xf_AppWindowFromX11Window(xfc, event->window);
889
890 if (appWindow)
891 {
892 /*
893 * ConfigureNotify coordinates are expressed relative to the window parent.
894 * Translate these to root window coordinates.
895 */
896 XTranslateCoordinates(xfc->display, appWindow->handle, RootWindowOfScreen(xfc->screen),
897 0, 0, &appWindow->x, &appWindow->y, &childWindow);
898 appWindow->width = event->width;
899 appWindow->height = event->height;
900
901 xf_AppWindowResize(xfc, appWindow);
902
903 /*
904 * Additional checks for not in a local move and not ignoring configure to send
905 * position update to server, also should the window not be focused then do not
906 * send to server yet (i.e. resizing using window decoration).
907 * The server will be updated when the window gets refocused.
908 */
909 if (appWindow->decorations)
910 {
911 /* moving resizing using window decoration */
912 xf_rail_adjust_position(xfc, appWindow);
913 }
914 else
915 {
916 if ((!event->send_event || appWindow->local_move.state == LMS_NOT_ACTIVE) &&
917 !appWindow->rail_ignore_configure && xfc->focused)
918 xf_rail_adjust_position(xfc, appWindow);
919 }
920 }
921 xf_rail_return_window(appWindow, FALSE);
922 }
923 return xf_pointer_update_scale(xfc);
924}
925
926static BOOL xf_event_MapNotify(xfContext* xfc, const XMapEvent* event, BOOL app)
927{
928 WINPR_ASSERT(xfc);
929 if (!app)
930 {
931 if (!gdi_send_suppress_output(xfc->common.context.gdi, FALSE))
932 return FALSE;
933 }
934 else
935 {
936 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
937
938 if (appWindow)
939 {
940 /* local restore event */
941 /* This is now handled as part of the PropertyNotify
942 * Doing this here would inhibit the ability to restore a maximized window
943 * that is minimized back to the maximized state
944 */
945 // xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
946 appWindow->is_mapped = TRUE;
947 }
948 xf_rail_return_window(appWindow, FALSE);
949 }
950
951 return TRUE;
952}
953
954static BOOL xf_event_UnmapNotify(xfContext* xfc, const XUnmapEvent* event, BOOL app)
955{
956 WINPR_ASSERT(xfc);
957 WINPR_ASSERT(event);
958
959 if (!app)
960 xf_keyboard_release_all_keypress(xfc);
961
962 if (!app)
963 return gdi_send_suppress_output(xfc->common.context.gdi, TRUE);
964
965 {
966 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
967
968 if (appWindow)
969 appWindow->is_mapped = FALSE;
970 xf_rail_return_window(appWindow, FALSE);
971 }
972
973 return TRUE;
974}
975
976static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, BOOL app)
977{
978 BOOL rc = TRUE;
979 WINPR_ASSERT(xfc);
980 WINPR_ASSERT(event);
981
982 const Window root = DefaultRootWindow(xfc->display);
983 if ((event->window == root) &&
984 ((event->atom == xfc->NET_WORKAREA) || (event->atom == xfc->NET_CURRENT_DESKTOP)))
985 {
986 if (xfc->remote_app && xfc->rail)
987 return xf_rail_schedule_workarea(xfc);
988 }
989
990 /*
991 * This section handles sending the appropriate commands to the rail server
992 * when the window has been minimized, maximized, restored locally
993 * ie. not using the buttons on the rail window itself
994 */
995 if (((event->atom == xfc->NET_WM_STATE) && (event->state != PropertyDelete)) ||
996 ((event->atom == xfc->WM_STATE) && (event->state != PropertyDelete)))
997 {
998 BOOL status = FALSE;
999 BOOL minimized = FALSE;
1000 BOOL minimizedChanged = FALSE;
1001 BOOL fullscreen = FALSE;
1002 unsigned long nitems = 0;
1003 unsigned long bytes = 0;
1004 unsigned char* prop = nullptr;
1005 xfAppWindow* appWindow = nullptr;
1006
1007 if (app)
1008 {
1009 appWindow = xf_AppWindowFromX11Window(xfc, event->window);
1010
1011 if (!appWindow)
1012 goto fail;
1013 }
1014
1015 if (event->atom == xfc->NET_WM_STATE)
1016 {
1017 status = xf_GetWindowProperty(xfc, event->window, xfc->NET_WM_STATE, 12, &nitems,
1018 &bytes, &prop);
1019
1020 if (status)
1021 {
1022 if (appWindow)
1023 {
1024 appWindow->maxVert = FALSE;
1025 appWindow->maxHorz = FALSE;
1026 }
1027 for (unsigned long i = 0; i < nitems; i++)
1028 {
1029 if ((Atom)WINPR_PACKED_ALIGN_CAST(UINT16**, prop)[i] ==
1030 xfc->NET_WM_STATE_FULLSCREEN)
1031 fullscreen = TRUE;
1032 if ((Atom)(WINPR_PACKED_ALIGN_CAST(UINT16**, prop))[i] ==
1033 Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT",
1034 False))
1035 {
1036 if (appWindow)
1037 appWindow->maxVert = TRUE;
1038 }
1039
1040 if ((Atom)(WINPR_PACKED_ALIGN_CAST(UINT16**, prop)[i]) ==
1041 Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ",
1042 False))
1043 {
1044 if (appWindow)
1045 appWindow->maxHorz = TRUE;
1046 }
1047 }
1048
1049 XFree(prop);
1050
1051 if (appWindow && appWindow->rail_fullscreen_normalizing)
1052 {
1053 if (!fullscreen && appWindow->maxVert && appWindow->maxHorz)
1054 {
1055 /* Normal maximized state has been restored. */
1056 appWindow->rail_fullscreen_normalizing = FALSE;
1057 }
1058 else
1059 {
1060 /* Ignore all transient WM states produced while Cinnamon
1061 * transitions from legacy fullscreen back to maximized. */
1062 if (fullscreen)
1063 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1064 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_FULLSCREEN, 0,
1065 0);
1066
1067 if (!appWindow->maxVert || !appWindow->maxHorz)
1068 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1069 NET_WM_STATE_ADD, xfc->NET_WM_STATE_MAXIMIZED_VERT,
1070 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0);
1071
1072 goto fail;
1073 }
1074 }
1075 else if (appWindow && fullscreen &&
1076 (appWindow->rail_state == WINDOW_SHOW_MAXIMIZED))
1077 {
1078 /* Cinnamon/Muffin incorrectly turns the server-driven RAIL
1079 * maximize resize into fullscreen. Normalize this over the
1080 * following PropertyNotify events without feeding transient
1081 * states back to the RAIL server. */
1082 appWindow->rail_fullscreen_normalizing = TRUE;
1083
1084 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1085 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_FULLSCREEN, 0, 0);
1086
1087 if (!appWindow->maxVert || !appWindow->maxHorz)
1088 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1089 NET_WM_STATE_ADD, xfc->NET_WM_STATE_MAXIMIZED_VERT,
1090 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0);
1091
1092 goto fail;
1093 }
1094 }
1095 }
1096
1097 if (event->atom == xfc->WM_STATE)
1098 {
1099 status =
1100 xf_GetWindowProperty(xfc, event->window, xfc->WM_STATE, 1, &nitems, &bytes, &prop);
1101
1102 if (status)
1103 {
1104 /* If the window is in the iconic state */
1105 if (((UINT32)*prop == 3) && !IsGnome())
1106 {
1107 minimized = TRUE;
1108 if (appWindow)
1109 appWindow->minimized = TRUE;
1110 }
1111 else
1112 {
1113 minimized = FALSE;
1114 if (appWindow)
1115 appWindow->minimized = FALSE;
1116 }
1117
1118 minimizedChanged = TRUE;
1119 XFree(prop);
1120 }
1121 }
1122
1123 if (app)
1124 {
1125 WINPR_ASSERT(appWindow);
1126 if (appWindow->maxVert && appWindow->maxHorz && !appWindow->minimized)
1127 {
1128 if (appWindow->rail_state != WINDOW_SHOW_MAXIMIZED)
1129 {
1130 appWindow->rail_state = WINDOW_SHOW_MAXIMIZED;
1131 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MAXIMIZE);
1132 }
1133 }
1134 else if (appWindow->minimized)
1135 {
1136 if (appWindow->rail_state != WINDOW_SHOW_MINIMIZED)
1137 {
1138 appWindow->rail_state = WINDOW_SHOW_MINIMIZED;
1139 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MINIMIZE);
1140 }
1141 }
1142 else
1143 {
1144 if (appWindow->rail_state != WINDOW_SHOW && appWindow->rail_state != WINDOW_HIDE)
1145 {
1146 appWindow->rail_state = WINDOW_SHOW;
1147 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
1148 }
1149 }
1150 }
1151 else if (minimizedChanged)
1152 rc = gdi_send_suppress_output(xfc->common.context.gdi, minimized);
1153
1154 fail:
1155 xf_rail_return_window(appWindow, FALSE);
1156 }
1157
1158 return rc;
1159}
1160
1161static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, const XEvent* event)
1162{
1163 if (!xfc->remote_app)
1164 return FALSE;
1165
1166 switch (appWindow->local_move.state)
1167 {
1168 case LMS_NOT_ACTIVE:
1169
1170 /* No local move in progress, nothing to do */
1171
1172 /* Prevent Configure from happening during indeterminant state of Horz or Vert Max only
1173 */
1174 if ((event->type == ConfigureNotify) && appWindow->rail_ignore_configure)
1175 {
1176 appWindow->rail_ignore_configure = FALSE;
1177 return TRUE;
1178 }
1179
1180 break;
1181
1182 case LMS_STARTING:
1183
1184 /* Local move initiated by RDP server, but we have not yet seen any updates from the X
1185 * server */
1186 switch (event->type)
1187 {
1188 case ConfigureNotify:
1189 /* Starting to see move events from the X server. Local move is now in progress.
1190 */
1191 appWindow->local_move.state = LMS_ACTIVE;
1192 /* Allow these events to be processed during move to keep our state up to date.
1193 */
1194 break;
1195
1196 case ButtonPress:
1197 case ButtonRelease:
1198 case KeyPress:
1199 case KeyRelease:
1200 case UnmapNotify:
1201 /*
1202 * A button release event means the X window server did not grab the
1203 * mouse before the user released it. In this case we must cancel the
1204 * local move. The event will be processed below as normal, below.
1205 */
1206 break;
1207
1208 case VisibilityNotify:
1209 case PropertyNotify:
1210 case Expose:
1211 /* Allow these events to pass */
1212 break;
1213
1214 default:
1215 /* Eat any other events */
1216 return TRUE;
1217 }
1218
1219 break;
1220
1221 case LMS_ACTIVE:
1222
1223 /* Local move is in progress */
1224 switch (event->type)
1225 {
1226 case ConfigureNotify:
1227 case VisibilityNotify:
1228 case PropertyNotify:
1229 case Expose:
1230 case GravityNotify:
1231 /* Keep us up to date on position */
1232 break;
1233
1234 default:
1235 /* Any other event terminates move */
1236 xf_rail_end_local_move(xfc, appWindow);
1237 break;
1238 }
1239
1240 break;
1241
1242 case LMS_TERMINATING:
1243 /* Already sent RDP end move to server. Allow events to pass. */
1244 break;
1245 default:
1246 break;
1247 }
1248
1249 return FALSE;
1250}
1251
1252BOOL xf_event_process(freerdp* instance, const XEvent* event)
1253{
1254 BOOL status = TRUE;
1255
1256 WINPR_ASSERT(instance);
1257 WINPR_ASSERT(event);
1258
1259 xfContext* xfc = (xfContext*)instance->context;
1260 WINPR_ASSERT(xfc);
1261
1262 rdpSettings* settings = xfc->common.context.settings;
1263 WINPR_ASSERT(settings);
1264
1265 if (xfc->remote_app)
1266 {
1267 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
1268
1269 if (appWindow)
1270 {
1271 /* Update "current" window for cursor change orders */
1272 xfc->appWindow = appWindow;
1273
1274 const BOOL rc = xf_event_suppress_events(xfc, appWindow, event);
1275 xf_rail_return_window(appWindow, FALSE);
1276 if (rc)
1277 return TRUE;
1278 }
1279 }
1280
1281 if (xfc->window)
1282 {
1283 xfFloatbar* floatbar = xfc->window->floatbar;
1284 if (xf_floatbar_check_event(floatbar, event))
1285 {
1286 xf_floatbar_event_process(floatbar, event);
1287 return TRUE;
1288 }
1289
1290 if (xf_floatbar_is_locked(floatbar))
1291 {
1292 /* Filter input events, floatbar is locked do not forward anything to the session */
1293 switch (event->type)
1294 {
1295 case MotionNotify:
1296 case ButtonPress:
1297 case ButtonRelease:
1298 case KeyPress:
1299 case KeyRelease:
1300 case FocusIn:
1301 case FocusOut:
1302 case EnterNotify:
1303 case LeaveNotify:
1304 return TRUE;
1305 default:
1306 break;
1307 }
1308 }
1309 }
1310
1311 xf_event_execute_action_script(xfc, event);
1312
1313 if (event->type != MotionNotify)
1314 {
1315 WLog_Print(xfc->log, WLOG_TRACE, "%s Event(%d): wnd=0x%08lX", x11_event_string(event->type),
1316 event->type, (unsigned long)event->xany.window);
1317 }
1318
1319 switch (event->type)
1320 {
1321 case Expose:
1322 status = xf_event_Expose(xfc, &event->xexpose, xfc->remote_app);
1323 break;
1324
1325 case VisibilityNotify:
1326 status = xf_event_VisibilityNotify(xfc, &event->xvisibility, xfc->remote_app);
1327 break;
1328
1329 case MotionNotify:
1330 status = xf_event_MotionNotify(xfc, &event->xmotion, xfc->remote_app);
1331 break;
1332
1333 case ButtonPress:
1334 status = xf_event_ButtonPress(xfc, &event->xbutton, xfc->remote_app);
1335 break;
1336
1337 case ButtonRelease:
1338 status = xf_event_ButtonRelease(xfc, &event->xbutton, xfc->remote_app);
1339 break;
1340
1341 case KeyPress:
1342 status = xf_event_KeyPress(xfc, &event->xkey, xfc->remote_app);
1343 break;
1344
1345 case KeyRelease:
1346 status = xf_event_KeyReleaseOrIgnore(xfc, &event->xkey, xfc->remote_app);
1347 break;
1348
1349 case FocusIn:
1350 status = xf_event_FocusIn(xfc, &event->xfocus, xfc->remote_app);
1351 break;
1352
1353 case FocusOut:
1354 status = xf_event_FocusOut(xfc, &event->xfocus, xfc->remote_app);
1355 break;
1356
1357 case EnterNotify:
1358 status = xf_event_EnterNotify(xfc, &event->xcrossing, xfc->remote_app);
1359 break;
1360
1361 case LeaveNotify:
1362 status = xf_event_LeaveNotify(xfc, &event->xcrossing, xfc->remote_app);
1363 break;
1364
1365 case NoExpose:
1366 break;
1367
1368 case GraphicsExpose:
1369 break;
1370
1371 case ConfigureNotify:
1372 status = xf_event_ConfigureNotify(xfc, &event->xconfigure, xfc->remote_app);
1373 break;
1374
1375 case MapNotify:
1376 status = xf_event_MapNotify(xfc, &event->xmap, xfc->remote_app);
1377 break;
1378
1379 case UnmapNotify:
1380 status = xf_event_UnmapNotify(xfc, &event->xunmap, xfc->remote_app);
1381 break;
1382
1383 case ReparentNotify:
1384 break;
1385
1386 case MappingNotify:
1387 status = xf_event_MappingNotify(xfc, &event->xmapping, xfc->remote_app);
1388 break;
1389
1390 case ClientMessage:
1391 status = xf_event_ClientMessage(xfc, &event->xclient, xfc->remote_app);
1392 break;
1393
1394 case PropertyNotify:
1395 status = xf_event_PropertyNotify(xfc, &event->xproperty, xfc->remote_app);
1396 break;
1397
1398 default:
1399 if (freerdp_settings_get_bool(settings, FreeRDP_SupportDisplayControl))
1400 xf_disp_handle_xevent(xfc, event);
1401
1402 break;
1403 }
1404
1405 xfWindow* window = xfc->window;
1406 xfFloatbar* floatbar = nullptr;
1407 if (window)
1408 floatbar = window->floatbar;
1409
1410 xf_cliprdr_handle_xevent(xfc, event);
1411 if (!xf_floatbar_check_event(floatbar, event) && !xf_floatbar_is_locked(floatbar))
1412 {
1413 if (xf_input_handle_event(xfc, event) < 0)
1414 return FALSE;
1415 }
1416
1417 LogDynAndXSync(xfc->log, xfc->display, FALSE);
1418 return status;
1419}
1420
1421BOOL xf_generic_RawButtonEvent_(xfContext* xfc, int button, BOOL app, BOOL down, const char* file,
1422 const char* fkt, size_t line)
1423{
1424 UINT16 flags = 0;
1425
1426 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
1427 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
1428 "%s: button=%d, app=%d, down=%d", __func__, button, app, down);
1429
1430 if (app || (button < 0))
1431 return FALSE;
1432
1433 for (size_t i = 0; i < ARRAYSIZE(xfc->button_map); i++)
1434 {
1435 const button_map* cur = &xfc->button_map[i];
1436
1437 if (cur->button == (UINT32)button)
1438 {
1439 flags = cur->flags;
1440 break;
1441 }
1442 }
1443
1444 if (flags != 0)
1445 {
1446 if (flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL))
1447 {
1448 if (down)
1449 freerdp_client_send_wheel_event(&xfc->common, flags);
1450 }
1451 else
1452 {
1453 BOOL extended = FALSE;
1454
1455 if (flags & (PTR_XFLAGS_BUTTON1 | PTR_XFLAGS_BUTTON2))
1456 {
1457 extended = TRUE;
1458
1459 if (down)
1460 flags |= PTR_XFLAGS_DOWN;
1461 }
1462 else if (flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3))
1463 {
1464 if (down)
1465 flags |= PTR_FLAGS_DOWN;
1466 }
1467
1468 if (extended)
1469 freerdp_client_send_extended_button_event(&xfc->common, TRUE, flags, 0, 0);
1470 else
1471 freerdp_client_send_button_event(&xfc->common, TRUE, flags, 0, 0);
1472 }
1473 }
1474
1475 return TRUE;
1476}
1477
1478BOOL xf_event_update_screen(freerdp* instance)
1479{
1480 WINPR_ASSERT(instance);
1481
1482 xfContext* xfc = (xfContext*)instance->context;
1483 WINPR_ASSERT(xfc);
1484
1485 if (!xfc->exposeRequested)
1486 return TRUE;
1487 xfc->exposeRequested = false;
1488
1489 if (!xfc->remote_app)
1490 {
1491 if (xfc->common.context.gdi->gfx)
1492 {
1493 xf_OutputExpose(xfc, WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.x),
1494 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.y),
1495 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.w),
1496 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.h));
1497 return TRUE;
1498 }
1499 xf_draw_screen(xfc, xfc->exposedArea.x, xfc->exposedArea.y, xfc->exposedArea.w,
1500 xfc->exposedArea.h);
1501 }
1502 else
1503 {
1504 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, xfc->exposedWindow);
1505 if (appWindow)
1506 xf_UpdateWindowArea(xfc, appWindow, xfc->exposedArea.x, xfc->exposedArea.y,
1507 xfc->exposedArea.w, xfc->exposedArea.h);
1508 xf_rail_return_window(appWindow, FALSE);
1509 }
1510 return TRUE;
1511}
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