mirror of https://github.com/FreeRDP/FreeRDP
Merge pull request #5251 from akallabeth/wayland_cursor_handling_fix
Moved wayland cursor handling to seat.
This commit is contained in:
commit
cfbf22348e
|
@ -132,8 +132,8 @@ static const struct zwp_fullscreen_shell_v1_listener fullscreen_shell_listener =
|
|||
|
||||
static void display_destroy_seat(UwacDisplay* d, uint32_t name)
|
||||
{
|
||||
UwacSeat* seat;
|
||||
wl_list_for_each(seat, &d->seats, link)
|
||||
UwacSeat* seat, *tmp;
|
||||
wl_list_for_each_safe(seat, tmp, &d->seats, link)
|
||||
{
|
||||
if (seat->seat_id == name)
|
||||
{
|
||||
|
@ -180,18 +180,6 @@ static void registry_handle_global(void* data, struct wl_registry* registry, uin
|
|||
{
|
||||
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, min(TARGET_SHM_INTERFACE, version));
|
||||
wl_shm_add_listener(d->shm, &shm_listener, d);
|
||||
|
||||
d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm);
|
||||
if (!d->cursor_theme) {
|
||||
assert(uwacErrorHandler(d, UWAC_ERROR_NOMEMORY, "unable to get wayland cursor theme\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
d->default_cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
|
||||
if (!d->default_cursor) {
|
||||
assert(uwacErrorHandler(d, UWAC_ERROR_NOMEMORY, "unable to get wayland cursor left_ptr\n"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (strcmp(interface, "wl_output") == 0)
|
||||
{
|
||||
|
@ -237,12 +225,12 @@ static void registry_handle_global(void* data, struct wl_registry* registry, uin
|
|||
}
|
||||
else if (strcmp(interface, "wl_data_device_manager") == 0)
|
||||
{
|
||||
UwacSeat* seat;
|
||||
UwacSeat* seat, *tmp;
|
||||
|
||||
d->data_device_manager = wl_registry_bind(registry, id, &wl_data_device_manager_interface,
|
||||
min(TARGET_DDM_INTERFACE, version));
|
||||
|
||||
wl_list_for_each(seat, &d->seats, link)
|
||||
wl_list_for_each_safe(seat, tmp, &d->seats, link)
|
||||
{
|
||||
UwacSeatRegisterDDM(seat);
|
||||
UwacSeatRegisterClipboard(seat);
|
||||
|
@ -596,9 +584,6 @@ UwacReturnCode UwacCloseDisplay(UwacDisplay** pdisplay)
|
|||
if (display->shell)
|
||||
wl_shell_destroy(display->shell);
|
||||
|
||||
if (display->cursor_theme)
|
||||
wl_cursor_theme_destroy(display->cursor_theme);
|
||||
|
||||
if (display->shm)
|
||||
wl_shm_destroy(display->shm);
|
||||
|
||||
|
@ -656,12 +641,12 @@ const char* UwacErrorString(UwacReturnCode error)
|
|||
UwacReturnCode UwacDisplayQueryInterfaceVersion(const UwacDisplay* display, const char* name,
|
||||
uint32_t* version)
|
||||
{
|
||||
const UwacGlobal* global;
|
||||
const UwacGlobal* global, *tmp;
|
||||
|
||||
if (!display)
|
||||
return UWAC_ERROR_INVALID_DISPLAY;
|
||||
|
||||
wl_list_for_each(global, &display->globals, link)
|
||||
wl_list_for_each_safe(global, tmp, &display->globals, link)
|
||||
{
|
||||
if (strcmp(global->interface, name) == 0)
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ set_cursor_image(UwacSeat* seat, uint32_t serial)
|
|||
struct wl_surface* surface = NULL;
|
||||
int32_t x = 0, y = 0;
|
||||
|
||||
if (!seat || !seat->display || !seat->display->default_cursor || !seat->display->default_cursor->images)
|
||||
if (!seat || !seat->display || !seat->default_cursor || !seat->default_cursor->images)
|
||||
return UWAC_ERROR_INTERNAL;
|
||||
|
||||
switch(seat->pointer_type) {
|
||||
|
@ -113,7 +113,7 @@ set_cursor_image(UwacSeat* seat, uint32_t serial)
|
|||
case 1: /* NULL pointer */
|
||||
break;
|
||||
default: /* Default system pointer */
|
||||
cursor = seat->display->default_cursor;
|
||||
cursor = seat->default_cursor;
|
||||
if (!cursor)
|
||||
return UWAC_ERROR_INTERNAL;
|
||||
image = cursor->images[0];
|
||||
|
@ -839,6 +839,19 @@ static void seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_s
|
|||
input->pointer = wl_seat_get_pointer(seat);
|
||||
wl_pointer_set_user_data(input->pointer, input);
|
||||
wl_pointer_add_listener(input->pointer, &pointer_listener, input);
|
||||
|
||||
input->cursor_theme = wl_cursor_theme_load(NULL, 32, input->display->shm);
|
||||
if (!input->cursor_theme) {
|
||||
assert(uwacErrorHandler(input->display, UWAC_ERROR_NOMEMORY, "unable to get wayland cursor theme\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
input->default_cursor = wl_cursor_theme_get_cursor(input->cursor_theme, "left_ptr");
|
||||
if (!input->default_cursor) {
|
||||
assert(uwacErrorHandler(input->display, UWAC_ERROR_NOMEMORY, "unable to get wayland cursor left_ptr\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
|
||||
#ifdef WL_POINTER_RELEASE_SINCE_VERSION
|
||||
if (input->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION)
|
||||
|
@ -846,6 +859,11 @@ static void seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_s
|
|||
else
|
||||
#endif
|
||||
wl_pointer_destroy(input->pointer);
|
||||
if (input->cursor_theme)
|
||||
wl_cursor_theme_destroy(input->cursor_theme);
|
||||
|
||||
input->default_cursor = NULL;
|
||||
input->cursor_theme = NULL;
|
||||
input->pointer = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,9 +120,6 @@ struct uwac_display {
|
|||
UwacTask dispatch_fd_task;
|
||||
uint32_t serial;
|
||||
|
||||
struct wl_cursor_theme *cursor_theme;
|
||||
struct wl_cursor *default_cursor;
|
||||
|
||||
struct wl_list windows;
|
||||
|
||||
struct wl_list outputs;
|
||||
|
@ -160,6 +157,8 @@ struct uwac_seat {
|
|||
struct wl_pointer *pointer;
|
||||
struct wl_surface *pointer_surface;
|
||||
struct wl_cursor_image *pointer_image;
|
||||
struct wl_cursor_theme *cursor_theme;
|
||||
struct wl_cursor *default_cursor;
|
||||
void *pointer_data;
|
||||
size_t pointer_size;
|
||||
int pointer_type;
|
||||
|
|
Loading…
Reference in New Issue