2018-07-13 14:40:56 +02:00
|
|
|
/*
|
|
|
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
|
|
|
* future consistency of this API.
|
|
|
|
*/
|
|
|
|
#ifndef WLR_USE_UNSTABLE
|
|
|
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
|
|
|
#endif
|
|
|
|
|
2017-10-11 21:48:40 +02:00
|
|
|
#ifndef WLR_TYPES_WLR_DATA_DEVICE_H
|
|
|
|
#define WLR_TYPES_WLR_DATA_DEVICE_H
|
|
|
|
|
|
|
|
#include <wayland-server.h>
|
2017-10-14 21:53:30 +02:00
|
|
|
#include <wlr/types/wlr_seat.h>
|
2017-10-11 21:48:40 +02:00
|
|
|
|
2017-10-15 17:06:03 +02:00
|
|
|
extern const struct
|
|
|
|
wlr_pointer_grab_interface wlr_data_device_pointer_drag_interface;
|
|
|
|
|
2017-10-16 13:29:18 +02:00
|
|
|
extern const struct
|
|
|
|
wlr_keyboard_grab_interface wlr_data_device_keyboard_drag_interface;
|
|
|
|
|
2017-11-13 21:41:48 +01:00
|
|
|
extern const struct
|
|
|
|
wlr_touch_grab_interface wlr_data_device_touch_drag_interface;
|
|
|
|
|
2017-10-11 21:48:40 +02:00
|
|
|
struct wlr_data_device_manager {
|
|
|
|
struct wl_global *global;
|
2018-07-08 20:21:31 +02:00
|
|
|
struct wl_list resources;
|
2018-05-03 21:22:51 +02:00
|
|
|
struct wl_list data_sources;
|
2017-12-07 00:50:55 +01:00
|
|
|
|
|
|
|
struct wl_listener display_destroy;
|
2018-05-03 21:22:51 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
|
|
|
|
|
|
|
void *data;
|
2017-10-11 21:48:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_data_offer {
|
|
|
|
struct wl_resource *resource;
|
2017-10-12 17:41:11 +02:00
|
|
|
struct wlr_data_source *source;
|
|
|
|
|
2017-12-29 22:51:33 +01:00
|
|
|
uint32_t actions;
|
|
|
|
enum wl_data_device_manager_dnd_action preferred_action;
|
2017-10-13 13:58:46 +02:00
|
|
|
bool in_ask;
|
|
|
|
|
2017-10-12 17:41:11 +02:00
|
|
|
struct wl_listener source_destroy;
|
2017-10-11 21:48:40 +02:00
|
|
|
};
|
|
|
|
|
2018-03-29 23:53:13 +02:00
|
|
|
/**
|
|
|
|
* A data source implementation. Only the `send` function is mandatory. Refer to
|
|
|
|
* the matching wl_data_source_* functions documentation to know what they do.
|
|
|
|
*/
|
|
|
|
struct wlr_data_source_impl {
|
2017-12-29 22:51:33 +01:00
|
|
|
void (*send)(struct wlr_data_source *source, const char *mime_type,
|
|
|
|
int32_t fd);
|
|
|
|
void (*accept)(struct wlr_data_source *source, uint32_t serial,
|
|
|
|
const char *mime_type);
|
|
|
|
void (*cancel)(struct wlr_data_source *source);
|
2017-10-11 21:48:40 +02:00
|
|
|
|
2017-12-29 22:51:33 +01:00
|
|
|
void (*dnd_drop)(struct wlr_data_source *source);
|
|
|
|
void (*dnd_finish)(struct wlr_data_source *source);
|
|
|
|
void (*dnd_action)(struct wlr_data_source *source,
|
|
|
|
enum wl_data_device_manager_dnd_action action);
|
2018-03-29 23:53:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_data_source {
|
|
|
|
const struct wlr_data_source_impl *impl;
|
|
|
|
|
|
|
|
// source metadata
|
|
|
|
struct wl_array mime_types;
|
|
|
|
int32_t actions;
|
2017-12-29 22:51:33 +01:00
|
|
|
|
|
|
|
// source status
|
2017-10-12 17:41:11 +02:00
|
|
|
bool accepted;
|
2017-12-29 22:51:33 +01:00
|
|
|
struct wlr_data_offer *offer;
|
2017-10-12 17:41:11 +02:00
|
|
|
|
2017-12-29 22:51:33 +01:00
|
|
|
// drag'n'drop status
|
2017-10-13 13:58:46 +02:00
|
|
|
enum wl_data_device_manager_dnd_action current_dnd_action;
|
|
|
|
uint32_t compositor_action;
|
2017-10-15 20:49:43 +02:00
|
|
|
|
2017-10-11 21:48:40 +02:00
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
|
|
|
};
|
|
|
|
|
2017-11-19 15:33:55 +01:00
|
|
|
struct wlr_drag_icon {
|
|
|
|
struct wlr_surface *surface;
|
|
|
|
struct wlr_seat_client *client;
|
|
|
|
struct wl_list link; // wlr_seat::drag_icons
|
|
|
|
bool mapped;
|
|
|
|
|
|
|
|
bool is_pointer;
|
|
|
|
int32_t touch_id;
|
|
|
|
|
|
|
|
struct {
|
2018-06-06 04:50:29 +02:00
|
|
|
struct wl_signal map;
|
2018-06-06 00:17:42 +02:00
|
|
|
struct wl_signal unmap;
|
2017-11-19 15:33:55 +01:00
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
|
|
|
|
|
|
|
struct wl_listener surface_destroy;
|
2017-11-19 17:10:27 +01:00
|
|
|
struct wl_listener seat_client_destroy;
|
2018-06-04 02:11:59 +02:00
|
|
|
|
|
|
|
void *data;
|
2017-11-19 15:33:55 +01:00
|
|
|
};
|
|
|
|
|
2017-10-14 21:53:30 +02:00
|
|
|
struct wlr_drag {
|
|
|
|
struct wlr_seat_pointer_grab pointer_grab;
|
2017-10-16 13:29:18 +02:00
|
|
|
struct wlr_seat_keyboard_grab keyboard_grab;
|
2017-11-13 14:22:04 +01:00
|
|
|
struct wlr_seat_touch_grab touch_grab;
|
2017-10-16 13:29:18 +02:00
|
|
|
|
2017-11-13 21:41:48 +01:00
|
|
|
struct wlr_seat *seat;
|
2017-10-30 13:37:54 +01:00
|
|
|
struct wlr_seat_client *seat_client;
|
|
|
|
struct wlr_seat_client *focus_client;
|
2017-10-14 21:53:30 +02:00
|
|
|
|
2017-11-13 21:41:48 +01:00
|
|
|
bool is_pointer_grab;
|
|
|
|
|
2017-11-19 15:33:55 +01:00
|
|
|
struct wlr_drag_icon *icon;
|
2017-10-14 21:53:30 +02:00
|
|
|
struct wlr_surface *focus;
|
|
|
|
struct wlr_data_source *source;
|
|
|
|
|
2017-11-01 13:05:02 +01:00
|
|
|
bool cancelling;
|
2017-11-13 21:41:48 +01:00
|
|
|
int32_t grab_touch_id;
|
2017-11-01 13:05:02 +01:00
|
|
|
|
2017-11-14 14:51:37 +01:00
|
|
|
struct wl_listener point_destroy;
|
2017-10-14 21:53:30 +02:00
|
|
|
struct wl_listener source_destroy;
|
2017-11-19 17:10:27 +01:00
|
|
|
struct wl_listener seat_client_destroy;
|
2017-11-19 15:33:55 +01:00
|
|
|
struct wl_listener icon_destroy;
|
2018-03-28 18:59:11 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal focus;
|
2018-03-28 20:16:14 +02:00
|
|
|
struct wl_signal motion;
|
2018-03-28 21:33:23 +02:00
|
|
|
struct wl_signal drop;
|
2018-03-28 18:59:11 +02:00
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
2017-10-14 21:53:30 +02:00
|
|
|
};
|
|
|
|
|
2018-03-28 20:16:14 +02:00
|
|
|
struct wlr_drag_motion_event {
|
|
|
|
struct wlr_drag *drag;
|
|
|
|
uint32_t time;
|
|
|
|
double sx, sy;
|
|
|
|
};
|
|
|
|
|
2018-03-28 21:33:23 +02:00
|
|
|
struct wlr_drag_drop_event {
|
|
|
|
struct wlr_drag *drag;
|
|
|
|
uint32_t time;
|
|
|
|
};
|
|
|
|
|
2017-10-11 21:48:40 +02:00
|
|
|
/**
|
|
|
|
* Create a wl data device manager global for this display.
|
|
|
|
*/
|
|
|
|
struct wlr_data_device_manager *wlr_data_device_manager_create(
|
2018-03-29 23:53:13 +02:00
|
|
|
struct wl_display *display);
|
2017-10-11 21:48:40 +02:00
|
|
|
|
2017-11-10 03:38:13 +01:00
|
|
|
/**
|
|
|
|
* Destroys a wlr_data_device_manager and removes its wl_data_device_manager global.
|
|
|
|
*/
|
|
|
|
void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager);
|
|
|
|
|
2017-10-12 17:41:11 +02:00
|
|
|
/**
|
2017-10-30 13:37:54 +01:00
|
|
|
* 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.
|
2017-10-12 17:41:11 +02:00
|
|
|
*/
|
2017-10-30 13:37:54 +01:00
|
|
|
void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client);
|
2017-10-12 17:41:11 +02:00
|
|
|
|
2018-03-29 23:53:13 +02:00
|
|
|
/**
|
|
|
|
* Sets the current selection for the seat. This removes the previous one if
|
|
|
|
* there was any.
|
|
|
|
*/
|
2017-10-15 20:49:43 +02:00
|
|
|
void wlr_seat_set_selection(struct wlr_seat *seat,
|
2018-03-29 23:53:13 +02:00
|
|
|
struct wlr_data_source *source, uint32_t serial);
|
2017-10-15 20:49:43 +02:00
|
|
|
|
2018-03-29 23:53:13 +02:00
|
|
|
/**
|
|
|
|
* Initializes the data source with the provided implementation.
|
|
|
|
*/
|
|
|
|
void wlr_data_source_init(struct wlr_data_source *source,
|
|
|
|
const struct wlr_data_source_impl *impl);
|
2017-12-25 16:10:16 +01:00
|
|
|
|
2018-03-29 23:53:13 +02:00
|
|
|
/**
|
|
|
|
* Finishes the data source.
|
|
|
|
*/
|
2017-12-25 18:18:26 +01:00
|
|
|
void wlr_data_source_finish(struct wlr_data_source *source);
|
|
|
|
|
2018-03-29 23:53:13 +02:00
|
|
|
/**
|
|
|
|
* Sends the data as the specified MIME type over the passed file descriptor,
|
|
|
|
* then close it.
|
|
|
|
*/
|
|
|
|
void wlr_data_source_send(struct wlr_data_source *source, const char *mime_type,
|
|
|
|
int32_t fd);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies the data source that a target accepts one of the offered MIME types.
|
|
|
|
* If a target doesn't accept any of the offered types, `mime_type` is NULL.
|
|
|
|
*/
|
|
|
|
void wlr_data_source_accept(struct wlr_data_source *source, uint32_t serial,
|
|
|
|
const char *mime_type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies the data source it is no longer valid and should be destroyed. That
|
|
|
|
* potentially destroys immediately the data source.
|
|
|
|
*/
|
|
|
|
void wlr_data_source_cancel(struct wlr_data_source *source);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies the data source that the drop operation was performed. This does not
|
|
|
|
* indicate acceptance.
|
|
|
|
*
|
|
|
|
* The data source may still be used in the future and should not be destroyed
|
|
|
|
* here.
|
|
|
|
*/
|
|
|
|
void wlr_data_source_dnd_drop(struct wlr_data_source *source);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies the data source that the drag-and-drop operation concluded. That
|
|
|
|
* potentially destroys immediately the data source.
|
|
|
|
*/
|
|
|
|
void wlr_data_source_dnd_finish(struct wlr_data_source *source);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies the data source that a target accepts the drag with the specified
|
|
|
|
* action.
|
|
|
|
*
|
|
|
|
* This shouldn't be called after `wlr_data_source_dnd_drop` unless the
|
|
|
|
* drag-and-drop operation ended in an "ask" action.
|
|
|
|
*/
|
|
|
|
void wlr_data_source_dnd_action(struct wlr_data_source *source,
|
|
|
|
enum wl_data_device_manager_dnd_action action);
|
|
|
|
|
2017-10-11 21:48:40 +02:00
|
|
|
#endif
|