I've fixed this unbearable bug when resizing a win...
# compose-desktop
u
I've fixed this unbearable bug when resizing a window in dark mode under Windows, in the next version of Nucleus that will be released. 🎉
🔥 8
a
Do you mean you fixed the background showing through at the edges? How did you fix it?
c
yeah whats the unbearable bug? is this the before or after the bug? lol
u
@Alexander Maryanovsky On Windows, Skiko's rendering pipeline clears the DirectX canvas to white before each frame. When the window is resized larger, the newly exposed pixels remain white for one frame — producing a visible white flash. I created a JNI module that eliminates this by adjusting Skiko's clear color to transparent for dark themes (rendered as opaque black on the DirectX surface), so the flash is invisible against a dark background. It also synchronizes the DWM caption and border colors (
DWMWA_CAPTION_COLOR
,
DWMWA_BORDER_COLOR
,
DWMWA_USE_IMMERSIVE_DARK_MODE
) with the title bar color for consistent Windows 11 window chrome styling.
a
Wouldn’t that just cause black bars on resize, which would be visible with a light theme?
u
I disable it in light mode
a
Ah, heh
Note this, though. Maybe you don’t need the hack anymore.
It now fills the canvas with the
SkiaLayer.awt
’s background color
u
Yes ! does the latest alpha version of Compose use it?
a
yes
u
I will check this, thanks a lot
a
Hmm, I’m not sure it’s the canvas you’re referring to, though
u
I think I'll keep my hack for a little while anyway, for backward compatibility.
a
Which one did you touch?
u
I touched the GPU-level clear color — SkiaLayer.setTransparency(true) changes ContextHandler.draw() so it clears to TRANSPARENT instead of WHITE. On the DirectX surface (DXGI_ALPHA_MODE_IGNORE), transparent renders as opaque black. I also handle the GDI level (WM_ERASEBKGND, SWP_NOCOPYBITS) and the DWM compositor (DwmExtendFrameIntoClientArea) to prevent white fills before Skiko even gets a chance to render. So it's a different layer from the AWT background your PR addresses 🙄 — but your fix might let me simplify or remove the setTransparency part.
a
So you’re changing the color
ContextHandler.draw
fills with?
Note there are 2 PRs. Both use the AWT background. The first one uses it to fill the canvas in
ContextHandler.draw
, but then we moved that to the Canvas in
SkiaLayer.update
, and the one in
ContextHandler.draw
is always filled with TRANSPARENT (0x0)
u
So you’re changing the color
ContextHandler.draw
fills with?
Yes, exactly. I toggle
SkiaLayer.setTransparency(true)
for dark themes, which makes
ContextHandler.draw()
clear to TRANSPARENT instead of WHITE.
Note there are 2 PRs. Both use the AWT background. The first one uses it to fill the canvas in ContextHandler.draw, but then we moved that to the Canvas in SkiaLayer.update, and the one in
ContextHandler.draw is always filled with TRANSPARENT (0x0)
so with the latest Skiko, my setTransparency(true) hack is redundant now.
a
But now it’s always filled with TRANSPARENT
So it’ll be black in light theme
u
Ah yes, I see
I'll keep my current hack for now and drop the
setTransparency
once the new Skiko hits stable. Thanks!
a
I’ll talk to the team about exposing the color with which we fill in ContextHandler.draw
🙌 1
Ohhh, great news 🙂
So now the workaround for this that used to only work for macOS now works for Windows too, with a slight change.
🎉 1
Copy code
@Composable
fun FrameWindowScope.windowBackgroundFlashingWorkaround(themeBackgroundColor: Color) {
    LaunchedEffect(window, themeBackgroundColor) {
        val awtColor = java.awt.Color(themeBackgroundColor.toArgb())
        window.background = awtColor  // for macOS 
        window.contentPane.background = awtColor  // for Windows
    }
}
u
oh it's very great
a
After setting
contentPane.background
I’m seeing almost no white bars on resize
In 1.11.0-alpha03
u
Yes, I see, there's still a little bit left. That's why I also handle the GDI level and the DWM compositor
a
I hope I didn’t break it in the 2nd PR. That won’t be seen until alpha04
But if I did, it just means we need to expose the clear color in
ContextHandler.draw
u
Nice ! can't wait to test 😁
a
Looks like I broke it, but not too badly. In alpha03 it’s enough to set contentPane background, in alpha04 you’ll need to set both contentPane and window background
(which you need to do anyway for macOS, at least previously)