[PTRun]Reverted start position to slightly off-center(#34083)

## Summary of the Pull Request
Reverted start-position to slightly off-center while still addressing
multi-monitor/multi-DPI scenarios.
This commit is contained in:
Ani
2024-07-31 17:14:45 +02:00
committed by GitHub
parent 3a080f5efd
commit 77c90b8d98
2 changed files with 23 additions and 11 deletions

View File

@@ -449,14 +449,22 @@ namespace PowerLauncher
// In terms of the hack itself, removing any of these three steps seems to fail in certain scenarios only,
// so be careful with testing!
var desiredScreen = GetScreen();
var workingArea = desiredScreen.WorkingArea;
Point ToDIP(double unitX, double unitY) => WindowsInteropHelper.TransformPixelsToDIP(this, unitX, unitY);
// Move to top-left of desired screen.
Top = desiredScreen.WorkingArea.Top;
Left = desiredScreen.WorkingArea.Left;
Top = workingArea.Top;
Left = workingArea.Left;
// Centralize twice.
WindowsInteropHelper.MoveToScreenCenter(this, desiredScreen);
WindowsInteropHelper.MoveToScreenCenter(this, desiredScreen);
void MoveToScreenTopCenter()
{
Left = ((ToDIP(workingArea.Width, 0).X - ActualWidth) / 2) + ToDIP(workingArea.X, 0).X;
Top = ((ToDIP(0, workingArea.Height).Y - SearchBox.ActualHeight) / 4) + ToDIP(0, workingArea.Y).Y;
}
MoveToScreenTopCenter();
MoveToScreenTopCenter();
}
private void OnLocationChanged(object sender, EventArgs e)