Merge pull request #542 from emersion/abstract-data-source
Abstract data sources
This commit is contained in:
commit
ce3a48c316
|
@ -23,33 +23,39 @@ struct wlr_data_offer {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
struct wlr_data_source *source;
|
struct wlr_data_source *source;
|
||||||
|
|
||||||
uint32_t dnd_actions;
|
uint32_t actions;
|
||||||
enum wl_data_device_manager_dnd_action preferred_dnd_action;
|
enum wl_data_device_manager_dnd_action preferred_action;
|
||||||
bool in_ask;
|
bool in_ask;
|
||||||
|
|
||||||
struct wl_listener source_destroy;
|
struct wl_listener source_destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_data_source {
|
struct wlr_data_source {
|
||||||
struct wl_resource *resource;
|
// source metadata
|
||||||
|
struct wl_array mime_types;
|
||||||
|
int32_t actions;
|
||||||
|
|
||||||
|
// source implementation
|
||||||
|
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);
|
||||||
|
|
||||||
|
// drag'n'drop implementation
|
||||||
|
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);
|
||||||
|
|
||||||
|
// source status
|
||||||
|
bool accepted;
|
||||||
struct wlr_data_offer *offer;
|
struct wlr_data_offer *offer;
|
||||||
struct wlr_seat_client *seat_client;
|
struct wlr_seat_client *seat_client;
|
||||||
|
|
||||||
struct wl_array mime_types;
|
// drag'n'drop status
|
||||||
|
|
||||||
bool accepted;
|
|
||||||
|
|
||||||
// drag and drop
|
|
||||||
enum wl_data_device_manager_dnd_action current_dnd_action;
|
enum wl_data_device_manager_dnd_action current_dnd_action;
|
||||||
uint32_t dnd_actions;
|
|
||||||
uint32_t compositor_action;
|
uint32_t compositor_action;
|
||||||
bool actions_set;
|
|
||||||
|
|
||||||
void (*accept)(struct wlr_data_source *source, uint32_t serial,
|
|
||||||
const char *mime_type);
|
|
||||||
void (*send)(struct wlr_data_source *source, const char *mime_type,
|
|
||||||
int32_t fd);
|
|
||||||
void (*cancel)(struct wlr_data_source *source);
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
|
|
|
@ -15,16 +15,18 @@ struct wlr_primary_selection_device_manager {
|
||||||
struct wlr_primary_selection_offer;
|
struct wlr_primary_selection_offer;
|
||||||
|
|
||||||
struct wlr_primary_selection_source {
|
struct wlr_primary_selection_source {
|
||||||
struct wl_resource *resource;
|
// source metadata
|
||||||
struct wlr_primary_selection_offer *offer;
|
|
||||||
struct wlr_seat_client *seat_client;
|
|
||||||
|
|
||||||
struct wl_array mime_types;
|
struct wl_array mime_types;
|
||||||
|
|
||||||
|
// source implementation
|
||||||
void (*send)(struct wlr_primary_selection_source *source,
|
void (*send)(struct wlr_primary_selection_source *source,
|
||||||
const char *mime_type, int32_t fd);
|
const char *mime_type, int32_t fd);
|
||||||
void (*cancel)(struct wlr_primary_selection_source *source);
|
void (*cancel)(struct wlr_primary_selection_source *source);
|
||||||
|
|
||||||
|
// source status
|
||||||
|
struct wlr_primary_selection_offer *offer;
|
||||||
|
struct wlr_seat_client *seat_client;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
|
|
|
@ -178,8 +178,7 @@ struct wlr_seat {
|
||||||
uint32_t capabilities;
|
uint32_t capabilities;
|
||||||
struct timespec last_event;
|
struct timespec last_event;
|
||||||
|
|
||||||
struct wlr_data_device *data_device; // TODO needed?
|
struct wlr_data_source *selection_data_source;
|
||||||
struct wlr_data_source *selection_source;
|
|
||||||
uint32_t selection_serial;
|
uint32_t selection_serial;
|
||||||
|
|
||||||
struct wlr_primary_selection_source *primary_selection_source;
|
struct wlr_primary_selection_source *primary_selection_source;
|
||||||
|
|
|
@ -14,26 +14,23 @@
|
||||||
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||||
|
|
||||||
static uint32_t data_offer_choose_action(struct wlr_data_offer *offer) {
|
static uint32_t data_offer_choose_action(struct wlr_data_offer *offer) {
|
||||||
uint32_t available_actions, preferred_action = 0;
|
uint32_t offer_actions, preferred_action = 0;
|
||||||
uint32_t source_actions, offer_actions;
|
|
||||||
|
|
||||||
if (wl_resource_get_version(offer->resource) >=
|
if (wl_resource_get_version(offer->resource) >=
|
||||||
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
|
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
|
||||||
offer_actions = offer->dnd_actions;
|
offer_actions = offer->actions;
|
||||||
preferred_action = offer->preferred_dnd_action;
|
preferred_action = offer->preferred_action;
|
||||||
} else {
|
} else {
|
||||||
offer_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
offer_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_resource_get_version(offer->source->resource) >=
|
uint32_t source_actions;
|
||||||
WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
|
if (offer->source->actions >= 0) {
|
||||||
source_actions = offer->source->dnd_actions;
|
source_actions = offer->source->actions;
|
||||||
} else {
|
} else {
|
||||||
source_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
source_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
||||||
}
|
}
|
||||||
|
|
||||||
available_actions = offer_actions & source_actions;
|
uint32_t available_actions = offer_actions & source_actions;
|
||||||
|
|
||||||
if (!available_actions) {
|
if (!available_actions) {
|
||||||
return WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
|
return WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
|
||||||
}
|
}
|
||||||
|
@ -53,14 +50,11 @@ static uint32_t data_offer_choose_action(struct wlr_data_offer *offer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void data_offer_update_action(struct wlr_data_offer *offer) {
|
static void data_offer_update_action(struct wlr_data_offer *offer) {
|
||||||
uint32_t action;
|
|
||||||
|
|
||||||
if (!offer->source) {
|
if (!offer->source) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
action = data_offer_choose_action(offer);
|
uint32_t action = data_offer_choose_action(offer);
|
||||||
|
|
||||||
if (offer->source->current_dnd_action == action) {
|
if (offer->source->current_dnd_action == action) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -71,9 +65,8 @@ static void data_offer_update_action(struct wlr_data_offer *offer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_resource_get_version(offer->source->resource) >=
|
if (offer->source->dnd_action) {
|
||||||
WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
|
offer->source->dnd_action(offer->source, action);
|
||||||
wl_data_source_send_action(offer->source->resource, action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_resource_get_version(offer->resource) >=
|
if (wl_resource_get_version(offer->resource) >=
|
||||||
|
@ -82,22 +75,6 @@ static void data_offer_update_action(struct wlr_data_offer *offer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void client_data_source_accept(struct wlr_data_source *source,
|
|
||||||
uint32_t serial, const char *mime_type) {
|
|
||||||
wl_data_source_send_target(source->resource, mime_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void client_data_source_send(struct wlr_data_source *source,
|
|
||||||
const char *mime_type, int32_t fd) {
|
|
||||||
wl_data_source_send_send(source->resource, mime_type, fd);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void client_data_source_cancel(struct wlr_data_source *source) {
|
|
||||||
wl_data_source_send_cancelled(source->resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void data_offer_accept(struct wl_client *client,
|
static void data_offer_accept(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t serial, const char *mime_type) {
|
struct wl_resource *resource, uint32_t serial, const char *mime_type) {
|
||||||
struct wlr_data_offer *offer = wl_resource_get_user_data(resource);
|
struct wlr_data_offer *offer = wl_resource_get_user_data(resource);
|
||||||
|
@ -108,7 +85,9 @@ static void data_offer_accept(struct wl_client *client,
|
||||||
|
|
||||||
// TODO check that client is currently focused by the input device
|
// TODO check that client is currently focused by the input device
|
||||||
|
|
||||||
|
if (offer->source->accept) {
|
||||||
offer->source->accept(offer->source, serial, mime_type);
|
offer->source->accept(offer->source, serial, mime_type);
|
||||||
|
}
|
||||||
offer->source->accepted = (mime_type != NULL);
|
offer->source->accepted = (mime_type != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,19 +107,17 @@ static void data_offer_destroy(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void data_source_notify_finish(struct wlr_data_source *source) {
|
static void data_source_notify_finish(struct wlr_data_source *source) {
|
||||||
if (!source->actions_set) {
|
assert(source->offer);
|
||||||
|
if (source->actions < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source->offer->in_ask && wl_resource_get_version(source->resource) >=
|
if (source->offer->in_ask && source->dnd_action) {
|
||||||
WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
|
source->dnd_action(source, source->current_dnd_action);
|
||||||
wl_data_source_send_action(source->resource,
|
|
||||||
source->current_dnd_action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_resource_get_version(source->resource) >=
|
if (source->dnd_finish) {
|
||||||
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
source->dnd_finish(source);
|
||||||
wl_data_source_send_dnd_finished(source->resource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
source->offer = NULL;
|
source->offer = NULL;
|
||||||
|
@ -158,18 +135,18 @@ static void data_offer_finish(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void data_offer_set_actions(struct wl_client *client,
|
static void data_offer_set_actions(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t dnd_actions,
|
struct wl_resource *resource, uint32_t actions,
|
||||||
uint32_t preferred_action) {
|
uint32_t preferred_action) {
|
||||||
struct wlr_data_offer *offer = wl_resource_get_user_data(resource);
|
struct wlr_data_offer *offer = wl_resource_get_user_data(resource);
|
||||||
|
|
||||||
if (dnd_actions & ~ALL_ACTIONS) {
|
if (actions & ~ALL_ACTIONS) {
|
||||||
wl_resource_post_error(offer->resource,
|
wl_resource_post_error(offer->resource,
|
||||||
WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK,
|
WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK,
|
||||||
"invalid action mask %x", dnd_actions);
|
"invalid action mask %x", actions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferred_action && (!(preferred_action & dnd_actions) ||
|
if (preferred_action && (!(preferred_action & actions) ||
|
||||||
__builtin_popcount(preferred_action) > 1)) {
|
__builtin_popcount(preferred_action) > 1)) {
|
||||||
wl_resource_post_error(offer->resource,
|
wl_resource_post_error(offer->resource,
|
||||||
WL_DATA_OFFER_ERROR_INVALID_ACTION,
|
WL_DATA_OFFER_ERROR_INVALID_ACTION,
|
||||||
|
@ -177,8 +154,8 @@ static void data_offer_set_actions(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
offer->dnd_actions = dnd_actions;
|
offer->actions = actions;
|
||||||
offer->preferred_dnd_action = preferred_action;
|
offer->preferred_action = preferred_action;
|
||||||
|
|
||||||
data_offer_update_action(offer);
|
data_offer_update_action(offer);
|
||||||
}
|
}
|
||||||
|
@ -196,19 +173,18 @@ static void data_offer_resource_destroy(struct wl_resource *resource) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offer->source->offer = NULL;
|
||||||
|
|
||||||
// If the drag destination has version < 3, wl_data_offer.finish
|
// If the drag destination has version < 3, wl_data_offer.finish
|
||||||
// won't be called, so do this here as a safety net, because
|
// won't be called, so do this here as a safety net, because
|
||||||
// we still want the version >=3 drag source to be happy.
|
// we still want the version >= 3 drag source to be happy.
|
||||||
if (wl_resource_get_version(offer->resource) <
|
if (wl_resource_get_version(offer->resource) <
|
||||||
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
|
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
|
||||||
data_source_notify_finish(offer->source);
|
data_source_notify_finish(offer->source);
|
||||||
} else if (offer->source->resource &&
|
} else if (offer->source->dnd_finish) {
|
||||||
wl_resource_get_version(offer->source->resource) >=
|
offer->source->cancel(offer->source);
|
||||||
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
|
||||||
wl_data_source_send_cancelled(offer->source->resource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
offer->source->offer = NULL;
|
|
||||||
out:
|
out:
|
||||||
free(offer);
|
free(offer);
|
||||||
}
|
}
|
||||||
|
@ -277,9 +253,9 @@ void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seat_client->seat->selection_source) {
|
if (seat_client->seat->selection_data_source) {
|
||||||
struct wlr_data_offer *offer = wlr_data_source_send_offer(
|
struct wlr_data_offer *offer = wlr_data_source_send_offer(
|
||||||
seat_client->seat->selection_source, seat_client);
|
seat_client->seat->selection_data_source, seat_client);
|
||||||
if (offer == NULL) {
|
if (offer == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -309,25 +285,30 @@ static void seat_client_selection_data_source_destroy(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seat->selection_source = NULL;
|
seat->selection_data_source = NULL;
|
||||||
|
|
||||||
wl_signal_emit(&seat->events.selection, seat);
|
wl_signal_emit(&seat->events.selection, seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_set_selection(struct wlr_seat *seat,
|
void wlr_seat_set_selection(struct wlr_seat *seat,
|
||||||
struct wlr_data_source *source, uint32_t serial) {
|
struct wlr_data_source *source, uint32_t serial) {
|
||||||
if (seat->selection_source &&
|
if (source) {
|
||||||
|
assert(source->send);
|
||||||
|
assert(source->cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seat->selection_data_source &&
|
||||||
seat->selection_serial - serial < UINT32_MAX / 2) {
|
seat->selection_serial - serial < UINT32_MAX / 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seat->selection_source) {
|
if (seat->selection_data_source) {
|
||||||
seat->selection_source->cancel(seat->selection_source);
|
seat->selection_data_source->cancel(seat->selection_data_source);
|
||||||
seat->selection_source = NULL;
|
seat->selection_data_source = NULL;
|
||||||
wl_list_remove(&seat->selection_data_source_destroy.link);
|
wl_list_remove(&seat->selection_data_source_destroy.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
seat->selection_source = source;
|
seat->selection_data_source = source;
|
||||||
seat->selection_serial = serial;
|
seat->selection_serial = serial;
|
||||||
|
|
||||||
struct wlr_seat_client *focused_client =
|
struct wlr_seat_client *focused_client =
|
||||||
|
@ -350,7 +331,7 @@ void wlr_seat_set_selection(struct wlr_seat *seat,
|
||||||
static void data_device_set_selection(struct wl_client *client,
|
static void data_device_set_selection(struct wl_client *client,
|
||||||
struct wl_resource *dd_resource, struct wl_resource *source_resource,
|
struct wl_resource *dd_resource, struct wl_resource *source_resource,
|
||||||
uint32_t serial) {
|
uint32_t serial) {
|
||||||
struct wlr_data_source *source = NULL;
|
struct client_data_source *source = NULL;
|
||||||
if (source_resource != NULL) {
|
if (source_resource != NULL) {
|
||||||
source = wl_resource_get_user_data(source_resource);
|
source = wl_resource_get_user_data(source_resource);
|
||||||
}
|
}
|
||||||
|
@ -358,8 +339,8 @@ static void data_device_set_selection(struct wl_client *client,
|
||||||
struct wlr_seat_client *seat_client =
|
struct wlr_seat_client *seat_client =
|
||||||
wl_resource_get_user_data(dd_resource);
|
wl_resource_get_user_data(dd_resource);
|
||||||
|
|
||||||
// TODO: store serial and check against incoming serial here
|
struct wlr_data_source *wlr_source = (struct wlr_data_source *)source;
|
||||||
wlr_seat_set_selection(seat_client->seat, source, serial);
|
wlr_seat_set_selection(seat_client->seat, wlr_source, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void data_device_release(struct wl_client *client,
|
static void data_device_release(struct wl_client *client,
|
||||||
|
@ -433,7 +414,7 @@ static void wlr_drag_set_focus(struct wlr_drag *drag,
|
||||||
if (wl_resource_get_version(offer->resource) >=
|
if (wl_resource_get_version(offer->resource) >=
|
||||||
WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION) {
|
WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION) {
|
||||||
wl_data_offer_send_source_actions(offer->resource,
|
wl_data_offer_send_source_actions(offer->resource,
|
||||||
drag->source->dnd_actions);
|
drag->source->actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
offer_resource = offer->resource;
|
offer_resource = offer->resource;
|
||||||
|
@ -510,18 +491,15 @@ static uint32_t pointer_drag_button(struct wlr_seat_pointer_grab *grab,
|
||||||
wl_resource_for_each(resource, &drag->focus_client->data_devices) {
|
wl_resource_for_each(resource, &drag->focus_client->data_devices) {
|
||||||
wl_data_device_send_drop(resource);
|
wl_data_device_send_drop(resource);
|
||||||
}
|
}
|
||||||
if (wl_resource_get_version(drag->source->resource) >=
|
if (drag->source->dnd_drop) {
|
||||||
WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION) {
|
drag->source->dnd_drop(drag->source);
|
||||||
wl_data_source_send_dnd_drop_performed(
|
|
||||||
drag->source->resource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drag->source->offer->in_ask =
|
drag->source->offer->in_ask =
|
||||||
drag->source->current_dnd_action ==
|
drag->source->current_dnd_action ==
|
||||||
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
||||||
} else if (wl_resource_get_version(drag->source->resource) >=
|
} else if (drag->source->dnd_finish) {
|
||||||
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
drag->source->cancel(drag->source);
|
||||||
wl_data_source_send_cancelled(drag->source->resource);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -834,6 +812,136 @@ static void data_device_destroy(struct wl_resource *resource) {
|
||||||
wl_list_remove(wl_resource_get_link(resource));
|
wl_list_remove(wl_resource_get_link(resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct client_data_source {
|
||||||
|
struct wlr_data_source source;
|
||||||
|
struct wl_resource *resource;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void client_data_source_accept(struct wlr_data_source *wlr_source,
|
||||||
|
uint32_t serial, const char *mime_type) {
|
||||||
|
struct client_data_source *source = (struct client_data_source *)wlr_source;
|
||||||
|
wl_data_source_send_target(source->resource, mime_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void client_data_source_send(struct wlr_data_source *wlr_source,
|
||||||
|
const char *mime_type, int32_t fd) {
|
||||||
|
struct client_data_source *source = (struct client_data_source *)wlr_source;
|
||||||
|
wl_data_source_send_send(source->resource, mime_type, fd);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void client_data_source_cancel(struct wlr_data_source *wlr_source) {
|
||||||
|
struct client_data_source *source = (struct client_data_source *)wlr_source;
|
||||||
|
wl_data_source_send_cancelled(source->resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void client_data_source_dnd_drop(struct wlr_data_source *wlr_source) {
|
||||||
|
struct client_data_source *source = (struct client_data_source *)wlr_source;
|
||||||
|
assert(wl_resource_get_version(source->resource) >=
|
||||||
|
WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION);
|
||||||
|
wl_data_source_send_dnd_drop_performed(source->resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void client_data_source_dnd_finish(struct wlr_data_source *wlr_source) {
|
||||||
|
struct client_data_source *source = (struct client_data_source *)wlr_source;
|
||||||
|
assert(wl_resource_get_version(source->resource) >=
|
||||||
|
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION);
|
||||||
|
wl_data_source_send_dnd_finished(source->resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void client_data_source_dnd_action(struct wlr_data_source *wlr_source,
|
||||||
|
enum wl_data_device_manager_dnd_action action) {
|
||||||
|
struct client_data_source *source = (struct client_data_source *)wlr_source;
|
||||||
|
assert(wl_resource_get_version(source->resource) >=
|
||||||
|
WL_DATA_SOURCE_ACTION_SINCE_VERSION);
|
||||||
|
wl_data_source_send_action(source->resource, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void data_source_destroy(struct wl_client *client,
|
||||||
|
struct wl_resource *resource) {
|
||||||
|
wl_resource_destroy(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void data_source_set_actions(struct wl_client *client,
|
||||||
|
struct wl_resource *resource, uint32_t dnd_actions) {
|
||||||
|
struct client_data_source *source =
|
||||||
|
wl_resource_get_user_data(resource);
|
||||||
|
|
||||||
|
if (source->source.actions >= 0) {
|
||||||
|
wl_resource_post_error(source->resource,
|
||||||
|
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
||||||
|
"cannot set actions more than once");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dnd_actions & ~ALL_ACTIONS) {
|
||||||
|
wl_resource_post_error(source->resource,
|
||||||
|
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
||||||
|
"invalid action mask %x", dnd_actions);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source->source.seat_client) {
|
||||||
|
wl_resource_post_error(source->resource,
|
||||||
|
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
||||||
|
"invalid action change after "
|
||||||
|
"wl_data_device.start_drag");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
source->source.actions = dnd_actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void data_source_offer(struct wl_client *client,
|
||||||
|
struct wl_resource *resource, const char *mime_type) {
|
||||||
|
struct client_data_source *source = wl_resource_get_user_data(resource);
|
||||||
|
|
||||||
|
char **p = wl_array_add(&source->source.mime_types, sizeof(*p));
|
||||||
|
if (p) {
|
||||||
|
*p = strdup(mime_type);
|
||||||
|
}
|
||||||
|
if (!p || !*p) {
|
||||||
|
if (p) {
|
||||||
|
source->source.mime_types.size -= sizeof(*p);
|
||||||
|
}
|
||||||
|
wl_resource_post_no_memory(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct wl_data_source_interface data_source_impl = {
|
||||||
|
.offer = data_source_offer,
|
||||||
|
.destroy = data_source_destroy,
|
||||||
|
.set_actions = data_source_set_actions,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void data_source_resource_handle_destroy(struct wl_resource *resource) {
|
||||||
|
struct client_data_source *source = wl_resource_get_user_data(resource);
|
||||||
|
wlr_data_source_finish(&source->source);
|
||||||
|
free(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_data_source_init(struct wlr_data_source *source) {
|
||||||
|
wl_array_init(&source->mime_types);
|
||||||
|
wl_signal_init(&source->events.destroy);
|
||||||
|
source->actions = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_data_source_finish(struct wlr_data_source *source) {
|
||||||
|
if (source == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_signal_emit(&source->events.destroy, source);
|
||||||
|
|
||||||
|
char **p;
|
||||||
|
wl_array_for_each(p, &source->mime_types) {
|
||||||
|
free(*p);
|
||||||
|
}
|
||||||
|
wl_array_release(&source->mime_types);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void data_device_manager_get_data_device(struct wl_client *client,
|
void data_device_manager_get_data_device(struct wl_client *client,
|
||||||
struct wl_resource *manager_resource, uint32_t id,
|
struct wl_resource *manager_resource, uint32_t id,
|
||||||
struct wl_resource *seat_resource) {
|
struct wl_resource *seat_resource) {
|
||||||
|
@ -852,101 +960,15 @@ void data_device_manager_get_data_device(struct wl_client *client,
|
||||||
wl_list_insert(&seat_client->data_devices, wl_resource_get_link(resource));
|
wl_list_insert(&seat_client->data_devices, wl_resource_get_link(resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void data_source_resource_destroy(struct wl_resource *resource) {
|
|
||||||
struct wlr_data_source *source =
|
|
||||||
wl_resource_get_user_data(resource);
|
|
||||||
wlr_data_source_finish(source);
|
|
||||||
free(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void data_source_destroy(struct wl_client *client,
|
|
||||||
struct wl_resource *resource) {
|
|
||||||
wl_resource_destroy(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void data_source_set_actions(struct wl_client *client,
|
|
||||||
struct wl_resource *resource, uint32_t dnd_actions) {
|
|
||||||
struct wlr_data_source *source =
|
|
||||||
wl_resource_get_user_data(resource);
|
|
||||||
|
|
||||||
if (source->actions_set) {
|
|
||||||
wl_resource_post_error(source->resource,
|
|
||||||
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
|
||||||
"cannot set actions more than once");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dnd_actions & ~ALL_ACTIONS) {
|
|
||||||
wl_resource_post_error(source->resource,
|
|
||||||
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
|
||||||
"invalid action mask %x", dnd_actions);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (source->seat_client) {
|
|
||||||
wl_resource_post_error(source->resource,
|
|
||||||
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
|
|
||||||
"invalid action change after "
|
|
||||||
"wl_data_device.start_drag");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
source->dnd_actions = dnd_actions;
|
|
||||||
source->actions_set = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void data_source_offer(struct wl_client *client,
|
|
||||||
struct wl_resource *resource, const char *mime_type) {
|
|
||||||
struct wlr_data_source *source =
|
|
||||||
wl_resource_get_user_data(resource);
|
|
||||||
char **p;
|
|
||||||
|
|
||||||
p = wl_array_add(&source->mime_types, sizeof(*p));
|
|
||||||
|
|
||||||
if (p) {
|
|
||||||
*p = strdup(mime_type);
|
|
||||||
}
|
|
||||||
if (!p || !*p){
|
|
||||||
if (p) {
|
|
||||||
source->mime_types.size -= sizeof(*p);
|
|
||||||
}
|
|
||||||
wl_resource_post_no_memory(resource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct wl_data_source_interface data_source_impl = {
|
|
||||||
.offer = data_source_offer,
|
|
||||||
.destroy = data_source_destroy,
|
|
||||||
.set_actions = data_source_set_actions,
|
|
||||||
};
|
|
||||||
|
|
||||||
void wlr_data_source_init(struct wlr_data_source *source) {
|
|
||||||
wl_array_init(&source->mime_types);
|
|
||||||
wl_signal_init(&source->events.destroy);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wlr_data_source_finish(struct wlr_data_source *source) {
|
|
||||||
if (source == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_signal_emit(&source->events.destroy, source);
|
|
||||||
|
|
||||||
char **p;
|
|
||||||
wl_array_for_each(p, &source->mime_types) {
|
|
||||||
free(*p);
|
|
||||||
}
|
|
||||||
wl_array_release(&source->mime_types);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void data_device_manager_create_data_source(struct wl_client *client,
|
static void data_device_manager_create_data_source(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t id) {
|
struct wl_resource *resource, uint32_t id) {
|
||||||
struct wlr_data_source *source = calloc(1, sizeof(struct wlr_data_source));
|
struct client_data_source *source =
|
||||||
|
calloc(1, sizeof(struct client_data_source));
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
wl_resource_post_no_memory(resource);
|
wl_resource_post_no_memory(resource);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_data_source_init(source);
|
wlr_data_source_init(&source->source);
|
||||||
|
|
||||||
source->resource = wl_resource_create(client, &wl_data_source_interface,
|
source->resource = wl_resource_create(client, &wl_data_source_interface,
|
||||||
wl_resource_get_version(resource), id);
|
wl_resource_get_version(resource), id);
|
||||||
|
@ -956,11 +978,24 @@ static void data_device_manager_create_data_source(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wl_resource_set_implementation(source->resource, &data_source_impl,
|
wl_resource_set_implementation(source->resource, &data_source_impl,
|
||||||
source, data_source_resource_destroy);
|
source, data_source_resource_handle_destroy);
|
||||||
|
|
||||||
source->accept = client_data_source_accept;
|
source->source.accept = client_data_source_accept;
|
||||||
source->send = client_data_source_send;
|
source->source.send = client_data_source_send;
|
||||||
source->cancel = client_data_source_cancel;
|
source->source.cancel = client_data_source_cancel;
|
||||||
|
|
||||||
|
if (wl_resource_get_version(source->resource) >=
|
||||||
|
WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION) {
|
||||||
|
source->source.dnd_drop = client_data_source_dnd_drop;
|
||||||
|
}
|
||||||
|
if (wl_resource_get_version(source->resource) >=
|
||||||
|
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
||||||
|
source->source.dnd_finish = client_data_source_dnd_finish;
|
||||||
|
}
|
||||||
|
if (wl_resource_get_version(source->resource) >=
|
||||||
|
WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
|
||||||
|
source->source.dnd_action = client_data_source_dnd_action;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_data_device_manager_interface
|
static const struct wl_data_device_manager_interface
|
||||||
|
@ -988,6 +1023,7 @@ void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wl_list_remove(&manager->display_destroy.link);
|
wl_list_remove(&manager->display_destroy.link);
|
||||||
|
// TODO: free wl_resources
|
||||||
wl_global_destroy(manager->global);
|
wl_global_destroy(manager->global);
|
||||||
free(manager);
|
free(manager);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <gtk-primary-selection-protocol.h>
|
#include <gtk-primary-selection-protocol.h>
|
||||||
#include <wlr/types/wlr_primary_selection.h>
|
#include <wlr/types/wlr_primary_selection.h>
|
||||||
#include <wlr/types/wlr_seat.h>
|
#include <wlr/types/wlr_seat.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
static void client_source_send(struct wlr_primary_selection_source *source,
|
|
||||||
const char *mime_type, int32_t fd) {
|
|
||||||
gtk_primary_selection_source_send_send(source->resource, mime_type, fd);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void client_source_cancel(
|
|
||||||
struct wlr_primary_selection_source *source) {
|
|
||||||
gtk_primary_selection_source_send_cancelled(source->resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void offer_handle_receive(struct wl_client *client,
|
static void offer_handle_receive(struct wl_client *client,
|
||||||
struct wl_resource *resource, const char *mime_type, int32_t fd) {
|
struct wl_resource *resource, const char *mime_type, int32_t fd) {
|
||||||
struct wlr_primary_selection_offer *offer =
|
struct wlr_primary_selection_offer *offer =
|
||||||
|
@ -55,11 +44,8 @@ static void offer_resource_handle_destroy(struct wl_resource *resource) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offer->source->resource) {
|
|
||||||
gtk_primary_selection_source_send_cancelled(offer->source->resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
offer->source->offer = NULL;
|
offer->source->offer = NULL;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(offer);
|
free(offer);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +59,24 @@ static void offer_handle_source_destroy(struct wl_listener *listener,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct client_data_source {
|
||||||
|
struct wlr_primary_selection_source source;
|
||||||
|
struct wl_resource *resource;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void client_source_send(struct wlr_primary_selection_source *wlr_source,
|
||||||
|
const char *mime_type, int32_t fd) {
|
||||||
|
struct client_data_source *source = (struct client_data_source *)wlr_source;
|
||||||
|
gtk_primary_selection_source_send_send(source->resource, mime_type, fd);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void client_source_cancel(
|
||||||
|
struct wlr_primary_selection_source *wlr_source) {
|
||||||
|
struct client_data_source *source = (struct client_data_source *)wlr_source;
|
||||||
|
gtk_primary_selection_source_send_cancelled(source->resource);
|
||||||
|
}
|
||||||
|
|
||||||
static struct wlr_primary_selection_offer *source_send_offer(
|
static struct wlr_primary_selection_offer *source_send_offer(
|
||||||
struct wlr_primary_selection_source *source,
|
struct wlr_primary_selection_source *source,
|
||||||
struct wlr_seat_client *target) {
|
struct wlr_seat_client *target) {
|
||||||
|
@ -119,16 +123,15 @@ static struct wlr_primary_selection_offer *source_send_offer(
|
||||||
|
|
||||||
static void source_handle_offer(struct wl_client *client,
|
static void source_handle_offer(struct wl_client *client,
|
||||||
struct wl_resource *resource, const char *mime_type) {
|
struct wl_resource *resource, const char *mime_type) {
|
||||||
struct wlr_primary_selection_source *source =
|
struct client_data_source *source = wl_resource_get_user_data(resource);
|
||||||
wl_resource_get_user_data(resource);
|
|
||||||
|
|
||||||
char **p = wl_array_add(&source->mime_types, sizeof(*p));
|
char **p = wl_array_add(&source->source.mime_types, sizeof(*p));
|
||||||
if (p) {
|
if (p) {
|
||||||
*p = strdup(mime_type);
|
*p = strdup(mime_type);
|
||||||
}
|
}
|
||||||
if (p == NULL || *p == NULL) {
|
if (p == NULL || *p == NULL) {
|
||||||
if (p) {
|
if (p) {
|
||||||
source->mime_types.size -= sizeof(*p);
|
source->source.mime_types.size -= sizeof(*p);
|
||||||
}
|
}
|
||||||
wl_resource_post_no_memory(resource);
|
wl_resource_post_no_memory(resource);
|
||||||
}
|
}
|
||||||
|
@ -145,9 +148,9 @@ static const struct gtk_primary_selection_source_interface source_impl = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void source_resource_handle_destroy(struct wl_resource *resource) {
|
static void source_resource_handle_destroy(struct wl_resource *resource) {
|
||||||
struct wlr_primary_selection_source *source =
|
struct client_data_source *source =
|
||||||
wl_resource_get_user_data(resource);
|
wl_resource_get_user_data(resource);
|
||||||
wlr_primary_selection_source_finish(source);
|
wlr_primary_selection_source_finish(&source->source);
|
||||||
free(source);
|
free(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +200,11 @@ static void seat_client_primary_selection_source_destroy(
|
||||||
|
|
||||||
void wlr_seat_set_primary_selection(struct wlr_seat *seat,
|
void wlr_seat_set_primary_selection(struct wlr_seat *seat,
|
||||||
struct wlr_primary_selection_source *source, uint32_t serial) {
|
struct wlr_primary_selection_source *source, uint32_t serial) {
|
||||||
|
if (source) {
|
||||||
|
assert(source->send);
|
||||||
|
assert(source->cancel);
|
||||||
|
}
|
||||||
|
|
||||||
if (seat->primary_selection_source &&
|
if (seat->primary_selection_source &&
|
||||||
seat->primary_selection_serial - serial < UINT32_MAX / 2) {
|
seat->primary_selection_serial - serial < UINT32_MAX / 2) {
|
||||||
return;
|
return;
|
||||||
|
@ -230,7 +238,7 @@ void wlr_seat_set_primary_selection(struct wlr_seat *seat,
|
||||||
static void device_handle_set_selection(struct wl_client *client,
|
static void device_handle_set_selection(struct wl_client *client,
|
||||||
struct wl_resource *resource, struct wl_resource *source_resource,
|
struct wl_resource *resource, struct wl_resource *source_resource,
|
||||||
uint32_t serial) {
|
uint32_t serial) {
|
||||||
struct wlr_primary_selection_source *source = NULL;
|
struct client_data_source *source = NULL;
|
||||||
if (source_resource != NULL) {
|
if (source_resource != NULL) {
|
||||||
source = wl_resource_get_user_data(source_resource);
|
source = wl_resource_get_user_data(source_resource);
|
||||||
}
|
}
|
||||||
|
@ -238,8 +246,9 @@ static void device_handle_set_selection(struct wl_client *client,
|
||||||
struct wlr_seat_client *seat_client =
|
struct wlr_seat_client *seat_client =
|
||||||
wl_resource_get_user_data(resource);
|
wl_resource_get_user_data(resource);
|
||||||
|
|
||||||
// TODO: store serial and check against incoming serial here
|
struct wlr_primary_selection_source *wlr_source =
|
||||||
wlr_seat_set_primary_selection(seat_client->seat, source, serial);
|
(struct wlr_primary_selection_source *)source;
|
||||||
|
wlr_seat_set_primary_selection(seat_client->seat, wlr_source, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_handle_destroy(struct wl_client *client,
|
static void device_handle_destroy(struct wl_client *client,
|
||||||
|
@ -280,13 +289,13 @@ void wlr_primary_selection_source_finish(
|
||||||
|
|
||||||
static void device_manager_handle_create_source(struct wl_client *client,
|
static void device_manager_handle_create_source(struct wl_client *client,
|
||||||
struct wl_resource *manager_resource, uint32_t id) {
|
struct wl_resource *manager_resource, uint32_t id) {
|
||||||
struct wlr_primary_selection_source *source =
|
struct client_data_source *source =
|
||||||
calloc(1, sizeof(struct wlr_primary_selection_source));
|
calloc(1, sizeof(struct client_data_source));
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_primary_selection_source_init(source);
|
wlr_primary_selection_source_init(&source->source);
|
||||||
|
|
||||||
int version = wl_resource_get_version(manager_resource);
|
int version = wl_resource_get_version(manager_resource);
|
||||||
source->resource = wl_resource_create(client,
|
source->resource = wl_resource_create(client,
|
||||||
|
@ -299,8 +308,8 @@ static void device_manager_handle_create_source(struct wl_client *client,
|
||||||
wl_resource_set_implementation(source->resource, &source_impl, source,
|
wl_resource_set_implementation(source->resource, &source_impl, source,
|
||||||
source_resource_handle_destroy);
|
source_resource_handle_destroy);
|
||||||
|
|
||||||
source->send = client_source_send;
|
source->source.send = client_source_send;
|
||||||
source->cancel = client_source_cancel;
|
source->source.cancel = client_source_cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void device_manager_handle_get_device(struct wl_client *client,
|
void device_manager_handle_get_device(struct wl_client *client,
|
||||||
|
|
|
@ -343,28 +343,38 @@ static const struct wlr_touch_grab_interface default_touch_grab_impl = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void wlr_seat_destroy(struct wlr_seat *wlr_seat) {
|
void wlr_seat_destroy(struct wlr_seat *seat) {
|
||||||
if (!wlr_seat) {
|
if (!seat) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_signal_emit(&wlr_seat->events.destroy, wlr_seat);
|
wl_signal_emit(&seat->events.destroy, seat);
|
||||||
|
|
||||||
wl_list_remove(&wlr_seat->display_destroy.link);
|
wl_list_remove(&seat->display_destroy.link);
|
||||||
|
|
||||||
|
if (seat->selection_data_source) {
|
||||||
|
seat->selection_data_source->cancel(seat->selection_data_source);
|
||||||
|
seat->selection_data_source = NULL;
|
||||||
|
wl_list_remove(&seat->selection_data_source_destroy.link);
|
||||||
|
}
|
||||||
|
if (seat->primary_selection_source) {
|
||||||
|
seat->primary_selection_source->cancel(seat->primary_selection_source);
|
||||||
|
seat->primary_selection_source = NULL;
|
||||||
|
wl_list_remove(&seat->primary_selection_source_destroy.link);
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_seat_client *client, *tmp;
|
struct wlr_seat_client *client, *tmp;
|
||||||
wl_list_for_each_safe(client, tmp, &wlr_seat->clients, link) {
|
wl_list_for_each_safe(client, tmp, &seat->clients, link) {
|
||||||
// will destroy other resources as well
|
// will destroy other resources as well
|
||||||
wl_resource_destroy(client->wl_resource);
|
wl_resource_destroy(client->wl_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_global_destroy(wlr_seat->wl_global);
|
wl_global_destroy(seat->wl_global);
|
||||||
free(wlr_seat->pointer_state.default_grab);
|
free(seat->pointer_state.default_grab);
|
||||||
free(wlr_seat->keyboard_state.default_grab);
|
free(seat->keyboard_state.default_grab);
|
||||||
free(wlr_seat->touch_state.default_grab);
|
free(seat->touch_state.default_grab);
|
||||||
free(wlr_seat->data_device);
|
free(seat->name);
|
||||||
free(wlr_seat->name);
|
free(seat);
|
||||||
free(wlr_seat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
@ -153,7 +153,8 @@ error_out:
|
||||||
static void xwm_selection_source_send(struct wlr_xwm_selection *selection,
|
static void xwm_selection_source_send(struct wlr_xwm_selection *selection,
|
||||||
const char *mime_type, int32_t fd) {
|
const char *mime_type, int32_t fd) {
|
||||||
if (selection == &selection->xwm->clipboard_selection) {
|
if (selection == &selection->xwm->clipboard_selection) {
|
||||||
struct wlr_data_source *source = selection->xwm->seat->selection_source;
|
struct wlr_data_source *source =
|
||||||
|
selection->xwm->seat->selection_data_source;
|
||||||
if (source != NULL) {
|
if (source != NULL) {
|
||||||
source->send(source, mime_type, fd);
|
source->send(source, mime_type, fd);
|
||||||
return;
|
return;
|
||||||
|
@ -214,7 +215,8 @@ static void xwm_selection_send_timestamp(struct wlr_xwm_selection *selection) {
|
||||||
static struct wl_array *xwm_selection_source_get_mime_types(
|
static struct wl_array *xwm_selection_source_get_mime_types(
|
||||||
struct wlr_xwm_selection *selection) {
|
struct wlr_xwm_selection *selection) {
|
||||||
if (selection == &selection->xwm->clipboard_selection) {
|
if (selection == &selection->xwm->clipboard_selection) {
|
||||||
struct wlr_data_source *source = selection->xwm->seat->selection_source;
|
struct wlr_data_source *source =
|
||||||
|
selection->xwm->seat->selection_data_source;
|
||||||
if (source != NULL) {
|
if (source != NULL) {
|
||||||
return &source->mime_types;
|
return &source->mime_types;
|
||||||
}
|
}
|
||||||
|
@ -834,8 +836,8 @@ void xwm_selection_finish(struct wlr_xwm *xwm) {
|
||||||
xcb_destroy_window(xwm->xcb_conn, xwm->selection_window);
|
xcb_destroy_window(xwm->xcb_conn, xwm->selection_window);
|
||||||
}
|
}
|
||||||
if (xwm->seat) {
|
if (xwm->seat) {
|
||||||
if (xwm->seat->selection_source &&
|
if (xwm->seat->selection_data_source &&
|
||||||
xwm->seat->selection_source->cancel == data_source_cancel) {
|
xwm->seat->selection_data_source->cancel == data_source_cancel) {
|
||||||
wlr_seat_set_selection(xwm->seat, NULL,
|
wlr_seat_set_selection(xwm->seat, NULL,
|
||||||
wl_display_next_serial(xwm->xwayland->wl_display));
|
wl_display_next_serial(xwm->xwayland->wl_display));
|
||||||
}
|
}
|
||||||
|
@ -871,7 +873,7 @@ static void seat_handle_selection(struct wl_listener *listener,
|
||||||
struct wlr_seat *seat = data;
|
struct wlr_seat *seat = data;
|
||||||
struct wlr_xwm *xwm =
|
struct wlr_xwm *xwm =
|
||||||
wl_container_of(listener, xwm, seat_selection);
|
wl_container_of(listener, xwm, seat_selection);
|
||||||
struct wlr_data_source *source = seat->selection_source;
|
struct wlr_data_source *source = seat->selection_data_source;
|
||||||
|
|
||||||
if (source != NULL && source->send == data_source_send) {
|
if (source != NULL && source->send == data_source_send) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue