203 Commits

Author SHA1 Message Date
Tong Mu
adb05f30f7 Migrate keyboard_key_handler_unittests to keyboard_win32_unittests (flutter/engine#30615)
* Refactor to MockKeyResponseController (ATP)

* Implement LateResponding and move GetEngine in (ATP)

* RespondValue

* DisorderlyRepliedEvents

* SlowFrameworkResponse

* NeverRedispatchShiftRightKeyDown

* Migrate AltGr event. (ATP)

* Correctly handle sys messages.

* Remove SendInputInfo

* Comment and format
2022-01-05 17:19:14 -08:00
Tong Mu
4cfe108309 [Win32, Keyboard] TextInputPlugin is no longer a KeyboardHandlerBase (flutter/engine#30456)
* Impl

* format

* Comment
2022-01-05 04:09:32 -08:00
Chris Bracken
e9eeafb871 Fix incorrect test names (flutter/engine#30385)
There were two tests in the FlutterWindowsView tests that were tagged as
FlutterWindowsEngine tests. This corrects those.
2021-12-16 15:23:05 -08:00
Chris Bracken
6a6541b4de Windows: Implement IAccessible hit testing (flutter/engine#30366)
IAccessible objects should implement accHitTest. Our implementation, in
AXPlatformNodeWin, delegates hit testing to
AXPlatformNodeDelegate::HitTestSync. Here, we do a quick recursive
depth-first walk of the accessibility tree to return the best match.

We define the best match as the deepest node in the tree that contains
the point under test whose children do not.

Issue: https://github.com/flutter/flutter/issues/77838
2021-12-16 10:13:15 -08:00
Tong Mu
3fface0f66 [Win32, Keyboard] Abstract KeyboardManager from FlutterWindowWin32 (flutter/engine#30296) 2021-12-14 17:54:03 -08:00
Chris Bracken
a9722681ef Support toggle buttons for desktop accessibility (flutter/engine#30297) 2021-12-13 11:04:05 -08:00
Chris Bracken
2474482021 Override FlutterPlatformNodeDelegate::GetUniqueId (flutter/engine#30261)
The default implementation of GetUniqueId on ui::AXPlatformNodeDelegate
always returns ID 1. We had previously implemented this on the windows
platform node delegate, but for consistency's sake, and because the
default implementation is surprising, we're promoting this to the
FlutterPlatformNodeDelegate base class.

Issue: https://github.com/flutter/flutter/issues/77838
2021-12-10 10:05:00 -08:00
Chris Bracken
616ed57c9b Simplify win32 platform node delegate GetParent (flutter/engine#30258)
In the Win32 accessibility tree, each AXTree node has an associated
IAccessible object. In WindowWin32, our WM_GETOBJECT handler returns the
IAccessible associated with the root node of the tree (node 0). On other
platforms, we often add our root accessibility object as a subnode of
some existing accessibility object associated with the view. On Windows,
the root IAccessible _is_ the accessibility object associated with the
view (on Windows, and HWND).

In the previous implementation, AccessibleObjectFromWindow actually just
returns the root IAccessible object, which is equivalent to just
returning GetNativeViewAccessible. Instead, we just return null once we
hit the root of the tree.

Issue: https://github.com/flutter/flutter/issues/77838
2021-12-09 19:29:11 -08:00
Chris Bracken
01b8db3de9 Call IAccessible::accFocus to move a11y focus (flutter/engine#30256)
On receipt of a FOCUS_CHANGED event from the AX tree, call
IAccessible::accFocus to tell screen readers to move the accessibility
focus to that node. This is in addition to setting the keyboard focus
via the EVENT_OBJECT_FOCUS event.

Issue: https://github.com/flutter/flutter/issues/77838
2021-12-09 15:58:07 -08:00
Chris Bracken
5992275cdb Win32: Handle OnAccessibilityEvent (flutter/engine#30176)
Implements OnAccessibilityEvent, which translates events from the AXTree
into Windows MSAA event notifications.

This also eliminates the UIA root object lookup in response to
WM_GETOBJECT, since our initial implementation, like Chromium's default
implementation, is based on MSAA.

Issue: https://github.com/flutter/flutter/issues/77838
2021-12-09 14:38:24 -08:00
Chris Bracken
0d41ebed6a Implement GetUniqueId on Windows node delegates (flutter/engine#30204)
`AXPlatformNodeDelegate` provides a default implementation of
`GetUniqueId()` which returns the same value (1) for all nodes.
`AXPlatformNodeWin` relies on a unique ID being returned from this
method in its `GetTargetFromChildID` method.

In the world MSAA accessibility, each `HWND` may have a root
`IAccessible` object associated with it. Events are fired by calling the
`NotifyWinEvent` Win32 call and specifying:

1. The `HWND` (in our case, the one associated with our `WindowWin32`)
2. The target object (`OBJID_CLIENT` for the root `IAccessible`
   associated with that `HWND`)
3. A child identifier that uniquely identifies the target node in the
   tree

This child identifier can be one of:

* `CHILDID_SELF` for events targeting the root `IAccessible`.
* A positive integer that specifies the index of a direct child of the
  root.
* A negative integer which, when negated, specifies the unique ID of a
  child within the tree.

On receipt of an accessibility event, `AXPlatformWin` (our `IAccessible`
implementation) looks up the target `IAccessible` from the child ID
specified on the event using its `GetTargetFromChildID` method and
delegates the appropriate method call to that object.

So, why is this implemented on our `AXPlatformNodeDelegate` subclass and
not on `AXPlatformNodeWin` itself? Because the implementation of
`AXPlatformNode::GetUniqueId()` delegates this lookup to the node
delegate.

As background, `AXUniqueId` automatically assigns itself a
globally-unique value in its constructor; it tracks all used values in
an internal static pool.

Issue: https://github.com/flutter/flutter/issues/77838
2021-12-08 09:41:46 -08:00
Chris Bracken
0189aaaca1 Win32: Implement DispatchAccessibilityAction (flutter/engine#30187)
Implements DispatchAccessibilityAction: a pass-through method that
forwards to the engine, which calls through the Embedder API back to the
framework.

Issue: https://github.com/flutter/flutter/issues/77838
2021-12-07 11:07:45 -08:00
Chris Bracken
334a0c6ff9 Use MallocMapping for DispatchSemanticsAction data (flutter/engine#30149)
In the Windows embedder, the data parameter of
FlutterWindowsEngine::DispatchSemanticsAction was a vector of bytes.
Here, we switch it to use MallocMapping since that is the type of the
data paramater on the DispatchAccessibilityAction method of
AccessibilityBridgeDelegate, which calls this method. This avoids an
extra type conversion.
2021-12-06 08:44:41 -08:00
Tong Mu
5d28d76321 [Windows keyboard] Remove redundant parameter FlutterWindowsView (flutter/engine#30086) 2021-12-02 15:39:01 -08:00
Tong Mu
fdc78e4146 [Win32, keyboard] Fix dead key events that don't have the dead key mask (flutter/engine#30004)
This PR fixes flutter/flutter#92654, a rare case where dead key events are not properly handled.
2021-12-01 00:49:44 -08:00
Chris Bracken
22c822564d Win32: add test of native a11y tree nodes (flutter/engine#29993)
Adds AddSemanticsNodeUpdateWithChildren, which tests that the native
tree of IAccessible COM objects is an accurate representation of the
platform-agnostic accessibility tree.

Issue: https://github.com/flutter/flutter/issues/77838
2021-11-29 15:34:05 -08:00
Chris Bracken
f8dfe2fab4 Win32 a11y bridge and platform node delegates (flutter/engine#29829)
* Win32 a11y bridge and platform node delegates

This is the third in a series of patches adding accessibility support
for the Windows embedder. This patch wires in the Accessibility bridge,
and lands the core structure of the Windows FlutterPlatformNodeDelegate
and AccessibilityBridgeDelegate classes, including:

* Instantiating the AccessibilityBridge when the semantics tree is
  enabled.
* Creating FlutterPlatformNodeDelegate wrappers for semantics tree
  nodes.
* Handling custom action updates.
* Building and updating the accessibility tree on semantics updates.
* Returning the native IAccessible objects when queried.

Breaking this out so that the follow-up patches can be reviewed and
landed in smaller, independent chunks.

Issue: https://github.com/flutter/flutter/issues/77838
Issue: https://github.com/flutter/flutter/issues/93928
2021-11-29 13:23:42 -08:00
Chris Bracken
5b6219cb49 [Win32] Use mock macro for UpdateSemanticsEnabled (flutter/engine#29976)
Previously, we'd mocked out UpdateSemanticsEnabled using a simple
lambda. Due to the embedder API's C ABI, we were unable to make use of
lambda captures. This patch instead uses MOCK_ENGINE_PROC so we can make
the test variable a local and rely on lambda capture.

Issue: https://github.com/flutter/flutter/issues/77838
2021-11-29 10:39:54 -08:00
Niklas Schulze
1306ea59ec winuwp: Add multi-touch support (flutter/engine#28067) 2021-11-18 13:03:03 -08:00
Greg Spencer
a079a95ef7 Fix Kanji switch in Japanese IME on WIndows (flutter/engine#29761) 2021-11-16 19:08:01 -08:00
Brandon DeRosier
0d67e4e080 Use Fuchsia's Windows Clang SDK (flutter/engine#29736) 2021-11-13 21:22:55 -08:00
Greg Spencer
8c6d3d2492 Check for both compose string and result string. (flutter/engine#29620)
It turns out that unlike the Microsoft IME, Sogou sends a single IME_COMPOSITION message that has both the GCS_COMPSTR and GCS_RESULTSTR flags set, and we check for a composition string before result string, with an "else" clause to check for the result string, so if GCS_COMPSTR is set, we never check for a result string.
2021-11-12 14:55:28 -08:00
George Wright
e372826773 Remove D3D9 fallback path (flutter/engine#29533) 2021-11-04 14:33:25 -07:00
Brandon DeRosier
9979f27436 Fix TaskRunnerTest.MaybeExecuteTaskOnlyExpired flake (flutter/engine#29484)
* Fix windows flake

* Make the timing deterministic
2021-11-02 14:57:55 -07:00
Greg Spencer
ba99c3b465 Fix deleting compose string in IME (flutter/engine#29396) 2021-11-01 10:45:59 -07:00
Tong Mu
f0825fd030 [Win32, Keyboard] Fix toggled state synthesization misses up events (flutter/engine#29282)
This PR fixes a problem where up events might be missed during synthesizing for toggled states.
2021-10-27 23:14:46 -07:00
Tong Mu
79249cf134 [macOS] Reset keyboard states on engine restart (flutter/engine#29283)
With this PR, the state of the keyboard system will be reset when the engine is reset (typically during a hot restart.)
2021-10-27 17:03:41 -07:00
godofredoc
ae68d0409b Update documentation links to point to main branch. (flutter/engine#29326) 2021-10-26 10:48:02 -07:00
moko256
463e6ff6e1 Fully inplement TaskRunner for UWP (flutter/flutter#70890) (flutter/engine#28013) 2021-10-21 16:03:02 -07:00
Chris Bracken
9d6070dd18 Win32: Enable semantics on accessibility query (flutter/engine#29269)
Windows does not provide a system notification the embedder can
subscribe to to determine when a screen reader or other assistive
technology that requires the semantics tree has been enabled. [1]

In the absence of such a notification, we watch for queries for the
IAccessible COM object representing the root node of the semantics tree,
and on receipt of such queries we enable the semantics tree. For the
time being, we assume that if accessiblity is enabled, it will be
enabled for the duration of the application lifetime. In a future patch
we can optimise this by adopting the approach taken by Chromium, which
is to disable semantics if we haven't received a query within some
reasonable timeout.

This patch enables Flutter's semantics tree; a follow-up patch wires in
the AccessibilityBridge which maintains the AXTree of COM objects that
is the Windows representation of the Flutter SemanticsTree.

Issue: https://github.com/flutter/flutter/issues/77838

[1]: https://docs.microsoft.com/en-us/windows/win32/winauto/screen-reader-parameter
2021-10-21 11:42:45 -07:00
Chris Bracken
746ed52a12 Add FlutterWindowsEngine::DispatchSemanticsAction (flutter/engine#29278)
Adds method for dispatching a semantics action received from the OS to
the matching node in Flutter's semantics tree.

Issue: https://github.com/flutter/flutter/issues/77838
2021-10-20 23:33:19 -07:00
moko256
28b5d6b9a4 [UWP] Remove 1px offset to make root widget fully shown (flutter/engine#27922) 2021-10-14 13:03:01 -07:00
Chris Bracken
794db8c01b Correct file line-endings from CRLF to LF (flutter/engine#29164) 2021-10-13 12:58:01 -07:00
Chris Bracken
5e2464a14d Cancel IME composing on clear text input client (flutter/engine#29146)
When a text input client is cleared, such as when the user changes focus
from one text input widget to another, or when the window itself loses
focus, cancel IME composing mode, close the composing candidates window
(if any), and reset the composing text.

Issue: https://github.com/flutter/flutter/issues/90503
2021-10-13 10:29:29 -07:00
James Clarke
d3f3b7368e Fix build flags for WinUWP (flutter/engine#29100) 2021-10-11 09:58:02 -07:00
Tong Mu
638b129319 [Windows] Add restart hooks, and reset keyboard (flutter/engine#28970)
With this PR, the state of the keyboard system will be reset when the engine is reset (typically during a hot restart.)
2021-10-04 14:02:22 -07:00
Tong Mu
2e334c1134 Keyboard guarantee non empty events (flutter/engine#28648)
* Web

* macos

* Linux

* Easier web impl

* doc and format

* Better linux impl

* Format

* Better impl mac

* Format

* Windows

* Format

* Apply suggestions from code review

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

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>
2021-10-04 14:01:51 -07:00
moko256
b8809dde77 Windows: Add dark theme support. (flutter/engine#28131)
This PR adds the dark theme support for both windows and winuwp engine, based on flutter/flutter#54612.

On Win32: using a registry value that is not documented. (I tested on Windows 10.0.19043.1165)
On UWP: using default background color. (I couldn't find WinRT API that returns dark/light directly, without xaml package.)

Flutter PR for win32: flutter/flutter#88520.
This PR will close flutter/flutter#54612.
This PR will complete one item in flutter/flutter#70214.
2021-09-28 11:03:18 -07:00
moko256
fecbc63bec [UWP] Implement clipboard. (flutter/engine#28064)
This PR implements clipboard in platform handler in UWP.
2021-09-27 17:01:42 -07:00
moko256
00ca12c712 [UWP] Add modifier keys support (flutter/engine#28724)
Implement GetModsForKeyState in keyboard_key_channel_handler.cc
2021-09-27 11:19:29 -07:00
Niklas Schulze
fec4d526e3 Windows: FlutterDesktopPixelBuffer: Add optional release callback (flutter/engine#28298) 2021-09-16 13:07:02 -07:00
moko256
34985c56b4 cleanup #28098 (flutter/engine#28334) 2021-09-09 13:17:01 -07:00
moko256
4836ff6b3c [UWP] Implement setting cursor icon. (flutter/engine#28098) 2021-08-26 17:15:46 -07:00
moko256
6239e74b25 [UWP] Add mouse button support (flutter/engine#28100) 2021-08-26 13:11:02 -07:00
Justin McCandless
e00871d812 hasStrings on Windows (flutter/engine#27749) 2021-08-24 17:54:01 -07:00
Tong Mu
3868bf03da Fix dead key handling on Win32 (again) (flutter/engine#28125)
- Fix dead character crashes the channel handler.
- Fix dead key messages are redispatched, making the message a regular character message.
2021-08-17 14:26:21 -07:00
Tong Mu
1704906f59 Fix dead key crashes on Win32 (flutter/engine#28047)
This PR fixes the crash caused by pressing dead keys on Win32.
2021-08-13 01:35:58 -07:00
Niklas Schulze
f6977e39d8 Windows: Add multi-touch support (flutter/engine#27863) 2021-08-12 21:02:01 -07:00
Tong Mu
9d45378f6f Windows keyboard integration tests and fix a number of issues (flutter/engine#27921)
* Basic changes

* Fix build

* Revert some changes

* Fix tests (ATP)

* Win32Message and inject messagelist

* wm builders

* Format

* Correct

* LowerCaseAUnhandled

* ShiftLeftKeyA

* Ctrl-A

* Ctrl-1

* Digit1OnFrenchLayout

* AltGrKeyQ

* Dead key E

* ^1

* Multibyte

* Format

* License

* Revert key.dart

* Move CreateKeyEventLparam

* MockEmbedderApiForKeyboard

* More MockEmbedderApiForKeyboard

* Doc

* Move MockMessageQueue

* is_deadchar doesnt seem needed

* ConvertChar32ToUtf8

* PeekNextMessageType

* Format

* Apply suggestions from code review

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

Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>
2021-08-11 14:47:03 -07:00
moko256
846c5c5beb UWP: Fix uwptools that does not uninstall package (flutter/engine#27694) 2021-08-09 10:24:41 -07:00