@@ -60,17 +60,6 @@ private func ClientToWindow(size: inout Size, for style: WindowStyle) {
60
60
size = Size ( width: Double ( r. right - r. left) , height: Double ( r. bottom - r. top) )
61
61
}
62
62
63
- private func ScaleClient( rect: inout Rect , for dpi: UINT , _ style: WindowStyle ) {
64
- let scale : Double = Double ( dpi) / Double( USER_DEFAULT_SCREEN_DPI)
65
-
66
- var r : RECT =
67
- RECT ( from: rect. applying ( AffineTransform ( scaleX: scale, y: scale) ) )
68
- if !AdjustWindowRectExForDpi( & r, style. base, false , style. extended, dpi) {
69
- log. warning ( " AdjustWindowRectExForDpi: \( Error ( win32: GetLastError ( ) ) ) " )
70
- }
71
- rect = Rect ( from: r)
72
- }
73
-
74
63
private func WindowBasedTransform( for view: View ? ) -> AffineTransform {
75
64
guard var view = view else { return . identity }
76
65
@@ -479,7 +468,7 @@ public class View: Responder {
479
468
}
480
469
481
470
// Scale window for DPI
482
- ScaleClient ( rect : & client, for: GetDpiForWindow ( self . hWnd) , style)
471
+ client = client . scaled ( for: GetDpiForWindow ( self . hWnd) , style : style)
483
472
484
473
// Resize and Position the Window
485
474
SetWindowPos ( self . hWnd, nil ,
@@ -543,10 +532,10 @@ public class View: Responder {
543
532
public var frame : Rect {
544
533
didSet {
545
534
// Scale window for DPI
546
- var client : Rect = self . frame
547
- ScaleClient ( rect : & client , for: GetDpiForWindow ( self . hWnd) ,
548
- WindowStyle ( DWORD ( bitPattern: self . GWL_STYLE) ,
549
- DWORD ( bitPattern: self . GWL_EXSTYLE) ) )
535
+ let client : Rect =
536
+ self . frame . scaled ( for: GetDpiForWindow ( self . hWnd) ,
537
+ style : WindowStyle ( DWORD ( bitPattern: self . GWL_STYLE) ,
538
+ DWORD ( bitPattern: self . GWL_EXSTYLE) ) )
550
539
551
540
// Resize and Position the Window
552
541
_ = SetWindowPos ( self . hWnd, nil ,
@@ -703,8 +692,8 @@ public class View: Responder {
703
692
WindowStyle ( DWORD ( bitPattern: view. GWL_STYLE) ,
704
693
DWORD ( bitPattern: view. GWL_EXSTYLE) )
705
694
706
- var client : Rect = view . frame
707
- ScaleClient ( rect : & client , for: GetDpiForWindow ( view. hWnd) , style)
695
+ let client : Rect =
696
+ view . frame . scaled ( for: GetDpiForWindow ( view. hWnd) , style : style)
708
697
709
698
// Resize and Position the Window
710
699
_ = SetWindowPos ( view. hWnd, nil ,
0 commit comments