Commit Graph

376 Commits

Author SHA1 Message Date
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
Maks Naumov
9f51d8948f Fix save_hot_y init in gtk_drag_get_icon()
Signed-off-by: Maks Naumov <maksqwe1@ukr.net>

https://bugzilla.gnome.org/show_bug.cgi?id=742786
2015-01-17 16:24:45 -05:00
Javier Jardón
710f332082 configure.ac: Depend on cairo 1.14.0
This is needed for cairo_set_device_scale()
2014-11-10 15:12:17 +00:00
Matthias Clasen
e3ef5d6fd2 GtkTooltip: Move nonexported API to a private header
This is our standard practice nowadays.
2014-10-19 22:51:21 -04:00
Matthias Clasen
6064fc343e Drop unused code
Not worth keeping this around.
2014-09-12 22:31:25 -04:00
Matthias Clasen
76b1361902 Drop two pointless lines
These return statements weren't making any difference.
2014-09-12 22:31:10 -04:00
Matthias Clasen
45369d506b GtkDnd: Move X11-specific code out of generic code path
There was some X11-specific code before an early exit
in the functions that grab and ungrab keys during DND.
It seems to not cause a problem under Wayland, but moving
it out of the way seems right anyway.
2014-09-12 22:31:04 -04:00
Matthias Clasen
fcb69e110b Remove an unneeded include 2014-09-06 19:03:06 -04:00
Carlos Garnacho
6f538950d4 dnd: Make the drag gesture obey the button mask specified
This was forgotten when making DnD use a GtkGesture in the handlers
attached to the widget in gtk_drag_source_set(). The gesture must obey
the specified button mask, and switch to denied state if the pressed
button isn't part of the given mask.

https://bugzilla.gnome.org/show_bug.cgi?id=735965
2014-09-04 14:59:08 +02:00
Carlos Garnacho
14b4e4d35a gtkdnd: Hardcode the DnD window onto the drag widget window on Wayland
This makes the drag widget use the same window surface that was passed
when starting the drag operation.

https://bugzilla.gnome.org/show_bug.cgi?id=697855
2014-09-01 19:50:12 +02:00
Matthias Clasen
7bec0939a8 Clean up and unify docs and formatting 2014-08-16 21:40:39 -04:00
Carlos Garnacho
8ca205af5d dnd: Set explicitly GtkGestureSingle::button to 0 on the drag gesture
This gesture handles drags done with any button, so unset the current button=1
default.

https://bugzilla.gnome.org/show_bug.cgi?id=734285
2014-08-15 13:53:39 +02:00
Carlos Garnacho
dd9166c435 dnd: Set drag gesture propagation phase to GTK_PHASE_NONE explicitly
This used to rely on the default phase value.

https://bugzilla.gnome.org/show_bug.cgi?id=734285
2014-08-15 13:49:39 +02:00
Matthias Clasen
cfec3ba794 Document that the drag icon window will be modified
This is in response to the complaint in
https://bugzilla.gnome.org/show_bug.cgi?id=732991
2014-07-11 18:09:47 -04:00
Carlos Garnacho
d05a9f9a7b gesture: Replace gtk_gesture_attach/detach with event controller API
Event controllers now auto-attach, and the GtkCapturePhase only determines
when are events dispatched, but all controllers are managed by the widget wrt
grabs.

All callers have been updated.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
994c94c25b dnd: Check on the right gesture sequence when starting the drag op 2014-05-23 19:54:29 +02:00
Carlos Garnacho
5369c77029 gesture: Simplify gesture/widget interaction public API
The propagation phase property/methods in GtkEventController are gone,
This is now set directly on the GtkWidget add/remove controller API,
which has been made private.

The only public bit now are the new functions gtk_gesture_attach() and
gtk_gesture_detach() that will use the private API underneath.

All callers have been updated.
2014-05-23 19:54:29 +02:00
Carlos Garnacho
040c82f0e8 dnd: Update to gesture widget-level API changes 2014-05-23 19:54:25 +02:00
Carlos Garnacho
b0eef458d1 dnd: Use GtkGestureDrag to initiate DnD
This gesture is used by gtk_drag_source_set() to determine
whether dragging moved past the threshold. The gesture events
are handled via the usual ::event callbacks, so we don't mess
up with callers expecting that to happen in a signal handler.

If the sequence gets claimed somewhere else in the event widget
stack, the DnD gesture will be cancelled.
2014-05-23 19:54:24 +02:00
Matthias Clasen
aab1610d40 DND: go back to a timeout for cancel animation
Using a tick callback does not really make sense here, since we
are not drawing in a window, but moving a toplevel around.
https://bugzilla.gnome.org/show_bug.cgi?id=728183
2014-04-22 23:45:59 -04:00
Jason Ekstrand
f02663532d Get rid of a stray character 2014-04-22 22:28:34 -04:00
Matthias Clasen
6193b9b640 csd: Fix drag hightlight drawing
When making the entire window a drop target, as file-roller does,
we don't want to draw the drag highlight around the CSD window
decorations.
https://bugzilla.gnome.org/show_bug.cgi?id=728526
 Please enter the commit message for your changes. Lines starting
2014-04-22 21:19:21 -04:00
Bastien Nocera
f71f7215ab all: Name more idles and timeouts
Following up from 438cd857c4,
name more timeouts and idles.

The original grep was missing checking for gdk_threads_add_*()
functions (at least for some of the files).

https://bugzilla.gnome.org/show_bug.cgi?id=726870
2014-03-26 20:09:30 -04:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
Matthias Clasen
7f6a964c47 Docs: Remove all entities and turn off sgml mode
With all element markup gone, it is time to turn off
sgml mode, and get rid of entities as well.
2014-02-09 17:58:07 -05:00
William Jon McCann
fa3f1e1488 docs: use apostrophe in *'ve 2014-02-07 13:38:26 -05:00
William Jon McCann
e34bd4137d docs: use apostrophes in *n't 2014-02-07 13:32:47 -05:00
William Jon McCann
7a208fbbf3 docs: use proper apostrophe
https://wiki.gnome.org/Design/OS/Typography
2014-02-07 13:06:10 -05:00
William Jon McCann
0ce016650b docs: Use markup for links 2014-02-07 09:42:12 -05:00
William Jon McCann
2a45418b67 docs: use proper quotes 2014-02-05 15:08:42 -05:00
William Jon McCann
4c8bd8e7cf docs: Identify examples that are C code
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00
Matthias Clasen
e1d9974537 Drop internal uses of gtk_widget_get_root_window
This function is just a one-line convenience function that
is about to be deprecated.
2014-01-24 20:16:33 -05:00
William Jon McCann
93138e96c1 docs: don't reference nonexisting type in docs 2014-01-21 23:20:38 -05:00
William Jon McCann
7eb8577e3e docs: fix selections documentation link 2014-01-21 18:57:40 -05:00
Matthias Clasen
8d3a91d6ba docs: Add a missing Since: tag 2013-12-05 09:08:35 -05:00
Bastien Nocera
438cd857c4 all: Add names to timeouts
Add names to every timeout we setup, so it's easier to track their
usage, and debug possible misbehaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=710651
2013-10-23 13:31:18 +02:00
Jasper St. Pierre
030b62d122 gtkdnd: Introduce a new API for more accurate drag origin data
When trying to drag, we currently the position of the first motion
event to determine where the drag came from. This might be alright
in the case of the old animation, but the data will be inaccurate
if the user has moved the pointer quite a bit since pressing the
cursor to start dragging. While we could monkey patch the GdkEvent
at the widget layer, this is unintuitive and strange.

Add a new API that takes a set of pointer coordinates describing
the origin of the drag. Additionally, adapt most widgets to use
it and use it with correct coordinates.

https://bugzilla.gnome.org/show_bug.cgi?id=705605
2013-08-14 07:12:52 -04:00
Jasper St. Pierre
e80d1f0523 gtkdnd: Use a more modern spring back animation for cancelled drags
https://bugzilla.gnome.org/show_bug.cgi?id=705605
2013-08-14 07:12:52 -04:00
Christian Hergert
a0bc600140 dnd: Motif DnD is no longer supported, update docs. 2013-08-08 16:06:00 +02:00
Jasper St. Pierre
b9d85b9412 gtkdnd: Clean up the doc comment of gtk_drag_begin 2013-08-07 11:53:04 -04:00
Alexander Larsson
8e423ba292 gtkdnd: Use surface based cursor APIs
This allows things to correctly scale things on HiDPI screens.
2013-08-07 13:34:10 +02:00
Alexander Larsson
0296f1a43a gtkdnd: Use RGBA windows when dragging if possible
If we have rgba visuals and a composited screen we should
just use a RGBA window rather than shaped windows.
2013-08-05 16:49:18 +02:00
Matthias Clasen
2f1fa7cdc3 Drop some unnecessary includes
Drop includes of deprecated headers where they are
no longer needed.
2013-07-19 22:32:23 -04:00
Matthias Clasen
0aa57d26b5 Move wholly deprecated classes to gtk/deprecated/
We've recently a number of classes wholly. For these cases,
move the headers and sources to gtk/deprecated/ and adjust
Makefiles and includes accordingly.

Affected classes:
GtkAction
GtkActionGroup
GtkActivatable
GtkIconFactory
GtkImageMenuItem
GtkRadioAction
GtkRecentAction
GtkStock
GtkToggleAction
GtkUIManager
2013-07-19 21:39:47 -04:00
William Jon McCann
424e1d0059 Start deprecating some GtkStock API 2013-06-25 19:05:32 -04:00
William Jon McCann
02c793f24a Start migrating internals away from GtkStock 2013-06-24 22:20:49 -04:00
ammonkey
4445dce697 fix mem leak in gtk_drag_set_icon_surface, destroy pattern
https://bugzilla.gnome.org/show_bug.cgi?id=681446
2013-04-13 20:06:43 -04:00
Matthias Clasen
329f7af159 Fix DND
The removal of the Motif DND code accidentally changed the
value of the TARGET_DELETE enumeration value, breaking DND
pretty badly.
2013-03-21 00:00:19 -04:00
Matthias Clasen
0cc688aa92 Drop the Motif DND protocol
The implementation is not working and unused, since XDND is the
de-facto standard under X nowadays.

https://bugzilla.gnome.org/show_bug.cgi?id=695476
2013-03-12 20:03:19 -04:00
Matthias Clasen
02e9152738 Fix DND with frame sync
Mutter magically ignores override-redirect windows with geometry
-100-100+1+1, and this breaks the frame synchronization between
gtk+ and mutter. For now, we avoid the issue by simply giving
the window a different geometry.
https://bugzilla.gnome.org/show_bug.cgi?id=694217
2013-02-28 07:48:06 -05:00
Matthias Clasen
2661403f88 Fix DND keyboard control with XI2
We are using XI2 to grab the key events, but we did not do the
necessary extra work to make GDK deliver root window events to us.

https://bugzilla.gnome.org/show_bug.cgi?id=681006
2012-08-06 22:56:59 -04:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Carlos Garcia Campos
6e9b06028c gtkdnd: Use symbolic names for button numbers 2012-01-27 09:47:43 +01:00
Alexander Larsson
6afeb8d355 Move fallback dnd cursors to resources 2012-01-16 14:19:19 +01:00
Javier Jardón
d005b01319 gtk/*: Use g_list_free_full() convenience function 2012-01-05 04:22:43 +01:00
Cosimo Cecchi
adbfbb7278 dnd: port to GtkIconHelper 2011-11-30 16:39:59 -05:00
Bastien Nocera
0888e6f485 gtk: Fix XIGrabKeycode usage
A modifier of "0" is still a modifier and must be submitted normally.
A num_modifiers of 0 is essentially a noop in the server.

As mentioned by Peter Hutterer <peter.hutterer@who-t.net>

https://bugzilla.gnome.org/show_bug.cgi?id=662839
2011-10-28 12:03:22 +01:00
Matthias Clasen
633918158b DND: Work better with XI2
It turns out that simply using XIGrabKeycode instead of XGrabKey
makes the DND keyboard support mostly work (there seem to be some
minor issues with modifiers). This means we no longer grab the
keyboard actively during DND, which in turn makes Alt-Tab and
other window manager shortcuts work again during DND.

At the same time, bring the DND key handling code into the
multi-backend work, by checking for X11 and XI2 at runtime,
in addition to compile time.
2011-10-20 20:59:50 -04:00
John (J5) Palmieri
9c4892f291 [gi] add more annotations to force drag and drop api to be methods 2011-06-29 14:54:25 -04:00
John (J5) Palmieri
f46f038abd [gi] make sure gtk_drag_dest_unset is annotated as a method 2011-06-29 12:11:36 -04:00
Daniel Drake
794a3706cd gtkdnd: Don't bind/unbind keycodes that couldn't be determined
At http://dev.laptop.org/ticket/10643 we are seeing that drag-and-drop
within the Sugar shell causes all of Sugar's custom keybindings to be
removed.

This is because gtkdnd tries to unbind XK_KP_Space, which (on my systems)
is resolved to NoSymbol by XKeycodeToKeysym(). NoSymbol has value 0,
the same as AnyKey, and XUngrabKey(AnyKey) is equivalent to unbinding
all possible keycodes.

Fix this by catching NoSymbol before binding/unbinding.

https://bugzilla.gnome.org/show_bug.cgi?id=652402
2011-06-12 21:44:00 -04:00
Colin Walters
b90e8cfc36 gtkdnd: Add API that takes GIcon
This will be useful for me to port gnome-panel to gnome-menus 4, which
uses GAppInfo, which in turn returns icon references as GIcon.

https://bugzilla.gnome.org/show_bug.cgi?id=649295
2011-05-03 12:53:46 -04:00
Javier Jardón
f7b7e8a6b8 Move documentation to inline comments: GtkDnd 2011-04-18 02:08:37 +01:00
Benjamin Otte
8a16876fc7 dnd: Use G_N_ELEMENTS()
Now that we have wesome macros in glib 2.0, we can use them. Woohoo, GTK
2.0 will be so awesome in the future.
(Did anybody touch dnd code this millenium?)
2011-03-26 23:48:42 +01:00
Benjamin Otte
ac6c6b03d9 gtk: Fix warnings for dnd code without XInput 2011-02-11 23:53:48 +01:00
Michael Natterer
1865011b7f gtk: don't send BUTTON_RELEASE to unrealized widgets
which happened when the source widget was hidden or destroyed while a
drag was going on, like when dragging from a popup that got a grab
broken as result of the dnd operation.
2011-02-11 10:48:43 +01:00
Johan Dahlin
358a2b8675 Rename time to time_ to avoid a scanner warning 2011-02-08 13:29:57 -02:00
Benjamin Otte
1483145806 API: image: Move private struct definitions into private header
They weren't privatized because the dnd code used them, too. But a
private header can allow the dnd code to be nasty, so go dnd code!
2011-02-08 08:58:49 +01:00
Laszlo Pandy
295c2fe8d1 [GI] Add method annotations to remaining gtk_drag_* functions.
https://bugzilla.gnome.org/show_bug.cgi?id=639945
2011-02-03 15:10:43 +01:00
Martin Pitt
1bd36ce723 [GI] Annotate gtk_drag_{dest,source}* as methods
As these do not start with gtk_widget_*, the GI scanner does not recognize them
as methods. With the recently added (method) annotation [1] it is now possible
to mark them as proper methods of GtkWidget.

https://bugzilla.gnome.org/show_bug.cgi?id=639945

[1] http://git.gnome.org/browse/gobject-introspection/commit/?id=09bca85dd4
2011-02-02 17:51:48 +01:00
Pavel Holejsovsky
2f0d40335b [GI] Add missing (transfer) annotations 2011-01-20 13:57:18 +01:00
Carlos Garnacho
96d8f85dcc Make DnD code use GtkStyleContext for the highlight rectangle. 2011-01-04 03:06:20 +01:00
Benjamin Otte
0c285341a9 API: gdk: gdk_display_get_device_state() => gdk_device_get_position()
The API was not display-specific, but belonged to the device. Also, we
didn't find a user of the modifier mask, so we dropped it.
2010-12-27 18:46:41 +01:00
Matthias Clasen
d77dcfb9b2 Better fix for keynav dnd
With proper rounding, we can go back to a 'small step' of 1.
2010-12-22 22:33:40 -05:00
Matthias Clasen
7e0a30b752 Abort a drag when a keynav drop has not destination
This was claimed to cause problems for Chromium, see bug 599130.

Also work around apparent rounding errors in XIWarpDevice by
setting the 'small step' for keynav dnd to 2 instead of 1 - I notice
that a warp seems to sometimes warp a little less than I tell it to,
and if I tell it to only move by 1 pixel then moving less means
that you are stuck.
2010-12-22 21:47:14 -05:00
Benjamin Otte
66f7c3a562 API: gdk: gdk_display_warp_device() => gdk_device_warp()
warping devices has nothing to do with displays, so putting it there
seems weird.
2010-12-21 12:07:06 -05:00
Benjamin Otte
8f1f743903 gtk: Use g_object_unref instead of gdk_cursor_unref 2010-12-21 12:07:05 -05:00