Skip to content

Commit

Permalink
Native window decorations: TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
DevCharly committed Jun 20, 2024
1 parent 0c0d4bf commit a857749
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

//
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" } )
Expand Down

0 comments on commit a857749

Please sign in to comment.