diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-01-24 09:48:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-24 09:48:26 -0500 |
commit | 460a630a43c3aa914a84e2a2a0f879f8042d6c7f (patch) | |
tree | 8059d8d549c88d4f6aba5d6af2bc9b3908d4627a /include | |
parent | b1731134e2935d2840dd0cc60b9bce2ba9dbcb1f (diff) | |
parent | a1f9d7ad9efbd248ceb85307a51e6dcf27f6bb25 (diff) |
Merge pull request #1427 from emersion/refactor-data-device
Refactor data-device
Diffstat (limited to 'include')
-rw-r--r-- | include/types/wlr_data_device.h | 16 | ||||
-rw-r--r-- | include/wlr/types/wlr_data_device.h | 27 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 2 |
3 files changed, 24 insertions, 21 deletions
diff --git a/include/types/wlr_data_device.h b/include/types/wlr_data_device.h index 376c5f09..28073880 100644 --- a/include/types/wlr_data_device.h +++ b/include/types/wlr_data_device.h @@ -16,8 +16,8 @@ struct wlr_client_data_source { extern const struct wlr_surface_role drag_icon_surface_role; -struct wlr_data_offer *data_offer_create(struct wl_client *client, - struct wlr_data_source *source, uint32_t version); +struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource, + struct wlr_data_source *source, enum wlr_data_offer_type type); void data_offer_update_action(struct wlr_data_offer *offer); void data_offer_destroy(struct wlr_data_offer *offer); @@ -26,12 +26,20 @@ struct wlr_client_data_source *client_data_source_create( struct wl_list *resource_list); struct wlr_client_data_source *client_data_source_from_resource( struct wl_resource *resource); -struct wlr_data_offer *data_source_send_offer(struct wlr_data_source *source, - struct wl_resource *device_resource); void data_source_notify_finish(struct wlr_data_source *source); +struct wlr_seat_client *seat_client_from_data_device_resource( + struct wl_resource *resource); bool seat_client_start_drag(struct wlr_seat_client *client, struct wlr_data_source *source, struct wlr_surface *icon_surface, struct wlr_surface *origin, uint32_t serial); +/** + * Creates a new wl_data_offer if there is a wl_data_source currently set as + * the seat selection and sends it to the seat client, followed by the + * wl_data_device.selection() event. If there is no current selection, the + * wl_data_device.selection() event will carry a NULL wl_data_offer. If the + * client does not have a wl_data_device for the seat nothing will be done. + */ +void seat_client_send_selection(struct wlr_seat_client *seat_client); #endif diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h index 4ab181db..59aa718f 100644 --- a/include/wlr/types/wlr_data_device.h +++ b/include/wlr/types/wlr_data_device.h @@ -35,9 +35,16 @@ struct wlr_data_device_manager { void *data; }; +enum wlr_data_offer_type { + WLR_DATA_OFFER_SELECTION, + WLR_DATA_OFFER_DRAG, +}; + struct wlr_data_offer { struct wl_resource *resource; struct wlr_data_source *source; + enum wlr_data_offer_type type; + struct wl_list link; // wlr_seat::{selection_offers,drag_offers} uint32_t actions; enum wl_data_device_manager_dnd_action preferred_action; @@ -55,7 +62,7 @@ struct wlr_data_source_impl { int32_t fd); void (*accept)(struct wlr_data_source *source, uint32_t serial, const char *mime_type); - void (*cancel)(struct wlr_data_source *source); + void (*destroy)(struct wlr_data_source *source); void (*dnd_drop)(struct wlr_data_source *source); void (*dnd_finish)(struct wlr_data_source *source); @@ -157,15 +164,6 @@ struct wlr_data_device_manager *wlr_data_device_manager_create( void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager); /** - * Creates a new wl_data_offer if there is a wl_data_source currently set as - * the seat selection and sends it to the seat client, followed by the - * wl_data_device.selection() event. If there is no current selection, the - * wl_data_device.selection() event will carry a NULL wl_data_offer. If the - * client does not have a wl_data_device for the seat nothing * will be done. - */ -void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client); - -/** * Requests a selection to be set for the seat. */ void wlr_seat_request_set_selection(struct wlr_seat *seat, @@ -187,11 +185,6 @@ void wlr_data_source_init(struct wlr_data_source *source, const struct wlr_data_source_impl *impl); /** - * Finishes the data source. - */ -void wlr_data_source_finish(struct wlr_data_source *source); - -/** * Sends the data as the specified MIME type over the passed file descriptor, * then close it. */ @@ -207,9 +200,9 @@ void wlr_data_source_accept(struct wlr_data_source *source, uint32_t serial, /** * Notifies the data source it is no longer valid and should be destroyed. That - * potentially destroys immediately the data source. + * destroys immediately the data source. */ -void wlr_data_source_cancel(struct wlr_data_source *source); +void wlr_data_source_destroy(struct wlr_data_source *source); /** * Notifies the data source that the drop operation was performed. This does not diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 6bc4af1a..f6df7413 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -197,6 +197,7 @@ struct wlr_seat { struct wlr_data_source *selection_source; uint32_t selection_serial; + struct wl_list selection_offers; // wlr_data_offer::link struct wlr_primary_selection_source *primary_selection_source; uint32_t primary_selection_serial; @@ -205,6 +206,7 @@ struct wlr_seat { struct wlr_drag *drag; struct wlr_data_source *drag_source; uint32_t drag_serial; + struct wl_list drag_offers; // wlr_data_offer::link struct wlr_seat_pointer_state pointer_state; struct wlr_seat_keyboard_state keyboard_state; |