git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commitc240abac430f40a4798bbd2c3e670b8fb5778586
parentc5af9fad4f
authorpraschke <[email protected]>
date2023-12-21 21:29
input-method: check that the input method is active when committing

 river/InputRelay.zig | 8 +++++---
 river/TextInput.zig  | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/river/InputRelay.zig b/river/InputRelay.zig
index 4e42e18..bdd1022 100644
--- a/river/InputRelay.zig
+++ b/river/InputRelay.zig
@@ -60,10 +60,11 @@ fn handleInputMethodCommit(
     input_method: *wlr.InputMethodV2,
 ) void {
     const self = @fieldParentPtr(Self, "input_method_commit", listener);
-    const text_input = self.getFocusedTextInput() orelse return;
-
     assert(input_method == self.input_method);
 
+    if (!input_method.client_active) return;
+    const text_input = self.getFocusedTextInput() orelse return;
+
     if (input_method.current.preedit.text) |preedit_text| {
         text_input.wlr_text_input.sendPreeditString(
             preedit_text,
@@ -159,6 +160,7 @@ pub fn sendInputMethodState(self: *Self, wlr_text_input: *wlr.TextInputV3) void
     const input_method = self.input_method orelse return;
 
     // TODO: only send each of those if they were modified
+    // after activation, all supported features must be sent
 
     if (wlr_text_input.active_features.surrounding_text) {
         if (wlr_text_input.current.surrounding.text) |text| {
@@ -201,7 +203,7 @@ pub fn setSurfaceFocus(self: *Self, wlr_surface: ?*wlr.Surface) void {
                 text_input.relay.disableTextInput(text_input);
                 text_input.wlr_text_input.sendLeave();
             } else {
-                log.debug("IM relay setSurfaceFocus already focused", .{});
+                log.debug("input relay setSurfaceFocus already focused", .{});
                 continue;
             }
         }
diff --git a/river/TextInput.zig b/river/TextInput.zig
index bfd341b..2208184 100644
--- a/river/TextInput.zig
+++ b/river/TextInput.zig
@@ -70,6 +70,8 @@ fn handleEnable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) v
         return;
     }
 
+    // must send surrounding_text if supported
+    // must send content_type if supported
     self.relay.sendInputMethodState(self.wlr_text_input);
 }