@@ -143,23 +143,27 @@ def __init__(self, window, cache_dir):
143
143
self .Size = Size (window .initial_width , window .initial_height )
144
144
self .MinimumSize = Size (window .min_size [0 ], window .min_size [1 ])
145
145
146
+ self .AutoScaleDimensions = SizeF (96.0 , 96.0 )
147
+ self .AutoScaleMode = WinForms .AutoScaleMode .Dpi
148
+ # for chromium edge, need this factor to modify the coordinates
149
+ self .scale_factor = windll .shcore .GetScaleFactorForDevice (0 ) / 100 if is_chromium else 1
150
+
146
151
if window .initial_x is not None and window .initial_y is not None :
147
152
self .StartPosition = WinForms .FormStartPosition .Manual
148
153
self .Location = Point (window .initial_x , window .initial_y )
149
154
elif window .screen :
150
155
self .StartPosition = WinForms .FormStartPosition .Manual
151
- x = (
152
- window .screen .frame .X + (window .screen .width / 2 ) + window . initial_width / 2
153
- if window .screen .frame .X >= 0
154
- else window .screen .frame .X - window .screen .width / 2
156
+ x = int (
157
+ window .screen .frame .X * self . scale_factor + (window .screen .width - window . initial_width ) * self . scale_factor / 2
158
+ if window .screen .frame .X >= 0
159
+ else window .screen .frame .X * self . scale_factor - window .screen .width * self . scale_factor / 2
155
160
)
156
- self .Location = Point (int (x ), int (window .screen .frame .Y + window .screen .height / 2 ))
161
+
162
+ y = int (window .screen .frame .Y * self .scale_factor + (window .screen .height - window .initial_height ) * self .scale_factor / 2 )
163
+ self .Location = Point (x , y )
157
164
else :
158
165
self .StartPosition = WinForms .FormStartPosition .CenterScreen
159
166
160
- self .AutoScaleDimensions = SizeF (96.0 , 96.0 )
161
- self .AutoScaleMode = WinForms .AutoScaleMode .Dpi
162
-
163
167
if not window .resizable :
164
168
self .FormBorderStyle = WinForms .FormBorderStyle .FixedSingle
165
169
self .MaximizeBox = False
@@ -186,7 +190,6 @@ def __init__(self, window, cache_dir):
186
190
self .url = window .real_url
187
191
self .text_select = window .text_select
188
192
self .TopMost = window .on_top
189
- self .scale_factor = 1
190
193
191
194
self .is_fullscreen = False
192
195
if window .fullscreen :
@@ -204,8 +207,6 @@ def __init__(self, window, cache_dir):
204
207
CEF .create_browser (window , self .Handle .ToInt32 (), BrowserView .alert , self )
205
208
elif is_chromium :
206
209
self .browser = Chromium .EdgeChrome (self , window , cache_dir )
207
- # for chromium edge, need this factor to modify the coordinates
208
- self .scale_factor = windll .shcore .GetScaleFactorForDevice (0 ) / 100
209
210
else :
210
211
self .browser = IE .MSHTML (self , window , BrowserView .alert )
211
212
@@ -785,7 +786,7 @@ def get_size(uid):
785
786
786
787
787
788
def get_screens ():
788
- screens = [Screen (s .Bounds .Width , s .Bounds .Height , s .WorkingArea . Location ) for s in WinForms .Screen .AllScreens ]
789
+ screens = [Screen (s .Bounds .Width , s .Bounds .Height , s .WorkingArea ) for s in WinForms .Screen .AllScreens ]
789
790
return screens
790
791
791
792
0 commit comments