mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user