Skip to content

Revert "Add composition event on macOS (#1979)" - #2119

Merged
ArturKovacs merged 1 commit into
rust-windowing:masterfrom
ArturKovacs:revert-1979
Jan 2, 2022
Merged

ArturKovacs merged 1 commit into
rust-windowing:masterfrom
ArturKovacs:revert-1979

Conversation

@ArturKovacs

@ArturKovacs ArturKovacs commented Dec 29, 2021 •

Copy link
Copy Markdown
Contributor

Fixes #2097

This reverts commit 8afeb91.

Reverting because this change made Pinyin input unusable
(only latin characters showed even after selecting the
desired Chinese character)

Furthermore the change itself was pretty much a hack. The change allowed an application to show the preedit text. However winit doesn't yet have an API for this so the implementation simply sent ReceivedCharacter events for each character of the preedit text and whenever the text changed it sent 'u{7f}' (aka DELETE) characters for each UTF32 code unit of the previous preedit text, then sent each character of the new preedit text.

For all these reasons, I believe a revert is warranted.

  • Tested on all platforms changed
  • Compilation warnings were addressed
  • cargo fmt has been run on this branch
  • cargo doc builds successfully
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

@ArturKovacs ArturKovacs added the DS - appkit Affects the AppKit/macOS backend label Dec 29, 2021
@ArturKovacs

Copy link
Copy Markdown
Contributor Author

With all that said I believe there's a strong need for a proper IME API in winit.

@ArturKovacs

Copy link
Copy Markdown
Contributor Author

@madsmtm @maroider Do you mind if I merge this?

@maroider

Copy link
Copy Markdown
Member

So if I've read this correctly, IME will work fine, but will lack the "enhancement" added by #1979?

If so, then I have no issue with reverting it, as having all IMEs work at all is more important than hacking in pre-edit text.

@ArturKovacs

Copy link
Copy Markdown
Contributor Author

So if I've read this correctly, IME will work fine, but will lack the "enhancement" added by #1979?

Yes.

@madsmtm

madsmtm commented Dec 31, 2021 •

Copy link
Copy Markdown
Member

Tagging @komi1230

@madsmtm madsmtm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very inexperienced with IME, but I agree that it's more important to fix the regression than for the "smart" rendering to work (to be honest, I never liked that hack, so that may also influence my decision).

let char_count = Rc::new(Cell::new(0));
let block = {
let char_count = char_count.clone();
ConcreteBlock::new(move || char_count.set(char_count.get() + 1)).copy()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also UB btw, the block must take the four arguments as described in the docs (even if unused)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out, I'll try to remember this for the future.

Comment thread CHANGELOG.md Outdated
# Unreleased

- On X11, add mappings for numpad comma, numpad enter, numlock and pause.
- On macOS, revert a change that inteded to improve IME but caused Pinyin input to stop working. (In other words, this change fixes Pinyin input)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inteded is misspelled, and the wording is a bit convoluted. Maybe something along the lines of "fixes Pinyin IME input by reverting ..."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be resolved now

Comment on lines +444 to +445
let mutable_string = marked_text.mutableString();
let _: () = msg_send![mutable_string, setString:""];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether this or the other method (release + alloc) is better here, but let's just leave it be for now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that releasing and allocating a new one would be safer, but the reference to markedText seems to be constrainted to the View, so it seems safe enough.

@komi1230

Copy link
Copy Markdown
Contributor

I was also inexperienced in IME and #1979 was just a workaround to make Japanese input work fine.

I'm sorry for taking time from you and I appreciate you to spending much cost to fix this.

This reverts commit 8afeb91.

Reverting because this change made pinyin input unusable
(only latin characters showed even after selecting the
desired Chinese character)
@ArturKovacs

Copy link
Copy Markdown
Contributor Author

@komi1230 I'm glad you contributed, and your original change added a feature that I also wanted have in winit. Actually I still want this feature but we will need a separate API for IME to do it right.

@ArturKovacs

Copy link
Copy Markdown
Contributor Author

@madsmtm did I address all your concerns and would you say that this can be merged?

@madsmtm

madsmtm commented Jan 2, 2022

Copy link
Copy Markdown
Member

Yup, go ahead!

@ArturKovacs
ArturKovacs merged commit 6b250a7 into rust-windowing:master Jan 2, 2022
@ArturKovacs
ArturKovacs deleted the revert-1979 branch January 2, 2022 21:01
This was referenced Jan 2, 2022
@komi1230

komi1230 commented Jan 6, 2022

Copy link
Copy Markdown
Contributor

As the current status, Japanese input method still doesn't work by merging this change and Chinese input method accidentally works fine.
We should add new API to handle pre-edit text as @ArturKovacs says.

I am Alacritty user with Japanese language, so I have big motivation to fix this issue.

In the below code, there is is_synthetic field in struct KeyboardInput in enum WindowEvent.
I looked up how to use this field but I'm not sure.

winit/src/event.rs

Lines 251 to 264 in 1b3b82a

KeyboardInput {
device_id: DeviceId,
input: KeyboardInput,
/// If `true`, the event was generated synthetically by winit
/// in one of the following circumstances:
///
/// * Synthetic key press events are generated for all keys pressed
/// when a window gains focus. Likewise, synthetic key release events
/// are generated for all keys pressed when a window goes out of focus.
/// ***Currently, this is only functional on X11 and Windows***
///
/// Otherwise, this value is always `false`.
is_synthetic: bool,
},

To implement new API to handle pre-edit text, should we add new field for this ?

@ArturKovacs

Copy link
Copy Markdown
Contributor Author

To implement new API to handle pre-edit text, should we add new field for this ?

I don't think that's a good approach. I think we will need a new WindowEvent kind. See the following thread for discussion about this: #1497

@madsmtm madsmtm mentioned this pull request Jan 7, 2022
5 tasks done
@komi1230 komi1230 mentioned this pull request Jan 11, 2022
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - appkit Affects the AppKit/macOS backend

Development

Successfully merging this pull request may close these issues.

Version 0.26.0 breaks macOS IME

4 participants