summaryrefslogtreecommitdiff
path: root/gtk/gtkdnd.c
Commit message (Collapse)AuthorAgeFilesLines
* Drop method annotation for gtk_drag_cancel()Emmanuele Bassi2018-02-121-1/+1
| | | | | | | | | The other method annotations were removed in commit c306e448b32e. There is no introspected ABI change, as g-ir-scanner would just ignore the annotation. This eliminates the last warning when building GTK on Linux.
* Fix overzalous method annotations for drag and dropAlban Browaeys2018-02-121-8/+8
| | | | | | | | | | | | | | | | | | | | Functional revert of commit 9c4892f2915. Fixes introspection scanner warnings like: Warning: Gtk: gtk_drag_finish: Methods must belong to the same namespace as the class they belong to That is, the gtk_drag_* functions cannot be methods as they have a "GdkDragContext" as the instance parameter, and that is not a valid type for the Gtk namespace. This is not an introspected ABI change, as the generated introspection data ignores the annotation. Signed-off-by: Emmanuele Bassi <ebassi@gnome.org> https://bugzilla.gnome.org/show_bug.cgi?id=692152
* pointerfocus: Don't include gtk.hBenjamin Otte2018-02-081-13/+10
| | | | | Also fix up gtktypes.h to include the required glib.h for G_BEGIN_DECLS and gtkdnd.c to include missing includes.
* The big versioning cleanupMatthias Clasen2018-02-061-8/+0
| | | | | | | Remove all the old 2.x and 3.x version annotations. GTK+ 4 is a new start, and from the perspective of a GTK+ 4 developer all these APIs have been around since the beginning.
* Replace gdk_threads_add_timeout* with g_timeout_add()Emmanuele Bassi2018-02-031-3/+1
| | | | | | | | | | | | | | | The main GDK thread lock is not portable and deprecated. The only reason why gdk_threads_add_timeout() and gdk_threads_add_timeout_full() exist is to allow invoking a callback with the GDK lock held, in case 3rd party libraries still use the deprecated gdk_threads_enter()/gdk_threads_leave() API. Since we're removing the GDK lock, and we're releasing a new major API, such code cannot exist any more; this means we can use the GLib API for installing timeout callbacks. https://bugzilla.gnome.org/show_bug.cgi?id=793124
* dnd: Drop docs that are no longer relevantMatthias Clasen2017-12-301-22/+0
| | | | | We no longer take an event as argument, so no need to explain how to obtain a suitable event.
* dnd: Get rid of IPC widgetsBenjamin Otte2017-12-161-103/+9
| | | | | | | Instead, pass the source window to gdk_drag_begin(). Also make Wayland use this window instead of the one under the pointer (though those 2 Windows are most likely the same anyway).
* dnd: Remove unused functionBenjamin Otte2017-12-161-72/+0
| | | | | | | | | | | The function was referencing itself in ways that bamboozled gcc: static void foo (void) { g_signal_handlers_disconnect_by_func (NULL, foo, NULL); } Well done, function, you get your own commit!
* x11: Use gdk_drag_context_get_display()Benjamin Otte2017-12-161-1/+1
|
* dnd: Remove handler for nonexisting signalBenjamin Otte2017-12-151-40/+0
| | | | The signal has been gone since e3e9bf4bea3307e9d0c6728d82f04994b069005f
* Drop gdk_atom_internMatthias Clasen2017-12-131-4/+4
| | | | | Atoms are just interned strings now, so we can just use g_intern_string.
* dnd: Remove gdk_drag_get_selection()Benjamin Otte2017-12-141-2/+0
| | | | | | | | | Without selections, drags can't have them either. Also included is removing the selection from GtkSelectionData. Includes a bunch of crude cleanups to Wayland code that no longer has to care about selection atoms.
* gtk: Avoid some event copiesCarlos Garnacho2017-12-141-1/+1
| | | | Those places can do with an extra reference.
* gtk: s/gdk_event_free/g_object_unref/Carlos Garnacho2017-12-141-1/+1
|
* gdk: Remove gdk_selection_convert()Benjamin Otte2017-12-141-1/+0
| | | | It's not used anymore.
* dnd: Only send DELETE request on X11Benjamin Otte2017-12-131-20/+1
| | | | This is Xdnd-specific and doesn't need to happen elsewhere.
* xxx: don't claim dnd selectionBenjamin Otte2017-12-131-18/+0
|
* x11: Move selection handling to GDKBenjamin Otte2017-12-131-18/+0
| | | | | Instead of claiming the selection in GTK, claim it in the X11 dnd code. Also handle SelectionRequest and SelectionClear X events there.
* dnd: Pass content to gdk_drag_begin()Benjamin Otte2017-12-131-1/+155
| | | | | | | | | | | | | | | | Instead of just passing the GdkContentFormats, we are now passing the GdkContentProvider to gdk_drag_begin(). This means that GDK itself can now query the data from the provider directly instead of having to send selection events. Use this to provide the private API gdk_drag_context_write() that allows backends to pass an output stream that this data will be written to. Implement this as the mechanism for providing drag data on Wayland. And to make this all work, implement a content provider named GtkDragContent that is implemented by reverting to the old DND drag-data-get machinery inside GTK, so for widgets everything works just like before.
* dnd: Pass device, not eventBenjamin Otte2017-12-121-31/+25
| | | | | You don't start a dnd operation with a device, you start it with an event.
* dnd: No longer allow passing -1Benjamin Otte2017-12-121-38/+12
| | | | Nobody ever does that and special cases are evil.
* dnd: Remove button argument from drag_begin()Benjamin Otte2017-12-121-88/+1
| | | | It was unused.
* Set a style class for drag iconsMatthias Clasen2017-12-101-3/+1
| | | | | | This lets us use the new icon-size machinery to ensure we don't have tiny drag icons when using named icons.
* gdk: Remove gdk_drag_manage_dnd()Benjamin Otte2017-12-111-4/+2
| | | | | | | Instead, pass the actions as part of gdk_drag_begin() and insist DND is always managed. A new side effect is that gdk_drag_begin() can now return %NULL.
* dnd: No point in determining the keyboardBenjamin Otte2017-12-111-9/+2
| | | | We only use the pointer.
* dnd: Pass dx/dy instead of x_root/y_rootBenjamin Otte2017-12-111-9/+25
| | | | | This way, we don't need root coordinates when computing the dnd start position.
* dnd: Make gdk_drag_context_set_device() privateBenjamin Otte2017-12-111-2/+0
| | | | | There's no need to call it from GTK anymore, because we pass the device to gdk_drag_begin().
* gdk: Remove outdated gdk_drag_begin() alternativesBenjamin Otte2017-12-111-1/+1
| | | | | There's only one that's ever used, so delete the others and rename this one to gdk_drag_begin().
* dnd: Remove "delete" argument from gtk_drag_finish()Benjamin Otte2017-12-101-19/+8
| | | | | | | The argument is ignored by anything but X11. It's treated like suggested_action == MOVE. So do that in gtk_drag_finish(), too.
* dnd: Introduce gdk_drop_read_async() and use itBenjamin Otte2017-12-101-15/+122
| | | | | | | | | | This is the replacement for selection usage. Backend implementations for X11 (missing support for backwards compat formats like COMPOUND_TEXT) and Wayland are included. GTK code should be adapted to use gdk_drop_read_*() functions instead of gtk_drag_get_data().
* dnd: Remove x/y coordinates from drag-data-receivedBenjamin Otte2017-12-051-8/+2
| | | | | | This is in preparation of using input streams to show that these coordinates aren't needed most of the time and can otherwise be saved during GtkWidget::drag-drop.
* dnd: Remove unused variablesBenjamin Otte2017-12-031-61/+24
|
* dnd: Handle rootwin drop in gdkMatthias Clasen2017-12-031-40/+6
| | | | This lets us drop the only use of the drag protocol in gtk.
* dnd: Remove much of the unmanaged dndMatthias Clasen2017-12-031-667/+18
|
* dnd: Add gtk_drag_set_icon_texture()Benjamin Otte2017-12-021-0/+32
|
* W32: Massive W32 DnD fixРуслан Ижбулатов2017-12-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* dnd: Stop using gdk_cursor_new_from_pixbufMatthias Clasen2017-11-291-11/+6
| | | | We can just use gdk_cursor_new_from_texture here.
* doc: Replace uses of #NULL with %NULLDaniel Boles2017-11-221-1/+1
|
* gdk: Sanitize GdkContentFormats APIBenjamin Otte2017-11-201-5/+5
| | | | | | | | | | Make sure the API reflects the idea that GdkContentFormats is a set containing mime types. In particular, treat the object itself as a plural - it's named content format`S' after all - and therefor use the correct verb form. Also make GdkContentFormats keep an array instead of a list, now that it's immutable.
* gdkdnd: Make GdkDragContext->formats a GdkContentFormatsBenjamin Otte2017-11-201-12/+1
| | | | Instead of it being a GList of GdkAtoms.
* contentformats: Rename GtkTargetListBenjamin Otte2017-11-201-18/+19
| | | | It's now called GdkContentsFormat
* selection: Make GtkTargetList members privateBenjamin Otte2017-11-201-34/+29
| | | | | Outside of the target list, don't access it directly, instead use public APIs like the newly introduced gtk_target_list_intersects().
* dnd: Remove GtkTargetEntry and GtkTargetFlagsBenjamin Otte2017-11-201-10/+4
| | | | | | | warning: We don't do any same-app checks anymore so you currently can copy local data into external apps. This will be fixed later.
* selection: Remove the info uintBenjamin Otte2017-11-161-35/+14
| | | | | | | | | Instead of allowing people to pass a uint user-data, insist on them comparing mime types. The user data was a uint instead of a pointer anyway, so uniqueness could not be guaranteed and it caused more issues than it was worth. And that's ignoring the fact that it basically wasn't used.
* image: Don't take icon size in set_from_definition()Benjamin Otte2017-11-151-1/+1
|
* gdk: Replace GDK_NONE with NULLBenjamin Otte2017-11-151-5/+5
|
* Fix up managed dndMatthias Clasen2017-11-111-2/+5
| | | | | | Since commit 6c56d04cee23d3340cf7cf08756c610efe9ccdab, we were doing some calls twice in the managed dnd case, leading to double drops.
* gdk: Cursors no longer have a displayBenjamin Otte2017-11-041-13/+2
| | | | | | | Change constructors to reflect that. While doing so, also add a fallback argument to the cursor constructors, so it is now possible to create cursors with fallback.
* dnd: Remove remnants of screen trackingMatthias Clasen2017-10-311-11/+2
| | | | There is only one screen nowadays, no need to track it.
* Drop GdkScreen from GdkDevice apisMatthias Clasen2017-10-311-5/+2
| | | | | Returning the screen does not add anything here and GdkScreen is going away.