@@ -60,17 +60,6 @@ private func ClientToWindow(size: inout Size, for style: WindowStyle) {
6060 size = Size ( width: Double ( r. right - r. left) , height: Double ( r. bottom - r. top) )
6161}
6262
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- 7463private func WindowBasedTransform( for view: View ? ) -> AffineTransform {
7564 guard var view = view else { return . identity }
7665
@@ -479,7 +468,7 @@ public class View: Responder {
479468 }
480469
481470 // Scale window for DPI
482- ScaleClient ( rect : & client, for: GetDpiForWindow ( self . hWnd) , style)
471+ client= client . scaled ( for: GetDpiForWindow ( self . hWnd) , style : style)
483472
484473 // Resize and Position the Window
485474 SetWindowPos ( self . hWnd, nil ,
@@ -543,10 +532,10 @@ public class View: Responder {
543532 public var frame : Rect {
544533 didSet {
545534 // 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) ) )
550539
551540 // Resize and Position the Window
552541 _ = SetWindowPos ( self . hWnd, nil ,
@@ -703,8 +692,8 @@ public class View: Responder {
703692 WindowStyle ( DWORD ( bitPattern: view. GWL_STYLE) ,
704693 DWORD ( bitPattern: view. GWL_EXSTYLE) )
705694
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)
708697
709698 // Resize and Position the Window
710699 _ = SetWindowPos ( view. hWnd, nil ,
0 commit comments