2010-12-18 20:38:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Intel Corporation
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-18 20:38:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-07-02 11:39:09 +00:00
|
|
|
#include "gdkdragprivate.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
#include "gdkprivate-wayland.h"
|
2017-11-20 03:42:43 +00:00
|
|
|
#include "gdkcontentformats.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
#include "gdkdisplay-wayland.h"
|
2017-12-10 00:05:37 +00:00
|
|
|
#include "gdkintl.h"
|
2016-01-13 20:00:34 +00:00
|
|
|
#include "gdkseat-wayland.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2015-11-19 19:26:11 +00:00
|
|
|
#include "gdkdeviceprivate.h"
|
|
|
|
|
2017-12-10 00:05:37 +00:00
|
|
|
#include <glib-unix.h>
|
|
|
|
#include <gio/gunixinputstream.h>
|
|
|
|
#include <gio/gunixoutputstream.h>
|
2010-12-18 20:38:49 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
#define GDK_TYPE_WAYLAND_DRAG (gdk_wayland_drag_get_type ())
|
|
|
|
#define GDK_WAYLAND_DRAG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDrag))
|
|
|
|
#define GDK_WAYLAND_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDragClass))
|
|
|
|
#define GDK_IS_WAYLAND_DRAG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG))
|
|
|
|
#define GDK_IS_WAYLAND_DRAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_DRAG))
|
|
|
|
#define GDK_WAYLAND_DRAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_DRAG, GdkWaylandDragClass))
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
typedef struct _GdkWaylandDrag GdkWaylandDrag;
|
|
|
|
typedef struct _GdkWaylandDragClass GdkWaylandDragClass;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
struct _GdkWaylandDrag
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag drag;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *dnd_surface;
|
|
|
|
struct wl_surface *dnd_wl_surface;
|
2014-08-21 19:30:22 +00:00
|
|
|
struct wl_data_source *data_source;
|
2018-05-06 00:06:53 +00:00
|
|
|
struct wl_data_offer *offer;
|
2014-08-21 18:20:37 +00:00
|
|
|
uint32_t serial;
|
2020-07-24 13:54:49 +00:00
|
|
|
int hot_x;
|
|
|
|
int hot_y;
|
2010-12-18 20:38:49 +00:00
|
|
|
};
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
struct _GdkWaylandDragClass
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDragClass parent_class;
|
2010-12-18 20:38:49 +00:00
|
|
|
};
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
static GList *drags;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
GType gdk_wayland_drag_get_type (void);
|
2014-09-06 00:41:06 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
G_DEFINE_TYPE (GdkWaylandDrag, gdk_wayland_drag, GDK_TYPE_DRAG)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_finalize (GObject *object)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkWaylandDrag *wayland_drag = GDK_WAYLAND_DRAG (object);
|
|
|
|
GdkDrag *drag = GDK_DRAG (object);
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *dnd_surface;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
drags = g_list_remove (drags, drag);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_drag_set_cursor (drag, NULL);
|
2014-08-21 19:30:22 +00:00
|
|
|
|
2018-07-25 07:00:09 +00:00
|
|
|
g_clear_pointer (&wayland_drag->data_source, wl_data_source_destroy);
|
|
|
|
g_clear_pointer (&wayland_drag->offer, wl_data_offer_destroy);
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
dnd_surface = wayland_drag->dnd_surface;
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
G_OBJECT_CLASS (gdk_wayland_drag_parent_class)->finalize (object);
|
2016-01-08 16:22:47 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (dnd_surface)
|
|
|
|
gdk_surface_destroy (dnd_surface);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 20:00:34 +00:00
|
|
|
static inline uint32_t
|
|
|
|
gdk_to_wl_actions (GdkDragAction action)
|
|
|
|
{
|
|
|
|
uint32_t dnd_actions = 0;
|
|
|
|
|
2018-05-08 11:56:08 +00:00
|
|
|
if (action & (GDK_ACTION_COPY | GDK_ACTION_LINK))
|
2016-01-13 20:00:34 +00:00
|
|
|
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
|
|
|
if (action & GDK_ACTION_MOVE)
|
|
|
|
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
|
|
|
|
if (action & GDK_ACTION_ASK)
|
|
|
|
dnd_actions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
|
|
|
|
|
|
|
return dnd_actions;
|
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_init (GdkWaylandDrag *drag_wayland)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag;
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
drag = GDK_DRAG (drag_wayland);
|
|
|
|
drags = g_list_prepend (drags, drag);
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2018-07-03 22:44:00 +00:00
|
|
|
gdk_drag_set_selected_action (drag, GDK_ACTION_COPY);
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
static GdkSurface *
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_get_drag_surface (GdkDrag *drag)
|
2015-12-02 04:33:53 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
return GDK_WAYLAND_DRAG (drag)->dnd_surface;
|
2015-12-02 04:33:53 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 02:53:38 +00:00
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_set_hotspot (GdkDrag *drag,
|
2020-07-24 13:54:49 +00:00
|
|
|
int hot_x,
|
|
|
|
int hot_y)
|
2015-12-08 02:53:38 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
|
2020-07-24 13:54:49 +00:00
|
|
|
int prev_hot_x = drag_wayland->hot_x;
|
|
|
|
int prev_hot_y = drag_wayland->hot_y;
|
2015-12-08 10:19:33 +00:00
|
|
|
const GdkRectangle damage_rect = { .width = 1, .height = 1 };
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
drag_wayland->hot_x = hot_x;
|
|
|
|
drag_wayland->hot_y = hot_y;
|
2015-12-08 10:19:33 +00:00
|
|
|
|
|
|
|
if (prev_hot_x == hot_x && prev_hot_y == hot_y)
|
|
|
|
return;
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
_gdk_wayland_surface_offset_next_wl_buffer (drag_wayland->dnd_surface,
|
2020-08-26 23:04:48 +00:00
|
|
|
prev_hot_x - hot_x, prev_hot_y - hot_y);
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_surface_invalidate_rect (drag_wayland->dnd_surface, &damage_rect);
|
2015-12-08 02:53:38 +00:00
|
|
|
}
|
|
|
|
|
2016-01-13 20:00:34 +00:00
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_set_cursor (GdkDrag *drag,
|
|
|
|
GdkCursor *cursor)
|
2016-01-13 20:00:34 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDevice *device = gdk_drag_get_device (drag);
|
2016-01-13 20:00:34 +00:00
|
|
|
|
2018-07-02 23:16:47 +00:00
|
|
|
if (device != NULL)
|
|
|
|
gdk_wayland_seat_set_global_cursor (gdk_device_get_seat (device), cursor);
|
2016-01-13 20:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_drop_performed (GdkDrag *drag,
|
|
|
|
guint32 time_)
|
2016-01-13 20:00:34 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_drag_set_cursor (drag, NULL);
|
2016-01-13 20:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_cancel (GdkDrag *drag,
|
|
|
|
GdkDragCancelReason reason)
|
2016-01-13 20:00:34 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_drag_set_cursor (drag, NULL);
|
2021-06-19 13:57:38 +00:00
|
|
|
gdk_drag_drop_done (drag, FALSE);
|
2016-01-13 20:00:34 +00:00
|
|
|
}
|
|
|
|
|
2016-03-16 20:49:21 +00:00
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_drop_done (GdkDrag *drag,
|
|
|
|
gboolean success)
|
2016-03-16 20:49:21 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
|
|
|
|
GdkDevice *device = gdk_drag_get_device (drag);
|
2018-05-31 19:15:59 +00:00
|
|
|
|
2020-01-04 05:12:57 +00:00
|
|
|
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), NULL);
|
2016-03-16 20:49:21 +00:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
if (drag_wayland->dnd_surface)
|
|
|
|
gdk_surface_hide (drag_wayland->dnd_surface);
|
2016-03-16 20:49:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_class_init (GdkWaylandDragClass *klass)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDragClass *drag_class = GDK_DRAG_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = gdk_wayland_drag_finalize;
|
|
|
|
|
|
|
|
drag_class->get_drag_surface = gdk_wayland_drag_get_drag_surface;
|
|
|
|
drag_class->set_hotspot = gdk_wayland_drag_set_hotspot;
|
|
|
|
drag_class->drop_done = gdk_wayland_drag_drop_done;
|
|
|
|
drag_class->set_cursor = gdk_wayland_drag_set_cursor;
|
|
|
|
drag_class->drop_performed = gdk_wayland_drag_drop_performed;
|
|
|
|
drag_class->cancel = gdk_wayland_drag_cancel;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2018-05-30 02:37:47 +00:00
|
|
|
static inline GdkDragAction
|
|
|
|
_wl_to_gdk_actions (uint32_t dnd_actions)
|
|
|
|
{
|
|
|
|
GdkDragAction actions = 0;
|
|
|
|
|
|
|
|
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
|
|
|
|
actions |= GDK_ACTION_COPY;
|
|
|
|
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
|
|
|
|
actions |= GDK_ACTION_MOVE;
|
|
|
|
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
|
|
|
actions |= GDK_ACTION_ASK;
|
|
|
|
|
|
|
|
return actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_source_target (void *data,
|
|
|
|
struct wl_data_source *source,
|
|
|
|
const char *mime_type)
|
|
|
|
{
|
|
|
|
GDK_NOTE (EVENTS,
|
|
|
|
g_message ("data source target, source = %p, mime_type = %s",
|
|
|
|
source, mime_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_write_done (GObject *drag,
|
|
|
|
GAsyncResult *result,
|
|
|
|
gpointer user_data)
|
2018-05-30 02:37:47 +00:00
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
if (!gdk_drag_write_finish (GDK_DRAG (drag), result, &error))
|
2018-05-30 02:37:47 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GDK_DISPLAY_NOTE (gdk_drag_get_display (GDK_DRAG (drag)), DND, g_message ("%p: failed to write stream: %s", drag, error->message));
|
2018-05-30 02:37:47 +00:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_source_send (void *data,
|
|
|
|
struct wl_data_source *source,
|
|
|
|
const char *mime_type,
|
|
|
|
int32_t fd)
|
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag = data;
|
2018-05-30 02:37:47 +00:00
|
|
|
GOutputStream *stream;
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), DND, g_message ("%p: data source send request for %s on fd %d\n",
|
2018-05-30 02:37:47 +00:00
|
|
|
source, mime_type, fd));
|
|
|
|
|
|
|
|
//mime_type = gdk_intern_mime_type (mime_type);
|
|
|
|
mime_type = g_intern_string (mime_type);
|
|
|
|
stream = g_unix_output_stream_new (fd, TRUE);
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_drag_write_async (drag,
|
|
|
|
mime_type,
|
|
|
|
stream,
|
|
|
|
G_PRIORITY_DEFAULT,
|
|
|
|
NULL,
|
|
|
|
gdk_wayland_drag_write_done,
|
|
|
|
drag);
|
2018-05-30 02:37:47 +00:00
|
|
|
g_object_unref (stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_source_cancelled (void *data,
|
|
|
|
struct wl_data_source *source)
|
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag = data;
|
2018-05-30 02:37:47 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS,
|
2018-05-30 02:37:47 +00:00
|
|
|
g_message ("data source cancelled, source = %p", source));
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_ERROR);
|
2018-05-30 02:37:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_source_dnd_drop_performed (void *data,
|
|
|
|
struct wl_data_source *source)
|
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag = data;
|
2018-05-30 02:37:47 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
g_signal_emit_by_name (drag, "drop-performed");
|
2018-05-30 02:37:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_source_dnd_finished (void *data,
|
|
|
|
struct wl_data_source *source)
|
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag = data;
|
2018-05-30 02:37:47 +00:00
|
|
|
|
2021-07-26 00:16:47 +00:00
|
|
|
g_object_ref (drag);
|
2018-06-29 17:34:14 +00:00
|
|
|
g_signal_emit_by_name (drag, "dnd-finished");
|
2021-06-19 13:57:38 +00:00
|
|
|
gdk_drag_drop_done (drag, TRUE);
|
2021-07-26 00:16:47 +00:00
|
|
|
g_object_unref (drag);
|
2018-05-30 02:37:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_source_action (void *data,
|
|
|
|
struct wl_data_source *source,
|
|
|
|
uint32_t action)
|
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag = data;
|
2018-05-30 02:37:47 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS,
|
2018-05-30 02:37:47 +00:00
|
|
|
g_message ("data source action, source = %p action=%x",
|
|
|
|
source, action));
|
|
|
|
|
2018-07-03 22:44:00 +00:00
|
|
|
gdk_drag_set_selected_action (drag, _wl_to_gdk_actions (action));
|
2018-05-30 02:37:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_data_source_listener data_source_listener = {
|
|
|
|
data_source_target,
|
|
|
|
data_source_send,
|
|
|
|
data_source_cancelled,
|
|
|
|
data_source_dnd_drop_performed,
|
|
|
|
data_source_dnd_finished,
|
|
|
|
data_source_action,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_create_data_source (GdkDrag *drag)
|
2018-05-30 02:37:47 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
|
|
|
|
GdkDisplay *display = gdk_drag_get_display (drag);
|
2018-05-30 02:37:47 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
const char *const *mimetypes;
|
2019-12-31 02:14:17 +00:00
|
|
|
GdkContentFormats *formats;
|
2018-05-30 02:37:47 +00:00
|
|
|
gsize i, n_mimetypes;
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
drag_wayland->data_source = wl_data_device_manager_create_data_source (display_wayland->data_device_manager);
|
|
|
|
wl_data_source_add_listener (drag_wayland->data_source,
|
2018-05-30 02:37:47 +00:00
|
|
|
&data_source_listener,
|
2018-06-29 17:34:14 +00:00
|
|
|
drag);
|
2018-05-30 02:37:47 +00:00
|
|
|
|
2019-12-31 02:14:17 +00:00
|
|
|
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
|
|
|
|
formats = gdk_content_formats_union_serialize_mime_types (formats);
|
|
|
|
|
|
|
|
mimetypes = gdk_content_formats_get_mime_types (formats, &n_mimetypes);
|
|
|
|
|
|
|
|
GDK_DISPLAY_NOTE (gdk_drag_get_display (drag), EVENTS,
|
|
|
|
{char *s = g_strjoinv (" ", (char **)mimetypes);
|
|
|
|
g_message ("create data source, mime types=%s", s);
|
|
|
|
g_free (s);});
|
|
|
|
|
2020-02-15 20:04:57 +00:00
|
|
|
wl_data_source_offer (drag_wayland->data_source, GDK_WAYLAND_LOCAL_DND_MIME_TYPE);
|
2018-05-30 02:37:47 +00:00
|
|
|
for (i = 0; i < n_mimetypes; i++)
|
2019-12-31 02:14:17 +00:00
|
|
|
wl_data_source_offer (drag_wayland->data_source, mimetypes[i]);
|
|
|
|
|
|
|
|
gdk_content_formats_unref (formats);
|
2018-05-30 02:37:47 +00:00
|
|
|
}
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *
|
2018-07-15 19:56:56 +00:00
|
|
|
_gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
2018-05-30 02:37:47 +00:00
|
|
|
GdkDevice *device,
|
|
|
|
GdkContentProvider *content,
|
|
|
|
GdkDragAction actions,
|
2020-05-17 21:49:02 +00:00
|
|
|
double dx,
|
|
|
|
double dy)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkWaylandDrag *drag_wayland;
|
|
|
|
GdkDrag *drag;
|
2018-05-31 19:15:59 +00:00
|
|
|
GdkSeat *seat;
|
2017-12-11 00:45:31 +00:00
|
|
|
GdkWaylandDisplay *display_wayland;
|
2018-07-03 18:58:31 +00:00
|
|
|
GdkCursor *cursor;
|
2014-08-21 19:30:22 +00:00
|
|
|
|
2017-12-11 00:45:31 +00:00
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
|
2018-05-31 19:15:59 +00:00
|
|
|
seat = gdk_device_get_seat (device);
|
2017-12-11 00:45:31 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
drag_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG,
|
2018-07-15 20:50:37 +00:00
|
|
|
"surface", surface,
|
2018-06-29 17:34:14 +00:00
|
|
|
"device", device,
|
|
|
|
"content", content,
|
2018-07-15 20:50:37 +00:00
|
|
|
"actions", actions,
|
2018-06-29 17:34:14 +00:00
|
|
|
NULL);
|
2018-07-15 20:06:55 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
drag = GDK_DRAG (drag_wayland);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
drag_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface));
|
|
|
|
drag_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface);
|
2018-05-30 02:37:47 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_drag_create_data_source (drag);
|
2014-08-21 19:30:22 +00:00
|
|
|
|
2017-12-11 00:45:31 +00:00
|
|
|
if (display_wayland->data_device_manager_version >=
|
|
|
|
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
|
|
|
|
{
|
2018-06-29 17:34:14 +00:00
|
|
|
wl_data_source_set_actions (drag_wayland->data_source,
|
2017-12-11 00:45:31 +00:00
|
|
|
gdk_to_wl_actions (actions));
|
|
|
|
}
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_seat_set_drag (seat, drag);
|
2018-05-31 19:15:59 +00:00
|
|
|
|
2017-12-11 00:45:31 +00:00
|
|
|
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
|
2018-06-29 17:34:14 +00:00
|
|
|
drag_wayland->data_source,
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_get_wl_surface (surface),
|
2018-06-29 17:34:14 +00:00
|
|
|
drag_wayland->dnd_wl_surface,
|
2017-12-11 00:45:31 +00:00
|
|
|
_gdk_wayland_display_get_serial (display_wayland));
|
|
|
|
|
2018-07-03 18:58:31 +00:00
|
|
|
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
|
|
|
|
gdk_drag_set_cursor (drag, cursor);
|
|
|
|
|
2018-05-31 19:15:59 +00:00
|
|
|
gdk_seat_ungrab (seat);
|
2017-12-11 00:45:31 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
return drag;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|