@@ -103,7 +103,13 @@ internal class ComposeWindowProcedure(
103103
104104 var isWindowActive by mutableStateOf(true )
105105
106- var isFullscreen = false
106+ var isFullscreen: Boolean = false
107+ set(value) {
108+ if (field != value) {
109+ field = value
110+ updateBorderAndShadow()
111+ }
112+ }
107113
108114 val skiaLayerProcedure = (window as ? ComposeWindow )?.findSkiaLayer()?.let {
109115 SkiaLayerWindowProcedure (
@@ -138,7 +144,7 @@ internal class ComposeWindowProcedure(
138144
139145 init {
140146 enableResizability()
141- enableBorderAndShadow ()
147+ updateBorderAndShadow ()
142148 }
143149
144150 override fun callback (hWnd : HWND , uMsg : Int , wParam : WPARAM , lParam : LPARAM ): LRESULT {
@@ -331,26 +337,34 @@ internal class ComposeWindowProcedure(
331337 * To disable window border and shadow, pass (0, 0, 0, 0) as window margins
332338 * (or, simply, don't call this function).
333339 */
334- private fun enableBorderAndShadow () {
340+ private fun updateBorderAndShadow () {
335341 val dwmApi = " dwmapi"
336342 .runCatching(NativeLibrary ::getInstance)
337343 .onFailure { logger.e(" Could not load dwmapi library" ) }
338344 .getOrNull()
345+
346+ val currentMargins = if (isFullscreen) {
347+ WindowMargins (0 , 0 , 0 , 0 )
348+ } else {
349+ margins
350+ }
351+
339352 dwmApi
340353 ?.runCatching { getFunction(" DwmExtendFrameIntoClientArea" ) }
341354 ?.onFailure { logger.e(" Could not enable window native decorations (border/shadow/rounded corners)" ) }
342355 ?.getOrNull()
343- ?.invoke(arrayOf(windowHandle, margins ))
356+ ?.invoke(arrayOf(windowHandle, currentMargins ))
344357
345358 if (isWindows11OrLater()) {
359+ val cornerPreference = if (isFullscreen) 1 else 2 // 1: DoNotRound, 2: Round
346360 dwmApi?.getFunction(" DwmSetWindowAttribute" )?.apply {
347361 invoke(
348362 WinNT .HRESULT ::class .java,
349363 arrayOf(windowHandle, 35 , IntByReference ((0xFFFFFFFE ).toInt()), 4 )
350364 )
351365 invoke(
352366 WinNT .HRESULT ::class .java,
353- arrayOf(windowHandle, 38 , IntByReference (2 ), 4 )
367+ arrayOf(windowHandle, 38 , IntByReference (cornerPreference ), 4 )
354368 )
355369 }
356370 }
0 commit comments