Commit graph

126 commits

Author SHA1 Message Date
Eberhard Beilharz
ab25157364
feat(linux): Refactor to benefit from C++ RAII
Also apply changes from code review comments.
2023-05-22 19:51:45 +02:00
Eberhard Beilharz
c2e6fe23bd
feat(linux): Client side 2023-05-15 09:13:58 +02:00
Eberhard Beilharz
c20531b08a
chore(linux): Log error 2023-03-06 16:00:43 +01:00
Eberhard Beilharz
a26caa4d18
feat(linux): Add DBus method SendText
This new DBus method allows an OSK to output a junk of text.
2023-03-06 16:00:43 +01:00
Marc Durdin
e645b8665f chore: Merge branch 'feature-ldml' into chore/A17S7-master-to-feature-ldml
* core/build.sh -- accept feature-ldml changes (remove call to get_builder_OS)
* developer/src/kmlmc/build.sh -- delete file
*	linux/debian/rules -- accept master changes, fixup call to core/build.sh
*	linux/ibus-keyman/tests/Makefile.am -- accept master changes, fixup call to core/build.sh
*	linux/scripts/build.sh -- accept master changes, fixup call to core/build.sh
*	linux/scripts/reconf.sh -- accept master changes
2023-02-22 08:00:08 +07:00
Eberhard Beilharz
4d3755770c
fix(linux): Collect consecutive backspaces
When using Wayland `im-wayland.so` (which is part of libgtk) gets
loaded into the client app instead of `im-ibus.so`. This means that
our ordered output doesn't work with Wayland.

This change works around a problem with keyboards that use multiple
consecutive backspace actions. Because method calls get processed
asynchronously some backspaces get lost. In clients that support
surrounding text we can count the consecutive backspaces and then
do one call to delete surrounding text with the appropriate number
of characters.

This can be tested with "Khmer Angkor" keyboard by typing `xEjmr`,
or with "Vedic Sanskrit Devanagari Phonetic (ITRANS)" keyboard by
typing `shrI`.

Part of #4273.
2023-02-20 18:47:51 +01:00
Steven R. Loomis
ae45295dc6 Merge remote-tracking branch 'upstream/master' into chore/merge-master-a17s5-REDO-epic-ldml 2023-02-03 16:53:35 -06:00
Eberhard Beilharz
f2cfccb572
chore(linux): Fix warnings
This warnings showed up when building with Meson.
2023-01-26 16:58:27 +01:00
Eberhard Beilharz
d20812d043
Merge pull request #8036 from TheSchlunz/TheSchlunz/issue7540
chore(linux): log failures to `km_kbp_context_clear(context)`
2023-01-19 11:46:49 +01:00
Eberhard Beilharz
4f19ea690f
Merge pull request #8037 from TheSchlunz/TheSchlunz/issue7541
chore(linux): use faster zero-length string check
2023-01-19 11:41:24 +01:00
Kevin Schluensen
28baf30135 Add status output 2023-01-18 18:27:37 +01:00
Kevin Schluensen
c7dedf6643 chore(linux): use faster zero-length string check
Fixes #7541
2023-01-18 13:06:16 +01:00
Kevin Schluensen
b7c27886c0 chore(linux): log failures to km_kbp_context_clear(context)
Fixes #7540
2023-01-18 12:57:13 +01:00
Eberhard Beilharz
3afc6961d7
fix(linux): Properly set context after changing IP
This change fixes a bug where we the context was wrong after
putting the IP in a new location by mouse-click.

Fixes #8024.

(cherry picked from commit a085fa244b)
2023-01-16 17:19:05 +01:00
Steven R. Loomis
bc14f18460 Merge remote-tracking branch 'origin/master' into chore/core/mergemaster4-epic-ldml 2022-12-15 17:55:13 -06:00
Eberhard Beilharz
f54ea7a7f2
Merge pull request #7804 from keymanapp/refactor/linux/kbdOptions
refactor(linux): Refactor setting keyboard options ⚙️
2022-11-29 10:48:02 +01:00
Eberhard Beilharz
0f2c9972c6
refactor(linux): Fix more memory leaks
Turns out there are more things we need to clean out if we run
into an error condition in the c'tor. Easiest is to call the
destroy method.
2022-11-28 16:46:55 +01:00
Eberhard Beilharz
8b4d3e09ed
Apply suggestions from code review
Co-authored-by: Marc Durdin <marc@durdin.net>
2022-11-28 16:40:02 +01:00
Eberhard Beilharz
61d5d69a12
refactor(linux): Address code review comments 2022-11-25 17:31:32 +01:00
Eberhard Beilharz
35b678a931
refactor(linux): Fix failing tests 2022-11-24 19:16:14 +01:00
Eberhard Beilharz
ddd8e5b08c
refactor(linux): Address code review comments 2022-11-24 17:00:11 +01:00
Eberhard Beilharz
afd5fc86f1
refactor(linux): Refactor setting keyboard options
- set keyboard options in a call to `km_kbp_state_options_update`
  separate from setting the environment options
- output status value if method fails
- if any of the methods fails we now return NULL
- split setting the options in multiple methods

Fixes #7717.
2022-11-23 19:05:54 +01:00
Eberhard Beilharz
5da4f17dd1
refactor(linux): Don't free consts
(cherry picked from commit b0b605709a)
2022-11-23 18:21:01 +01:00
Eberhard Beilharz
0f0ab06f53
refactor(linux): Use consts instead of strings
This refactoring makes use of the already defined strings.
It also simplifies setting the values by directly specifying an
UTF-16 string.

Motivated by the changes in PR #7667.

(cherry picked from commit 31340b5b51)
2022-11-23 18:20:52 +01:00
Eberhard Beilharz
a958f1a369
Merge pull request #7792 from keymanapp/fix/linux/7774_buildWithOldIbus
fix(linux): Allow to build without patched ibus version
2022-11-23 08:42:36 +01:00
Eberhard Beilharz
c1871fdd70
fix(linux): Improve compiler warning if ibus not patched
Co-authored-by: Marc Durdin <marc@durdin.net>
2022-11-23 08:42:25 +01:00
Eberhard Beilharz
bb54946a8a
fix(linux): Fix warning
Commit acab920de8 didn't really fix
the warning. https://stackoverflow.com/a/2524675/1836776 suggests
to use `%zu` which is what this change does now.
2022-11-22 18:47:11 +01:00
Eberhard Beilharz
da765f1625
fix(linux): Allow to build without patched ibus version
This change makes it possible to compile even when the updated
ibus version is not installed. Of course ordered output won't work
in that case, but at least it will compile and the rest of Keyman
will work.

Fixes #7774.
2022-11-22 18:05:46 +01:00
Eberhard Beilharz
812c7c33b9
fix(linux): Revert "fix(linux): Fix a warning"
This reverts commit acab920de8.

I'm confused - now we're getting the same warning again - claiming
that `size_t` is defined as `long unsigned int` and so we have to
use `%lu`!? Is this related to the platform we're compiling on?
This time, the warning we get is when compiling for x86_64:

```
engine.c: In function ‘get_current_context_text’:
engine.c:224:15: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  224 |     g_message("%s: current context is:%u:%lu:%s:", __FUNCTION__, km_kbp_context_length(context), buf_size, current_context_utf8);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                  |
      |                                                                  size_t {aka long unsigned int}
engine.c:224:40: note: format string is defined here
  224 |     g_message("%s: current context is:%u:%lu:%s:", __FUNCTION__, km_kbp_context_length(context), buf_size, current_context_utf8);
      |                                       ~^
      |                                        |
      |                                        unsigned int
      |                                       %lu

```

Reverting the previous fix for now.
2022-11-21 16:12:00 +01:00
Eberhard Beilharz
acab920de8
fix(linux): Fix a warning
`size_t` is defined as `unsigned int`, not as a long.
2022-11-17 19:26:28 +01:00
Eberhard Beilharz
b0b605709a
refactor(linux): Don't free consts 2022-11-11 18:44:28 +01:00
Eberhard Beilharz
31340b5b51
refactor(linux): Use consts instead of strings
This refactoring makes use of the already defined strings.
It also simplifies setting the values by directly specifying an
UTF-16 string.

Motivated by the changes in PR #7667.
2022-11-10 19:56:35 +01:00
Marc Durdin
deeb246783
Merge pull request #7084 from keymanapp/fix/linux/improvecontext
fix(linux): Improve setting context
2022-10-26 12:34:24 +11:00
Marc Durdin
5321538d1d
Merge pull request #7503 from keymanapp/chore/linux/clearify
chore(linux): call `reset_context` instead of `...focus_in`
2022-10-25 06:23:42 +11:00
Eberhard Beilharz
7b3f891eb9
chore(linux): Rename internal method to commit_string
The previous method name `ibus_keyman_engine_commit_string`
suggests that this method is overridden from ibus-engine class.
However, while it is true that ibus-engine has a
`ibus_engine_commit_string` method it can't be overridden. This
change renames the method to make it clearer that this is an internal
method that won't be called by ibus.
2022-10-20 09:34:28 +02:00
Eberhard Beilharz
e529052dc5
chore(linux): call reset_context instead of ...focus_in
Both `ibus_keyman_engine_reset` and `ibus_keyman_engine_focus_in`
are methods that get called by ibus. Having `ibus_keyman_engine_reset`
call `ibus_keyman_engine_focus_in` makes it much harder to see in
log files which methods get really called by ibus.

This change replaces the call of `...focus_in` with `reset_context`,
which is what `...focus_in` does as well. The only other thing that
`ibus_keyman_engine_focus_in` does in addition to that is calling
`ibus_engine_register_properties` - which shouldn't be necessary on
a reset (besides that we don't seem to do anything with the one
status property we register).
2022-10-20 09:22:11 +02:00
Eberhard Beilharz
cfe0998b2e
refactor(linux): Comment unused methods
Closes #7297.
2022-10-20 09:06:27 +02:00
Eberhard Beilharz
448baad79d
refactor(linux): Replace tabs with spaces 2022-10-20 09:02:48 +02:00
Eberhard Beilharz
d4283754df
refactor(linux): Refactor alignment of params 2022-10-20 09:02:48 +02:00
Eberhard Beilharz
2dab491a10
chore(linux): Always output function name in debug messages 2022-10-20 08:56:58 +02:00
Eberhard Beilharz
2663aa738c
chore(linux): Improve debug output 2022-10-20 08:56:36 +02:00
Eberhard Beilharz
f4410616e8
fix(linux): Fix tests
The previous changes didn't work when we output a character +
deadkey. In response to outputting the character we get a
`ibus_keyman_engine_set_surrounding_text` call in which we
called `reset_context` which removed the deadkey marker. This change
fixes this problem by comparing the surrounding text with the
context we already have. Only if it's different we reset the
context.
2022-10-17 20:27:04 +02:00
Eberhard Beilharz
696f683d0e
chore(linux): address code review comments 2022-10-13 11:13:28 +02:00
Marc Durdin
0945b92732 chore: Merge branch 'master' into chore/merge-master-into-feature-ldml 2022-10-13 13:38:31 +11:00
Eberhard Beilharz
d2262f2223
refactor(linux): Some refactorings
- adjust indentation of `reset_context`
- move variable definition to block where they're used
- make use of method to detect surrounding text support
2022-10-12 21:19:10 +02:00
Eberhard Beilharz
bad0feea9b
fix(linux): Improve setting context
This change always gets the context from the surrounding text
if `reset_context` gets called. This helps when the user puts the
IP after a certain character. Previously we basically lost the
context, with this change we restore the context so that it's like
the user just typed the previous characters.
2022-10-12 21:14:26 +02:00
Eberhard Beilharz
bcd29634bf
feat(linux): Address code review comments
Co-authored-by: Marc Durdin <marc@durdin.net>
2022-10-11 18:44:30 +02:00
Eberhard Beilharz
908dfbeefb
feat(linux): Optimize if surrounding text is supported
Only send fake event if client does not support surrounding text.
2022-10-11 18:44:30 +02:00
Eberhard Beilharz
e6601f205c
feat(linux): match state of original event when creating fake event
We forward a fake event for both keydown and keyup. This change
will set the flag on the fake event so that we get keydown and keyup.
This is probably not technically necessary, but it helps in
debugging because you can then see that both fake events still
belong to the same keypress.
2022-10-11 18:44:30 +02:00
Eberhard Beilharz
dba2002287
feat(linux): Still support older ibus versions
If we're dealing with an older ibus version that doesn't have the
necessary patches we fall back to the old behaviour. Otherwise
we use the new output reordering.
2022-10-11 18:44:29 +02:00