diff options
-rw-r--r-- | include/rootston/seat.h | 15 | ||||
-rw-r--r-- | include/wlr/types/wlr_data_device.h | 4 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 2 | ||||
-rw-r--r-- | rootston/seat.c | 38 | ||||
-rw-r--r-- | types/wlr_data_device.c | 6 | ||||
-rw-r--r-- | types/wlr_seat.c | 3 |
6 files changed, 57 insertions, 11 deletions
diff --git a/include/rootston/seat.h b/include/rootston/seat.h index cf5dd3b2..c71f7de0 100644 --- a/include/rootston/seat.h +++ b/include/rootston/seat.h @@ -17,12 +17,15 @@ struct roots_seat { struct wl_list views; // roots_seat_view::link bool has_focus; + struct wl_list drag_icons; // roots_drag_icon::link + struct wl_list keyboards; struct wl_list pointers; struct wl_list touch; struct wl_list tablet_tools; - struct wl_listener seat_destroy; + struct wl_listener new_drag_icon; + struct wl_listener destroy; }; struct roots_seat_view { @@ -33,6 +36,16 @@ struct roots_seat_view { struct wl_listener view_destroy; }; +struct roots_drag_icon { + struct roots_seat *seat; + struct wlr_drag_icon *wlr_drag_icon; + struct wl_list link; + + struct wl_listener surface_commit; + struct wl_listener map; + struct wl_listener destroy; +}; + struct roots_pointer { struct roots_seat *seat; struct wlr_input_device *device; diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h index 54514b4c..ff4a0f7e 100644 --- a/include/wlr/types/wlr_data_device.h +++ b/include/wlr/types/wlr_data_device.h @@ -71,10 +71,10 @@ struct wlr_drag_icon { bool is_pointer; int32_t touch_id; - int32_t sx; - int32_t sy; + int32_t sx, sy; struct { + struct wl_signal map; // emitted when mapped or unmapped struct wl_signal destroy; } events; diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index c2a89f33..ffdabd98 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -209,6 +209,8 @@ struct wlr_seat { struct wl_signal selection; struct wl_signal primary_selection; + struct wl_signal new_drag_icon; + struct wl_signal destroy; } events; diff --git a/rootston/seat.c b/rootston/seat.c index 1a0e6253..5817e13c 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -241,16 +241,37 @@ static void roots_seat_init_cursor(struct roots_seat *seat) { seat->cursor->tool_tip.notify = handle_tool_tip; wl_signal_add(&seat->seat->events.request_set_cursor, - &seat->cursor->request_set_cursor); + &seat->cursor->request_set_cursor); seat->cursor->request_set_cursor.notify = handle_request_set_cursor; } +static void roots_seat_handle_new_drag_icon(struct wl_listener *listener, + void *data) { + struct roots_seat *seat = wl_container_of(listener, seat, new_drag_icon); + struct wlr_drag_icon *wlr_drag_icon = data; + + struct roots_drag_icon *icon = calloc(1, sizeof(struct roots_drag_icon)); + if (icon == NULL) { + return; + } + icon->seat = seat; + icon->wlr_drag_icon = wlr_drag_icon; + + icon->surface_commit.notify = roots_drag_icon_handle_surface_commit; + wl_signal_add(&wlr_drag_icon->events.surface_commit, &icon->surface_commit); + icon->map.notify = roots_drag_icon_handle_map; + wl_signal_add(&wlr_drag_icon->events.map, &icon->map); + icon->destroy.notify = roots_drag_icon_handle_destroy; + wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy); + + wl_list_insert(&seat->drag_icons, &icon->link); +} + static void seat_view_destroy(struct roots_seat_view *seat_view); -static void roots_seat_handle_seat_destroy(struct wl_listener *listener, +static void roots_seat_handle_destroy(struct wl_listener *listener, void *data) { - struct roots_seat *seat = - wl_container_of(listener, seat, seat_destroy); + struct roots_seat *seat = wl_container_of(listener, seat, destroy); // TODO: probably more to be freed here wl_list_remove(&seat->seat_destroy.link); @@ -262,7 +283,7 @@ static void roots_seat_handle_seat_destroy(struct wl_listener *listener, } void roots_seat_destroy(struct roots_seat *seat) { - roots_seat_handle_seat_destroy(&seat->seat_destroy, seat->seat); + roots_seat_handle_destroy(&seat->destroy, seat->seat); wlr_seat_destroy(seat->seat); } @@ -277,6 +298,7 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) { wl_list_init(&seat->touch); wl_list_init(&seat->tablet_tools); wl_list_init(&seat->views); + wl_list_init(&seat->drag_icons); seat->input = input; @@ -295,8 +317,10 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) { wl_list_insert(&input->seats, &seat->link); - seat->seat_destroy.notify = roots_seat_handle_seat_destroy; - wl_signal_add(&seat->seat->events.destroy, &seat->seat_destroy); + seat->new_drag_icon.notify = roots_seat_handle_new_drag_icon; + wl_signal_add(&seat->seat->events.new_drag_icon, &seat->new_drag_icon); + seat->destroy.notify = roots_seat_handle_seat_destroy; + wl_signal_add(&seat->seat->events.destroy, &seat->destroy); return seat; } diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c index 5a6bc198..243c460d 100644 --- a/types/wlr_data_device.c +++ b/types/wlr_data_device.c @@ -454,6 +454,7 @@ static void wlr_drag_end(struct wlr_drag *drag) { if (drag->icon) { drag->icon->mapped = false; wl_list_remove(&drag->icon_destroy.link); + wl_signal_emit(&drag->icon->events.map, drag->icon); } free(drag); @@ -673,8 +674,8 @@ static struct wlr_drag_icon *wlr_drag_icon_create( icon->is_pointer = is_pointer; icon->touch_id = touch_id; icon->mapped = true; - wl_list_insert(&client->seat->drag_icons, &icon->link); + wl_signal_init(&icon->events.map); wl_signal_init(&icon->events.destroy); wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy); @@ -686,6 +687,9 @@ static struct wlr_drag_icon *wlr_drag_icon_create( wl_signal_add(&client->events.destroy, &icon->seat_client_destroy); icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy; + wl_list_insert(&client->seat->drag_icons, &icon->link); + wl_signal_emit(&client->seat->events.new_drag_icon, icon); + return icon; } diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 019cb567..79c4f6f6 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -454,7 +454,10 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) { wl_list_init(&wlr_seat->clients); wl_list_init(&wlr_seat->drag_icons); + wl_signal_init(&wlr_seat->events.new_drag_icon); + wl_signal_init(&wlr_seat->events.request_set_cursor); + wl_signal_init(&wlr_seat->events.selection); wl_signal_init(&wlr_seat->events.primary_selection); |