From 331e0268a3eee5893f8fa2f34d8dfa36cafa3e10 Mon Sep 17 00:00:00 2001 From: stffabi Date: Wed, 16 Feb 2022 08:53:17 +0100 Subject: [PATCH] [v2, windows] Do not show caption buttons if frameless and translucent+transparency (#1152) --- v2/internal/frontend/desktop/windows/window.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/v2/internal/frontend/desktop/windows/window.go b/v2/internal/frontend/desktop/windows/window.go index 690bfe638..b823ab794 100644 --- a/v2/internal/frontend/desktop/windows/window.go +++ b/v2/internal/frontend/desktop/windows/window.go @@ -147,12 +147,18 @@ func (w *Window) WndProc(msg uint32, wparam, lparam uintptr) uintptr { if w.frontendOptions.Frameless { switch msg { case w32.WM_ACTIVATE: - // If we want to have a frameless window but with border, extend the client area outside of the window. This - // Option is not affected by returning 0 in WM_NCCALCSIZE. - // As a result we have hidden the titlebar but still have the default border drawn. + // If we want to have a frameless window but with the default frame decorations, extend the DWM client area. + // This Option is not affected by returning 0 in WM_NCCALCSIZE. + // As a result we have hidden the titlebar but still have the default window frame styling. // See: https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea#remarks if winoptions := w.frontendOptions.Windows; winoptions != nil && winoptions.EnableFramelessBorder { - if err := dwmExtendFrameIntoClientArea(w.Handle(), w32.MARGINS{-1, -1, -1, -1}); err != nil { + // -1: Adds the default frame styling (aero shadow and e.g. rounded corners on Windows 11) + // Also shows the caption buttons if transparent ant translucent but they don't work. + // 0: Adds the default frame styling but no aero shadow, does not show the caption buttons. + // 1: Adds the default frame styling (aero shadow and e.g. rounded corners on Windows 11) but no caption buttons + // are shown if transparent ant translucent. + margins := w32.MARGINS{1, 1, 1, 1} // Only extend 1 pixel to have the default frame styling but no caption buttons + if err := dwmExtendFrameIntoClientArea(w.Handle(), margins); err != nil { log.Fatal(fmt.Errorf("DwmExtendFrameIntoClientArea failed: %s", err)) } }