21 #include <freerdp/config.h>
23 #include "wlf_pointer.h"
24 #include "wlfreerdp.h"
26 #define TAG CLIENT_TAG("wayland.pointer")
35 static BOOL wlf_Pointer_New(rdpContext* context, rdpPointer* pointer)
37 wlfPointer* ptr = (wlfPointer*)pointer;
42 ptr->size = 4ULL * pointer->width * pointer->height;
43 ptr->data = winpr_aligned_malloc(ptr->size, 16);
48 if (!freerdp_image_copy_from_pointer_data(
49 ptr->data, PIXEL_FORMAT_BGRA32, 0, 0, 0, pointer->width, pointer->height,
50 pointer->xorMaskData, pointer->lengthXorMask, pointer->andMaskData,
51 pointer->lengthAndMask, pointer->xorBpp, &context->gdi->palette))
53 winpr_aligned_free(ptr->data);
60 static void wlf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
62 wlfPointer* ptr = (wlfPointer*)pointer;
63 WINPR_UNUSED(context);
66 winpr_aligned_free(ptr->data);
69 static BOOL wlf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
72 wlfPointer* ptr = (wlfPointer*)pointer;
79 UwacReturnCode rc = UWAC_ERROR_INTERNAL;
83 if (!wlf || !wlf->seat)
91 if (!wlf_scale_coordinates(context, &x, &y, FALSE) ||
92 !wlf_scale_coordinates(context, &w, &h, FALSE))
103 area.right = (UINT16)pointer->width;
104 area.bottom = (UINT16)pointer->height;
106 if (!wlf_copy_image(ptr->data, 4ULL * pointer->width, pointer->width, pointer->height, data,
107 4ULL * w, w, h, &area,
111 rc = UwacSeatSetMouseCursor(wlf->seat, data, size, w, h, x, y);
113 if (rc == UWAC_SUCCESS)
121 static BOOL wlf_Pointer_SetNull(rdpContext* context)
125 if (!wlf || !wlf->seat)
128 if (UwacSeatSetMouseCursor(wlf->seat, NULL, 0, 0, 0, 0, 0) != UWAC_SUCCESS)
134 static BOOL wlf_Pointer_SetDefault(rdpContext* context)
138 if (!wlf || !wlf->seat)
141 if (UwacSeatSetMouseCursor(wlf->seat, NULL, 1, 0, 0, 0, 0) != UWAC_SUCCESS)
147 static BOOL wlf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
150 WLog_WARN(TAG,
"not implemented");
154 BOOL wlf_register_pointer(rdpGraphics* graphics)
156 rdpPointer pointer = { 0 };
158 pointer.size =
sizeof(wlfPointer);
159 pointer.New = wlf_Pointer_New;
160 pointer.Free = wlf_Pointer_Free;
161 pointer.Set = wlf_Pointer_Set;
162 pointer.SetNull = wlf_Pointer_SetNull;
163 pointer.SetDefault = wlf_Pointer_SetDefault;
164 pointer.SetPosition = wlf_Pointer_SetPosition;
165 graphics_register_pointer(graphics, &pointer);
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.