302 Commits

Author SHA1 Message Date
Bruno Leroux
ed7aea9a05 [Linux] Synthesize modifier keys events on pointer events (flutter/engine#37491)
Co-authored-by: Bruno Leroux <bruno.leroux@gmail.com>
2022-11-21 20:34:41 +00:00
gaaclarke
af036b8857 Turned on performance-unnecessary-value-param everywhere. (flutter/engine#37447)
* Turned on performance-unnecessary-value-param everywhere.

* linux host additions

* ios patch

* reverted bad fix

* revert bad fix

* another ios patch

* removed lint fix printer
2022-11-09 20:55:13 +00:00
Bruno Leroux
f6c5601c2f [Lixux] fix pressing Shift+AltLeft throws (flutter/engine#37079) 2022-10-29 03:51:57 +00:00
Joel Winarske
93a55ddeeb Enable cross compile of Linux GTK embedder (flutter/engine#36056) 2022-09-22 13:03:47 -07:00
Robert Ancell
42c4e6191f Fix wrong use of fl_method_call_respond arguments in documentation (flutter/engine#35247) 2022-08-29 09:48:08 -07:00
J-P Nurmi
6321cd7b64 [Linux][FlView] guard against disconnecting a disconnected signal (flutter/engine#35490)
GObject's dispose() method may be called multiple times. Guard against
trying to disconnect the same signal multiple times by clearing the ID
to avoid warnings when closing the window.

```
(bug:74019): GLib-GObject-WARNING **: 11:15:08.697: ../../../gobject/gsignal.c:2731: instance '0x55e1c3ea0200' has no handler with id '255'
```
2022-08-25 13:27:20 -07:00
J-P Nurmi
5ced18fed0 [Linux] use top-level GTK IM client window (flutter/engine#35272)
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
2022-08-09 16:55:41 -07:00
J-P Nurmi
bacc6eb5cc [Linux] remove AtkText stub implementation (flutter/engine#34839)
When Orca has "Speak object under mouse" enabled, it tries to get the
text range extents for any object that implements the AtkText interface
and gets a bit confused by our AtkText stub implementation that merely
returns null for `get_text`.

Removing the stub implementation helps to avoid the issue that Orca
would try to call `atk_text_get_range_extents()` with `start_offset=0`
and `end_offset=0`:

> Atk-CRITICAL **: atk_text_get_range_extents: assertion 'start_offset >= 0 && start_offset < end_offset' failed
2022-08-04 11:33:55 -07:00
Tong Mu
ee2970fc03 [Keyboard, Linux] Disconnect keymap signal on dispose (flutter/engine#34488) 2022-07-07 15:06:47 +12:00
J-P Nurmi
625f971298 [Linux] do not destroy unowned GdkKeymap instance (flutter/engine#34351)
`gdk_keymap_get_for_display()` does not transfer ownership to the
caller. Destroying the keymap object would cause problems further down
the road when `GtkWindow` gets to clean up and tries to destroy the
same keymap.
2022-06-29 11:25:52 +12:00
godofredoc
de593702de Add gen_snapshot to flutter_gtk. (flutter/engine#34287) 2022-06-27 17:00:06 +00:00
J-P Nurmi
4eb93fed5a Fix build on Linux (flutter/engine#34312)
* Fix build on Linux

The MockBinaryMessenger tweaks applied by #33955 caused the newly added
tests in #33313 to not build.

* Fix clang-tidy failures
2022-06-27 08:03:37 -07:00
J-P Nurmi
433ac149bf [Linux][A11y] implement AtkEditableText interface (flutter/engine#33955)
* Make FlAccessibleNode derivable

This allows introducing specialized subclasses that implement such a11y
interfaces as AtkEditableText that should not be implemented for the
generic node.

* FlAccessibleNode: add set value, text selection & perform action

Prepare API required for the upcoming AtkEditableText implementation.

* FlViewAccessible: postpone child node creation

This changes the a11y node creation flow so that (unknown) child nodes
are not pre-created when their parent is updated but "pending" child
node IDs are collected for later. Parent-child relationships are
established at the end of update batches when all nodes have been
created.

* Add FlAccessibleTextField that implements AtkEditableText

Solves: flutter/flutter#103191
2022-06-27 10:11:40 +12:00
J-P Nurmi
514b0a43b8 [Linux][A11y] report disabled animations and high contrast accessibility features (flutter/engine#33313)
* FlEngine: add fl_engine_update_accessibility_features()
* FlSettings: add API for high-contrast & animations
* FlEngine: allow passing mock messenger at construction time
* FlSettingsPlugin: report accessibility features
2022-06-27 10:10:55 +12:00
J-P Nurmi
d79e1196c9 [Linux] remove duplicate clone_string() in favor of g_strdup() (flutter/engine#34031)
GLib's g_strdup() offers the same behavior that it returns NULL if the
argument is NULL: https://docs.gtk.org/glib/func.strdup.html
2022-06-24 12:24:33 -07:00
Tong Mu
ee0e8303fb [Keyboard] Mark generated file names with infix .g. (flutter/engine#34123)
* Impl

* Format
2022-06-23 20:02:33 -07:00
Chris Bracken
53a9648da9 [lint] Merge impeller .clang-tidy into main config (flutter/engine#33692)
Merges most (but not all) of the impeller .clang-tidy rules into the
main .clang-tidy config. Merges:

readability-identifier-naming.PrivateMemberSuffix (_)
readability-identifier-naming.EnumConstantPrefix (k)
modernize-use-default-member-init.UseAssignment
Does not merge:

readability-identifier-naming.PublicMethodCase (CamelCase)
readability-identifier-naming.PrivateMethodCase (CamelCase)
These last two are not merged due to the non-trivial number of existing
field accessors that use field_name() methods to directly return
field_name_. While these are permitted by the C++ style guide, we may
want to move to a single, simple rule and name everything in CamelCase.
These can be enabled in a followup patch.

No new tests added, since this change is style-only.
2022-06-21 11:52:42 -07:00
J-P Nurmi
b7bfa342dd [Linux] Test text input (flutter/engine#34186)
This PR finishes what #33661 and #33111 started - most of `FlTextInputPlugin` is now covered by tests.
2022-06-21 10:03:30 -07:00
J-P Nurmi
024fd472b8 [Linux][Testing] reduce the boilerplate for MockBinaryMessenger (flutter/engine#34029)
Let MockBinaryMessenger internally manage the FlBinaryMessenger wrapper
instance and provide it via operator FlBinaryMessenger*() to avoid
having to create two objects in every test. The same technique was used
for MockSettings in #32618.
2022-06-21 09:07:05 +12:00
godofredoc
5e932a2524 Fixes for gn artifacts. (flutter/engine#34152) 2022-06-18 04:23:04 +00:00
J-P Nurmi
f7d46e29c2 [Linux] take first steps towards testable text input (flutter/engine#33661)
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.
2022-06-10 11:17:22 -07:00
Chris Bracken
56fbdd0232 [lint] Enforce k prefix for global constants (flutter/engine#33666)
Enforces that all global constants are prefixed with a 'k' as per the
style guide and updates the codebase into conformance where necessary.

This does not change any public API.

Additional testing provided by the addition of the lint rule.

Ref: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#begin-global-constant-names-with-prefix-k
2022-05-27 18:33:38 -07:00
J-P Nurmi
f35001f852 [Linux] fix typos in FlAccessibleNode docs (flutter/engine#32651) 2022-05-27 13:28:31 -07:00
J-P Nurmi
12ac248051 [Linux] FlTextInputPlugin: use FlView as GTK IM client window (flutter/engine#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](f2e0d91b59/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).
2022-05-26 13:08:06 -07:00
Sophie Winter
86379d5cb3 Force GTK IM context to initialize at start (flutter/engine#32118)
Fixes https://github.com/flutter/flutter/issues/100385
2022-05-26 13:07:34 -07:00
Callum Moffat
bef8075011 Linux trackpad gestures (flutter/engine#31592) 2022-05-23 16:53:06 -07:00
J-P Nurmi
f0703acbed [Linux][A11y] use ATK_ROLE_PASSWORD_TEXT for obscured text (flutter/engine#33179) 2022-05-13 09:06:54 +12:00
J-P Nurmi
7c79154e8f [Linux] read settings from XDG desktop portal if available (flutter/engine#33100)
* [Linux] read settings from XDG desktop portal if available

Fixes: flutter/flutter#101438
2022-05-13 09:06:29 +12:00
J-P Nurmi
8a485f85fd [Linux] add FlViewAccessible tests (flutter/engine#32769)
* [Linux] make FlViewAccessible testable

Add construct-only 'engine' property to make it possible to inject a
mock engine.
2022-05-11 09:16:10 +12:00
godofredoc
1df74f0938 Fix gtk targets for arm64 artifacts. (flutter/engine#33130) 2022-05-05 09:54:08 -07:00
Tong Mu
e6f56a53ff [Linux] Make unit tests abort on critical errors, and fix two such errors (flutter/engine#32348) 2022-04-28 15:24:05 -07:00
J-P Nurmi
ef3ff4212e [Linux] add missing ATK_STATE_SENSITIVE flag (flutter/engine#32487)
Fixes: flutter/flutter#101500
2022-04-27 09:19:57 +12:00
J-P Nurmi
050055f52c [Linux] fix and test light vs. dark theme detection (flutter/engine#32618) 2022-04-26 10:39:03 -07:00
Tong Mu
d5820083a5 [Linux, Keyboard] Derive keyboard layout using printable information from system (flutter/engine#32665)
* Workable layout deduction

* Compilable test

* Tests

* Remove print, format

* Use new way to pass logical key

* Use unique_ptr

* Format

* Fix matrix format

* Format

* Cleanup

* Remove duplicate

* Remove printf

* Update shell/platform/linux/fl_keyboard_manager.cc

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>
2022-04-21 00:48:22 -07:00
William Wold
59fa2c79e1 Linux/GTK: Do not jump cursor to start on preedit change (flutter/engine#32083)
Fixes https://github.com/flutter/flutter/issues/97032
2022-04-20 10:34:03 -07:00
J-P Nurmi
1bfba47c48 [Linux] add MockSignalHandler for testing GObject signals (flutter/engine#32650) 2022-04-14 13:19:05 -07:00
J-P Nurmi
4248b9b708 [Linux] add (Fl)MockBinaryMessenger for GMock (flutter/engine#32649) 2022-04-14 13:14:05 -07:00
J-P Nurmi
0002a8f57c [Linux] add GTest printer for FlValue (flutter/engine#32652)
Improves test failure messages when matching FlValue arguments.

For example, before:

  Expected arg #2: has setting ("platformBrightness", 0x32f0980)
           Actual: 0x7f81ec005990, 0x32f0900

And after:

  Expected arg #2: has setting ("platformBrightness", dark)
           Actual: 0x27bded0, {textScaleFactor: 0.0, alwaysUse24HourFormat: false, platformBrightness: light}
2022-04-14 10:52:51 +12:00
J-P Nurmi
f47c6428ec [Linux] add missing AtkObject::get_index_in_parent implementation (flutter/engine#32499) 2022-04-12 20:44:05 -07:00
Tong Mu
fd61f28c45 [Linux, Keyboard] Extract KeyboardManager's external dependencies as ViewDelegate; Rework testing framework (flutter/engine#32305) 2022-04-12 14:19:04 -07:00
J-P Nurmi
e2c68680b7 [linux] fix accessibility roles for radios and switches (flutter/engine#32454) 2022-04-07 16:16:03 -07:00
Tong Mu
60a3850cf5 [Linux, Keyboard] Make keyboard tests use unique_ptr and vector (flutter/engine#32372)
* Tester

* redispatched

* Correct events

* Format

* CallRecord

* nonnulaable call_records

* dispatch unique_ptr

* Remove print

* format

* Remove print

* Update shell/platform/linux/fl_keyboard_manager.h

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>
2022-03-31 19:34:02 -07:00
Tong Mu
13e62bd9c7 [Linux, Keyboard] Convert duplicate down events to repeat events (flutter/engine#32261) 2022-03-25 16:36:08 -07:00
Renzo Olivares
0d9b02f227 Linux deltas double free and newline fix (flutter/engine#32168)
* Fix double free

* Fix entering a newline

* Formatting

Co-authored-by: Renzo Olivares <roliv@google.com>
2022-03-22 12:13:13 -07:00
Robert Ancell
8aa424bd89 Changed the default a11y node role from ATK_ROLE_FRAME to ATK_ROLE_PANEL (flutter/engine#31602) 2022-03-10 22:55:11 -08:00
Robert Ancell
6f6f57f38f Fix signals adding/removing a11y nodes in Linux. (flutter/engine#31601) 2022-03-10 22:50:06 -08:00
Robert Ancell
b58e7be9b6 Set a11y roles for checks, toggles and sliders. (flutter/engine#31600) 2022-03-10 22:40:05 -08:00
Robert Ancell
d3517e43a9 Generate a11y events for widgets that use kFlutterSemanticsFlagIsToggled (flutter/engine#31582) 2022-03-10 22:35:10 -08:00
Justin McCandless
53425594be Bugfix: linux deltas should use selection here, not composing (flutter/engine#31906)
Fix for TextEditingDeltas composing case.
2022-03-09 13:25:02 -08:00
Chris Bracken
8335c02fd1 [Linux] Fix CJK input (flutter/engine#31813)
Fixes an issue with CJK IMEs wherein a text input state update may be
sent to the framework that misleads the framework into assuming that IME
composing has ended.

As an example, when inputting Korean text, characters are built up keystroke by
keystroke until the point that either:

* the user presses space/enter to terminate composing and commit the
  character, or;
* the user presses a key such that the character currently being
  composed cannot be modified further, and the IME determines that the
  user has begun composing the next character.

The following is an example sequence of events for the latter case:

1. User presses ㅂ. Begin compose event followed by change event
   received with ㅂ. Embedder sends state update to framework.
2. User presses ㅏ. im_preedit_changed_cb with 바. Embedder sends state
   update to framework.
3. User presses ㄴ. im_preedit_changed_cb with 반.  Embedder sends state
   update to framework.
4. User presses ㅏ. At this point, the current character being composed
   (반) cannot be modified in a meaningful way, and the IME determines
   that the user is typing 바 followed by 나. im_commit_cb received with
   바, immediately followed by im_preedit_changed event with 나.

In step 4, we previously sent two events to the framework, one
immediately after the other:

* im_commit_cb triggers the text input model to commit the current
  composing region to the string under edit. This causes the composing
  region to collapse to an empty range.
* im_preedit_change_cb triggers the text input model to insert the new
  composing character and set the composing region to that character.

Conceptually, this is an atomic operation. The fourth keystroke causes
the 반 character to be broken into two (바 and ㄴ) and the latter to be
modified to 나. From the user's point of view, as well as from the IME's
point of view, the user has NOT stopped composing, and the composing
region has simply moved on to the next character.

Flutter has no concept of whether the user is composing or not other
that whether a non-empty composing region exists. As such, sending a
state update after the commit event misleads the framework into
believing that composing has ended. This triggers a serious bug:

Text fields with input formatters applied do not perform input
formatting updates while composing is active; instead they wait until
composing has ended to apply any formatting. The previous behaviour
would thus trigger input formatters to be applied each time the user
input caused a new character to be input. This has the add-on negative
effect that once formatting has been applied, it sends an update back to
the embedder so that the native OS text input state can be updated.
However, since the commit event is immediately followed by a
preedit change, the state has changed in the meantime, and the embedder
is left processing an update (the intermediate state sent after the
commit) which is now out of date (i.e. missing the new state from the
change event).

The source of this bug is as follows:
* Commit event for a character/compose region is sent from the engine.
  The engine TextInputModel still models its `composing` field as true.
  An update is sent to the framework with the committed text and an
  empty composing range such as (1, 1). Note that the engine previously
  only sends a range of (-1, -1) when composing has ended, NOT just when
  it has an empty composing region.
* Framework receives commit event and updates the text to match. The
  framework does not model the system composing state; instead its
  understanding of whether the user is composing or not is entirely
  predicated on whether the composing region is empty or not. If it is,
  it triggers input formatters, which in this case have no effect on the
  text/selection. However, the framework consistently models empty
  compose regions as (-1, -1) and resets the text editing value as such.
  Because the framework triggered a change to the TextEditingValue, it
  dutifully sends the update back to the engine.
* In the meantime, in parallel with the above step, the engine starts
  processing the change event immediately following the commit, and
  updates the text and composing region with the next character. This
  change is promptly stomped on by the incoming framework update.

To avoid this, we have the engine consistently send empty compose
regions as (-1, -1) to the framework. After the input formatter is
applied on commit, the compose region is still (-1, -1) and there are
therefore no diffs, and the framework will not send an update back to
the engine and stomp on any new state on the engine side.

Longer-term, we really should add some form of versioning information to
the text edit protocol so as to detect and resolve conflicts rather than
relying entirely on not creating races in the first place.

This bug was revealed by flutter/flutter#90211
which applies an input formatter to single-line text fields in order to
suppress newlines.

Issue: flutter/flutter#97174
2022-03-04 11:39:26 -08:00