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)((UINT16**)prop)[i] == xfc->NET_WM_STATE_FULLSCREEN)
1025 fullscreen = TRUE;
1026 if ((Atom)((UINT16**)prop)[i] ==
1027 Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT",
1028 False))
1029 {
1030 if (appWindow)
1031 appWindow->maxVert = TRUE;
1032 }
1033
1034 if ((Atom)((UINT16**)prop)[i] ==
1035 Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ",
1036 False))
1037 {
1038 if (appWindow)
1039 appWindow->maxHorz = TRUE;
1040 }
1041 }
1042
1043 XFree(prop);
1044
1045 if (appWindow && appWindow->rail_fullscreen_normalizing)
1046 {
1047 if (!fullscreen && appWindow->maxVert && appWindow->maxHorz)
1048 {
1049 /* Normal maximized state has been restored. */
1050 appWindow->rail_fullscreen_normalizing = FALSE;
1051 }
1052 else
1053 {
1054 /* Ignore all transient WM states produced while Cinnamon
1055 * transitions from legacy fullscreen back to maximized. */
1056 if (fullscreen)
1057 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1058 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_FULLSCREEN, 0,
1059 0);
1060
1061 if (!appWindow->maxVert || !appWindow->maxHorz)
1062 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1063 NET_WM_STATE_ADD, xfc->NET_WM_STATE_MAXIMIZED_VERT,
1064 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0);
1065
1066 goto fail;
1067 }
1068 }
1069 else if (appWindow && fullscreen &&
1070 (appWindow->rail_state == WINDOW_SHOW_MAXIMIZED))
1071 {
1072 /* Cinnamon/Muffin incorrectly turns the server-driven RAIL
1073 * maximize resize into fullscreen. Normalize this over the
1074 * following PropertyNotify events without feeding transient
1075 * states back to the RAIL server. */
1076 appWindow->rail_fullscreen_normalizing = TRUE;
1077
1078 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1079 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_FULLSCREEN, 0, 0);
1080
1081 if (!appWindow->maxVert || !appWindow->maxHorz)
1082 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1083 NET_WM_STATE_ADD, xfc->NET_WM_STATE_MAXIMIZED_VERT,
1084 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0);
1085
1086 goto fail;
1087 }
1088 }
1089 }
1090
1091 if (event->atom == xfc->WM_STATE)
1092 {
1093 status =
1094 xf_GetWindowProperty(xfc, event->window, xfc->WM_STATE, 1, &nitems, &bytes, &prop);
1095
1096 if (status)
1097 {
1098 /* If the window is in the iconic state */
1099 if (((UINT32)*prop == 3) && !IsGnome())
1100 {
1101 minimized = TRUE;
1102 if (appWindow)
1103 appWindow->minimized = TRUE;
1104 }
1105 else
1106 {
1107 minimized = FALSE;
1108 if (appWindow)
1109 appWindow->minimized = FALSE;
1110 }
1111
1112 minimizedChanged = TRUE;
1113 XFree(prop);
1114 }
1115 }
1116
1117 if (app)
1118 {
1119 WINPR_ASSERT(appWindow);
1120 if (appWindow->maxVert && appWindow->maxHorz && !appWindow->minimized)
1121 {
1122 if (appWindow->rail_state != WINDOW_SHOW_MAXIMIZED)
1123 {
1124 appWindow->rail_state = WINDOW_SHOW_MAXIMIZED;
1125 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MAXIMIZE);
1126 }
1127 }
1128 else if (appWindow->minimized)
1129 {
1130 if (appWindow->rail_state != WINDOW_SHOW_MINIMIZED)
1131 {
1132 appWindow->rail_state = WINDOW_SHOW_MINIMIZED;
1133 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MINIMIZE);
1134 }
1135 }
1136 else
1137 {
1138 if (appWindow->rail_state != WINDOW_SHOW && appWindow->rail_state != WINDOW_HIDE)
1139 {
1140 appWindow->rail_state = WINDOW_SHOW;
1141 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
1142 }
1143 }
1144 }
1145 else if (minimizedChanged)
1146 rc = gdi_send_suppress_output(xfc->common.context.gdi, minimized);
1147
1148 fail:
1149 xf_rail_return_window(appWindow, FALSE);
1150 }
1151
1152 return rc;
1153}
1154
1155static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow, const XEvent* event)
1156{
1157 if (!xfc->remote_app)
1158 return FALSE;
1159
1160 switch (appWindow->local_move.state)
1161 {
1162 case LMS_NOT_ACTIVE:
1163
1164 /* No local move in progress, nothing to do */
1165
1166 /* Prevent Configure from happening during indeterminant state of Horz or Vert Max only
1167 */
1168 if ((event->type == ConfigureNotify) && appWindow->rail_ignore_configure)
1169 {
1170 appWindow->rail_ignore_configure = FALSE;
1171 return TRUE;
1172 }
1173
1174 break;
1175
1176 case LMS_STARTING:
1177
1178 /* Local move initiated by RDP server, but we have not yet seen any updates from the X
1179 * server */
1180 switch (event->type)
1181 {
1182 case ConfigureNotify:
1183 /* Starting to see move events from the X server. Local move is now in progress.
1184 */
1185 appWindow->local_move.state = LMS_ACTIVE;
1186 /* Allow these events to be processed during move to keep our state up to date.
1187 */
1188 break;
1189
1190 case ButtonPress:
1191 case ButtonRelease:
1192 case KeyPress:
1193 case KeyRelease:
1194 case UnmapNotify:
1195 /*
1196 * A button release event means the X window server did not grab the
1197 * mouse before the user released it. In this case we must cancel the
1198 * local move. The event will be processed below as normal, below.
1199 */
1200 break;
1201
1202 case VisibilityNotify:
1203 case PropertyNotify:
1204 case Expose:
1205 /* Allow these events to pass */
1206 break;
1207
1208 default:
1209 /* Eat any other events */
1210 return TRUE;
1211 }
1212
1213 break;
1214
1215 case LMS_ACTIVE:
1216
1217 /* Local move is in progress */
1218 switch (event->type)
1219 {
1220 case ConfigureNotify:
1221 case VisibilityNotify:
1222 case PropertyNotify:
1223 case Expose:
1224 case GravityNotify:
1225 /* Keep us up to date on position */
1226 break;
1227
1228 default:
1229 /* Any other event terminates move */
1230 xf_rail_end_local_move(xfc, appWindow);
1231 break;
1232 }
1233
1234 break;
1235
1236 case LMS_TERMINATING:
1237 /* Already sent RDP end move to server. Allow events to pass. */
1238 break;
1239 default:
1240 break;
1241 }
1242
1243 return FALSE;
1244}
1245
1246BOOL xf_event_process(freerdp* instance, const XEvent* event)
1247{
1248 BOOL status = TRUE;
1249
1250 WINPR_ASSERT(instance);
1251 WINPR_ASSERT(event);
1252
1253 xfContext* xfc = (xfContext*)instance->context;
1254 WINPR_ASSERT(xfc);
1255
1256 rdpSettings* settings = xfc->common.context.settings;
1257 WINPR_ASSERT(settings);
1258
1259 if (xfc->remote_app)
1260 {
1261 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
1262
1263 if (appWindow)
1264 {
1265 /* Update "current" window for cursor change orders */
1266 xfc->appWindow = appWindow;
1267
1268 const BOOL rc = xf_event_suppress_events(xfc, appWindow, event);
1269 xf_rail_return_window(appWindow, FALSE);
1270 if (rc)
1271 return TRUE;
1272 }
1273 }
1274
1275 if (xfc->window)
1276 {
1277 xfFloatbar* floatbar = xfc->window->floatbar;
1278 if (xf_floatbar_check_event(floatbar, event))
1279 {
1280 xf_floatbar_event_process(floatbar, event);
1281 return TRUE;
1282 }
1283
1284 if (xf_floatbar_is_locked(floatbar))
1285 {
1286 /* Filter input events, floatbar is locked do not forward anything to the session */
1287 switch (event->type)
1288 {
1289 case MotionNotify:
1290 case ButtonPress:
1291 case ButtonRelease:
1292 case KeyPress:
1293 case KeyRelease:
1294 case FocusIn:
1295 case FocusOut:
1296 case EnterNotify:
1297 case LeaveNotify:
1298 return TRUE;
1299 default:
1300 break;
1301 }
1302 }
1303 }
1304
1305 xf_event_execute_action_script(xfc, event);
1306
1307 if (event->type != MotionNotify)
1308 {
1309 WLog_Print(xfc->log, WLOG_TRACE, "%s Event(%d): wnd=0x%08lX", x11_event_string(event->type),
1310 event->type, (unsigned long)event->xany.window);
1311 }
1312
1313 switch (event->type)
1314 {
1315 case Expose:
1316 status = xf_event_Expose(xfc, &event->xexpose, xfc->remote_app);
1317 break;
1318
1319 case VisibilityNotify:
1320 status = xf_event_VisibilityNotify(xfc, &event->xvisibility, xfc->remote_app);
1321 break;
1322
1323 case MotionNotify:
1324 status = xf_event_MotionNotify(xfc, &event->xmotion, xfc->remote_app);
1325 break;
1326
1327 case ButtonPress:
1328 status = xf_event_ButtonPress(xfc, &event->xbutton, xfc->remote_app);
1329 break;
1330
1331 case ButtonRelease:
1332 status = xf_event_ButtonRelease(xfc, &event->xbutton, xfc->remote_app);
1333 break;
1334
1335 case KeyPress:
1336 status = xf_event_KeyPress(xfc, &event->xkey, xfc->remote_app);
1337 break;
1338
1339 case KeyRelease:
1340 status = xf_event_KeyReleaseOrIgnore(xfc, &event->xkey, xfc->remote_app);
1341 break;
1342
1343 case FocusIn:
1344 status = xf_event_FocusIn(xfc, &event->xfocus, xfc->remote_app);
1345 break;
1346
1347 case FocusOut:
1348 status = xf_event_FocusOut(xfc, &event->xfocus, xfc->remote_app);
1349 break;
1350
1351 case EnterNotify:
1352 status = xf_event_EnterNotify(xfc, &event->xcrossing, xfc->remote_app);
1353 break;
1354
1355 case LeaveNotify:
1356 status = xf_event_LeaveNotify(xfc, &event->xcrossing, xfc->remote_app);
1357 break;
1358
1359 case NoExpose:
1360 break;
1361
1362 case GraphicsExpose:
1363 break;
1364
1365 case ConfigureNotify:
1366 status = xf_event_ConfigureNotify(xfc, &event->xconfigure, xfc->remote_app);
1367 break;
1368
1369 case MapNotify:
1370 status = xf_event_MapNotify(xfc, &event->xmap, xfc->remote_app);
1371 break;
1372
1373 case UnmapNotify:
1374 status = xf_event_UnmapNotify(xfc, &event->xunmap, xfc->remote_app);
1375 break;
1376
1377 case ReparentNotify:
1378 break;
1379
1380 case MappingNotify:
1381 status = xf_event_MappingNotify(xfc, &event->xmapping, xfc->remote_app);
1382 break;
1383
1384 case ClientMessage:
1385 status = xf_event_ClientMessage(xfc, &event->xclient, xfc->remote_app);
1386 break;
1387
1388 case PropertyNotify:
1389 status = xf_event_PropertyNotify(xfc, &event->xproperty, xfc->remote_app);
1390 break;
1391
1392 default:
1393 if (freerdp_settings_get_bool(settings, FreeRDP_SupportDisplayControl))
1394 xf_disp_handle_xevent(xfc, event);
1395
1396 break;
1397 }
1398
1399 xfWindow* window = xfc->window;
1400 xfFloatbar* floatbar = nullptr;
1401 if (window)
1402 floatbar = window->floatbar;
1403
1404 xf_cliprdr_handle_xevent(xfc, event);
1405 if (!xf_floatbar_check_event(floatbar, event) && !xf_floatbar_is_locked(floatbar))
1406 {
1407 if (xf_input_handle_event(xfc, event) < 0)
1408 return FALSE;
1409 }
1410
1411 LogDynAndXSync(xfc->log, xfc->display, FALSE);
1412 return status;
1413}
1414
1415BOOL xf_generic_RawButtonEvent_(xfContext* xfc, int button, BOOL app, BOOL down, const char* file,
1416 const char* fkt, size_t line)
1417{
1418 UINT16 flags = 0;
1419
1420 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
1421 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
1422 "%s: button=%d, app=%d, down=%d", __func__, button, app, down);
1423
1424 if (app || (button < 0))
1425 return FALSE;
1426
1427 for (size_t i = 0; i < ARRAYSIZE(xfc->button_map); i++)
1428 {
1429 const button_map* cur = &xfc->button_map[i];
1430
1431 if (cur->button == (UINT32)button)
1432 {
1433 flags = cur->flags;
1434 break;
1435 }
1436 }
1437
1438 if (flags != 0)
1439 {
1440 if (flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL))
1441 {
1442 if (down)
1443 freerdp_client_send_wheel_event(&xfc->common, flags);
1444 }
1445 else
1446 {
1447 BOOL extended = FALSE;
1448
1449 if (flags & (PTR_XFLAGS_BUTTON1 | PTR_XFLAGS_BUTTON2))
1450 {
1451 extended = TRUE;
1452
1453 if (down)
1454 flags |= PTR_XFLAGS_DOWN;
1455 }
1456 else if (flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3))
1457 {
1458 if (down)
1459 flags |= PTR_FLAGS_DOWN;
1460 }
1461
1462 if (extended)
1463 freerdp_client_send_extended_button_event(&xfc->common, TRUE, flags, 0, 0);
1464 else
1465 freerdp_client_send_button_event(&xfc->common, TRUE, flags, 0, 0);
1466 }
1467 }
1468
1469 return TRUE;
1470}
1471
1472BOOL xf_event_update_screen(freerdp* instance)
1473{
1474 WINPR_ASSERT(instance);
1475
1476 xfContext* xfc = (xfContext*)instance->context;
1477 WINPR_ASSERT(xfc);
1478
1479 if (!xfc->exposeRequested)
1480 return TRUE;
1481 xfc->exposeRequested = false;
1482
1483 if (!xfc->remote_app)
1484 {
1485 if (xfc->common.context.gdi->gfx)
1486 {
1487 xf_OutputExpose(xfc, WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.x),
1488 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.y),
1489 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.w),
1490 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.h));
1491 return TRUE;
1492 }
1493 xf_draw_screen(xfc, xfc->exposedArea.x, xfc->exposedArea.y, xfc->exposedArea.w,
1494 xfc->exposedArea.h);
1495 }
1496 else
1497 {
1498 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, xfc->exposedWindow);
1499 if (appWindow)
1500 xf_UpdateWindowArea(xfc, appWindow, xfc->exposedArea.x, xfc->exposedArea.y,
1501 xfc->exposedArea.w, xfc->exposedArea.h);
1502 xf_rail_return_window(appWindow, FALSE);
1503 }
1504 return TRUE;
1505}
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