From: Benjamin Otte Date: Mon, 30 Apr 2018 11:14:29 +0000 (+0200) Subject: dnd: Add a private struct X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~22^2~336 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=eb9105aceaba6d8fa1e646a633b374c65e0d65c4;p=gtk4.git dnd: Add a private struct And put member veriables into it. Also fix backends to use accessors instead of direct access. --- diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index d7a58c9850..545e7cb3ca 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -35,6 +35,14 @@ #include "gdkenumtypes.h" #include "gdkeventsprivate.h" +typedef struct _GdkDragContextPrivate GdkDragContextPrivate; + +struct _GdkDragContextPrivate +{ + GdkDisplay *display; + GdkDevice *device; +}; + static struct { GdkDragAction action; const gchar *name; @@ -69,6 +77,8 @@ static GParamSpec *properties[N_PROPERTIES] = { NULL, }; static guint signals[N_SIGNALS] = { 0 }; static GList *contexts = NULL; +G_DEFINE_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT) + /** * SECTION:dnd * @title: Drag And Drop @@ -103,7 +113,11 @@ static GList *contexts = NULL; GdkDisplay * gdk_drag_context_get_display (GdkDragContext *context) { - return context->display; + GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + + g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); + + return priv->display; } /** @@ -214,13 +228,13 @@ gdk_drag_context_get_dest_surface (GdkDragContext *context) GdkDevice * gdk_drag_context_get_device (GdkDragContext *context) { + GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); - return context->device; + return priv->device; } -G_DEFINE_TYPE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT) - static void gdk_drag_context_init (GdkDragContext *context) { @@ -234,6 +248,7 @@ gdk_drag_context_set_property (GObject *gobject, GParamSpec *pspec) { GdkDragContext *context = GDK_DRAG_CONTEXT (gobject); + GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); switch (prop_id) { @@ -244,9 +259,9 @@ gdk_drag_context_set_property (GObject *gobject, break; case PROP_DEVICE: - context->device = g_value_dup_object (value); - g_assert (context->device != NULL); - context->display = gdk_device_get_display (context->device); + priv->device = g_value_dup_object (value); + g_assert (priv->device != NULL); + priv->display = gdk_device_get_display (priv->device); break; default: @@ -262,6 +277,7 @@ gdk_drag_context_get_property (GObject *gobject, GParamSpec *pspec) { GdkDragContext *context = GDK_DRAG_CONTEXT (gobject); + GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); switch (prop_id) { @@ -270,11 +286,11 @@ gdk_drag_context_get_property (GObject *gobject, break; case PROP_DEVICE: - g_value_set_object (value, context->device); + g_value_set_object (value, priv->device); break; case PROP_DISPLAY: - g_value_set_object (value, context->display); + g_value_set_object (value, priv->display); break; case PROP_FORMATS: diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h index 5bb20e7b1c..9778bc00e0 100644 --- a/gdk/gdkdndprivate.h +++ b/gdk/gdkdndprivate.h @@ -80,8 +80,6 @@ struct _GdkDragContext { GObject parent_instance; /*< private >*/ - GdkDisplay *display; - gboolean is_source; GdkSurface *source_surface; GdkSurface *dest_surface; @@ -93,8 +91,6 @@ struct _GdkDragContext { GdkDragAction suggested_action; GdkDragAction action; - GdkDevice *device; - guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */ }; diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index c82c8381af..db6f4e833a 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -2239,7 +2239,7 @@ gdk_win32_drag_context_find_window (GdkDragContext *context, g_object_ref (dest_surface); } else - dest_surface = gdk_win32_surface_foreign_new_for_display (context->display, a.result); + dest_surface = gdk_win32_surface_foreign_new_for_display (gdk_drag_context_get_display (context), a.result); if (use_ole2_dnd) *protocol = GDK_DRAG_PROTO_OLE2; diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index 54138c047f..93c39bf532 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -2140,7 +2140,7 @@ gdk_x11_drag_context_find_surface (GdkDragContext *context, gint y_root, GdkDragProtocol *protocol) { - GdkX11Screen *screen_x11 = GDK_X11_SCREEN(GDK_X11_DISPLAY (context->display)->screen); + GdkX11Screen *screen_x11; GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context); GdkSurfaceCache *window_cache; GdkDisplay *display; @@ -2148,6 +2148,7 @@ gdk_x11_drag_context_find_surface (GdkDragContext *context, GdkSurface *dest_surface; display = gdk_drag_context_get_display (context); + screen_x11 = GDK_X11_SCREEN(GDK_X11_DISPLAY (display)->screen); window_cache = drag_context_find_window_cache (context_x11, display); @@ -2811,7 +2812,7 @@ drag_context_grab (GdkDragContext *context) g_set_object (&x11_context->grab_seat, seat); - gdk_x11_display_error_trap_push (context->display); + gdk_x11_display_error_trap_push (display); for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i) { @@ -2863,7 +2864,7 @@ drag_context_grab (GdkDragContext *context) } } - gdk_x11_display_error_trap_pop_ignored (context->display); + gdk_x11_display_error_trap_pop_ignored (display); return TRUE; }