| 1 |
/* GDK - The GIMP Drawing Kit |
| 2 |
* |
| 3 |
* gdkselection-win32.h: Private Win32 specific selection object |
| 4 |
* |
| 5 |
* Copyright © 2017 LRN |
| 6 |
* |
| 7 |
* This library is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU Library General Public |
| 9 |
* License as published by the Free Software Foundation; either |
| 10 |
* version 2 of the License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* This library is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* Library General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Library General Public |
| 18 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef __GDK_SELECTION_WIN32_H__ |
| 22 |
#define __GDK_SELECTION_WIN32_H__ |
| 23 |
|
| 24 |
G_BEGIN_DECLS |
| 25 |
|
| 26 |
#define _gdk_win32_selection_get() (_win32_selection) |
| 27 |
#define _gdk_atom_array_index(a, i) (g_array_index (a, GdkAtom, i)) |
| 28 |
#define _gdk_win32_selection_atom(i) (_gdk_atom_array_index (_gdk_win32_selection_get ()->known_atoms, i)) |
| 29 |
#define _gdk_cf_array_index(a, i) (g_array_index (a, UINT, i)) |
| 30 |
#define _gdk_win32_selection_cf(i) (_gdk_cf_array_index (_gdk_win32_selection_get ()->known_clipboard_formats, i)) |
| 31 |
|
| 32 |
/* Maps targets to formats or vice versa, depending on the |
| 33 |
* semantics of the array that holds these. |
| 34 |
* Also remembers whether the data needs to be transmuted. |
| 35 |
*/ |
| 36 |
typedef struct { |
| 37 |
gint format; |
| 38 |
GdkAtom target; |
| 39 |
gboolean transmute; |
| 40 |
} GdkSelTargetFormat; |
| 41 |
|
| 42 |
/* We emulate the GDK_SELECTION window properties of windows (as used |
| 43 |
* in the X11 backend) by using a hash table from window handles to |
| 44 |
* GdkSelProp structs. |
| 45 |
*/ |
| 46 |
typedef struct { |
| 47 |
guchar *data; |
| 48 |
gsize length; |
| 49 |
gint bitness; |
| 50 |
GdkAtom target; |
| 51 |
} GdkSelProp; |
| 52 |
|
| 53 |
/* OLE-based DND state */ |
| 54 |
typedef enum { |
| 55 |
GDK_WIN32_DND_NONE, |
| 56 |
GDK_WIN32_DND_PENDING, |
| 57 |
GDK_WIN32_DND_DROPPED, |
| 58 |
GDK_WIN32_DND_FAILED, |
| 59 |
GDK_WIN32_DND_DRAGGING, |
| 60 |
} GdkWin32DndState; |
| 61 |
|
| 62 |
enum _GdkWin32AtomIndex |
| 63 |
{ |
| 64 |
/* GdkAtoms: properties, targets and types */ |
| 65 |
GDK_WIN32_ATOM_INDEX_GDK_SELECTION = 0, |
| 66 |
GDK_WIN32_ATOM_INDEX_CLIPBOARD_MANAGER, |
| 67 |
GDK_WIN32_ATOM_INDEX_WM_TRANSIENT_FOR, |
| 68 |
GDK_WIN32_ATOM_INDEX_TARGETS, |
| 69 |
GDK_WIN32_ATOM_INDEX_DELETE, |
| 70 |
GDK_WIN32_ATOM_INDEX_SAVE_TARGETS, |
| 71 |
GDK_WIN32_ATOM_INDEX_UTF8_STRING, |
| 72 |
GDK_WIN32_ATOM_INDEX_TEXT, |
| 73 |
GDK_WIN32_ATOM_INDEX_COMPOUND_TEXT, |
| 74 |
GDK_WIN32_ATOM_INDEX_TEXT_URI_LIST, |
| 75 |
GDK_WIN32_ATOM_INDEX_TEXT_HTML, |
| 76 |
GDK_WIN32_ATOM_INDEX_IMAGE_PNG, |
| 77 |
GDK_WIN32_ATOM_INDEX_IMAGE_JPEG, |
| 78 |
GDK_WIN32_ATOM_INDEX_IMAGE_BMP, |
| 79 |
GDK_WIN32_ATOM_INDEX_IMAGE_GIF, |
| 80 |
/* DND selections */ |
| 81 |
GDK_WIN32_ATOM_INDEX_LOCAL_DND_SELECTION, |
| 82 |
GDK_WIN32_ATOM_INDEX_DROPFILES_DND, |
| 83 |
GDK_WIN32_ATOM_INDEX_OLE2_DND, |
| 84 |
/* Clipboard formats */ |
| 85 |
GDK_WIN32_ATOM_INDEX_PNG, |
| 86 |
GDK_WIN32_ATOM_INDEX_JFIF, |
| 87 |
GDK_WIN32_ATOM_INDEX_GIF, |
| 88 |
GDK_WIN32_ATOM_INDEX_CF_DIB, |
| 89 |
GDK_WIN32_ATOM_INDEX_CFSTR_SHELLIDLIST, |
| 90 |
GDK_WIN32_ATOM_INDEX_CF_TEXT, |
| 91 |
GDK_WIN32_ATOM_INDEX_CF_UNICODETEXT, |
| 92 |
GDK_WIN32_ATOM_INDEX_LAST |
| 93 |
}; |
| 94 |
|
| 95 |
typedef enum _GdkWin32AtomIndex GdkWin32AtomIndex; |
| 96 |
|
| 97 |
enum _GdkWin32CFIndex |
| 98 |
{ |
| 99 |
GDK_WIN32_CF_INDEX_PNG = 0, |
| 100 |
GDK_WIN32_CF_INDEX_JFIF, |
| 101 |
GDK_WIN32_CF_INDEX_GIF, |
| 102 |
GDK_WIN32_CF_INDEX_UNIFORMRESOURCELOCATORW, |
| 103 |
GDK_WIN32_CF_INDEX_CFSTR_SHELLIDLIST, |
| 104 |
GDK_WIN32_CF_INDEX_HTML_FORMAT, |
| 105 |
GDK_WIN32_CF_INDEX_TEXT_HTML, |
| 106 |
GDK_WIN32_CF_INDEX_IMAGE_PNG, |
| 107 |
GDK_WIN32_CF_INDEX_IMAGE_JPEG, |
| 108 |
GDK_WIN32_CF_INDEX_IMAGE_BMP, |
| 109 |
GDK_WIN32_CF_INDEX_IMAGE_GIF, |
| 110 |
GDK_WIN32_CF_INDEX_TEXT_URI_LIST, |
| 111 |
GDK_WIN32_CF_INDEX_UTF8_STRING, |
| 112 |
GDK_WIN32_CF_INDEX_LAST |
| 113 |
}; |
| 114 |
|
| 115 |
typedef enum _GdkWin32CFIndex GdkWin32CFIndex; |
| 116 |
|
| 117 |
#define GDK_TYPE_WIN32_SELECTION (gdk_win32_selection_get_type ()) |
| 118 |
#define GDK_WIN32_SELECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_WIN32_SELECTION, GdkWin32Selection)) |
| 119 |
#define GDK_WIN32_SELECTION_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_WIN32_SELECTION, GdkWin32SelectionClass)) |
| 120 |
#define GDK_IS_WIN32_SELECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_WIN32_SELECTION)) |
| 121 |
#define GDK_IS_WIN32_SELECTION_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_WIN32_SELECTION)) |
| 122 |
#define GDK_WIN32_SELECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_WIN32_SELECTION, GdkWin32SelectionClass)) |
| 123 |
|
| 124 |
typedef struct _GdkWin32Selection GdkWin32Selection; |
| 125 |
typedef struct _GdkWin32SelectionClass GdkWin32SelectionClass; |
| 126 |
|
| 127 |
/* This object is just a sink to hold all the selection- and dnd-related data |
| 128 |
* that otherwise would be in global variables. |
| 129 |
*/ |
| 130 |
struct _GdkWin32Selection |
| 131 |
{ |
| 132 |
GObject parent_instance; |
| 133 |
|
| 134 |
GHashTable *sel_prop_table; |
| 135 |
GdkSelProp *dropfiles_prop; |
| 136 |
/* We store the owner of each selection in this table. Obviously, this only |
| 137 |
* is valid intra-app, and in fact it is necessary for the intra-app DND to work. |
| 138 |
*/ |
| 139 |
GHashTable *sel_owner_table; |
| 140 |
|
| 141 |
/* GdkAtoms for well-known image formats */ |
| 142 |
GdkAtom *known_pixbuf_formats; |
| 143 |
int n_known_pixbuf_formats; |
| 144 |
|
| 145 |
/* GArray of GdkAtoms for various known Selection and DnD strings. |
| 146 |
* Size is guaranteed to be at least GDK_WIN32_ATOM_INDEX_LAST |
| 147 |
*/ |
| 148 |
GArray *known_atoms; |
| 149 |
|
| 150 |
/* GArray of UINTs for various known clipboard formats. |
| 151 |
* Size is guaranteed to be at least GDK_WIN32_CF_INDEX_LAST. |
| 152 |
*/ |
| 153 |
GArray *known_clipboard_formats; |
| 154 |
|
| 155 |
GdkWin32DndState dnd_target_state; |
| 156 |
GdkWin32DndState dnd_source_state; |
| 157 |
|
| 158 |
/* Holds a reference to the data object for the target drop site. |
| 159 |
*/ |
| 160 |
IDataObject *dnd_data_object_target; |
| 161 |
|
| 162 |
/* Carries DnD target context from idroptarget_*() to convert_selection() */ |
| 163 |
GdkDragContext *target_drag_context; |
| 164 |
|
| 165 |
/* Carries W32 format ID from idataobject_getdata() to property_change() */ |
| 166 |
UINT property_change_format; |
| 167 |
/* Carries the W32-wrapped data between idataobject_getdata() and property_change() */ |
| 168 |
LPSTGMEDIUM property_change_data; |
| 169 |
/* Carries the transmute field of the GdkSelTargetFormat from from idataobject_getdata() to property_change() */ |
| 170 |
gboolean property_change_transmute; |
| 171 |
/* Carries the target atom from GDK_SELECTION_REQUEST issuer to property_change() */ |
| 172 |
GdkAtom property_change_target_atom; |
| 173 |
|
| 174 |
/* TRUE when we are emptying the clipboard ourselves */ |
| 175 |
gboolean ignore_destroy_clipboard; |
| 176 |
|
| 177 |
/* Array of GdkSelTargetFormats describing the targets supported by the clipboard selection */ |
| 178 |
GArray *clipboard_selection_targets; |
| 179 |
|
| 180 |
/* Same for the DnD selection (applies for both LOCAL and OLE2 DnD) */ |
| 181 |
GArray *dnd_selection_targets; |
| 182 |
|
| 183 |
/* If TRUE, then we queued a GDK_SELECTION_REQUEST with TARGETS |
| 184 |
* target. This field is checked to prevent queueing |
| 185 |
* multiple selection requests. |
| 186 |
*/ |
| 187 |
gboolean targets_request_pending; |
| 188 |
|
| 189 |
/* The handle that was given to OpenClipboard(). |
| 190 |
* NULL is a valid handle, |
| 191 |
* INVALID_HANDLE_VALUE means that the clipboard is closed. |
| 192 |
*/ |
| 193 |
HWND clipboard_opened_for; |
| 194 |
|
| 195 |
/* A target-keyed hash table of GArrays of GdkSelTargetFormats describing compatibility formats for a target */ |
| 196 |
GHashTable *compatibility_formats; |
| 197 |
/* A format-keyed hash table of GArrays of GdkAtoms describing compatibility targets for a format */ |
| 198 |
GHashTable *compatibility_targets; |
| 199 |
}; |
| 200 |
|
| 201 |
struct _GdkWin32SelectionClass |
| 202 |
{ |
| 203 |
GObjectClass parent_class; |
| 204 |
}; |
| 205 |
|
| 206 |
GType gdk_win32_selection_get_type (void) G_GNUC_CONST; |
| 207 |
|
| 208 |
void _gdk_win32_clear_clipboard_queue (); |
| 209 |
gchar * _gdk_win32_get_clipboard_format_name (UINT fmt, |
| 210 |
gboolean *is_predefined); |
| 211 |
void _gdk_win32_add_format_to_targets (UINT format, |
| 212 |
GArray *array, |
| 213 |
GList **list); |
| 214 |
gint _gdk_win32_add_target_to_selformats (GdkAtom target, |
| 215 |
GArray *array); |
| 216 |
void _gdk_win32_selection_property_change (GdkWin32Selection *win32_sel, |
| 217 |
GdkWindow *window, |
| 218 |
GdkAtom property, |
| 219 |
GdkAtom type, |
| 220 |
gint format, |
| 221 |
GdkPropMode mode, |
| 222 |
const guchar *data, |
| 223 |
gint nelements); |
| 224 |
|
| 225 |
#endif /* __GDK_SELECTION_WIN32_H__ */ |