[QuickAccent]Fix positioning on scaled desktop (#21200)

This commit is contained in:
Laszlo Nemeth
2022-10-25 20:44:17 +02:00
committed by GitHub
parent 76b4237cf1
commit d1f55bb9ea
2 changed files with 6 additions and 4 deletions

View File

@@ -7,6 +7,7 @@
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<PropertyGroup>
<CsWinRTIncludes>PowerToys.PowerAccentKeyboardService</CsWinRTIncludes>

View File

@@ -36,7 +36,7 @@ public class PowerAccent : IDisposable
{
_keyboardListener.SetShowToolbarEvent(new PowerToys.PowerAccentKeyboardService.ShowToolbar((LetterKey letterKey) =>
{
Application.Current.Dispatcher.Invoke(() =>
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
ShowToolbar(letterKey);
});
@@ -44,7 +44,7 @@ public class PowerAccent : IDisposable
_keyboardListener.SetHideToolbarEvent(new PowerToys.PowerAccentKeyboardService.HideToolbar((InputType inputType) =>
{
Application.Current.Dispatcher.Invoke(() =>
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
SendInputAndHideToolbar(inputType);
});
@@ -52,7 +52,7 @@ public class PowerAccent : IDisposable
_keyboardListener.SetNextCharEvent(new PowerToys.PowerAccentKeyboardService.NextChar((TriggerKey triggerKey) =>
{
Application.Current.Dispatcher.Invoke(() =>
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
ProcessNextChar(triggerKey);
});
@@ -176,7 +176,8 @@ public class PowerAccent : IDisposable
public Point GetDisplayCoordinates(Size window)
{
(Point Location, Size Size, double Dpi) activeDisplay = WindowsFunctions.GetActiveDisplay();
Rect screen = new Rect(activeDisplay.Location, activeDisplay.Size) / activeDisplay.Dpi;
double primaryDPI = Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth;
Rect screen = new Rect(activeDisplay.Location, activeDisplay.Size) / primaryDPI;
Position position = _settingService.Position;
/* Debug.WriteLine("Dpi: " + activeDisplay.Dpi); */