#include "config.h"
+#include <string.h>
+
#define INITGUID
-#include <string.h>
+#include "gdkdnd.h"
+#include "gdkproperty.h"
+#include "gdkprivate.h"
+#include "gdkx.h"
#ifdef OLE2_DND
#include <ole2.h>
+#else
+#include <objbase.h>
#endif
-#ifdef _MSC_VER
+#ifdef _MSC_VER /* These aren't in mingw32 */
#include <shlobj.h>
#include <shlguid.h>
#endif
#include <gdk/gdk.h>
-#include "gdkx.h"
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
#ifdef OLE2_DND
+#define PRINT_RIID(riid) \
+ g_print ("riid = %.08x-%.04x-%.04x-%.02x%.02x-%.02x%.02x%.02x%.02x%.02x%.02x", \
+ ((gulong *) riid)[0], \
+ ((gushort *) riid)[2], \
+ ((gushort *) riid)[3], \
+ ((guchar *) riid)[8], \
+ ((guchar *) riid)[9], \
+ ((guchar *) riid)[10], \
+ ((guchar *) riid)[11], \
+ ((guchar *) riid)[12], \
+ ((guchar *) riid)[13], \
+ ((guchar *) riid)[14], \
+ ((guchar *) riid)[15]);
+
+
HRESULT STDMETHODCALLTYPE
m_query_interface_target (IDropTarget __RPC_FAR *This,
/* [in] */ REFIID riid,
*ppvObject = NULL;
- g_print ("riid = %.08x-%.04x-%.04x-%.02x%.02x-%.02x%.02x%.02x%.02x%.02x%.02x",
- ((gulong *) riid)[0],
- ((gushort *) riid)[2],
- ((gushort *) riid)[3],
- ((guchar *) riid)[8],
- ((guchar *) riid)[9],
- ((guchar *) riid)[10],
- ((guchar *) riid)[11],
- ((guchar *) riid)[12],
- ((guchar *) riid)[13],
- ((guchar *) riid)[14],
- ((guchar *) riid)[15]);
+ PRINT_RIID (riid);
+
if (IsEqualGUID (riid, &IID_IUnknown))
{
+ g_print ("...IUnknown\n");
m_add_ref_target (This);
*ppvObject = This;
- g_print ("...IUnknown\n");
return S_OK;
}
else if (IsEqualGUID (riid, &IID_IDropTarget))
{
+ g_print ("...IDropTarget\n");
m_add_ref_target (This);
*ppvObject = This;
- g_print ("...IDropTarget\n");
return S_OK;
}
else
*ppvObject = NULL;
- g_print ("riid = %.02x%.02x%.02x%.02x-%.02x%.02x-%.02x%.02x-%.02x%.02x-%.02x%.02x%.02x%.02x%.02x%.02x",
- ((guchar *) riid)[0],
- ((guchar *) riid)[1],
- ((guchar *) riid)[2],
- ((guchar *) riid)[3],
- ((guchar *) riid)[4],
- ((guchar *) riid)[5],
- ((guchar *) riid)[6],
- ((guchar *) riid)[7],
- ((guchar *) riid)[8],
- ((guchar *) riid)[9],
- ((guchar *) riid)[10],
- ((guchar *) riid)[11],
- ((guchar *) riid)[12],
- ((guchar *) riid)[13],
- ((guchar *) riid)[14],
- ((guchar *) riid)[15]);
+ PRINT_RIID (riid);
if (IsEqualGUID (riid, &IID_IUnknown))
{
+ g_print ("...IUnknown\n");
m_add_ref_source (This);
*ppvObject = This;
- g_print ("...IUnknown\n");
return S_OK;
}
else if (IsEqualGUID (riid, &IID_IDropSource))
{
+ g_print ("...IDropSource\n");
m_add_ref_source (This);
*ppvObject = This;
- g_print ("...IDropSource\n");
return S_OK;
}
else
private = (GdkDragContextPrivate *) context;
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
context->is_source = FALSE;
- context->source_window = (GdkWindow *) &gdk_root_parent;
+ context->source_window = (GdkWindow *) gdk_root_parent;
context->dest_window = event->any.window;
gdk_window_ref (context->dest_window);
/* WM_DROPFILES drops are always file names */
}
g_string_append (result, "\015\012");
}
- gdk_sel_prop_store ((GdkWindow *) &gdk_root_parent,
+ gdk_sel_prop_store ((GdkWindow *) gdk_root_parent,
text_uri_list_atom, 8, result->str, result->len + 1);
DragFinish (hdrop);
GdkDragProtocol *protocol)
{
GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
- GdkWindowPrivate *drag_window_private = (GdkWindowPrivate *) drag_window;
+ GdkDrawablePrivate *drag_window_private = (GdkDrawablePrivate*) drag_window;
HWND recipient;
POINT pt;
{
}
+static GdkFilterReturn
+gdk_destroy_filter (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer data)
+{
+#ifdef OLE2_DND
+ MSG *msg = (MSG *) xev;
+
+ if (msg->message == WM_DESTROY)
+ {
+ IDropTarget *idtp = (IDropTarget *) data;
+
+ GDK_NOTE (DND, g_print ("gdk_destroy_filter: WM_DESTROY: %#x\n", msg->hwnd));
+ RevokeDragDrop (msg->hwnd);
+ CoLockObjectExternal (idtp, FALSE, TRUE);
+ }
+#endif
+ return GDK_FILTER_CONTINUE;
+}
+
void
gdk_window_register_dnd (GdkWindow *window)
{
- GdkWindowPrivate *private = (GdkWindowPrivate *) window;
+ GdkDrawablePrivate *private = (GdkDrawablePrivate *) window;
#ifdef OLE2_DND
target_drag_context *context;
HRESULT hres;
}
else if (!SUCCEEDED (hres))
g_warning ("gdk_window_register_dnd: RegisterDragDrop failed");
+ else
+ {
+ gdk_window_add_filter (window, gdk_destroy_filter, &context->idt);
+ }
}
#endif
}