From 29abf93bb6a52101a53ece0b23e3b24c593a737e Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 12 Oct 2017 14:28:37 +0200 Subject: Check pointer focused surface instead of view at cursor --- rootston/cursor.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'rootston') diff --git a/rootston/cursor.c b/rootston/cursor.c index eeb657ad..4c3a9947 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -80,10 +80,16 @@ void cursor_update_position(struct roots_input *input, uint32_t time) { case ROOTS_CURSOR_PASSTHROUGH: view = view_at(desktop, input->cursor->x, input->cursor->y, &surface, &sx, &sy); - if (view != input->client_cursor_view) { + bool set_compositor_cursor = !view && input->cursor_client; + if (view) { + struct wl_client *view_client = + wl_resource_get_client(view->wlr_surface->resource); + set_compositor_cursor = view_client != input->cursor_client; + } + if (set_compositor_cursor) { wlr_log(L_DEBUG, "Switching to compositor cursor"); cursor_set_xcursor_image(input, input->xcursor->images[0]); - input->client_cursor_view = NULL; + input->cursor_client = NULL; } if (view) { wlr_seat_pointer_notify_enter(input->wl_seat, surface, sx, sy); @@ -298,10 +304,8 @@ static void handle_request_set_cursor(struct wl_listener *listener, request_set_cursor); struct wlr_seat_pointer_request_set_cursor_event *event = data; - struct wlr_surface *focused_surface = NULL; - double sx, sy; - struct roots_view *focused_view = view_at(input->server->desktop, - input->cursor->x, input->cursor->y, &focused_surface, &sx, &sy); + struct wlr_surface *focused_surface = + event->seat_handle->wlr_seat->pointer_state.focused_surface; bool ok = focused_surface != NULL; if (focused_surface != NULL) { struct wl_client *focused_client = @@ -309,7 +313,7 @@ static void handle_request_set_cursor(struct wl_listener *listener, ok = event->client == focused_client; } if (!ok) { - wlr_log(L_DEBUG, "Denying request to set cursor outside view"); + wlr_log(L_DEBUG, "Denying request to set cursor from unfocused client"); return; } @@ -321,7 +325,7 @@ static void handle_request_set_cursor(struct wl_listener *listener, event->hotspot_x, event->hotspot_y); } - input->client_cursor_view = focused_view; + input->cursor_client = event->client; } void cursor_initialize(struct roots_input *input) { -- cgit v1.2.3 From 8fd4ae5de86b62e482e338113e94f23ee183d28d Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 14 Oct 2017 12:21:36 +0200 Subject: Fix cursor role name, fix segfault when surface->resource is NULL --- rootston/cursor.c | 4 ++-- types/wlr_output.c | 2 +- types/wlr_seat.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'rootston') diff --git a/rootston/cursor.c b/rootston/cursor.c index 4c3a9947..03189587 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -306,8 +306,8 @@ static void handle_request_set_cursor(struct wl_listener *listener, struct wlr_surface *focused_surface = event->seat_handle->wlr_seat->pointer_state.focused_surface; - bool ok = focused_surface != NULL; - if (focused_surface != NULL) { + bool ok = focused_surface != NULL && focused_surface->resource != NULL; + if (ok) { struct wl_client *focused_client = wl_resource_get_client(focused_surface->resource); ok = event->client == focused_client; diff --git a/types/wlr_output.c b/types/wlr_output.c index b416f9de..bd4799c4 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -231,7 +231,7 @@ static void handle_cursor_surface_destroy(struct wl_listener *listener, void wlr_output_set_cursor_surface(struct wlr_output *output, struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y) { - if (surface && strcmp(surface->role, "cursor") != 0) { + if (surface && strcmp(surface->role, "wl_pointer-cursor") != 0) { return; } diff --git a/types/wlr_seat.c b/types/wlr_seat.c index ef81655c..aea4196b 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -28,7 +28,7 @@ static void wl_pointer_set_cursor(struct wl_client *client, if (surface_resource != NULL) { surface = wl_resource_get_user_data(surface_resource); - if (wlr_surface_set_role(surface, "cursor", resource, + if (wlr_surface_set_role(surface, "wl_pointer-cursor", resource, WL_POINTER_ERROR_ROLE) < 0) { return; } -- cgit v1.2.3