linebender / glazier

Deprecated Rust Window Creation Library
Apache License 2.0
206 stars 32 forks source link

Support composition on Wayland (and x11) #119

Closed DJMcNab closed 1 year ago

DJMcNab commented 1 year ago

Work towards #118.

This is nearly complete - I need to make sure it interacts correctly with the normal IME and manual updates to the text field (e.g. mouse selections, etc.)

I've made a few potentially controversial decisions primarily around cancellation. See the big block of text in src/text.rs for some context.

To play around with this on GNOME, either use:

cargo run --example edit_text --no-default-features --features=x11

or apply

diff --git a/src/backend/wayland/input/mod.rs b/src/backend/wayland/input/mod.rs
index 51755a0..a6551f4 100644
--- a/src/backend/wayland/input/mod.rs
+++ b/src/backend/wayland/input/mod.rs
@@ -75,11 +75,12 @@ impl WaylandState {
         };
         let idx = self.input_states.len();
         self.input_states.push(new_info);
-        let input = &mut self.input_states[idx];
-        input.input_state = self
-            .text_input
-            .as_ref()
-            .map(|text_input| InputState::new(text_input, &input.seat, &self.wayland_queue, id));
+        if false {
+            let input = &mut self.input_states[idx];
+            input.input_state = self.text_input.as_ref().map(|text_input| {
+                InputState::new(text_input, &input.seat, &self.wayland_queue, id)
+            });
+        }
     }

     pub(super) fn initial_seats(&mut self) {

It should just work on KDE, as KDE doesn't use IME for compose.

DJMcNab commented 1 year ago

I've moved this to a draft, because I need to reconsider our interactions with the input lock

nyabinary commented 1 year ago

How the progress?

DJMcNab commented 1 year ago

Needs testing and review, but if everything else is OK, we're ready to land.

Still need to fixup clippy and change the default features back to just x11, but otherwise it should work!