On Tue, 25 Apr 2023 19:13:14 GMT, Martin Fox <d...@openjdk.org> wrote:
>> This replaces obsolete XIM and uses gtk api for IME. >> Gtk uses [ibus](https://github.com/ibus/ibus) >> >> Gtk3+ uses relative positioning (as Wayland does), so I've added a Relative >> positioning on `InputMethodRequest`. > > I see that this PR changes the behavior of dead keys. You may be aware of > this but I thought I would write this up for others to review. > > In the past when the user pressed a dead key they got no feedback until they > pressed the next key at which point the final character would appear. With > this PR when the user presses a dead key they get a preview of the diacritic > which looks the same as previewing text from an IME. > > This is a change from the old JavaFX behavior but not necessarily a bug. In > fact it matches the new behavior of Ubuntu. I'm not sure when they made the > switch but in Ubuntu 18 there was no diacritic preview and in Ubuntu 22 there > is. It also matches the way the Mac works. > > At the API level this changes the event stream. In the past the dead key only > generated an incorrectly encoded RELEASED KeyEvent. The fully composed > character was then delivered as the commit string in an InputMethodEvent. > With this PR the (sort of bogus) RELEASED KeyEvent goes away and is replaced > by an InputMethodEvent that delivers the preview diacritic in the compose > string. > > One minor detail: after entering a dead key the cursor moves to a point > before the preview diacritic instead of after it. That looks like a bug and > doesn't match the way other parts of Ubuntu behave. @beldenfox Thanks for taking your time to look at this. I have fixed the preview diacritic caret position. @beldenfox I'm getting the bogus KEY_RELEASED event you mentioned. It's weird because tbe dead key produces a KEY_RELEASED but not a KEY_PRESS. Edit: bool WindowContextBase::im_filter_keypress(GdkEventKey *event) { return gtk_im_context_filter_keypress(im_ctx.ctx, event); } This is why. I will check, but I think dead keys should either produce both KEY_PRESS and KEY_RELEASED or none. I have attached a simple test app on [JDK-8305418](https://bugs.openjdk.org/browse/JDK-8305418) On Windows (using the test app mentioned) I get when typing é: Pressed: ´ Pressed: e Released: e I think it should have a Released event with ´, shouldn't it? Also Windows does not deliver the `InputMethodEvent.INPUT_METHOD_TEXT_CHANGED` event. > modules/javafx.graphics/src/main/native-glass/gtk/glass_key.cpp line 58: > >> 56: >> 57: // This function exists because gdk_keyval_to_unicode won't translate >> dead keys >> 58: guint32 glass_gdk_keyval_to_unicode(guint keyval) { > > I don't think this routine is needed. You only need Unicode text for a TYPED > KeyEvent and dead keys don't generate those. `notifyKey` will just ignore any > text you pass in for PRESSED or RELEASED events. I was doing some experimentation. But your're right, removed it. ------------- PR Comment: https://git.openjdk.org/jfx/pull/1080#issuecomment-1537228963 PR Comment: https://git.openjdk.org/jfx/pull/1080#issuecomment-1537240046 PR Review Comment: https://git.openjdk.org/jfx/pull/1080#discussion_r1194958983