Commit graph

63 commits

Author SHA1 Message Date
Vlad Zahorodnii
e2a393ce2d Move utils.h file to utils directory 2022-01-25 16:56:33 +00:00
Weng Xuetian
791b0bb296 Do not remove WAYLAND_DISPLAY environment variable for input method.
Based on the implementation of wl_display_connect, WAYLAND_SOCKET is
always preferred over WAYLAND_DISPLAY, which means it is OK to have both
of them set. This allows subprocess of input method to have the correct
WAYLAND_DISPLAY variable set.
2022-01-15 19:36:40 +00:00
Vlad Zahorodnii
8e8f55b18a Drop Process helper
Direct session is long time gone and SIGUSR1 and SIGUSR2 are not used
anywhere so drop the Process helper.
2022-01-11 08:01:10 +00:00
Weng Xuetian
ca7298a325 Ensure modifier change is forwarded after the key sending to input method.
Same as real hardware wl_keyboard, key should be sent before modifier
change. For example, Left Ctrl press and release should produce
key events in the order of Control_L and Control+Control_L.
2022-01-02 03:26:23 +00:00
Aleix Pol
13b85d77fc inputmethod: Expose VirtualKeyboard.willShowOnActive on dbus
It can help clients predict how KWin will react. Sometimes, the noise of
seeing a virtual keyboard pop up is reason enough not to focus an input
field.
2021-12-28 23:53:08 +00:00
Weng Xuetian
8a2f64fbe1
Do not call setActive(true) when request input panel to show
Observed in kdevelop, that isEnabled() could be false when switching
between different tabs with Ctrl+Tab. But Qt may still call show()
if you click on the texteditor widget. This leads to isEnabled == false but
setActive(true) is called. This causes kdevelop in a usable state because
keyboard grab will be created and no key event will reach application
because isEnabled == false. Under normal circumstances, key will reach
widget first and triggers another text_input_v2 enable to make input
method work properly.
2021-12-27 21:34:06 -08:00
Weng Xuetian
c074e2eb42 Try our best to convert preedit styling to text-input-v3 cursor range.
text-input-v3 does not have preedit styling, instead, it can only
specify the range of cursor. Try to keep track of any
highlight/selection style range and combine them together. If it matches
the cursor position, use it as the cursor range.
2021-12-27 06:32:31 +00:00
Weng Xuetian
f50866d3f8 Fix different semantics of delete_surrounding_text between zwp_input_method_V1 and text_input_v{2,3} 2021-12-27 05:33:58 +00:00
Weng Xuetian
4f2c3a00c4 Change InputMethod::show() and InputMethod::hide() to not change active state.
Qt usually request InputMethod::hide() upon unfocus, but
InputMethod::show() is actually never called if focus transfer is done
by keyboard, which leads to a permanent disabled input method state.

It can be easily reproduced with a window with two text field, e.g.
QFileDialog, by pressing tab to switch the focused widget.

The semantics of hide/show should not deactivate the input method.
Instead, it should simply hide/show the input panel. Also it should not
be a hard request for input method to permanently hide the window. When
input method asked to show it again, the input panel window should be
shown.
2021-12-23 03:00:52 +00:00
Weng Xuetian
119f0d02be Do no send empty preedit string to text-input-v3.
zwp_input_method_v1 has some different semantics comparing to
text-input-v3. There is no way to indicate that "clear preedit" with
zwp_input_method_v1. In some client (Namely, Gtk), receiving an empty
preedit string will also trigger replace selection action. For example,
focus into address bar in firefox will automatically select the URL in
the address bar, and a following empty preedit string will clear the
selection which is not desirable.

To avoid such behavior, simply send an empty "done()" to clear text
input v3 preedit if preedit is empty.
2021-12-23 02:18:55 +00:00
Weng Xuetian
6d6ce2981e Add preedit styling support for text-input-v2. 2021-12-20 19:18:45 +00:00
Weng Xuetian
0b1565c54c
Do not send reset to an already active input context.
This may be problematic for certain client, e.g. firefox, and cause
input always reset after any key press. Also, sending reset on an
activate also does not match the text input v3 semantics.
2021-12-19 00:15:20 -08:00
Weng Xuetian
bd40db7dd1
Fix text input v3 related protocol usage.
zwp_input_method_v1 does not support generic double buffered event.
deleteSurroundingText need to be followed with done().
zwp_input_method_v1 preedit event order is preeditCursor,
preeditStyling, preeditString. To align it with text-input-v3 semantices,
send done() after receiving preedit_string() from input method.
2021-12-19 00:12:31 -08:00
Weng Xuetian
d66be7b99f Forward xkb modifier changes to input method.
Since not all the key are forwarded to input method, any modifier
changes need to be forwarded to input method as long as keyboard grab
is active.
2021-12-16 03:29:00 +00:00
Weng Xuetian
11f6292cb5 Move input keyboard filter to be just before the key is sent to application.
Features like global shortcuts should be handled before the input
method.
2021-12-16 03:29:00 +00:00
Weng Xuetian
9e68357ce9 Do not unset DISPLAY and XAUTHORITY for input method.
Those variable are required for XIM to work for Xwayland application.
2021-12-15 17:49:48 +00:00
Vlad Zahorodnii
f1e96676ef Remove boolean trap in AbstractClient::isShown()
Check shaded state where needed.
2021-11-24 08:11:35 +00:00
Rodney Dawes
518c75a042 InputMethod: Use new API to pass modifiers map along to clients 2021-10-15 16:47:06 -04:00
Rodney Dawes
9818f4a4e5 InputMethod: Update for kwayland-server API change with keysym events
To avoid needless conversion of modifiers in kwayland-server, we needed
to break API so that the modifiers are simply passed through.
2021-10-15 16:47:06 -04:00
Aleix Pol
3e77907d21 inputmethod: Use touch events to decide if the panel is shown not the state
Prefer hiding/showing the panel (i.e. the window) when not a touch event
than stopping to make the inputmethod active.
This way we remain compatible with non-virtualkeyboard inputmethods.
2021-10-15 15:41:35 +00:00
Xaver Hugl
5b9deafa14 InputMethod: only activate virtual keyboard when used with touch 2021-10-15 15:41:35 +00:00
Vlad Zahorodnii
e550480c43 Rework input method teardown logic
Explicitly destroy input method rather than wait for the input method
connection to be destroyed by WaylandServer, it's less error prone.

BUG: 443603
2021-10-14 10:02:50 +00:00
Vlad Zahorodnii
5be593d4e4 wayland: Drop internal connection
It's practically unused now.
2021-10-07 13:28:08 +00:00
Aleix Pol
1473466ef7 inputmethod: Remove the SNI entirely
It can be replaced with an ad-hoc plasmoid that gets to be a bit more
specific and interactive.
2021-08-12 16:00:15 +00:00
Aleix Pol
05f3939cf1 inputmethod: Use the command as the availability metric 2021-07-22 20:12:54 +02:00
Aleix Pol
278da74eab inputmethod: Add a property to tell whether an input method is running 2021-07-22 17:42:53 +02:00
Aleix Pol
422522d15b inputmethod: Also expose the visibility on dbus
Since we adapted inputmethod to support methods like ibus, the input
method can be active but not have a visible panel.
This includes an extra property that will indicate us if the panel is
visible at any time. This will allow us to properly render the virtual
keyboard hide button in Plasma Mobile (or wherever we need it).
2021-07-21 13:10:30 +02:00
Aleix Pol
abf22570c7 inputmethod: Reduce consecutive activation+deactivation+activation sequences
So far calling setActive(true) would issue a deactivation then another
activation. This sometimes makes maliit crash and we can achieve the
same result just by just issuing a reset.
2021-07-21 13:10:30 +02:00
Aleix Pol
638174ae09 inputmethod: Make sure the menu is only created when we create the SNI
It always does the same anyway, this way we make sure we don't leak
2021-07-21 13:10:30 +02:00
Aleix Pol
0169bca6e0 inputmethod sni: return early for readability 2021-07-21 13:10:29 +02:00
Xaver Hugl
4b5571163e inputmethod: save enabled state 2021-07-10 17:47:45 +00:00
Aleix Pol
09f99df1a3 inputmethod: Be more assertive towards the input panel visibility
If a new input client has taken over, don't override the trackedClient's
geometry.
Only consider the input geometry of a visible keyboard.
2021-06-10 03:33:36 +00:00
Aleix Pol
6fa96852dc inputmethod: Reconsider what a hidden input method is
When the panel disappears, just reconsider the panel's state but don't
just stop sending updates to the input method.
Some input methods are just helpers that show and hide as necessary.
2021-06-10 03:33:36 +00:00
Vlad Zahorodnii
1b2c7b248b Run clazy with qt-keywords fixit
In C++20, there will be emit() class member, which can conflict with the
emit keyword. Given that, there are plans to enable QT_NO_KEYWORDS by
default in the future.

See also
https://lists.qt-project.org/pipermail/development/2020-February/038812.html
2021-06-08 10:49:42 +03:00
Aleix Pol
34bfc25759 inputmethod: Don't move the clients around when the input panel is an overlay
It's meant to be floating around the cursor, if we do this we just get a
weird tiny screen.
2021-06-05 23:33:32 +00:00
Bhushan Shah
2b1d709b04 inputmethod: hook the key and modifiers functions 2021-06-04 00:14:34 +02:00
Aleix Pol
454425b43f inputmethod: Allow input methods to grab the keyboard
This allows different input methods to get information about what's
beign typed from the actual hardware. This is especially useful for
non-latin script languages.
2021-06-03 19:13:21 +02:00
Aleix Pol
74724065ae inputmethod: Don't disable them by default if there's a connected keyboard
If the user has chosen to have a virtual keyboard (i.e. prefered maliit
over none in the KCM) they should get it. If it's too annoying it should
either be disabled or we can fix it so it gets less in the way.

This is especially important since some hardware registers itself as a
keyboard even if it's not a fully functional keyboard.
2021-06-03 10:51:01 +00:00
Aleix Pol
1e5fae1e91 inputmethod: warn when we're committing strings to noone 2021-05-24 14:16:23 +02:00
Aleix Pol
8fad7aa4f3 inputmethod: Also update the trackingClient when there's none set
Also moves the setting code to a separate method for readability
2021-05-24 14:16:23 +02:00
Aleix Pol
f60b9176da inputmethod: Use the inputmethod's context as the isActive measure
Ensures that m_active and the input context do not get out of sync and
that the right signals are always emitted by always using setActive to
activate.
Uses the context to define InputMethod::isActive.
2021-05-24 14:16:23 +02:00
Aleix Pol
184e53e5c2 inputmethod: Make sure we send a state commit
Detach from the serials that the client send us, since they don't really
matter to the input method and track our own.
Also issue a commit state whenever we adopt a new input context. This
can happen for reasons that don't come from the client, like for example
the input method has just been enabled.
In practice, this solves an issue that we can easily see with maliit
where it would be left in a half-initialised state and would show
autocorrection fields on terminal applications when unnecessary and
possibly similar problems every now and then.
2021-05-24 14:16:14 +02:00
Nicolas Fella
99b84a321a Don't show virtual keyboard SNI when no virtual keyboard is selected in the KCM
Not choosing any virtual keyboard is a valid option. In this case do not show the SNI since it isn't very useful then and takes up some space in the system tray.

BUG: 437171
2021-05-24 11:53:30 +00:00
Aleix Pol
f4715b9ac5 inputmethod: deactivate the input method when we textinputv3 is committed as disabled
Fixes InputMethodTest::testEnableDisableV3 on my system when running on
Valgrind, should hopefully also fix on CI.
2021-05-14 09:28:57 +00:00
Bhushan Shah
6b25335a2b inputmethod: fix coding style
GIT_SILENT
2021-05-11 16:44:01 +05:30
Aleix Pol
64178a0536 textinputv3: activate the input method when textinput says it's enabled 2021-05-11 12:47:27 +02:00
Vlad Zahorodnii
7261bbb230 Fix bad QObject::connect() argument
This fixes the warning that's printed when InputMethod tries to connect
the frameGeometryChanged signal of a null toplevel.
2021-05-09 22:45:27 +00:00
Aleix Pol
4aefbdd175 --warning 2021-05-04 23:07:16 +02:00
Bhushan Shah
d987b94e42 inputmethod: do not deactivate the context when key is pressed
When keyboard_grab is implemented, if we reset the inputmethod context
on any key, input method will not get keyboard input and will not be
able to use it.
2021-05-03 09:44:27 +05:30
Aleix Pol
904c48d563 inputmethod: properly report the text_input_v2 overlap information
Call ::updateInputPanelState when necessary (instead of a trimmed-down
refreshFrame version.
Actually provide the overlap information when it's available, there's no
need to send wrong information there.
2021-04-30 17:46:52 +02:00