Skip to content

Commit

Permalink
[Winforms] Fix window placing on a screen
Browse files Browse the repository at this point in the history
  • Loading branch information
r0x0r committed Jan 22, 2025
1 parent ec1603c commit 93314f9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions webview/platforms/winforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,18 @@ def __init__(self, window, cache_dir):

if window.initial_x is not None and window.initial_y is not None:
self.StartPosition = WinForms.FormStartPosition.Manual
self.Location = Point(window.initial_x, window.initial_y)
self.Location = Point(
int(window.initial_x * self.scale_factor),
int(window.initial_y * self.scale_factor)
)
elif window.screen:
self.StartPosition = WinForms.FormStartPosition.Manual
x = int(
window.screen.frame.X * self.scale_factor + (window.screen.width - window.initial_width) * self.scale_factor / 2
if window.screen.frame.X >= 0
else window.screen.frame.X * self.scale_factor - window.screen.width * self.scale_factor / 2
window.screen.x * self.scale_factor + (window.screen.width - window.initial_width) * self.scale_factor / 2
if window.screen.x >= 0
else window.screen.X * self.scale_factor + window.screen.width / 2
)

y = int(window.screen.frame.Y * self.scale_factor + (window.screen.height - window.initial_height) * self.scale_factor / 2)
y = int(window.screen.y * self.scale_factor + (window.screen.height - window.initial_height) * self.scale_factor / 2)
self.Location = Point(x, y)
else:
self.StartPosition = WinForms.FormStartPosition.CenterScreen
Expand Down Expand Up @@ -936,7 +938,7 @@ def get_size(uid):


def get_screens():
screens = [Screen(s.Bounds.X, s.Bounds.Y, s.Bounds.Height, s.WorkingArea) for s in WinForms.Screen.AllScreens]
screens = [Screen(s.Bounds.X, s.Bounds.Y, s.Bounds.Width, s.Bounds.Height, s.WorkingArea) for s in WinForms.Screen.AllScreens]
return screens


Expand Down

0 comments on commit 93314f9

Please sign in to comment.