[gtk/wip/otte/win32-cleanup: 3/5] win32: Remove local dnd
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/win32-cleanup: 3/5] win32: Remove local dnd
- Date: Sat, 31 Jul 2021 03:50:26 +0000 (UTC)
commit 6b760b5d37f7d408b0619c645b0999aa5d5c514e
Author: Benjamin Otte <otte redhat com>
Date: Sat Jul 31 01:40:47 2021 +0200
win32: Remove local dnd
We use "real" OLE2 DND exclusively now.
gdk/win32/gdkdisplay-win32.c | 1 -
gdk/win32/gdkdrag-win32.c | 306 ++++++-----------------------
gdk/win32/gdkdrop-win32.c | 416 ++--------------------------------------
gdk/win32/gdkmain-win32.c | 17 --
gdk/win32/gdkprivate-win32.h | 10 -
gdk/win32/gdkwin32dnd-private.h | 35 ----
6 files changed, 77 insertions(+), 708 deletions(-)
---
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index 372f2a3294..6e30e240fe 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -527,7 +527,6 @@ _gdk_win32_display_open (const char *display_name)
_gdk_win32_lang_notification_init ();
_gdk_drag_init ();
- _gdk_drop_init ();
win32_display->keymap = g_object_new (GDK_TYPE_WIN32_KEYMAP, NULL);
_gdk_win32_keymap_set_active_layout (win32_display->keymap, _gdk_input_locale);
diff --git a/gdk/win32/gdkdrag-win32.c b/gdk/win32/gdkdrag-win32.c
index cd8561aca3..9225c478a5 100644
--- a/gdk/win32/gdkdrag-win32.c
+++ b/gdk/win32/gdkdrag-win32.c
@@ -719,8 +719,6 @@ typedef enum {
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)
@@ -788,8 +786,7 @@ gdk_drag_new (GdkDisplay *display,
GdkSurface *surface,
GdkContentProvider *content,
GdkDragAction actions,
- GdkDevice *device,
- GdkDragProtocol protocol)
+ GdkDevice *device)
{
GdkWin32Drag *drag_win32;
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
@@ -809,8 +806,6 @@ gdk_drag_new (GdkDisplay *display,
else
drag_win32->scale = gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL);
- drag_win32->protocol = protocol;
-
return drag;
}
@@ -1078,21 +1073,6 @@ maybe_emit_action_changed (GdkWin32Drag *drag_win32,
}
}
-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)
{
@@ -1667,28 +1647,18 @@ void
_gdk_drag_init (void)
{
CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
+ HRESULT hr;
- if (g_strcmp0 (getenv ("GDK_WIN32_OLE2_DND"), "0") == 0)
- use_ole2_dnd = FALSE;
-
- if (use_ole2_dnd)
- {
- HRESULT hr;
-
- 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 ();
}
@@ -1719,6 +1689,9 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
double px, py;
int x_root, y_root;
+ source_drag_context *source_ctx;
+ data_object *data_obj;
+ GdkWin32DnDThreadDoDragDrop *ddd;
g_return_val_if_fail (surface != NULL, NULL);
@@ -1726,8 +1699,7 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
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"));
@@ -1751,34 +1723,29 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
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;
- }
+ ddd = g_new0 (GdkWin32DnDThreadDoDragDrop, 1);
+
+ 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);
@@ -1887,100 +1854,6 @@ manufacture_keystate_from_GMT (GdkModifierType state)
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,
@@ -2001,6 +1874,7 @@ gdk_win32_drag_drop (GdkDrag *drag,
{
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 ());
@@ -2009,29 +1883,12 @@ gdk_win32_drag_drop (GdkDrag *drag,
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);
+ ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
- if (drop)
- {
- GdkDragAction actions;
+ drag_win32->util_data.state = GDK_WIN32_DND_DROPPED;
- 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);
-
- 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
@@ -2120,7 +1977,9 @@ gdk_win32_drag_drop_done (GdkDrag *drag,
gboolean success)
{
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
+ GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
GdkDragAnim *anim;
+ gpointer ddd;
/*
cairo_surface_t *win_surface;
cairo_surface_t *surface;
@@ -2135,24 +1994,15 @@ gdk_win32_drag_drop_done (GdkDrag *drag,
/* 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);
-
- if (success)
- drag_win32->util_data.state = GDK_WIN32_DND_DROPPED;
- else
- drag_win32->util_data.state = GDK_WIN32_DND_NONE;
+ ddd = g_hash_table_lookup (clipdrop->active_source_drags, drag);
- if (ddd)
- send_source_state_update (clipdrop, drag_win32, ddd);
- }
- else if (drag_win32->protocol == GDK_DRAG_PROTO_LOCAL)
- {
-
- }
+ 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);
drag_win32->handle_events = FALSE;
if (success)
@@ -2277,14 +2127,6 @@ gdk_win32_drag_cancel (GdkDrag *drag,
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);
@@ -2306,32 +2148,11 @@ gdk_win32_drag_drop_performed (GdkDrag *drag,
#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)
{
+ GdkWin32Clipdrop *clipdrop = _gdk_win32_clipdrop_get ();
GdkModifierType state;
GdkWin32Drag *drag_win32 = GDK_WIN32_DRAG (drag);
DWORD key_state;
@@ -2351,26 +2172,16 @@ gdk_dnd_handle_motion_event (GdkDrag *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 ();
-
- 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;
}
@@ -2452,11 +2263,6 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
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;
}
diff --git a/gdk/win32/gdkdrop-win32.c b/gdk/win32/gdkdrop-win32.c
index e8e8205840..e414fc7935 100644
--- a/gdk/win32/gdkdrop-win32.c
+++ b/gdk/win32/gdkdrop-win32.c
@@ -76,9 +76,6 @@ struct _GdkWin32Drop
{
GdkDrop drop;
- /* The drag protocol being in use */
- GdkDragProtocol protocol;
-
/* The actions supported at GTK level. Set in gdk_win32_drop_status(). */
GdkDragAction actions;
@@ -92,13 +89,7 @@ struct _GdkWin32Drop
*/
GArray *droptarget_w32format_contentformat_map;
- /* The list from WM_DROPFILES is store here temporarily,
- * until the next gdk_win32_drop_read_async ()
- */
- char *dropfiles_list;
-
guint drop_finished : 1; /* FALSE until gdk_drop_finish() is called */
- guint drop_failed : 1; /* Whether the drop was unsuccessful */
};
struct _GdkWin32DropClass
@@ -140,9 +131,6 @@ struct _drop_target_context
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)
{
@@ -173,8 +161,7 @@ gdk_drop_new (GdkDisplay *display,
GdkDevice *device,
GdkDrag *drag,
GdkContentFormats *formats,
- GdkSurface *surface,
- GdkDragProtocol protocol)
+ GdkSurface *surface)
{
GdkWin32Drop *drop_win32;
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
@@ -191,8 +178,6 @@ gdk_drop_new (GdkDisplay *display,
else
drop_win32->scale = gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL);
- drop_win32->protocol = protocol;
-
return GDK_DROP (drop_win32);
}
@@ -451,51 +436,6 @@ set_source_actions_helper (GdkDrop *drop,
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.
@@ -545,8 +485,7 @@ idroptarget_dragenter (LPDROPTARGET This,
gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
drag,
formats,
- ctx->surface,
- GDK_DRAG_PROTO_OLE2);
+ ctx->surface);
drop_win32 = GDK_WIN32_DROP (drop);
g_array_set_size (drop_win32->droptarget_w32format_contentformat_map, 0);
gdk_content_formats_unref (formats);
@@ -575,55 +514,6 @@ idroptarget_dragenter (LPDROPTARGET This,
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.
@@ -681,18 +571,6 @@ idroptarget_dragover (LPDROPTARGET This,
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)
{
@@ -708,35 +586,6 @@ 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,
@@ -891,175 +740,6 @@ resolve_link (HWND hWnd,
return SUCCEEDED (hr);
}
-#if 0
-
-/* Check for filenames like C:\Users\tml\AppData\Local\Temp\d5qtkvvs.bmp */
-static gboolean
-filename_looks_tempish (const char *filename)
-{
- char *dirname;
- char *p;
- const char *q;
- gboolean retval = FALSE;
-
- dirname = g_path_get_dirname (filename);
-
- p = dirname;
- q = g_get_tmp_dir ();
-
- while (*p && *q &&
- ((G_IS_DIR_SEPARATOR (*p) && G_IS_DIR_SEPARATOR (*q)) ||
- g_ascii_tolower (*p) == g_ascii_tolower (*q)))
- p++, q++;
-
- if (!*p && !*q)
- retval = TRUE;
-
- g_free (dirname);
-
- return retval;
-}
-
-static gboolean
-close_it (gpointer data)
-{
- close (GPOINTER_TO_INT (data));
-
- return FALSE;
-}
-
-#endif
-
-static GdkWin32MessageFilterReturn
-gdk_dropfiles_filter (GdkWin32Display *display,
- MSG *msg,
- int *ret_valp,
- gpointer data)
-{
- GdkSurface *window;
- GdkDrop *drop;
- GdkWin32Drop *drop_win32;
- GString *result;
- HANDLE hdrop;
- POINT pt;
- int nfiles, i;
- char *fileName, *linkedFile;
-
- if (msg->message != WM_DROPFILES)
- return GDK_WIN32_MESSAGE_FILTER_CONTINUE;
-
- GDK_NOTE (DND, g_print ("WM_DROPFILES: %p\n", msg->hwnd));
-
- window = gdk_win32_handle_table_lookup (msg->hwnd);
-
- drop = gdk_drop_new (GDK_DISPLAY (display),
- gdk_seat_get_pointer (gdk_display_get_default_seat (GDK_DISPLAY (display))),
- NULL,
- /* WM_DROPFILES drops are always file names */
- gdk_content_formats_new ((const char *[2]) {
- "text/uri-list",
- NULL
- }, 1),
- window,
- GDK_DRAG_PROTO_WIN32_DROPFILES);
- drop_win32 = GDK_WIN32_DROP (drop);
-
- gdk_drop_set_actions (drop, GDK_ACTION_COPY);
-
- hdrop = (HANDLE) msg->wParam;
- DragQueryPoint (hdrop, &pt);
- ClientToScreen (msg->hwnd, &pt);
-
- nfiles = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
-
- result = g_string_new (NULL);
- for (i = 0; i < nfiles; i++)
- {
- char *uri;
- wchar_t wfn[MAX_PATH];
-
- DragQueryFileW (hdrop, i, wfn, MAX_PATH);
- fileName = g_utf16_to_utf8 (wfn, -1, NULL, NULL, NULL);
-
- /* Resolve shortcuts */
- if (resolve_link (msg->hwnd, wfn, &linkedFile))
- {
- uri = g_filename_to_uri (linkedFile, NULL, NULL);
- if (uri != NULL)
- {
- g_string_append (result, uri);
- GDK_NOTE (DND, g_print ("... %s link to %s: %s\n",
- fileName, linkedFile, uri));
- g_free (uri);
- }
- g_free (fileName);
- fileName = linkedFile;
- }
- else
- {
- uri = g_filename_to_uri (fileName, NULL, NULL);
- if (uri != NULL)
- {
- g_string_append (result, uri);
- GDK_NOTE (DND, g_print ("... %s: %s\n", fileName, uri));
- g_free (uri);
- }
- }
-
-#if 0
- /* Awful hack to recognize temp files corresponding to
- * images dragged from Firefox... Open the file right here
- * so that it is less likely that Firefox manages to delete
- * it before the GTK-using app (typically GIMP) has opened
- * it.
- *
- * Not compiled in for now, because it means images dragged
- * from Firefox would stay around in the temp folder which
- * is not what Firefox intended. I don't feel comfortable
- * with that, both from a geenral sanity point of view, and
- * from a privacy point of view. It's better to wait for
- * Firefox to fix the problem, for instance by deleting the
- * temp file after a longer delay, or to wait until we
- * implement the OLE2_DND...
- */
- if (filename_looks_tempish (fileName))
- {
- int fd = g_open (fileName, _O_RDONLY|_O_BINARY, 0);
- if (fd == -1)
- {
- GDK_NOTE (DND, g_print ("Could not open %s, maybe an image dragged from Firefox that it
already deleted\n", fileName));
- }
- else
- {
- GDK_NOTE (DND, g_print ("Opened %s as %d so that Firefox won't delete it\n", fileName, fd));
- g_timeout_add_seconds (1, close_it, GINT_TO_POINTER (fd));
- }
- }
-#endif
-
- g_free (fileName);
- g_string_append (result, "\015\012");
- }
-
- g_clear_pointer (&drop_win32->dropfiles_list, g_free);
- drop_win32->dropfiles_list = result->str;
- g_string_free (result, FALSE);
- if (drop_win32->dropfiles_list == NULL)
- drop_win32->dropfiles_list = g_strdup ("");
-
- gdk_drop_emit_drop_event (drop,
- FALSE,
- pt.x / drop_win32->scale,
- pt.y / drop_win32->scale,
- _gdk_win32_get_next_tick (msg->time));
-
- DragFinish (hdrop);
-
- *ret_valp = 0;
-
- return GDK_WIN32_MESSAGE_FILTER_REMOVE;
-}
-
static void
gdk_win32_drop_status (GdkDrop *drop,
GdkDragAction actions,
@@ -1078,14 +758,6 @@ gdk_win32_drop_status (GdkDrop *drop,
_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
@@ -1101,9 +773,6 @@ gdk_win32_drop_finish (GdkDrop *drop,
drop_win32->actions = action;
drop_win32->drop_finished = TRUE;
-
- if (drop_win32->protocol == GDK_DRAG_PROTO_OLE2)
- return;
}
#if 0
@@ -1134,6 +803,7 @@ gdk_destroy_filter (GdkXEvent *xev,
void
_gdk_win32_surface_register_dnd (GdkSurface *window)
{
+ GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
drop_target_context *ctx;
HRESULT hr;
@@ -1141,43 +811,28 @@ _gdk_win32_surface_register_dnd (GdkSurface *window)
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_surface_get_display (window)),
gdk_dropfiles_filter, NULL);
- DragAcceptFiles (GDK_SURFACE_HWND (window), TRUE);
- }
- else
- {
- GdkWin32Surface *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;
}
}
}
@@ -1266,28 +921,6 @@ gdk_win32_drop_read_async (GdkDrop *drop,
mime_types = gdk_content_formats_get_mime_types (formats, &n_mime_types);
- if (drop_win32->protocol == GDK_DRAG_PROTO_WIN32_DROPFILES)
- {
- for (i = 0; i < n_mime_types; i++)
- if (g_strcmp0 (mime_types[i], "text/uri-list") == 0)
- break;
- if (i >= n_mime_types)
- {
- g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("No compatible transfer format found"));
- g_clear_pointer (&drop_win32->dropfiles_list, g_free);
-
- return;
- }
-
- stream = g_memory_input_stream_new_from_data (drop_win32->dropfiles_list, strlen
(drop_win32->dropfiles_list), g_free);
- drop_win32->dropfiles_list = NULL;
- g_object_set_data (G_OBJECT (stream), "gdk-dnd-stream-contenttype", (gpointer) "text/uri-list");
- g_task_return_pointer (task, stream, g_object_unref);
-
- return;
- }
-
tctx = GDK_WIN32_SURFACE (gdk_drop_get_surface (drop))->drop_target;
if (tctx == NULL)
@@ -1413,10 +1046,3 @@ gdk_win32_drop_class_init (GdkWin32DropClass *klass)
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;
-}
diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c
index faa5c80021..f698ceedc2 100644
--- a/gdk/win32/gdkmain-win32.c
+++ b/gdk/win32/gdkmain-win32.c
@@ -221,23 +221,6 @@ _gdk_win32_print_dc (HDC hdc)
DeleteObject (hrgn);
}
-char *
-_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
-{
- switch (protocol)
- {
-#define CASE(x) case GDK_DRAG_PROTO_##x: return #x
- CASE (NONE);
- CASE (WIN32_DROPFILES);
- CASE (OLE2);
- CASE (LOCAL);
-#undef CASE
- default: return static_printf ("illegal_%d", protocol);
- }
- /* NOTREACHED */
- return NULL;
-}
-
char *
_gdk_win32_surface_state_to_string (GdkToplevelState state)
{
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index b7977d2f27..a7f45f1a00 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -149,14 +149,6 @@ typedef enum {
GDK_WIN32_PE_INUSE
} GdkWin32PalEntryState;
-typedef enum
-{
- GDK_DRAG_PROTO_NONE = 0,
- GDK_DRAG_PROTO_WIN32_DROPFILES,
- GDK_DRAG_PROTO_OLE2,
- GDK_DRAG_PROTO_LOCAL,
-} GdkDragProtocol;
-
GType _gdk_gc_win32_get_type (void);
gulong _gdk_win32_get_next_tick (gulong suggested_tick);
@@ -211,7 +203,6 @@ void _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
void _gdk_win32_print_hpalette (HPALETTE hpal);
void _gdk_win32_print_dc (HDC hdc);
-char *_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol);
char *_gdk_win32_surface_state_to_string (GdkToplevelState state);
char *_gdk_win32_surface_style_to_string (LONG style);
char *_gdk_win32_surface_exstyle_to_string (LONG style);
@@ -426,7 +417,6 @@ BOOL WINAPI GtkShowWindow (GdkSurface *window,
/* Initialization */
void _gdk_win32_surfaceing_init (void);
void _gdk_drag_init (void);
-void _gdk_drop_init (void);
void _gdk_events_init (GdkDisplay *display);
#endif /* __GDK_PRIVATE_WIN32_H__ */
diff --git a/gdk/win32/gdkwin32dnd-private.h b/gdk/win32/gdkwin32dnd-private.h
index 8cb91823f6..51ad9b7175 100644
--- a/gdk/win32/gdkwin32dnd-private.h
+++ b/gdk/win32/gdkwin32dnd-private.h
@@ -43,9 +43,6 @@ struct _GdkWin32Drag
{
GdkDrag drag;
- /* The drag protocol being used */
- GdkDragProtocol protocol;
-
/* The surface used for grabs.
* Usually the same as GdkDrag->source_surface
*/
@@ -95,38 +92,6 @@ gpointer _gdk_win32_dnd_thread_main (gpointer data)
GdkDrag *_gdk_win32_find_drag_for_dest_window (HWND dest_window);
GdkDrop *_gdk_win32_get_drop_for_dest_surface (GdkSurface *dest);
-gboolean _gdk_win32_local_drop_target_will_emit_motion (GdkDrop *drop,
- int x_root,
- int y_root,
- DWORD grfKeyState);
-
-void _gdk_win32_local_drop_target_dragenter (GdkDrag *drag,
- GdkSurface *dest_surface,
- int x_root,
- int y_root,
- DWORD grfKeyState,
- guint32 time_,
- GdkDragAction *actions);
-void _gdk_win32_local_drop_target_dragover (GdkDrop *drop,
- GdkDrag *drag,
- int x_root,
- int y_root,
- DWORD grfKeyState,
- guint32 time_,
- GdkDragAction *actions);
-void _gdk_win32_local_drop_target_dragleave (GdkDrop *drop,
- guint32 time_);
-void _gdk_win32_local_drop_target_drop (GdkDrop *drop,
- GdkDrag *drag,
- guint32 time_,
- GdkDragAction *actions);
-
-void _gdk_win32_local_drag_give_feedback (GdkDrag *drag,
- GdkDragAction actions);
-void _gdk_win32_local_drag_drop_response (GdkDrag *drag,
- GdkDragAction action);
-
-
G_END_DECLS
#endif /* __GDK_WIN32_DND_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]