diff options
| author | Leonardo Hernández Hernández <leohdz172@proton.me> | 2023-06-27 18:21:58 -0600 | 
|---|---|---|
| committer | Leonardo Hernández Hernández <leohdz172@proton.me> | 2023-07-23 19:56:55 -0600 | 
| commit | 0e5405610ea2c7f07675c7d22bf6991a0d947803 (patch) | |
| tree | c2d45aaad627249086952856269f6ddfdf3bc5fa /dwl.c | |
| parent | 0bb1a1cc5c31b8375d3c64a50e7ada57994fd2a2 (diff) | |
add support for cursor-shape-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4106
Diffstat (limited to '')
| -rw-r--r-- | dwl.c | 20 | 
1 files changed, 20 insertions, 0 deletions
| @@ -18,6 +18,7 @@  #include <wlr/render/wlr_renderer.h>  #include <wlr/types/wlr_compositor.h>  #include <wlr/types/wlr_cursor.h> +#include <wlr/types/wlr_cursor_shape_v1.h>  #include <wlr/types/wlr_data_control_v1.h>  #include <wlr/types/wlr_data_device.h>  #include <wlr/types/wlr_drm.h> @@ -294,6 +295,7 @@ static void requestmonstate(struct wl_listener *listener, void *data);  static void resize(Client *c, struct wlr_box geo, int interact);  static void run(char *startup_cmd);  static void setcursor(struct wl_listener *listener, void *data); +static void setcursorshape(struct wl_listener *listener, void *data);  static void setfloating(Client *c, int floating);  static void setfullscreen(Client *c, int fullscreen);  static void setgamma(struct wl_listener *listener, void *data); @@ -353,6 +355,7 @@ static struct wlr_layer_shell_v1 *layer_shell;  static struct wlr_output_manager_v1 *output_mgr;  static struct wlr_gamma_control_manager_v1 *gamma_control_mgr;  static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr; +static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;  static struct wlr_cursor *cursor;  static struct wlr_xcursor_manager *cursor_mgr; @@ -2004,6 +2007,20 @@ setcursor(struct wl_listener *listener, void *data)  }  void +setcursorshape(struct wl_listener *listener, void *data) +{ +	struct wlr_cursor_shape_manager_v1_request_set_shape_event *event = data; +	if (cursor_mode != CurNormal && cursor_mode != CurPressed) +		return; +	/* This can be sent by any client, so we check to make sure this one is +	 * actually has pointer focus first. If so, we can tell the cursor to +	 * use the provided cursor shape. */ +	if (event->seat_client == seat->pointer_state.focused_client) +		wlr_cursor_set_xcursor(cursor, cursor_mgr, +							   wlr_cursor_shape_v1_name(event->shape)); +} + +void  setfloating(Client *c, int floating)  {  	c->isfloating = floating; @@ -2286,6 +2303,9 @@ setup(void)  	LISTEN_STATIC(&cursor->events.axis, axisnotify);  	LISTEN_STATIC(&cursor->events.frame, cursorframe); +	cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1); +	LISTEN_STATIC(&cursor_shape_mgr->events.request_set_shape, setcursorshape); +  	/*  	 * Configures a seat, which is a single "seat" at which a user sits and  	 * operates the computer. This conceptually includes up to one keyboard, | 
