[gtk+] selection: Remove #ifdef WAYLAND
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] selection: Remove #ifdef WAYLAND
- Date: Wed, 15 Nov 2017 18:21:53 +0000 (UTC)
commit fb94f79094745a0e3fc64d5d56cea1637a8fdb73
Author: Benjamin Otte <otte redhat com>
Date: Tue Nov 14 03:56:35 2017 +0100
selection: Remove #ifdef WAYLAND
Instead, turn the functions into backend API:
gdk_broadway_display_add_selection_targets()
gdk_broadway_display_clear_selection_targets()
Remove the old per-backend functions, too.
gdk/broadway/gdkdisplay-broadway.c | 2 +
gdk/broadway/gdkprivate-broadway.h | 7 ++++
gdk/broadway/gdkselection-broadway.c | 15 +++++++++
gdk/gdkdisplayprivate.h | 7 ++++
gdk/gdkselection.c | 21 +++++++++++++
gdk/gdkselection.h | 10 ++++++
gdk/quartz/gdkdisplay-quartz.c | 2 +
gdk/wayland/gdkdisplay-wayland.c | 2 +
gdk/wayland/gdkprivate-wayland.h | 7 ++++
gdk/wayland/gdkselection-wayland.c | 16 +++++-----
gdk/wayland/gdkwayland.h | 1 -
gdk/wayland/gdkwaylandselection.h | 54 ----------------------------------
gdk/wayland/meson.build | 1 -
gdk/win32/gdkdisplay-win32.c | 2 +
gdk/win32/gdkprivate-win32.h | 7 ++++
gdk/win32/gdkselection-win32.c | 15 +++++++--
gdk/win32/gdkwin32misc.h | 6 ----
gdk/x11/gdkdisplay-x11.c | 2 +
gdk/x11/gdkprivate-x11.h | 7 ++++
gdk/x11/gdkselection-x11.c | 15 +++++++++
gtk/gtkselection.c | 43 +++++----------------------
21 files changed, 133 insertions(+), 109 deletions(-)
---
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index bac7a97..2b69bc8 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -357,6 +357,8 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->set_selection_owner = _gdk_broadway_display_set_selection_owner;
display_class->send_selection_notify = _gdk_broadway_display_send_selection_notify;
display_class->get_selection_property = _gdk_broadway_display_get_selection_property;
+ display_class->clear_selection_targets = gdk_broadway_display_clear_selection_targets;
+ display_class->add_selection_targets = gdk_broadway_display_add_selection_targets;
display_class->convert_selection = _gdk_broadway_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;
diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h
index 4b1ee65..8a82d47 100644
--- a/gdk/broadway/gdkprivate-broadway.h
+++ b/gdk/broadway/gdkprivate-broadway.h
@@ -130,6 +130,13 @@ gint _gdk_broadway_display_get_selection_property (GdkDisplay *display,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
+void gdk_broadway_display_clear_selection_targets (GdkDisplay *display,
+ GdkAtom selection);
+void gdk_broadway_display_add_selection_targets (GdkDisplay *display,
+ GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets);
void _gdk_broadway_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
diff --git a/gdk/broadway/gdkselection-broadway.c b/gdk/broadway/gdkselection-broadway.c
index b62e11e..1f3813b 100644
--- a/gdk/broadway/gdkselection-broadway.c
+++ b/gdk/broadway/gdkselection-broadway.c
@@ -159,6 +159,21 @@ _gdk_broadway_display_get_selection_property (GdkDisplay *display,
}
void
+gdk_broadway_display_clear_selection_targets (GdkDisplay *display,
+ GdkAtom selection)
+{
+}
+
+void
+gdk_broadway_display_add_selection_targets (GdkDisplay *display,
+ GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets)
+{
+}
+
+void
_gdk_broadway_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 493f730..96f2814 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -186,6 +186,13 @@ struct _GdkDisplayClass
guchar **data,
GdkAtom *type,
gint *format);
+ void (*clear_selection_targets)(GdkDisplay *display,
+ GdkAtom selection);
+ void (*add_selection_targets) (GdkDisplay *display,
+ GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets);
void (*convert_selection) (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c
index 302a76a..9eb60f5 100644
--- a/gdk/gdkselection.c
+++ b/gdk/gdkselection.c
@@ -329,3 +329,24 @@ gdk_utf8_to_string_target (const gchar *str)
return GDK_DISPLAY_GET_CLASS (display)->utf8_to_string_target (display, str);
}
+
+void
+gdk_selection_clear_targets (GdkDisplay *display,
+ GdkAtom selection)
+{
+}
+
+void
+gdk_selection_add_targets (GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint n_targets)
+{
+ GdkDisplay *display;
+
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ display = gdk_window_get_display (window);
+
+ GDK_DISPLAY_GET_CLASS (display)->add_selection_targets (display, window, selection, targets, n_targets);
+}
diff --git a/gdk/gdkselection.h b/gdk/gdkselection.h
index 3969825..54858f5 100644
--- a/gdk/gdkselection.h
+++ b/gdk/gdkselection.h
@@ -209,6 +209,16 @@ void gdk_selection_send_notify_for_display (GdkDisplay *display,
GdkAtom property,
guint32 time_);
+GDK_AVAILABLE_IN_3_94
+void gdk_selection_clear_targets (GdkDisplay *display,
+ GdkAtom selection);
+
+GDK_AVAILABLE_IN_3_94
+void gdk_selection_add_targets (GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint n_targets);
+
G_END_DECLS
#endif /* __GDK_SELECTION_H__ */
diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c
index 07d55b8..206a84a 100644
--- a/gdk/quartz/gdkdisplay-quartz.c
+++ b/gdk/quartz/gdkdisplay-quartz.c
@@ -280,6 +280,8 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
display_class->get_selection_owner = _gdk_quartz_display_get_selection_owner;
display_class->set_selection_owner = _gdk_quartz_display_set_selection_owner;
display_class->get_selection_property = _gdk_quartz_display_get_selection_property;
+ display_class->clear_selection_targets = gdk_quartz_display_clear_selection_targets;
+ display_class->add_selection_targets = gdk_quartz_display_add_selection_targets;
display_class->convert_selection = _gdk_quartz_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target;
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index f74dd2a..d8dc8cb 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -1043,6 +1043,8 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->set_selection_owner = _gdk_wayland_display_set_selection_owner;
display_class->send_selection_notify = _gdk_wayland_display_send_selection_notify;
display_class->get_selection_property = _gdk_wayland_display_get_selection_property;
+ display_class->clear_selection_targets = gdk_wayland_display_clear_selection_targets;
+ display_class->add_selection_targets = gdk_wayland_display_add_selection_targets;
display_class->convert_selection = _gdk_wayland_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index 64ea4e0..055597e 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -149,6 +149,13 @@ gint _gdk_wayland_display_get_selection_property (GdkDisplay *display,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
+void gdk_wayland_display_clear_selection_targets (GdkDisplay *display,
+ GdkAtom selection);
+void gdk_wayland_display_add_selection_targets (GdkDisplay *display,
+ GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets);
void _gdk_wayland_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index b98caa8..b60a99a 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -966,7 +966,7 @@ data_source_dnd_finished (void *data,
g_signal_emit_by_name (context, "dnd-finished");
gdk_selection_owner_set (NULL, atoms[ATOM_DND], GDK_CURRENT_TIME, TRUE);
- gdk_wayland_selection_clear_targets (display, atoms[ATOM_DND]);
+ gdk_wayland_display_clear_selection_targets (display, atoms[ATOM_DND]);
}
static void
@@ -1486,12 +1486,12 @@ _gdk_wayland_display_utf8_to_string_target (GdkDisplay *display,
}
void
-gdk_wayland_selection_add_targets (GdkWindow *window,
- GdkAtom selection,
- guint ntargets,
- GdkAtom *targets)
+gdk_wayland_display_add_selection_targets (GdkDisplay *display,
+ GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets)
{
- GdkDisplay *display = gdk_window_get_display (window);
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
gpointer data_source;
guint i;
@@ -1532,8 +1532,8 @@ gdk_wayland_selection_add_targets (GdkWindow *window,
}
void
-gdk_wayland_selection_clear_targets (GdkDisplay *display,
- GdkAtom selection)
+gdk_wayland_display_clear_selection_targets (GdkDisplay *display,
+ GdkAtom selection)
{
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
diff --git a/gdk/wayland/gdkwayland.h b/gdk/wayland/gdkwayland.h
index 2b79295..14f25d1 100644
--- a/gdk/wayland/gdkwayland.h
+++ b/gdk/wayland/gdkwayland.h
@@ -32,7 +32,6 @@
#include <gdk/wayland/gdkwaylanddevice.h>
#include <gdk/wayland/gdkwaylanddisplay.h>
#include <gdk/wayland/gdkwaylandmonitor.h>
-#include <gdk/wayland/gdkwaylandselection.h>
#include <gdk/wayland/gdkwaylandwindow.h>
#include <gdk/wayland/gdkwaylandglcontext.h>
diff --git a/gdk/wayland/meson.build b/gdk/wayland/meson.build
index 0914301..434d290 100644
--- a/gdk/wayland/meson.build
+++ b/gdk/wayland/meson.build
@@ -19,7 +19,6 @@ gdk_wayland_public_headers = files([
'gdkwaylanddisplay.h',
'gdkwaylandglcontext.h',
'gdkwaylandmonitor.h',
- 'gdkwaylandselection.h',
'gdkwaylandwindow.h'
])
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index 04b2f77..bdcfa66 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -1268,6 +1268,8 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
display_class->set_selection_owner = _gdk_win32_display_set_selection_owner;
display_class->send_selection_notify = _gdk_win32_display_send_selection_notify;
display_class->get_selection_property = _gdk_win32_display_get_selection_property;
+ display_class->clear_selection_targets = gdk_win32_display_clear_selection_targets;
+ display_class->add_selection_targets = gdk_win32_display_add_selection_targets;
display_class->convert_selection = _gdk_win32_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_win32_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_win32_display_utf8_to_string_target;
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index cb74e66..fd9b67e 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -439,6 +439,13 @@ gint _gdk_win32_display_get_selection_property (GdkDisplay *display,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
+void gdk_win32_display_clear_selection_targets (GdkDisplay *display,
+ GdkAtom selection);
+void gdk_win32_display_add_selection_targets (GdkDisplay *display,
+ GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets);
void _gdk_win32_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c
index 131c0bf..9de7226 100644
--- a/gdk/win32/gdkselection-win32.c
+++ b/gdk/win32/gdkselection-win32.c
@@ -1134,6 +1134,12 @@ gdk_free_compound_text (guchar *ctext)
g_return_if_fail (ctext == NULL);
}
+void
+gdk_win32_display_clear_selection_targets (GdkDisplay *display,
+ GdkAtom selection)
+{
+}
+
/* This function is called from gtk_selection_add_target() and
* gtk_selection_add_targets() in gtkselection.c. It is this function
* that takes care of setting those clipboard formats for which we use
@@ -1142,10 +1148,11 @@ gdk_free_compound_text (guchar *ctext)
*/
void
-gdk_win32_selection_add_targets (GdkWindow *owner,
- GdkAtom selection,
- gint n_targets,
- GdkAtom *targets)
+gdk_win32_display_add_selection_targets (GdkDisplay *display,
+ GdkWindow *owner,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets)
{
HWND hwnd = NULL;
gboolean has_image = FALSE;
diff --git a/gdk/win32/gdkwin32misc.h b/gdk/win32/gdkwin32misc.h
index dadb4e2..1bc11f5 100644
--- a/gdk/win32/gdkwin32misc.h
+++ b/gdk/win32/gdkwin32misc.h
@@ -82,12 +82,6 @@ GDK_AVAILABLE_IN_ALL
HGDIOBJ gdk_win32_window_get_handle (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
-void gdk_win32_selection_add_targets (GdkWindow *owner,
- GdkAtom selection,
- gint n_targets,
- GdkAtom *targets);
-
-GDK_AVAILABLE_IN_ALL
GdkWindow * gdk_win32_window_foreign_new_for_display (GdkDisplay *display,
HWND anid);
GDK_AVAILABLE_IN_ALL
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 5a560d6..c89753a 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -3193,6 +3193,8 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->set_selection_owner = _gdk_x11_display_set_selection_owner;
display_class->send_selection_notify = _gdk_x11_display_send_selection_notify;
display_class->get_selection_property = _gdk_x11_display_get_selection_property;
+ display_class->clear_selection_targets = gdk_x11_display_clear_selection_targets;
+ display_class->add_selection_targets = gdk_x11_display_add_selection_targets;
display_class->convert_selection = _gdk_x11_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index ab43c39..0cc8d36 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -171,6 +171,13 @@ gint _gdk_x11_display_get_selection_property (GdkDisplay *display,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
+void gdk_x11_display_clear_selection_targets (GdkDisplay *display,
+ GdkAtom selection);
+void gdk_x11_display_add_selection_targets (GdkDisplay *display,
+ GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets);
void _gdk_x11_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c
index ede4817..fe977ae 100644
--- a/gdk/x11/gdkselection-x11.c
+++ b/gdk/x11/gdkselection-x11.c
@@ -313,6 +313,21 @@ _gdk_x11_display_get_selection_property (GdkDisplay *display,
}
void
+gdk_x11_display_clear_selection_targets (GdkDisplay *display,
+ GdkAtom selection)
+{
+}
+
+void
+gdk_x11_display_add_selection_targets (GdkDisplay *display,
+ GdkWindow *window,
+ GdkAtom selection,
+ GdkAtom *targets,
+ guint ntargets)
+{
+}
+
+void
_gdk_x11_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index 611c09e..2ab9dc7 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -878,10 +878,7 @@ gtk_selection_clear_targets (GtkWidget *widget,
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (selection != GDK_NONE);
-#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
- gdk_wayland_selection_clear_targets (gtk_widget_get_display (widget), selection);
-#endif
+ gdk_selection_clear_targets (gtk_widget_get_display (widget), selection);
lists = g_object_get_data (G_OBJECT (widget), gtk_selection_handler_key);
@@ -927,13 +924,7 @@ gtk_selection_add_target (GtkWidget *widget,
list = gtk_selection_target_list_get (widget, selection);
gtk_target_list_add (list, target, 0, info);
-#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
- gdk_wayland_selection_add_targets (gtk_widget_get_window (widget), selection, 1, &target);
-#endif
-#ifdef GDK_WINDOWING_WIN32
- gdk_win32_selection_add_targets (gtk_widget_get_window (widget), selection, 1, &target);
-#endif
+ gdk_selection_add_targets (gtk_widget_get_window (widget), selection, &target, 1);
}
/**
@@ -953,6 +944,8 @@ gtk_selection_add_targets (GtkWidget *widget,
guint ntargets)
{
GtkTargetList *list;
+ GdkAtom *atoms = g_new (GdkAtom, ntargets);
+ guint i;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (selection != GDK_NONE);
@@ -961,31 +954,11 @@ gtk_selection_add_targets (GtkWidget *widget,
list = gtk_selection_target_list_get (widget, selection);
gtk_target_list_add_table (list, targets, ntargets);
-#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
- {
- GdkAtom *atoms = g_new (GdkAtom, ntargets);
- guint i;
+ for (i = 0; i < ntargets; i++)
+ atoms[i] = gdk_atom_intern (targets[i].target, FALSE);
- for (i = 0; i < ntargets; i++)
- atoms[i] = gdk_atom_intern (targets[i].target, FALSE);
-
- gdk_wayland_selection_add_targets (gtk_widget_get_window (widget), selection, ntargets, atoms);
- g_free (atoms);
- }
-#endif
-
-#ifdef GDK_WINDOWING_WIN32
- {
- int i;
- GdkAtom *atoms = g_new (GdkAtom, ntargets);
-
- for (i = 0; i < ntargets; ++i)
- atoms[i] = gdk_atom_intern (targets[i].target, FALSE);
- gdk_win32_selection_add_targets (gtk_widget_get_window (widget), selection, ntargets, atoms);
- g_free (atoms);
- }
-#endif
+ gdk_selection_add_targets (gtk_widget_get_window (widget), selection, atoms, ntargets);
+ g_free (atoms);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]