* fix(macOS): always raise keyDown before the input context sees the event
AvnView passed every keyDown to the NSTextInputContext first and only
raised a KeyDown when the context did not consume the event. The context
consumes every printable key by routing it to insertText:, so while a
text input client was active no KeyDown was raised for space, letters or
digits and a KeyGesture on those keys could never match. Only modified
keys were special-cased.
keyDown: now always raises exactly one KeyDown per NSEvent before the
input context is consulted. Composition state only decides which key is
reported: while hasMarkedText is set the key is masked as
AvnKeyImeProcessed, the same way Win32 reports VK_PROCESSKEY, so user
code still observes the event but no gesture matches it. The physical key
and the key symbol keep their real values in both cases.
If user code handles the event the input context is skipped entirely, so
no text and no preedit is produced. This mirrors the Win32 behaviour of
swallowing WM_CHAR after a handled WM_KEYDOWN.
The modifier special case, the handleKeyDown: helper and
_lastKeyDownEvent are gone. doCommandBySelector: is kept but empty, since
falling back to NSResponder would perform the default action and beep.
Adds a Keyboard page to IntegrationTestApp that reports the last key
down, a key down count and the last text input, plus Appium tests
covering gestures with and without a modifier, text suppression for a
handled gesture, and a single key down per key press.
* fix(macOS): mask the composition starting key for composing input methods
hasMarkedText only becomes true once a composition is in progress, so the
keystroke that starts one was still reported with its real key and could
match a KeyGesture. Win32 reports VK_PROCESSKEY for that keystroke too.
keyDown: now also masks the key as AvnKeyImeProcessed when a printable
character key is typed into a text input client while the selected
keyboard input source is a composing input method.
Whether an input source composes is resolved through
TISGetInputSourceProperty: anything that is not a plain keyboard layout
composes, except an input method in the alphanumeric input mode, which
passes keys straight through and therefore keeps the real key. Unknown
input sources keep the real key as well, so gestures are never lost to a
failed lookup. The lookup includes installed but not enabled input
sources, since an input method mode can be selected without being listed
as enabled, and the result is cached per input source id because this runs
for every key down.
Only printable character keys are masked. KeySymbolFromScanCode reports
the control character for Backspace, Enter, Tab and Escape, so the
presence of a key symbol is not enough to decide: masking those would stop
TextBox from reacting to them, which broke Backspace while an input method
was selected. Command and Control combinations are shortcuts and are not
masked either.
Plain keyboard layouts are unaffected: dead key compositions are not
driven by the input source and stay covered by hasMarkedText.
The Keyboard page now subscribes to KeyDown and TextInput with
handledEventsToo, so keys TextBox handles in its class handler, such as
Backspace and the arrows, stay visible in the readout.
* test(macOS): skip the Keyboard tests on the Appium 1 leg
The tests synthesize key input through W3C actions, which the mac2
driver bundled with Appium 1 does not implement, so on the macOS CI leg
they could only fail. They keep running on Windows, where WinAppDriver
handles W3C actions, and on macOS builds with IsRunningAppium2, which
target a current mac2 driver. The infrastructure change that would run
them on macOS CI is split out for a separate pull request.
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* Fix TopMost handling for Popups on Windows
* Properly handle TopMost property changes
* Call SetTopMost in PopupRoot constructor (similar to SetWindowManagerAddShadowHint)
* Make sure the parent is focused when the popup is clicked directly to activate the app.
* Move PopupsPage to IntegrationTestApp
* Move Popup code to the XAML, making visual/logical management implicit
* Add popup integration tests
* Fix MenuTests+Default.Click_Grandchild by delaying popup activation
* Kill input focus when input element on popup is focused element
* try to fix tests
* try to fix test v2
* Integration tests: ensure menus get closed after testing
* run popup tests only on windows
* WIP: Removing the hack to see if anything changes.
* WIP: Removing the second hack.
I'm guessing this will fix it.
* fix to make transparent window integration app work on macOS
* fix menu tests
* Fix warning in MenuTests
* Add a background to integration test popup
---------
Co-authored-by: Maxwell Katz <maxkatz6@outlook.com>
Co-authored-by: Steven Kirk <grokys@users.noreply.github.com>
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
Toggling the window decorations can cause the window to be moved off screen, causing integration test failures. Until this bug is fixed, detect this and move the window to the screen origin. See #11411.
* Added embedding page to IntegrationTestApp.
Currently embeds a lone native text box, and only when running on Windows.
* Win32 automation support for native control host.
Allows native controls to appear in the Avalonia automation tree as a child of the `NativeControlHost`. They also appear in the _wrong_ place - as a direct child of the `Window` - but this appears to be expected behavior as it happens when hosting a win32 control in WPF as well.
* Basic native control integration test on win32.
* Test editing native win32 control in popup.
* Add embedded text box on macOS.
* macOS automation support for native control host.
Implements special-casing of `InteropAutomationPeer`on macOS.
* Make native control integration test work on macOS.
The test for the native control in a popup is disabled on macOS because we have a bug there.
* Add missing parts
* Fix build error
* Skip test to see if CI passes again.
* Log more info about integration tests on win32.
* Try to fix flaky test.
* The tests won't yet work on macOS yet.
Will require #16577.
---------
Co-authored-by: Benedikt Stebner <Gillibald@users.noreply.github.com>
Co-authored-by: Max Katz <maxkatz6@outlook.com>
* Refactor IntegrationTestApp.
Use a `ListBox` to switch pages instead of a `TabControl`: the `TabControl` didn't adapt well to smaller screen sizes, and the `MainWindow` was getting unwieldy anyway.
* Update tests to use new pager.
Move logic for selecting the page to a base class as we may need to handle scrolling manually on macOS at some point (Appium on macOS doesn't scroll elements into view automatically).
* Add AutomationPeer.IsOffscreen.
This is needed in order for controls to be scrolled into view using WinAppDriver. The default is the same as WPF and the default value is overridden in the same controls as WPF (where present).
* Draft new API
* Push reusable ScreensBaseImpl implementation
* Fix tests and stubs
* Update ScreensPage sample to work on mobile + show new APIs
* Reimplement Windows ScreensImpl, reuse existing screens in other places of backend, use Microsoft.Windows.CsWin32 for interop
* Make X11 project buildable, don't utilize new APIs yet
* Reimplement macOS Screens API, differenciate screens by CGDirectDisplayID
* Fix build
* Adjust breaking changes file (none affect users)
* Fix missing macOS Screen.DisplayName
* Add more tests + fix screen removal
* Add screens integration tests
* Use hash set with comparer when removing screens
* Make screenimpl safer on macOS as per review
* Replace UnmanagedCallersOnly usage with source generated EnumDisplayMonitors
* Remove unused dllimport
* Only implement GetHashCode and Equals on PlatformScreen subclass, without changing base Screen
* Add accessibility ID to the TrayPopupRoot on Windows
* [Windows] Add left click and menu item click e2e tests for TrayIcon
* [Windows] Add TrayIcon visibility toggle tests
* Implement macOS tray icon tests
* Make it easier to read tray icon logs
* Try to handle win10 accessibility names
* Try to upload PageSource
* Set condition: always
* Hopefully, it works on CI
* Try to upload PageSource #2
* Fix win10, hopefully for the last time
* Enable IncludeAvaloniaGenerators on integartion tests app
* Implement basic TitleBarAutomationPeer
* Add WindowDecorationsTests (windows only for now)
* Implement window decoration tests on macOS
* Fix build on appium 1
* Fix some windows tests
* Extract WindowDecorationsTests into a separated collection, so it won't conflict
* Fix build
* Fix build
* ensure owner topmost flag is set if its topmost when showing a owned window
* add comments on why HWND_TOPMOST is set again
* add Topmost with owned window integration tests
* fix tests
* Fix native menu bar tooltip
* Make ToolTip tests more reliable
* Increase MacOS_Native_Menu_Has_ToolTip_If_Defined sleep delay
* Disable MacOS_Native_Menu_Has_ToolTip_If_Defined, as it fails way too often
Integration tests for #10420:
- Adds an `--overlayPopups` command-line argument to IntegrationTestApp
- Renames `TestAppFixture` -> `DefaultAppFixture`
- Adds additional `OverlayPopupsAppFixture`
- Runs ComboBox and Menu tests in both default and overlay popups mode
- VS keeps changing the `.sln` file