Commit Graph

57 Commits

Author SHA1 Message Date
Matthias Clasen
d7e0af62e3 eventcontroller: Convert docs 2021-03-11 16:37:36 +00:00
Emmanuele Bassi
e8b6e6cad0 docs: Clean up the first paragraph for various symbols
The documentation engine will use the first paragraph as the summary for
a type or constant.
2021-03-11 16:37:30 +00:00
Emmanuele Bassi
69b181f263 Remove boxed type for GtkCrossingData
The GtkCrossingData type is completely private, so there's no point in
having a boxed type for it.
2020-12-15 15:55:15 +00:00
David Lechner
8190f0c420 gtk/enums: fix doc comment references
Enum members need a "%" prefix rather than "@" or "%@" in order to
automatically create links in the documentation.
2020-11-07 17:46:26 +00:00
Matthias Clasen
f561000124 docs: Clean up many dangling links
In many cases, these were references to no longer
existing api, so some rewording was necessary.
2020-08-04 22:11:34 -04:00
Matthias Clasen
66120cff4b eventcontroller: Fix crossing event scopes
We want to deliver crossing events to controllers
with scope same-native as long as at least one of
the targets is on the same native. As a new approach,
treat out-of-scope targets like NULL, and deliver
crossing events as long as one of the targets is
not NULL.
2020-05-29 19:41:39 -04:00
Corentin Noël
076b2f11d2 docs: Fix several missing references in the documentation
This fixes several typos and missing references
2020-05-11 19:26:20 +02:00
Timm Bäder
771b3ea6f3 eventcontroller: Remove some unnecessary casts
Instead of comparing two GtkWidget*s by casting the two GtkNative*s, we
can as well compare two GtkNative*s. Also if gtk_widget_get_native()
returns NULL, the code previously failed.
2020-05-05 08:20:10 +02:00
Matthias Clasen
b4c79bad34 Assorted documentation fixes 2020-04-20 00:38:58 -04:00
Emmanuele Bassi
96cfb12946 Fix annotations for GtkEventController 2020-04-16 19:40:00 +01:00
Matthias Clasen
bd56bc9055 Add gtk_event_controller_get_current_event[_state]
For now these are private, to replace internal uses
of gtk_get_current_event[_state], but we may want to
make them public.
2020-04-11 17:29:27 -04:00
Matthias Clasen
ddd126740e Fix a hard-to-spot typo
The symptom caused by this was scales in
popovers not reacting to dragging.
2020-02-22 13:49:12 -05:00
Matthias Clasen
31bf9da63a Strip const from GdkEvent
Events are refcounted structs, and we generally don't
pass these as const.
2020-02-21 00:51:02 -05:00
Matthias Clasen
cd601ffb9e eventcontroller: Make the target widget available
Make it possible for event controllers to obtain
the target widget during handle_event.
2020-02-21 00:51:02 -05:00
Matthias Clasen
e54e48f6d1 Explicitly pass the target to handle_event
Pass the event propagation target explicitly down to
the event controllers. This is a step towards getting
rid of gdk_event_set_target.
2020-02-21 00:51:02 -05:00
Matthias Clasen
b38869b3aa Stop looking at the related target for filtering
We are now sending crossing events (which are the only ones
where a related target makes sense) via handle_crossing.
2020-02-21 00:51:02 -05:00
Matthias Clasen
d063b6b6cc Reinstate filtering for crossing events
The event propagation limit should apply to crossing events
as well.
2020-02-21 00:51:02 -05:00
Matthias Clasen
e3158a1bfb Make crossing events handled the same way 2020-02-21 00:50:59 -05:00
Matthias Clasen
23c67f8c67 New focus change handling
Instead of relying on gdk's antiquated crossing events,
create a new GtkCrossingData struct that contains the
actual widgets, and a new event controller vfunc that
expects this struct. This also saves us from making sense
of X's crossing modes and details, and makes for a
generally simpler api.

The ::focus-in and ::focus-out signals of GtkEventControllerKey
have been replaced by a single ::focus-change signal that
takes GtkCrossingData as an argument. All callers have
been updated.
2020-02-21 00:47:53 -05:00
Matthias Clasen
dd251d85c4 Pass translated coordinates outside the event
We want to make events readonly, so stop translating
their coordinates and instead pass the translated
coordinates separately, when propagating events.
2020-02-21 00:47:53 -05:00
Matthias Clasen
b398af914f eventcontroller: Fix name property
This never worked. Oops.
2019-12-25 09:47:22 -05:00
Hodong Kim
19b1fcfee3 Fix a typo 2019-06-24 18:42:40 +00:00
Matthias Clasen
955ae40cd6 event controller: Add a name property
This helps identifying controllers in the inspector.
2019-06-20 22:48:33 -04:00
Matthias Clasen
2606ca0bd1 Introduce event controller propagation limits
Limit event handlers by default to only handle
events targeting the same surface as their widget.
2019-05-28 20:25:13 +00:00
Matthias Clasen
299422994a fixup! event controller: Don't deliver events to insensitive widgets 2019-05-02 20:20:20 +00:00
Matthias Clasen
65233726f8 event controller: Don't deliver events to insensitive widgets
This is another way to avoid delivering events
to insensitive widgets.
2019-05-02 15:50:44 -04:00
Benjamin Otte
ba7849960e eventcontroller: Make widget no longer a construct-only property
The new API model is now complete. To set a widget on a controller, it
is now necessary to call gtk_widget_add_controller().
2018-04-26 17:59:42 +02:00
Benjamin Otte
9af03fa602 widget: Expose gtk_widget_add_controller()
.. and gtk_widget_remove_controller().
2018-04-26 17:59:41 +02:00
Benjamin Otte
e01e9ce092 eventcontroller: Add vfuncs to (un)set widget
This is the first step towards refactoring how widgets deal with event
controllers.

In the future, the widget will treat controllers the same way it treats
child widgets:
1. The controllers will be created without a widget.
2. There will be gtk_widget_add/remove_controller() functions to add
   or remove controllers.
3. The widget will hold a reference to all its controllers.

This way we will ultimately be able to automate controllers with ui
files.
2018-04-26 17:59:41 +02:00
Benjamin Otte
325f6121ba eventcontroller: Remove unused evmask member variable 2018-03-07 16:17:15 +01:00
Benjamin Otte
074e7001dc eventcontroller: Get rid of constructed vfunc
Instead, add the controller to the widget in set_property.
2018-03-07 16:17:15 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
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.
2018-02-06 01:16:32 -05:00
Carlos Garnacho
c02d0f3c0a eventcontroller: Drop event_mask API
This is unchecked, we can remove it entirely as well.
2017-09-19 18:39:03 +02:00
Timm Bäder
e2e91bf9bc Fix a few documentation issues 2017-07-19 21:27:15 -04:00
Matthias Clasen
89ca0db7c5 event controller: Convert to g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
2015-09-06 17:11:36 -04:00
Carlos Garnacho
3808322f80 eventcontroller: Add private ::filter method
This will be used right before handle_event() in order to filter
out events, useful to make the previous "no touchpad events" behavior
the default, and have gesture subclasses include manually the touchpad
events they handle.
2015-08-12 23:20:25 +02:00
Matthias Clasen
3b45be94e8 Gestures: Properly handle weak references
Every call to g_object_add_weak_pointer must be matched with
a g_object_remove_weak_pointer call, or we will get invalid
writes inside GObject.

https://bugzilla.gnome.org/show_bug.cgi?id=746013
2015-03-11 06:47:04 -04:00
Matthias Clasen
3569d373a2 Fix 7c4bf742e8
The objects-finalize test constructs gestures with NULL as
a widget. The recent addition of weak references was not
ready for that.
2015-03-02 20:18:15 -05:00
Debarshi Ray
0910eaf6fe eventcontroller: Chain up on constructed
https://bugzilla.gnome.org/show_bug.cgi?id=745225
2015-03-02 11:53:56 +01:00
Debarshi Ray
7c4bf742e8 eventcontroller, widget: Don't crash if destroyed before the other
There are two scenarios. A widget sub-class owns a GtkEventController
and passes itself to it, or a controller owned by something else is
passed a widget.

In the second case, if the widget is destroyed before the controller,
we will have a crash when destructing the controller because we will
be accessing invalid memory. Adding a weak reference on the widget
addresses that problem.

This leads to a crash in the first case. When the widget is getting
destroyed, it will drop the reference to its own controller. The
controller will skip touching the widget because the weak reference
would have turned it to NULL. However, when the widget sub-class chains
up to GtkWidget it will try to free all the controllers in its list.
Unfortunately, all these controllers have already been destroyed. So
we need to guard against this too.

https://bugzilla.gnome.org/show_bug.cgi?id=745225
2015-03-02 11:53:52 +01:00
Carlos Garnacho
7daa2a1eba event-controller: Chain up on dispose 2015-01-14 16:03:10 +01:00
Carlos Garnacho
a050b017ed eventcontroller: Default to GTK_PHASE_BUBBLE
This is in practice the most common value, so make that the default

https://bugzilla.gnome.org/show_bug.cgi?id=734285
2014-08-15 13:49:39 +02:00
Matthias Clasen
110f859899 GtkEventController: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:31:02 -04:00
Carlos Garnacho
618e3d3157 eventcontroller: Ensure controllers stay alive during event emission
Those might trigger the destruction of some widget that would dispose the
event controller while the event is still being handled, so keep an extra
ref on the controller during event processing.
2014-05-28 19:39:07 +02:00
Matthias Clasen
3bb404f40c Don't assert in gtk_event_controller_constructed
This prevents some of our generic object implementation tests
from working with gesture objects. Instead, add g_return_if_fail
checks in all the gesture constructors.
2014-05-27 14:33:32 -04:00
Carlos Garnacho
49a6626884 eventcontroller: Hide more details
Signals are left hidden, so the only entry point to handle_event/reset
is API.
2014-05-27 17:47:12 +02: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
2e903243c6 eventcontroller: Make the event-mask property and methods private.
This will rarely have any use if no subclassing is allowed, so just make it
private for our own.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
03a3b2ccab eventcontroller: introspection fix
Set transfer annotation on gtk_event_controller_get_widget()
2014-05-23 19:54:33 +02:00
Matthias Clasen
0442431943 Docs: Cosmetic fixes 2014-05-23 19:54:33 +02:00