[gtk+] wayland: Add skeleton for a GdkClipboardWayland
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] wayland: Add skeleton for a GdkClipboardWayland
- Date: Sun, 3 Dec 2017 04:56:01 +0000 (UTC)
commit 00192266a1d97e1c1e16152236aa9f1e8c33c5d9
Author: Benjamin Otte <otte redhat com>
Date: Sat Dec 2 21:54:36 2017 +0100
wayland: Add skeleton for a GdkClipboardWayland
Creates the source file and a custom subclass and makes sure it's used
by GDK.
gdk/wayland/gdkclipboard-wayland.c | 78 ++++++++++++++++++++++++++++++++++++
gdk/wayland/gdkclipboard-wayland.h | 39 ++++++++++++++++++
gdk/wayland/gdkdevice-wayland.c | 19 +++++++++
gdk/wayland/meson.build | 1 +
4 files changed, 137 insertions(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkclipboard-wayland.c b/gdk/wayland/gdkclipboard-wayland.c
new file mode 100644
index 0000000..cddc37b
--- /dev/null
+++ b/gdk/wayland/gdkclipboard-wayland.c
@@ -0,0 +1,78 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkclipboardprivate.h"
+#include "gdkclipboard-wayland.h"
+
+
+typedef struct _GdkWaylandClipboardClass GdkWaylandClipboardClass;
+
+struct _GdkWaylandClipboard
+{
+ GdkClipboard parent;
+};
+
+struct _GdkWaylandClipboardClass
+{
+ GdkClipboardClass parent_class;
+};
+
+G_DEFINE_TYPE (GdkWaylandClipboard, gdk_wayland_clipboard, GDK_TYPE_CLIPBOARD)
+
+static void
+gdk_wayland_clipboard_finalize (GObject *object)
+{
+ //GdkWaylandClipboard *cb = GDK_WAYLAND_CLIPBOARD (object);
+
+ G_OBJECT_CLASS (gdk_wayland_clipboard_parent_class)->finalize (object);
+}
+
+static void
+gdk_wayland_clipboard_class_init (GdkWaylandClipboardClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ //GdkClipboardClass *clipboard_class = GDK_CLIPBOARD_CLASS (class);
+
+ object_class->finalize = gdk_wayland_clipboard_finalize;
+
+#if 0
+ clipboard_class->claim = gdk_wayland_clipboard_claim;
+ clipboard_class->store_async = gdk_wayland_clipboard_store_async;
+ clipboard_class->store_finish = gdk_wayland_clipboard_store_finish;
+ clipboard_class->read_async = gdk_wayland_clipboard_read_async;
+ clipboard_class->read_finish = gdk_wayland_clipboard_read_finish;
+#endif
+}
+
+static void
+gdk_wayland_clipboard_init (GdkWaylandClipboard *cb)
+{
+}
+
+GdkClipboard *
+gdk_wayland_clipboard_new (GdkDisplay *display)
+{
+ GdkWaylandClipboard *cb;
+
+ cb = g_object_new (GDK_TYPE_WAYLAND_CLIPBOARD,
+ "display", display,
+ NULL);
+
+ return GDK_CLIPBOARD (cb);
+}
diff --git a/gdk/wayland/gdkclipboard-wayland.h b/gdk/wayland/gdkclipboard-wayland.h
new file mode 100644
index 0000000..cf8bd7e
--- /dev/null
+++ b/gdk/wayland/gdkclipboard-wayland.h
@@ -0,0 +1,39 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_CLIPBOARD_WAYLAND_H__
+#define __GDK_CLIPBOARD_WAYLAND_H__
+
+#include "gdk/gdkclipboard.h"
+
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_WAYLAND_CLIPBOARD (gdk_wayland_clipboard_get_type ())
+#define GDK_WAYLAND_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_WAYLAND_CLIPBOARD,
GdkWaylandClipboard))
+#define GDK_IS_WAYLAND_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_WAYLAND_CLIPBOARD))
+
+typedef struct _GdkWaylandClipboard GdkWaylandClipboard;
+
+GType gdk_wayland_clipboard_get_type (void) G_GNUC_CONST;
+
+GdkClipboard * gdk_wayland_clipboard_new (GdkDisplay *display);
+
+
+G_END_DECLS
+
+#endif /* __GDK_CLIPBOARD_WAYLAND_H__ */
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 1fc93ed..908d9bd 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -24,6 +24,8 @@
#include <string.h>
#include <gdk/gdkwindow.h>
#include <gdk/gdktypes.h>
+#include "gdkclipboard-wayland.h"
+#include "gdkclipboardprivate.h"
#include "gdkprivate-wayland.h"
#include "gdkseat-wayland.h"
#include "gdkwayland.h"
@@ -230,6 +232,8 @@ struct _GdkWaylandSeat
uint32_t keyboard_time;
uint32_t keyboard_key_serial;
+ GdkClipboard *clipboard;
+ GdkClipboard *primary_clipboard;
struct gtk_primary_selection_device *primary_data_device;
struct wl_data_device *data_device;
GdkDragContext *drop_context;
@@ -4469,6 +4473,8 @@ gdk_wayland_seat_finalize (GObject *object)
/* FIXME: destroy data_device */
g_clear_object (&seat->keyboard_settings);
g_clear_object (&seat->drop_context);
+ g_clear_object (&seat->clipboard);
+ g_clear_object (&seat->primary_clipboard);
g_hash_table_destroy (seat->touches);
gdk_window_destroy (seat->foreign_dnd_window);
zwp_tablet_seat_v2_destroy (seat->wp_tablet_seat);
@@ -4817,11 +4823,19 @@ _gdk_wayland_display_create_seat (GdkWaylandDisplay *display_wayland,
seat->wl_seat);
gtk_primary_selection_device_add_listener (seat->primary_data_device,
&primary_selection_device_listener, seat);
+ seat->primary_clipboard = gdk_wayland_clipboard_new (display);
+ }
+ else
+ {
+ /* If the compositor doesn't support primary clipboard,
+ * just do it local-only */
+ seat->primary_clipboard = gdk_clipboard_new (display);
}
seat->data_device =
wl_data_device_manager_get_data_device (display_wayland->data_device_manager,
seat->wl_seat);
+ seat->clipboard = gdk_wayland_clipboard_new (display);
seat->drop_context = _gdk_wayland_drop_context_new (display,
seat->data_device);
wl_data_device_add_listener (seat->data_device,
@@ -4845,6 +4859,11 @@ _gdk_wayland_display_create_seat (GdkWaylandDisplay *display_wayland,
seat);
}
+ if (display->clipboard == NULL)
+ display->clipboard = g_object_ref (seat->clipboard);
+ if (display->primary_clipboard == NULL)
+ display->primary_clipboard = g_object_ref (seat->primary_clipboard);
+
gdk_display_add_seat (display, GDK_SEAT (seat));
}
diff --git a/gdk/wayland/meson.build b/gdk/wayland/meson.build
index 434d290..c395631 100644
--- a/gdk/wayland/meson.build
+++ b/gdk/wayland/meson.build
@@ -1,5 +1,6 @@
gdk_wayland_sources = files([
'gdkapplaunchcontext-wayland.c',
+ 'gdkclipboard-wayland.c',
'gdkcursor-wayland.c',
'gdkdevice-wayland.c',
'gdkdisplay-wayland.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]