Use a setter in the backends.
GdkDevice *device;
#endif
GdkContentFormats *formats;
+ GdkDragAction actions;
+ GdkDragAction suggested_action;
};
static struct {
GdkDragAction
gdk_drag_context_get_actions (GdkDragContext *context)
{
+ GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
+
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
- return context->actions;
+ return priv->actions;
}
/**
GdkDragAction
gdk_drag_context_get_suggested_action (GdkDragContext *context)
{
+ GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
+
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), 0);
- return context->suggested_action;
+ return priv->suggested_action;
}
/**
return g_task_propagate_boolean (G_TASK (result), error);
}
+void
+gdk_drag_context_set_actions (GdkDragContext *context,
+ GdkDragAction actions,
+ GdkDragAction suggested_action)
+{
+ GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
+
+ priv->actions = actions;
+ priv->suggested_action = suggested_action;
+}
+
/**
* gdk_drag_context_get_drag_surface:
* @context: a #GdkDragContext
{
return (action & (action - 1)) == 0;
}
-
GdkSurface *drag_surface;
GdkContentProvider *content;
- GdkDragAction actions;
- GdkDragAction suggested_action;
GdkDragAction action;
guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
void gdk_drag_context_set_cursor (GdkDragContext *context,
GdkCursor *cursor);
+void gdk_drag_context_set_actions (GdkDragContext *context,
+ GdkDragAction actions,
+ GdkDragAction suggested_action);
+
void gdk_drag_context_cancel (GdkDragContext *context,
GdkDragCancelReason reason);
gboolean gdk_drag_context_handle_source_event (GdkEvent *event);
static void
update_context_from_dragging_info (id <NSDraggingInfo> sender)
{
+ GdkDragAction action;
+
g_assert (current_context != NULL);
GDK_QUARTZ_DRAG_CONTEXT (current_context)->dragging_info = sender;
- current_context->suggested_action = drag_operation_to_drag_action ([sender draggingSourceOperationMask]);
- current_context->actions = current_context->suggested_action;
+ action = drag_operation_to_drag_action ([sender draggingSourceOperationMask]);
+ gdk_drag_context_set_actions (current_context, action, action);
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
if (drop_context == NULL)
return;
- drop_context->actions = gdk_wayland_actions_to_gdk_actions (source_actions);
+ gdk_drag_context_set_actions (drop_context,
+ gdk_wayland_actions_to_gdk_actions (source_actions),
+ gdk_drag_context_get_suggested_action (drop_context));
_gdk_wayland_drag_context_emit_event (drop_context, GDK_DRAG_MOTION,
GDK_CURRENT_TIME);
if (drop_context == NULL)
return;
- drop_context->suggested_action = gdk_wayland_actions_to_gdk_actions (action);
+ gdk_drag_context_set_actions (drop_context,
+ gdk_drag_context_get_actions (drop_context),
+ gdk_wayland_actions_to_gdk_actions (action));
_gdk_wayland_drag_context_emit_event (drop_context, GDK_DRAG_MOTION,
GDK_CURRENT_TIME);
return dnd_actions;
}
-void
-gdk_wayland_drag_context_set_action (GdkDragContext *context,
- GdkDragAction action)
-{
- context->suggested_action = context->action = action;
-}
-
static void
gdk_wayland_drag_context_drag_abort (GdkDragContext *context,
guint32 time)
contexts = g_list_prepend (contexts, context);
context->action = GDK_ACTION_COPY;
- context->suggested_action = GDK_ACTION_COPY;
- context->actions = GDK_ACTION_COPY | GDK_ACTION_MOVE;
}
static GdkSurface *
gdouble x,
gdouble y);
-void gdk_wayland_drag_context_set_action (GdkDragContext *context,
- GdkDragAction action);
-
GdkDragContext * gdk_wayland_drag_context_lookup_by_data_source (struct wl_data_source *source);
GdkDragContext * gdk_wayland_drag_context_lookup_by_source_surface (GdkSurface *surface);
struct wl_data_source * gdk_wayland_drag_context_get_data_source (GdkDragContext *context);
context->is_source = TRUE;
g_set_object (&context->source_surface, source_surface);
- context->actions = actions;
+ gdk_drag_context_set_actions (context, actions, actions);
context_win32->protocol = protocol;
gdk_content_formats_unref (formats);
tmp_event->dnd.time = time;
gdk_event_set_device (tmp_event, gdk_drag_context_get_device (current_dest_drag));
- current_dest_drag->suggested_action = action;
+ gdk_drag_context_set_actions (current_dest_drag, action, action);
tmp_event->dnd.x_root = x_root;
tmp_event->dnd.y_root = y_root;
g_return_val_if_fail (context != NULL, FALSE);
- context->actions = possible_actions;
-
GDK_NOTE (DND, g_print ("gdk_win32_drag_context_drag_motion: @ %+d:%+d %s suggested=%s, possible=%s\n"
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
x_root, y_root,
_gdk_win32_drag_action_to_string (suggested_action),
_gdk_win32_drag_action_to_string (possible_actions),
context,
- _gdk_win32_drag_action_to_string (context->actions),
- _gdk_win32_drag_action_to_string (context->suggested_action),
+ _gdk_win32_drag_action_to_string (gdk_drag_context_get_actions (context)),
+ _gdk_win32_drag_action_to_string (gdk_drag_context_get_suggested_action (context)),
_gdk_win32_drag_action_to_string (context->action)));
context_win32 = GDK_WIN32_DRAG_CONTEXT (context);
dest_surface);
if (dest_context)
- dest_context->actions = context->actions;
+ gdk_drag_context_set_actions (dest_context, possible_actions, suggested_action);
- context->suggested_action = suggested_action;
+ gdk_drag_context_set_actions (context, possible_actions, suggested_action);
}
else
{
default:
break;
}
- context->suggested_action = suggested_action;
+ gdk_drag_context_set_actions (context, possible_actions, suggested_action);
}
else
{
context->dest_surface = NULL;
- context->action = 0;
+ gdk_drag_context_set_actions (context, 0, 0);
}
GDK_NOTE (DND, g_print ("gdk_dnd_handle_drag_status: 0x%p\n",
GDK_NOTE (DND, g_print (" returning TRUE\n"
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
context,
- _gdk_win32_drag_action_to_string (context->actions),
- _gdk_win32_drag_action_to_string (context->suggested_action),
+ _gdk_win32_drag_action_to_string (gdk_drag_context_get_actions (context)),
+ _gdk_win32_drag_action_to_string (gdk_drag_context_get_suggested_action (context)),
_gdk_win32_drag_action_to_string (context->action)));
return TRUE;
}
GDK_NOTE (DND, g_print (" returning FALSE\n"
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
context,
- _gdk_win32_drag_action_to_string (context->actions),
- _gdk_win32_drag_action_to_string (context->suggested_action),
+ _gdk_win32_drag_action_to_string (gdk_drag_context_get_actions (context)),
+ _gdk_win32_drag_action_to_string (gdk_drag_context_get_suggested_action (context)),
_gdk_win32_drag_action_to_string (context->action)));
return FALSE;
}
context->is_source = FALSE;
g_set_object (&context->source_surface, source_surface);
g_set_object (&context->dest_surface, dest_surface);
- context->actions = actions;
+ gdk_drag_context_set_actions (context, actions, actions);
context_win32->protocol = protocol;
gdk_content_formats_unref (formats);
ctx->context = context;
context->action = GDK_ACTION_MOVE;
- context->suggested_action = get_suggested_action (context_win32, grfKeyState);
+ gdk_drag_context_set_actions (context,
+ GDK_ACTION_COPY | GDK_ACTION_MOVE,
+ get_suggested_action (context_win32, grfKeyState));
set_data_object (&ctx->data_object, pDataObj);
pt_x = pt.x / context_win32->scale + _gdk_offset_x;
pt_y = pt.y / context_win32->scale + _gdk_offset_y;
gint pt_x = pt.x / context_win32->scale + _gdk_offset_x;
gint pt_y = pt.y / context_win32->scale + _gdk_offset_y;
- ctx->context->suggested_action = get_suggested_action (context_win32, grfKeyState);
+ gdk_drag_context_set_actions (ctx->context,
+ gdk_drag_context_get_actions (ctx->context),
+ get_suggested_action (context_win32, grfKeyState));
- GDK_NOTE (DND, g_print ("idroptarget_dragover %p @ %d : %d (raw %ld : %ld), suggests %d action S_OK\n", This, pt_x, pt_y, pt.x, pt.y, ctx->context->suggested_action));
+ GDK_NOTE (DND, g_print ("idroptarget_dragover %p @ %d : %d (raw %ld : %ld), suggests %d action S_OK\n", This, pt_x, pt_y, pt.x, pt.y, gdk_drag_context_get_suggested_action (ctx->context)));
if (pt_x != context_win32->last_x ||
pt_y != context_win32->last_y ||
return E_POINTER;
}
- ctx->context->suggested_action = get_suggested_action (context_win32, grfKeyState);
+ gdk_drag_context_set_actions (ctx->context,
+ gdk_drag_context_get_actions (ctx->context),
+ get_suggested_action (context_win32, grfKeyState));
dnd_event_emit (GDK_DROP_START, ctx->context, pt_x, pt_y, ctx->context->dest_surface);
context_win32 = GDK_WIN32_DROP_CONTEXT (context);
/* WM_DROPFILES drops are always file names */
-
- context->suggested_action = GDK_ACTION_COPY;
+ gdk_drag_context_set_actions (context, GDK_ACTION_COPY, GDK_ACTION_COPY);
current_dest_drag = context;
hdrop = (HANDLE) msg->wParam;
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
_gdk_win32_drag_action_to_string (action),
context,
- _gdk_win32_drag_action_to_string (context->actions),
- _gdk_win32_drag_action_to_string (context->suggested_action),
+ _gdk_win32_drag_action_to_string (gdk_drag_context_get_actions (context)),
+ _gdk_win32_drag_action_to_string (gdk_drag_context_get_suggested_action (context)),
_gdk_win32_drag_action_to_string (context->action)));
context->action = action;
context->source_surface,
context->dest_surface,
gdk_content_formats_ref (gdk_drag_context_get_formats (context)),
- context->actions,
+ gdk_drag_context_get_actions (context),
GDK_DRAG_PROTO_LOCAL);
gdk_surface_set_events (new_context->source_surface,
{
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;
&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;
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)
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
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)
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;
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)
{
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;
}
}
default:
break;
}
- context->suggested_action = suggested_action;
}
else
{
g_signal_emit_by_name (context, "action-changed", context->action);
}
}
- else
- {
- context->suggested_action = suggested_action;
- }
/* Send a drag-motion event */
*/
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;