Skip to content

Commit 7b0e421

Browse files
authored
fix: handle tray width on scaled systems (#12)
Fixes width when the desktop is scaled.
1 parent 6ecbc3f commit 7b0e421

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

App/TrayWindow.xaml.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ private void ResizeWindow()
192192
// Adjust the AppWindow size
193193
var scale = GetDisplayScale();
194194
var height = (int)(desiredSize.Height * scale);
195-
AppWindow.Resize(new SizeInt32(WIDTH, height));
195+
var width = (int)(WIDTH * scale);
196+
AppWindow.Resize(new SizeInt32(width, height));
196197
}
197198

198199
private double GetDisplayScale()
@@ -232,12 +233,13 @@ private void MoveWindow()
232233
private PointInt32 GetWindowPosition()
233234
{
234235
var height = AppWindow.Size.Height;
236+
var width = AppWindow.Size.Width;
235237
var cursorPosition = _lastActivatePosition;
236238
if (cursorPosition is null)
237239
{
238240
var primaryWorkArea = DisplayArea.Primary.WorkArea;
239241
return new PointInt32(
240-
primaryWorkArea.Width - WIDTH,
242+
primaryWorkArea.Width - width,
241243
primaryWorkArea.Height - height
242244
);
243245
}
@@ -252,7 +254,7 @@ private PointInt32 GetWindowPosition()
252254
).WorkArea;
253255

254256
// Adjust if the window goes off the right edge of the display.
255-
if (x + WIDTH > workArea.X + workArea.Width) x = workArea.X + workArea.Width - WIDTH;
257+
if (x + width > workArea.X + workArea.Width) x = workArea.X + workArea.Width - width;
256258

257259
// Adjust if the window goes off the bottom edge of the display.
258260
if (y + height > workArea.Y + workArea.Height) y = workArea.Y + workArea.Height - height;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy