mirror of
https://github.com/wizbright/waybox.git
synced 2026-02-04 04:06:17 -05:00
Backported pointer request changes from tinywl
Some checks failed
build / build (push) Has been cancelled
Some checks failed
build / build (push) Has been cancelled
This commit is contained in:
parent
c75ac6d731
commit
044ce8f7c0
2 changed files with 19 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ struct wb_cursor {
|
|||
struct wl_listener cursor_axis;
|
||||
struct wl_listener cursor_frame;
|
||||
|
||||
struct wl_listener pointer_focus_change;
|
||||
struct wl_listener request_cursor;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,18 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener, void *da
|
|||
process_cursor_motion(cursor->server, event->time_msec);
|
||||
}
|
||||
|
||||
static void handle_pointer_focus_change(struct wl_listener *listener, void *data) {
|
||||
struct wb_cursor *cursor = wl_container_of(
|
||||
listener, cursor, pointer_focus_change);
|
||||
/* This event is raised when the pointer focus is changed, including when the
|
||||
* client is closed. We set the cursor image to its default if target surface
|
||||
* is NULL */
|
||||
struct wlr_seat_pointer_focus_change_event *event = data;
|
||||
if (event->new_surface == NULL) {
|
||||
wlr_cursor_set_xcursor(cursor->cursor, cursor->xcursor_manager, "default");
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_cursor_button(struct wl_listener *listener, void *data) {
|
||||
/* This event is forwarded by the cursor when a pointer emits a button
|
||||
* event. */
|
||||
|
|
@ -213,6 +225,10 @@ struct wb_cursor *wb_cursor_create(struct wb_server *server) {
|
|||
cursor->cursor_frame.notify = handle_cursor_frame;
|
||||
wl_signal_add(&cursor->cursor->events.frame, &cursor->cursor_frame);
|
||||
|
||||
cursor->pointer_focus_change.notify = handle_pointer_focus_change;
|
||||
wl_signal_add(&server->seat->seat->pointer_state.events.focus_change,
|
||||
&cursor->pointer_focus_change);
|
||||
|
||||
cursor->request_cursor.notify = handle_cursor_request;
|
||||
wl_signal_add(&server->seat->seat->events.request_set_cursor,
|
||||
&cursor->request_cursor);
|
||||
|
|
@ -235,6 +251,8 @@ void wb_cursor_destroy(struct wb_cursor *cursor) {
|
|||
wl_list_remove(&cursor->cursor_axis.link);
|
||||
wl_list_remove(&cursor->cursor_frame.link);
|
||||
|
||||
wl_list_remove(&cursor->pointer_focus_change.link);
|
||||
|
||||
wlr_xcursor_manager_destroy(cursor->xcursor_manager);
|
||||
wlr_cursor_destroy(cursor->cursor);
|
||||
free(cursor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue