mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
data-device: remove data_source_send_offer
This commit is contained in:
parent
1150ff13ce
commit
84f278eca1
5 changed files with 23 additions and 28 deletions
|
@ -16,8 +16,8 @@ struct wlr_client_data_source {
|
||||||
|
|
||||||
extern const struct wlr_surface_role drag_icon_surface_role;
|
extern const struct wlr_surface_role drag_icon_surface_role;
|
||||||
|
|
||||||
struct wlr_data_offer *data_offer_create(struct wl_client *client,
|
struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource,
|
||||||
struct wlr_data_source *source, uint32_t version);
|
struct wlr_data_source *source);
|
||||||
void data_offer_update_action(struct wlr_data_offer *offer);
|
void data_offer_update_action(struct wlr_data_offer *offer);
|
||||||
void data_offer_destroy(struct wlr_data_offer *offer);
|
void data_offer_destroy(struct wlr_data_offer *offer);
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ struct wlr_client_data_source *client_data_source_create(
|
||||||
struct wl_list *resource_list);
|
struct wl_list *resource_list);
|
||||||
struct wlr_client_data_source *client_data_source_from_resource(
|
struct wlr_client_data_source *client_data_source_from_resource(
|
||||||
struct wl_resource *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);
|
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,
|
bool seat_client_start_drag(struct wlr_seat_client *client,
|
||||||
struct wlr_data_source *source, struct wlr_surface *icon_surface,
|
struct wlr_data_source *source, struct wlr_surface *icon_surface,
|
||||||
struct wlr_surface *origin, uint32_t serial);
|
struct wlr_surface *origin, uint32_t serial);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
static const struct wl_data_device_interface data_device_impl;
|
static const struct wl_data_device_interface data_device_impl;
|
||||||
|
|
||||||
static struct wlr_seat_client *seat_client_from_data_device_resource(
|
struct wlr_seat_client *seat_client_from_data_device_resource(
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
assert(wl_resource_instance_of(resource, &wl_data_device_interface,
|
assert(wl_resource_instance_of(resource, &wl_data_device_interface,
|
||||||
&data_device_impl));
|
&data_device_impl));
|
||||||
|
@ -103,7 +103,7 @@ void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client) {
|
||||||
wl_resource_for_each(device_resource, &seat_client->data_devices) {
|
wl_resource_for_each(device_resource, &seat_client->data_devices) {
|
||||||
if (source != NULL) {
|
if (source != NULL) {
|
||||||
struct wlr_data_offer *offer =
|
struct wlr_data_offer *offer =
|
||||||
data_source_send_offer(source, device_resource);
|
data_offer_create(device_resource, source);
|
||||||
if (offer == NULL) {
|
if (offer == NULL) {
|
||||||
wl_client_post_no_memory(seat_client->client);
|
wl_client_post_no_memory(seat_client->client);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -198,14 +198,21 @@ static void data_offer_handle_source_destroy(struct wl_listener *listener,
|
||||||
data_offer_destroy(offer);
|
data_offer_destroy(offer);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_data_offer *data_offer_create(struct wl_client *client,
|
struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource,
|
||||||
struct wlr_data_source *source, uint32_t version) {
|
struct wlr_data_source *source) {
|
||||||
|
struct wlr_seat_client *seat_client =
|
||||||
|
seat_client_from_data_device_resource(device_resource);
|
||||||
|
assert(seat_client != NULL);
|
||||||
|
assert(source != NULL); // a NULL source means no selection
|
||||||
|
|
||||||
struct wlr_data_offer *offer = calloc(1, sizeof(struct wlr_data_offer));
|
struct wlr_data_offer *offer = calloc(1, sizeof(struct wlr_data_offer));
|
||||||
if (offer == NULL) {
|
if (offer == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
offer->source = source;
|
offer->source = source;
|
||||||
|
|
||||||
|
struct wl_client *client = wl_resource_get_client(device_resource);
|
||||||
|
uint32_t version = wl_resource_get_version(device_resource);
|
||||||
offer->resource =
|
offer->resource =
|
||||||
wl_resource_create(client, &wl_data_offer_interface, version, 0);
|
wl_resource_create(client, &wl_data_offer_interface, version, 0);
|
||||||
if (offer->resource == NULL) {
|
if (offer->resource == NULL) {
|
||||||
|
@ -218,5 +225,12 @@ struct wlr_data_offer *data_offer_create(struct wl_client *client,
|
||||||
offer->source_destroy.notify = data_offer_handle_source_destroy;
|
offer->source_destroy.notify = data_offer_handle_source_destroy;
|
||||||
wl_signal_add(&source->events.destroy, &offer->source_destroy);
|
wl_signal_add(&source->events.destroy, &offer->source_destroy);
|
||||||
|
|
||||||
|
wl_data_device_send_data_offer(device_resource, offer->resource);
|
||||||
|
|
||||||
|
char **p;
|
||||||
|
wl_array_for_each(p, &source->mime_types) {
|
||||||
|
wl_data_offer_send_offer(offer->resource, *p);
|
||||||
|
}
|
||||||
|
|
||||||
return offer;
|
return offer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,25 +11,6 @@
|
||||||
#include "types/wlr_data_device.h"
|
#include "types/wlr_data_device.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
|
||||||
struct wlr_data_offer *data_source_send_offer(struct wlr_data_source *source,
|
|
||||||
struct wl_resource *device_resource) {
|
|
||||||
struct wl_client *client = wl_resource_get_client(device_resource);
|
|
||||||
uint32_t version = wl_resource_get_version(device_resource);
|
|
||||||
struct wlr_data_offer *offer = data_offer_create(client, source, version);
|
|
||||||
if (offer == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_data_device_send_data_offer(device_resource, offer->resource);
|
|
||||||
|
|
||||||
char **p;
|
|
||||||
wl_array_for_each(p, &source->mime_types) {
|
|
||||||
wl_data_offer_send_offer(offer->resource, *p);
|
|
||||||
}
|
|
||||||
|
|
||||||
return offer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wlr_data_source_init(struct wlr_data_source *source,
|
void wlr_data_source_init(struct wlr_data_source *source,
|
||||||
const struct wlr_data_source_impl *impl) {
|
const struct wlr_data_source_impl *impl) {
|
||||||
assert(impl->send);
|
assert(impl->send);
|
||||||
|
|
|
@ -62,7 +62,7 @@ static void drag_set_focus(struct wlr_drag *drag,
|
||||||
struct wl_resource *device_resource;
|
struct wl_resource *device_resource;
|
||||||
wl_resource_for_each(device_resource, &focus_client->data_devices) {
|
wl_resource_for_each(device_resource, &focus_client->data_devices) {
|
||||||
struct wlr_data_offer *offer =
|
struct wlr_data_offer *offer =
|
||||||
data_source_send_offer(drag->source, device_resource);
|
data_offer_create(device_resource, drag->source);
|
||||||
if (offer == NULL) {
|
if (offer == NULL) {
|
||||||
wl_resource_post_no_memory(device_resource);
|
wl_resource_post_no_memory(device_resource);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue