From a857749740466db4b29e60861c6bfdc88f6da573 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 20 Jun 2024 13:31:36 +0200 Subject: [PATCH] Native window decorations: TODO --- .../FlatWindowsNativeWindowBorder.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/flatlaf-natives/flatlaf-natives-jna/src/main/java/com/formdev/flatlaf/natives/jna/windows/FlatWindowsNativeWindowBorder.java b/flatlaf-natives/flatlaf-natives-jna/src/main/java/com/formdev/flatlaf/natives/jna/windows/FlatWindowsNativeWindowBorder.java index bdf31aa70..d7c1b958e 100644 --- a/flatlaf-natives/flatlaf-natives-jna/src/main/java/com/formdev/flatlaf/natives/jna/windows/FlatWindowsNativeWindowBorder.java +++ b/flatlaf-natives/flatlaf-natives-jna/src/main/java/com/formdev/flatlaf/natives/jna/windows/FlatWindowsNativeWindowBorder.java @@ -60,8 +60,11 @@ import com.sun.jna.platform.win32.WinDef.RECT; import com.sun.jna.platform.win32.WinDef.UINT_PTR; import com.sun.jna.platform.win32.WinDef.WPARAM; +import com.sun.jna.platform.win32.WinError; import com.sun.jna.platform.win32.WinUser.HMONITOR; import com.sun.jna.platform.win32.WinUser.WindowProc; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; // @@ -615,6 +618,14 @@ private LRESULT WmNcCalcSize( HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam if( hasAutohideTaskbar( ABE_RIGHT, monitorInfo.rcMonitor ) ) params.rgrc[0].right--; } + } else if( SystemInfo.isWindows_11_orLater ) { + IntByReference borderThickness = new IntByReference(); + if( DWMApi.INSTANCE.DwmGetWindowAttribute( hwnd, DWMApi.DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, + borderThickness.getPointer(), 4 ) == WinError.S_OK.intValue() ) + { + System.out.println( "borderThickness " + borderThickness.getValue() ); + params.rgrc[0].top += borderThickness.getValue(); + } } // write changed params back to native memory @@ -898,6 +909,18 @@ private interface GDI32Ex HBRUSH CreateSolidBrush( DWORD color ); } + //---- interface DWMApi --------------------------------------------------- + + private interface DWMApi + extends StdCallLibrary + { + DWMApi INSTANCE = Native.load( "dwmapi", DWMApi.class, W32APIOptions.DEFAULT_OPTIONS ); + + int DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37; + + int DwmGetWindowAttribute( HWND hwnd, int dwAttribute, Pointer pvAttribute, int cbAttribute ); + } + //---- class NCCALCSIZE_PARAMS -------------------------------------------- @FieldOrder( { "rgrc" } )