* drag window) in response to this, as all the functions
* that GDK could perform here are already handled by the
* OS driving the DnD process via DoDragDrop() call.
- * The LOCAL protocol, on the other hand, does a lot,
- * similar to what X11 backend does with XDND - it sends
- * GDK_DRAG_LEAVE and GDK_DRAG_ENTER, emits GDK_DRAG_MOTION.
*
* GDK_BUTTON_RELEASE checks the
* released button - if it's the button that was used to
* the OS notifies the process about these things happening.
* For X11 backend that is done in Xdnd event filters,
* for W32 backend this is done in IDropSource/IDropTarget
- * object methods for the OLE2 protocol, whereas for the
- * LOCAL protocol these events are emitted only by GDK itself
- * (with the exception of WM_DROPFILES message, which causes
- * GDK to create a drop context and then immediately finish
- * the drag, providing the list of files it got from the message).
+ * object methods for the OLE2 protocol.
*
*/
return FALSE;
}
-void
-_gdk_win32_local_drag_drop_response (GdkDrag *drag,
- GdkDragAction action)
-{
- GDK_NOTE (DND, g_print ("_gdk_win32_local_drag_drop_response: 0x%p\n",
- drag));
-
- g_signal_emit_by_name (drag, "dnd-finished");
- gdk_drag_drop_done (drag, action != 0);
-}
-
static gboolean
do_drag_drop_response (gpointer user_data)
{
return NULL;
}
-/* For the LOCAL protocol */
-typedef enum {
- GDK_DRAG_STATUS_DRAG,
- GDK_DRAG_STATUS_MOTION_WAIT,
- GDK_DRAG_STATUS_ACTION_WAIT,
- GDK_DRAG_STATUS_DROP
-} GdkDragStatus;
-
-static gboolean use_ole2_dnd = TRUE;
-
static gboolean drag_context_grab (GdkDrag *drag);
G_DEFINE_TYPE (GdkWin32Drag, gdk_win32_drag, GDK_TYPE_DRAG)
GdkSurface *surface,
GdkContentProvider *content,
GdkDragAction actions,
- GdkDevice *device,
- GdkDragProtocol protocol)
+ GdkDevice *device)
{
GdkWin32Drag *drag_win32;
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
else
drag_win32->scale = gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL);
- drag_win32->protocol = protocol;
-
return drag;
}
}
}
-void
-_gdk_win32_local_drag_give_feedback (GdkDrag *drag,
- GdkDragAction actions)
-{
- GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
-
- if (drag_win32->drag_status == GDK_DRAG_STATUS_MOTION_WAIT)
- drag_win32->drag_status = GDK_DRAG_STATUS_DRAG;
-
- GDK_NOTE (DND, g_print ("_gdk_win32_local_drag_give_feedback: 0x%p\n",
- drag));
-
- maybe_emit_action_changed (drag_win32, actions);
-}
-
static gboolean
give_feedback (gpointer user_data)
{
void
_gdk_drag_init (void)
{
- CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
-
- if (g_strcmp0 (getenv ("GDK_WIN32_OLE2_DND"), "0") == 0)
- use_ole2_dnd = FALSE;
+ HRESULT hr;
- if (use_ole2_dnd)
- {
- HRESULT hr;
+ CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
- hr = OleInitialize (NULL);
+ hr = OleInitialize (NULL);
- if (! SUCCEEDED (hr))
- g_error ("OleInitialize failed");
- }
+ if (! SUCCEEDED (hr))
+ g_error ("OleInitialize failed");
}
void
_gdk_win32_dnd_exit (void)
{
- if (use_ole2_dnd)
- {
- OleUninitialize ();
- }
-
+ OleUninitialize ();
CoUninitialize ();
}
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
double px, py;
int x_root, y_root;
+ GdkWin32DnDThreadDoDragDrop *ddd;
+ source_drag_context *source_ctx;
+ data_object *data_obj;
g_return_val_if_fail (surface != NULL, NULL);
surface,
content,
actions,
- device,
- use_ole2_dnd ? GDK_DRAG_PROTO_OLE2 : GDK_DRAG_PROTO_LOCAL);
+ device);
drag_win32 = GDK_WIN32_DRAG (drag);
GDK_NOTE (DND, g_print ("_gdk_win32_surface_drag_begin\n"));
return FALSE;
}
- if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
- {
- GdkWin32DnDThreadDoDragDrop *ddd = g_new0 (GdkWin32DnDThreadDoDragDrop, 1);
- source_drag_context *source_ctx;
- data_object *data_obj;
-
- source_ctx = source_context_new (drag, gdk_drag_get_formats (drag));
- data_obj = data_object_new (drag);
-
- ddd->base.item_type = GDK_WIN32_DND_THREAD_QUEUE_ITEM_DO_DRAG_DROP;
- ddd->base.opaque_context = drag_win32;
- ddd->src_context = source_ctx;
- ddd->src_object = data_obj;
- ddd->allowed_drop_effects = 0;
- if (actions & GDK_ACTION_COPY)
- ddd->allowed_drop_effects |= DROPEFFECT_COPY;
- if (actions & GDK_ACTION_MOVE)
- ddd->allowed_drop_effects |= DROPEFFECT_MOVE;
- if (actions & GDK_ACTION_LINK)
- ddd->allowed_drop_effects |= DROPEFFECT_LINK;
-
- g_hash_table_replace (clipdrop->active_source_drags, g_object_ref (drag), ddd);
- increment_dnd_queue_counter ();
- g_async_queue_push (clipdrop->dnd_queue, ddd);
- API_CALL (PostThreadMessage, (clipdrop->dnd_thread_id, thread_wakeup_message, 0, 0));
-
- drag_win32->util_data.state = GDK_WIN32_DND_PENDING;
- }
-
- move_drag_surface (drag, x_root, y_root);
-
- return drag;
-}
-
-/* TODO: remove this?
- * window finder is only used by our gdk_drag_update() to
- * find the window at drag coordinates - which is
- * something IDropSourceNotify already gives us.
- * Unless, of course, we keep the LOCAL protocol around.
- */
-typedef struct {
- int x;
- int y;
- HWND ignore;
- HWND result;
-} find_window_enum_arg;
-
-static BOOL CALLBACK
-find_window_enum_proc (HWND hwnd,
- LPARAM lparam)
-{
- RECT rect;
- POINT tl, br;
- find_window_enum_arg *a = (find_window_enum_arg *) lparam;
-
- if (hwnd == a->ignore)
- return TRUE;
-
- if (!IsWindowVisible (hwnd))
- return TRUE;
-
- tl.x = tl.y = 0;
- ClientToScreen (hwnd, &tl);
- GetClientRect (hwnd, &rect);
- br.x = rect.right;
- br.y = rect.bottom;
- ClientToScreen (hwnd, &br);
-
- if (a->x >= tl.x && a->y >= tl.y && a->x < br.x && a->y < br.y)
- {
- a->result = hwnd;
- return FALSE;
- }
- else
- return TRUE;
-}
-
-/* Finds the HWND under cursor. Local DnD protocol
- * uses this function, since local protocol is implemented
- * entirely in GDK and cannot rely on the OS to notify
- * drop targets about drags that move over them.
- */
-static HWND
-gdk_win32_drag_find_window (GdkDrag *drag,
- GdkSurface *drag_surface,
- int x_root,
- int y_root)
-{
- GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
- find_window_enum_arg a;
+ ddd = g_new0 (GdkWin32DnDThreadDoDragDrop, 1);
- g_assert (_win32_main_thread == NULL ||
- _win32_main_thread == g_thread_self ());
+ source_ctx = source_context_new (drag, gdk_drag_get_formats (drag));
+ data_obj = data_object_new (drag);
- a.x = x_root * drag_win32->scale - _gdk_offset_x;
- a.y = y_root * drag_win32->scale - _gdk_offset_y;
- a.ignore = drag_surface ? GDK_SURFACE_HWND (drag_surface) : NULL;
- a.result = INVALID_HANDLE_VALUE;
+ ddd->base.item_type = GDK_WIN32_DND_THREAD_QUEUE_ITEM_DO_DRAG_DROP;
+ ddd->base.opaque_context = drag_win32;
+ ddd->src_context = source_ctx;
+ ddd->src_object = data_obj;
+ ddd->allowed_drop_effects = 0;
+ if (actions & GDK_ACTION_COPY)
+ ddd->allowed_drop_effects |= DROPEFFECT_COPY;
+ if (actions & GDK_ACTION_MOVE)
+ ddd->allowed_drop_effects |= DROPEFFECT_MOVE;
+ if (actions & GDK_ACTION_LINK)
+ ddd->allowed_drop_effects |= DROPEFFECT_LINK;
- GDK_NOTE (DND,
- g_print ("gdk_win32_drag_find_window: %p %+d%+d\n",
- (drag_surface ? GDK_SURFACE_HWND (drag_surface) : NULL),
- a.x, a.y));
+ g_hash_table_replace (clipdrop->active_source_drags, g_object_ref (drag), ddd);
+ increment_dnd_queue_counter ();
+ g_async_queue_push (clipdrop->dnd_queue, ddd);
+ API_CALL (PostThreadMessage, (clipdrop->dnd_thread_id, thread_wakeup_message, 0, 0));
- EnumWindows (find_window_enum_proc, (LPARAM) &a);
+ drag_win32->util_data.state = GDK_WIN32_DND_PENDING;
- GDK_NOTE (DND,
- g_print ("gdk_win32_drag_find_window: %p %+d%+d: %p\n",
- (drag_surface ? GDK_SURFACE_HWND (drag_surface) : NULL),
- x_root, y_root,
- a.result));
+ move_drag_surface (drag, x_root, y_root);
- return a.result;
+ return drag;
}
static DWORD
return key_state;
}
-/* This only works if dest_window our window and the DnD operation
- * is currently local to the application.
- */
-static GdkDrop *
-_gdk_win32_get_drop_for_dest_window (HWND dest_window)
-{
- GdkSurface *drop_surface = gdk_win32_handle_table_lookup (dest_window);
- GdkDrop *result = NULL;
-
- if (drop_surface)
- result = _gdk_win32_get_drop_for_dest_surface (drop_surface);
-
- return result;
-}
-
-static gboolean
-gdk_win32_local_drag_motion (GdkDrag *drag,
- HWND dest_window,
- int x_root,
- int y_root,
- GdkDragAction possible_actions,
- DWORD key_state,
- guint32 time_)
-{
- GdkWin32Drag *drag_win32;
- GdkDrop *drop;
- GdkDragAction actions;
-
- g_assert (_win32_main_thread == NULL ||
- _win32_main_thread == g_thread_self ());
-
- g_return_val_if_fail (drag != NULL, FALSE);
-
- drag_win32 = GDK_WIN32_DRAG (drag);
-
- drop = _gdk_win32_get_drop_for_dest_window (drag_win32->dest_window);
-
- actions = gdk_drag_get_actions (drag);
-
- GDK_NOTE (DND, g_print ("gdk_win32_local_drag_motion: @ %+d:%+d possible=%s\n"
- " dest=%p (current %p) drop=%p drag=%p:{actions=%s,action=%s}\n",
- x_root, y_root,
- _gdk_win32_drag_action_to_string (possible_actions),
- dest_window, drag_win32->dest_window, drop, drag,
- _gdk_win32_drag_action_to_string (actions),
- _gdk_win32_drag_action_to_string (gdk_drag_get_selected_action (drag))));
-
- if (drag_win32->dest_window != dest_window)
- {
- /* Send a leave to the last destination */
- if (drop)
- _gdk_win32_local_drop_target_dragleave (drop, time_);
-
- drag_win32->dest_window = dest_window;
- drag_win32->drag_status = GDK_DRAG_STATUS_DRAG;
-
- _gdk_win32_local_drop_target_dragenter (drag,
- gdk_win32_handle_table_lookup (dest_window),
- x_root,
- y_root,
- key_state,
- time_,
- &actions);
-
- drop = _gdk_win32_get_drop_for_dest_window (drag_win32->dest_window);
- maybe_emit_action_changed (drag_win32, actions);
- }
-
- /* Send a drag-motion event */
-
- drag_win32->util_data.last_x = x_root;
- drag_win32->util_data.last_y = y_root;
-
- if (drop != NULL &&
- drag_win32->drag_status == GDK_DRAG_STATUS_DRAG &&
- _gdk_win32_local_drop_target_will_emit_motion (drop, x_root, y_root, key_state))
- {
- actions = gdk_drag_get_actions (drag);
- drag_win32->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
-
- _gdk_win32_local_drop_target_dragover (drop, drag, x_root, y_root, key_state, time_, &actions);
-
- maybe_emit_action_changed (drag_win32, actions);
- }
-
- GDK_NOTE (DND, g_print (" returning %s\n"
- " drag=%p:{actions=%s,action=%s}\n",
- (drop != NULL && drag_win32->drag_status == GDK_DRAG_STATUS_DRAG) ? "TRUE" : "FALSE",
- drag,
- _gdk_win32_drag_action_to_string (gdk_drag_get_actions (drag)),
- _gdk_win32_drag_action_to_string (gdk_drag_get_selected_action (drag))));
- return (drop != NULL && drag_win32->drag_status == GDK_DRAG_STATUS_DRAG);
-}
-
static void
send_source_state_update (GdkWin32Clipdrop *clipdrop,
GdkWin32Drag *drag_win32,
{
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
+ gpointer ddd;
g_assert (_win32_main_thread == NULL ||
_win32_main_thread == g_thread_self ());
GDK_NOTE (DND, g_print ("gdk_win32_drag_drop\n"));
- if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
- {
- GdkDrop *drop = _gdk_win32_get_drop_for_dest_window (drag_win32->dest_window);
-
- if (drop)
- {
- GdkDragAction actions;
-
- actions = gdk_drag_get_actions (drag);
- _gdk_win32_local_drop_target_drop (drop, drag, time_, &actions);
- maybe_emit_action_changed (drag_win32, actions);
- _gdk_win32_local_drag_drop_response (drag, actions);
- }
- }
- else if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
- {
- gpointer ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
+ ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
- drag_win32->util_data.state = GDK_WIN32_DND_DROPPED;
+ drag_win32->util_data.state = GDK_WIN32_DND_DROPPED;
- if (ddd)
- send_source_state_update (clipdrop, drag_win32, ddd);
- }
+ if (ddd)
+ send_source_state_update (clipdrop, drag_win32, ddd);
}
static void
{
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
GdkDragAnim *anim;
+ GdkWin32Clipdrop *clipdrop;
+ gpointer ddd;
/*
cairo_surface_t *win_surface;
cairo_surface_t *surface;
/* FIXME: This is temporary, until the code is fixed to ensure that
* gdk_drag_finish () is called by GTK.
*/
- if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
- {
- GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
- gpointer ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
+ clipdrop = _gdk_win32_clipdrop_get ();
+ ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
- if (success)
- drag_win32->util_data.state = GDK_WIN32_DND_DROPPED;
- else
- drag_win32->util_data.state = GDK_WIN32_DND_NONE;
+ if (success)
+ drag_win32->util_data.state = GDK_WIN32_DND_DROPPED;
+ else
+ drag_win32->util_data.state = GDK_WIN32_DND_NONE;
- if (ddd)
- send_source_state_update (clipdrop, drag_win32, ddd);
- }
- else if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
- {
-
- }
+ if (ddd)
+ send_source_state_update (clipdrop, drag_win32, ddd);
drag_win32->handle_events = FALSE;
drag,
reason_str));
- if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
- {
- GdkDrop *drop = _gdk_win32_get_drop_for_dest_window (drag_win32->dest_window);
- if (drop)
- _gdk_win32_local_drop_target_dragleave (drop, GDK_CURRENT_TIME);
- drop = NULL;
- }
-
gdk_drag_set_cursor (drag, NULL);
drag_context_ungrab (drag);
gdk_drag_drop_done (drag, FALSE);
#define BIG_STEP 20
#define SMALL_STEP 1
-static void
-gdk_local_drag_update (GdkDrag *drag,
- double x_root,
- double y_root,
- DWORD grfKeyState,
- guint32 evtime)
-{
- GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
- HWND dest_window;
-
- g_assert (_win32_main_thread == NULL ||
- _win32_main_thread == g_thread_self ());
-
- dest_window = gdk_win32_drag_find_window (drag,
- drag_win32->drag_surface,
- x_root, y_root);
-
- gdk_win32_local_drag_motion (drag, dest_window, x_root, y_root,
- gdk_drag_get_actions (drag),
- grfKeyState, evtime);
-}
-
static gboolean
gdk_dnd_handle_motion_event (GdkDrag *drag,
GdkEvent *event)
DWORD key_state;
double x, y;
double x_root, y_root;
+ GdkWin32Clipdrop *clipdrop;
GDK_NOTE (DND, g_print ("gdk_dnd_handle_motion_event: 0x%p\n", drag));
key_state = manufacture_keystate_from_GMT (state);
- if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
- {
- gdk_local_drag_update (drag, x_root, y_root, key_state,
- gdk_event_get_time (event));
- }
- else if (drag_win32->protocol == GDK_DRAG_PROTO_OLE2)
- {
- GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
+ clipdrop = _gdk_win32_clipdrop_get ();
- GDK_NOTE (DND, g_print ("Post WM_MOUSEMOVE keystate=%lu\n", key_state));
+ GDK_NOTE (DND, g_print ("Post WM_MOUSEMOVE keystate=%lu\n", key_state));
- drag_win32->util_data.last_x = x_root;
- drag_win32->util_data.last_y = y_root;
+ drag_win32->util_data.last_x = x_root;
+ drag_win32->util_data.last_y = y_root;
- API_CALL (PostThreadMessage, (clipdrop->dnd_thread_id,
- WM_MOUSEMOVE,
- key_state,
- MAKELPARAM (x * drag_win32->scale,
- y * drag_win32->scale)));
- }
+ API_CALL (PostThreadMessage, (clipdrop->dnd_thread_id,
+ WM_MOUSEMOVE,
+ key_state,
+ MAKELPARAM (x * drag_win32->scale,
+ y * drag_win32->scale)));
return TRUE;
}
if (drag_win32->drag_surface)
move_drag_surface (drag, drag_win32->util_data.last_x, drag_win32->util_data.last_y);
- if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
- gdk_local_drag_update (drag, drag_win32->util_data.last_x, drag_win32->util_data.last_y,
- manufacture_keystate_from_GMT (state),
- gdk_event_get_time (event));
-
return TRUE;
}
IDataObject *data_object;
};
-/* TRUE to use OLE2 protocol, FALSE to use local protocol */
-static gboolean use_ole2_dnd = TRUE;
-
static void
gdk_win32_drop_init (GdkWin32Drop *drop)
{
return GDK_DROP (drop_win32);
}
-/* Gets the GdkDrop that corresponds to a particular GdkSurface.
- * Will be NULL for surfaces that are not registered as drop targets,
- * or for surfaces that are currently not under the drag cursor.
- * This function is only used for local DnD, where we do have
- * a real GdkSurface that corresponds to the HWND under cursor.
- */
-GdkDrop *
-_gdk_win32_get_drop_for_dest_surface (GdkSurface *dest)
-{
- GdkWin32Surface *impl;
-
- if (dest == NULL)
- return NULL;
-
- impl = GDK_WIN32_SURFACE (dest);
-
- if (impl->drop_target != NULL)
- return impl->drop_target->drop;
-
- return impl->drop;
-}
-
#define PRINT_GUID(guid) \
g_print ("%.08lx-%.04x-%.04x-%.02x%.02x-%.02x%.02x%.02x%.02x%.02x%.02x", \
return actions;
}
-void
-_gdk_win32_local_drop_target_dragenter (GdkDrag *drag,
- GdkSurface *dest_surface,
- int x_root,
- int y_root,
- DWORD grfKeyState,
- guint32 time_,
- GdkDragAction *actions)
-{
- GdkDrop *drop;
- GdkWin32Drop *drop_win32;
- GdkDisplay *display;
- GdkDragAction source_actions;
- GdkWin32Surface *impl = GDK_WIN32_SURFACE (dest_surface);
-
- GDK_NOTE (DND, g_print ("_gdk_win32_local_drop_target_dragenter %p @ %d : %d"
- " for dest window 0x%p"
- ". actions = %s\n",
- drag, x_root, y_root,
- dest_surface,
- _gdk_win32_drag_action_to_string (*actions)));
-
- display = gdk_surface_get_display (dest_surface);
- drop = gdk_drop_new (display,
- gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
- drag,
- gdk_drag_get_formats (drag),
- dest_surface,
- GDK_DRAG_PROTO_LOCAL);
- drop_win32 = GDK_WIN32_DROP (drop);
-
- impl->drop = drop;
-
- source_actions = set_source_actions_helper (drop, *actions, grfKeyState);
-
- gdk_drop_emit_enter_event (drop, TRUE, x_root, y_root, time_);
- drop_win32->last_key_state = grfKeyState;
- drop_win32->last_x = x_root;
- drop_win32->last_y = y_root;
- *actions = filter_actions (drop_win32->actions, source_actions);
-
- GDK_NOTE (DND, g_print ("_gdk_win32_local_drop_target_dragenter returns with actions %s\n",
- _gdk_win32_drag_action_to_string (*actions)));
-}
-
/* The pdwEffect here initially points
* to a DWORD that contains the value of dwOKEffects argument in DoDragDrop,
* i.e. the drag action that the drag source deems acceptable.
return S_OK;
}
-gboolean
-_gdk_win32_local_drop_target_will_emit_motion (GdkDrop *drop,
- int x_root,
- int y_root,
- DWORD grfKeyState)
-{
- GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (drop);
-
- if (x_root != drop_win32->last_x ||
- y_root != drop_win32->last_y ||
- grfKeyState != drop_win32->last_key_state)
- return TRUE;
-
- return FALSE;
-}
-
-void
-_gdk_win32_local_drop_target_dragover (GdkDrop *drop,
- GdkDrag *drag,
- int x_root,
- int y_root,
- DWORD grfKeyState,
- guint32 time_,
- GdkDragAction *actions)
-{
- GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (drop);
- GdkDragAction source_actions;
-
- source_actions = set_source_actions_helper (drop, *actions, grfKeyState);
-
- GDK_NOTE (DND, g_print ("_gdk_win32_local_drop_target_dragover %p @ %d : %d"
- ", actions = %s\n",
- drop, x_root, y_root,
- _gdk_win32_drag_action_to_string (*actions)));
-
- if (_gdk_win32_local_drop_target_will_emit_motion (drop, x_root, y_root, grfKeyState))
- {
- gdk_drop_emit_motion_event (drop, TRUE, x_root, y_root, time_);
- drop_win32->last_key_state = grfKeyState;
- drop_win32->last_x = x_root;
- drop_win32->last_y = y_root;
- }
-
- *actions = filter_actions (drop_win32->actions, source_actions);
-
- GDK_NOTE (DND, g_print ("_gdk_win32_local_drop_target_dragover returns with actions %s\n",
- _gdk_win32_drag_action_to_string (*actions)));
-}
-
/* NOTE: This method is called continuously, even if nothing is
* happening, as long as the drag operation is in progress and
* the cursor is above our window.
return S_OK;
}
-void
-_gdk_win32_local_drop_target_dragleave (GdkDrop *drop,
- guint32 time_)
-{
- GdkWin32Surface *impl = GDK_WIN32_SURFACE (gdk_drop_get_surface (drop));
- GDK_NOTE (DND, g_print ("_gdk_win32_local_drop_target_dragleave %p\n", drop));
-
- gdk_drop_emit_leave_event (drop, TRUE, time_);
-
- g_clear_object (&impl->drop);
-}
-
static HRESULT STDMETHODCALLTYPE
idroptarget_dragleave (LPDROPTARGET This)
{
return S_OK;
}
-void
-_gdk_win32_local_drop_target_drop (GdkDrop *drop,
- GdkDrag *drag,
- guint32 time_,
- GdkDragAction *actions)
-{
- GdkWin32Drop *drop_win32 = GDK_WIN32_DROP (drop);
-
- GDK_NOTE (DND, g_print ("_gdk_win32_local_drop_target_drop %p ", drop));
-
- set_source_actions_helper (drop,
- *actions,
- drop_win32->last_key_state);
-
- drop_win32->drop_finished = FALSE;
- gdk_drop_emit_drop_event (drop, TRUE, drop_win32->last_x, drop_win32->last_y, time_);
-
- while (!drop_win32->drop_finished)
- g_main_context_iteration (NULL, FALSE);
-
- /* Notify local source of the DnD result
- * Special case:
- * drop_win32->actions is guaranteed to contain 1 action after gdk_drop_finish ()
- */
- *actions = drop_win32->actions;
-
- GDK_NOTE (DND, g_print ("drop with action %s\n", _gdk_win32_drag_action_to_string (*actions)));
-}
-
static HRESULT STDMETHODCALLTYPE
idroptarget_drop (LPDROPTARGET This,
LPDATAOBJECT pDataObj,
_gdk_win32_drag_action_to_string (preferred)));
drop_win32->actions = actions;
-
- if (drop_win32->protocol == GDK_DRAG_PROTO_OLE2)
- return;
-
- drag = gdk_drop_get_drag (drop);
-
- if (drag != NULL)
- _gdk_win32_local_drag_give_feedback (drag, actions);
}
static void
drop_win32->actions = action;
drop_win32->drop_finished = TRUE;
-
- if (drop_win32->protocol == GDK_DRAG_PROTO_OLE2)
- return;
}
#if 0
{
drop_target_context *ctx;
HRESULT hr;
+ GdkWin32Surface *impl;
g_return_if_fail (window != NULL);
GDK_NOTE (DND, g_print ("gdk_win32_surface_register_dnd: %p\n", GDK_SURFACE_HWND (window)));
- if (!use_ole2_dnd)
- {
- /* We always claim to accept dropped files, but in fact we might not,
- * of course. This function is called in such a way that it cannot know
- * whether the window (widget) in question actually accepts files
- * (in gtk, data of type text/uri-list) or not.
- */
- gdk_win32_display_add_filter (GDK_WIN32_DISPLAY (gdk_display_get_default ()), gdk_dropfiles_filter, NULL);
- DragAcceptFiles (GDK_SURFACE_HWND (window), TRUE);
- }
- else
- {
- GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
+ impl = GDK_WIN32_SURFACE (window);
- /* Return if window is already setup for DND. */
- if (impl->drop_target != NULL)
- return;
+ /* Return if window is already setup for DND. */
+ if (impl->drop_target != NULL)
+ return;
- ctx = target_context_new (window);
+ ctx = target_context_new (window);
- hr = CoLockObjectExternal ((IUnknown *) &ctx->idt, TRUE, FALSE);
- if (!SUCCEEDED (hr))
- OTHER_API_FAILED ("CoLockObjectExternal");
+ hr = CoLockObjectExternal ((IUnknown *) &ctx->idt, TRUE, FALSE);
+ if (!SUCCEEDED (hr))
+ OTHER_API_FAILED ("CoLockObjectExternal");
+ else
+ {
+ hr = RegisterDragDrop (GDK_SURFACE_HWND (window), &ctx->idt);
+ if (hr == DRAGDROP_E_ALREADYREGISTERED)
+ {
+ g_print ("DRAGDROP_E_ALREADYREGISTERED\n");
+ CoLockObjectExternal ((IUnknown *) &ctx->idt, FALSE, FALSE);
+ }
+ else if (!SUCCEEDED (hr))
+ OTHER_API_FAILED ("RegisterDragDrop");
else
{
- hr = RegisterDragDrop (GDK_SURFACE_HWND (window), &ctx->idt);
- if (hr == DRAGDROP_E_ALREADYREGISTERED)
- {
- g_print ("DRAGDROP_E_ALREADYREGISTERED\n");
- CoLockObjectExternal ((IUnknown *) &ctx->idt, FALSE, FALSE);
- }
- else if (!SUCCEEDED (hr))
- OTHER_API_FAILED ("RegisterDragDrop");
- else
- {
- impl->drop_target = ctx;
- }
+ impl->drop_target = ctx;
}
}
}
drop_class->read_async = gdk_win32_drop_read_async;
drop_class->read_finish = gdk_win32_drop_read_finish;
}
-
-void
-_gdk_drop_init (void)
-{
- if (g_strcmp0 (getenv ("GDK_WIN32_OLE2_DND"), "0") == 0)
- use_ole2_dnd = FALSE;
-}