Skip to content

Commit

Permalink
Do not propagate SurroundingTextChanged if input connection is in update
Browse files Browse the repository at this point in the history
  • Loading branch information
kerams committed Jan 23, 2025
1 parent cd7c5b1 commit b5497ff
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 186 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ dotnet_diagnostic.CA1851.severity = warning
dotnet_diagnostic.CA1854.severity = warning
#CA2211:Non-constant fields should not be visible
dotnet_diagnostic.CA2211.severity = error
# IDE0059: Unnecessary assignment of a value
dotnet_diagnostic.IDE0059.severity = error

# Wrapping preferences
csharp_wrap_before_ternary_opsigns = false
Expand Down
1 change: 1 addition & 0 deletions Avalonia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.RenderTests.WpfCompare", "tests\Avalonia.RenderTests.WpfCompare\Avalonia.RenderTests.WpfCompare.csproj", "{9AE1B827-21AC-4063-AB22-C8804B7F931E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Win32.Automation", "src\Windows\Avalonia.Win32.Automation\Avalonia.Win32.Automation.csproj", "{0097673D-DBCE-476E-82FE-E78A56E58AA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XEmbedSample", "samples\XEmbedSample\XEmbedSample.csproj", "{255614F5-CB64-4ECA-A026-E0B1AF6A2EF4}"
EndProject
Global
Expand Down
2 changes: 1 addition & 1 deletion global.json → _global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "8.0.404",
"rollForward": "latestFeature"
"rollForward": "major"
},
"msbuild-sdks": {
"Microsoft.Build.Traversal": "4.1.0"
Expand Down
7 changes: 5 additions & 2 deletions samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<ProvisioningType>manual</ProvisioningType>
<TargetFramework>$(AvsCurrentIOSTargetFramework)</TargetFramework>
<TargetFramework>net9.0-ios</TargetFramework>
<!-- <TargetFramework>$(AvsCurrentTvOSTargetFramework)</TargetFramework>-->
<SupportedOSPlatformVersion>$(AvsMinSupportedIOSVersion)</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion>16.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj" />
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions samples/ControlCatalog.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<array>
<string>arm64</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<!--<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>-->
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
43 changes: 0 additions & 43 deletions samples/ControlCatalog.iOS/Resources/LaunchScreen.xib

This file was deleted.

7 changes: 6 additions & 1 deletion samples/SafeAreaDemo.iOS/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:96ac-94-112-66-237.ngrok-free.app?mode=developer</string>
</array>
</dict>
</plist>
4 changes: 2 additions & 2 deletions samples/SafeAreaDemo.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>SafeAreaDemo</string>
<string>deckademyaa</string>
<key>CFBundleIdentifier</key>
<string>companyName.SafeAreaDemo</string>
<string>com.deckademyaa</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
Expand Down
8 changes: 6 additions & 2 deletions samples/SafeAreaDemo.iOS/SafeAreaDemo.iOS.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(AvsCurrentIOSTargetFramework)</TargetFramework>
<SupportedOSPlatformVersion>$(AvsMinSupportedIOSVersion)</SupportedOSPlatformVersion>
<TargetFramework>net9.0-ios</TargetFramework>
<SupportedOSPlatformVersion>16.0</SupportedOSPlatformVersion>
<ProvisioningType>manual</ProvisioningType>
<Nullable>enable</Nullable>
<MtouchUseLlvm>false</MtouchUseLlvm>
<UseInterpreter>true</UseInterpreter>
<TrimMode>partial</TrimMode>
<LinkMode>SdkOnly</LinkMode>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/SafeAreaDemo/Views/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<CheckBox IsChecked="{Binding UseSafeArea}" IsEnabled="{Binding !AutoSafeAreaPadding}">Use Safe Area</CheckBox>
<CheckBox IsChecked="{Binding AutoSafeAreaPadding}">Automatic Paddings</CheckBox>
<CheckBox IsChecked="{Binding HideSystemBars}">Hide System Bars</CheckBox>
<TextBox Width="200" Watermark="Tap to Show Keyboard"/>
<TextBox Width="200" Watermark="Tap to Show Keyboard" Height="100" AcceptsReturn="True" />
</StackPanel>
</Grid>
</DockPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void SetClient(TextInputMethodClient? client)

_inputConnection?.UpdateState();

_client.SurroundingTextChanged += _client_SurroundingTextChanged;
_client.SelectionChanged += _client_SelectionChanged;
}
else
Expand Down Expand Up @@ -119,6 +120,13 @@ private void OnSelectionChanged()
_inputConnection.IsInUpdate = false;
}

private void _client_SurroundingTextChanged(object? sender, EventArgs e)
{
if (_inputConnection is null || _inputConnection.IsInBatchEdit || _inputConnection.IsInUpdate)
return;
OnSurroundingTextChanged();
}

public void OnBatchEditEnded()
{
if (_inputConnection is null || _inputConnection.IsInBatchEdit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal void UpdateState()
{
var selection = _editBuffer.Selection;

if (IsInMonitorMode && InputMethod.Client is { } client)
if (IsInMonitorMode && InputMethod.Client is { })
{
InputMethod.IMM.UpdateExtractedText(InputMethod.View, ExtractedTextToken,
_editBuffer.ExtractedText);
Expand Down
4 changes: 1 addition & 3 deletions src/iOS/Avalonia.iOS/Avalonia.iOS.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(AvsCurrentIOSTargetFramework);$(AvsCurrentTvOSTargetFramework)</TargetFrameworks>
<TargetFrameworks>net9.0-ios</TargetFrameworks>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">$(AvsMinSupportedIOSVersion)</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tvos'">$(AvsMinSupportedTvOSVersion)</SupportedOSPlatformVersion>
<!-- Not yet enabled as a target framework -->
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">$(AvsMinSupportedMacCatalystVersion)</SupportedOSPlatformVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- Compatibility attributes are pretty much broken for iOS-like platforms. Verify by hand. -->
Expand Down
Loading

0 comments on commit b5497ff

Please sign in to comment.