mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
W32: Massive W32 DnD fix
Massive changes to OLE2 DnD protocol, which was completely broken before: * Keep GdkDragContext and OLE2 objects separate (don't ref/unref them together, don't necessarily create them together). * Keep IDataObject formats in the object itself, not in a global variable. * Fix getdata() to look up the request target in its format list, not in the global hash table * Create target GdkDragContext on each drag_enter, destroy it on drag_leave, whereas IDropTarget is created when a window becomes a drag destination and is re-used indefinitely. * Query the source IDataObject for its supported types, cache them in the target (!) context. This is how GTK+ works, honestly. * Remember current_src_object when we initiate a drag, to be able to detect later on that the data object is ours and use a shortcut when querying targets * Make sure GDK_DRAG_MOTION is only sent when something changes * Support GTK drag cursors * Ensure that exotic GTK clipboard formats are registered (but try to avoid registering formats that can't be used between applications). * Don't enumerate internal formats * Ensure that DnD indicator window can't accept drags or receive any kind of input (use WS_EX_TRANSPARENT). * Remove unneeded indentation in _gdk_win32_dnd_do_dragdrop() * Fix indentation in gdk_win32_drag_context_drop_finish() * Remove obsolete comments in _gdk_win32_window_register_dnd() * Check for DnD in progress when processing WM_KILLFOCUS, don't emit a grab break event in such cases (this allows alt-tabbing while DnD is in progress, though there may be lingering issues with focus after dropping...) * Support Shell ID List -> text/uri-list conversion, now it's possible to drop files (dragged from Explorer) on GTK+ applications * Explicitly use RegisterClipboardFormatA() when we know that the string is not in unicode. Otherwise explicitly use RegisterClipboardFormatW() with a UTF8->UTF16 converted string * Fix _gdk_win32_display_get_selection_owner() to correctly bail when selection owner HWND is NULL (looking up GdkWindow for NULL HWND always succeeds and returns the root window - not the intended effect) * More logging * Send DROP_FINISHED event after DnD loop ends * Send STATUS event on feedback * Move GetKeyboardState() and related code into _gdk_win32_window_drag_begin(), so that it's closer to the point where last_pt and start_pt are set * Use & 0x80 to check for the key being pressed. Windows will set low-order bit to 1 for all mouse buttons to indicate that they are toggled, so simply checking for the value not being 0 is not enough anymore. This is probably a new thing in modern W32 that didn't exist before (OLE2 DnD code is old). * Fixed (hopefully) and simplified HiDPI parts of the code. Also adds managed DnD implementation for W32 GDK backend (for both OLE2 and LOCAL protocols). Mostly a copy of the X11 backend code, but there are some minor differences: * doesn't use drag_window field in GdkDragContext, uses the one in GdkWin32DragContext exclusively * subtracts hotspot offset from the window coordinates when showing the dragback animation * tries to consistently support scaling and caches the scale in the context * Some keynav code is removed (places where grabbing/ungrabbing should happen is marked with TODOs), and the rest is probably inert. Also significantly changes the way selection (and clipboard) is handled (as MSDN rightly notes, the handling for DnD and Clipboard formats is virtually the same, so it makes sense to handle both with the same code): * Don't spam GDK_OWNER_CHANGE, send them only when owner actually changes * Open clipboard when our process becomes the clipboard owner (we are doing it anyway, to empty the clipboard and *become* the owner), and then don't close it until a scheduled selection request event (with TARGETS target) is received. Process that event by announcing all of our supported formats (by that time add_targets() should have been called up the stack, thus the formats are known; just in case, add_targets() will also schedule a selection request, if one isn't scheduled already, so that late-coming formats can still be announced). * Allow clipboard opening for selection_convert() to be delayed if it fails initially. * The last two points above should fix all the bugs about GTK+ rising too much ruckus over OpenClipboard() failures, as owner change *is allowed* to fail (though not all callers currently handle that case), and selection_convert() is asynchronous to begin with. Still, this is somewhat risky, as there's a possibility that the code will work in unexpected ways and the clipboard will remain open. There's now logging to track the clipboard being opened and closed, and a number of failsafes that try to ensure that it isn't kept open for no reason. * Added copious notes on the way clipboard works on X11, Windows and GDK-W32, also removed old comments in DnD implementation, replaced some of them with the new ones * A lot of crufty module-global variables are stuffed into a singleton object, GdkWin32Selection. It's technically possible to make it a sub-object of the Display object (the way Wayland backend does), but since Display object on W32 is a singleton anyway... why bother? * Fixed the send_change_events() a bit (was slightly broken in one of the previous iterations) * Ensure that there's no confusion between selection conversion (an artifact term from X11) and selection transmutation (changing the data to be W32-compatible) * Put all the transmutation code and format-target-matching code into gdkselection-win32.c, now this code isn't spread across multiple files. * Consequently, moved some code away from gdkproperty-win32.c and gdkdnd-win32.c * Extensive format transmutation checks for OLE2 DnD and clipboard. We now keep track of which format mappings are for transmutations, and which aren't (for example, when formats are passed as-is, or when a registered name is just an alias) * Put transmutation code into separate functions * Ensure that drop target keeps a format->target map for supported formats, this is useful when selection_convert() is called, as it only receives a single target and no hints on the format from which the data should be transmuted into this target. * Add clear_targets() on W32, to de called by GTK * Use g_set_object() instead of g_ref_object() where it is allowed. * Fix indentation (and convert tabs to spaces), remove unused variables (This commit is cherry-picked from the gtk-3-22 branch) https://bugzilla.gnome.org/show_bug.cgi?id=786509
This commit is contained in:
parent
3237c2172a
commit
6c29e81051
@ -549,7 +549,7 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
HWND hwnd_owner;
|
||||
HWND hwnd_opener;
|
||||
GdkEvent *event;
|
||||
GdkWindow *owner;
|
||||
GdkWin32Selection *win32_sel = _gdk_win32_selection_get ();
|
||||
|
||||
hwnd_owner = GetClipboardOwner ();
|
||||
|
||||
@ -564,14 +564,16 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (_gdk_debug_flags & GDK_DEBUG_DND)
|
||||
{
|
||||
if (OpenClipboard (hwnd))
|
||||
if (win32_sel->clipboard_opened_for != INVALID_HANDLE_VALUE ||
|
||||
OpenClipboard (hwnd))
|
||||
{
|
||||
UINT nFormat = 0;
|
||||
|
||||
while ((nFormat = EnumClipboardFormats (nFormat)) != 0)
|
||||
g_print ("%s ", _gdk_win32_cf_to_string (nFormat));
|
||||
|
||||
CloseClipboard ();
|
||||
if (win32_sel->clipboard_opened_for == INVALID_HANDLE_VALUE)
|
||||
CloseClipboard ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -582,6 +584,20 @@ inner_clipboard_window_procedure (HWND hwnd,
|
||||
|
||||
GDK_NOTE (DND, g_print (" \n"));
|
||||
|
||||
if (win32_sel->stored_hwnd_owner != hwnd_owner)
|
||||
{
|
||||
if (win32_sel->clipboard_opened_for != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseClipboard ();
|
||||
GDK_NOTE (DND, g_print ("Closed clipboard @ %s:%d\n", __FILE__, __LINE__));
|
||||
}
|
||||
|
||||
win32_sel->clipboard_opened_for = INVALID_HANDLE_VALUE;
|
||||
win32_sel->stored_hwnd_owner = hwnd_owner;
|
||||
|
||||
_gdk_win32_clear_clipboard_queue ();
|
||||
}
|
||||
|
||||
event = gdk_event_new (GDK_OWNER_CHANGE);
|
||||
event->owner_change.window = NULL;
|
||||
event->owner_change.reason = GDK_OWNER_CHANGE_NEW_OWNER;
|
||||
@ -710,16 +726,30 @@ gdk_win32_display_request_selection_notification (GdkDisplay *display,
|
||||
static gboolean
|
||||
gdk_win32_display_supports_clipboard_persistence (GdkDisplay *display)
|
||||
{
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_win32_display_store_clipboard (GdkDisplay *display,
|
||||
GdkWindow *clipboard_window,
|
||||
guint32 time_,
|
||||
const GdkAtom *targets,
|
||||
gint n_targets)
|
||||
GdkWindow *clipboard_window,
|
||||
guint32 time_,
|
||||
const GdkAtom *targets,
|
||||
gint n_targets)
|
||||
{
|
||||
GdkEvent tmp_event;
|
||||
SendMessage (GDK_WINDOW_HWND (clipboard_window), WM_RENDERALLFORMATS, 0, 0);
|
||||
|
||||
memset (&tmp_event, 0, sizeof (tmp_event));
|
||||
tmp_event.selection.type = GDK_SELECTION_NOTIFY;
|
||||
tmp_event.selection.window = clipboard_window;
|
||||
tmp_event.selection.send_event = FALSE;
|
||||
tmp_event.selection.selection = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_CLIPBOARD_MANAGER);
|
||||
tmp_event.selection.target = 0;
|
||||
tmp_event.selection.property = NULL;
|
||||
tmp_event.selection.requestor = 0;
|
||||
tmp_event.selection.time = GDK_CURRENT_TIME;
|
||||
|
||||
gdk_event_put (&tmp_event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -56,6 +56,8 @@
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdevice-wintab.h"
|
||||
#include "gdkwin32dnd.h"
|
||||
#include "gdkdisplay-win32.h"
|
||||
#include "gdkselection-win32.h"
|
||||
#include "gdkdndprivate.h"
|
||||
|
||||
#include <windowsx.h>
|
||||
@ -2324,6 +2326,10 @@ gdk_event_translate (MSG *msg,
|
||||
|
||||
int i;
|
||||
|
||||
GdkWin32Selection *win32_sel = NULL;
|
||||
|
||||
STGMEDIUM *property_change_data;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
window = gdk_win32_handle_table_lookup (msg->hwnd);
|
||||
|
||||
@ -3141,7 +3147,8 @@ gdk_event_translate (MSG *msg,
|
||||
|
||||
case WM_KILLFOCUS:
|
||||
if (keyboard_grab != NULL &&
|
||||
!GDK_WINDOW_DESTROYED (keyboard_grab->window))
|
||||
!GDK_WINDOW_DESTROYED (keyboard_grab->window) &&
|
||||
(_modal_operation_in_progress & GDK_WIN32_MODAL_OP_DND) == 0)
|
||||
{
|
||||
generate_grab_broken_event (_gdk_device_manager, keyboard_grab->window, TRUE, NULL);
|
||||
}
|
||||
@ -3739,7 +3746,9 @@ gdk_event_translate (MSG *msg,
|
||||
break;
|
||||
|
||||
case WM_DESTROYCLIPBOARD:
|
||||
if (!_ignore_destroy_clipboard)
|
||||
win32_sel = _gdk_win32_selection_get ();
|
||||
|
||||
if (!win32_sel->ignore_destroy_clipboard)
|
||||
{
|
||||
event = gdk_event_new (GDK_SELECTION_CLEAR);
|
||||
event->selection.window = window;
|
||||
@ -3757,12 +3766,29 @@ gdk_event_translate (MSG *msg,
|
||||
case WM_RENDERFORMAT:
|
||||
GDK_NOTE (EVENTS, g_print (" %s", _gdk_win32_cf_to_string (msg->wParam)));
|
||||
|
||||
if (!(target = g_hash_table_lookup (_format_atom_table, GINT_TO_POINTER (msg->wParam))))
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_print (" (target not found)"));
|
||||
return_val = TRUE;
|
||||
break;
|
||||
}
|
||||
*ret_valp = 0;
|
||||
return_val = TRUE;
|
||||
|
||||
win32_sel = _gdk_win32_selection_get ();
|
||||
|
||||
for (target = NULL, i = 0;
|
||||
i < win32_sel->clipboard_selection_targets->len;
|
||||
i++)
|
||||
{
|
||||
GdkSelTargetFormat target_format = g_array_index (win32_sel->clipboard_selection_targets, GdkSelTargetFormat, i);
|
||||
|
||||
if (target_format.format == msg->wParam)
|
||||
{
|
||||
target = target_format.target;
|
||||
win32_sel->property_change_transmute = target_format.transmute;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == NULL)
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_print (" (target not found)"));
|
||||
break;
|
||||
}
|
||||
|
||||
/* We need to render to clipboard immediately, don't call
|
||||
* _gdk_win32_append_event()
|
||||
@ -3772,45 +3798,61 @@ gdk_event_translate (MSG *msg,
|
||||
event->selection.send_event = FALSE;
|
||||
event->selection.selection = GDK_SELECTION_CLIPBOARD;
|
||||
event->selection.target = target;
|
||||
event->selection.property = _gdk_selection;
|
||||
event->selection.property = _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_GDK_SELECTION);
|
||||
event->selection.requestor = gdk_win32_handle_table_lookup (msg->hwnd);
|
||||
event->selection.time = msg->time;
|
||||
property_change_data = g_new0 (STGMEDIUM, 1);
|
||||
win32_sel->property_change_data = property_change_data;
|
||||
win32_sel->property_change_format = msg->wParam;
|
||||
|
||||
fixup_event (event);
|
||||
GDK_NOTE (EVENTS, g_print (" (calling _gdk_event_emit)"));
|
||||
GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
|
||||
_gdk_event_emit (event);
|
||||
gdk_event_free (event);
|
||||
win32_sel->property_change_format = 0;
|
||||
|
||||
/* Now the clipboard owner should have rendered */
|
||||
if (!_delayed_rendering_data)
|
||||
if (!property_change_data->hGlobal)
|
||||
{
|
||||
GDK_NOTE (EVENTS, g_print (" (no _delayed_rendering_data?)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (msg->wParam == CF_DIB)
|
||||
{
|
||||
_delayed_rendering_data =
|
||||
_gdk_win32_selection_convert_to_dib (_delayed_rendering_data,
|
||||
target);
|
||||
if (!_delayed_rendering_data)
|
||||
{
|
||||
g_warning ("Cannot convert to DIB from delayed rendered image");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* The requestor is holding the clipboard, no
|
||||
* OpenClipboard() is required/possible
|
||||
*/
|
||||
GDK_NOTE (DND,
|
||||
g_print (" SetClipboardData(%s,%p)",
|
||||
_gdk_win32_cf_to_string (msg->wParam),
|
||||
_delayed_rendering_data));
|
||||
property_change_data->hGlobal));
|
||||
|
||||
API_CALL (SetClipboardData, (msg->wParam, _delayed_rendering_data));
|
||||
_delayed_rendering_data = NULL;
|
||||
API_CALL (SetClipboardData, (msg->wParam, property_change_data->hGlobal));
|
||||
}
|
||||
|
||||
g_clear_pointer (&property_change_data, g_free);
|
||||
*ret_valp = 0;
|
||||
return_val = TRUE;
|
||||
break;
|
||||
|
||||
case WM_RENDERALLFORMATS:
|
||||
*ret_valp = 0;
|
||||
return_val = TRUE;
|
||||
|
||||
win32_sel = _gdk_win32_selection_get ();
|
||||
|
||||
if (API_CALL (OpenClipboard, (msg->hwnd)))
|
||||
{
|
||||
for (target = NULL, i = 0;
|
||||
i < win32_sel->clipboard_selection_targets->len;
|
||||
i++)
|
||||
{
|
||||
GdkSelTargetFormat target_format = g_array_index (win32_sel->clipboard_selection_targets, GdkSelTargetFormat, i);
|
||||
if (target_format.format != 0)
|
||||
SendMessage (msg->hwnd, WM_RENDERFORMAT, target_format.format, 0);
|
||||
}
|
||||
|
||||
API_CALL (CloseClipboard, ());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3980,16 +4022,18 @@ gdk_event_dispatch (GSource *source,
|
||||
|
||||
if (event)
|
||||
{
|
||||
GdkWin32Selection *sel_win32 = _gdk_win32_selection_get ();
|
||||
|
||||
_gdk_event_emit (event);
|
||||
|
||||
gdk_event_free (event);
|
||||
|
||||
/* Do drag & drop if it is still pending */
|
||||
if (_dnd_source_state == GDK_WIN32_DND_PENDING)
|
||||
if (sel_win32->dnd_source_state == GDK_WIN32_DND_PENDING)
|
||||
{
|
||||
_dnd_source_state = GDK_WIN32_DND_DRAGGING;
|
||||
sel_win32->dnd_source_state = GDK_WIN32_DND_DRAGGING;
|
||||
_gdk_win32_dnd_do_dragdrop ();
|
||||
_dnd_source_state = GDK_WIN32_DND_NONE;
|
||||
sel_win32->dnd_source_state = GDK_WIN32_DND_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,41 +42,11 @@ HKL _gdk_input_locale;
|
||||
gboolean _gdk_input_locale_is_ime;
|
||||
UINT _gdk_input_codepage;
|
||||
|
||||
GdkAtom _gdk_selection;
|
||||
GdkAtom _wm_transient_for;
|
||||
GdkAtom _targets;
|
||||
GdkAtom _delete;
|
||||
GdkAtom _save_targets;
|
||||
GdkAtom _utf8_string;
|
||||
GdkAtom _text;
|
||||
GdkAtom _compound_text;
|
||||
GdkAtom _text_uri_list;
|
||||
GdkAtom _text_html;
|
||||
GdkAtom _image_png;
|
||||
GdkAtom _image_jpeg;
|
||||
GdkAtom _image_bmp;
|
||||
GdkAtom _image_gif;
|
||||
|
||||
GdkAtom _local_dnd;
|
||||
GdkAtom _gdk_win32_dropfiles;
|
||||
GdkAtom _gdk_ole2_dnd;
|
||||
|
||||
UINT _cf_png;
|
||||
UINT _cf_jfif;
|
||||
UINT _cf_gif;
|
||||
UINT _cf_url;
|
||||
UINT _cf_html_format;
|
||||
UINT _cf_text_html;
|
||||
|
||||
GdkWin32DndState _dnd_target_state = GDK_WIN32_DND_NONE;
|
||||
GdkWin32DndState _dnd_source_state = GDK_WIN32_DND_NONE;
|
||||
|
||||
gint _gdk_input_ignore_wintab = FALSE;
|
||||
gint _gdk_max_colors = 0;
|
||||
|
||||
GdkWin32ModalOpKind _modal_operation_in_progress = GDK_WIN32_MODAL_OP_NONE;
|
||||
HWND _modal_move_resize_window = NULL;
|
||||
gboolean _ignore_destroy_clipboard = FALSE;
|
||||
|
||||
HGLOBAL _delayed_rendering_data = NULL;
|
||||
GHashTable *_format_atom_table = NULL;
|
||||
/* The singleton selection object pointer */
|
||||
GdkWin32Selection *_win32_selection = NULL;
|
||||
|
@ -44,6 +44,9 @@
|
||||
#include <wintab.h>
|
||||
#include <imm.h>
|
||||
|
||||
/* for CFSTR_SHELLIDLIST */
|
||||
#include <shlobj.h>
|
||||
|
||||
static gboolean gdk_synchronize = FALSE;
|
||||
|
||||
static gboolean dummy;
|
||||
@ -88,38 +91,6 @@ _gdk_win32_windowing_init (void)
|
||||
GDK_NOTE (EVENTS, g_print ("input_locale:%p, codepage:%d\n",
|
||||
_gdk_input_locale, _gdk_input_codepage));
|
||||
|
||||
_gdk_selection = gdk_atom_intern_static_string ("GDK_SELECTION");
|
||||
_wm_transient_for = gdk_atom_intern_static_string ("WM_TRANSIENT_FOR");
|
||||
_targets = gdk_atom_intern_static_string ("TARGETS");
|
||||
_delete = gdk_atom_intern_static_string ("DELETE");
|
||||
_save_targets = gdk_atom_intern_static_string ("SAVE_TARGETS");
|
||||
_utf8_string = gdk_atom_intern_static_string ("UTF8_STRING");
|
||||
_text = gdk_atom_intern_static_string ("TEXT");
|
||||
_compound_text = gdk_atom_intern_static_string ("COMPOUND_TEXT");
|
||||
_text_uri_list = gdk_atom_intern_static_string ("text/uri-list");
|
||||
_text_html = gdk_atom_intern_static_string ("text/html");
|
||||
_image_png = gdk_atom_intern_static_string ("image/png");
|
||||
_image_jpeg = gdk_atom_intern_static_string ("image/jpeg");
|
||||
_image_bmp = gdk_atom_intern_static_string ("image/bmp");
|
||||
_image_gif = gdk_atom_intern_static_string ("image/gif");
|
||||
|
||||
_local_dnd = gdk_atom_intern_static_string ("LocalDndSelection");
|
||||
_gdk_win32_dropfiles = gdk_atom_intern_static_string ("DROPFILES_DND");
|
||||
_gdk_ole2_dnd = gdk_atom_intern_static_string ("OLE2_DND");
|
||||
|
||||
/* MS Office 2007, at least, offers images in common file formats
|
||||
* using clipboard format names like "PNG" and "JFIF". So we follow
|
||||
* the lead and map the GDK target name "image/png" to the clipboard
|
||||
* format name "PNG" etc.
|
||||
*/
|
||||
_cf_png = RegisterClipboardFormat ("PNG");
|
||||
_cf_jfif = RegisterClipboardFormat ("JFIF");
|
||||
_cf_gif = RegisterClipboardFormat ("GIF");
|
||||
|
||||
_cf_url = RegisterClipboardFormat ("UniformResourceLocatorW");
|
||||
_cf_html_format = RegisterClipboardFormat ("HTML Format");
|
||||
_cf_text_html = RegisterClipboardFormat ("text/html");
|
||||
|
||||
_gdk_win32_selection_init ();
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <gdk/win32/gdkwin32screen.h>
|
||||
#include <gdk/win32/gdkwin32keys.h>
|
||||
#include <gdk/win32/gdkdevicemanager-win32.h>
|
||||
#include <gdk/win32/gdkselection-win32.h>
|
||||
|
||||
#include "gdkinternals.h"
|
||||
|
||||
@ -284,46 +285,8 @@ extern UINT _gdk_input_codepage;
|
||||
|
||||
extern guint _gdk_keymap_serial;
|
||||
|
||||
/* GdkAtoms: properties, targets and types */
|
||||
extern GdkAtom _gdk_selection;
|
||||
extern GdkAtom _wm_transient_for;
|
||||
extern GdkAtom _targets;
|
||||
extern GdkAtom _delete;
|
||||
extern GdkAtom _save_targets;
|
||||
extern GdkAtom _utf8_string;
|
||||
extern GdkAtom _text;
|
||||
extern GdkAtom _compound_text;
|
||||
extern GdkAtom _text_uri_list;
|
||||
extern GdkAtom _text_html;
|
||||
extern GdkAtom _image_png;
|
||||
extern GdkAtom _image_jpeg;
|
||||
extern GdkAtom _image_bmp;
|
||||
extern GdkAtom _image_gif;
|
||||
|
||||
/* DND selections */
|
||||
extern GdkAtom _local_dnd;
|
||||
extern GdkAtom _gdk_win32_dropfiles;
|
||||
extern GdkAtom _gdk_ole2_dnd;
|
||||
|
||||
/* Clipboard formats */
|
||||
extern UINT _cf_png;
|
||||
extern UINT _cf_jfif;
|
||||
extern UINT _cf_gif;
|
||||
extern UINT _cf_url;
|
||||
extern UINT _cf_html_format;
|
||||
extern UINT _cf_text_html;
|
||||
|
||||
/* OLE-based DND state */
|
||||
typedef enum {
|
||||
GDK_WIN32_DND_NONE,
|
||||
GDK_WIN32_DND_PENDING,
|
||||
GDK_WIN32_DND_DROPPED,
|
||||
GDK_WIN32_DND_FAILED,
|
||||
GDK_WIN32_DND_DRAGGING,
|
||||
} GdkWin32DndState;
|
||||
|
||||
extern GdkWin32DndState _dnd_target_state;
|
||||
extern GdkWin32DndState _dnd_source_state;
|
||||
/* The singleton selection object pointer */
|
||||
GdkWin32Selection *_win32_selection;
|
||||
|
||||
void _gdk_win32_dnd_do_dragdrop (void);
|
||||
void _gdk_win32_ole2_dnd_property_change (GdkAtom type,
|
||||
@ -354,20 +317,6 @@ void _gdk_win32_end_modal_call (GdkWin32ModalOpKind kind);
|
||||
extern gboolean _gdk_input_ignore_wintab;
|
||||
extern gint _gdk_max_colors;
|
||||
|
||||
/* TRUE when we are emptying the clipboard ourselves */
|
||||
extern gboolean _ignore_destroy_clipboard;
|
||||
|
||||
/* Mapping from registered clipboard format id (native) to
|
||||
* corresponding GdkAtom
|
||||
*/
|
||||
extern GHashTable *_format_atom_table;
|
||||
|
||||
/* Hold the result of a delayed rendering */
|
||||
extern HGLOBAL _delayed_rendering_data;
|
||||
|
||||
HGLOBAL _gdk_win32_selection_convert_to_dib (HGLOBAL hdata,
|
||||
GdkAtom target);
|
||||
|
||||
/* Convert a pixbuf to an HICON (or HCURSOR). Supports alpha under
|
||||
* Windows XP, thresholds alpha otherwise.
|
||||
*/
|
||||
@ -513,6 +462,9 @@ void _gdk_win32_window_change_property (GdkWindow *window,
|
||||
gint nelements);
|
||||
void _gdk_win32_window_delete_property (GdkWindow *window, GdkAtom property);
|
||||
|
||||
void gdk_win32_selection_clear_targets (GdkDisplay *display,
|
||||
GdkAtom selection);
|
||||
|
||||
/* Stray GdkWin32Screen members */
|
||||
gboolean _gdk_win32_get_setting (const gchar *name, GValue *value);
|
||||
void _gdk_win32_screen_on_displaychange_event (GdkWin32Screen *screen);
|
||||
|
@ -137,20 +137,15 @@ _gdk_win32_window_get_property (GdkWindow *window,
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_win32_window_change_property (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
GdkPropMode mode,
|
||||
const guchar *data,
|
||||
gint nelements)
|
||||
_gdk_win32_window_change_property (GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
GdkPropMode mode,
|
||||
const guchar *data,
|
||||
gint nelements)
|
||||
{
|
||||
HGLOBAL hdata;
|
||||
gint i, size;
|
||||
guchar *ucptr;
|
||||
wchar_t *wcptr, *p;
|
||||
glong wclen;
|
||||
GError *err = NULL;
|
||||
GdkWin32Selection *win32_sel = _gdk_win32_selection_get ();
|
||||
|
||||
g_return_if_fail (window != NULL);
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
@ -161,6 +156,7 @@ _gdk_win32_window_change_property (GdkWindow *window,
|
||||
GDK_NOTE (DND, {
|
||||
gchar *prop_name = gdk_atom_name (property);
|
||||
gchar *type_name = gdk_atom_name (type);
|
||||
gchar *datastring = _gdk_win32_data_to_string (data, MIN (10, format*nelements/8));
|
||||
|
||||
g_print ("gdk_property_change: %p %s %s %s %d*%d bits: %s\n",
|
||||
GDK_WINDOW_HWND (window),
|
||||
@ -171,103 +167,35 @@ _gdk_win32_window_change_property (GdkWindow *window,
|
||||
(mode == GDK_PROP_MODE_APPEND ? "APPEND" :
|
||||
"???"))),
|
||||
format, nelements,
|
||||
_gdk_win32_data_to_string (data, MIN (10, format*nelements/8)));
|
||||
datastring);
|
||||
g_free (datastring);
|
||||
g_free (prop_name);
|
||||
g_free (type_name);
|
||||
});
|
||||
|
||||
#ifndef G_DISABLE_CHECKS
|
||||
/* We should never come here for these types */
|
||||
g_return_if_fail (type != GDK_TARGET_STRING);
|
||||
g_return_if_fail (type != _text);
|
||||
g_return_if_fail (type != _compound_text);
|
||||
g_return_if_fail (type != _save_targets);
|
||||
|
||||
if (property == _gdk_selection &&
|
||||
format == 8 &&
|
||||
mode == GDK_PROP_MODE_REPLACE)
|
||||
if (G_UNLIKELY (type == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_COMPOUND_TEXT) ||
|
||||
type == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_SAVE_TARGETS)))
|
||||
{
|
||||
if (type == _image_bmp && nelements < sizeof (BITMAPFILEHEADER))
|
||||
{
|
||||
g_warning ("Clipboard contains invalid bitmap data");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == _utf8_string)
|
||||
{
|
||||
wcptr = g_utf8_to_utf16 ((char *) data, nelements, NULL, &wclen, &err);
|
||||
if (err != NULL)
|
||||
{
|
||||
g_warning ("Failed to convert utf8: %s", err->message);
|
||||
g_clear_error (&err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!OpenClipboard (GDK_WINDOW_HWND (window)))
|
||||
{
|
||||
WIN32_API_FAILED ("OpenClipboard");
|
||||
g_free (wcptr);
|
||||
return;
|
||||
}
|
||||
|
||||
wclen++; /* Terminating 0 */
|
||||
size = wclen * 2;
|
||||
for (i = 0; i < wclen; i++)
|
||||
if (wcptr[i] == '\n' && (i == 0 || wcptr[i - 1] != '\r'))
|
||||
size += 2;
|
||||
|
||||
if (!(hdata = GlobalAlloc (GMEM_MOVEABLE, size)))
|
||||
{
|
||||
WIN32_API_FAILED ("GlobalAlloc");
|
||||
if (!CloseClipboard ())
|
||||
WIN32_API_FAILED ("CloseClipboard");
|
||||
g_free (wcptr);
|
||||
return;
|
||||
}
|
||||
|
||||
ucptr = GlobalLock (hdata);
|
||||
|
||||
p = (wchar_t *) ucptr;
|
||||
for (i = 0; i < wclen; i++)
|
||||
{
|
||||
if (wcptr[i] == '\n' && (i == 0 || wcptr[i - 1] != '\r'))
|
||||
*p++ = '\r';
|
||||
*p++ = wcptr[i];
|
||||
}
|
||||
g_free (wcptr);
|
||||
|
||||
GlobalUnlock (hdata);
|
||||
GDK_NOTE (DND, g_print ("... SetClipboardData(CF_UNICODETEXT,%p)\n",
|
||||
hdata));
|
||||
if (!SetClipboardData (CF_UNICODETEXT, hdata))
|
||||
WIN32_API_FAILED ("SetClipboardData");
|
||||
|
||||
if (!CloseClipboard ())
|
||||
WIN32_API_FAILED ("CloseClipboard");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We use delayed rendering for everything else than
|
||||
* text. We can't assign hdata to the clipboard here as type
|
||||
* may be "image/png", "image/jpg", etc. In this case
|
||||
* there's a further conversion afterwards.
|
||||
*/
|
||||
GDK_NOTE (DND, g_print ("... delayed rendering\n"));
|
||||
_delayed_rendering_data = NULL;
|
||||
if (!(hdata = GlobalAlloc (GMEM_MOVEABLE, nelements > 0 ? nelements : 1)))
|
||||
{
|
||||
WIN32_API_FAILED ("GlobalAlloc");
|
||||
return;
|
||||
}
|
||||
ucptr = GlobalLock (hdata);
|
||||
memcpy (ucptr, data, nelements);
|
||||
GlobalUnlock (hdata);
|
||||
_delayed_rendering_data = hdata;
|
||||
}
|
||||
g_return_if_fail_warning (G_LOG_DOMAIN,
|
||||
G_STRFUNC,
|
||||
"change_property called with a bad type");
|
||||
return;
|
||||
}
|
||||
else if (property == _gdk_ole2_dnd)
|
||||
#endif
|
||||
|
||||
if (property == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_GDK_SELECTION) ||
|
||||
property == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_OLE2_DND))
|
||||
{
|
||||
/* Will happen only if gdkdnd-win32.c has OLE2 dnd support compiled in */
|
||||
_gdk_win32_ole2_dnd_property_change (type, format, data, nelements);
|
||||
_gdk_win32_selection_property_change (win32_sel,
|
||||
window,
|
||||
property,
|
||||
type,
|
||||
format,
|
||||
mode,
|
||||
data,
|
||||
nelements);
|
||||
}
|
||||
else
|
||||
g_warning ("gdk_property_change: General case not implemented");
|
||||
@ -291,10 +219,18 @@ _gdk_win32_window_delete_property (GdkWindow *window,
|
||||
g_free (prop_name);
|
||||
});
|
||||
|
||||
if (property == _gdk_selection)
|
||||
if (property == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_GDK_SELECTION) ||
|
||||
property == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_OLE2_DND))
|
||||
_gdk_selection_property_delete (window);
|
||||
else if (property == _wm_transient_for)
|
||||
gdk_window_set_transient_for (window, NULL);
|
||||
/*
|
||||
else if (property == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_WM_TRANSIENT_FOR))
|
||||
{
|
||||
GdkScreen *screen;
|
||||
|
||||
screen = gdk_window_get_screen (window);
|
||||
gdk_window_set_transient_for (window, NULL);
|
||||
}
|
||||
*/
|
||||
else
|
||||
{
|
||||
prop_name = gdk_atom_name (property);
|
||||
|
File diff suppressed because it is too large
Load Diff
228
gdk/win32/gdkselection-win32.h
Normal file
228
gdk/win32/gdkselection-win32.h
Normal file
@ -0,0 +1,228 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
*
|
||||
* gdkselection-win32.h: Private Win32 specific selection object
|
||||
*
|
||||
* Copyright © 2017 LRN
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_SELECTION_WIN32_H__
|
||||
#define __GDK_SELECTION_WIN32_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define _gdk_win32_selection_get() (_win32_selection)
|
||||
#define _gdk_atom_array_index(a, i) (g_array_index (a, GdkAtom, i))
|
||||
#define _gdk_win32_selection_atom(i) (_gdk_atom_array_index (_gdk_win32_selection_get ()->known_atoms, i))
|
||||
#define _gdk_cf_array_index(a, i) (g_array_index (a, UINT, i))
|
||||
#define _gdk_win32_selection_cf(i) (_gdk_cf_array_index (_gdk_win32_selection_get ()->known_clipboard_formats, i))
|
||||
|
||||
/* Maps targets to formats or vice versa, depending on the
|
||||
* semantics of the array that holds these.
|
||||
* Also remembers whether the data needs to be transmuted.
|
||||
*/
|
||||
typedef struct {
|
||||
gint format;
|
||||
GdkAtom target;
|
||||
gboolean transmute;
|
||||
} GdkSelTargetFormat;
|
||||
|
||||
/* We emulate the GDK_SELECTION window properties of windows (as used
|
||||
* in the X11 backend) by using a hash table from window handles to
|
||||
* GdkSelProp structs.
|
||||
*/
|
||||
typedef struct {
|
||||
guchar *data;
|
||||
gsize length;
|
||||
gint bitness;
|
||||
GdkAtom target;
|
||||
} GdkSelProp;
|
||||
|
||||
/* OLE-based DND state */
|
||||
typedef enum {
|
||||
GDK_WIN32_DND_NONE,
|
||||
GDK_WIN32_DND_PENDING,
|
||||
GDK_WIN32_DND_DROPPED,
|
||||
GDK_WIN32_DND_FAILED,
|
||||
GDK_WIN32_DND_DRAGGING,
|
||||
} GdkWin32DndState;
|
||||
|
||||
enum _GdkWin32AtomIndex
|
||||
{
|
||||
/* GdkAtoms: properties, targets and types */
|
||||
GDK_WIN32_ATOM_INDEX_GDK_SELECTION = 0,
|
||||
GDK_WIN32_ATOM_INDEX_CLIPBOARD_MANAGER,
|
||||
GDK_WIN32_ATOM_INDEX_WM_TRANSIENT_FOR,
|
||||
GDK_WIN32_ATOM_INDEX_TARGETS,
|
||||
GDK_WIN32_ATOM_INDEX_DELETE,
|
||||
GDK_WIN32_ATOM_INDEX_SAVE_TARGETS,
|
||||
GDK_WIN32_ATOM_INDEX_UTF8_STRING,
|
||||
GDK_WIN32_ATOM_INDEX_TEXT,
|
||||
GDK_WIN32_ATOM_INDEX_COMPOUND_TEXT,
|
||||
GDK_WIN32_ATOM_INDEX_TEXT_URI_LIST,
|
||||
GDK_WIN32_ATOM_INDEX_TEXT_HTML,
|
||||
GDK_WIN32_ATOM_INDEX_IMAGE_PNG,
|
||||
GDK_WIN32_ATOM_INDEX_IMAGE_JPEG,
|
||||
GDK_WIN32_ATOM_INDEX_IMAGE_BMP,
|
||||
GDK_WIN32_ATOM_INDEX_IMAGE_GIF,
|
||||
/* DND selections */
|
||||
GDK_WIN32_ATOM_INDEX_LOCAL_DND_SELECTION,
|
||||
GDK_WIN32_ATOM_INDEX_DROPFILES_DND,
|
||||
GDK_WIN32_ATOM_INDEX_OLE2_DND,
|
||||
/* Clipboard formats */
|
||||
GDK_WIN32_ATOM_INDEX_PNG,
|
||||
GDK_WIN32_ATOM_INDEX_JFIF,
|
||||
GDK_WIN32_ATOM_INDEX_GIF,
|
||||
GDK_WIN32_ATOM_INDEX_CF_DIB,
|
||||
GDK_WIN32_ATOM_INDEX_CFSTR_SHELLIDLIST,
|
||||
GDK_WIN32_ATOM_INDEX_CF_TEXT,
|
||||
GDK_WIN32_ATOM_INDEX_CF_UNICODETEXT,
|
||||
GDK_WIN32_ATOM_INDEX_LAST
|
||||
};
|
||||
|
||||
typedef enum _GdkWin32AtomIndex GdkWin32AtomIndex;
|
||||
|
||||
enum _GdkWin32CFIndex
|
||||
{
|
||||
GDK_WIN32_CF_INDEX_PNG = 0,
|
||||
GDK_WIN32_CF_INDEX_JFIF,
|
||||
GDK_WIN32_CF_INDEX_GIF,
|
||||
GDK_WIN32_CF_INDEX_UNIFORMRESOURCELOCATORW,
|
||||
GDK_WIN32_CF_INDEX_CFSTR_SHELLIDLIST,
|
||||
GDK_WIN32_CF_INDEX_HTML_FORMAT,
|
||||
GDK_WIN32_CF_INDEX_TEXT_HTML,
|
||||
GDK_WIN32_CF_INDEX_IMAGE_PNG,
|
||||
GDK_WIN32_CF_INDEX_IMAGE_JPEG,
|
||||
GDK_WIN32_CF_INDEX_IMAGE_BMP,
|
||||
GDK_WIN32_CF_INDEX_IMAGE_GIF,
|
||||
GDK_WIN32_CF_INDEX_TEXT_URI_LIST,
|
||||
GDK_WIN32_CF_INDEX_UTF8_STRING,
|
||||
GDK_WIN32_CF_INDEX_LAST
|
||||
};
|
||||
|
||||
typedef enum _GdkWin32CFIndex GdkWin32CFIndex;
|
||||
|
||||
#define GDK_TYPE_WIN32_SELECTION (gdk_win32_selection_get_type ())
|
||||
#define GDK_WIN32_SELECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_WIN32_SELECTION, GdkWin32Selection))
|
||||
#define GDK_WIN32_SELECTION_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_WIN32_SELECTION, GdkWin32SelectionClass))
|
||||
#define GDK_IS_WIN32_SELECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_WIN32_SELECTION))
|
||||
#define GDK_IS_WIN32_SELECTION_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_WIN32_SELECTION))
|
||||
#define GDK_WIN32_SELECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_WIN32_SELECTION, GdkWin32SelectionClass))
|
||||
|
||||
typedef struct _GdkWin32Selection GdkWin32Selection;
|
||||
typedef struct _GdkWin32SelectionClass GdkWin32SelectionClass;
|
||||
|
||||
/* This object is just a sink to hold all the selection- and dnd-related data
|
||||
* that otherwise would be in global variables.
|
||||
*/
|
||||
struct _GdkWin32Selection
|
||||
{
|
||||
GObject *parent_instance;
|
||||
GHashTable *sel_prop_table;
|
||||
GdkSelProp *dropfiles_prop;
|
||||
/* We store the owner of each selection in this table. Obviously, this only
|
||||
* is valid intra-app, and in fact it is necessary for the intra-app DND to work.
|
||||
*/
|
||||
GHashTable *sel_owner_table;
|
||||
|
||||
/* GdkAtoms for well-known image formats */
|
||||
GdkAtom *known_pixbuf_formats;
|
||||
int n_known_pixbuf_formats;
|
||||
|
||||
/* GArray of GdkAtoms for various known Selection and DnD strings.
|
||||
* Size is guaranteed to be at least GDK_WIN32_ATOM_INDEX_LAST
|
||||
*/
|
||||
GArray *known_atoms;
|
||||
|
||||
/* GArray of UINTs for various known clipboard formats.
|
||||
* Size is guaranteed to be at least GDK_WIN32_CF_INDEX_LAST.
|
||||
*/
|
||||
GArray *known_clipboard_formats;
|
||||
|
||||
GdkWin32DndState dnd_target_state;
|
||||
GdkWin32DndState dnd_source_state;
|
||||
|
||||
/* Holds a reference to the data object for the target drop site.
|
||||
*/
|
||||
IDataObject *dnd_data_object_target;
|
||||
|
||||
/* Carries DnD target context from idroptarget_*() to convert_selection() */
|
||||
GdkDragContext *target_drag_context;
|
||||
|
||||
/* Carries W32 format ID from idataobject_getdata() to property_change() */
|
||||
UINT property_change_format;
|
||||
/* Carries the W32-wrapped data between idataobject_getdata() and property_change() */
|
||||
LPSTGMEDIUM property_change_data;
|
||||
/* Carries the transmute field of the GdkSelTargetFormat from from idataobject_getdata() to property_change() */
|
||||
gboolean property_change_transmute;
|
||||
|
||||
/* TRUE when we are emptying the clipboard ourselves */
|
||||
gboolean ignore_destroy_clipboard;
|
||||
|
||||
/* Array of GdkSelTargetFormats describing the targets supported by the clipboard selection */
|
||||
GArray *clipboard_selection_targets;
|
||||
|
||||
/* Same for the DnD selection (applies for both LOCAL and OLE2 DnD) */
|
||||
GArray *dnd_selection_targets;
|
||||
|
||||
/* If TRUE, then we queued a GDK_SELECTION_REQUEST with TARGETS
|
||||
* target. This field is checked to prevent queueing
|
||||
* multiple selection requests.
|
||||
*/
|
||||
gboolean targets_request_pending;
|
||||
|
||||
/* The handle that was given to OpenClipboard().
|
||||
* NULL is a valid handle,
|
||||
* INVALID_HANDLE_VALUE means that the clipboard is closed.
|
||||
*/
|
||||
HWND clipboard_opened_for;
|
||||
|
||||
/* A target-keyed hash table of GArrays of GdkSelTargetFormats describing compatibility formats for a target */
|
||||
GHashTable *compatibility_formats;
|
||||
/* A format-keyed hash table of GArrays of GdkAtoms describing compatibility targets for a format */
|
||||
GHashTable *compatibility_targets;
|
||||
|
||||
/* Last observer owner of the clipboard, as reported by the OS.
|
||||
* This is compared to GetClipboardOwner() return value to see
|
||||
* whether the owner changed.
|
||||
*/
|
||||
HWND stored_hwnd_owner;
|
||||
};
|
||||
|
||||
struct _GdkWin32SelectionClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gdk_win32_selection_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void _gdk_win32_clear_clipboard_queue ();
|
||||
gchar * _gdk_win32_get_clipboard_format_name (UINT fmt,
|
||||
gboolean *is_predefined);
|
||||
void _gdk_win32_add_format_to_targets (UINT format,
|
||||
GArray *array,
|
||||
GList **list);
|
||||
gint _gdk_win32_add_target_to_selformats (GdkAtom target,
|
||||
GArray *array);
|
||||
void _gdk_win32_selection_property_change (GdkWin32Selection *win32_sel,
|
||||
GdkWindow *window,
|
||||
GdkAtom property,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
GdkPropMode mode,
|
||||
const guchar *data,
|
||||
gint nelements);
|
||||
|
||||
#endif /* __GDK_SELECTION_WIN32_H__ */
|
65
gdk/win32/gdkwin32dnd-private.h
Normal file
65
gdk/win32/gdkwin32dnd-private.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2010 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GDK_WIN32_DND_PRIVATE_H__
|
||||
#define __GDK_WIN32_DND_PRIVATE_H__
|
||||
|
||||
#if !defined (__GDKWIN32_H_INSIDE__) && !defined (GDK_COMPILATION)
|
||||
#error "Only <gdk/gdkwin32.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _GdkWin32DragContext
|
||||
{
|
||||
GdkDragContext context;
|
||||
GdkWindow *ipc_window;
|
||||
GdkWindow *drag_window;
|
||||
GdkCursor *cursor;
|
||||
GdkSeat *grab_seat;
|
||||
GdkDragAction actions;
|
||||
GdkDragAction current_action;
|
||||
|
||||
guint drag_status : 4; /* Current status of drag */
|
||||
guint drop_failed : 1; /* Whether the drop was unsuccessful */
|
||||
guint has_image_format : 1;
|
||||
|
||||
guint scale; /* Temporarily caches the HiDPI scale */
|
||||
gint hot_x; /* Hotspot offset from the top-left of the drag-window, scaled (can be added to GDK space coordinates) */
|
||||
gint hot_y;
|
||||
gint last_x; /* Coordinates from last event, in GDK space */
|
||||
gint last_y;
|
||||
gint start_x; /* Coordinates of the drag start, in GDK space */
|
||||
gint start_y;
|
||||
DWORD last_key_state; /* Key state from last event */
|
||||
|
||||
/* Just like context->targets, but an array, and with format IDs
|
||||
* stored inside.
|
||||
*/
|
||||
GArray *droptarget_format_target_map;
|
||||
};
|
||||
|
||||
struct _GdkWin32DragContextClass
|
||||
{
|
||||
GdkDragContextClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_WIN32_DND_PRIVATE_H__ */
|
@ -789,6 +789,14 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display,
|
||||
if (impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY)
|
||||
dwExStyle |= WS_EX_TOOLWINDOW;
|
||||
|
||||
/* WS_EX_TRANSPARENT means "try draw this window last, and ignore input".
|
||||
* It's the last part we're after. We don't want DND indicator to accept
|
||||
* input, because that will make it a potential drop target, and if it's
|
||||
* under the mouse cursor, this will kill any DND.
|
||||
*/
|
||||
if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DND)
|
||||
dwExStyle |= WS_EX_TRANSPARENT;
|
||||
|
||||
klass = RegisterGdkClass (window->window_type, impl->type_hint);
|
||||
|
||||
wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
|
||||
|
@ -45,6 +45,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
#include <gdk/win32/gdkwin32.h>
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
#include <gdk/wayland/gdkwayland.h>
|
||||
#endif
|
||||
@ -1157,6 +1161,9 @@ gtk_drag_is_managed (GtkWidget *source_widget)
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (source_widget)) ||
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
GDK_IS_WIN32_DISPLAY (gtk_widget_get_display (source_widget)) ||
|
||||
#endif
|
||||
FALSE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user