diff options
-rw-r--r-- | include/sway/input/cursor.h | 2 | ||||
-rw-r--r-- | include/sway/server.h | 2 | ||||
-rw-r--r-- | protocols/meson.build | 1 | ||||
-rw-r--r-- | sway/input/cursor.c | 24 | ||||
-rw-r--r-- | sway/server.c | 7 |
5 files changed, 36 insertions, 0 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 1636588a..1e21c66f 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -145,4 +145,6 @@ uint32_t get_mouse_button(const char *name, char **error); | |||
145 | 145 | ||
146 | const char *get_mouse_button_name(uint32_t button); | 146 | const char *get_mouse_button_name(uint32_t button); |
147 | 147 | ||
148 | void handle_request_set_cursor_shape(struct wl_listener *listener, void *data); | ||
149 | |||
148 | #endif | 150 | #endif |
diff --git a/include/sway/server.h b/include/sway/server.h index 0e4ec2be..1eb308a4 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -120,6 +120,8 @@ struct sway_server { | |||
120 | struct wl_listener xdg_activation_v1_request_activate; | 120 | struct wl_listener xdg_activation_v1_request_activate; |
121 | struct wl_listener xdg_activation_v1_new_token; | 121 | struct wl_listener xdg_activation_v1_new_token; |
122 | 122 | ||
123 | struct wl_listener request_set_cursor_shape; | ||
124 | |||
123 | struct wl_list pending_launcher_ctxs; // launcher_ctx::link | 125 | struct wl_list pending_launcher_ctxs; // launcher_ctx::link |
124 | 126 | ||
125 | // The timeout for transactions, after which a transaction is applied | 127 | // The timeout for transactions, after which a transaction is applied |
diff --git a/protocols/meson.build b/protocols/meson.build index e6fdec7d..b6fdec8c 100644 --- a/protocols/meson.build +++ b/protocols/meson.build | |||
@@ -13,6 +13,7 @@ protocols = [ | |||
13 | wl_protocol_dir / 'unstable/tablet/tablet-unstable-v2.xml', | 13 | wl_protocol_dir / 'unstable/tablet/tablet-unstable-v2.xml', |
14 | wl_protocol_dir / 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml', | 14 | wl_protocol_dir / 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml', |
15 | wl_protocol_dir / 'staging/content-type/content-type-v1.xml', | 15 | wl_protocol_dir / 'staging/content-type/content-type-v1.xml', |
16 | wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml', | ||
16 | 'wlr-layer-shell-unstable-v1.xml', | 17 | 'wlr-layer-shell-unstable-v1.xml', |
17 | 'idle.xml', | 18 | 'idle.xml', |
18 | 'wlr-input-inhibitor-unstable-v1.xml', | 19 | 'wlr-input-inhibitor-unstable-v1.xml', |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index f970e6a2..62c74d04 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <time.h> | 7 | #include <time.h> |
8 | #include <strings.h> | 8 | #include <strings.h> |
9 | #include <wlr/types/wlr_cursor.h> | 9 | #include <wlr/types/wlr_cursor.h> |
10 | #include <wlr/types/wlr_cursor_shape_v1.h> | ||
10 | #include <wlr/types/wlr_idle.h> | 11 | #include <wlr/types/wlr_idle.h> |
11 | #include <wlr/types/wlr_pointer.h> | 12 | #include <wlr/types/wlr_pointer.h> |
12 | #include <wlr/types/wlr_touch.h> | 13 | #include <wlr/types/wlr_touch.h> |
@@ -1467,3 +1468,26 @@ void sway_cursor_constrain(struct sway_cursor *cursor, | |||
1467 | wl_signal_add(&constraint->surface->events.commit, | 1468 | wl_signal_add(&constraint->surface->events.commit, |
1468 | &cursor->constraint_commit); | 1469 | &cursor->constraint_commit); |
1469 | } | 1470 | } |
1471 | |||
1472 | void handle_request_set_cursor_shape(struct wl_listener *listener, void *data) { | ||
1473 | const struct wlr_cursor_shape_manager_v1_request_set_shape_event *event = data; | ||
1474 | struct sway_seat *seat = event->seat_client->seat->data; | ||
1475 | |||
1476 | if (!seatop_allows_set_cursor(seat)) { | ||
1477 | return; | ||
1478 | } | ||
1479 | |||
1480 | struct wl_client *focused_client = NULL; | ||
1481 | struct wlr_surface *focused_surface = seat->wlr_seat->pointer_state.focused_surface; | ||
1482 | if (focused_surface != NULL) { | ||
1483 | focused_client = wl_resource_get_client(focused_surface->resource); | ||
1484 | } | ||
1485 | |||
1486 | // TODO: check cursor mode | ||
1487 | if (focused_client == NULL || event->seat_client->client != focused_client) { | ||
1488 | sway_log(SWAY_DEBUG, "denying request to set cursor from unfocused client"); | ||
1489 | return; | ||
1490 | } | ||
1491 | |||
1492 | cursor_set_image(seat->cursor, wlr_cursor_shape_v1_name(event->shape), focused_client); | ||
1493 | } | ||
diff --git a/sway/server.c b/sway/server.c index 3a11088a..50f0a702 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <wlr/render/wlr_renderer.h> | 11 | #include <wlr/render/wlr_renderer.h> |
12 | #include <wlr/types/wlr_compositor.h> | 12 | #include <wlr/types/wlr_compositor.h> |
13 | #include <wlr/types/wlr_content_type_v1.h> | 13 | #include <wlr/types/wlr_content_type_v1.h> |
14 | #include <wlr/types/wlr_cursor_shape_v1.h> | ||
14 | #include <wlr/types/wlr_data_control_v1.h> | 15 | #include <wlr/types/wlr_data_control_v1.h> |
15 | #include <wlr/types/wlr_drm.h> | 16 | #include <wlr/types/wlr_drm.h> |
16 | #include <wlr/types/wlr_export_dmabuf_v1.h> | 17 | #include <wlr/types/wlr_export_dmabuf_v1.h> |
@@ -44,6 +45,7 @@ | |||
44 | #include "sway/input/input-manager.h" | 45 | #include "sway/input/input-manager.h" |
45 | #include "sway/output.h" | 46 | #include "sway/output.h" |
46 | #include "sway/server.h" | 47 | #include "sway/server.h" |
48 | #include "sway/input/cursor.h" | ||
47 | #include "sway/tree/root.h" | 49 | #include "sway/tree/root.h" |
48 | 50 | ||
49 | #if HAVE_XWAYLAND | 51 | #if HAVE_XWAYLAND |
@@ -235,6 +237,11 @@ bool server_init(struct sway_server *server) { | |||
235 | wl_signal_add(&server->xdg_activation_v1->events.new_token, | 237 | wl_signal_add(&server->xdg_activation_v1->events.new_token, |
236 | &server->xdg_activation_v1_new_token); | 238 | &server->xdg_activation_v1_new_token); |
237 | 239 | ||
240 | struct wlr_cursor_shape_manager_v1 *cursor_shape_manager = | ||
241 | wlr_cursor_shape_manager_v1_create(server->wl_display, 1); | ||
242 | server->request_set_cursor_shape.notify = handle_request_set_cursor_shape; | ||
243 | wl_signal_add(&cursor_shape_manager->events.request_set_shape, &server->request_set_cursor_shape); | ||
244 | |||
238 | wl_list_init(&server->pending_launcher_ctxs); | 245 | wl_list_init(&server->pending_launcher_ctxs); |
239 | 246 | ||
240 | // Avoid using "wayland-0" as display socket | 247 | // Avoid using "wayland-0" as display socket |