mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
dnd: Add a private struct
And put member veriables into it. Also fix backends to use accessors instead of direct access.
This commit is contained in:
parent
8366ef71c0
commit
eb9105acea
34
gdk/gdkdnd.c
34
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:
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user