73 lines
2.5 KiB
Diff
73 lines
2.5 KiB
Diff
From 881869b14f48e9c5c91daf2600c52fc522fb739e Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
Date: Fri, 22 Mar 2019 16:12:39 +0100
|
|
Subject: [PATCH 16/23] clipboard: remove vdagent-selection-id usage
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Modernize a bit the code, using gtk_clipboard_get_selection().
|
|
|
|
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
---
|
|
src/vdagent/clipboard.c | 29 ++++++++++++++++++++---------
|
|
1 file changed, 20 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/vdagent/clipboard.c b/src/vdagent/clipboard.c
|
|
index a8d2e91..1e49248 100644
|
|
--- a/src/vdagent/clipboard.c
|
|
+++ b/src/vdagent/clipboard.c
|
|
@@ -32,8 +32,26 @@
|
|
#define SELECTION_COUNT (VD_AGENT_CLIPBOARD_SELECTION_PRIMARY + 1)
|
|
#define TYPE_COUNT (VD_AGENT_CLIPBOARD_IMAGE_JPG + 1)
|
|
|
|
-#define sel_id_from_clip(clipboard) \
|
|
- GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(clipboard), "vdagent-selection-id"))
|
|
+static const GdkAtom sel_atom[] = {
|
|
+ [VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD] = GDK_SELECTION_CLIPBOARD,
|
|
+ [VD_AGENT_CLIPBOARD_SELECTION_PRIMARY] = GDK_SELECTION_PRIMARY,
|
|
+};
|
|
+
|
|
+G_STATIC_ASSERT(G_N_ELEMENTS(sel_atom) == SELECTION_COUNT);
|
|
+
|
|
+static gint sel_id_from_clip(GtkClipboard *clipboard)
|
|
+{
|
|
+ GdkAtom sel = gtk_clipboard_get_selection(clipboard);
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < G_N_ELEMENTS(sel_atom); i++) {
|
|
+ if (sel == sel_atom[i]) {
|
|
+ return i;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ g_return_val_if_reached(0);
|
|
+}
|
|
|
|
enum {
|
|
OWNER_NONE,
|
|
@@ -440,10 +458,6 @@ VDAgentClipboards *vdagent_clipboards_init(struct vdagent_x11 *x11,
|
|
{
|
|
#ifdef WITH_GTK
|
|
guint sel_id;
|
|
- const GdkAtom sel_atom[SELECTION_COUNT] = {
|
|
- GDK_SELECTION_CLIPBOARD, /* VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD */
|
|
- GDK_SELECTION_PRIMARY, /* VD_AGENT_CLIPBOARD_SELECTION_PRIMARY */
|
|
- };
|
|
#endif
|
|
|
|
VDAgentClipboards *c;
|
|
@@ -456,9 +470,6 @@ VDAgentClipboards *vdagent_clipboards_init(struct vdagent_x11 *x11,
|
|
for (sel_id = 0; sel_id < SELECTION_COUNT; sel_id++) {
|
|
GtkClipboard *clipboard = gtk_clipboard_get(sel_atom[sel_id]);
|
|
c->selections[sel_id].clipboard = clipboard;
|
|
- /* enables the use of sel_id_from_clipboard(clipboard) macro */
|
|
- g_object_set_data(G_OBJECT(clipboard), "vdagent-selection-id",
|
|
- GUINT_TO_POINTER(sel_id));
|
|
g_signal_connect(G_OBJECT(clipboard), "owner-change",
|
|
G_CALLBACK(clipboard_owner_change_cb), c);
|
|
}
|
|
--
|
|
2.23.0
|
|
|