Commit Graph

715 Commits

Author SHA1 Message Date
Emmanuele Bassi
d46e1288a4 Copy axes when rewriting events 2020-04-17 22:23:32 +01:00
Timm Bäder
ca47e96d35 widget: Return an array from list_devices
To forther reduce the GList usage in the code base.
2020-04-17 15:21:00 +02:00
Timm Bäder
7bc4daae2f main: Stop using GList when propagating events
There are still some cases missing.
2020-04-17 15:21:00 +02:00
Emmanuele Bassi
f28aa1ba02 Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.

The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.

The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 19:54:02 +01:00
Matthias Clasen
8e9406a082 Move key event rewriting
Stop rewriting key and focus events on the GDK side.
Instead deliver them as they are, and propagate them
from the root on the gtk side, in gtkmain.c. And
stop complaining about focus events on popups - we
can just ignore them if we have no use for them.
2020-04-15 14:56:32 -04:00
Matthias Clasen
feee281cf8 Drop gtk_get_current_ apis
We have event controller apis to replace these.
There is one remaining use of gtk_get_current_event_time
in gtkwindow.c, so we can't drop the implementation yet.

Add a section in the migration guide for this.
2020-04-11 17:29:27 -04:00
Emmanuele Bassi
d701a89281 Turn GskRenderNode into a derivable type
Language bindings—especially ones based on introspection—cannot deal
with custom type hiearchies. Luckily for us, GType has a derivable type
with low overhead: GTypeInstance.

By turning GskRenderNode into a GTypeInstance, and creating derived
types for each class of node, we can provide an introspectable API to
our non-C API consumers, with no functional change to the C API itself.
2020-04-08 15:40:15 +01:00
Matthias Clasen
fcd36e59b1 Fix crossing event generation
We were not properly setting the new_descendent field
in Crossing structs for GTK_CROSSING_OUT events. This
was causing extraneous ::leave signals to be emitted,
and make model buttons in popover menus flicker when
hovered.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2536
2020-04-02 00:39:46 -04:00
Carlos Garnacho
fa7f6ad910 gtkmain: Do not try to coalesce/ignore crossing events
Under grabbing circumstances we used to get several crossing events,
some corresponding to the grab itself and some corresponding to
pointer motion.

The backends now do a better job at keeping those simple, which
means we sit listening for events that don't actually arrive. This
triggers pointer focus issues when dragging windows or opening
grabbing popups.

Actually obey those events, they will be the only ones we get now.
2020-04-01 00:40:17 +02:00
Benjamin Otte
bb4fbe3d8f accels: Remove GtkAccelGroup 2020-03-25 23:14:44 -04:00
Emmanuele Bassi
bca1f6b64f gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2020-03-25 23:14:27 -04:00
Carlos Garnacho
0f73e83f44 gtkwindow: Remove internal popover API
This was only used by text handles, and not anymore.
2020-03-20 15:52:19 +01:00
Matthias Clasen
31db615885 Revert "Merge branch 'disable-window-test' into 'master'"
This reverts commit 3ac4c76b18, reversing
changes made to 6ec96d2e98.
2020-03-19 18:03:16 -04:00
Benjamin Otte
ff6df33b6a accels: Remove GtkAccelGroup 2020-03-18 23:00:51 -04:00
Emmanuele Bassi
b28da74e90 gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2020-03-18 23:00:51 -04:00
Benjamin Otte
a411959c91 droptarget: Redo
This is a huge reorganization of GtkDropTarget. I did not know how to
split this up, so it's unfortunately all one commit.

Highlights:

- Split GtkDropTarget into GtkDropTarget and GtkDropTargetAsync
  GtkDropTarget is the simple one that only works with GTypes and offers
  a synchronous interface.
  GtkDropTargetAsync retains the full old functionality and allows
  handling mime types.

- Drop events are handled differently
  Instead of picking a single drop target and sending all DND events to
  it, every event is sent to every drop target. The first one to handle
  the event gets to call gdk_drop_status(), further handlers do not
  interact with the GdkDrop.
  Of course, for the ultimate GDK_DROP_STARTING event, only the first
  one to accept the drop gets to handle it.
  This allows stacking DND event controllers that aren't necessarily
  interested in handling the event or that might decide later to drop
  it.

- Port all widgets to either of those
  Both have a somewhat changed API due to the new event handling.
  For the ones who should use the sync version, lots of cleanup was
  involved to operate on a sync API.
2020-03-02 03:18:55 +01:00
Matthias Clasen
57c8a643ff Drop gtk_grab_get_current
Another grab-related api that we are not using.
2020-02-28 16:29:56 -05:00
Matthias Clasen
0ffb35c9e7 Drop device grabs
We were not using this api at all, so lets drop it.
2020-02-28 16:27:42 -05:00
Benjamin Otte
a12e563cd2 main: Don't synthesize crossing events when nothing changed
This was especially bad because it was confusing the event controllers
so much, they'd emit leave + enter events every time the mouse moved.
2020-02-22 07:33:40 +01:00
Benjamin Otte
fc43ec0bbc gtk: Bubble drag events like motion events
Emit crossing events - with a new GTK_CROSSING_DROP type - like we do
for motion events. There is no more special casing for them.

Note that the gesture has not been updated yet, so some obscure behavior
may occur.
2020-02-22 07:33:40 +01:00
Benjamin Otte
808961564c gdk: Make DRAG_ENTER event take x/y coordinates
Make it mirror the behavior of ENTER/LEAVE events.
2020-02-21 18:19:16 +01:00
Matthias Clasen
e062137b2c motion controller: Match focus event propagation
Make the crossing event generation for pointer events
match what we do for focus now.
2020-02-21 00:51:03 -05:00
Matthias Clasen
b1eaa502df events: reorganize getters
Restructure the getters for event fields to
be more targeted at particular event types.

Update all callers, and replace all direct
event struct access with getters.

As a side-effect, this drops some unused getters.
2020-02-21 00:51:03 -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
e5223b1cee main: Stop calling gdk_event_set_target
GTK is no longer relying on this.
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
e3158a1bfb Make crossing events handled the same way 2020-02-21 00:50:59 -05:00
Matthias Clasen
64b9c6aaaa main: Drop gtk_get_event_target
This is no longer used.
2020-02-21 00:47:53 -05:00
Matthias Clasen
cd2b58574d Drop GDK_NOTHING
Events of type GDK_NOTHING are good for nothing.
2020-02-21 00:47:53 -05:00
Matthias Clasen
c343031a0e Stop using g_object_ref/unref on events
Use gdk_event_ref/unref instead of g_object_ref/unref.
Events will stop being object soon.
2020-02-21 00:47:53 -05:00
Matthias Clasen
9a1497f582 events: Drop GDK_DESTROY
No backend is emitting GDK_DESTROY events anymore, so no
need to carry this around.
2020-02-21 00:40:52 -05:00
Matthias Clasen
7db8be93f4 gtk: Stop handling GDK_DESTROY differently from GDK_DELETE
We don't have child windows anymore, so there is no difference.
2020-02-21 00:40:52 -05:00
Matthias Clasen
495de0b78b main: Use constructors instead of gdk_event_copy + rewriting 2020-02-21 00:40:52 -05:00
Matthias Clasen
a5f58e8d28 main: Use event constructors
At the same time, stop setting child_surface in
crossing events. Nothing in GTK looks at it.
2020-02-21 00:40:52 -05:00
Benjamin Otte
732716ba95 debug: When debug-printing, treat NULL as the default display
Otherwise we lose debug prints from all code that allows NULL displays.
2020-02-19 01:21:33 +01:00
Benjamin Otte
a278edab22 window: Remove type argument from gtk_window_new() 2020-02-14 21:18:49 +01:00
Matthias Clasen
59b935af38 Merge branch 'mainloop-cleanup' into 'master'
Mainloop cleanup

See merge request GNOME/gtk!1404
2020-02-10 14:32:09 +00:00
Matthias Clasen
9309153abc Remove GTK_DEBUG=baselines
This has been reimplemented differently
in the inspector.
2020-02-10 00:10:43 -05:00
Matthias Clasen
a8db322be6 Drop gtk_get_main_thread
This is not a very useful api, and if you need it,
you can just as easily keep track yourself which thread
called gtk_init().
2020-02-09 23:13:13 -05:00
Matthias Clasen
4dd780a96b Drop gtk_main and gtk_main_quit
The alternatives are to use GtkApplication,
or use GMainContext.
2020-02-09 23:13:13 -05:00
Matthias Clasen
4c22939dea docs: Update an example
Don't use gtk_main() in the mainloop example.
It is going away.
2020-02-09 23:12:32 -05:00
Matthias Clasen
7eb889c7aa Drop gtk_main_level
This api isn't useful without gtk_main, which is also
on the way out.
2020-02-09 23:12:32 -05:00
Matthias Clasen
49a6ad3dd1 Drop gtk_main_iteration
This function and its cousin, gtk_main_iteration_do, are
thin wrappers around GMainContext api that should just
be used directly.
2020-02-09 23:12:32 -05:00
Matthias Clasen
ebc720bfdb Drop gtk_events_pending
This was just a thin wrapper around gtk_main_context_pending,
which should be used directly instead.
2020-02-09 23:11:49 -05:00
Matthias Clasen
057f41532b Remove gtk_main_do_event from the docs 2020-02-09 10:55:37 -05:00
Matthias Clasen
c1970009ff docs: Remove more mentions of gtk_main_do_event 2020-02-09 10:45:33 -05:00
Carlos Garnacho
e67f0bfcfd gtkmain: Wait for GDK_CROSSING_UNGRAB leave event with implicit grabs
If there is a passive grab and the pointer leaves the window we would
receive a GDK_CROSSING_NORMAL event when the pointer moves outside
the window, and a GDK_CROSSING_UNGRAB event when we do release the
button and the implicit grab.

We currently would react to the first, but want to react to the
second. In the time between both events, the client would still receive
pointer motion that will reach the implicitly grabbed widget.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/13
2020-02-07 01:02:47 +01:00
Matthias Clasen
f5daecf353 Merge branch 'dnd-gestures-2' into 'master'
Add new dnd api

See merge request GNOME/gtk!1278
2020-01-11 06:09:58 +00:00
Christian Hergert
2f3518c80d gtkmain: be deterministic in source removal
Fixes gtk_main_sync() to only remove a source if it has not
already executed (and been removed). The previous code was
using gtk_main_quit() directly which would be non-determinstic
based on the previous value in the return register.
2020-01-10 15:04:44 -08:00
Christian Hergert
4a7f68e79e gtkmain: short-circuit gtk_main_sync() where no display
If there is no display, we will hit the slow path here which
can introduce long latencies in unit tests. This checks for
a NULL list of displays and simply short-circuits.
2020-01-10 15:00:10 -08:00