1999-11-11 22:12:27 +00:00
|
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
|
* Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
|
2009-12-16 11:47:57 +00:00
|
|
|
|
* Copyright (C) 2001 Archaeopteryx Software Inc.
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
* Copyright (C) 1998-2002 Tor Lillqvist
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-11-11 22:12:27 +00:00
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-11-11 22:12:27 +00:00
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
2009-12-16 11:04:29 +00:00
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
1999-11-11 22:12:27 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2009-11-14 22:32:14 +00:00
|
|
|
|
#include <io.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
2009-12-16 11:47:57 +00:00
|
|
|
|
/*
|
2009-12-16 23:50:47 +00:00
|
|
|
|
* Comment from the old OLE2 DND code that is being merged in. Note
|
|
|
|
|
* that this comment might not fully reflect reality as the code
|
|
|
|
|
* obviously will have to be modified in this merge. Especially the
|
|
|
|
|
* talk about supporting other than UTF-8 text is bogus, that will not
|
|
|
|
|
* happen.
|
2009-12-16 11:47:57 +00:00
|
|
|
|
*
|
|
|
|
|
* Support for OLE-2 drag and drop added at Archaeopteryx Software, 2001
|
|
|
|
|
* For more information, contact Stephan R.A. Deibel (sdeibel@archaeopteryx.com)
|
|
|
|
|
*
|
|
|
|
|
* Notes on implementation:
|
|
|
|
|
*
|
|
|
|
|
* This is a first pass at OLE2 support. It only supports text and unicode text
|
|
|
|
|
* data types, and file list dnd (which is handled seperately as it predates OLE2
|
|
|
|
|
* both in this implementation and on Windows in general).
|
|
|
|
|
*
|
|
|
|
|
* As such, the data type conversion from gdk selection targets to OLE2 CF_* data
|
|
|
|
|
* type specifiers is partially hardwired. Fixing this is complicated by (a) the
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* fact that the widget’s declared selection types aren’t accessible in calls here
|
|
|
|
|
* that need to declare the corresponding OLE2 data types, and (b) there isn’t a
|
2009-12-16 11:47:57 +00:00
|
|
|
|
* 1-1 correspondence between gdk target types and OLE2 types. The former needs
|
|
|
|
|
* some redesign in gtk dnd (something a gdk/gtk expert should do; I have tried
|
|
|
|
|
* and failed!). As an example of the latter: gdk STRING, TEXT, COMPOUND_TEXT map
|
|
|
|
|
* to CF_TEXT, CF_OEMTEXT, and CF_UNICODETEXT but as a group and with conversions
|
|
|
|
|
* necessary for various combinations. Currently, the code here (and in
|
|
|
|
|
* gdkdnd-win32.c) can handle gdk STRING and TEXT but not COMPOUND_TEXT, and OLE2
|
|
|
|
|
* CF_TEXT and CF_UNICODETEXT but not CF_OEMTEXT. The necessary conversions are
|
|
|
|
|
* supplied by the implementation here.
|
|
|
|
|
*
|
|
|
|
|
* Note that in combination with another hack originated by Archaeopteryx
|
|
|
|
|
* Software, the text conversions here may go to utf-8 unicode as the standard
|
|
|
|
|
* within-gtk target or to single-byte ascii when the USE_ACP_TEXT compilation
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* flag is TRUE. This mode was added to support applications that aren’t using
|
2009-12-16 11:47:57 +00:00
|
|
|
|
* utf-8 across the gtk/gdk API but instead use single-byte ascii according to
|
|
|
|
|
* the current Windows code page. See gdkim-win32.c for more info on that.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2015-04-29 07:31:08 +00:00
|
|
|
|
|
2013-05-13 13:45:18 +00:00
|
|
|
|
/* The mingw.org compiler does not export GUIDS in it's import library. To work
|
|
|
|
|
* around that, define INITGUID to have the GUIDS declared. */
|
|
|
|
|
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
#define INITGUID
|
2013-05-13 13:45:18 +00:00
|
|
|
|
#endif
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
#include "gdkdnd.h"
|
|
|
|
|
#include "gdkproperty.h"
|
Large changes to the Win32 backend, partially made necessary by the
2000-05-02 Tor Lillqvist <tml@iki.fi>
Large changes to the Win32 backend, partially made necessary by
the changes to the backend-independent internal
structures. Attempts to implement similar backing store stuff as
on X11. The current (CVS) version of the Win32 backend is *not* as
stable as it was before the no-flicker branch was merged. A
zipfile with that version is available from
http://www.gimp.org/win32/. That should be use by "production"
code until this CVS version is usable. (But note, the Win32
backend has never been claimed to be "production quality".)
* README.win32: Add the above comment about versions.
* gdk/gdkwindow.c: Don't use backing store for now on Win32.
* gdk/gdk.def: Update.
* gdk/gdkfont.h: Declare temporary Win32-only functions. Will
presumably be replaced by some more better mechanism as 1.4 gets
closer to release shape.
* gdk/makefile.{cygwin,msc}: Update.
* gdk/win32/*.c: Correct inclusions of the backend-specific and
internal headers. Change code according to changes in these. Use
gdk_drawable_*, not gdk_window_* where necessary.
* gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not
our old DND.
* gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try
to interpret single characters as UTF-8. Thanks to Hans Breuer.
Use correct function name in warning messages.
* gdk/win32/gdkevents-win32.c: Use correct parameter lists for the
GSourceFuncs gdk_event_prepare and gdk_event_check.
(gdk_event_get_graphics_expose): Do implement, use
PeekMessage. Thanks to Hans Breuer.
(event_mask_string): Debugging function to print an GdkEventMask.
(gdk_pointer_grab): Use it.
* gdk/win32/gdkfont-win32.c: The Unicode subrange that the
(old) book I used claimed was Hangul actually is CJK Unified
Ideographs Extension A. Also, Hangul Syllables were missing.
Improve logging.
* gdk/win32/gdkgc-win32.c: Largish changes.
* gdk/win32/gdkim-win32.c (gdk_set_locale): Use
g_win32_getlocale() from GLib, and not setlocale() to get current
locale name.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to
gdkwin32.h, similarily as in the X11 backend.
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix,
assignment was used instead of equals in if test. Thanks to Hans
Breuer.
* gdk/win32/makefile.{cygwin,msc}
* gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the
path to the Win32 headers that works also with the mingw compiler.
* gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
|
#include "gdkprivate-win32.h"
|
2011-01-02 10:51:25 +00:00
|
|
|
|
#include "gdkwin32.h"
|
|
|
|
|
#include "gdkwin32dnd.h"
|
|
|
|
|
#include "gdk/gdkdndprivate.h"
|
2017-11-03 08:37:18 +00:00
|
|
|
|
#include "gdkdisplayprivate.h"
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
#include <ole2.h>
|
|
|
|
|
|
|
|
|
|
#include <shlobj.h>
|
|
|
|
|
#include <shlguid.h>
|
|
|
|
|
|
|
|
|
|
#include <gdk/gdk.h>
|
2009-11-14 22:32:14 +00:00
|
|
|
|
#include <glib/gstdio.h>
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
GDK_DRAG_STATUS_DRAG,
|
|
|
|
|
GDK_DRAG_STATUS_MOTION_WAIT,
|
|
|
|
|
GDK_DRAG_STATUS_ACTION_WAIT,
|
|
|
|
|
GDK_DRAG_STATUS_DROP
|
2009-12-16 11:04:29 +00:00
|
|
|
|
} GdkDragStatus;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
struct _GdkWin32DragContext
|
|
|
|
|
{
|
|
|
|
|
GdkDragContext context;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
|
|
|
|
|
guint drag_status : 4; /* Current status of drag */
|
|
|
|
|
guint drop_failed : 1; /* Whether the drop was unsuccessful */
|
|
|
|
|
|
|
|
|
|
POINT ole2_dnd_last_pt; /* Coordinates from last event */
|
|
|
|
|
DWORD ole2_dnd_last_key_state; /* Key state from last event */
|
|
|
|
|
gboolean ole2_dnd_being_finalized;
|
|
|
|
|
gint ole2_dnd_ref_count;
|
|
|
|
|
IUnknown *ole2_dnd_iface;
|
2011-01-02 10:51:25 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GdkWin32DragContextClass
|
|
|
|
|
{
|
|
|
|
|
GdkDragContextClass parent_class;
|
|
|
|
|
};
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
static GList *contexts;
|
|
|
|
|
static GdkDragContext *current_dest_drag = NULL;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
static gboolean use_ole2_dnd = FALSE;
|
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
G_DEFINE_TYPE (GdkWin32DragContext, gdk_win32_drag_context, GDK_TYPE_DRAG_CONTEXT)
|
|
|
|
|
|
2000-07-25 20:38:35 +00:00
|
|
|
|
static void
|
2011-09-22 20:47:23 +00:00
|
|
|
|
gdk_win32_drag_context_init (GdkWin32DragContext *context)
|
2000-07-25 20:38:35 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
contexts = g_list_prepend (contexts, context);
|
2009-12-16 23:50:47 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context->ole2_dnd_being_finalized = FALSE;
|
|
|
|
|
context->ole2_dnd_ref_count = 1;
|
|
|
|
|
context->ole2_dnd_iface = NULL;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drag_context_init %p\n", context));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-25 20:38:35 +00:00
|
|
|
|
static void
|
2011-01-02 10:51:25 +00:00
|
|
|
|
gdk_win32_drag_context_finalize (GObject *object)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkDragContext *context;
|
|
|
|
|
GdkWin32DragContext *context_win32;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drag_context_finalize %p\n", object));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_WIN32_DRAG_CONTEXT (object));
|
|
|
|
|
|
|
|
|
|
context = GDK_DRAG_CONTEXT (object);
|
|
|
|
|
context_win32 = GDK_WIN32_DRAG_CONTEXT (object);
|
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
|
|
|
|
{
|
|
|
|
|
contexts = g_list_remove (contexts, context);
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (context == current_dest_drag)
|
|
|
|
|
current_dest_drag = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if (context_win32->ole2_dnd_iface)
|
2009-12-16 23:50:47 +00:00
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32->ole2_dnd_being_finalized = TRUE;
|
|
|
|
|
context_win32->ole2_dnd_iface->lpVtbl->Release (context_win32->ole2_dnd_iface);
|
|
|
|
|
context_win32->ole2_dnd_iface = NULL;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
G_OBJECT_CLASS (gdk_win32_drag_context_parent_class)->finalize (object);
|
2000-07-25 20:38:35 +00:00
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2000-07-25 20:38:35 +00:00
|
|
|
|
/* Drag Contexts */
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-11-21 13:33:16 +00:00
|
|
|
|
static GdkDragContext *
|
2016-02-06 05:35:41 +00:00
|
|
|
|
gdk_drag_context_new (GdkDisplay *display)
|
2000-07-25 20:38:35 +00:00
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32;
|
|
|
|
|
GdkDragContext *context;
|
|
|
|
|
|
|
|
|
|
context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT, NULL);
|
|
|
|
|
context = GDK_DRAG_CONTEXT(context_win32);
|
2016-04-26 07:31:33 +00:00
|
|
|
|
context->display = display;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
|
2016-02-06 05:35:41 +00:00
|
|
|
|
gdk_drag_context_set_device (context, gdk_seat_get_pointer (gdk_display_get_default_seat (display)));
|
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
return context;
|
2000-07-25 20:38:35 +00:00
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
static GdkDragContext *
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
gdk_drag_context_find (gboolean is_source,
|
|
|
|
|
GdkWindow *source,
|
|
|
|
|
GdkWindow *dest)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
GList *tmp_list = contexts;
|
|
|
|
|
GdkDragContext *context;
|
|
|
|
|
|
|
|
|
|
while (tmp_list)
|
|
|
|
|
{
|
|
|
|
|
context = (GdkDragContext *)tmp_list->data;
|
|
|
|
|
|
|
|
|
|
if ((!context->is_source == !is_source) &&
|
2001-08-19 18:34:59 +00:00
|
|
|
|
((source == NULL) || (context->source_window && (context->source_window == source))) &&
|
|
|
|
|
((dest == NULL) || (context->dest_window && (context->dest_window == dest))))
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
return context;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#define PRINT_GUID(guid) \
|
|
|
|
|
g_print ("%.08lx-%.04x-%.04x-%.02x%.02x-%.02x%.02x%.02x%.02x%.02x%.02x", \
|
|
|
|
|
((gulong *) guid)[0], \
|
|
|
|
|
((gushort *) guid)[2], \
|
|
|
|
|
((gushort *) guid)[3], \
|
|
|
|
|
((guchar *) guid)[8], \
|
|
|
|
|
((guchar *) guid)[9], \
|
|
|
|
|
((guchar *) guid)[10], \
|
|
|
|
|
((guchar *) guid)[11], \
|
|
|
|
|
((guchar *) guid)[12], \
|
|
|
|
|
((guchar *) guid)[13], \
|
|
|
|
|
((guchar *) guid)[14], \
|
|
|
|
|
((guchar *) guid)[15]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static FORMATETC *formats;
|
|
|
|
|
static int nformats;
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
IDropTarget idt;
|
|
|
|
|
GdkDragContext *context;
|
|
|
|
|
} target_drag_context;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
IDropSource ids;
|
|
|
|
|
GdkDragContext *context;
|
|
|
|
|
} source_drag_context;
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
IDataObject ido;
|
|
|
|
|
int ref_count;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GdkDragContext *context;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
} data_object;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
IEnumFORMATETC ief;
|
|
|
|
|
int ref_count;
|
|
|
|
|
int ix;
|
|
|
|
|
} enum_formats;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
static source_drag_context *pending_src_context = NULL;
|
|
|
|
|
static IDataObject *dnd_data = NULL;
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
static enum_formats *enum_formats_new (void);
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
/* map windows -> target drag contexts. The table
|
|
|
|
|
* owns a ref to both objects.
|
|
|
|
|
*/
|
|
|
|
|
static GHashTable* target_ctx_for_window = NULL;
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
static ULONG STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_addref (LPDROPTARGET This)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
target_drag_context *ctx = (target_drag_context *) This;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32 = GDK_WIN32_DRAG_CONTEXT (ctx->context);
|
|
|
|
|
|
|
|
|
|
int ref_count = ++context_win32->ole2_dnd_ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idroptarget_addref %p %d\n", This, ref_count));
|
2009-03-11 13:37:26 +00:00
|
|
|
|
g_object_ref (G_OBJECT (ctx->context));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2000-07-25 20:38:35 +00:00
|
|
|
|
return ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_queryinterface (LPDROPTARGET This,
|
|
|
|
|
REFIID riid,
|
|
|
|
|
LPVOID *ppvObject)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, {
|
|
|
|
|
g_print ("idroptarget_queryinterface %p ", This);
|
|
|
|
|
PRINT_GUID (riid);
|
|
|
|
|
});
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID (riid, &IID_IUnknown))
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...IUnknown S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_addref (This);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*ppvObject = This;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
else if (IsEqualGUID (riid, &IID_IDropTarget))
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...IDropTarget S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_addref (This);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*ppvObject = This;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...E_NOINTERFACE\n"));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_release (LPDROPTARGET This)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
target_drag_context *ctx = (target_drag_context *) This;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32 = GDK_WIN32_DRAG_CONTEXT (ctx->context);
|
|
|
|
|
|
|
|
|
|
int ref_count = --context_win32->ole2_dnd_ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idroptarget_release %p %d\n", This, ref_count));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if (!context_win32->ole2_dnd_being_finalized)
|
2009-03-11 13:37:26 +00:00
|
|
|
|
g_object_unref (G_OBJECT (ctx->context));
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
if (ref_count == 0)
|
|
|
|
|
g_free (This);
|
|
|
|
|
|
|
|
|
|
return ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
|
|
static GdkAtom
|
|
|
|
|
cf_to_atom (CLIPFORMAT cf)
|
|
|
|
|
{
|
|
|
|
|
switch (cf)
|
|
|
|
|
{
|
|
|
|
|
case CF_UNICODETEXT:
|
|
|
|
|
return _utf8_string;
|
|
|
|
|
case CF_HDROP:
|
|
|
|
|
return _text_uri_list;
|
|
|
|
|
case CF_DIB:
|
|
|
|
|
return _image_bmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cf == _cf_url)
|
|
|
|
|
return _text_uri_list;
|
|
|
|
|
|
|
|
|
|
if (cf == _cf_html_format || cf == _cf_text_html)
|
|
|
|
|
return _text_html;
|
|
|
|
|
|
|
|
|
|
return GDK_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static GdkDragAction
|
|
|
|
|
get_suggested_action (DWORD grfKeyState)
|
|
|
|
|
{
|
|
|
|
|
/* This is the yucky Windows standard: Force link action if both
|
|
|
|
|
* Control and Alt are down, copy if Control is down alone, move if
|
|
|
|
|
* Alt is down alone, or use default of move within the app or copy
|
|
|
|
|
* when origin of the drag is in another app.
|
|
|
|
|
*/
|
|
|
|
|
if (grfKeyState & MK_CONTROL && grfKeyState & MK_SHIFT)
|
|
|
|
|
return GDK_ACTION_LINK; /* Link action not supported */
|
|
|
|
|
else if (grfKeyState & MK_CONTROL)
|
|
|
|
|
return GDK_ACTION_COPY;
|
|
|
|
|
else if (grfKeyState & MK_ALT)
|
|
|
|
|
return GDK_ACTION_MOVE;
|
|
|
|
|
#if 0 /* Default is always copy for now */
|
|
|
|
|
else if (_dnd_source_state == GDK_WIN32_DND_DRAGGING)
|
|
|
|
|
return GDK_ACTION_MOVE;
|
|
|
|
|
#endif
|
|
|
|
|
else
|
|
|
|
|
return GDK_ACTION_COPY;
|
|
|
|
|
/* Any way to determine when to add in DROPEFFECT_SCROLL? */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Process pending events -- we don't want to service non-GUI events
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* forever so do one iteration and then do more only if there’s a
|
2009-12-16 11:04:29 +00:00
|
|
|
|
* pending GDK event.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2016-02-06 05:35:41 +00:00
|
|
|
|
process_pending_events (GdkDisplay *display)
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
g_main_context_iteration (NULL, FALSE);
|
2016-02-06 05:35:41 +00:00
|
|
|
|
while (_gdk_event_queue_find_first (display))
|
2009-12-16 11:04:29 +00:00
|
|
|
|
g_main_context_iteration (NULL, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static DWORD
|
|
|
|
|
drop_effect_for_action (GdkDragAction action)
|
|
|
|
|
{
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case GDK_ACTION_MOVE:
|
|
|
|
|
return DROPEFFECT_MOVE;
|
|
|
|
|
case GDK_ACTION_LINK:
|
|
|
|
|
return DROPEFFECT_LINK;
|
|
|
|
|
case GDK_ACTION_COPY:
|
|
|
|
|
return DROPEFFECT_COPY;
|
|
|
|
|
default:
|
|
|
|
|
return DROPEFFECT_NONE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dnd_event_put (GdkEventType type,
|
|
|
|
|
GdkDragContext *context,
|
|
|
|
|
const POINTL pt,
|
|
|
|
|
gboolean to_dest_window)
|
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkEvent *e;
|
|
|
|
|
|
|
|
|
|
e = gdk_event_new (type);
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
if (to_dest_window)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
e->dnd.window = context->dest_window;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
else
|
2010-05-25 22:38:44 +00:00
|
|
|
|
e->dnd.window = context->source_window;
|
|
|
|
|
e->dnd.send_event = FALSE;
|
|
|
|
|
e->dnd.context = g_object_ref (context);
|
|
|
|
|
e->dnd.time = GDK_CURRENT_TIME;
|
|
|
|
|
e->dnd.x_root = pt.x + _gdk_offset_x;
|
|
|
|
|
e->dnd.y_root = pt.x + _gdk_offset_y;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
if (e->dnd.window != NULL)
|
|
|
|
|
g_object_ref (e->dnd.window);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gdk_event_set_device (e, gdk_drag_context_get_device (context));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (e, gdk_device_get_seat (gdk_drag_context_get_device (context)));
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (e));
|
|
|
|
|
gdk_event_put (e);
|
|
|
|
|
gdk_event_free (e);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_dragenter (LPDROPTARGET This,
|
|
|
|
|
LPDATAOBJECT pDataObj,
|
|
|
|
|
DWORD grfKeyState,
|
|
|
|
|
POINTL pt,
|
|
|
|
|
LPDWORD pdwEffect)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
target_drag_context *ctx = (target_drag_context *) This;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idroptarget_dragenter %p S_OK\n", This));
|
2009-03-11 13:37:26 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
ctx->context->suggested_action = get_suggested_action (grfKeyState);
|
|
|
|
|
dnd_event_put (GDK_DRAG_ENTER, ctx->context, pt, TRUE);
|
2016-02-06 05:35:41 +00:00
|
|
|
|
process_pending_events (gdk_device_get_display (gdk_drag_context_get_device (ctx->context)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
*pdwEffect = drop_effect_for_action (ctx->context->action);
|
|
|
|
|
|
|
|
|
|
/* Assume that target can accept the data: In fact it may fail but
|
|
|
|
|
* we are not really set up to query the target!
|
|
|
|
|
*/
|
2009-03-11 13:37:26 +00:00
|
|
|
|
return S_OK;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_dragover (LPDROPTARGET This,
|
|
|
|
|
DWORD grfKeyState,
|
|
|
|
|
POINTL pt,
|
|
|
|
|
LPDWORD pdwEffect)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
target_drag_context *ctx = (target_drag_context *) This;
|
|
|
|
|
|
|
|
|
|
GDK_NOTE (DND, g_print ("idroptarget_dragover %p S_OK\n", This));
|
|
|
|
|
|
|
|
|
|
ctx->context->suggested_action = get_suggested_action (grfKeyState);
|
|
|
|
|
dnd_event_put (GDK_DRAG_MOTION, ctx->context, pt, TRUE);
|
2016-02-06 05:35:41 +00:00
|
|
|
|
process_pending_events (gdk_device_get_display (gdk_drag_context_get_device (ctx->context)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
*pdwEffect = drop_effect_for_action (ctx->context->action);
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
return S_OK;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_dragleave (LPDROPTARGET This)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
target_drag_context *ctx = (target_drag_context *) This;
|
|
|
|
|
POINTL pt = { 0, 0 };
|
|
|
|
|
|
|
|
|
|
GDK_NOTE (DND, g_print ("idroptarget_dragleave %p S_OK\n", This));
|
|
|
|
|
|
|
|
|
|
dnd_event_put (GDK_DRAG_LEAVE, ctx->context, pt, TRUE);
|
2016-02-06 05:35:41 +00:00
|
|
|
|
process_pending_events (gdk_device_get_display (gdk_drag_context_get_device (ctx->context)));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
return S_OK;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_drop (LPDROPTARGET This,
|
|
|
|
|
LPDATAOBJECT pDataObj,
|
|
|
|
|
DWORD grfKeyState,
|
|
|
|
|
POINTL pt,
|
|
|
|
|
LPDWORD pdwEffect)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
target_drag_context *ctx = (target_drag_context *) This;
|
|
|
|
|
|
|
|
|
|
GDK_NOTE (DND, g_print ("idroptarget_drop %p ", This));
|
|
|
|
|
|
|
|
|
|
if (pDataObj == NULL)
|
|
|
|
|
{
|
|
|
|
|
GDK_NOTE (DND, g_print ("E_POINTER\n"));
|
|
|
|
|
return E_POINTER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dnd_data = pDataObj;
|
|
|
|
|
|
|
|
|
|
ctx->context->suggested_action = get_suggested_action (grfKeyState);
|
|
|
|
|
dnd_event_put (GDK_DROP_START, ctx->context, pt, TRUE);
|
2016-02-06 05:35:41 +00:00
|
|
|
|
process_pending_events (gdk_device_get_display (gdk_drag_context_get_device (ctx->context)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
|
|
|
|
dnd_data = NULL;
|
|
|
|
|
|
|
|
|
|
/* Notify OLE of copy or move */
|
|
|
|
|
if (_dnd_target_state != GDK_WIN32_DND_DROPPED)
|
|
|
|
|
*pdwEffect = DROPEFFECT_NONE;
|
|
|
|
|
else
|
|
|
|
|
*pdwEffect = drop_effect_for_action (ctx->context->action);
|
|
|
|
|
|
|
|
|
|
GDK_NOTE (DND, g_print ("S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
return S_OK;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idropsource_addref (LPDROPSOURCE This)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
source_drag_context *ctx = (source_drag_context *) This;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32 = GDK_WIN32_DRAG_CONTEXT (ctx->context);
|
|
|
|
|
|
|
|
|
|
int ref_count = ++context_win32->ole2_dnd_ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idropsource_addref %p %d\n", This, ref_count));
|
|
|
|
|
g_object_ref (G_OBJECT (ctx->context));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
return ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idropsource_queryinterface (LPDROPSOURCE This,
|
|
|
|
|
REFIID riid,
|
|
|
|
|
LPVOID *ppvObject)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, {
|
|
|
|
|
g_print ("idropsource_queryinterface %p ", This);
|
|
|
|
|
PRINT_GUID (riid);
|
|
|
|
|
});
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID (riid, &IID_IUnknown))
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...IUnknown S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idropsource_addref (This);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*ppvObject = This;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
else if (IsEqualGUID (riid, &IID_IDropSource))
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...IDropSource S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idropsource_addref (This);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*ppvObject = This;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...E_NOINTERFACE\n"));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idropsource_release (LPDROPSOURCE This)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
source_drag_context *ctx = (source_drag_context *) This;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32 = GDK_WIN32_DRAG_CONTEXT (ctx->context);
|
|
|
|
|
|
|
|
|
|
int ref_count = --context_win32->ole2_dnd_ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idropsource_release %p %d\n", This, ref_count));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if (!context_win32->ole2_dnd_being_finalized)
|
2009-03-11 13:37:26 +00:00
|
|
|
|
g_object_unref (G_OBJECT (ctx->context));
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
if (ref_count == 0)
|
|
|
|
|
g_free (This);
|
|
|
|
|
|
|
|
|
|
return ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
/* Emit GDK events for any changes in mouse events or control key
|
|
|
|
|
* state since the last recorded state. Return true if any events
|
|
|
|
|
* have been emitted and false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2011-09-22 20:47:23 +00:00
|
|
|
|
send_change_events (GdkDragContext *context,
|
2009-12-16 11:04:29 +00:00
|
|
|
|
DWORD key_state,
|
|
|
|
|
gboolean esc_pressed)
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32 = GDK_WIN32_DRAG_CONTEXT (context);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
POINT pt;
|
|
|
|
|
gboolean changed = FALSE;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
HWND hwnd = GDK_WINDOW_HWND (context->source_window);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
LPARAM lparam;
|
|
|
|
|
WPARAM wparam;
|
|
|
|
|
|
|
|
|
|
if (!API_CALL (GetCursorPos, (&pt)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!API_CALL (ScreenToClient, (hwnd, &pt)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if (pt.x != context_win32->ole2_dnd_last_pt.x || pt.y != context_win32->ole2_dnd_last_pt.y ||
|
|
|
|
|
key_state != context_win32->ole2_dnd_last_key_state)
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
lparam = MAKELPARAM (pt.x, pt.y);
|
|
|
|
|
wparam = key_state;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if (pt.x != context_win32->ole2_dnd_last_pt.x || pt.y != context_win32->ole2_dnd_last_pt.y)
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
GDK_NOTE (DND, g_print ("Sending WM_MOUSEMOVE (%ld,%ld)\n", pt.x, pt.y));
|
|
|
|
|
SendMessage (hwnd, WM_MOUSEMOVE, wparam, lparam);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if ((key_state & MK_LBUTTON) != (context_win32->ole2_dnd_last_key_state & MK_LBUTTON))
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (key_state & MK_LBUTTON)
|
|
|
|
|
SendMessage (hwnd, WM_LBUTTONDOWN, wparam, lparam);
|
|
|
|
|
else
|
|
|
|
|
SendMessage (hwnd, WM_LBUTTONUP, wparam, lparam);
|
|
|
|
|
}
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if ((key_state & MK_MBUTTON) != (context_win32->ole2_dnd_last_key_state & MK_MBUTTON))
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (key_state & MK_MBUTTON)
|
|
|
|
|
SendMessage (hwnd, WM_MBUTTONDOWN, wparam, lparam);
|
|
|
|
|
else
|
|
|
|
|
SendMessage (hwnd, WM_MBUTTONUP, wparam, lparam);
|
|
|
|
|
}
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if ((key_state & MK_RBUTTON) != (context_win32->ole2_dnd_last_key_state & MK_RBUTTON))
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (key_state & MK_RBUTTON)
|
|
|
|
|
SendMessage (hwnd, WM_RBUTTONDOWN, wparam, lparam);
|
|
|
|
|
else
|
|
|
|
|
SendMessage (hwnd, WM_RBUTTONUP, wparam, lparam);
|
|
|
|
|
}
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if ((key_state & MK_CONTROL) != (context_win32->ole2_dnd_last_key_state & MK_CONTROL))
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (key_state & MK_CONTROL)
|
|
|
|
|
SendMessage (hwnd, WM_KEYDOWN, VK_CONTROL, 0);
|
|
|
|
|
else
|
|
|
|
|
SendMessage (hwnd, WM_KEYUP, VK_CONTROL, 0);
|
|
|
|
|
}
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if ((key_state & MK_SHIFT) != (context_win32->ole2_dnd_last_key_state & MK_SHIFT))
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (key_state & MK_CONTROL)
|
|
|
|
|
SendMessage (hwnd, WM_KEYDOWN, VK_SHIFT, 0);
|
|
|
|
|
else
|
|
|
|
|
SendMessage (hwnd, WM_KEYUP, VK_SHIFT, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
changed = TRUE;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32->ole2_dnd_last_key_state = key_state;
|
|
|
|
|
context_win32->ole2_dnd_last_pt = pt;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (esc_pressed)
|
|
|
|
|
{
|
|
|
|
|
GDK_NOTE (DND, g_print ("Sending a escape key down message to %p\n", hwnd));
|
|
|
|
|
SendMessage (hwnd, WM_KEYDOWN, VK_ESCAPE, 0);
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idropsource_querycontinuedrag (LPDROPSOURCE This,
|
|
|
|
|
BOOL fEscapePressed,
|
|
|
|
|
DWORD grfKeyState)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
source_drag_context *ctx = (source_drag_context *) This;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idropsource_querycontinuedrag %p ", This));
|
|
|
|
|
|
|
|
|
|
if (send_change_events (ctx->context, grfKeyState, fEscapePressed))
|
2016-02-06 05:35:41 +00:00
|
|
|
|
process_pending_events (gdk_device_get_display (gdk_drag_context_get_device (ctx->context)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
|
|
|
|
if (_dnd_source_state == GDK_WIN32_DND_DROPPED)
|
|
|
|
|
{
|
|
|
|
|
GDK_NOTE (DND, g_print ("DRAGDROP_S_DROP\n"));
|
|
|
|
|
return DRAGDROP_S_DROP;
|
|
|
|
|
}
|
|
|
|
|
else if (_dnd_source_state == GDK_WIN32_DND_NONE)
|
|
|
|
|
{
|
|
|
|
|
GDK_NOTE (DND, g_print ("DRAGDROP_S_CANCEL\n"));
|
|
|
|
|
return DRAGDROP_S_CANCEL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GDK_NOTE (DND, g_print ("S_OK\n"));
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idropsource_givefeedback (LPDROPSOURCE This,
|
|
|
|
|
DWORD dwEffect)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
source_drag_context *ctx = (source_drag_context *) This;
|
|
|
|
|
GdkDragAction suggested_action;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idropsource_givefeedback %p DRAGDROP_S_USEDEFAULTCURSORS\n", This));
|
|
|
|
|
|
|
|
|
|
if (dwEffect == DROPEFFECT_MOVE)
|
|
|
|
|
suggested_action = GDK_ACTION_MOVE;
|
|
|
|
|
else
|
|
|
|
|
suggested_action = GDK_ACTION_COPY;
|
|
|
|
|
ctx->context->action = suggested_action;
|
|
|
|
|
|
|
|
|
|
if (dwEffect == DROPEFFECT_NONE)
|
|
|
|
|
{
|
|
|
|
|
if (ctx->context->dest_window != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (ctx->context->dest_window);
|
|
|
|
|
ctx->context->dest_window = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DRAGDROP_S_USEDEFAULTCURSORS;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
static ULONG STDMETHODCALLTYPE
|
|
|
|
|
idataobject_addref (LPDATAOBJECT This)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2000-05-07 19:45:27 +00:00
|
|
|
|
data_object *dobj = (data_object *) This;
|
|
|
|
|
int ref_count = ++dobj->ref_count;
|
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_addref %p %d\n", This, ref_count));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
return ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
|
|
|
|
idataobject_queryinterface (LPDATAOBJECT This,
|
|
|
|
|
REFIID riid,
|
|
|
|
|
LPVOID *ppvObject)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, {
|
|
|
|
|
g_print ("idataobject_queryinterface %p ", This);
|
|
|
|
|
PRINT_GUID (riid);
|
|
|
|
|
});
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID (riid, &IID_IUnknown))
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...IUnknown S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_addref (This);
|
|
|
|
|
*ppvObject = This;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
else if (IsEqualGUID (riid, &IID_IDataObject))
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...IDataObject S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_addref (This);
|
|
|
|
|
*ppvObject = This;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...E_NOINTERFACE\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_release (LPDATAOBJECT This)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2000-05-07 19:45:27 +00:00
|
|
|
|
data_object *dobj = (data_object *) This;
|
|
|
|
|
int ref_count = --dobj->ref_count;
|
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_release %p %d\n", This, ref_count));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
if (ref_count == 0)
|
|
|
|
|
g_free (This);
|
|
|
|
|
|
|
|
|
|
return ref_count;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
static HRESULT
|
|
|
|
|
query (LPDATAOBJECT This,
|
|
|
|
|
LPFORMATETC pFormatEtc)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!pFormatEtc)
|
|
|
|
|
return DV_E_FORMATETC;
|
|
|
|
|
|
|
|
|
|
if (pFormatEtc->lindex != -1)
|
|
|
|
|
return DV_E_LINDEX;
|
|
|
|
|
|
|
|
|
|
if ((pFormatEtc->tymed & TYMED_HGLOBAL) == 0)
|
|
|
|
|
return DV_E_TYMED;
|
|
|
|
|
|
|
|
|
|
if ((pFormatEtc->dwAspect & DVASPECT_CONTENT) == 0)
|
|
|
|
|
return DV_E_DVASPECT;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < nformats; i++)
|
|
|
|
|
if (pFormatEtc->cfFormat == formats[i].cfFormat)
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
|
|
return DV_E_FORMATETC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static FORMATETC *active_pFormatEtc = NULL;
|
|
|
|
|
static STGMEDIUM *active_pMedium = NULL;
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_getdata (LPDATAOBJECT This,
|
|
|
|
|
LPFORMATETC pFormatEtc,
|
|
|
|
|
LPSTGMEDIUM pMedium)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
data_object *ctx = (data_object *) This;
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
GdkEvent e;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_getdata %p %s ",
|
|
|
|
|
This, _gdk_win32_cf_to_string (pFormatEtc->cfFormat)));
|
|
|
|
|
|
|
|
|
|
/* Check whether we can provide requested format */
|
|
|
|
|
hr = query (This, pFormatEtc);
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
|
|
/* Append a GDK_SELECTION_GET event and then hope the app sets the
|
|
|
|
|
* property associated with the _gdk_ole2_dnd atom
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
active_pFormatEtc = pFormatEtc;
|
|
|
|
|
active_pMedium = pMedium;
|
|
|
|
|
|
|
|
|
|
e.type = GDK_SELECTION_REQUEST;
|
|
|
|
|
e.selection.window = ctx->context->source_window;
|
|
|
|
|
e.selection.send_event = FALSE; /* ??? */
|
|
|
|
|
/* FIXME: Should really both selection and property be _gdk_ole2_dnd? */
|
|
|
|
|
e.selection.selection = _gdk_ole2_dnd;
|
|
|
|
|
/* FIXME: Target? */
|
|
|
|
|
e.selection.target = _utf8_string;
|
|
|
|
|
e.selection.property = _gdk_ole2_dnd;
|
|
|
|
|
e.selection.time = GDK_CURRENT_TIME;
|
|
|
|
|
|
|
|
|
|
g_object_ref (e.selection.window);
|
|
|
|
|
|
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (&e));
|
|
|
|
|
gdk_event_put (&e);
|
2016-02-06 05:35:41 +00:00
|
|
|
|
process_pending_events (gdk_device_get_display (gdk_drag_context_get_device (ctx->context)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
|
|
|
|
active_pFormatEtc = NULL;
|
|
|
|
|
active_pMedium = NULL;
|
|
|
|
|
|
|
|
|
|
if (pMedium->hGlobal == NULL) {
|
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_getdatahere (LPDATAOBJECT This,
|
|
|
|
|
LPFORMATETC pFormatEtc,
|
|
|
|
|
LPSTGMEDIUM pMedium)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_getdatahere %p %s E_UNEXPECTED\n",
|
|
|
|
|
This, _gdk_win32_cf_to_string (pFormatEtc->cfFormat)));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_querygetdata (LPDATAOBJECT This,
|
|
|
|
|
LPFORMATETC pFormatEtc)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
HRESULT hr;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
hr = query (This, pFormatEtc);
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#define CASE(x) case x: g_print (#x)
|
|
|
|
|
GDK_NOTE (DND, {
|
|
|
|
|
g_print ("idataobject_querygetdata %p %s \n",
|
|
|
|
|
This, _gdk_win32_cf_to_string (pFormatEtc->cfFormat));
|
|
|
|
|
switch (hr)
|
|
|
|
|
{
|
|
|
|
|
CASE (DV_E_FORMATETC);
|
|
|
|
|
CASE (DV_E_LINDEX);
|
|
|
|
|
CASE (DV_E_TYMED);
|
|
|
|
|
CASE (DV_E_DVASPECT);
|
|
|
|
|
CASE (S_OK);
|
|
|
|
|
default: g_print ("%#lx", hr);
|
|
|
|
|
}
|
|
|
|
|
});
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
return hr;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_getcanonicalformatetc (LPDATAOBJECT This,
|
|
|
|
|
LPFORMATETC pFormatEtcIn,
|
|
|
|
|
LPFORMATETC pFormatEtcOut)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_getcanonicalformatetc %p E_UNEXPECTED\n", This));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
return E_UNEXPECTED;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_setdata (LPDATAOBJECT This,
|
|
|
|
|
LPFORMATETC pFormatEtc,
|
|
|
|
|
LPSTGMEDIUM pMedium,
|
|
|
|
|
BOOL fRelease)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_setdata %p %s E_UNEXPECTED\n",
|
|
|
|
|
This, _gdk_win32_cf_to_string (pFormatEtc->cfFormat)));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_enumformatetc (LPDATAOBJECT This,
|
|
|
|
|
DWORD dwDirection,
|
|
|
|
|
LPENUMFORMATETC *ppEnumFormatEtc)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_enumformatetc %p ", This));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
if (dwDirection != DATADIR_GET)
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
|
|
|
|
GDK_NOTE (DND, g_print ("E_NOTIMPL\n"));
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
|
}
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
*ppEnumFormatEtc = &enum_formats_new ()->ief;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
|
|
|
|
GDK_NOTE (DND, g_print ("%p S_OK\n", *ppEnumFormatEtc));
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
return S_OK;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_dadvise (LPDATAOBJECT This,
|
|
|
|
|
LPFORMATETC pFormatetc,
|
|
|
|
|
DWORD advf,
|
|
|
|
|
LPADVISESINK pAdvSink,
|
|
|
|
|
DWORD *pdwConnection)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_dadvise %p E_NOTIMPL\n", This));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
return E_NOTIMPL;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_dunadvise (LPDATAOBJECT This,
|
|
|
|
|
DWORD dwConnection)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_dunadvise %p E_NOTIMPL\n", This));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
return E_NOTIMPL;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_enumdadvise (LPDATAOBJECT This,
|
|
|
|
|
LPENUMSTATDATA *ppenumAdvise)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("idataobject_enumdadvise %p OLE_E_ADVISENOTSUPPORTED\n", This));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
return OLE_E_ADVISENOTSUPPORTED;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
static ULONG STDMETHODCALLTYPE
|
|
|
|
|
ienumformatetc_addref (LPENUMFORMATETC This)
|
|
|
|
|
{
|
|
|
|
|
enum_formats *en = (enum_formats *) This;
|
|
|
|
|
int ref_count = ++en->ref_count;
|
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("ienumformatetc_addref %p %d\n", This, ref_count));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
return ref_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
|
|
|
|
ienumformatetc_queryinterface (LPENUMFORMATETC This,
|
|
|
|
|
REFIID riid,
|
|
|
|
|
LPVOID *ppvObject)
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, {
|
|
|
|
|
g_print ("ienumformatetc_queryinterface %p", This);
|
|
|
|
|
PRINT_GUID (riid);
|
|
|
|
|
});
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID (riid, &IID_IUnknown))
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...IUnknown S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
ienumformatetc_addref (This);
|
|
|
|
|
*ppvObject = This;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
else if (IsEqualGUID (riid, &IID_IEnumFORMATETC))
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...IEnumFORMATETC S_OK\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
ienumformatetc_addref (This);
|
|
|
|
|
*ppvObject = This;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("...E_NOINTERFACE\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE
|
|
|
|
|
ienumformatetc_release (LPENUMFORMATETC This)
|
|
|
|
|
{
|
|
|
|
|
enum_formats *en = (enum_formats *) This;
|
|
|
|
|
int ref_count = --en->ref_count;
|
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("ienumformatetc_release %p %d\n", This, ref_count));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
if (ref_count == 0)
|
|
|
|
|
g_free (This);
|
|
|
|
|
|
|
|
|
|
return ref_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
|
|
|
|
ienumformatetc_next (LPENUMFORMATETC This,
|
|
|
|
|
ULONG celt,
|
|
|
|
|
LPFORMATETC elts,
|
|
|
|
|
ULONG *nelt)
|
|
|
|
|
{
|
|
|
|
|
enum_formats *en = (enum_formats *) This;
|
2015-10-16 07:22:39 +00:00
|
|
|
|
ULONG i, n;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("ienumformatetc_next %p %d %ld ", This, en->ix, celt));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
|
for (i = 0; i < celt; i++)
|
|
|
|
|
{
|
|
|
|
|
if (en->ix >= nformats)
|
|
|
|
|
break;
|
|
|
|
|
elts[i] = formats[en->ix++];
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nelt != NULL)
|
|
|
|
|
*nelt = n;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("%s\n", (n == celt) ? "S_OK" : "S_FALSE"));
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
if (n == celt)
|
|
|
|
|
return S_OK;
|
|
|
|
|
else
|
|
|
|
|
return S_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
|
|
|
|
ienumformatetc_skip (LPENUMFORMATETC This,
|
|
|
|
|
ULONG celt)
|
|
|
|
|
{
|
|
|
|
|
enum_formats *en = (enum_formats *) This;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("ienumformatetc_skip %p %d %ld S_OK\n", This, en->ix, celt));
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
en->ix += celt;
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
|
|
|
|
ienumformatetc_reset (LPENUMFORMATETC This)
|
|
|
|
|
{
|
|
|
|
|
enum_formats *en = (enum_formats *) This;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("ienumformatetc_reset %p S_OK\n", This));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
en->ix = 0;
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE
|
|
|
|
|
ienumformatetc_clone (LPENUMFORMATETC This,
|
|
|
|
|
LPENUMFORMATETC *ppEnumFormatEtc)
|
|
|
|
|
{
|
|
|
|
|
enum_formats *en = (enum_formats *) This;
|
|
|
|
|
enum_formats *new;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("ienumformatetc_clone %p S_OK\n", This));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
new = enum_formats_new ();
|
|
|
|
|
|
|
|
|
|
new->ix = en->ix;
|
|
|
|
|
|
|
|
|
|
*ppEnumFormatEtc = &new->ief;
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
static IDropTargetVtbl idt_vtbl = {
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idroptarget_queryinterface,
|
|
|
|
|
idroptarget_addref,
|
|
|
|
|
idroptarget_release,
|
|
|
|
|
idroptarget_dragenter,
|
|
|
|
|
idroptarget_dragover,
|
|
|
|
|
idroptarget_dragleave,
|
|
|
|
|
idroptarget_drop
|
1999-11-11 22:12:27 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static IDropSourceVtbl ids_vtbl = {
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idropsource_queryinterface,
|
|
|
|
|
idropsource_addref,
|
|
|
|
|
idropsource_release,
|
|
|
|
|
idropsource_querycontinuedrag,
|
|
|
|
|
idropsource_givefeedback
|
1999-11-11 22:12:27 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static IDataObjectVtbl ido_vtbl = {
|
2000-05-07 19:45:27 +00:00
|
|
|
|
idataobject_queryinterface,
|
|
|
|
|
idataobject_addref,
|
|
|
|
|
idataobject_release,
|
|
|
|
|
idataobject_getdata,
|
|
|
|
|
idataobject_getdatahere,
|
|
|
|
|
idataobject_querygetdata,
|
|
|
|
|
idataobject_getcanonicalformatetc,
|
|
|
|
|
idataobject_setdata,
|
|
|
|
|
idataobject_enumformatetc,
|
|
|
|
|
idataobject_dadvise,
|
|
|
|
|
idataobject_dunadvise,
|
|
|
|
|
idataobject_enumdadvise
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static IEnumFORMATETCVtbl ief_vtbl = {
|
|
|
|
|
ienumformatetc_queryinterface,
|
|
|
|
|
ienumformatetc_addref,
|
|
|
|
|
ienumformatetc_release,
|
|
|
|
|
ienumformatetc_next,
|
|
|
|
|
ienumformatetc_skip,
|
|
|
|
|
ienumformatetc_reset,
|
|
|
|
|
ienumformatetc_clone
|
1999-11-11 22:12:27 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static target_drag_context *
|
2009-12-16 11:04:29 +00:00
|
|
|
|
target_context_new (GdkWindow *window)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkDragContext *context;
|
|
|
|
|
GdkWin32DragContext *context_win32;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
target_drag_context *result;
|
|
|
|
|
|
2016-02-06 05:35:41 +00:00
|
|
|
|
context = gdk_drag_context_new (gdk_window_get_display (window));
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32 = GDK_WIN32_DRAG_CONTEXT (context);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
result = g_new0 (target_drag_context, 1);
|
|
|
|
|
result->context = context;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
result->idt.lpVtbl = &idt_vtbl;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
result->context->protocol = GDK_DRAG_PROTO_OLE2;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
result->context->is_source = FALSE;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
result->context->source_window = NULL;
|
|
|
|
|
|
|
|
|
|
result->context->dest_window = window;
|
|
|
|
|
g_object_ref (window);
|
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
/* FIXME: context->targets? */
|
2009-12-16 11:04:29 +00:00
|
|
|
|
result->context->actions = GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE;
|
|
|
|
|
result->context->suggested_action = GDK_ACTION_MOVE;
|
|
|
|
|
result->context->action = GDK_ACTION_MOVE;
|
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32->ole2_dnd_iface = (IUnknown *) &result->idt;
|
2009-03-11 13:37:26 +00:00
|
|
|
|
idroptarget_addref (&result->idt);
|
|
|
|
|
|
2000-10-09 19:49:42 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("target_context_new: %p\n", result));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static source_drag_context *
|
2009-12-16 11:04:29 +00:00
|
|
|
|
source_context_new (GdkWindow *window,
|
|
|
|
|
GList *targets)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkDragContext *context;
|
|
|
|
|
GdkWin32DragContext *context_win32;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
source_drag_context *result;
|
|
|
|
|
|
2016-02-06 05:35:41 +00:00
|
|
|
|
context = gdk_drag_context_new (gdk_window_get_display (window));
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32 = GDK_WIN32_DRAG_CONTEXT (context);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
result = g_new0 (source_drag_context, 1);
|
|
|
|
|
result->context = context;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
result->ids.lpVtbl = &ids_vtbl;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
result->context->protocol = GDK_DRAG_PROTO_OLE2;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
result->context->is_source = TRUE;
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
result->context->source_window = window;
|
|
|
|
|
g_object_ref (window);
|
|
|
|
|
|
|
|
|
|
result->context->dest_window = NULL;
|
|
|
|
|
result->context->targets = g_list_copy (targets);
|
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32->ole2_dnd_iface = (IUnknown *) &result->ids;
|
2009-03-11 13:37:26 +00:00
|
|
|
|
idropsource_addref (&result->ids);
|
|
|
|
|
|
2000-10-09 19:49:42 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("source_context_new: %p\n", result));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
static data_object *
|
2009-12-16 11:04:29 +00:00
|
|
|
|
data_object_new (GdkDragContext *context)
|
2000-05-07 19:45:27 +00:00
|
|
|
|
{
|
|
|
|
|
data_object *result;
|
|
|
|
|
|
|
|
|
|
result = g_new0 (data_object, 1);
|
|
|
|
|
|
|
|
|
|
result->ido.lpVtbl = &ido_vtbl;
|
|
|
|
|
result->ref_count = 1;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
result->context = context;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("data_object_new: %p\n", result));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static enum_formats *
|
|
|
|
|
enum_formats_new (void)
|
|
|
|
|
{
|
|
|
|
|
enum_formats *result;
|
|
|
|
|
|
|
|
|
|
result = g_new0 (enum_formats, 1);
|
|
|
|
|
|
|
|
|
|
result->ief.lpVtbl = &ief_vtbl;
|
|
|
|
|
result->ref_count = 1;
|
|
|
|
|
result->ix = 0;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
void
|
|
|
|
|
_gdk_win32_ole2_dnd_property_change (GdkAtom type,
|
|
|
|
|
gint format,
|
|
|
|
|
const guchar *data,
|
|
|
|
|
gint nelements)
|
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (use_ole2_dnd)
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
HGLOBAL hdata = NULL;
|
|
|
|
|
|
|
|
|
|
if (active_pFormatEtc == NULL || active_pMedium == NULL)
|
|
|
|
|
return;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Set up the data buffer for wide character text request */
|
|
|
|
|
if (active_pFormatEtc->cfFormat == CF_UNICODETEXT)
|
2009-12-16 11:04:29 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
gunichar2 *wdata;
|
|
|
|
|
glong wlen;
|
|
|
|
|
|
|
|
|
|
wdata = g_utf8_to_utf16 ((const char *) data, -1, NULL, &wlen, NULL);
|
|
|
|
|
hdata = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (wlen + 1) * 2);
|
|
|
|
|
if (hdata)
|
|
|
|
|
{
|
|
|
|
|
wchar_t *ptr = (wchar_t *) GlobalLock(hdata);
|
|
|
|
|
memcpy (ptr, wdata, (wlen + 1) * 2);
|
|
|
|
|
GlobalUnlock(hdata);
|
|
|
|
|
}
|
|
|
|
|
g_free (wdata);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
}
|
2009-12-16 23:50:47 +00:00
|
|
|
|
else
|
|
|
|
|
g_warning ("Only text handled for now");
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Pack up data */
|
|
|
|
|
active_pMedium->tymed = TYMED_HGLOBAL;
|
|
|
|
|
active_pMedium->hGlobal = hdata;
|
|
|
|
|
active_pMedium->pUnkForRelease = 0;
|
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
/* From MS Knowledge Base article Q130698 */
|
|
|
|
|
|
2008-03-24 17:35:02 +00:00
|
|
|
|
static gboolean
|
2004-12-19 21:00:58 +00:00
|
|
|
|
resolve_link (HWND hWnd,
|
2008-03-24 17:35:02 +00:00
|
|
|
|
wchar_t *link,
|
2008-08-04 22:35:16 +00:00
|
|
|
|
gchar **lpszPath)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2008-03-24 17:35:02 +00:00
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA wfad;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
HRESULT hr;
|
2004-12-19 21:00:58 +00:00
|
|
|
|
IShellLinkW *pslW = NULL;
|
|
|
|
|
IPersistFile *ppf = NULL;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2008-03-24 17:35:02 +00:00
|
|
|
|
/* Check if the file is empty first because IShellLink::Resolve for
|
|
|
|
|
* some reason succeeds with an empty file and returns an empty
|
|
|
|
|
* "link target". (#524151)
|
|
|
|
|
*/
|
|
|
|
|
if (!GetFileAttributesExW (link, GetFileExInfoStandard, &wfad) ||
|
|
|
|
|
(wfad.nFileSizeHigh == 0 && wfad.nFileSizeLow == 0))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2004-12-19 21:00:58 +00:00
|
|
|
|
/* Assume failure to start with: */
|
1999-11-11 22:12:27 +00:00
|
|
|
|
*lpszPath = 0;
|
|
|
|
|
|
|
|
|
|
/* Call CoCreateInstance to obtain the IShellLink interface
|
|
|
|
|
* pointer. This call fails if CoInitialize is not called, so it is
|
|
|
|
|
* assumed that CoInitialize has been called.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
hr = CoCreateInstance (&CLSID_ShellLink,
|
|
|
|
|
NULL,
|
|
|
|
|
CLSCTX_INPROC_SERVER,
|
|
|
|
|
&IID_IShellLinkW,
|
|
|
|
|
(LPVOID *)&pslW);
|
2004-12-19 21:00:58 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
if (SUCCEEDED (hr))
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
/* The IShellLink interface supports the IPersistFile
|
|
|
|
|
* interface. Get an interface pointer to it.
|
|
|
|
|
*/
|
2009-12-16 11:04:29 +00:00
|
|
|
|
hr = pslW->lpVtbl->QueryInterface (pslW,
|
|
|
|
|
&IID_IPersistFile,
|
|
|
|
|
(LPVOID *) &ppf);
|
|
|
|
|
}
|
2004-12-19 21:00:58 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
if (SUCCEEDED (hr))
|
2004-12-19 21:00:58 +00:00
|
|
|
|
{
|
|
|
|
|
/* Load the file. */
|
2009-12-16 11:04:29 +00:00
|
|
|
|
hr = ppf->lpVtbl->Load (ppf, link, STGM_READ);
|
2004-12-19 21:00:58 +00:00
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
|
|
|
|
if (SUCCEEDED (hr))
|
2004-12-19 21:00:58 +00:00
|
|
|
|
{
|
|
|
|
|
/* Resolve the link by calling the Resolve()
|
|
|
|
|
* interface function.
|
|
|
|
|
*/
|
2009-12-16 11:04:29 +00:00
|
|
|
|
hr = pslW->lpVtbl->Resolve (pslW, hWnd, SLR_ANY_MATCH | SLR_NO_UI);
|
2004-12-19 21:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
if (SUCCEEDED (hr))
|
2004-12-19 21:00:58 +00:00
|
|
|
|
{
|
2006-08-29 23:01:53 +00:00
|
|
|
|
wchar_t wtarget[MAX_PATH];
|
2004-12-19 21:00:58 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
hr = pslW->lpVtbl->GetPath (pslW, wtarget, MAX_PATH, NULL, 0);
|
|
|
|
|
if (SUCCEEDED (hr))
|
2006-08-29 23:01:53 +00:00
|
|
|
|
*lpszPath = g_utf16_to_utf8 (wtarget, -1, NULL, NULL, NULL);
|
2004-12-19 21:00:58 +00:00
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2004-12-19 21:00:58 +00:00
|
|
|
|
if (ppf)
|
|
|
|
|
ppf->lpVtbl->Release (ppf);
|
2006-08-29 23:01:53 +00:00
|
|
|
|
|
2004-12-19 21:00:58 +00:00
|
|
|
|
if (pslW)
|
|
|
|
|
pslW->lpVtbl->Release (pslW);
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
return SUCCEEDED (hr);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-14 22:32:14 +00:00
|
|
|
|
#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
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
static GdkFilterReturn
|
|
|
|
|
gdk_dropfiles_filter (GdkXEvent *xev,
|
|
|
|
|
GdkEvent *event,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GdkDragContext *context;
|
|
|
|
|
GString *result;
|
|
|
|
|
MSG *msg = (MSG *) xev;
|
|
|
|
|
HANDLE hdrop;
|
|
|
|
|
POINT pt;
|
2000-10-09 19:49:42 +00:00
|
|
|
|
gint nfiles, i;
|
2008-08-04 22:35:16 +00:00
|
|
|
|
gchar *fileName, *linkedFile;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
if (msg->message == WM_DROPFILES)
|
|
|
|
|
{
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("WM_DROPFILES: %p\n", msg->hwnd));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2016-02-06 05:35:41 +00:00
|
|
|
|
context = gdk_drag_context_new (gdk_window_get_display (event->any.window));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
|
|
|
|
|
context->is_source = FALSE;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2017-11-14 23:05:41 +00:00
|
|
|
|
context->source_window = NULL;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
context->dest_window = event->any.window;
|
2003-06-30 21:58:24 +00:00
|
|
|
|
g_object_ref (context->dest_window);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
/* WM_DROPFILES drops are always file names */
|
|
|
|
|
context->targets =
|
2009-12-16 11:04:29 +00:00
|
|
|
|
g_list_append (NULL, _text_uri_list);
|
2005-06-17 19:41:01 +00:00
|
|
|
|
context->actions = GDK_ACTION_COPY;
|
|
|
|
|
context->suggested_action = GDK_ACTION_COPY;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
current_dest_drag = context;
|
|
|
|
|
|
|
|
|
|
event->dnd.type = GDK_DROP_START;
|
|
|
|
|
event->dnd.context = current_dest_drag;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
gdk_event_set_device (event, gdk_drag_context_get_device (current_dest_drag));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (event, gdk_device_get_seat (gdk_drag_context_get_device (current_dest_drag)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
hdrop = (HANDLE) msg->wParam;
|
|
|
|
|
DragQueryPoint (hdrop, &pt);
|
|
|
|
|
ClientToScreen (msg->hwnd, &pt);
|
|
|
|
|
|
2005-04-30 17:50:00 +00:00
|
|
|
|
event->dnd.x_root = pt.x + _gdk_offset_x;
|
|
|
|
|
event->dnd.y_root = pt.y + _gdk_offset_y;
|
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to
2002-11-12 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkprivate-win32.h
* gdk/win32/*.c: Rename all global variables and functions to
start with underscore.
Merge from stable:
More work on the Win32 backend. The cause of some scrolling
problems was that SetWindowPos() and ScrollWindowEx() don't blit
those parts of the window they think are invalid. As we didn't
keep Windows's update region in synch with GDK's, Windows thought
those areas that in fact had been updated were invalid. Calling
ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to
be an elegant and efficient solution, removing from Windows's
update region those areas we are about to repaint proactively.
In some cases garbage leftover values were used for the clip
origin in GdkGCWin32. This showed up as odd blank areas around the
pixmaps included in the Text Widget in gtk-demo.
Having the clip region either as a GdkRegion or a HRGN in
GdkGCWin32 was unnecessary, it's better to just use a HRGN.
The translation and antiexpose queue handling in
gdkgeometry-win32.c seems unnecessary (and not implementable in
the same way as on X11 anyway, no serial numbers) on Windows,
ifdeffed out.
Don't (try to) do guffaw scrolling as there is no static window
gravity on Windows. Guffaw scrolling would be unnecessary anyway,
as there is the ScrollWindow() API. This improves the behaviour of
the Text Widget demo in gtk-demo a lot. But I have no idea how the
lack of static win gravity should be handled in other places where
the X11 code uses it. Especially _gdk_window_move_resize_child().
There is still some problem in expose handling. By moving an
obscuring window back and forth over testgtk's main window, for
instance, every now and then you typically get narrow vertical or
horizontal strips of pixels that haven't been properly redrawn
after being exposed. A fencepost error somewhere?
Otherwise, all of testgtk and gtk-demo except "big windows" now
seem to work pretty well.
Bug #79720 should be fixed now.
* gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string,
gdk_win32_print_paletteentries, gdk_win32_print_system_palette,
gdk_win32_print_hpalette)
* gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description)
* gdk/win32/gdkevents-win32.c (gdk_win32_message_name):
Move all debugging helper functions to gdkmain-win32.c.
* gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles):
Rewrite. Make static. Must take tile origin parameters, too.
(gdk_win32_draw_rectangle): Pass the tile/stipple origin to
_gdk_win32_draw_tiles(). Remove #if 0 code.
(blit_inside_window): Don't call ScrollDC(), that didn't work at
all like I thought. A simple call to BitBlt() is enough.
* gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused
latin_locale_loaded variable.
(_gdk_win32_get_next_tick): New function. Used to make sure
timestamps of events are always increasing, both in events
generated from the window procedure and in events gotten via
PeekMessage(). Not sure whether this is actually useful, but it
seemed as a good idea.
(real_window_procedure): Don't use a local GdkEventPrivate
variable. Don't attempt any compression of configure or expose
events here, handled elsewhere.
(erase_background): Accumulate window offsets when traversing up
the parent chain for GDK_PARENT_RELATIVE_BG, in order to get
correct alignment of background pixmaps. Don't fill with
BLACK_BRUSH if GDK_NO_BG.
(gdk_event_get_graphics_expose): A bit more verbose debugging output.
(gdk_event_translate): Use _gdk_win32_get_next_tick(). In the
WM_PAINT handler, don't check for empty update rect. When we get a
WM_PAINT, the update region isn't empty. And if it for some
strange reason is, that will be handled later anyway. Call
GetUpdateRgn() before calling BeginPaint() and EndPaint() (which
empty the update region).
* gdk/win32/gdkdnd-win32.c
* gdk/win32/gdkinput-win32.c:
Use _gdk_win32_get_next_tick().
* gdk/win32/gdkfont-win32.c: Use %p to print HFONTs.
(gdk_text_size): Remove, unused.
* gdk/win32/gdkgc-win32.c: Set clip origins to zero
when appropriate.
(gdk_gc_copy): Increase refcount on colormap if present.
(gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple,
combine it with clip region after selecting into the DC.
(_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region.
(_gdk_win3_gdkregion_to_hrgn): New function, code snippet
extracted from gdk_win32_hdc_get().
* gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue
handling.
(gdk_window_copy_area_scroll): Increase clipRect to avoid
ScrollWindowEx() not scrolling pixels it thinks are invalid.
Scroll also children with the ScrollWindowEx() call. No need to
call gdk_window_move() on the children.
(gdk_window_scroll): Don't do guffaw scrolling.
(gdk_window_compute_position): Fix typo, used win32_y where x was
intended.
(gdk_window_premove, gdk_window_postmove,
gdk_window_clip_changed): Add debugging output.
(_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn()
on the region.
(_gdk_window_process_expose): No use for the serial number
parameter now. Instead of a rectangle, take a region parameter, as
Windows gives us one in WM_PAINT.
* gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string,
_gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string,
_gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string,
_gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string,
_gdk_win32_gdkregion_to_string): New debugging functions.
(static_printf): Helper function for the above. sprintfs into a
static circular buffer, return value should be used "soon".
* gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory
leak, free list after use.
(gdk_window_gravity_works): Remove, we know that there is no such
thing on Windows.
(gdk_window_set_static_bit_gravity,
gdk_window_set_static_win_gravity): Ditto, remove, they didn't do
anything anyway.
(_gdk_windowing_window_init, gdk_window_foreign_new): Call
_gdk_window_init_position() like in the X11 backend.
(gdk_window_reparent): Don't call the now nonexistent
gdk_window_set_static_win_gravity(). No idea what should be done
instead.
(gdk_window_get_geometry): The returned x and y should be relative
to parent. Used to be always zero..
(gdk_window_set_static_gravities): Return FALSE if trying to set
static gravity.
* gdk/win32/gdkprivate-win32.h: Drop the clip_region field from
GdkGCWin32. Only use the HRGN hcliprgn. Declare new
functions.
* gdk/win32/*.c: Use new debugging functions.
* gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
|
|
|
|
event->dnd.time = _gdk_win32_get_next_tick (msg->time);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
nfiles = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
|
|
|
|
|
|
|
|
|
|
result = g_string_new (NULL);
|
|
|
|
|
for (i = 0; i < nfiles; i++)
|
|
|
|
|
{
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
|
gchar *uri;
|
2006-08-29 23:01:53 +00:00
|
|
|
|
wchar_t wfn[MAX_PATH];
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
|
|
2006-08-29 23:01:53 +00:00
|
|
|
|
DragQueryFileW (hdrop, i, wfn, MAX_PATH);
|
|
|
|
|
fileName = g_utf16_to_utf8 (wfn, -1, NULL, NULL, NULL);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
/* Resolve shortcuts */
|
2008-03-24 17:35:02 +00:00
|
|
|
|
if (resolve_link (msg->hwnd, wfn, &linkedFile))
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
|
uri = g_filename_to_uri (linkedFile, NULL, NULL);
|
|
|
|
|
if (uri != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_string_append (result, uri);
|
2005-03-16 01:38:57 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("... %s link to %s: %s\n",
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
|
fileName, linkedFile, uri));
|
|
|
|
|
g_free (uri);
|
|
|
|
|
}
|
2009-11-14 22:32:14 +00:00
|
|
|
|
g_free (fileName);
|
|
|
|
|
fileName = linkedFile;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
|
uri = g_filename_to_uri (fileName, NULL, NULL);
|
|
|
|
|
if (uri != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_string_append (result, uri);
|
2005-03-16 01:38:57 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("... %s: %s\n", fileName, uri));
|
Massive changes. Too many to list here, but I'll try a summary:
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-17 00:25:05 +00:00
|
|
|
|
g_free (uri);
|
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
2009-11-14 22:32:14 +00:00
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
2004-12-19 21:00:58 +00:00
|
|
|
|
g_free (fileName);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
g_string_append (result, "\015\012");
|
|
|
|
|
}
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
_gdk_dropfiles_store (result->str);
|
|
|
|
|
g_string_free (result, FALSE);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
DragFinish (hdrop);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
return GDK_FILTER_TRANSLATE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return GDK_FILTER_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
static void
|
|
|
|
|
add_format (GArray *fmts,
|
|
|
|
|
CLIPFORMAT cf)
|
|
|
|
|
{
|
|
|
|
|
FORMATETC fmt;
|
|
|
|
|
|
|
|
|
|
fmt.cfFormat = cf;
|
|
|
|
|
fmt.ptd = NULL;
|
|
|
|
|
fmt.dwAspect = DVASPECT_CONTENT;
|
|
|
|
|
fmt.lindex = -1;
|
|
|
|
|
fmt.tymed = TYMED_HGLOBAL;
|
|
|
|
|
|
|
|
|
|
g_array_append_val (fmts, fmt);
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
void
|
Make gdkx.h the only installed header from gdk/x11. All structures in
Fri Sep 7 11:51:44 2001 Owen Taylor <otaylor@redhat.com>
Make gdkx.h the only installed header from gdk/x11.
All structures in gdk/x11 are opaque.
* gdk/x11/Makefile.am gdk/x11/gdkx.h gdk/x11/gdkprivate-x11.h:
Don't install gdk{drawable,pixmap,window}-x11.h.
* gdk/x11/{gdkcolormap-x11.c, gdkfont-x11.c, gdkx.h, gdkvisual-x11.c:
Move GdkColormapPrivateX11, GdkFontPrivateX GdkImagePrivateX11,
GdkVisualClass into C files.
* gdk/gdkpixmap-x11.[ch]: Make gdk_pixmap_impl_get_type() static.
* gdk/x11/{gdkcolor-x11.c, gdkcursor-x11.c, gdkdrawable-x11.c,
gdkfont-x11.c, gdkgc-x11.c, gdkx.h, gdkimage-x11,gdkvisual-x11.c}
Add public functions to replace previously exported direct
structure access.
gdk_x11_colormap_get_{xdisplay,xcolormap}
gdk_x11_cursor_get_{xdisplay,xcursor},
gdk_x11_drawable_get_{xdisplay,xcursor,gdk_x11_visual_get_xvisual,
gdk_x11_font_get_{xdisplay,xfont}, gdk_x11_image_get_{xdisplay,ximage},
gdk_x11_gc_get_{xdisplay,ximage}
* gdk/gdkprivate.h gdk/gdkinternals.h: Move GdkColorInfo,
GdkEventFilter, GdkClientFilter, GdkFontPrivate to gdkinternals.
Fix a number of variables and functions that were exported
"accidentally" from GDK.
* gdk/**.[ch]: gdk => _gdk for gdk_visual_init,
gdk_events_init, gdk_input_init, gdk_dnd_init, gdk_image_exit,
gdk_input_exit, gdk_windowing_exit, gdk_event_func, gdk_event_data,
gdk_event_notify, gdk_queued_events, gdk_queued_tail,
gdk_event_new, gdk_events_queue, gdk_events_unqueue,
gdk_event_queue_find_first, gdk_event_queue_remove_link,
gdk_event_queue_append, gdk_event_button_generate,
gdk_debug_flags, gdk_default_filters, gdk_parent_root.
* gdk/x11/{gdkevents-x11.c, gdkglobals-x11.c, gdkimage-x11.c,
gdkmain-x11.c, gdkprivate-x11.h, gdk/x11/gdkwindow-x11.c}:
gdk => _gdk for gdk_event_mask_table, gkd_nevent_masks,
gdk_wm_window_protocols, gdk_leader_window, gdk_xgrab_window,
gdk_use_xshm, gdk_input_ignore_core.
* gdk/x11/xsettings-common.h (xsettings_list_insert): Add
#defines to namespace functions into the private _gdk_
namespace.
* gdk/gdkwindow.[ch] gdk/x11/gdkx.h: Add gdk_get_default_root_window ()
to replace gdk_parent_root exported variable. Adjust and
deprecate GDK_ROOT_PARENT().
* demos/{testpixbuf-drawable.c,testpixbuf-save.c}: Fix
GDK_ROOT_PARENT usage, remove includes of port-specific
headers.
* gdk/{win32,x11,fb}/gdkinput*.[ch]: s/gdk/_gdk/ for
_gdk_input_gxid_host, _gdk_input_gxid_port, _gdk_input_ignore_core,
gdk_input_devices, _gdk_input_windows, gdk_init_input_core.
* gdk/x11/{gdkevents-x11.,c gdkglobals-x11.c, gdkmain-x11.c}
docs/Changes-2.0.txt: Remove gdk_wm_protocols,
gdk_wm_delete_window functions, gdk_wm_take_focus,
use gdk_atom_intern() instead.
* gdk/linux-fb/{gdkselection-fb.c, gdkmain-fb.c, gdkprivatefb.h}
gdk/win32/{gdkselection-win32.c, gdkmgdkwin32.h, gdkprivate-win32.h}
gdk/x11/{gdkselection-x11.c gdkx.h, gtkprivate-x11.h}
gtk/gtkselection.c
Unexport gdk_selection_property, just use
gdk_atom_intern ("GDK_SELECTION").
* gdk/x11/{gdkprivate-x11.h,gdkdrawable-x11h,gdkgc-x11.c,gdkx.h}:
Unexport gdk_drawable_impl_x11_get_type, gdk_gc_x11_get_type,
GDK_GC_X11 cast macros, GdkGCX11 structures, GdkCursorPrivate,
GdkVisualprivate, gdk_x11_gc_flush.
Make a number of public exports of variables into functions
to increase encapsulation.
* gdk/gdkinternals.h gdk/gdkinput.h gdk/gdkevents.h
gdk/linux-fb/gdkmouse-fb.c: gdk_core_pointer => _gdk_core_pointer,
move to gdkinternals.h. Add gdk_device_get_core_pointer ().
* gdk/gdkprivate.h gdk/gdkpango.c gdk/gdkinternals.h
docs/Changes-2.0.txt: Unexport gdk_parent_root, gdk_error_code,
gdk_error_warnings.
* gdk/x11/{gdkcolormap-x11.c, gdkmain-x11.c, gdkx.h}
docs/Changes-2.0.txt:
s/gdk_screen/_gdk_screen/, add gdk_x11_get_default_screen()
s/gdk_root_window/_gdk_root_window/, add gdk_x11_get_default_root_xwindow()
Add gdk_x11_get_default_xdisplay().
* gdk/gdk.h gdk/gdk.c linux-fb/gdkfb.h linux-fb/gdkglobals-fb.c
win32/gdkwin32.h x11/gdkglobals-x11.c gdk/x11/gdkmain-x11.c
gdk/x11/gdkx.h: gdk/gdk.def: Add gdk_get/set_program_class,
Don't export gdk_progclass, move --class command line
option and handling to common portion of GDK.
Miscellaneous fixes:
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Fix
g_return_val_if_fail that should have been g_return_if_fail.
* gdk/gdkinternals.h gdk/gdkprivate.h: Move
gdk_synthesize_window_state() to the semi-public gdkprivate.h.
* gtk/gtkdnd.c (_gtk_drag_source_handle_event): Remove uneeded
X11 dependency.
* gdk/linux-fb/gdkmain-fb.c gdk/win32/gdkmain-win32.c gdk/TODO:
Remove unused gdk_key_repeat_disable/restore.
* linux-fb/gdkglobals-fb.c win32/gdkglobals-win32.c
x11/gdkglobals-x11.c x11/gdkprivate-x11.h gdk/gdk.def:
Remove unused gdk_null_window_warnings variable.
* gdk/Makefile.am (DIST_SUBDIRS) nanox/*: cvs remove nanox;
it can be retrieved from the repository; it is too far
from functional to be worth having people check out;
it would be easier to start from scratch, I suspect.
* gdk/x11/gdkpixmap-x11.c: Fix lvalue usage of GDK_PIXMAP_XID().
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
* gdk/x11/gdkkeys-x11.c gdk/gdkrgb.c gdk/gdkwindow.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkselection-x11.c:
Fix some accidentally global variables and unused global variables.
Add some space for future expansion to multihead.
* gdk/gdkdrawable.h: Add four reserved function pointers
for future expansion of GdkDrawableClass.
* gtk/gtkwindow.h gtk/gtkinvisible.h: Add reserved pointer
where we can put a GdkScreen * later.
2001-09-07 21:50:20 +00:00
|
|
|
|
_gdk_dnd_init (void)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2015-12-14 18:40:25 +00:00
|
|
|
|
CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
|
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (getenv ("GDK_WIN32_USE_EXPERIMENTAL_OLE2_DND"))
|
|
|
|
|
use_ole2_dnd = TRUE;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (use_ole2_dnd)
|
|
|
|
|
{
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
GArray *fmts;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
hr = OleInitialize (NULL);
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (! SUCCEEDED (hr))
|
|
|
|
|
g_error ("OleInitialize failed");
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
fmts = g_array_new (FALSE, FALSE, sizeof (FORMATETC));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* The most important presumably */
|
|
|
|
|
add_format (fmts, CF_UNICODETEXT);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Used for GTK+ internal DND, I think was the intent? Anyway, code below assumes
|
|
|
|
|
* this is at index 1.
|
|
|
|
|
*/
|
|
|
|
|
add_format (fmts, CF_GDIOBJFIRST);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
add_format (fmts, CF_HDROP);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
add_format (fmts, _cf_png);
|
|
|
|
|
add_format (fmts, CF_DIB);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
add_format (fmts, _cf_url);
|
|
|
|
|
add_format (fmts, _cf_html_format);
|
|
|
|
|
add_format (fmts, _cf_text_html);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
nformats = fmts->len;
|
|
|
|
|
formats = (FORMATETC*) g_array_free (fmts, FALSE);
|
|
|
|
|
|
|
|
|
|
target_ctx_for_window = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
void
|
2001-10-28 21:28:51 +00:00
|
|
|
|
_gdk_win32_dnd_exit (void)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (use_ole2_dnd)
|
|
|
|
|
{
|
|
|
|
|
OleUninitialize ();
|
|
|
|
|
}
|
2015-12-14 18:40:25 +00:00
|
|
|
|
|
|
|
|
|
CoUninitialize ();
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Source side */
|
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
|
static void
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
local_send_leave (GdkDragContext *context,
|
|
|
|
|
guint32 time)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkEvent *tmp_event;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-03-11 14:09:13 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("local_send_leave: context=%p current_dest_drag=%p\n",
|
|
|
|
|
context,
|
|
|
|
|
current_dest_drag));
|
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
|
if ((current_dest_drag != NULL) &&
|
|
|
|
|
(current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&
|
|
|
|
|
(current_dest_drag->source_window == context->source_window))
|
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event = gdk_event_new (GDK_DRAG_LEAVE);
|
|
|
|
|
|
|
|
|
|
tmp_event->dnd.window = g_object_ref (context->dest_window);
|
2001-08-19 18:34:59 +00:00
|
|
|
|
/* Pass ownership of context to the event */
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event->dnd.send_event = FALSE;
|
|
|
|
|
tmp_event->dnd.context = g_object_ref (current_dest_drag);
|
|
|
|
|
tmp_event->dnd.time = GDK_CURRENT_TIME; /* FIXME? */
|
|
|
|
|
gdk_event_set_device (tmp_event, gdk_drag_context_get_device (context));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (tmp_event, gdk_device_get_seat (gdk_drag_context_get_device (context)));
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
|
|
|
|
current_dest_drag = NULL;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (tmp_event));
|
|
|
|
|
gdk_event_put (tmp_event);
|
|
|
|
|
gdk_event_free (tmp_event);
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
local_send_enter (GdkDragContext *context,
|
|
|
|
|
guint32 time)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkEvent *tmp_event;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
GdkDragContext *new_context;
|
|
|
|
|
|
2009-03-11 14:09:13 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("local_send_enter: context=%p current_dest_drag=%p\n",
|
|
|
|
|
context,
|
|
|
|
|
current_dest_drag));
|
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
|
if (current_dest_drag != NULL)
|
|
|
|
|
{
|
2009-03-11 13:37:26 +00:00
|
|
|
|
g_object_unref (G_OBJECT (current_dest_drag));
|
2001-08-19 18:34:59 +00:00
|
|
|
|
current_dest_drag = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-06 05:35:41 +00:00
|
|
|
|
new_context = gdk_drag_context_new (gdk_window_get_display (context->source_window));
|
2001-08-19 18:34:59 +00:00
|
|
|
|
new_context->protocol = GDK_DRAG_PROTO_LOCAL;
|
|
|
|
|
new_context->is_source = FALSE;
|
|
|
|
|
|
|
|
|
|
new_context->source_window = context->source_window;
|
2003-06-30 21:58:24 +00:00
|
|
|
|
g_object_ref (new_context->source_window);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
|
new_context->dest_window = context->dest_window;
|
2003-06-30 21:58:24 +00:00
|
|
|
|
g_object_ref (new_context->dest_window);
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
|
|
|
|
new_context->targets = g_list_copy (context->targets);
|
|
|
|
|
|
|
|
|
|
gdk_window_set_events (new_context->source_window,
|
|
|
|
|
gdk_window_get_events (new_context->source_window) |
|
|
|
|
|
GDK_PROPERTY_CHANGE_MASK);
|
|
|
|
|
new_context->actions = context->actions;
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event = gdk_event_new (GDK_DRAG_ENTER);
|
|
|
|
|
tmp_event->dnd.window = g_object_ref (context->dest_window);
|
|
|
|
|
tmp_event->dnd.send_event = FALSE;
|
|
|
|
|
tmp_event->dnd.context = g_object_ref (new_context);
|
|
|
|
|
tmp_event->dnd.time = GDK_CURRENT_TIME; /* FIXME? */
|
|
|
|
|
gdk_event_set_device (tmp_event, gdk_drag_context_get_device (context));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (tmp_event, gdk_device_get_seat (gdk_drag_context_get_device (context)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
|
current_dest_drag = new_context;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (tmp_event));
|
|
|
|
|
gdk_event_put (tmp_event);
|
|
|
|
|
gdk_event_free (tmp_event);
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
local_send_motion (GdkDragContext *context,
|
2009-12-16 11:04:29 +00:00
|
|
|
|
gint x_root,
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
gint y_root,
|
|
|
|
|
GdkDragAction action,
|
|
|
|
|
guint32 time)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkEvent *tmp_event;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32 = GDK_WIN32_DRAG_CONTEXT (context);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
|
|
|
|
GDK_NOTE (DND, g_print ("local_send_motion: context=%p (%d,%d) current_dest_drag=%p\n",
|
|
|
|
|
context, x_root, y_root,
|
2009-03-11 14:09:13 +00:00
|
|
|
|
current_dest_drag));
|
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
|
if ((current_dest_drag != NULL) &&
|
|
|
|
|
(current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&
|
|
|
|
|
(current_dest_drag->source_window == context->source_window))
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *current_dest_drag_win32;
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event = gdk_event_new (GDK_DRAG_MOTION);
|
|
|
|
|
tmp_event->dnd.window = g_object_ref (current_dest_drag->dest_window);
|
|
|
|
|
tmp_event->dnd.send_event = FALSE;
|
|
|
|
|
tmp_event->dnd.context = g_object_ref (current_dest_drag);
|
|
|
|
|
tmp_event->dnd.time = time;
|
|
|
|
|
gdk_event_set_device (tmp_event, gdk_drag_context_get_device (current_dest_drag));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (tmp_event, gdk_device_get_seat (gdk_drag_context_get_device (current_dest_drag)));
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
|
|
|
|
current_dest_drag->suggested_action = action;
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event->dnd.x_root = x_root;
|
|
|
|
|
tmp_event->dnd.y_root = y_root;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
current_dest_drag_win32 = GDK_WIN32_DRAG_CONTEXT (current_dest_drag);
|
|
|
|
|
current_dest_drag_win32->ole2_dnd_last_pt.x = x_root - _gdk_offset_x;
|
|
|
|
|
current_dest_drag_win32->ole2_dnd_last_pt.y = y_root - _gdk_offset_y;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (tmp_event));
|
|
|
|
|
gdk_event_put (tmp_event);
|
|
|
|
|
gdk_event_free (tmp_event);
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
local_send_drop (GdkDragContext *context,
|
|
|
|
|
guint32 time)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkEvent *tmp_event;
|
2009-03-11 14:09:13 +00:00
|
|
|
|
|
|
|
|
|
GDK_NOTE (DND, g_print ("local_send_drop: context=%p current_dest_drag=%p\n",
|
|
|
|
|
context,
|
|
|
|
|
current_dest_drag));
|
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
|
if ((current_dest_drag != NULL) &&
|
|
|
|
|
(current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&
|
|
|
|
|
(current_dest_drag->source_window == context->source_window))
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2004-02-28 13:21:25 +00:00
|
|
|
|
/* Pass ownership of context to the event */
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event = gdk_event_new (GDK_DROP_START);
|
|
|
|
|
tmp_event->dnd.window = g_object_ref (current_dest_drag->dest_window);
|
|
|
|
|
tmp_event->dnd.send_event = FALSE;
|
|
|
|
|
tmp_event->dnd.context = g_object_ref (current_dest_drag);
|
|
|
|
|
tmp_event->dnd.time = GDK_CURRENT_TIME;
|
|
|
|
|
gdk_event_set_device (tmp_event, gdk_drag_context_get_device (current_dest_drag));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (tmp_event, gdk_device_get_seat (gdk_drag_context_get_device (current_dest_drag)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32 = GDK_WIN32_DRAG_CONTEXT (current_dest_drag);
|
|
|
|
|
tmp_event->dnd.x_root = context_win32->ole2_dnd_last_pt.x + _gdk_offset_x;
|
|
|
|
|
tmp_event->dnd.y_root = context_win32->ole2_dnd_last_pt.y + _gdk_offset_y;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2004-02-28 13:21:25 +00:00
|
|
|
|
current_dest_drag = NULL;
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (tmp_event));
|
|
|
|
|
gdk_event_put (tmp_event);
|
|
|
|
|
gdk_event_free (tmp_event);
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
static void
|
2000-05-07 19:45:27 +00:00
|
|
|
|
gdk_drag_do_leave (GdkDragContext *context,
|
|
|
|
|
guint32 time)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
if (context->dest_window)
|
|
|
|
|
{
|
2000-05-07 19:45:27 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drag_do_leave\n"));
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
|
|
|
|
{
|
|
|
|
|
if (context->protocol == GDK_DRAG_PROTO_LOCAL)
|
|
|
|
|
local_send_leave (context, time);
|
|
|
|
|
}
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
g_object_unref (context->dest_window);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
context->dest_window = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GdkDragContext *
|
2011-01-02 10:51:25 +00:00
|
|
|
|
_gdk_win32_window_drag_begin (GdkWindow *window,
|
|
|
|
|
GdkDevice *device,
|
2015-12-07 18:47:45 +00:00
|
|
|
|
GList *targets,
|
|
|
|
|
gint x_root,
|
|
|
|
|
gint y_root)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
|
|
|
|
{
|
|
|
|
|
GdkDragContext *new_context;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
g_return_val_if_fail (window != NULL, NULL);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2016-02-06 05:35:41 +00:00
|
|
|
|
new_context = gdk_drag_context_new (gdk_window_get_display (window));
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
new_context->is_source = TRUE;
|
|
|
|
|
new_context->source_window = window;
|
|
|
|
|
g_object_ref (window);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
new_context->targets = g_list_copy (targets);
|
|
|
|
|
new_context->actions = 0;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
return new_context;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
source_drag_context *ctx;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
g_return_val_if_fail (window != NULL, NULL);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drag_begin\n"));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
ctx = source_context_new (window, targets);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
_dnd_source_state = GDK_WIN32_DND_PENDING;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
pending_src_context = ctx;
|
2010-05-10 15:27:00 +00:00
|
|
|
|
g_object_ref (ctx->context);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
return ctx->context;
|
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gdk_win32_dnd_do_dragdrop (void)
|
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (use_ole2_dnd)
|
|
|
|
|
{
|
|
|
|
|
GdkDragContext* drag_ctx;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *drag_ctx_win32;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
BYTE kbd_state[256];
|
|
|
|
|
data_object *dobj;
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
DWORD dwEffect;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#if 0
|
2009-12-16 23:50:47 +00:00
|
|
|
|
HGLOBAL global;
|
|
|
|
|
STGMEDIUM medium;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#endif
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (pending_src_context == NULL)
|
|
|
|
|
return;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
drag_ctx = pending_src_context->context;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
drag_ctx_win32 = GDK_WIN32_DRAG_CONTEXT (drag_ctx);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
dobj = data_object_new (drag_ctx);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
API_CALL (GetCursorPos, (&drag_ctx_win32->ole2_dnd_last_pt));
|
|
|
|
|
API_CALL (ScreenToClient, (GDK_WINDOW_HWND (drag_ctx->source_window), &drag_ctx_win32->ole2_dnd_last_pt));
|
|
|
|
|
drag_ctx_win32->ole2_dnd_last_key_state = 0;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
API_CALL (GetKeyboardState, (kbd_state));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (kbd_state[VK_CONTROL])
|
2011-09-22 20:47:23 +00:00
|
|
|
|
drag_ctx_win32->ole2_dnd_last_key_state |= MK_CONTROL;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (kbd_state[VK_SHIFT])
|
2011-09-22 20:47:23 +00:00
|
|
|
|
drag_ctx_win32->ole2_dnd_last_key_state |= MK_SHIFT;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (kbd_state[VK_LBUTTON])
|
2011-09-22 20:47:23 +00:00
|
|
|
|
drag_ctx_win32->ole2_dnd_last_key_state |= MK_LBUTTON;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (kbd_state[VK_MBUTTON])
|
2011-09-22 20:47:23 +00:00
|
|
|
|
drag_ctx_win32->ole2_dnd_last_key_state |= MK_MBUTTON;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (kbd_state[VK_RBUTTON])
|
2011-09-22 20:47:23 +00:00
|
|
|
|
drag_ctx_win32->ole2_dnd_last_key_state |= MK_RBUTTON;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#if 0
|
2009-12-16 23:50:47 +00:00
|
|
|
|
global = GlobalAlloc (GMEM_FIXED, sizeof (ctx));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
memcpy (&global, ctx, sizeof (ctx));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
medium.tymed = TYMED_HGLOBAL;
|
|
|
|
|
medium.hGlobal = global;
|
|
|
|
|
medium.pUnkForRelease = NULL;
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* FIXME I wish I remember what I was thinking of here, i.e. what
|
|
|
|
|
* the formats[1] signifies, i.e. the CF_GDIOBJFIRST FORMATETC?
|
|
|
|
|
*/
|
|
|
|
|
dobj->ido.lpVtbl->SetData (&dobj->ido, &formats[1], &medium, TRUE);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#endif
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Start dragging with mainloop inside the OLE2 API. Exits only when done */
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("Calling DoDragDrop\n"));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
_gdk_win32_begin_modal_call ();
|
|
|
|
|
hr = DoDragDrop (&dobj->ido, &pending_src_context->ids,
|
|
|
|
|
DROPEFFECT_COPY | DROPEFFECT_MOVE,
|
|
|
|
|
&dwEffect);
|
|
|
|
|
_gdk_win32_end_modal_call ();
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("DoDragDrop returned %s\n",
|
|
|
|
|
(hr == DRAGDROP_S_DROP ? "DRAGDROP_S_DROP" :
|
|
|
|
|
(hr == DRAGDROP_S_CANCEL ? "DRAGDROP_S_CANCEL" :
|
|
|
|
|
(hr == E_UNEXPECTED ? "E_UNEXPECTED" :
|
|
|
|
|
g_strdup_printf ("%#.8lx", hr))))));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Delete dnd selection after successful move */
|
|
|
|
|
if (hr == DRAGDROP_S_DROP && dwEffect == DROPEFFECT_MOVE)
|
|
|
|
|
{
|
|
|
|
|
GdkEvent tmp_event;
|
|
|
|
|
|
|
|
|
|
tmp_event.type = GDK_SELECTION_REQUEST;
|
|
|
|
|
tmp_event.selection.window = drag_ctx->source_window;
|
|
|
|
|
tmp_event.selection.send_event = FALSE;
|
|
|
|
|
tmp_event.selection.selection = _gdk_ole2_dnd;
|
|
|
|
|
tmp_event.selection.target = _delete;
|
|
|
|
|
tmp_event.selection.property = _gdk_ole2_dnd; /* ??? */
|
|
|
|
|
tmp_event.selection.time = GDK_CURRENT_TIME; /* ??? */
|
|
|
|
|
g_object_ref (tmp_event.selection.window);
|
|
|
|
|
|
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (&tmp_event));
|
|
|
|
|
gdk_event_put (&tmp_event);
|
|
|
|
|
}
|
2009-03-11 13:37:26 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#if 0
|
2009-12-16 23:50:47 +00:00
|
|
|
|
// Send a GDK_DROP_FINISHED to the source window
|
|
|
|
|
GetCursorPos (&pt);
|
|
|
|
|
ptl.x = pt.x;
|
|
|
|
|
ptl.y = pt.y;
|
|
|
|
|
if ( pending_src_context != NULL && pending_src_context->context != NULL
|
|
|
|
|
&& pending_src_context->context->source_window != NULL )
|
|
|
|
|
push_dnd_event (GDK_DROP_FINISHED, pending_src_context->context, ptl, FALSE);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#endif
|
2009-03-11 13:37:26 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
dobj->ido.lpVtbl->Release (&dobj->ido);
|
|
|
|
|
if (pending_src_context != NULL)
|
|
|
|
|
{
|
|
|
|
|
pending_src_context->ids.lpVtbl->Release (&pending_src_context->ids);
|
|
|
|
|
pending_src_context = NULL;
|
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-06 14:03:32 +00:00
|
|
|
|
/* Untested, may not work ...
|
|
|
|
|
* ... but as of this writing is only used by exlusive X11 gtksocket.c
|
|
|
|
|
*/
|
|
|
|
|
GdkDragProtocol
|
|
|
|
|
_gdk_win32_window_get_drag_protocol (GdkWindow *window,
|
|
|
|
|
GdkWindow **target)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2011-02-06 14:03:32 +00:00
|
|
|
|
GdkDragProtocol protocol = GDK_DRAG_PROTO_NONE;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2011-02-06 14:03:32 +00:00
|
|
|
|
if (gdk_window_get_window_type (window) != GDK_WINDOW_FOREIGN)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2009-03-11 13:37:26 +00:00
|
|
|
|
if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL)
|
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (use_ole2_dnd)
|
2011-02-06 14:03:32 +00:00
|
|
|
|
protocol = GDK_DRAG_PROTO_OLE2;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
else
|
2011-02-06 14:03:32 +00:00
|
|
|
|
protocol = GDK_DRAG_PROTO_LOCAL;
|
2009-03-11 13:37:26 +00:00
|
|
|
|
}
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-06 14:03:32 +00:00
|
|
|
|
if (target)
|
|
|
|
|
{
|
|
|
|
|
*target = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return protocol;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-19 13:42:19 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
gint x;
|
|
|
|
|
gint 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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static GdkWindow *
|
|
|
|
|
gdk_win32_drag_context_find_window (GdkDragContext *context,
|
2011-09-19 13:42:19 +00:00
|
|
|
|
GdkWindow *drag_window,
|
|
|
|
|
gint x_root,
|
|
|
|
|
gint y_root,
|
|
|
|
|
GdkDragProtocol *protocol)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2011-09-19 13:42:19 +00:00
|
|
|
|
GdkWindow *dest_window, *dw;
|
|
|
|
|
find_window_enum_arg a;
|
2003-06-30 21:58:24 +00:00
|
|
|
|
|
2011-09-19 13:42:19 +00:00
|
|
|
|
a.x = x_root - _gdk_offset_x;
|
|
|
|
|
a.y = y_root - _gdk_offset_y;
|
|
|
|
|
a.ignore = drag_window ? GDK_WINDOW_HWND (drag_window) : NULL;
|
|
|
|
|
a.result = NULL;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2011-09-19 13:42:19 +00:00
|
|
|
|
EnumWindows (find_window_enum_proc, (LPARAM) &a);
|
2003-06-30 21:58:24 +00:00
|
|
|
|
|
2011-09-19 13:42:19 +00:00
|
|
|
|
if (a.result == NULL)
|
2011-01-02 10:51:25 +00:00
|
|
|
|
dest_window = NULL;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2011-09-19 13:42:19 +00:00
|
|
|
|
dw = gdk_win32_handle_table_lookup (a.result);
|
|
|
|
|
if (dw)
|
|
|
|
|
{
|
|
|
|
|
dest_window = gdk_window_get_toplevel (dw);
|
|
|
|
|
g_object_ref (dest_window);
|
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
else
|
2017-10-31 14:16:18 +00:00
|
|
|
|
dest_window = gdk_win32_window_foreign_new_for_display (context->display, a.result);
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (use_ole2_dnd)
|
2011-09-19 13:42:19 +00:00
|
|
|
|
*protocol = GDK_DRAG_PROTO_OLE2;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
else if (context->source_window)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
*protocol = GDK_DRAG_PROTO_LOCAL;
|
|
|
|
|
else
|
2011-09-19 13:42:19 +00:00
|
|
|
|
*protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND,
|
2009-12-16 11:04:29 +00:00
|
|
|
|
g_print ("gdk_drag_find_window: %p %+d%+d: %p: %p %s\n",
|
2003-06-30 21:58:24 +00:00
|
|
|
|
(drag_window ? GDK_WINDOW_HWND (drag_window) : NULL),
|
|
|
|
|
x_root, y_root,
|
2011-09-19 13:42:19 +00:00
|
|
|
|
a.result,
|
2011-01-02 10:51:25 +00:00
|
|
|
|
(dest_window ? GDK_WINDOW_HWND (dest_window) : NULL),
|
2009-12-16 11:04:29 +00:00
|
|
|
|
_gdk_win32_drag_protocol_to_string (*protocol)));
|
2011-01-02 10:51:25 +00:00
|
|
|
|
|
|
|
|
|
return dest_window;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_win32_drag_context_drag_motion (GdkDragContext *context,
|
1999-11-11 22:12:27 +00:00
|
|
|
|
GdkWindow *dest_window,
|
|
|
|
|
GdkDragProtocol protocol,
|
2009-12-16 11:04:29 +00:00
|
|
|
|
gint x_root,
|
1999-11-11 22:12:27 +00:00
|
|
|
|
gint y_root,
|
|
|
|
|
GdkDragAction suggested_action,
|
|
|
|
|
GdkDragAction possible_actions,
|
|
|
|
|
guint32 time)
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (context != NULL, FALSE);
|
|
|
|
|
|
2009-03-11 14:09:13 +00:00
|
|
|
|
context->actions = possible_actions;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drag_motion: %s suggested=%s, possible=%s\n"
|
|
|
|
|
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
|
2009-03-11 14:09:13 +00:00
|
|
|
|
_gdk_win32_drag_protocol_to_string (protocol),
|
|
|
|
|
_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 (context->action)));
|
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32 = GDK_WIN32_DRAG_CONTEXT (context);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
2009-03-11 14:09:13 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (context->dest_window == dest_window)
|
|
|
|
|
{
|
|
|
|
|
GdkDragContext *dest_context;
|
2009-03-11 14:09:13 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
dest_context = gdk_drag_context_find (FALSE,
|
|
|
|
|
context->source_window,
|
|
|
|
|
dest_window);
|
2009-03-11 14:09:13 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (dest_context)
|
|
|
|
|
dest_context->actions = context->actions;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
context->suggested_action = suggested_action;
|
|
|
|
|
}
|
|
|
|
|
else
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkEvent *tmp_event;
|
2009-12-16 23:50:47 +00:00
|
|
|
|
|
|
|
|
|
/* Send a leave to the last destination */
|
|
|
|
|
gdk_drag_do_leave (context, time);
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32->drag_status = GDK_DRAG_STATUS_DRAG;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Check if new destination accepts drags, and which protocol */
|
|
|
|
|
if (dest_window)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
context->dest_window = dest_window;
|
|
|
|
|
g_object_ref (context->dest_window);
|
|
|
|
|
context->protocol = protocol;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
switch (protocol)
|
|
|
|
|
{
|
|
|
|
|
case GDK_DRAG_PROTO_LOCAL:
|
|
|
|
|
local_send_enter (context, time);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
context->suggested_action = suggested_action;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
context->dest_window = NULL;
|
|
|
|
|
context->action = 0;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Push a status event, to let the client know that
|
|
|
|
|
* the drag changed
|
|
|
|
|
*/
|
2011-09-22 20:47:23 +00:00
|
|
|
|
tmp_event = gdk_event_new (GDK_DRAG_STATUS);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event->dnd.window = g_object_ref (context->source_window);
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* We use this to signal a synthetic status. Perhaps
|
|
|
|
|
* we should use an extra field...
|
|
|
|
|
*/
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event->dnd.send_event = TRUE;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event->dnd.context = g_object_ref (context);
|
|
|
|
|
tmp_event->dnd.time = time;
|
2011-09-22 20:47:23 +00:00
|
|
|
|
gdk_event_set_device (tmp_event, gdk_drag_context_get_device (context));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (tmp_event, gdk_device_get_seat (gdk_drag_context_get_device (context)));
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (tmp_event));
|
|
|
|
|
gdk_event_put (tmp_event);
|
2011-09-22 20:47:23 +00:00
|
|
|
|
gdk_event_free (tmp_event);
|
2009-12-16 23:50:47 +00:00
|
|
|
|
}
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Send a drag-motion event */
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
context_win32->ole2_dnd_last_pt.x = x_root - _gdk_offset_x;
|
|
|
|
|
context_win32->ole2_dnd_last_pt.y = y_root - _gdk_offset_y;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (context->dest_window)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if (context_win32->drag_status == GDK_DRAG_STATUS_DRAG)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
switch (context->protocol)
|
|
|
|
|
{
|
|
|
|
|
case GDK_DRAG_PROTO_LOCAL:
|
|
|
|
|
local_send_motion (context, x_root, y_root, suggested_action, time);
|
|
|
|
|
break;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
case GDK_DRAG_PROTO_NONE:
|
|
|
|
|
g_warning ("GDK_DRAG_PROTO_NONE is not valid in gdk_drag_motion()");
|
|
|
|
|
break;
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
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 (context->action)));
|
|
|
|
|
return TRUE;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
2009-03-11 14:09:13 +00:00
|
|
|
|
}
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-03-11 14:09:13 +00:00
|
|
|
|
GDK_NOTE (DND, g_print (" returning FALSE\n"
|
2009-12-16 11:04:29 +00:00
|
|
|
|
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
|
2009-03-11 14:09:13 +00:00
|
|
|
|
context,
|
|
|
|
|
_gdk_win32_drag_action_to_string (context->actions),
|
|
|
|
|
_gdk_win32_drag_action_to_string (context->suggested_action),
|
|
|
|
|
_gdk_win32_drag_action_to_string (context->action)));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_win32_drag_context_drag_drop (GdkDragContext *context,
|
1999-11-11 22:12:27 +00:00
|
|
|
|
guint32 time)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drag_drop\n"));
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
|
|
|
|
{
|
|
|
|
|
if (context->dest_window &&
|
|
|
|
|
context->protocol == GDK_DRAG_PROTO_LOCAL)
|
|
|
|
|
local_send_drop (context, time);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dnd_source_state = GDK_WIN32_DND_DROPPED;
|
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_win32_drag_context_drag_abort (GdkDragContext *context,
|
1999-11-11 22:12:27 +00:00
|
|
|
|
guint32 time)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drag_abort\n"));
|
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (use_ole2_dnd)
|
|
|
|
|
_dnd_source_state = GDK_WIN32_DND_NONE;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Destination side */
|
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_win32_drag_context_drag_status (GdkDragContext *context,
|
2000-05-07 19:45:27 +00:00
|
|
|
|
GdkDragAction action,
|
|
|
|
|
guint32 time)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2001-08-19 18:34:59 +00:00
|
|
|
|
GdkDragContext *src_context;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkEvent *tmp_event;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drag_status: %s\n"
|
|
|
|
|
" context=%p:{actions=%s,suggested=%s,action=%s}\n",
|
2009-03-11 14:09:13 +00:00
|
|
|
|
_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 (context->action)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
context->action = action;
|
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
src_context = gdk_drag_context_find (TRUE,
|
|
|
|
|
context->source_window,
|
|
|
|
|
context->dest_window);
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (src_context)
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *src_context_win32 = GDK_WIN32_DRAG_CONTEXT (src_context);
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2011-09-22 20:47:23 +00:00
|
|
|
|
if (src_context_win32->drag_status == GDK_DRAG_STATUS_MOTION_WAIT)
|
|
|
|
|
src_context_win32->drag_status = GDK_DRAG_STATUS_DRAG;
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event = gdk_event_new (GDK_DRAG_STATUS);
|
|
|
|
|
tmp_event->dnd.window = g_object_ref (context->source_window);
|
|
|
|
|
tmp_event->dnd.send_event = FALSE;
|
|
|
|
|
tmp_event->dnd.context = g_object_ref (src_context);
|
|
|
|
|
tmp_event->dnd.time = GDK_CURRENT_TIME; /* FIXME? */
|
2011-09-22 20:47:23 +00:00
|
|
|
|
gdk_event_set_device (tmp_event, gdk_drag_context_get_device (src_context));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (tmp_event, gdk_device_get_seat (gdk_drag_context_get_device (src_context)));
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (action == GDK_ACTION_DEFAULT)
|
|
|
|
|
action = 0;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
src_context->action = action;
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (tmp_event));
|
|
|
|
|
gdk_event_put (tmp_event);
|
2011-09-22 20:47:23 +00:00
|
|
|
|
gdk_event_free (tmp_event);
|
2009-12-16 23:50:47 +00:00
|
|
|
|
}
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_win32_drag_context_drop_reply (GdkDragContext *context,
|
2000-05-07 19:45:27 +00:00
|
|
|
|
gboolean ok,
|
|
|
|
|
guint32 time)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2001-08-19 18:34:59 +00:00
|
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
|
|
2000-05-07 19:45:27 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drop_reply\n"));
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
|
|
|
|
if (context->dest_window)
|
|
|
|
|
{
|
|
|
|
|
if (context->protocol == GDK_DRAG_PROTO_WIN32_DROPFILES)
|
|
|
|
|
_gdk_dropfiles_store (NULL);
|
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_win32_drag_context_drop_finish (GdkDragContext *context,
|
2000-05-07 19:45:27 +00:00
|
|
|
|
gboolean success,
|
|
|
|
|
guint32 time)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2001-08-19 18:34:59 +00:00
|
|
|
|
GdkDragContext *src_context;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkEvent *tmp_event;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
2001-08-19 18:34:59 +00:00
|
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_drop_finish\n"));
|
2001-08-19 18:34:59 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (!use_ole2_dnd)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
src_context = gdk_drag_context_find (TRUE,
|
|
|
|
|
context->source_window,
|
|
|
|
|
context->dest_window);
|
|
|
|
|
if (src_context)
|
|
|
|
|
{
|
2010-05-25 22:38:44 +00:00
|
|
|
|
tmp_event = gdk_event_new (GDK_DROP_FINISHED);
|
|
|
|
|
tmp_event->dnd.window = g_object_ref (src_context->source_window);
|
|
|
|
|
tmp_event->dnd.send_event = FALSE;
|
|
|
|
|
tmp_event->dnd.context = g_object_ref (src_context);
|
|
|
|
|
gdk_event_set_device (tmp_event, gdk_drag_context_get_device (src_context));
|
2015-12-14 14:44:29 +00:00
|
|
|
|
gdk_event_set_seat (tmp_event, gdk_device_get_seat (gdk_drag_context_get_device (src_context)));
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
GDK_NOTE (EVENTS, _gdk_win32_print_event (tmp_event));
|
|
|
|
|
gdk_event_put (tmp_event);
|
|
|
|
|
gdk_event_free (tmp_event);
|
2009-12-16 23:50:47 +00:00
|
|
|
|
}
|
2001-08-19 18:34:59 +00:00
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
else
|
2009-12-16 23:50:47 +00:00
|
|
|
|
{
|
|
|
|
|
gdk_drag_do_leave (context, time);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
if (success)
|
|
|
|
|
_dnd_target_state = GDK_WIN32_DND_DROPPED;
|
|
|
|
|
else
|
|
|
|
|
_dnd_target_state = GDK_WIN32_DND_FAILED;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-11-11 18:39:57 +00:00
|
|
|
|
|
2009-12-16 11:04:29 +00:00
|
|
|
|
#if 0
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
static GdkFilterReturn
|
|
|
|
|
gdk_destroy_filter (GdkXEvent *xev,
|
|
|
|
|
GdkEvent *event,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
MSG *msg = (MSG *) xev;
|
|
|
|
|
|
|
|
|
|
if (msg->message == WM_DESTROY)
|
|
|
|
|
{
|
|
|
|
|
IDropTarget *idtp = (IDropTarget *) data;
|
|
|
|
|
|
2003-06-30 21:58:24 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_destroy_filter: WM_DESTROY: %p\n", msg->hwnd));
|
2000-05-07 19:45:27 +00:00
|
|
|
|
#if 0
|
|
|
|
|
idtp->lpVtbl->Release (idtp);
|
|
|
|
|
#endif
|
1999-11-11 22:12:27 +00:00
|
|
|
|
RevokeDragDrop (msg->hwnd);
|
2009-03-11 13:37:26 +00:00
|
|
|
|
CoLockObjectExternal ((IUnknown*) idtp, FALSE, TRUE);
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
return GDK_FILTER_CONTINUE;
|
|
|
|
|
}
|
2009-12-16 11:04:29 +00:00
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-11-11 22:12:27 +00:00
|
|
|
|
void
|
2011-01-02 10:51:25 +00:00
|
|
|
|
_gdk_win32_window_register_dnd (GdkWindow *window)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2000-05-07 19:45:27 +00:00
|
|
|
|
target_drag_context *ctx;
|
2009-12-16 11:04:29 +00:00
|
|
|
|
HRESULT hr;
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (window != NULL);
|
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL)
|
2001-08-19 18:34:59 +00:00
|
|
|
|
return;
|
2009-03-11 13:37:26 +00:00
|
|
|
|
else
|
|
|
|
|
g_object_set_data (G_OBJECT (window), "gdk-dnd-registered", GINT_TO_POINTER (TRUE));
|
Apply the same fixes and improvements as to the gtk-1-3-win32-production
2002-01-10 Tor Lillqvist <tml@iki.fi>
Apply the same fixes and improvements as to the
gtk-1-3-win32-production branch: Bug fixes and cleanup of
selection and DND functionality. Still doesn't work as well as the
win32-production branch, though, but getting closer.
After this, need to add Archaeopteryx Software's OLE2 DND support.
* gdk/win32/gdkselection-win32.c (gdk_selection_owner_set,
gdk_selection_send_notify, generate_selection_notify): Don't use
SendMessage() to generate events for the same app, instead use
gdk_event_put().
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition,
initialisation and handling of gdk_selection_notify_msg,
gdk_selection_request_msg and gdk_selection_clear_msg.
* gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list,
gdk_free_text_list, gdk_string_to_compound_text,
gdk_free_compound_text): Implement trivially, witrh a text_list
always having a single element, and a compound text always
consisting of just a single (UTF-8!) string. Let's see how well
this works.
* gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix
non-ASCII paste from the clipboard: Try getting the same formats
from the Windows clipboard that gdk_property_change() puts there:
CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): When
storing text on the clipboard, handle non-ASCII text
correctly. The logic is as follows:
If we have only ASCII characters, use CF_TEXT.
Else, if we are on NT, use CF_UNICODETEXT.
Else (we are on Win9x), if all the characters are present in the
code page of some installed locale, use CF_TEXT and also set
CF_LOCALE to that locale.
Else (still on Win9x) store as RTF. We use a very simple RTF
string, just the text, no fonts or other crap, with the non-ASCII
characters as Unicode \uN keywords. Additionally, also store the
UTF-8 string as such, under the format "UTF8_STRING", so that GDK
can also paste from the Clipboard what it has copied there. (Thus
no need to implement any RTF parser.)
(find_common_locale): New function, implements the search for a
locale for case 3 above.
* gdk/win32/gdkglobals-win32.c: New global variables
compound_text, text_uri_list, utf8_string, cf_rtf and
cf_utf8_string.
* gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function,
converts from a wchar_t string to UTF-8.
(_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts.
(_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts.
* gdk/win32/gdkevents-win32.c (build_keypress_event): Use
_gdk_ucs2_to_utf8().
* gdk/win32/gdkselection-win32.c: Remove some unnecessary logging.
* gdk/win32/gdkdnd-win32.c: Plug memory leaks, the
gdk_drag_context_ref() was called unnecessarily in a couple of
places, meaning drag contexts were never freed. The same memory
leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW.
(gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily
stored file list.
* gdk/win32/gdkselection-win32.c: Clarify the use of the
sel_prop_table. Now it is used only for storing the GDK_SELECTION
"properties".
The file names dropped with WM_DROPFILES -style DND is stored
temporarily (between the drop and the target picking them up) in a
separate place.
Have a separate hash table to map selection atoms to owner
windows. This used to be quite mixed up.
(_gdk_dropfiles_store): New function, to store the dropped file
list for the drop target to possibly fetch, and clear it
afterwards, from gdk_drop_reply().
(gdk_selection_owner_get): Much simplified now.
2002-01-10 00:53:39 +00:00
|
|
|
|
|
2009-03-11 13:37:26 +00:00
|
|
|
|
GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %p\n", GDK_WINDOW_HWND (window)));
|
1999-11-11 22:12:27 +00:00
|
|
|
|
|
2009-12-16 23:50:47 +00:00
|
|
|
|
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_window_add_filter (window, gdk_dropfiles_filter, NULL);
|
|
|
|
|
DragAcceptFiles (GDK_WINDOW_HWND (window), TRUE);
|
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
/* Return if window is already setup for DND. */
|
|
|
|
|
if (g_hash_table_lookup (target_ctx_for_window, GDK_WINDOW_HWND (window)) != NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Register for OLE2 d&d : similarly, claim to accept all supported
|
|
|
|
|
* data types because we cannot know from here what the window
|
|
|
|
|
* actually accepts.
|
|
|
|
|
*/
|
|
|
|
|
/* FIXME: This of course won't work with user-extensible data types! */
|
|
|
|
|
ctx = target_context_new (window);
|
|
|
|
|
|
|
|
|
|
hr = CoLockObjectExternal ((IUnknown *) &ctx->idt, TRUE, FALSE);
|
|
|
|
|
if (!SUCCEEDED (hr))
|
|
|
|
|
OTHER_API_FAILED ("CoLockObjectExternal");
|
1999-11-11 22:12:27 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-16 23:50:47 +00:00
|
|
|
|
hr = RegisterDragDrop (GDK_WINDOW_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
|
|
|
|
|
{
|
2010-05-12 02:25:46 +00:00
|
|
|
|
g_object_ref (window);
|
2009-12-16 23:50:47 +00:00
|
|
|
|
g_hash_table_insert (target_ctx_for_window, GDK_WINDOW_HWND (window), ctx);
|
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_win32_drag_context_drop_status (GdkDragContext *context)
|
|
|
|
|
{
|
2011-09-22 20:47:23 +00:00
|
|
|
|
GdkWin32DragContext *context_win32 = GDK_WIN32_DRAG_CONTEXT (context);
|
|
|
|
|
|
|
|
|
|
return ! context_win32->drop_failed;
|
2011-01-02 10:51:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GdkAtom
|
|
|
|
|
gdk_win32_drag_context_get_selection (GdkDragContext *context)
|
1999-11-11 22:12:27 +00:00
|
|
|
|
{
|
2009-12-16 11:04:29 +00:00
|
|
|
|
switch (context->protocol)
|
|
|
|
|
{
|
|
|
|
|
case GDK_DRAG_PROTO_LOCAL:
|
|
|
|
|
return _local_dnd;
|
|
|
|
|
case GDK_DRAG_PROTO_WIN32_DROPFILES:
|
|
|
|
|
return _gdk_win32_dropfiles;
|
|
|
|
|
case GDK_DRAG_PROTO_OLE2:
|
|
|
|
|
return _gdk_ole2_dnd;
|
|
|
|
|
default:
|
|
|
|
|
return GDK_NONE;
|
|
|
|
|
}
|
1999-11-11 22:12:27 +00:00
|
|
|
|
}
|
2004-08-27 23:38:06 +00:00
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_win32_drag_context_class_init (GdkWin32DragContextClass *klass)
|
2004-08-27 23:38:06 +00:00
|
|
|
|
{
|
2011-01-02 10:51:25 +00:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
|
2004-08-27 23:38:06 +00:00
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
object_class->finalize = gdk_win32_drag_context_finalize;
|
2004-08-27 23:38:06 +00:00
|
|
|
|
|
2011-01-02 10:51:25 +00:00
|
|
|
|
context_class->find_window = gdk_win32_drag_context_find_window;
|
|
|
|
|
context_class->drag_status = gdk_win32_drag_context_drag_status;
|
|
|
|
|
context_class->drag_motion = gdk_win32_drag_context_drag_motion;
|
|
|
|
|
context_class->drag_abort = gdk_win32_drag_context_drag_abort;
|
|
|
|
|
context_class->drag_drop = gdk_win32_drag_context_drag_drop;
|
|
|
|
|
context_class->drop_reply = gdk_win32_drag_context_drop_reply;
|
|
|
|
|
context_class->drop_finish = gdk_win32_drag_context_drop_finish;
|
|
|
|
|
context_class->drop_status = gdk_win32_drag_context_drop_status;
|
|
|
|
|
context_class->get_selection = gdk_win32_drag_context_get_selection;
|
2004-08-27 23:38:06 +00:00
|
|
|
|
}
|