Commit Graph

352 Commits

Author SHA1 Message Date
Carlos Garnacho
1349ffa0db gtkdnd: Avoid gdk_device_manager_get_client_pointer()
It's now deprecated
2015-12-15 23:18:10 +01:00
Matthias Clasen
a22c1ec980 dnd: Cleanups
Remove some now unused includes and dead code, and rename
gtk_drag_set_icon_window to gtk_drag_set_icon_widget_internal,
since it is no longer restricted to toplevel windows.
2015-12-13 18:24:41 -05:00
Matthias Clasen
95f648147d dnd: Stop doing cancel animation in GTK+
Under Wayland, the compositor does it, so there is no need
for us to move the window ourselves. For X11, we are now
doing the animation from the X11 backend. Trigger that by
calling gdk_drag_drop_done().

What changes here is that we have to keep the icon_window
alive for as long as the drag context exists. Use a weak
reference to do so.
2015-12-13 16:02:02 -05:00
Matthias Clasen
a24bbcbb8d dnd: Pass start coordinates when creating the drag context
This will be used in subsequent commits.
2015-12-13 10:39:43 -05:00
Matthias Clasen
bf7a7a5f3d dnd: pass hotspot to GDK
This uses the new api introduced in the previous commits.
2015-12-07 21:54:55 -05:00
Matthias Clasen
08ecf19907 dnd: Remove an unused struct field
We only have one screen nowadays, so the fallback_icon is
never used.
2015-12-07 21:15:23 -05:00
Matthias Clasen
ec5baa144d Update gtk_drag_highlight() docs
What they said was no longer true.
2015-12-03 08:37:58 -05:00
Matthias Clasen
0b9136842d Use :dnd pseudoclass for drag highlighting
Instead of a ::draw handler with a hardcoded outline,
use CSS for drawing the highlight.
2015-12-02 23:49:07 -05:00
Benjamin Otte
c10b6b7297 dnd: Add gtk_image_set_from_definition()
... and use it in the DND code, thereby getting rid of the icon helper.
2015-12-02 15:45:14 +01:00
Benjamin Otte
4d31bf91db dnd: No need to reset the icon
When we start a drag cancel animation, we can just keep the existing
window. The reset was only necessary to convert from cursor icon to
window and we removed the cursor handling.
2015-12-02 15:22:23 +01:00
Matthias Clasen
93d9c77ead dnd: Drop an unused argument 2015-12-02 00:51:47 -05:00
Matthias Clasen
676862a213 dnd: Some simplifications
We can now use a GtkImage instead of toplevel with
a custom draw callback and a specially prepared cairo
pattern.
2015-12-02 00:48:37 -05:00
Matthias Clasen
28b97ff0e9 dnd: Prevent black background in icons 2015-12-02 00:03:11 -05:00
Matthias Clasen
ae4f6da550 DND: Drop support for using rgba cursors as icons
This adds a lot of complication to the code, and is not really
a big win, since still need to support icon windows anyway.
2015-12-01 23:47:56 -05:00
Matthias Clasen
5bb12474d9 dnd: Fix issues with drag icons under Wayland
The Wayland dnd surface must remain in place until the drag
is over. Setting it directly as the hardcoded window of the
widget we construct carries the danger that it might get
destroyed prematurely, e.g. when the application calls
gtk_drag_set_icon_name more than once and we recreate the
widget.

Instead, create a dedicated toplevel, and reparent the widget
into it. To keep the code simple, we use the same approach
under X11 as well, and make it the responsibility of the
GDK dnd code to keep the window position updated. We already
pass the current pointer position to gdk_drag_motion, which
makes this very easy.

As a side-effect of these changes, it is now possible to use
non-toplevel widgets as drag icons.

https://bugzilla.gnome.org/show_bug.cgi?id=748763
2015-12-01 23:47:56 -05:00
Benjamin Otte
7a154d9acd dnd: Add gtk_drag_set_icon_definition()
... and use it for entry icons.

As a side effect, icons dragged from entries will now resize to DND
size.
2015-12-02 00:29:30 +01:00
Benjamin Otte
4a42aa5229 imagedefinition: Remove icon-size
The size of icons is a property that is relevant to who is rendering the
icon, not to the icon itself.

Example: Starting a DND operation from an entry icon should cause the
icon to resize (from the entr icon's size to the DND icon size).
2015-12-02 00:29:30 +01:00
Benjamin Otte
e99eba4415 dnd: Rewrite iconhelper code
It now uses GtkImageDefinition instead.
2015-12-02 00:29:30 +01:00
Benjamin Otte
482d71d680 iconhelper: Add a scale argument to gtk_icon_helper_load_surface()
It will be used in the next patch.
2015-12-02 00:29:30 +01:00
Benjamin Otte
afad393b15 iconhelper: Refactor ensure_surface()
Make gtk_icon_helper_ensure_surface() a private function that just
ensures the surface was loaded.

Add gtk_icon_helper_load_surface() that is called by the above function
and the dnd code to actually load the surface.
2015-12-02 00:29:30 +01:00
Benjamin Otte
3bacffd063 dnd: Use surface for dnd icon instead of pixbuf 2015-12-02 00:29:29 +01:00
Benjamin Otte
1c96b703a6 dragsource: Store an itemdefinition, not an iconhelper
The icon is never rendered, so there's no need for the extra iconhelper
code.
2015-12-02 00:29:29 +01:00
Benjamin Otte
415030d25f dnd: Split GtkDragSourceSite into its own file 2015-11-25 20:31:27 +01:00
Benjamin Otte
2bee73c1f9 dnd: Just pass iconhelper instead of whole DragSourceSite
Simplifies the code.
2015-11-25 16:32:40 +01:00
Benjamin Otte
175d5d580e dnd: Remove unused struct members 2015-11-25 16:32:40 +01:00
Benjamin Otte
29cdb2001c iconhelper: Don't include gtk.h 2015-11-25 16:32:39 +01:00
Carlos Garnacho
770feff302 gtkdnd: Unbreak non-wayland builds
missing #ifdef...
2015-11-20 13:30:14 +01:00
Carlos Garnacho
26f9d6b1c1 gtkdnd: Ensure we don't fold the drag icon into the cursor on wayland
This is wrong by all accounts there, as we can do no tricks there to show
a "drag failed" animation, which is performed by the compositor itself
on wayland.
2015-11-19 23:28:19 +01:00
Carlos Garnacho
e3012dc9b3 gtkdnd: Use gdk_drag_begin_for_device()
We've got the pointer at hand there, just pass that instead of figuring
out from the client pointer.
2015-11-19 23:26:49 +01:00
Matthias Clasen
1e51398e9a Small cleanup
Use g_clear_object in gtkdnd.c.
2015-10-08 07:20:26 -04:00
Carlos Garnacho
9e2092d306 gtkdnd: Fix introspection annotations in some functions
The GdkEvent field is nullable on gtk_drag_begin*, and gtk_drag_cancel()
is a method, like the rest of the DnD API.
2015-07-07 12:50:14 +02:00
Carlos Garnacho
dadb2750b1 gtkdnd: Account for setting a same icon helper
g_set_object() will take care of ref'ing before destroying the previous
instance, which might actually be the same pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=751401
2015-07-07 11:24:37 +02:00
Carlos Garnacho
3f8982a0cd gtkdnd: Traverse across insensitive widgets
The current widget lookup code bails out on insensitive widgets, there's
however legit cases where we want DnD handled by a parent of the insensitive
widget, so just keep going upwards in that case.

We also use now the widget state flags, because get_sensitive() doesn't
propagate across hierarchies, so we could conceivably find a drop site
inside an insensitive widget.

https://bugzilla.gnome.org/show_bug.cgi?id=751793
2015-07-06 18:19:07 +02:00
Carlos Garnacho
0606b525b4 gtkdnd: Plug a leak
We create a cairo_t in order to find out the surface extents, but it
was being leaked, dragging the whole drag surface with it through
extra refs.
2015-06-25 15:09:56 +02:00
Carlos Garnacho
a0e8056848 dnd: Remove emission of fake button release event
Nowadays (and for quite some years now) we rely on GdkEventGrabBroken
events to be received. This fake button event seems a remnant of
the early Gtk 2.x days, and is currently even inconsistent with our
event delivery model, so just remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=749737
2015-06-02 17:27:05 +02:00
Matthias Clasen
2a0d5c39d9 dnd: Fix compiler warnings
Fix warnings due to -Wdeclaration-after-statement and -Wshadow.
2015-06-02 09:08:15 -04:00
Matthias Clasen
3ae953092a Don't force an icon window
We were inadvertently forcing the use of an icon window
in all cases. This patch makes it so that we once again
use a combined cursor when possible.
2015-05-16 23:55:09 -04:00
Matthias Clasen
0a5e216d42 DND: Move private api to a private header 2015-05-16 17:54:01 -04:00
Matthias Clasen
987da43e71 Remove multi-screen handling in DND code
We only have one screen nowadays. No need to carry around
code for handling screen changes.
2015-05-16 17:26:45 -04:00
Carlos Garnacho
cba2ecc0cc gtkdnd: Restore widget opacity after fading out
Otherwise the widget is left fully transparent, and will start as such if
the widget is reused.
2015-03-29 22:57:31 +02:00
Carlos Garnacho
a6cafa1edb gtkdnd: Set the icon helper from the drag site onto the context
If the icon happened to come from the drag site icon helper (ie. set through
gtk_drag_source_set_icon*), it would be referenced on the GtkDragInfo,
but not hooked into its context. This results on non visible drag windows,
until set_icon_helper() happened to be called on some path.
2015-03-29 22:21:19 +02:00
Matthias Clasen
37774928bd dnd: Introduce a helper to manage the weak pointer
Introduce a setter that takes care of updating the weak ref
whenever we assign info->widget. Just a cleanup of the previous patch.
2015-03-22 11:16:29 -04:00
Tom Hughes
e7eaca9534 DND: Clean up weak pointers when they are no longer needed
Failure to do so leads to memory corruption down the road.
This was introduced in commit 650c25e06c.

https://bugzilla.gnome.org/show_bug.cgi?id=746602
2015-03-22 11:16:29 -04:00
Carlos Garnacho
cc780116a2 dnd: Set the parent DnD wayland surface on gtk_drag_set_icon_window()
This is a better place to call this, both lets us remove all other calls,
and additionally handles the gtk_drag_set_icon_widget() entry point.
2015-02-19 20:54:25 +01:00
Matthias Clasen
4f1780c782 Robustness fixes for drag cancel animation
gtk_widget_get_frame_clock() can return NULL. Deal with that
by silently stopping the drag cancel animation in this case.
2015-01-30 10:13:29 -05:00
Matthias Clasen
c160ba0696 dnd: Allow programmatic drag cancellation
Add a gtk_drag_cancel() function that can be used on the
source side to cancel an ongoing drag operation. This can
be useful, e.g. if the data that is being dragged becomes
unavailable.
2015-01-30 09:38:41 -05:00
Matthias Clasen
f2cfe9ed74 dnd: Make dest side safe against destroy
Use a weak pointer to clean up when the current drag destination
gets destroyed.
2015-01-30 00:05:33 -05:00
Matthias Clasen
542c824c71 Trivial doc fixes
Remove two erroneous quotation marks.
2015-01-24 19:25:50 -05:00
Timm Bäder
9668962da1 gtkdnd: Set the dnd window's screen before its visual
This makes dnd icons work for widgets on a !default screen.

https://bugzilla.gnome.org/show_bug.cgi?id=743393
2015-01-24 15:57:46 -05:00
Benjamin Otte
8c534fefca dnd: Draw dnd icon with regular code
Overriding the window background is ugly because the window background
is owned by GTK and can be reset at any time.

https://bugzilla.gnome.org/show_bug.cgi?id=742646
2015-01-20 01:07:13 +01:00