UIKit doesn't report the end of the touches in progress when the view leaves
its window, for example when switching tabs with a finger held down. Their
pointers stayed in the touch device, captured to the control under the finger,
and every later touch on that view counted as a second finger, which broke
double taps. Raise a touch cancel for them, or a leave window for a pen or
trackpad pointer, like the Windows backends do.
Touches that end are now forgotten before their event is raised, so a handler
that removes the view doesn't cancel them a second time. Once a handler
cancelled them, the other touches of the same event are no longer raised.
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
Reset() made the AvaloniaView first responder before SetClient handed it to the next text box. AvaloniaView is not a text input, so UIKit dismissed the keyboard and presented it again on every focus change between text boxes.
Reset() is now a no-op, as on Android. The input method manager always calls SetClient right after it, which makes the next text box's responder first responder directly. When focus leaves text input, SetClient(null) still dismisses the keyboard.
* Keep an iOS main thread display link alive while touches are down
UIKit delivers touches at the rate the main thread is animating at, and the
render timer's display link runs on a background thread, so drags updated at
60 Hz even with a 120 Hz render timer. When the display can go above 60 Hz,
keep one process-wide main thread display link with the same frame rate
range while any view has touches down, and stop it when the last touch ends.
A view forgets its touches in progress when it leaves its window or is
disposed, since UIKit doesn't report their end then, for example when
switching tabs with a finger held down.
* Run iOS trackpad scroll momentum at the display rate with time-based decay
The momentum link decayed the velocity per callback, assuming 60 callbacks
per second, so momentum would end twice as fast at 120 Hz. Give it the
display's frame rate range and decay the velocity by elapsed time, capped at
4 frames after a stall. Behaviour at 60 Hz is unchanged.
* Use the view's screen instead of UIScreen.MainScreen on iOS
UIScreen.MainScreen is deprecated and may not be the screen the app is on
when it runs on an external display. The touch display link now checks the
touched view's screen, and the 60 Hz warning checks the screen of the window
a view moves to. Also shortens the momentum comments.
* Let the iOS render timer follow the display refresh rate
CADisplayLink runs at 60 Hz on ProMotion iPhones unless a preferred frame
rate range is set. Request CAFrameRateRange(60, 120, 120); Core Animation
picks the closest supported rate and lowers it in Low Power Mode.
iOSPlatformOptions.EnableHighRefreshRate, on by default, lets apps that can't
sustain high rates keep the system default. iPhone apps also need
CADisableMinimumFrameDurationOnPhone for rates above 60 Hz, so a warning is
logged at startup when it's missing; ControlCatalog.iOS sets it.
* Pause the iOS render timer's display link while the render loop is idle
The link kept waking its thread on every vsync after the render loop cleared
Tick. Pause it while Tick is null or the application is in the background.
CADisplayLink.paused is thread safe, so the state is updated directly, under
a lock, by whichever thread changes it.
* Implement iOS VoiceOver support
* Some investigation (it is not working)
* Progress
* Functional prototype for iOS VoiceOver support
* Improved VoiceOver control function
* Implement traits and accessibility actions for VoiceOver
* Remove unused using statement
* Default IsOffscreenBehavior should be based on IsEffectivelyVisible
* Use most specific activation function first
* Ensure that offscreen UIAccessibilityElements are removed
* Fix interrupted speech upon focusing element
* Accessibility improvements based on tests with low vision users
* More improvements to iOS VoiceOver access
* Final fixes for iOS VoiceOver
* Add informative comments
* Implement review suggestions for iOS VoiceOver
* Fixed bugs in determining whether controls are offscreen
* Ensure that AutomationPeer children are updated
* Fix failing tests for IsEffectivelyVisible & CompositorHitTesting
* Implement AccessibilityContainer for all peer wrappers
Addresses performance concerns regarding the accessibility tree
* Fix iOS VoiceOver not giving touch feedback for some labeled elements
* More garbage collection for iOS VoiceOver
* Consolidate garbage collection code for iOS VoiceOver feature
* Final fixes for new iOS VoiceOver implementation
* Pass informative parameters to UIAccessibility notifications
* Fix crashing bug with iOS VoiceOver scroll gesture
* Fix: use `IInputRoot.RootElement` to compute screen coordinates
* Fix: use more precise logic for distinguishing groups from controls
* Fix: iOS VoiceOver recognizes all container elements
* Fix: recognize `SplitButton` as container type
* Fix: include custom controls under container category
* Fix: recognize commonly templated containers
* Fix: use `HashSet` for determining whether control type maps to a container
* Fix: optimizations for iOS VoiceOver
* Fix: update accessibility properties unconditionally
* Fix: use cached state for containers
* Fix: use basic `HashSet` type for container type lookup
* Fix: include `ScrollViewer` as group control type
* Fix: remove references to `ImmutableDictionary`
* Fix: VoiceOver should read page headers
* Fix: implement support for `AutomationId` for iOS automation tree
* Fix iOS accessibility peer updates
* Fix: include recommended fixes and changes from Copilot review
* Fix: revert formatting and modified tests
* Fix iOS accessibility trait and view disposal
---------
Co-authored-by: IsaMorphic <me@isamorphic.dev>
Co-authored-by: Jumar Macato <16554748+jmacato@users.noreply.github.com>
* Add new IPlatformSettings APIs
* Add control catalog PlatformSettingsPage
* Windows PreferredApplicationLanguage implementation
* Browser PreferredApplicationLanguage implementation
* Run API suppressions for the IPlatformSettings
* Rebase PlatformSettingsPage on new ContentPage
* Return CultureInfo.InstalledUICulture instead of CultureInfo.CurrentUICulture for default PreferredApplicationLanguage implementation
* Android PreferredApplicationLanguage implementation
* iOS PreferredApplicationLanguage implementation
* Use GetUserPreferredUILanguages for Win32 implementation instead of GetUserDefaultLocaleName
* MacOS implementation of PreferredApplicationLanguage
* Use GlobalizationPreferences for WIn32 prefered language, GetUserPreferredUILanguages doesn't work as expected with Windows settigns
* Avoid AvaloniaLocator in control catalog
* Remove unused method
* Add value/remarks XML docs on the PreferredApplicationLanguage
* Correctly set ActualThemeVariant
* Don't call OnColorValuesChanged unnecessarily on Win32
* Don't call OnColorValuesChanged unnecessarily on macOS
* Change iOS PlatformSettings to match other platforms
* Don't call OnColorValuesChanged unnecessarily on Android
* Android: set theme using SetLocalNightMode
* Don't call OnColorValuesChanged unnecessarily on X11/Wayland
* Don't call OnColorValuesChanged unnecessarily on Browser
* Fix timer Start order
* Remove dead code in DBusPlatformSettings
When the iOS app uses scene-based lifecycle (iOS 13+), Apple delivers
cold-launch user activities and URL contexts via UISceneConnectionOptions
on scene:willConnectToSession:options: — NOT via the warm-path selectors
scene:continueUserActivity: or scene:openURLContexts:. AvaloniaSceneDelegate
ignored connectionOptions entirely, so cold-launching the app from a
Universal Link or custom-scheme URL dropped the URL on the floor.
The user's subscriber to IActivatableLifetime.Activated then only saw
the base ActivatedEventArgs raised by the foreground transition
(OnLeavingBackground), never a ProtocolActivatedEventArgs with the URL.
Fix: in WillConnect, after the window is created and made key, drain
both connectionOptions.UserActivities and connectionOptions.UrlContexts
through the existing IAvaloniaAppInternalDelegate paths. Also add a
scene:openURLContexts: handler so warm custom-scheme URLs work under
scene lifecycle (previously these were silently dropped too —
application:openURL: on the AppDelegate is not called when scenes are
in use).
Closes#21362 (cold path of #17600 / #18005).
The IAvaloniaAppInternalDelegate interface gains an OpenUrl(NSUrl)
method so the scene delegate can route URL contexts through the same
code path the existing application:openURL:options: AppDelegate handler
uses.
No new tests — the Avalonia.iOS UnitTests and IntegrationTests projects
don't currently exist in the repo. Manual verification steps in the
issue: build any Avalonia.iOS app with Associated Domains entitlement
+ AASA served, force-quit, tap a Universal Link, observe the
Activated event fires with ProtocolActivatedEventArgs (not base
ActivatedEventArgs). Happy to add a test if maintainers can point at
a scene-lifecycle test fixture to model from.
* Truncate the content when writing
To maintain consistency with other operating system APIs, see: https://github.com/AvaloniaUI/Avalonia/pull/20804 & https://github.com/AvaloniaUI/Avalonia/pull/20807
* Prevent accidental truncation when creating files
* Update comments
* Validate existing item type when creating storage
* Truncate files on creation in storage items
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* test: add DataFormat.CreateInProcessFormat tests
Cover the new InProcess format API: kind, identifier, null/empty
validation, non-ASCII identifiers, HasSystemName for all four kinds,
ToSystemName throwing, equality/inequality, DataTransferItem
integration, and coexistence with other formats in DataTransfer.
* feat: implement DataFormat.CreateInProcessFormat<T> for in-process drag/drop
Add DataFormatKind.InProcess and DataFormat.CreateInProcessFormat<T>()
so users can pass arbitrary object references during in-process
drag-and-drop without crossing serialization boundaries.
- Add HasSystemName property to indicate whether ToSystemName() is valid
- Update ToSystemName to throw for InProcess (same as Universal)
- Guard all 7 platform backends (Win32, macOS, X11, Android, Browser,
iOS) to skip InProcess formats during clipboard/drag-drop enumeration
Closes#20097
* fix: remove HasSystemName API per review feedback
* Don't tick with render loop when app is idle
* Update src/Avalonia.Base/Rendering/Composition/Transport/BatchStreamArrayPool.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* wip
* wip
* api diff
* fixes
* Address review: clear wakeupPending at tick start, guard CarbonEmissionsHack subscriptions
- Clear _wakeupPending at start of TimerTick so wakeups already processed
by the current tick don't force an unnecessary extra tick
- Guard CarbonEmissionsHack against duplicate subscriptions using a private
attached property
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix lock-order inversion in Add/Remove vs TimerTick
Move Wakeup() and Stop() calls outside the _items lock in Add/Remove
to prevent deadlock with TimerTick which acquires _timerLock then _items.
Add/Remove are UI-thread-only so the extracted logic remains safe.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: remove unused usings, guard double Stop(), fix SleepLoop extra frame
- Remove unused using directives from IRenderLoopTask.cs
- Guard TimerTick Stop() with _running check to prevent double Stop()
when Remove() already stopped the timer
- SleepLoopRenderTimer: use WaitOne(timeout) instead of Thread.Sleep
so Stop() can interrupt the sleep, and recheck _stopped before Tick
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix DisplayLinkTimer foreground handler bypassing render loop state
Only resume the display link on WillEnterForeground if the timer was
calling Start() to avoid setting _stopped=false when the render loop
had the timer stopped.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix DisplayLinkTimer thread safety, revert global NU5104 suppression
- Stop() now only sets _stopped flag; OnLinkTick() self-pauses the
CADisplayLink from the timer thread to avoid thread-affinity issues
- Revert NU5104 global suppression in SharedVersion.props
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Cap _ticksSinceLastCommit to prevent int overflow
Stop incrementing once it reaches CommitGraceTicks to prevent
wrapping negative and keeping the render loop awake indefinitely.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: remove Start/Stop from IRenderTimer, merge into Tick setter
Timer start/stop is now controlled entirely by setting the Tick
property: non-null starts, null stops. This eliminates the explicit
Start()/Stop() methods from IRenderTimer, making the API simpler.
DefaultRenderLoop controls the timer purely through Tick assignment
under its _timerLock. A new _hasItems flag tracks subscriber presence
since Tick is now transient (null when idle).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: address review comments on timer thread safety and guards
- ChoreographerTimer: add _frameCallbackActive guard to prevent double
PostFrameCallback from both Tick setter and SubscribeView
- ServerCompositor: cap _ticksSinceLastCommit at int.MaxValue
- SleepLoopRenderTimer: make _tick volatile, remove _stopped recheck
(guard moved to DefaultRenderLoop)
- DefaultRenderLoop: add _running check at tick start to drop late ticks
- ThreadProxyRenderTimer: add lock for internal state manipulation
- DisplayLinkTimer: add lock for all internal state manipulation
- Re-add NU5104 suppression to SharedVersion.props
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: make _hasItems volatile for cross-thread visibility
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: guard against redundant starts in DefaultRenderTimer, make _tick volatile across all timers
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Remove CarbonEmissionsHack, revert iOS/Android timers to always-ticking
- Delete CarbonEmissionsHack class and its XAML reference
- Revert DisplayLinkTimer (iOS) to original always-ticking implementation
- Revert ChoreographerTimer (Android) to original always-ticking implementation
- Add TODO comments for future start/stop on RenderLoop request
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix DirectCompositionConnection WaitOne not respecting process exit cancellation
Use WaitHandle.WaitAny with both _wakeEvent and cts.Token.WaitHandle so
the loop can exit when ProcessExit fires while the timer is stopped.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* timers
* XML docs
* Cache delegate
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Merge ISkiaGpuWithPlatformGraphicsContext into ISkiaGpu
* Merge ISkiaGpuRenderTarget2 into ISkiaGpuRenderTarget
* Merge IRenderTarget2 into IRenderTarget
* Update API suppressions
* Update API suppressions
* Introduce a universal IGlyphTypeface implementation that does not rely on any platform implementation
* Revert changes
* Fix Android
* Make the test happy
* Fix build
* Update baseline
* Fix naming
* Fix headless
* Move interfaces to dedicated files
Make GlyphTypeface.GlyphCount an integer
* Fix GlyphCount
* Make IGlyphTypeface NotClientImplementable
* Make sure we cache platform typefaces by their desired name, style, weight and stretch
* Update baseline
* Only use IGlyphTypeface
* Fix Android
* Try to clear the buffer before we encode somethimg
* Add needed test font
* Add more unit tests
* Reduce allocations
* Remove Direct2D1 test files
* More tests
* More complete table implementations
* More adjustments
* Use batch APIs
* Handle invalid timestamps
* Update baseline
* Introduce a CharacterToGlyphMap struct for faster access
* Remove AggressiveInlining
* Remove AggressiveInlining
* Make the head table optional for legacy fonts
* Remove Load method. Fix TextBlockTests
* Fix nullables
* Remove redundant folder
* Update Api baseline
* revert diff helper changes
* revert changes
* Use bare minimum font for Headless platform and introduce a test font manager that uses the Inter font for testing.
* Add missing font file for Headless platform
---------
Co-authored-by: Gillibald <stebner@avaloniaui.net>
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* support reading images from clipboard(win32/android)
* Add DataFormat.Image. Prioritize png format when retrieving image from clipboard
* add browser support
* addressed comments
* win32 - add support for CF_DIB and CF_BITMAP formats
* win32 - add support for copying bitmaps to clipboard as DIB
* browser - add support for copying bitmap to clipboard
* Implement bitmap clipboard for iOS
* rename DataFormat.Image to DataFormat.Bitmap
* Implement Bitmap clipboard on macOS
* Use MemoryStream for bitmap clipboard/dnd on macOS backend
* Add public.jpeg support on macOS backend (convert it to png while in objc)
* Support TIFF format on iOS backend, by converting it to UIImage first
* Add Bitmap DND sample
* add clipboard bitmap support on linux
* simply bitmap format search on win32 clipboard
* fix linux clipboard image
* Bump MACOSX_DEPLOYMENT_TARGET
* Fix IDL incompatibility
* address review
* more reviews
* Fix Android crash on copy when a bitmap is present in the clipboard
* Handle any error that might occur pasting from an external content provider
* Add data transfer extension methods for Bitmap
---------
Co-authored-by: Max Katz <maxkatz6@outlook.com>
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* Add new SaveFilePickerWithResultAsync API to the base
* Add SaveFilePickerWithResultAsync stub impl
* Control Catalog SaveFilePickerWithResultAsync sample with XML and JSON types
* Make SaveFilePickerResult a struct
* Add managed picker implementation
* Make SaveFilePickerResult a readonly struct
* Windows implementation of SaveFilePickerWithResultAsync
* Test impl for dbus
* Reuse the file type object (FTO) so StorageFile consumer can match exactly the right FTO when receiving the SaveFilePicker's result.
* Add Gtk impl
* Avalonia.Native: surface selected save dialog filters
* macOS: report selected NSSavePanel filter
* Modify the conditional in case there's duplicate descriptions of FTO's in DBusSystemDialog.cs
* Instantiate FPFT as fallback
* Pass the mime/pattern to instantiated FPFT
* Update API diff
* Fix review comments
---------
Co-authored-by: Max Katz <maxkatz6@outlook.com>
* Retarget to SkiaSharp 3.0
* Replace SKFilterQuality with SKSamplingOptions
* Replace obsolete GRBackendRenderTarget ctor
* Replace SkiaMetalApi reflection with stable APIs
* Use SKMatrix4x4 where it makes more sense perf wise
* Add CS0618 warning as error for Skia
* Fix ToSKSamplingOptions implementation
* Remove hacky compile time condition
* Update API compat
* Remove maccatalyst hack
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* Use AndroidViewControlHandle for android toplevel handle
* Use UIViewControlHandle for iOS toplevel handle
* Use JSObjectControlHandle for browser toplevel handle
* Revert NativeControlHostImpl changes
* Implemented IClipboard.TryGetInProcessDataObjectAsync for X11
* [Win32] Implemented TryGetInProcessDataObjectAsync
* Rest of the platforms
* Run `nuke ValidateApiDiff`
---------
Co-authored-by: Max Katz <maxkatz6@outlook.com>