|
|
@ -82,6 +82,7 @@ static const int item_height = 64; |
|
|
|
static const int item_padding = 16; |
|
|
|
static const int item_padding = 16; |
|
|
|
|
|
|
|
|
|
|
|
static const char flower_mime_type[] = "application/x-wayland-dnd-flower"; |
|
|
|
static const char flower_mime_type[] = "application/x-wayland-dnd-flower"; |
|
|
|
|
|
|
|
static const char text_mime_type[] = "text/plain;charset=utf-8"; |
|
|
|
|
|
|
|
|
|
|
|
static struct item * |
|
|
|
static struct item * |
|
|
|
item_create(struct display *display, int x, int y, int seed) |
|
|
|
item_create(struct display *display, int x, int y, int seed) |
|
|
@ -280,13 +281,26 @@ data_source_send(void *data, struct wl_data_source *source, |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct dnd_flower_message dnd_flower_message;
|
|
|
|
struct dnd_flower_message dnd_flower_message;
|
|
|
|
struct dnd_drag *dnd_drag = data; |
|
|
|
struct dnd_drag *dnd_drag = data; |
|
|
|
|
|
|
|
char buffer[128]; |
|
|
|
|
|
|
|
int n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(mime_type, flower_mime_type) == 0) { |
|
|
|
dnd_flower_message.seed = dnd_drag->item->seed; |
|
|
|
dnd_flower_message.seed = dnd_drag->item->seed; |
|
|
|
dnd_flower_message.x_offset = dnd_drag->x_offset; |
|
|
|
dnd_flower_message.x_offset = dnd_drag->x_offset; |
|
|
|
dnd_flower_message.y_offset = dnd_drag->y_offset; |
|
|
|
dnd_flower_message.y_offset = dnd_drag->y_offset; |
|
|
|
|
|
|
|
|
|
|
|
if (write(fd, &dnd_flower_message, sizeof dnd_flower_message) < 0) |
|
|
|
if (write(fd, &dnd_flower_message, |
|
|
|
|
|
|
|
sizeof dnd_flower_message) < 0) |
|
|
|
abort(); |
|
|
|
abort(); |
|
|
|
|
|
|
|
} else if (strcmp(mime_type, text_mime_type) == 0) { |
|
|
|
|
|
|
|
n = snprintf(buffer, sizeof buffer, "seed=%d x=%d y=%d\n", |
|
|
|
|
|
|
|
dnd_drag->item->seed, |
|
|
|
|
|
|
|
dnd_drag->x_offset, |
|
|
|
|
|
|
|
dnd_drag->y_offset); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (write(fd, buffer, n) < 0) |
|
|
|
|
|
|
|
abort(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
close(fd); |
|
|
|
close(fd); |
|
|
|
} |
|
|
|
} |
|
|
@ -425,9 +439,9 @@ dnd_button_handler(struct widget *widget, |
|
|
|
&data_source_listener, |
|
|
|
&data_source_listener, |
|
|
|
dnd_drag); |
|
|
|
dnd_drag); |
|
|
|
wl_data_source_offer(dnd_drag->data_source, |
|
|
|
wl_data_source_offer(dnd_drag->data_source, |
|
|
|
"application/x-wayland-dnd-flower"); |
|
|
|
flower_mime_type); |
|
|
|
wl_data_source_offer(dnd_drag->data_source, |
|
|
|
wl_data_source_offer(dnd_drag->data_source, |
|
|
|
"text/plain; charset=utf-8"); |
|
|
|
text_mime_type); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wl_data_device_start_drag(input_get_data_device(input), |
|
|
|
wl_data_device_start_drag(input_get_data_device(input), |
|
|
|