From 65d57920e534acb231bb04964b257b2186c7ce73 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 7 Oct 2017 10:55:17 +0200 Subject: rootston: handle request_set_cursor --- include/rootston/input.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/rootston') diff --git a/include/rootston/input.h b/include/rootston/input.h index 9caf66c0..bdd2a104 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -107,6 +107,8 @@ struct roots_input { struct wl_listener cursor_tool_tip; struct wl_listener pointer_grab_end; + + struct wl_listener request_set_cursor; }; struct roots_input *input_create(struct roots_server *server, -- cgit v1.2.3 From 4d157fe5de78d632548df8f523f04a53b5688417 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 9 Oct 2017 12:51:28 +0200 Subject: Switch back to compositor cursor when leaving view --- include/rootston/input.h | 1 + rootston/cursor.c | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'include/rootston') diff --git a/include/rootston/input.h b/include/rootston/input.h index bdd2a104..43408516 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -79,6 +79,7 @@ struct roots_input { struct wlr_xcursor_theme *theme; struct wlr_xcursor *xcursor; struct wlr_seat *wl_seat; + bool client_cursor; enum roots_cursor_mode mode; struct roots_view *active_view, *last_active_view; diff --git a/rootston/cursor.c b/rootston/cursor.c index 97f9ca83..106e054f 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -58,6 +58,21 @@ void view_begin_rotate(struct roots_input *input, struct wlr_cursor *cursor, wlr_seat_pointer_clear_focus(input->wl_seat); } +static void cursor_set_xcursor_image(struct roots_input *input, + struct wlr_xcursor_image *image) { + struct roots_output *output; + wl_list_for_each(output, &input->server->desktop->outputs, link) { + if (!wlr_output_set_cursor(output->wlr_output, image->buffer, + image->width, image->width, image->height, + image->hotspot_x, image->hotspot_y)) { + wlr_log(L_DEBUG, "Failed to set hardware cursor"); + return; + } + } + + input->client_cursor = false; +} + void cursor_update_position(struct roots_input *input, uint32_t time) { struct roots_desktop *desktop = input->server->desktop; struct roots_view *view; @@ -72,6 +87,10 @@ void cursor_update_position(struct roots_input *input, uint32_t time) { wlr_seat_pointer_notify_motion(input->wl_seat, time, sx, sy); } else { wlr_seat_pointer_clear_focus(input->wl_seat); + if (input->client_cursor) { + wlr_log(L_DEBUG, "Switching to compositor cursor"); + cursor_set_xcursor_image(input, input->xcursor->images[0]); + } } break; case ROOTS_CURSOR_MOVE: @@ -279,18 +298,16 @@ static void handle_request_set_cursor(struct wl_listener *listener, struct roots_input *input = wl_container_of(listener, input, request_set_cursor); struct wlr_seat_pointer_request_set_cursor_event *event = data; - if (event->surface == NULL) { - wlr_log(L_DEBUG, "handle_request_set_cursor with NULL surface"); - return; - } - wlr_log(L_DEBUG, "handle_request_set_cursor"); + wlr_log(L_DEBUG, "Setting client cursor"); struct roots_output *output; wl_list_for_each(output, &input->server->desktop->outputs, link) { wlr_output_set_cursor_surface(output->wlr_output, event->surface, event->hotspot_x, event->hotspot_y); } + + input->client_cursor = true; } void cursor_initialize(struct roots_input *input) { -- cgit v1.2.3 From 84921740881f638622c6a0c1b4ab319218f1f7ac Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 9 Oct 2017 13:12:38 +0200 Subject: Switch back to compositor cursor when switching from one view to another --- include/rootston/input.h | 2 +- rootston/cursor.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'include/rootston') diff --git a/include/rootston/input.h b/include/rootston/input.h index 43408516..fbabbdb6 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -79,7 +79,7 @@ struct roots_input { struct wlr_xcursor_theme *theme; struct wlr_xcursor *xcursor; struct wlr_seat *wl_seat; - bool client_cursor; + struct roots_view *client_cursor_view; enum roots_cursor_mode mode; struct roots_view *active_view, *last_active_view; diff --git a/rootston/cursor.c b/rootston/cursor.c index 2df9bcb5..eeb657ad 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -69,8 +69,6 @@ static void cursor_set_xcursor_image(struct roots_input *input, return; } } - - input->client_cursor = false; } void cursor_update_position(struct roots_input *input, uint32_t time) { @@ -82,15 +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) { + wlr_log(L_DEBUG, "Switching to compositor cursor"); + cursor_set_xcursor_image(input, input->xcursor->images[0]); + input->client_cursor_view = NULL; + } if (view) { wlr_seat_pointer_notify_enter(input->wl_seat, surface, sx, sy); wlr_seat_pointer_notify_motion(input->wl_seat, time, sx, sy); } else { wlr_seat_pointer_clear_focus(input->wl_seat); - if (input->client_cursor) { - wlr_log(L_DEBUG, "Switching to compositor cursor"); - cursor_set_xcursor_image(input, input->xcursor->images[0]); - } } break; case ROOTS_CURSOR_MOVE: @@ -301,8 +300,8 @@ static void handle_request_set_cursor(struct wl_listener *listener, struct wlr_surface *focused_surface = NULL; double sx, sy; - view_at(input->server->desktop, input->cursor->x, input->cursor->y, - &focused_surface, &sx, &sy); + struct roots_view *focused_view = view_at(input->server->desktop, + input->cursor->x, input->cursor->y, &focused_surface, &sx, &sy); bool ok = focused_surface != NULL; if (focused_surface != NULL) { struct wl_client *focused_client = @@ -322,7 +321,7 @@ static void handle_request_set_cursor(struct wl_listener *listener, event->hotspot_x, event->hotspot_y); } - input->client_cursor = true; + input->client_cursor_view = focused_view; } void cursor_initialize(struct roots_input *input) { -- cgit v1.2.3