summaryrefslogtreecommitdiff
path: root/gdk/x11/gdkdnd-x11.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-05-13 17:03:57 +0200
committerBenjamin Otte <otte@redhat.com>2018-06-18 23:49:19 +0200
commit2e27967814276fb94d2c4d1982bc504a26282188 (patch)
treecd7d4cab45ac51fa5e0871d7a168cd1ac8ceaebf /gdk/x11/gdkdnd-x11.c
parent18c3b725b4b2e477ca4d6d8380203ef9ba04b8d6 (diff)
downloadgtk+-2e27967814276fb94d2c4d1982bc504a26282188.tar.gz
dnd: Make actions a private member variable
Use a setter in the backends.
Diffstat (limited to 'gdk/x11/gdkdnd-x11.c')
-rw-r--r--gdk/x11/gdkdnd-x11.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index 5542dc6ada..42761dc6e5 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -1527,6 +1527,7 @@ xdnd_read_actions (GdkX11DragContext *context_x11)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
GdkDisplay *display = gdk_drag_context_get_display (context);
+ GdkDragAction actions = GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK;
Atom type;
int format;
gulong nitems, after;
@@ -1549,12 +1550,12 @@ xdnd_read_actions (GdkX11DragContext *context_x11)
&after, &data) == Success &&
type == XA_ATOM)
{
- atoms = (Atom *)data;
+ actions = 0;
- context->actions = 0;
+ atoms = (Atom *)data;
for (i = 0; i < nitems; i++)
- context->actions |= xdnd_action_from_atom (display, atoms[i]);
+ actions |= xdnd_action_from_atom (display, atoms[i]);
context_x11->xdnd_have_actions = TRUE;
@@ -1562,20 +1563,20 @@ xdnd_read_actions (GdkX11DragContext *context_x11)
if (GDK_DISPLAY_DEBUG_CHECK (display, DND))
{
GString *action_str = g_string_new (NULL);
- if (context->actions & GDK_ACTION_MOVE)
+ GdkDragAction actions = gdk_drag_context_get_actions (context);
+ if (actions & GDK_ACTION_MOVE)
g_string_append(action_str, "MOVE ");
- if (context->actions & GDK_ACTION_COPY)
+ if (actions & GDK_ACTION_COPY)
g_string_append(action_str, "COPY ");
- if (context->actions & GDK_ACTION_LINK)
+ if (actions & GDK_ACTION_LINK)
g_string_append(action_str, "LINK ");
- if (context->actions & GDK_ACTION_ASK)
+ if (actions & GDK_ACTION_ASK)
g_string_append(action_str, "ASK ");
g_message("Xdnd actions = %s", action_str->str);
g_string_free (action_str, TRUE);
}
#endif /* G_ENABLE_DEBUG */
-
}
if (data)
@@ -1595,10 +1596,12 @@ xdnd_read_actions (GdkX11DragContext *context_x11)
if (source_context)
{
- context->actions = source_context->actions;
+ actions = gdk_drag_context_get_actions (source_context);
context_x11->xdnd_have_actions = TRUE;
}
}
+
+ gdk_drag_context_set_actions (context, actions, gdk_drag_context_get_suggested_action (context));
}
/* We have to make sure that the XdndActionList we keep internally
@@ -1899,6 +1902,7 @@ xdnd_position_filter (const XEvent *xevent,
GdkX11Display *display_x11;
GdkDragContext *context;
GdkX11DragContext *context_x11;
+ GdkDragAction suggested_action;
if (!event->any.surface ||
gdk_surface_get_surface_type (event->any.surface) == GDK_SURFACE_FOREIGN)
@@ -1930,10 +1934,15 @@ xdnd_position_filter (const XEvent *xevent,
event->dnd.time = time;
- context->suggested_action = xdnd_action_from_atom (display, action);
-
- if (!context_x11->xdnd_have_actions)
- context->actions = context->suggested_action;
+ suggested_action = xdnd_action_from_atom (display, action);
+ if (context_x11->xdnd_have_actions)
+ gdk_drag_context_set_actions (context,
+ gdk_drag_context_get_actions (context),
+ suggested_action);
+ else
+ gdk_drag_context_set_actions (context,
+ suggested_action,
+ suggested_action);
event->dnd.x_root = x_root / impl->surface_scale;
event->dnd.y_root = y_root / impl->surface_scale;
@@ -2219,7 +2228,7 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
if (context_x11->drag_surface)
move_drag_surface (context, x_root, y_root);
- context->actions = possible_actions;
+ gdk_drag_context_set_actions (context, possible_actions, suggested_action);
if (protocol == GDK_DRAG_PROTO_XDND && context_x11->version == 0)
{
@@ -2261,7 +2270,7 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
if (dest_context)
{
- dest_context->actions = context->actions;
+ gdk_drag_context_set_actions (dest_context, possible_actions, suggested_action);
GDK_X11_DRAG_CONTEXT (dest_context)->xdnd_have_actions = TRUE;
}
}
@@ -2294,7 +2303,6 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
default:
break;
}
- context->suggested_action = suggested_action;
}
else
{
@@ -2312,10 +2320,6 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
g_signal_emit_by_name (context, "action-changed", context->action);
}
}
- else
- {
- context->suggested_action = suggested_action;
- }
/* Send a drag-motion event */
@@ -2342,7 +2346,7 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
*/
if (gdk_content_formats_contain_mime_type (formats, "application/x-rootwindow-drop") ||
gdk_content_formats_contain_mime_type (formats, "application/x-rootwin-drop"))
- context->action = context->suggested_action;
+ context->action = gdk_drag_context_get_suggested_action (context);
else
context->action = 0;