-
Notifications
You must be signed in to change notification settings - Fork 6k
[Linux] FlTextInputPlugin: use FlView as GTK IM client window #33111
Conversation
GTK IM operates in coordinates relative to its client window. Let GTK IM use the native window that backs FlView, which is the same native window that is used for key event processing - see GDK_KEY_XXX_MASK in fl_view_realize(). This is an important step towards testable FlTextInputPlugin because it eliminates the dependency to GtkWidget's coordinate translation API and that way paves the road for replacing FlTextInputPlugin's FlView instance with a plain GdkWindow. In tests, that window can be an instance of GdkOffscreenWindow.
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Ping @robert-ancell @cbracken |
cbracken
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code change itself LGTM. I'll ping @Hixie for a test exemption given the goal of this chain of refactorings is to enable testing of this code, and that tests are already written in your branch.
Please wait until @Hixie has reviewed/approved before merging.
|
test-exempt: has tests already planned |
|
@cbracken May I land this please? |
|
Thanks! I've pushed the next step: |
This PR is a continuation of #33111 and includes necessary changes to test the `TextInputType.setClient()` platform channel call. Testing the actual text input flow requires a mock IM context that will follow in a separate PR. * [Linux] pass GdkWindow instead of FlView to FlTextInputPlugin * [Linux] add MockBinaryMessenger::ReceiveMessage() * [Linux] add test for TextInputType.setClient * Drop the offscreen window GdkOffscreenWindow requires display & screen which is a problem in headless mode. Luckily, we don't really need a window instance in tests because its only passed as a client window to the IM context which will be mocked out when we get to tests that depend on it.
…r#33111) GTK IM operates in [coordinates relative to its client window](https://docs.gtk.org/gtk3/method.IMContext.set_cursor_location.html#:~:text=The%20location%20is%20relative%20to%20the%20client%C2%A0window.). Let GTK IM use the native window that backs FlView, which is the same native window that is used for key event processing - see GDK_KEY_XXX_MASK in fl_view_realize(). This is an important step towards testable FlTextInputPlugin because it eliminates the depency to GtkWidget's coordinate translation API and that way paves the road for replacing FlTextInputPlugin's FlView instance with a plain GdkWindow. In tests, that window can be an instance of GdkOffscreenWindow. There are no tests included yet but after a few more refactoring steps it will be possible to execute tests like this: [fl_text_input_plugin_test.cc](https://github.com/jpnurmi/engine/blob/f2e0d91b59c0375d08fcc1397d164827168725d7/shell/platform/linux/fl_text_input_plugin_test.cc). The other refactoring steps are visible at [jpnurmi/engine/commits/text-input-plugin](https://github.com/jpnurmi/engine/commits/text-input-plugin).
This PR is a continuation of flutter#33111 and includes necessary changes to test the `TextInputType.setClient()` platform channel call. Testing the actual text input flow requires a mock IM context that will follow in a separate PR. * [Linux] pass GdkWindow instead of FlView to FlTextInputPlugin * [Linux] add MockBinaryMessenger::ReceiveMessage() * [Linux] add test for TextInputType.setClient * Drop the offscreen window GdkOffscreenWindow requires display & screen which is a problem in headless mode. Luckily, we don't really need a window instance in tests because its only passed as a client window to the IM context which will be mocked out when we get to tests that depend on it.
This PR takes a step back and changes the GTK IM client window back from FlView to GtkApplicationWindow as it was before #33111. The window was originally changed to FlView to make the code testable by cutting a dependency to gtk_widget_translate_coordinates(). The change was hard to revert because there were several conflicting changes on top. Therefore, this PR introduces an FlTextInputViewDelegate to be able to provide coordinate mapping in a testable way. Fixes: flutter/flutter#108832
This PR takes a step back and changes the GTK IM client window back from FlView to GtkApplicationWindow as it was before flutter#33111. The window was originally changed to FlView to make the code testable by cutting a dependency to gtk_widget_translate_coordinates(). The change was hard to revert because there were several conflicting changes on top. Therefore, this PR introduces an FlTextInputViewDelegate to be able to provide coordinate mapping in a testable way. Fixes: flutter/flutter#108832
GTK IM operates in coordinates relative to its client window. Let GTK
IM use the native window that backs FlView, which is the same native
window that is used for key event processing - see GDK_KEY_XXX_MASK in
fl_view_realize().
This is an important step towards testable FlTextInputPlugin because it
eliminates the depency to GtkWidget's coordinate translation API and
that way paves the road for replacing FlTextInputPlugin's FlView
instance with a plain GdkWindow. In tests, that window can be an
instance of GdkOffscreenWindow.
There are no tests included yet but after a few more refactoring steps
it will be possible to execute tests like this: fl_text_input_plugin_test.cc.
The other refactoring steps are visible at jpnurmi/engine/commits/text-input-plugin.
Pre-launch Checklist
///).