Commit Graph

42 Commits

Author SHA1 Message Date
Matthias Clasen
e499a09759 Drop gtkintl.h
Include gtkprivate.h for I_() and glib-i18n.h for
gettext macros.
2022-09-24 10:03:37 -04:00
Bilal Elmoussaoui
3b383569a4 g-i: Add nullable annotations to EventControllerKey::im-context
Fixes https://github.com/gtk-rs/gtk4-rs/issues/874
2022-02-11 12:59:55 +01:00
Matthias Clasen
91f7b9663f gtk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
094d5d5260 eventcontrollerkey: Convert docs 2021-03-11 16:37:36 +00:00
Matthias Clasen
643d873f47 eventcontrollerkey: Update im focus when active window changes
Use the new GTK_CROSSING_ACTIVE crossing events to update
the im context focus when the window becomes active or
inactive. IBus requires this, since it has only a single,
global focus location.

Fixes: #2390
2020-07-30 13:23:45 -04:00
Matthias Clasen
2ff3e3d1e4 gtk: Improve struct packing in places
Plug some holes in our structs by rearranging
a few fields. This is was done looking at
pahole output.
2020-07-25 11:57:37 -04:00
Matthias Clasen
0a96a483c6 gdk: Redo key events
Add all of the keyboard translation results in the key event,
so we can translate the keyboard state at the time the event
is created, and avoid doing state translation at match time.

We actually need to carry two sets of translation results,
since we ignore CapsLock when matching accelerators, in
gdk_event_matches().

At the same time, drop the scancode field - it is only ever
set on win32, and is basically unused in GTK.

Update all callers.
2020-04-06 15:13:54 -04:00
Emmanuele Bassi
f02521c502 Remove bindings activation from GtkEventControllerKey
We're going to use shortcuts soon.
2020-03-25 22:36:03 -04: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
Emmanuele Bassi
5033fc62f2 Remove bindings activation from GtkEventControllerKey
We're going to use shortcuts soon.
2020-03-18 23:00:50 -04:00
Matthias Clasen
8823882f97 gtk: Stop using GdkEventKey
We should just use GdkEvent, instead of taking
a GdkEventKey, and then cast it everywhere.
2020-02-21 00:51:03 -05:00
Matthias Clasen
0c96b2d8f7 Bring back im context focus-in/out
The key controller still needs to track focus,
in order to emit these signals when required.
2020-02-21 00:51:03 -05:00
Matthias Clasen
5a2f829a40 Split off GtkEventControllerFocus
Split the focus tracking into a separate
GtkEventControllerFocus, and change the API one more time.
We are back to having ::focus-in and ::focus-out signals.

Update all users.
2020-02-21 00:51:03 -05:00
Matthias Clasen
89c3a7ab24 wip: Add more information to crossing events
Add fields for direct descendents to GtkCrossingData,
and populate them when emitting focus change events.

Also add accessors for these fields to GtkEventControllerKey,
and verify that they are set properly in the focus test.

Not done yet: Do the same for pointer crossing events.
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
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
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
Takao Fujiwara
5be14577d6 imwayland: Connect gtk_im_context_focus_in/out to GtkEventControllerKey
GtkEventControllerKey can handle GDK_FOCUS_CHANGE and call
gtk_im_context_focus_in/out directly.

https://gitlab.gnome.org/GNOME/gtk/issues/2390
2020-01-28 23:47:16 +09:00
Benjamin Otte
a3cfb42888 eventcontrollerkey: Change behavior of contains-focus
contains-focus now returns TRUE when is-focus is TRUE instead of FALSE.

Fixes #2184
2019-10-07 04:49:50 +02:00
Benjamin Otte
578dc9e70b eventcontrollerkey: Add getters for the properties
...and use them.
2019-10-07 04:49:50 +02:00
Christian Hergert
41e373f10c gtk: fix all uses of g_cclosure_marshal_generic
This adds specific marshallers for all of the locations where a generic
marshaller is being used. It also provides va_marshallers to reduce the
chances that we get stack traces from perf going through ffi_call_unix64.

This is forward ported from gtk-3-24.

# Conflicts:
#	gtk/gtkeventcontrollerkey.c
#	gtk/gtkeventcontrollermotion.c
#	gtk/gtkgesture.c
#	gtk/gtkgesturemultipress.c
2019-06-02 14:24:51 -07:00
Matthias Clasen
91d6893f02 key controller: Don't eat modifier events
The key controller was consuming key events
for modifier keys, for no entirely convincing
reason, which leads to problems when somebody
actually listens for those, such as the simple
input method does for C-S-u processing.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1884
2019-05-13 17:01:51 +00:00
Matthias Clasen
da7cd6ae25 Trigger bindings when forwarding key events
This broke backspace handling in entries when an entry
completion is present.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1793
2019-03-31 14:04:35 -04:00
Matthias Clasen
93905a8513 key controller: Enforce limitations of key forwarding
We now set current_event for focus-change as well,
so make sure to check the event type.
2019-03-16 21:24:45 -04:00
Matthias Clasen
4f06b669c5 key controller: Improve the docs
Mention the limitations of the key forwarding api.
2019-03-16 21:24:45 -04:00
Matthias Clasen
f3ed3e99c3 key controller: Add getters for focus event targets
This information can be needed in signal handlers,
so make it available.
2019-03-16 21:24:45 -04:00
Matthias Clasen
4f5a8207bc key controller: Add focus properties
Add boolean properties, is-focus and contains-focus, that
track whether the focus is in the widget itself or in
one of its descendants.
2019-03-16 21:24:45 -04:00
Matthias Clasen
2f1194c0c1 key controller: Fix a copy/paste error
Prefix the finalize function properly.
2019-03-16 21:24:45 -04:00
Matthias Clasen
921eccb459 Pass mode and detail to focus-in/out signals
This information is useful when maintaining a
'last focus' field.

Update all users.
2019-03-16 21:24:45 -04:00
Carlos Garnacho
19bf937401 eventcontrollerkey: Use run_controllers() API to forward key events
All 3 phases are run ATM, but just on the specific widget.
2019-02-20 13:16:07 +01:00
Daniel Boles
a350192ea2 EventControllerKey: Add missing documentation bits 2018-12-14 23:28:54 +00:00
Ernestas Kulik
fd69f1cd79 eventcontrollerkey: Document key-pressed and key-released
None of the GtkEventControllerKey signals are documented; this commit
adds documentation for a couple of them.
2018-07-02 12:18:26 +03:00
Matthias Clasen
36396093e6 docs: Document GtkEventControllerKey
The long description was missing.
2018-06-26 12:20:47 -04:00
Matthias Clasen
8755d884f3 Remove a lot of Since annotations
4.0 will represent a clean epoch. We don't want to have
lots of noise in the docs about 2.x or 3.x.
2018-06-25 19:55:04 -04:00
Carlos Garnacho
15e00759c7 eventcontrollerkey: Port to new API model 2018-04-26 17:59:42 +02:00
Carlos Garnacho
3361fe1e62 gtkeventcontrollerkey: Add ::focus-in/out signals
And handle GDK_FOCUS_CHANGE events in order to emit those.
2018-04-05 19:26:55 +02:00
Carlos Garnacho
5a34d0f816 gtkeventcontrollerkey: Add get_group() call
Callers can use this function on a key-pressed/released signal
to find out the key event group, useful in a few places.
2018-04-05 19:26:55 +02:00
Carlos Garnacho
695549d5a7 eventcontrollerkey: Add function to forward stuff elsewhere 2018-04-05 19:26:54 +02:00
Carlos Garnacho
1ce79b29e3 gtk: Add GtkEventControllerKey
This event controller is meant to replace usage from key-press/release-event
handlers all through. Optionally it can be set a GtkIMContext, so interaction
is carried by the controller.
2018-04-05 19:26:04 +02:00