File tree Expand file tree Collapse file tree
crates/tauri-runtime-wry/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ tauri-runtime-wry : patch:bug
3+ ---
4+
5+ Fix getting the DPI internally leaks ` HDC ` handles on Windows. This also improves the resizing speed on undecorated windows
Original file line number Diff line number Diff line change @@ -68,10 +68,6 @@ mod imp {
6868
6969 #[ allow( non_snake_case) ]
7070 pub unsafe fn hwnd_dpi ( hwnd : HWND ) -> u32 {
71- let hdc = GetDC ( Some ( hwnd) ) ;
72- if hdc. is_invalid ( ) {
73- return USER_DEFAULT_SCREEN_DPI ;
74- }
7571 if let Some ( GetDpiForWindow ) = * GET_DPI_FOR_WINDOW {
7672 // We are on Windows 10 Anniversary Update (1607) or later.
7773 match GetDpiForWindow ( hwnd) {
@@ -95,9 +91,15 @@ mod imp {
9591 } else {
9692 // We are on Vista or later.
9793 if IsProcessDPIAware ( ) . as_bool ( ) {
94+ let hdc = GetDC ( Some ( hwnd) ) ;
95+ if hdc. is_invalid ( ) {
96+ return USER_DEFAULT_SCREEN_DPI ;
97+ }
9898 // If the process is DPI aware, then scaling must be handled by the application using
9999 // this DPI value.
100- GetDeviceCaps ( Some ( hdc) , LOGPIXELSX ) as u32
100+ let dpi = GetDeviceCaps ( Some ( hdc) , LOGPIXELSX ) as u32 ;
101+ ReleaseDC ( Some ( hwnd) , hdc) ;
102+ dpi
101103 } else {
102104 // If the process is DPI unaware, then scaling is performed by the OS; we thus return
103105 // 96 (scale factor 1.0) to prevent the window from being re-scaled by both the
You can’t perform that action at this time.
0 commit comments