mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 07:30:42 -05:00
wayland: Move the primary data device manager to its own file
Instead of having everything clumped at MetaWaylandDataManager,
split the primary selection to its own struct. This manager is
handled separately from wl_data_device_manager and other selection
managers, so they would be able to interoperate between them, even.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
(cherry picked from commit 5e8d8b9ade
)
This commit is contained in:
parent
8b69e7902a
commit
e98e1c13dd
@ -495,6 +495,8 @@ if have_wayland
|
||||
'wayland/meta-wayland-cursor-surface.h',
|
||||
'wayland/meta-wayland-data-device.c',
|
||||
'wayland/meta-wayland-data-device.h',
|
||||
'wayland/meta-wayland-data-device-primary.c',
|
||||
'wayland/meta-wayland-data-device-primary.h',
|
||||
'wayland/meta-wayland-data-offer.c',
|
||||
'wayland/meta-wayland-data-offer.h',
|
||||
'wayland/meta-wayland-data-offer-primary.c',
|
||||
|
326
src/wayland/meta-wayland-data-device-primary.c
Normal file
326
src/wayland/meta-wayland-data-device-primary.c
Normal file
@ -0,0 +1,326 @@
|
||||
/*
|
||||
* Copyright © 2011 Kristian Høgsberg
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* The file is based on src/data-device.c from Weston */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "wayland/meta-wayland-data-device-primary.h"
|
||||
|
||||
#include "compositor/meta-dnd-actor-private.h"
|
||||
#include "meta/meta-selection-source-memory.h"
|
||||
#include "wayland/meta-selection-source-wayland-private.h"
|
||||
#include "wayland/meta-wayland-data-offer-primary.h"
|
||||
#include "wayland/meta-wayland-data-source-primary.h"
|
||||
#include "wayland/meta-wayland-dnd-surface.h"
|
||||
#include "wayland/meta-wayland-pointer.h"
|
||||
#include "wayland/meta-wayland-private.h"
|
||||
#include "wayland/meta-wayland-seat.h"
|
||||
|
||||
#include "gtk-primary-selection-server-protocol.h"
|
||||
|
||||
static struct wl_resource * create_and_send_primary_offer (MetaWaylandDataDevicePrimary *data_device,
|
||||
struct wl_resource *target);
|
||||
|
||||
static void
|
||||
unbind_resource (struct wl_resource *resource)
|
||||
{
|
||||
wl_list_remove (wl_resource_get_link (resource));
|
||||
}
|
||||
|
||||
static void
|
||||
default_destructor (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
{
|
||||
wl_resource_destroy (resource);
|
||||
}
|
||||
|
||||
static void
|
||||
set_selection_source (MetaWaylandDataDevicePrimary *data_device,
|
||||
MetaSelectionSource *selection_source)
|
||||
|
||||
{
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
|
||||
meta_selection_set_owner (meta_display_get_selection (display),
|
||||
META_SELECTION_PRIMARY,
|
||||
selection_source);
|
||||
g_set_object (&data_device->owner, selection_source);
|
||||
}
|
||||
|
||||
static void
|
||||
unset_selection_source (MetaWaylandDataDevicePrimary *data_device)
|
||||
{
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
|
||||
if (!data_device->owner)
|
||||
return;
|
||||
|
||||
meta_selection_unset_owner (meta_display_get_selection (display),
|
||||
META_SELECTION_PRIMARY,
|
||||
data_device->owner);
|
||||
g_clear_object (&data_device->owner);
|
||||
}
|
||||
|
||||
static void
|
||||
primary_source_destroyed (gpointer data,
|
||||
GObject *object_was_here)
|
||||
{
|
||||
MetaWaylandDataDevicePrimary *data_device = data;
|
||||
|
||||
data_device->data_source = NULL;
|
||||
unset_selection_source (data_device);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_data_device_primary_set_selection (MetaWaylandDataDevicePrimary *data_device,
|
||||
MetaWaylandDataSource *source,
|
||||
uint32_t serial)
|
||||
{
|
||||
MetaWaylandSeat *seat = wl_container_of (data_device, seat, primary_data_device);
|
||||
MetaSelectionSource *selection_source;
|
||||
|
||||
g_assert (!source || META_IS_WAYLAND_DATA_SOURCE_PRIMARY (source));
|
||||
|
||||
if (data_device->data_source &&
|
||||
data_device->serial - serial < UINT32_MAX / 2)
|
||||
return;
|
||||
|
||||
if (data_device->data_source)
|
||||
{
|
||||
g_object_weak_unref (G_OBJECT (data_device->data_source),
|
||||
primary_source_destroyed,
|
||||
data_device);
|
||||
}
|
||||
|
||||
data_device->data_source = source;
|
||||
data_device->serial = serial;
|
||||
|
||||
if (source)
|
||||
{
|
||||
meta_wayland_data_source_set_seat (source, seat);
|
||||
g_object_weak_ref (G_OBJECT (source),
|
||||
primary_source_destroyed,
|
||||
data_device);
|
||||
|
||||
selection_source = meta_selection_source_wayland_new (source);
|
||||
}
|
||||
else
|
||||
{
|
||||
selection_source = g_object_new (META_TYPE_SELECTION_SOURCE_MEMORY, NULL);
|
||||
}
|
||||
|
||||
set_selection_source (data_device, selection_source);
|
||||
g_object_unref (selection_source);
|
||||
}
|
||||
|
||||
static void
|
||||
primary_device_set_selection (struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *source_resource,
|
||||
uint32_t serial)
|
||||
{
|
||||
MetaWaylandDataDevicePrimary *data_device = wl_resource_get_user_data (resource);
|
||||
MetaWaylandSeat *seat = wl_container_of (data_device, seat, primary_data_device);
|
||||
MetaWaylandDataSource *source = NULL;
|
||||
|
||||
if (source_resource)
|
||||
source = wl_resource_get_user_data (source_resource);
|
||||
|
||||
if (wl_resource_get_client (resource) !=
|
||||
meta_wayland_keyboard_get_focus_client (seat->keyboard))
|
||||
return;
|
||||
|
||||
meta_wayland_data_device_primary_set_selection (data_device, source, serial);
|
||||
}
|
||||
|
||||
static const struct gtk_primary_selection_device_interface primary_device_interface = {
|
||||
primary_device_set_selection,
|
||||
default_destructor,
|
||||
};
|
||||
|
||||
static void
|
||||
owner_changed_cb (MetaSelection *selection,
|
||||
MetaSelectionType selection_type,
|
||||
MetaSelectionSource *new_owner,
|
||||
MetaWaylandDataDevicePrimary *data_device)
|
||||
{
|
||||
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
|
||||
MetaWaylandSeat *seat = compositor->seat;
|
||||
struct wl_resource *data_device_resource;
|
||||
struct wl_client *focus_client;
|
||||
|
||||
focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard);
|
||||
if (!focus_client)
|
||||
return;
|
||||
|
||||
if (selection_type == META_SELECTION_PRIMARY)
|
||||
{
|
||||
data_device_resource =
|
||||
wl_resource_find_for_client (&data_device->resource_list,
|
||||
focus_client);
|
||||
if (data_device_resource)
|
||||
{
|
||||
struct wl_resource *offer = NULL;
|
||||
|
||||
if (new_owner)
|
||||
{
|
||||
offer = create_and_send_primary_offer (data_device,
|
||||
data_device_resource);
|
||||
}
|
||||
|
||||
gtk_primary_selection_device_send_selection (data_device_resource,
|
||||
offer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_owners_changed_handler_connected (MetaWaylandDataDevicePrimary *data_device)
|
||||
{
|
||||
if (data_device->selection_owner_signal_id != 0)
|
||||
return;
|
||||
|
||||
data_device->selection_owner_signal_id =
|
||||
g_signal_connect (meta_display_get_selection (meta_get_display ()),
|
||||
"owner-changed",
|
||||
G_CALLBACK (owner_changed_cb), data_device);
|
||||
}
|
||||
|
||||
static void
|
||||
primary_device_manager_create_source (struct wl_client *client,
|
||||
struct wl_resource *manager_resource,
|
||||
guint32 id)
|
||||
{
|
||||
struct wl_resource *source_resource;
|
||||
|
||||
source_resource =
|
||||
wl_resource_create (client, >k_primary_selection_source_interface,
|
||||
wl_resource_get_version (manager_resource),
|
||||
id);
|
||||
meta_wayland_data_source_primary_new (source_resource);
|
||||
}
|
||||
|
||||
static void
|
||||
primary_device_manager_get_device (struct wl_client *client,
|
||||
struct wl_resource *manager_resource,
|
||||
guint32 id,
|
||||
struct wl_resource *seat_resource)
|
||||
{
|
||||
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
||||
struct wl_resource *cr;
|
||||
|
||||
cr = wl_resource_create (client, >k_primary_selection_device_interface,
|
||||
wl_resource_get_version (manager_resource), id);
|
||||
wl_resource_set_implementation (cr, &primary_device_interface,
|
||||
&seat->primary_data_device, unbind_resource);
|
||||
wl_list_insert (&seat->primary_data_device.resource_list, wl_resource_get_link (cr));
|
||||
|
||||
ensure_owners_changed_handler_connected (&seat->primary_data_device);
|
||||
}
|
||||
|
||||
static const struct gtk_primary_selection_device_manager_interface primary_manager_interface = {
|
||||
primary_device_manager_create_source,
|
||||
primary_device_manager_get_device,
|
||||
default_destructor,
|
||||
};
|
||||
|
||||
static void
|
||||
bind_primary_manager (struct wl_client *client,
|
||||
void *data,
|
||||
uint32_t version,
|
||||
uint32_t id)
|
||||
{
|
||||
struct wl_resource *resource;
|
||||
|
||||
resource = wl_resource_create (client, >k_primary_selection_device_manager_interface,
|
||||
version, id);
|
||||
wl_resource_set_implementation (resource, &primary_manager_interface, NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_data_device_primary_manager_init (MetaWaylandCompositor *compositor)
|
||||
{
|
||||
if (wl_global_create (compositor->wayland_display,
|
||||
>k_primary_selection_device_manager_interface,
|
||||
1, NULL, bind_primary_manager) == NULL)
|
||||
g_error ("Could not create data_device");
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_data_device_primary_init (MetaWaylandDataDevicePrimary *data_device)
|
||||
{
|
||||
wl_list_init (&data_device->resource_list);
|
||||
}
|
||||
|
||||
static struct wl_resource *
|
||||
create_and_send_primary_offer (MetaWaylandDataDevicePrimary *data_device,
|
||||
struct wl_resource *target)
|
||||
{
|
||||
MetaWaylandDataOffer *offer;
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
struct wl_resource *resource;
|
||||
GList *mimetypes, *l;
|
||||
|
||||
mimetypes = meta_selection_get_mimetypes (meta_display_get_selection (display),
|
||||
META_SELECTION_PRIMARY);
|
||||
if (!mimetypes)
|
||||
return NULL;
|
||||
|
||||
offer = meta_wayland_data_offer_primary_new (target);
|
||||
resource = meta_wayland_data_offer_get_resource (offer);
|
||||
|
||||
gtk_primary_selection_device_send_data_offer (target, resource);
|
||||
|
||||
for (l = mimetypes; l; l = l->next)
|
||||
gtk_primary_selection_offer_send_offer (resource, l->data);
|
||||
|
||||
g_list_free_full (mimetypes, g_free);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_data_device_primary_set_keyboard_focus (MetaWaylandDataDevicePrimary *data_device)
|
||||
{
|
||||
MetaWaylandSeat *seat = wl_container_of (data_device, seat, primary_data_device);
|
||||
struct wl_client *focus_client;
|
||||
struct wl_resource *data_device_resource;
|
||||
|
||||
focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard);
|
||||
|
||||
if (focus_client == data_device->focus_client)
|
||||
return;
|
||||
|
||||
data_device->focus_client = focus_client;
|
||||
|
||||
if (!focus_client)
|
||||
return;
|
||||
|
||||
data_device_resource = wl_resource_find_for_client (&data_device->resource_list, focus_client);
|
||||
if (data_device_resource)
|
||||
{
|
||||
struct wl_resource *offer;
|
||||
offer = create_and_send_primary_offer (data_device, data_device_resource);
|
||||
gtk_primary_selection_device_send_selection (data_device_resource, offer);
|
||||
}
|
||||
}
|
54
src/wayland/meta-wayland-data-device-primary.h
Normal file
54
src/wayland/meta-wayland-data-device-primary.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright © 2008 Kristian Høgsberg
|
||||
* 2020 Red Hat Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef META_WAYLAND_DATA_DEVICE_PRIMARY_H
|
||||
#define META_WAYLAND_DATA_DEVICE_PRIMARY_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
#include "clutter/clutter.h"
|
||||
#include "meta/meta-selection-source.h"
|
||||
#include "wayland/meta-wayland-data-offer.h"
|
||||
#include "wayland/meta-wayland-data-source.h"
|
||||
#include "wayland/meta-wayland-types.h"
|
||||
|
||||
struct _MetaWaylandDataDevicePrimary
|
||||
{
|
||||
uint32_t serial;
|
||||
MetaWaylandDataSource *data_source;
|
||||
struct wl_list resource_list;
|
||||
struct wl_client *focus_client;
|
||||
|
||||
guint selection_owner_signal_id;
|
||||
|
||||
MetaSelectionSource *owner;
|
||||
};
|
||||
|
||||
void meta_wayland_data_device_primary_manager_init (MetaWaylandCompositor *compositor);
|
||||
|
||||
void meta_wayland_data_device_primary_init (MetaWaylandDataDevicePrimary *data_device);
|
||||
|
||||
void meta_wayland_data_device_primary_set_keyboard_focus (MetaWaylandDataDevicePrimary *data_device);
|
||||
|
||||
#endif /* META_WAYLAND_DATA_DEVICE_PRIMARY_H */
|
@ -25,7 +25,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "wayland/meta-wayland-data-device.h"
|
||||
#include "wayland/meta-wayland-data-source-primary.h"
|
||||
|
||||
#include <gio/gunixoutputstream.h>
|
||||
#include <glib-unix.h>
|
||||
@ -38,14 +37,11 @@
|
||||
#include "compositor/meta-dnd-actor-private.h"
|
||||
#include "meta/meta-selection-source-memory.h"
|
||||
#include "wayland/meta-selection-source-wayland-private.h"
|
||||
#include "wayland/meta-wayland-data-offer-primary.h"
|
||||
#include "wayland/meta-wayland-dnd-surface.h"
|
||||
#include "wayland/meta-wayland-pointer.h"
|
||||
#include "wayland/meta-wayland-private.h"
|
||||
#include "wayland/meta-wayland-seat.h"
|
||||
|
||||
#include "gtk-primary-selection-server-protocol.h"
|
||||
|
||||
#define ROOTWINDOW_DROP_MIME "application/x-rootwindow-drop"
|
||||
|
||||
static void unset_selection_source (MetaWaylandDataDevice *data_device,
|
||||
@ -56,8 +52,6 @@ drag_grab_data_source_destroyed (gpointer data, GObject *where_the_object_was);
|
||||
|
||||
static struct wl_resource * create_and_send_clipboard_offer (MetaWaylandDataDevice *data_device,
|
||||
struct wl_resource *target);
|
||||
static struct wl_resource * create_and_send_primary_offer (MetaWaylandDataDevice *data_device,
|
||||
struct wl_resource *target);
|
||||
|
||||
static void
|
||||
unbind_resource (struct wl_resource *resource)
|
||||
@ -926,84 +920,6 @@ static const struct wl_data_device_interface data_device_interface = {
|
||||
default_destructor,
|
||||
};
|
||||
|
||||
static void
|
||||
primary_source_destroyed (gpointer data,
|
||||
GObject *object_was_here)
|
||||
{
|
||||
MetaWaylandDataDevice *data_device = data;
|
||||
|
||||
data_device->primary_data_source = NULL;
|
||||
unset_selection_source (data_device, META_SELECTION_PRIMARY);
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_data_device_set_primary (MetaWaylandDataDevice *data_device,
|
||||
MetaWaylandDataSource *source,
|
||||
guint32 serial)
|
||||
{
|
||||
MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device);
|
||||
MetaSelectionSource *selection_source;
|
||||
|
||||
g_assert (!source || META_IS_WAYLAND_DATA_SOURCE_PRIMARY (source));
|
||||
|
||||
if (data_device->primary_data_source &&
|
||||
data_device->primary_serial - serial < UINT32_MAX / 2)
|
||||
return;
|
||||
|
||||
if (data_device->primary_data_source)
|
||||
{
|
||||
g_object_weak_unref (G_OBJECT (data_device->primary_data_source),
|
||||
primary_source_destroyed,
|
||||
data_device);
|
||||
}
|
||||
|
||||
data_device->primary_data_source = source;
|
||||
data_device->primary_serial = serial;
|
||||
|
||||
if (source)
|
||||
{
|
||||
meta_wayland_data_source_set_seat (source, seat);
|
||||
g_object_weak_ref (G_OBJECT (source),
|
||||
primary_source_destroyed,
|
||||
data_device);
|
||||
|
||||
selection_source = meta_selection_source_wayland_new (source);
|
||||
}
|
||||
else
|
||||
{
|
||||
selection_source = g_object_new (META_TYPE_SELECTION_SOURCE_MEMORY, NULL);
|
||||
}
|
||||
|
||||
set_selection_source (data_device, META_SELECTION_PRIMARY,
|
||||
selection_source);
|
||||
g_object_unref (selection_source);
|
||||
}
|
||||
|
||||
static void
|
||||
primary_device_set_selection (struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *source_resource,
|
||||
uint32_t serial)
|
||||
{
|
||||
MetaWaylandDataDevice *data_device = wl_resource_get_user_data (resource);
|
||||
MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device);
|
||||
MetaWaylandDataSource *source = NULL;
|
||||
|
||||
if (source_resource)
|
||||
source = wl_resource_get_user_data (source_resource);
|
||||
|
||||
if (wl_resource_get_client (resource) !=
|
||||
meta_wayland_keyboard_get_focus_client (seat->keyboard))
|
||||
return;
|
||||
|
||||
meta_wayland_data_device_set_primary (data_device, source, serial);
|
||||
}
|
||||
|
||||
static const struct gtk_primary_selection_device_interface primary_device_interface = {
|
||||
primary_device_set_selection,
|
||||
default_destructor,
|
||||
};
|
||||
|
||||
static void
|
||||
create_data_source (struct wl_client *client,
|
||||
struct wl_resource *resource, guint32 id)
|
||||
@ -1030,26 +946,7 @@ owner_changed_cb (MetaSelection *selection,
|
||||
if (!focus_client)
|
||||
return;
|
||||
|
||||
if (selection_type == META_SELECTION_PRIMARY)
|
||||
{
|
||||
data_device_resource =
|
||||
wl_resource_find_for_client (&data_device->primary_resource_list,
|
||||
focus_client);
|
||||
if (data_device_resource)
|
||||
{
|
||||
struct wl_resource *offer = NULL;
|
||||
|
||||
if (new_owner)
|
||||
{
|
||||
offer = create_and_send_primary_offer (data_device,
|
||||
data_device_resource);
|
||||
}
|
||||
|
||||
gtk_primary_selection_device_send_selection (data_device_resource,
|
||||
offer);
|
||||
}
|
||||
}
|
||||
else if (selection_type == META_SELECTION_CLIPBOARD)
|
||||
if (selection_type == META_SELECTION_CLIPBOARD)
|
||||
{
|
||||
data_device_resource =
|
||||
wl_resource_find_for_client (&data_device->resource_list, focus_client);
|
||||
@ -1101,44 +998,6 @@ static const struct wl_data_device_manager_interface manager_interface = {
|
||||
get_data_device
|
||||
};
|
||||
|
||||
static void
|
||||
primary_device_manager_create_source (struct wl_client *client,
|
||||
struct wl_resource *manager_resource,
|
||||
guint32 id)
|
||||
{
|
||||
struct wl_resource *source_resource;
|
||||
|
||||
source_resource =
|
||||
wl_resource_create (client, >k_primary_selection_source_interface,
|
||||
wl_resource_get_version (manager_resource),
|
||||
id);
|
||||
meta_wayland_data_source_primary_new (source_resource);
|
||||
}
|
||||
|
||||
static void
|
||||
primary_device_manager_get_device (struct wl_client *client,
|
||||
struct wl_resource *manager_resource,
|
||||
guint32 id,
|
||||
struct wl_resource *seat_resource)
|
||||
{
|
||||
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
||||
struct wl_resource *cr;
|
||||
|
||||
cr = wl_resource_create (client, >k_primary_selection_device_interface,
|
||||
wl_resource_get_version (manager_resource), id);
|
||||
wl_resource_set_implementation (cr, &primary_device_interface,
|
||||
&seat->data_device, unbind_resource);
|
||||
wl_list_insert (&seat->data_device.primary_resource_list, wl_resource_get_link (cr));
|
||||
|
||||
ensure_owners_changed_handler_connected (&seat->data_device);
|
||||
}
|
||||
|
||||
static const struct gtk_primary_selection_device_manager_interface primary_manager_interface = {
|
||||
primary_device_manager_create_source,
|
||||
primary_device_manager_get_device,
|
||||
default_destructor,
|
||||
};
|
||||
|
||||
static void
|
||||
bind_manager (struct wl_client *client,
|
||||
void *data, guint32 version, guint32 id)
|
||||
@ -1148,19 +1007,6 @@ bind_manager (struct wl_client *client,
|
||||
wl_resource_set_implementation (resource, &manager_interface, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_primary_manager (struct wl_client *client,
|
||||
void *data,
|
||||
uint32_t version,
|
||||
uint32_t id)
|
||||
{
|
||||
struct wl_resource *resource;
|
||||
|
||||
resource = wl_resource_create (client, >k_primary_selection_device_manager_interface,
|
||||
version, id);
|
||||
wl_resource_set_implementation (resource, &primary_manager_interface, NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_data_device_manager_init (MetaWaylandCompositor *compositor)
|
||||
{
|
||||
@ -1169,18 +1015,12 @@ meta_wayland_data_device_manager_init (MetaWaylandCompositor *compositor)
|
||||
META_WL_DATA_DEVICE_MANAGER_VERSION,
|
||||
NULL, bind_manager) == NULL)
|
||||
g_error ("Could not create data_device");
|
||||
|
||||
if (wl_global_create (compositor->wayland_display,
|
||||
>k_primary_selection_device_manager_interface,
|
||||
1, NULL, bind_primary_manager) == NULL)
|
||||
g_error ("Could not create data_device");
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_data_device_init (MetaWaylandDataDevice *data_device)
|
||||
{
|
||||
wl_list_init (&data_device->resource_list);
|
||||
wl_list_init (&data_device->primary_resource_list);
|
||||
}
|
||||
|
||||
static struct wl_resource *
|
||||
@ -1210,31 +1050,6 @@ create_and_send_clipboard_offer (MetaWaylandDataDevice *data_device,
|
||||
return resource;
|
||||
}
|
||||
|
||||
static struct wl_resource *
|
||||
create_and_send_primary_offer (MetaWaylandDataDevice *data_device,
|
||||
struct wl_resource *target)
|
||||
{
|
||||
MetaWaylandDataOffer *offer;
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
GList *mimetypes, *l;
|
||||
|
||||
mimetypes = meta_selection_get_mimetypes (meta_display_get_selection (display),
|
||||
META_SELECTION_PRIMARY);
|
||||
if (!mimetypes)
|
||||
return NULL;
|
||||
|
||||
offer = meta_wayland_data_offer_primary_new (target);
|
||||
|
||||
gtk_primary_selection_device_send_data_offer (target, offer->resource);
|
||||
|
||||
for (l = mimetypes; l; l = l->next)
|
||||
gtk_primary_selection_offer_send_offer (offer->resource, l->data);
|
||||
|
||||
g_list_free_full (mimetypes, g_free);
|
||||
|
||||
return offer->resource;
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_data_device_set_keyboard_focus (MetaWaylandDataDevice *data_device)
|
||||
{
|
||||
@ -1259,14 +1074,6 @@ meta_wayland_data_device_set_keyboard_focus (MetaWaylandDataDevice *data_device)
|
||||
offer = create_and_send_clipboard_offer (data_device, data_device_resource);
|
||||
wl_data_device_send_selection (data_device_resource, offer);
|
||||
}
|
||||
|
||||
data_device_resource = wl_resource_find_for_client (&data_device->primary_resource_list, focus_client);
|
||||
if (data_device_resource)
|
||||
{
|
||||
struct wl_resource *offer;
|
||||
offer = create_and_send_primary_offer (data_device, data_device_resource);
|
||||
gtk_primary_selection_device_send_selection (data_device_resource, offer);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -38,13 +38,10 @@ typedef struct _MetaWaylandDataSourceFuncs MetaWaylandDataSourceFuncs;
|
||||
struct _MetaWaylandDataDevice
|
||||
{
|
||||
uint32_t selection_serial;
|
||||
uint32_t primary_serial;
|
||||
MetaWaylandDataSource *selection_data_source;
|
||||
MetaWaylandDataSource *dnd_data_source;
|
||||
MetaWaylandDataSource *primary_data_source;
|
||||
struct wl_listener selection_data_source_listener;
|
||||
struct wl_list resource_list;
|
||||
struct wl_list primary_resource_list;
|
||||
MetaWaylandDragGrab *current_grab;
|
||||
struct wl_client *focus_client;
|
||||
|
||||
@ -70,9 +67,6 @@ void meta_wayland_data_device_set_dnd_source (MetaWaylandDataDevice *data_de
|
||||
void meta_wayland_data_device_set_selection (MetaWaylandDataDevice *data_device,
|
||||
MetaWaylandDataSource *source,
|
||||
guint32 serial);
|
||||
void meta_wayland_data_device_set_primary (MetaWaylandDataDevice *data_device,
|
||||
MetaWaylandDataSource *source,
|
||||
guint32 serial);
|
||||
void meta_wayland_data_device_unset_dnd_selection (MetaWaylandDataDevice *data_device);
|
||||
|
||||
const MetaWaylandDragDestFuncs *
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "wayland/meta-wayland-seat.h"
|
||||
|
||||
#include "wayland/meta-wayland-data-device.h"
|
||||
#include "wayland/meta-wayland-data-device-primary.h"
|
||||
#include "wayland/meta-wayland-private.h"
|
||||
#include "wayland/meta-wayland-tablet-seat.h"
|
||||
#include "wayland/meta-wayland-versions.h"
|
||||
@ -231,6 +232,7 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
|
||||
seat->gtk_text_input = meta_wayland_gtk_text_input_new (seat);
|
||||
|
||||
meta_wayland_data_device_init (&seat->data_device);
|
||||
meta_wayland_data_device_primary_init (&seat->primary_data_device);
|
||||
|
||||
clutter_seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||
meta_wayland_seat_update_capabilities (seat, clutter_seat);
|
||||
@ -431,6 +433,7 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
|
||||
{
|
||||
meta_wayland_keyboard_set_focus (seat->keyboard, surface);
|
||||
meta_wayland_data_device_set_keyboard_focus (&seat->data_device);
|
||||
meta_wayland_data_device_primary_set_keyboard_focus (&seat->primary_data_device);
|
||||
}
|
||||
|
||||
tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat);
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "clutter/clutter.h"
|
||||
#include "wayland/meta-wayland-data-device.h"
|
||||
#include "wayland/meta-wayland-data-device-primary.h"
|
||||
#include "wayland/meta-wayland-input-device.h"
|
||||
#include "wayland/meta-wayland-keyboard.h"
|
||||
#include "wayland/meta-wayland-pointer.h"
|
||||
@ -45,6 +46,7 @@ struct _MetaWaylandSeat
|
||||
MetaWaylandTouch *touch;
|
||||
|
||||
MetaWaylandDataDevice data_device;
|
||||
MetaWaylandDataDevicePrimary primary_data_device;
|
||||
|
||||
MetaWaylandGtkTextInput *gtk_text_input;
|
||||
MetaWaylandTextInput *text_input;
|
||||
|
@ -37,6 +37,7 @@ typedef struct _MetaWaylandTouch MetaWaylandTouch;
|
||||
typedef struct _MetaWaylandDragDestFuncs MetaWaylandDragDestFuncs;
|
||||
typedef struct _MetaWaylandDataOffer MetaWaylandDataOffer;
|
||||
typedef struct _MetaWaylandDataDevice MetaWaylandDataDevice;
|
||||
typedef struct _MetaWaylandDataDevicePrimary MetaWaylandDataDevicePrimary;
|
||||
|
||||
typedef struct _MetaWaylandTabletManager MetaWaylandTabletManager;
|
||||
typedef struct _MetaWaylandTabletSeat MetaWaylandTabletSeat;
|
||||
|
@ -395,6 +395,7 @@ meta_wayland_init (void)
|
||||
|
||||
meta_wayland_outputs_init (compositor);
|
||||
meta_wayland_data_device_manager_init (compositor);
|
||||
meta_wayland_data_device_primary_manager_init (compositor);
|
||||
meta_wayland_subsurfaces_init (compositor);
|
||||
meta_wayland_shell_init (compositor);
|
||||
meta_wayland_pointer_gestures_init (compositor);
|
||||
|
Loading…
Reference in New Issue
Block a user