@@ -560,14 +560,15 @@ impl MyWndProc {
560560 if let Some ( hwnd) = self . handle . borrow ( ) . get_hwnd ( ) {
561561 match op {
562562 DeferredOp :: SetSize ( size_dp) => unsafe {
563- let size_px = size_dp. to_px ( self . scale ( ) ) ;
563+ let area = ScaledArea :: from_dp ( size_dp, self . scale ( ) ) ;
564+ let size_px = area. size_px ( ) ;
564565 if SetWindowPos (
565566 hwnd,
566567 HWND_TOPMOST ,
567568 0 ,
568569 0 ,
569- size_px. width . round ( ) as i32 ,
570- size_px. height . round ( ) as i32 ,
570+ size_px. width as i32 ,
571+ size_px. height as i32 ,
571572 SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE ,
572573 ) == 0
573574 {
@@ -1248,9 +1249,10 @@ impl WndProc for MyWndProc {
12481249 let min_max_info = unsafe { & mut * ( lparam as * mut MINMAXINFO ) } ;
12491250 self . with_wnd_state ( |s| {
12501251 if let Some ( min_size_dp) = s. min_size {
1251- let min_size_px = min_size_dp. to_px ( self . scale ( ) ) ;
1252- min_max_info. ptMinTrackSize . x = min_size_px. width . round ( ) as i32 ;
1253- min_max_info. ptMinTrackSize . y = min_size_px. height . round ( ) as i32 ;
1252+ let min_area = ScaledArea :: from_dp ( min_size_dp, self . scale ( ) ) ;
1253+ let min_size_px = min_area. size_px ( ) ;
1254+ min_max_info. ptMinTrackSize . x = min_size_px. width as i32 ;
1255+ min_max_info. ptMinTrackSize . y = min_size_px. height as i32 ;
12541256 }
12551257 } ) ;
12561258 Some ( 0 )
@@ -1938,7 +1940,7 @@ impl WindowHandle {
19381940 }
19391941 }
19401942
1941- // Gets the position of the window in virtual screen coordinates
1943+ /// Gets the position of the window in virtual screen coordinates
19421944 pub fn get_position ( & self ) -> Point {
19431945 if let Some ( w) = self . state . upgrade ( ) {
19441946 let hwnd = w. hwnd . get ( ) ;
@@ -1992,12 +1994,12 @@ impl WindowHandle {
19921994 Insets :: ZERO
19931995 }
19941996
1995- // Sets the size of the window in DP
1997+ /// Sets the size of the window in display points
19961998 pub fn set_size ( & self , size : Size ) {
19971999 self . defer ( DeferredOp :: SetSize ( size) ) ;
19982000 }
19992001
2000- // Gets the size of the window in pixels
2002+ /// Gets the size of the window in display points
20012003 pub fn get_size ( & self ) -> Size {
20022004 if let Some ( w) = self . state . upgrade ( ) {
20032005 let hwnd = w. hwnd . get ( ) ;
@@ -2016,7 +2018,7 @@ impl WindowHandle {
20162018 } ;
20172019 let width = rect. right - rect. left ;
20182020 let height = rect. bottom - rect. top ;
2019- return Size :: new ( width as f64 , height as f64 ) ;
2021+ return Size :: new ( width as f64 , height as f64 ) . to_dp ( w . scale . get ( ) ) ;
20202022 }
20212023 }
20222024 Size :: new ( 0.0 , 0.0 )
@@ -2026,12 +2028,12 @@ impl WindowHandle {
20262028 self . defer ( DeferredOp :: SetResizable ( resizable) ) ;
20272029 }
20282030
2029- // Sets the window state.
2031+ /// Sets the window state.
20302032 pub fn set_window_state ( & self , state : window:: WindowState ) {
20312033 self . defer ( DeferredOp :: SetWindowState ( state) ) ;
20322034 }
20332035
2034- // Gets the window state.
2036+ /// Gets the window state.
20352037 pub fn get_window_state ( & self ) -> window:: WindowState {
20362038 // We can not store state internally because it could be modified externally.
20372039 if let Some ( w) = self . state . upgrade ( ) {
@@ -2057,7 +2059,7 @@ impl WindowHandle {
20572059 }
20582060 }
20592061
2060- // Allows windows to handle a custom titlebar like it was the default one.
2062+ /// Allows windows to handle a custom titlebar like it was the default one.
20612063 pub fn handle_titlebar ( & self , val : bool ) {
20622064 if let Some ( w) = self . state . upgrade ( ) {
20632065 w. handle_titlebar . set ( val) ;
0 commit comments