21#include <freerdp/config.h>
22#include "xf_reconnect.h"
30#include <winpr/assert.h>
31#include <winpr/path.h>
33#include <freerdp/log.h>
34#include <freerdp/locale/keyboard.h>
38#include "xf_cliprdr.h"
42#include "xf_graphics.h"
48#define CLAMP_COORDINATES(x, y) \
57static const DWORD mouseLogLevel = WLOG_TRACE;
59const char* x11_event_string(
int event)
73 return "ButtonRelease";
76 return "MotionNotify";
91 return "KeymapNotify";
97 return "GraphicsExpose";
102 case VisibilityNotify:
103 return "VisibilityNotify";
106 return "CreateNotify";
109 return "DestroyNotify";
112 return "UnmapNotify";
121 return "ReparentNotify";
123 case ConfigureNotify:
124 return "ConfigureNotify";
126 case ConfigureRequest:
127 return "ConfigureRequest";
130 return "GravityNotify";
133 return "ResizeRequest";
135 case CirculateNotify:
136 return "CirculateNotify";
138 case CirculateRequest:
139 return "CirculateRequest";
142 return "PropertyNotify";
145 return "SelectionClear";
147 case SelectionRequest:
148 return "SelectionRequest";
150 case SelectionNotify:
151 return "SelectionNotify";
154 return "ColormapNotify";
157 return "ClientMessage";
160 return "MappingNotify";
163 return "GenericEvent";
170static BOOL xf_action_script_append(xfContext* xfc,
const char* buffer,
size_t size,
171 WINPR_ATTR_UNUSED
void* user,
const char* what,
const char* arg)
177 if (!buffer || (size == 0))
180 if (!ArrayList_Append(xfc->xevents, buffer))
182 ArrayList_Clear(xfc->xevents);
188BOOL xf_event_action_script_init(xfContext* xfc)
192 xf_event_action_script_free(xfc);
194 char* val = getConfigOption(TRUE,
"isActionScriptAllowed");
197 xfc->isActionScriptAllowed = !val || (_stricmp(val,
"true") == 0);
200 if (!xfc->isActionScriptAllowed)
203 xfc->xevents = ArrayList_New(TRUE);
208 wObject* obj = ArrayList_Object(xfc->xevents);
213 return run_action_script(xfc,
"xevent",
nullptr, xf_action_script_append,
nullptr);
216void xf_event_action_script_free(xfContext* xfc)
220 ArrayList_Free(xfc->xevents);
221 xfc->xevents =
nullptr;
225static BOOL action_script_run(xfContext* xfc,
const char* buffer,
size_t size,
void* user,
226 const char* what,
const char* arg)
229 if (!xfc->isActionScriptAllowed)
239 WLog_Print(xfc->log, WLOG_WARN,
"ActionScript xevent: script did not return data");
243 if (winpr_PathFileExists(buffer))
247 winpr_asprintf(&cmd, &cmdlen,
"%s %s %s", buffer, what, arg);
252 FILE* fp = popen(cmd,
"w");
256 WLog_Print(xfc->log, WLOG_ERROR,
"Failed to execute '%s'", buffer);
260 *pstatus = pclose(fp);
263 WLog_Print(xfc->log, WLOG_ERROR,
"Command '%s' returned %d", buffer, *pstatus);
269 WLog_Print(xfc->log, WLOG_WARN,
"ActionScript xevent: No such file '%s'", buffer);
276static BOOL xf_event_execute_action_script(xfContext* xfc,
const XEvent* event)
279 char* name =
nullptr;
281 const char* xeventName =
nullptr;
283 if (!xfc->actionScriptExists || !xfc->xevents || !xfc->window)
286 if (event->type > LASTEvent)
289 xeventName = x11_event_string(event->type);
290 count = ArrayList_Count(xfc->xevents);
292 for (
size_t index = 0; index < count; index++)
294 name = (
char*)ArrayList_GetItem(xfc->xevents, index);
296 if (_stricmp(name, xeventName) == 0)
306 char command[2048] = WINPR_C_ARRAY_INIT;
307 char arg[2048] = WINPR_C_ARRAY_INIT;
308 (void)_snprintf(command,
sizeof(command),
"xevent %s", xeventName);
309 (void)_snprintf(arg,
sizeof(arg),
"%lu", (
unsigned long)xfc->window->handle);
310 return run_action_script(xfc, command, arg, action_script_run,
nullptr);
313void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y)
315 if (!xfc || !xfc->common.context.settings || !y || !x)
318 rdpSettings* settings = xfc->common.context.settings;
321 if (!xfc->remote_app)
325 if (xf_picture_transform_required(xfc))
329 double xScalingFactor = xfc->scaledWidth / dw;
330 double yScalingFactor = xfc->scaledHeight / dh;
331 tx = (INT64)lround((1.0 * (*x) + xfc->offset_x) * xScalingFactor);
332 ty = (INT64)lround((1.0 * (*y) + xfc->offset_y) * yScalingFactor);
338 CLAMP_COORDINATES(tx, ty);
343void xf_event_adjust_coordinates(xfContext* xfc,
int* x,
int* y)
345 if (!xfc || !xfc->common.context.settings || !y || !x)
348 if (!xfc->remote_app)
351 rdpSettings* settings = xfc->common.context.settings;
352 if (xf_picture_transform_required(xfc))
355 (double)xfc->scaledWidth;
357 (double)xfc->scaledHeight;
358 *x = (int)((*x - xfc->offset_x) * xScalingFactor);
359 *y = (int)((*y - xfc->offset_y) * yScalingFactor);
365 CLAMP_COORDINATES(*x, *y);
368static BOOL xf_event_Expose(xfContext* xfc,
const XExposeEvent* event, BOOL app)
373 rdpSettings* settings = xfc->common.context.settings;
374 WINPR_ASSERT(settings);
379 xfc->exposedArea.x = 0;
380 xfc->exposedArea.y = 0;
381 xfc->exposedArea.w = WINPR_ASSERTING_INT_CAST(
383 xfc->exposedArea.h = WINPR_ASSERTING_INT_CAST(
388 xfc->exposedArea.x =
event->x;
389 xfc->exposedArea.y =
event->y;
390 xfc->exposedArea.w =
event->width;
391 xfc->exposedArea.h =
event->height;
394 xfc->exposedWindow =
event->window;
395 xfc->exposeRequested =
true;
400static BOOL xf_event_VisibilityNotify(xfContext* xfc,
const XVisibilityEvent* event, BOOL app)
403 xfc->unobscured =
event->state == VisibilityUnobscured;
407BOOL xf_generic_MotionNotify_(xfContext* xfc,
int x,
int y, Window window, BOOL app,
408 const char* file,
const char* fkt,
size_t line)
410 Window childWindow = None;
412 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
413 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
414 "%s: x=%d, y=%d, window=0x%08lx, app=%d", __func__, x, y, window,
418 WINPR_ASSERT(xfc->common.context.settings);
423 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, window);
424 xf_rail_return_window(appWindow, FALSE);
429 XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y, &x, &y,
433 xf_event_adjust_coordinates(xfc, &x, &y);
434 freerdp_client_send_button_event(&xfc->common, FALSE, PTR_FLAGS_MOVE, x, y);
436 if (xfc->fullscreen && !app)
439 XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
445BOOL xf_generic_RawMotionNotify_(xfContext* xfc,
int x,
int y, WINPR_ATTR_UNUSED Window window,
446 BOOL app,
const char* file,
const char* fkt,
size_t line)
450 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
451 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
452 "%s: x=%d, y=%d, window=0x%08lx, app=%d", __func__, x, y, window,
457 WLog_Print(xfc->log, WLOG_ERROR,
458 "Relative mouse input is not supported with remoate app mode!");
462 return freerdp_client_send_button_event(&xfc->common, TRUE, PTR_FLAGS_MOVE, x, y);
465static BOOL xf_event_MotionNotify(xfContext* xfc,
const XMotionEvent* event, BOOL app)
470 xf_floatbar_set_root_y(xfc->window->floatbar, event->y);
472 if (xfc->xi_event || xfc->xi_rawevent || (xfc->common.mouse_grabbed && xf_use_rel_mouse(xfc)))
475 return xf_generic_MotionNotify(xfc, event->x, event->y, event->window, app);
478BOOL xf_generic_ButtonEvent_(xfContext* xfc,
int x,
int y,
int button, Window window, BOOL app,
479 BOOL down,
const char* file,
const char* fkt,
size_t line)
482 Window childWindow = None;
484 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
485 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
486 "%s: x=%d, y=%d, button=%d, window=0x%08lx, app=%d, down=%d",
487 __func__, x, y, button, window, app, down);
493 for (
size_t i = 0; i < ARRAYSIZE(xfc->button_map); i++)
497 if (cur->button == (UINT32)button)
506 if (flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL))
509 freerdp_client_send_wheel_event(&xfc->common, flags);
513 BOOL extended = FALSE;
515 if (flags & (PTR_XFLAGS_BUTTON1 | PTR_XFLAGS_BUTTON2))
520 flags |= PTR_XFLAGS_DOWN;
522 else if (flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3))
525 flags |= PTR_FLAGS_DOWN;
531 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, window);
532 xf_rail_return_window(appWindow, FALSE);
537 XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y,
538 &x, &y, &childWindow);
541 xf_event_adjust_coordinates(xfc, &x, &y);
544 freerdp_client_send_extended_button_event(&xfc->common, FALSE, flags, x, y);
546 freerdp_client_send_button_event(&xfc->common, FALSE, flags, x, y);
553static BOOL xf_grab_mouse(xfContext* xfc)
562 XGrabPointer(xfc->display, xfc->window->handle, False,
563 ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask |
564 EnterWindowMask | LeaveWindowMask,
565 GrabModeAsync, GrabModeAsync, xfc->window->handle, None, CurrentTime);
566 xfc->common.mouse_grabbed = TRUE;
571static BOOL xf_grab_kbd(xfContext* xfc)
578 XGrabKeyboard(xfc->display, xfc->window->handle, TRUE, GrabModeAsync, GrabModeAsync,
583static BOOL xf_event_ButtonPress(xfContext* xfc,
const XButtonEvent* event, BOOL app)
587 if (xfc->xi_event || xfc->xi_rawevent || (xfc->common.mouse_grabbed && xf_use_rel_mouse(xfc)))
589 if (!app && xfc_is_floatbar_window(xfc, event->window))
591 return xf_generic_ButtonEvent(xfc, event->x, event->y,
592 WINPR_ASSERTING_INT_CAST(
int, event->button), event->window, app,
596static BOOL xf_event_ButtonRelease(xfContext* xfc,
const XButtonEvent* event, BOOL app)
600 if (xfc->xi_event || xfc->xi_rawevent || (xfc->common.mouse_grabbed && xf_use_rel_mouse(xfc)))
602 return xf_generic_ButtonEvent(xfc, event->x, event->y,
603 WINPR_ASSERTING_INT_CAST(
int, event->button), event->window, app,
607static BOOL xf_event_KeyPress(xfContext* xfc,
const XKeyEvent* event, BOOL app)
610 char str[256] = WINPR_C_ARRAY_INIT;
613 const XKeyEvent* cev;
618 XLookupString(cnv.ev, str,
sizeof(str), &keysym,
nullptr);
619 xf_keyboard_key_press(xfc, event, keysym);
623static BOOL xf_event_KeyRelease(xfContext* xfc,
const XKeyEvent* event, BOOL app)
626 char str[256] = WINPR_C_ARRAY_INIT;
629 const XKeyEvent* cev;
635 XLookupString(cnv.ev, str,
sizeof(str), &keysym,
nullptr);
636 xf_keyboard_key_release(xfc, event, keysym);
642static BOOL xf_event_KeyReleaseOrIgnore(xfContext* xfc,
const XKeyEvent* event, BOOL app)
647 if ((event->type == KeyRelease) && XEventsQueued(xfc->display, QueuedAfterReading))
649 XEvent nev = WINPR_C_ARRAY_INIT;
650 XPeekEvent(xfc->display, &nev);
652 if ((nev.type == KeyPress) && (nev.xkey.time == event->time) &&
653 (nev.xkey.keycode == event->keycode))
660 return xf_event_KeyRelease(xfc, event, app);
663static BOOL xf_event_FocusIn(xfContext* xfc,
const XFocusInEvent* event, BOOL app)
665 if (event->mode == NotifyGrab)
670 if (xfc->mouse_active && !app)
673 if (!xf_grab_kbd(xfc))
680 xf_keyboard_release_all_keypress(xfc);
694 xf_pointer_update_scale(xfc);
698 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
703 xf_rail_adjust_position(xfc, appWindow);
704 xf_rail_return_window(appWindow, FALSE);
707 xf_keyboard_focus_in(xfc);
711static BOOL xf_event_FocusOut(xfContext* xfc,
const XFocusOutEvent* event, BOOL app)
713 if (event->mode == NotifyUngrab)
716 xfc->focused = FALSE;
718 if (event->mode == NotifyWhileGrabbed)
719 XUngrabKeyboard(xfc->display, CurrentTime);
721 xf_keyboard_release_all_keypress(xfc);
735static BOOL xf_event_MappingNotify(xfContext* xfc,
const XMappingEvent* event, BOOL app)
739 switch (event->request)
741 case MappingModifier:
742 return xf_keyboard_update_modifier_map(xfc);
743 case MappingKeyboard:
744 WLog_Print(xfc->log, WLOG_TRACE,
"[%d] MappingKeyboard", event->request);
745 return xf_keyboard_init(xfc);
747 WLog_Print(xfc->log, WLOG_TRACE,
"[%d] MappingPointer", event->request);
748 xf_button_map_init(xfc);
751 WLog_Print(xfc->log, WLOG_WARN,
752 "[%d] Unsupported MappingNotify::request, must be one "
753 "of[MappingModifier(%d), MappingKeyboard(%d), MappingPointer(%d)]",
754 event->request, MappingModifier, MappingKeyboard, MappingPointer);
759static BOOL xf_event_ClientMessage(xfContext* xfc,
const XClientMessageEvent* event, BOOL app)
761 if ((event->message_type == xfc->WM_PROTOCOLS) &&
762 ((Atom)event->data.l[0] == xfc->WM_DELETE_WINDOW))
767 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
770 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_CLOSE);
771 xf_rail_return_window(appWindow, FALSE);
776 WLog_Print(xfc->log, WLOG_TRACE,
"Main window closed");
784static BOOL xf_event_EnterNotify(xfContext* xfc,
const XEnterWindowEvent* event, BOOL app)
791 xfc->mouse_active = TRUE;
794 XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
801 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
804 xfc->appWindow = appWindow;
805 xf_rail_return_window(appWindow, FALSE);
811static BOOL xf_event_LeaveNotify(xfContext* xfc,
const XLeaveWindowEvent* event, BOOL app)
813 if (event->mode == NotifyGrab || event->mode == NotifyUngrab)
817 xfc->mouse_active = FALSE;
818 XUngrabKeyboard(xfc->display, CurrentTime);
822 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
825 if (xfc->appWindow == appWindow)
826 xfc->appWindow =
nullptr;
827 xf_rail_return_window(appWindow, FALSE);
832static BOOL xf_event_ConfigureNotify(xfContext* xfc,
const XConfigureEvent* event, BOOL app)
834 Window childWindow = None;
835 xfAppWindow* appWindow =
nullptr;
840 const rdpSettings* settings = xfc->common.context.settings;
841 WINPR_ASSERT(settings);
843 WLog_Print(xfc->log, WLOG_DEBUG,
"x=%" PRId32
", y=%" PRId32
", w=%" PRId32
", h=%" PRId32,
844 event->x, event->y, event->width, event->height);
851 if (xfc->window->left != event->x)
852 xfc->window->left =
event->x;
854 if (xfc->window->top != event->y)
855 xfc->window->top =
event->y;
857 if (xfc->window->width != event->width || xfc->window->height != event->height)
859 xfc->window->width =
event->width;
860 xfc->window->height =
event->height;
868 xfc->scaledWidth = xfc->window->width;
869 xfc->scaledHeight = xfc->window->height;
872 WINPR_ASSERTING_INT_CAST(
874 WINPR_ASSERTING_INT_CAST(
879 xfc->scaledWidth = WINPR_ASSERTING_INT_CAST(
881 xfc->scaledHeight = WINPR_ASSERTING_INT_CAST(
890 const int alignedWidth = (xfc->window->width / 2) * 2;
891 const int alignedHeight = (xfc->window->height / 2) * 2;
893 xf_disp_handle_configureNotify(xfc, alignedWidth, alignedHeight);
898 appWindow = xf_AppWindowFromX11Window(xfc, event->window);
906 XTranslateCoordinates(xfc->display, appWindow->handle, RootWindowOfScreen(xfc->screen),
907 0, 0, &appWindow->x, &appWindow->y, &childWindow);
908 appWindow->width =
event->width;
909 appWindow->height =
event->height;
911 xf_AppWindowResize(xfc, appWindow);
919 if (appWindow->decorations)
922 xf_rail_adjust_position(xfc, appWindow);
926 if ((!event->send_event || appWindow->local_move.state == LMS_NOT_ACTIVE) &&
927 !appWindow->rail_ignore_configure && xfc->focused)
928 xf_rail_adjust_position(xfc, appWindow);
931 xf_rail_return_window(appWindow, FALSE);
933 return xf_pointer_update_scale(xfc);
936static BOOL xf_event_MapNotify(xfContext* xfc,
const XMapEvent* event, BOOL app)
941 if (!gdi_send_suppress_output(xfc->common.context.gdi, FALSE))
946 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
956 appWindow->is_mapped = TRUE;
957 if (appWindow->surfaceStale)
959 const UINT64 windowId = appWindow->windowId;
960 const UINT32 surfaceId = appWindow->surfaceId;
961 xf_rail_return_window(appWindow, FALSE);
962 return xf_AppWindowRepaintFromSurface(xfc, windowId, surfaceId);
965 xf_rail_return_window(appWindow, FALSE);
971static BOOL xf_event_UnmapNotify(xfContext* xfc,
const XUnmapEvent* event, BOOL app)
977 xf_keyboard_release_all_keypress(xfc);
980 return gdi_send_suppress_output(xfc->common.context.gdi, TRUE);
983 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->window);
986 appWindow->is_mapped = FALSE;
987 xf_rail_return_window(appWindow, FALSE);
993static BOOL xf_event_PropertyNotify(xfContext* xfc,
const XPropertyEvent* event, BOOL app)
999 const Window root = DefaultRootWindow(xfc->display);
1000 if ((event->window == root) &&
1001 ((event->atom == xfc->NET_WORKAREA) || (event->atom == xfc->NET_CURRENT_DESKTOP)))
1003 if (xfc->remote_app && xfc->rail)
1004 return xf_rail_schedule_workarea(xfc);
1012 if (((event->atom == xfc->NET_WM_STATE) && (event->state != PropertyDelete)) ||
1013 ((event->atom == xfc->WM_STATE) && (event->state != PropertyDelete)))
1015 BOOL status = FALSE;
1016 BOOL minimized = FALSE;
1017 BOOL minimizedChanged = FALSE;
1018 BOOL fullscreen = FALSE;
1019 unsigned long nitems = 0;
1020 unsigned long bytes = 0;
1021 unsigned char* prop =
nullptr;
1022 xfAppWindow* appWindow =
nullptr;
1026 appWindow = xf_AppWindowFromX11Window(xfc, event->window);
1032 if (event->atom == xfc->NET_WM_STATE)
1034 status = xf_GetWindowProperty(xfc, event->window, xfc->NET_WM_STATE, 12, &nitems,
1041 appWindow->maxVert = FALSE;
1042 appWindow->maxHorz = FALSE;
1044 for (
unsigned long i = 0; i < nitems; i++)
1046 if ((Atom)WINPR_PACKED_ALIGN_CAST(UINT16**, prop)[i] ==
1047 xfc->NET_WM_STATE_FULLSCREEN)
1049 if ((Atom)(WINPR_PACKED_ALIGN_CAST(UINT16**, prop))[i] ==
1050 Logging_XInternAtom(xfc->log, xfc->display,
"_NET_WM_STATE_MAXIMIZED_VERT",
1054 appWindow->maxVert = TRUE;
1057 if ((Atom)(WINPR_PACKED_ALIGN_CAST(UINT16**, prop)[i]) ==
1058 Logging_XInternAtom(xfc->log, xfc->display,
"_NET_WM_STATE_MAXIMIZED_HORZ",
1062 appWindow->maxHorz = TRUE;
1068 if (appWindow && appWindow->rail_fullscreen_normalizing)
1070 if (!fullscreen && appWindow->maxVert && appWindow->maxHorz)
1073 appWindow->rail_fullscreen_normalizing = FALSE;
1080 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1081 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_FULLSCREEN, 0,
1084 if (!appWindow->maxVert || !appWindow->maxHorz)
1085 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1086 NET_WM_STATE_ADD, xfc->NET_WM_STATE_MAXIMIZED_VERT,
1087 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0);
1092 else if (appWindow && fullscreen &&
1093 (appWindow->rail_state == WINDOW_SHOW_MAXIMIZED))
1099 appWindow->rail_fullscreen_normalizing = TRUE;
1101 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1102 NET_WM_STATE_REMOVE, xfc->NET_WM_STATE_FULLSCREEN, 0, 0);
1104 if (!appWindow->maxVert || !appWindow->maxHorz)
1105 xf_SendClientEvent(xfc, appWindow->handle, xfc->NET_WM_STATE, 4,
1106 NET_WM_STATE_ADD, xfc->NET_WM_STATE_MAXIMIZED_VERT,
1107 xfc->NET_WM_STATE_MAXIMIZED_HORZ, 0);
1114 if (event->atom == xfc->WM_STATE)
1117 xf_GetWindowProperty(xfc, event->window, xfc->WM_STATE, 1, &nitems, &bytes, &prop);
1122 if (((UINT32)*prop == 3) && !IsGnome())
1126 appWindow->minimized = TRUE;
1132 appWindow->minimized = FALSE;
1135 minimizedChanged = TRUE;
1142 WINPR_ASSERT(appWindow);
1143 if (appWindow->maxVert && appWindow->maxHorz && !appWindow->minimized)
1145 if (appWindow->rail_state != WINDOW_SHOW_MAXIMIZED)
1147 appWindow->rail_state = WINDOW_SHOW_MAXIMIZED;
1148 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MAXIMIZE);
1151 else if (appWindow->minimized)
1153 if (appWindow->rail_state != WINDOW_SHOW_MINIMIZED)
1155 appWindow->rail_state = WINDOW_SHOW_MINIMIZED;
1156 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_MINIMIZE);
1161 if (appWindow->rail_state != WINDOW_SHOW && appWindow->rail_state != WINDOW_HIDE)
1163 appWindow->rail_state = WINDOW_SHOW;
1164 rc = xf_rail_send_client_system_command(xfc, appWindow->windowId, SC_RESTORE);
1168 else if (minimizedChanged)
1169 rc = gdi_send_suppress_output(xfc->common.context.gdi, minimized);
1172 xf_rail_return_window(appWindow, FALSE);
1178static BOOL xf_event_suppress_events(xfContext* xfc, xfAppWindow* appWindow,
const XEvent* event)
1180 if (!xfc->remote_app)
1183 switch (appWindow->local_move.state)
1185 case LMS_NOT_ACTIVE:
1191 if ((event->type == ConfigureNotify) && appWindow->rail_ignore_configure)
1193 appWindow->rail_ignore_configure = FALSE;
1203 switch (event->type)
1205 case ConfigureNotify:
1208 appWindow->local_move.state = LMS_ACTIVE;
1225 case VisibilityNotify:
1226 case PropertyNotify:
1241 switch (event->type)
1243 case ConfigureNotify:
1244 case VisibilityNotify:
1245 case PropertyNotify:
1253 xf_rail_end_local_move(xfc, appWindow);
1259 case LMS_TERMINATING:
1269BOOL xf_event_process(freerdp* instance,
const XEvent* event)
1273 WINPR_ASSERT(instance);
1274 WINPR_ASSERT(event);
1276 xfContext* xfc = (xfContext*)instance->context;
1278 if (!xf_reconnect_event(xfc, event))
1281 rdpSettings* settings = xfc->common.context.settings;
1282 WINPR_ASSERT(settings);
1284 if (xfc->remote_app)
1286 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, event->xany.window);
1291 xfc->appWindow = appWindow;
1293 const BOOL rc = xf_event_suppress_events(xfc, appWindow, event);
1294 xf_rail_return_window(appWindow, FALSE);
1302 xfFloatbar* floatbar = xfc->window->floatbar;
1303 if (xf_floatbar_check_event(floatbar, event))
1305 xf_floatbar_event_process(floatbar, event);
1309 if (xf_floatbar_is_locked(floatbar))
1312 switch (event->type)
1330 xf_event_execute_action_script(xfc, event);
1332 if (event->type != MotionNotify)
1334 WLog_Print(xfc->log, WLOG_TRACE,
"%s Event(%d): wnd=0x%08lX", x11_event_string(event->type),
1335 event->type, (
unsigned long)event->xany.window);
1338 switch (event->type)
1341 status = xf_event_Expose(xfc, &event->xexpose, xfc->remote_app);
1344 case VisibilityNotify:
1345 status = xf_event_VisibilityNotify(xfc, &event->xvisibility, xfc->remote_app);
1349 status = xf_event_MotionNotify(xfc, &event->xmotion, xfc->remote_app);
1353 status = xf_event_ButtonPress(xfc, &event->xbutton, xfc->remote_app);
1357 status = xf_event_ButtonRelease(xfc, &event->xbutton, xfc->remote_app);
1361 status = xf_event_KeyPress(xfc, &event->xkey, xfc->remote_app);
1365 status = xf_event_KeyReleaseOrIgnore(xfc, &event->xkey, xfc->remote_app);
1369 status = xf_event_FocusIn(xfc, &event->xfocus, xfc->remote_app);
1373 status = xf_event_FocusOut(xfc, &event->xfocus, xfc->remote_app);
1377 status = xf_event_EnterNotify(xfc, &event->xcrossing, xfc->remote_app);
1381 status = xf_event_LeaveNotify(xfc, &event->xcrossing, xfc->remote_app);
1387 case GraphicsExpose:
1390 case ConfigureNotify:
1391 status = xf_event_ConfigureNotify(xfc, &event->xconfigure, xfc->remote_app);
1395 status = xf_event_MapNotify(xfc, &event->xmap, xfc->remote_app);
1399 status = xf_event_UnmapNotify(xfc, &event->xunmap, xfc->remote_app);
1402 case ReparentNotify:
1406 status = xf_event_MappingNotify(xfc, &event->xmapping, xfc->remote_app);
1410 status = xf_event_ClientMessage(xfc, &event->xclient, xfc->remote_app);
1413 case PropertyNotify:
1414 status = xf_event_PropertyNotify(xfc, &event->xproperty, xfc->remote_app);
1419 xf_disp_handle_xevent(xfc, event);
1424 xfWindow* window = xfc->window;
1425 xfFloatbar* floatbar =
nullptr;
1427 floatbar = window->floatbar;
1429 xf_cliprdr_handle_xevent(xfc, event);
1430 if (!xf_floatbar_check_event(floatbar, event) && !xf_floatbar_is_locked(floatbar))
1432 if (xf_input_handle_event(xfc, event) < 0)
1436 LogDynAndXSync(xfc->log, xfc->display, FALSE);
1440BOOL xf_generic_RawButtonEvent_(xfContext* xfc,
int button, BOOL app, BOOL down,
const char* file,
1441 const char* fkt,
size_t line)
1445 if (WLog_IsLevelActive(xfc->log, mouseLogLevel))
1446 WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt,
1447 "%s: button=%d, app=%d, down=%d", __func__, button, app, down);
1449 if (app || (button < 0))
1452 for (
size_t i = 0; i < ARRAYSIZE(xfc->button_map); i++)
1456 if (cur->button == (UINT32)button)
1465 if (flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL))
1468 freerdp_client_send_wheel_event(&xfc->common, flags);
1472 BOOL extended = FALSE;
1474 if (flags & (PTR_XFLAGS_BUTTON1 | PTR_XFLAGS_BUTTON2))
1479 flags |= PTR_XFLAGS_DOWN;
1481 else if (flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3))
1484 flags |= PTR_FLAGS_DOWN;
1488 freerdp_client_send_extended_button_event(&xfc->common, TRUE, flags, 0, 0);
1490 freerdp_client_send_button_event(&xfc->common, TRUE, flags, 0, 0);
1497BOOL xf_event_update_screen(freerdp* instance)
1499 WINPR_ASSERT(instance);
1501 xfContext* xfc = (xfContext*)instance->context;
1504 if (!xfc->exposeRequested)
1506 xfc->exposeRequested =
false;
1508 if (!xfc->remote_app)
1510 if (xfc->common.context.gdi->gfx)
1512 xf_OutputExpose(xfc, WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.x),
1513 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.y),
1514 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.w),
1515 WINPR_ASSERTING_INT_CAST(uint32_t, xfc->exposedArea.h));
1518 xf_draw_screen(xfc, xfc->exposedArea.x, xfc->exposedArea.y, xfc->exposedArea.w,
1519 xfc->exposedArea.h);
1523 xfAppWindow* appWindow = xf_AppWindowFromX11Window(xfc, xfc->exposedWindow);
1525 xf_UpdateWindowArea(xfc, appWindow, xfc->exposedArea.x, xfc->exposedArea.y,
1526 xfc->exposedArea.w, xfc->exposedArea.h);
1527 xf_rail_return_window(appWindow, FALSE);
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.
OBJECT_FREE_FN fnObjectFree
WINPR_ATTR_NODISCARD OBJECT_NEW_FN fnObjectNew