Commit Graph

188 Commits

Author SHA1 Message Date
Matthias Clasen
55f871c193 imcontext: Fixes to the state machine
It turns out that we we were sometimes emitting
preedit-end multiple times, and sometimes not at
all. Same for preedit-start. To fix this up, introduce
a in_compose_sequence flag, maintain it, and use it
in the right places.

After these changes, both

C-S-u 1 2 3 Enter
Compose a e

generate the right signals:

preedit-start, preedit-changed,..., preedit-end, commit
2021-02-24 13:31:31 -05:00
Matthias Clasen
4327a866f4 imcontext: Make Compose preedit less intrusive
Tweak the preedit display for Compose sequences to
be not so distracting. We only show the Compose key
when it occurs in the middle of the sequence or is
the only key so far, and use · instead of ⎄ for it.

Also, make sure to display dead keys more adequately.
2021-02-18 11:44:09 -05:00
Matthias Clasen
05fe2441a7 imcontext: Enable font fallback for preedit
Not doing so only invites hexboxes.

Fixes: #3678
2021-02-17 22:11:57 -05:00
Matthias Clasen
af9a578d68 imcontext: Prepare for multi-char values
Reshuffle things so we can easily handle values
that are strings instead of just single Unicode
characters.
2021-02-01 23:43:59 -05:00
Matthias Clasen
10fcdd88e3 imcontext: Code cleanup
Get rid of auxiliary check_table function.
2021-02-01 20:41:45 -05:00
Matthias Clasen
5d9509c51b imcontext: Move code around
Move all the checking code to gtkcomposetable.c, and
add api that we can use in tests.
2021-02-01 20:27:38 -05:00
Matthias Clasen
aa9054a5f1 imcontext: Use gtk_compose_table_check
Use the just-introduced api.
2021-02-01 19:41:07 -05:00
Matthias Clasen
edeaf9c040 imcontext: Drop GTK_MAX_COMPOSE_LEN
Drop GTK_MAX_COMPOSE_LEN from docs. It is no longer
used by GTK at all.  We leave the define in place
for now, to avoid breaking 3rd party code that might
use it.
2021-02-01 12:31:23 -05:00
Matthias Clasen
031944ad30 imcontext: Stop using GTK_MAX_COMPOSE_LEN
Allocate the compose_buffer, and resize it when needed
to match the tables we use.
2021-02-01 12:10:05 -05:00
Matthias Clasen
bf8b974f68 imcontext: Code cleanup
Use g_clear_pointer instead of opencoding it in
multiple places.
2021-02-01 12:10:05 -05:00
Matthias Clasen
e39b5c99f1 imcontext: Add a precondition check 2021-02-01 00:43:44 -05:00
Matthias Clasen
8883243aaa imcontext: Show preedit for compose sequences
Show the sequences as they are entered, using ⎄ for
the compose key, to match what IBus does nowadays.
Also handle backspace to allow corrections.
2021-02-01 00:37:43 -05:00
Matthias Clasen
89511eecf1 imcontext: Update our check for dead keys
A bunch of keysyms for dead keys have been added since this
code was last touched. Update the check to cover the full
range from dead_grave to dead_greek.
2021-01-31 23:56:24 -05:00
Matthias Clasen
d4e069a629 Port tracing to the sysprof collector api
Use the new sysprof collector api to do tracing.
2020-08-21 10:55:01 -04:00
Carlos Garnacho
cab1dcb696 gdk: Conflate GDK devices
Make GdkEvents hold a single GdkDevice. This device is closer to
the logical device conceptually, although it must be sufficient for
device checks (i.e. GdkInputSource), which makes it similar to the
physical devices.

Make the logical devices have a more accurate GdkInputSource where
needed, and conflate the event devices altogether.
2020-07-29 01:27:51 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +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
71fe843d99 impcontextsimple: Drop ifdef'ed platform dependencies
The proper way to do this would be to adapt the tables
to have the right data for the platform. Since 4.0 is
a new start in many ways, lets clean this up.
2020-04-07 14:54:04 -04:00
Matthias Clasen
c297d45b8a gtk: Stop using modifier intents
Reviewing the existing settings, the only backend with
some differences in the modifier intent settings is OS X,
and we would rather have that implemented by interpreting
the existing modifiers in the appropriate way.

                X11      Wayland  Win32    OS X

primary         ctrl     ctrl     ctrl     mod2
mnemonic        alt      alt      alt      alt
context menu    -        -        -        ctrl
extend sel      shift    shift    shift    shift
modify sel      ctrl     ctrl     ctrl     mod2
no text         alt|ctrl alt|ctrl alt|ctrl mod2|ctrl
shift group     varies   -        -        alt

GTK now uses the following modifiers:

primary         ctrl
mnemonic        alt
extend sel      shift
modify sel      ctrl
no text         alt|ctrl

The context menu and shift group intents were not used
in GTK at all.

Update tests to no longer expect <Primary> to roundtrip
through the accelerator parsing and formatting code.
2020-04-06 16:32:03 -04:00
Matthias Clasen
0eb728aa51 imcontextsimple: Disable some win32-only code
This code needs to be redone differently, since keymaps are no
longer going to be exposed. There should really not be this much
ifdef-ed backend-specific code here anyway. Or any, really.
2020-04-06 15:33:49 -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
Matthias Clasen
4495bacfd1 gtk: Use display apis for keymap mapping
This removes the last uses of GdkKeymap from GTK.
2020-04-06 01:40:49 -04:00
Matthias Clasen
234a21905c gtk: Stop using keymap apis
Stop using most keymap apis in GTK. Only a few calls
related to virtual modifiers are left.
2020-04-06 01:40:49 -04:00
Matthias Clasen
aaa4e40a1f imcontexsimple: Move Compose file loading to class_init
This ensures that it is done only once.
2020-04-02 09:04:23 -04:00
Matthias Clasen
8ec254e2bb imcontextsimple: Simpify Compose file loading
We are not loading the Compose file for individual contexts,
it just gets added to a global list. So don't pass an im context
along. This will let us move the loading out of the initialization
of individual contexts, and only do it once.
2020-04-02 09:02:05 -04:00
Matthias Clasen
2a9911724f imcontextsimple: Load ~/.Compose unconditionally
There is nothing display-specific in the ~/.Compose file,
so we can just try to load it without looking at the
display we are on.
2020-04-02 09:02:05 -04:00
Matthias Clasen
a9b4ac3d59 imcontextsimple: Add a profiler mark for IO
We are loading a file here, thankfully in a thread, but
we do it every time an entry is created. Add a profiler
mark, to make this visible.
2020-04-02 09:02:05 -04:00
Matthias Clasen
aa2ca80817 imcontextsimple: Don't use g_object_unref on events
Events are not objects anymore.
2020-03-28 14:29:08 -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
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
dac61b3cce imcontextsimple: Use event constructors 2020-02-21 00:40:52 -05:00
Matthias Clasen
d3c45cb979 docs: Miscellaneous doc fixes
Additions and correction all over the place,
in GDK and GTK docs.
2019-02-24 16:53:12 -05:00
Benjamin Otte
bbd1532f84 imcontext: Fix priorities of modules
All built-in backend modules get a priority of 0 because they are the
default ones.
GtkIMContextSimple gets a priority of G_MININT because it's the fallback
one.

This mirrors the media modules code.
2019-01-22 04:33:11 +01:00
Mohammed Sadiq
bdf3b6f64d Revert "imcontext: Make size arguments be gsize and not int"
This was committed accidently.

This reverts commit eefd2d6f10.
2018-06-14 11:15:14 +05:30
Benjamin Otte
eefd2d6f10 imcontext: Make size arguments be gsize and not int
Otherwise gcc complains when we use these as arguments to g_new() on
32bit architectures with:

../gtk/gtkcomposetable.c: In function ‘gtk_compose_table_list_add_array’:
/usr/include/glib-2.0/glib/gmem.h:217:10: warning: argument 1 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]
      __p = g_##func##_n (__n, __s);   \
      ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gmem.h:279:42: note: in expansion of macro ‘_G_NEW’
 #define g_new0(struct_type, n_structs)   _G_NEW (struct_type, n_structs, malloc0)
                                          ^~~~~~
../gtk/gtkcomposetable.c:851:22: note: in expansion of macro ‘g_new0’
   gtk_compose_seqs = g_new0 (guint16, length);
                      ^~~~~~
/usr/include/glib-2.0/glib/gmem.h:96:10: note: in a call to allocation function ‘g_malloc0_n’ declared here
 gpointer g_malloc0_n      (gsize  n_blocks,
          ^~~~~~~~~~~
2018-06-14 06:37:00 +05:30
Руслан Ижбулатов
43d6fe2583 Fix missing default switch cases in gtkimcontextsimple 2018-06-10 21:21:22 +00:00
Руслан Ижбулатов
76855e8999 imcontextsimple: ensure W32 code only runs on W32 displays
gdk_win32_keymap_check_compose() shouldn't be called for
non-W32 displays (i.e. when using broadway or other backends
that could be made to run on Windows).
2018-04-26 17:50:55 +00:00
Matthias Clasen
8be12a2427 Drop Ctrl-Shift-e support
Now that we have Emoji completion, drop the rather limited
Ctrl-Shift-e support in GtkIMContextSimple, and leave this
sequence to input methods.
2018-04-23 18:54:43 -04:00
Alexander Larsson
39851fbdbf Continue renaming window to surface
This renames a lot of arguments, local variables and functions.
2018-03-21 11:49:14 +01:00
Alexander Larsson
3dce0dcca7 GdkSurface: Rename lots of stuff from window->surface
Mostly these are internal things, but the major public change is
that event.window is now event.surface.
2018-03-20 15:14:10 +01:00
Alexander Larsson
391727bd0d GdkWindow -> GdkSurface initial type rename
This renames the GdkWindow class and related classes (impl, backend
subclasses) to surface. Additionally it renames related types:
GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType,
GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge

This is an automatic conversion using the below commands:

git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass

git sed -f g GdkWindow GdkSurface
git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing
git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING
git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2"
git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE
git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo

git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE"
git sed -f g "broadway_window" "broadway_surface"
git sed -f g "BroadwayWindow" "BroadwaySurface"
git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE"
git sed -f g "wayland_window" "wayland_surface"
git sed -f g "WaylandWindow" "WaylandSurface"
git sed -f g "X11_WINDOW" "X11_SURFACE"
git sed -f g "x11_window" "x11_surface"
git sed -f g "X11Window" "X11Surface"
git sed -f g "WIN32_WINDOW" "WIN32_SURFACE"
git sed -f g "win32_window" "win32_surface"
git sed -f g "Win32Window" "Win32Surface"
git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE"
git sed -f g "quartz_window" "quartz_surface"
git sed -f g "QuartzWindow" "QuartzSurface"

git checkout NEWS* po-properties
2018-03-20 11:40:08 +01:00
Quentin Glidic
f431e28ce3 gtkimcontextsimple.c: Use X11_DATA_PREFIX only on X11
Unlike what commit d01ea18dc3 says, X11 is
not a requirement for Wayland, so a Wayland-only build is possible. We
just use the same logic as other non-X11 platforms.

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

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2018-03-19 11:39:47 +01:00
Matthias Clasen
e0771a54a2 Avoid warnings
When generating introspection data, we instantiate types without
calling gtk_init, so make sure that extension points are registered
before the type is trying to implement them.
2018-03-09 02:13:13 -05:00
Matthias Clasen
29bcc38ae6 Convert immodules to use an extension point
Add an extension point called gtk-im-module, which requires
the type GtkIMContext. Simplify the loading by using GIO
infrastructure. Drop the locale filtering for now, I don't
think it is really necessary nowadays.

Convert existing platform modules to gio modules.
Sill to do: Drop the conditional build machinery.
Either always include them, or never.
2018-02-24 21:34:40 -05: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
Matthias Clasen
e92c0e85ec Replace gdk_keymap_get_for_display by gdk_display_get_keymap
Replace all uses of the old function by the new one.
No functional change.
2017-12-15 07:44:58 -05:00
Matthias Clasen
fd85ff0c7a Drop gdk_keymap_get_default()
It is better to use the explicit keymap getter - the
default display may not even use the current gdk backend.
2017-12-14 23:57:54 -05:00
Carlos Garnacho
d491e49fd6 gtk: s/gdk_event_free/g_object_unref/ 2017-12-14 01:05:48 +01:00
Matthias Clasen
95876cbc9c Remove gdk/gdkx.h
It was just a kludge.
2017-11-16 23:00:01 -05:00