mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:39:30 +08:00
[windows] Disable frameless decorations during fullscreen (#2288)
Otherwise this leads to thin transparent lines on the window borders on older Windows versions.
This commit is contained in:
parent
05679e70d0
commit
aaf039bcff
@ -81,14 +81,17 @@ type MONITORINFO struct {
|
|||||||
DwFlags uint32
|
DwFlags uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExtendFrameIntoClientArea(hwnd uintptr) {
|
func ExtendFrameIntoClientArea(hwnd uintptr, extend bool) {
|
||||||
// -1: Adds the default frame styling (aero shadow and e.g. rounded corners on Windows 11)
|
// -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.
|
// 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.
|
// 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
|
// 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.
|
// are shown if transparent ant translucent.
|
||||||
margins := &MARGINS{1, 1, 1, 1} // Only extend 1 pixel to have the default frame styling but no caption buttons
|
var margins MARGINS
|
||||||
if err := dwmExtendFrameIntoClientArea(hwnd, margins); err != nil {
|
if extend {
|
||||||
|
margins = MARGINS{1, 1, 1, 1} // Only extend 1 pixel to have the default frame styling but no caption buttons
|
||||||
|
}
|
||||||
|
if err := dwmExtendFrameIntoClientArea(hwnd, &margins); err != nil {
|
||||||
log.Fatal(fmt.Errorf("DwmExtendFrameIntoClientArea failed: %s", err))
|
log.Fatal(fmt.Errorf("DwmExtendFrameIntoClientArea failed: %s", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ type Window struct {
|
|||||||
theme winoptions.Theme
|
theme winoptions.Theme
|
||||||
themeChanged bool
|
themeChanged bool
|
||||||
|
|
||||||
|
framelessWithDecorations bool
|
||||||
|
|
||||||
OnSuspend func()
|
OnSuspend func()
|
||||||
OnResume func()
|
OnResume func()
|
||||||
dragging bool
|
dragging bool
|
||||||
@ -39,6 +41,8 @@ type Window struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *operatingsystem.WindowsVersionInfo, chromium *edge.Chromium) *Window {
|
func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *operatingsystem.WindowsVersionInfo, chromium *edge.Chromium) *Window {
|
||||||
|
windowsOptions := appoptions.Windows
|
||||||
|
|
||||||
result := &Window{
|
result := &Window{
|
||||||
frontendOptions: appoptions,
|
frontendOptions: appoptions,
|
||||||
minHeight: appoptions.MinHeight,
|
minHeight: appoptions.MinHeight,
|
||||||
@ -49,13 +53,15 @@ func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *ope
|
|||||||
isActive: true,
|
isActive: true,
|
||||||
themeChanged: true,
|
themeChanged: true,
|
||||||
chromium: chromium,
|
chromium: chromium,
|
||||||
|
|
||||||
|
framelessWithDecorations: appoptions.Frameless && (windowsOptions == nil || !windowsOptions.DisableFramelessWindowDecorations),
|
||||||
}
|
}
|
||||||
result.SetIsForm(true)
|
result.SetIsForm(true)
|
||||||
|
|
||||||
var exStyle int
|
var exStyle int
|
||||||
if appoptions.Windows != nil {
|
if windowsOptions != nil {
|
||||||
exStyle = w32.WS_EX_CONTROLPARENT | w32.WS_EX_APPWINDOW
|
exStyle = w32.WS_EX_CONTROLPARENT | w32.WS_EX_APPWINDOW
|
||||||
if appoptions.Windows.WindowIsTranslucent {
|
if windowsOptions.WindowIsTranslucent {
|
||||||
exStyle |= w32.WS_EX_NOREDIRECTIONBITMAP
|
exStyle |= w32.WS_EX_NOREDIRECTIONBITMAP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +78,7 @@ func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *ope
|
|||||||
result.SetParent(parent)
|
result.SetParent(parent)
|
||||||
|
|
||||||
loadIcon := true
|
loadIcon := true
|
||||||
if appoptions.Windows != nil && appoptions.Windows.DisableWindowIcon == true {
|
if windowsOptions != nil && windowsOptions.DisableWindowIcon == true {
|
||||||
loadIcon = false
|
loadIcon = false
|
||||||
}
|
}
|
||||||
if loadIcon {
|
if loadIcon {
|
||||||
@ -85,8 +91,8 @@ func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *ope
|
|||||||
win32.SetBackgroundColour(result.Handle(), appoptions.BackgroundColour.R, appoptions.BackgroundColour.G, appoptions.BackgroundColour.B)
|
win32.SetBackgroundColour(result.Handle(), appoptions.BackgroundColour.R, appoptions.BackgroundColour.G, appoptions.BackgroundColour.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
if appoptions.Windows != nil {
|
if windowsOptions != nil {
|
||||||
result.theme = appoptions.Windows.Theme
|
result.theme = windowsOptions.Theme
|
||||||
} else {
|
} else {
|
||||||
result.theme = winoptions.SystemDefault
|
result.theme = winoptions.SystemDefault
|
||||||
}
|
}
|
||||||
@ -102,18 +108,18 @@ func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *ope
|
|||||||
|
|
||||||
result.UpdateTheme()
|
result.UpdateTheme()
|
||||||
|
|
||||||
if appoptions.Windows != nil {
|
if windowsOptions != nil {
|
||||||
result.OnSuspend = appoptions.Windows.OnSuspend
|
result.OnSuspend = windowsOptions.OnSuspend
|
||||||
result.OnResume = appoptions.Windows.OnResume
|
result.OnResume = windowsOptions.OnResume
|
||||||
if appoptions.Windows.WindowIsTranslucent {
|
if windowsOptions.WindowIsTranslucent {
|
||||||
if !win32.SupportsBackdropTypes() {
|
if !win32.SupportsBackdropTypes() {
|
||||||
result.SetTranslucentBackground()
|
result.SetTranslucentBackground()
|
||||||
} else {
|
} else {
|
||||||
win32.EnableTranslucency(result.Handle(), win32.BackdropType(appoptions.Windows.BackdropType))
|
win32.EnableTranslucency(result.Handle(), win32.BackdropType(windowsOptions.BackdropType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if appoptions.Windows.DisableWindowIcon {
|
if windowsOptions.DisableWindowIcon {
|
||||||
result.DisableIcon()
|
result.DisableIcon()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,6 +137,12 @@ func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *ope
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Fullscreen() {
|
func (w *Window) Fullscreen() {
|
||||||
|
if w.Form.IsFullScreen() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if w.framelessWithDecorations {
|
||||||
|
win32.ExtendFrameIntoClientArea(w.Handle(), false)
|
||||||
|
}
|
||||||
w.Form.SetMaxSize(0, 0)
|
w.Form.SetMaxSize(0, 0)
|
||||||
w.Form.SetMinSize(0, 0)
|
w.Form.SetMinSize(0, 0)
|
||||||
w.Form.Fullscreen()
|
w.Form.Fullscreen()
|
||||||
@ -140,6 +152,9 @@ func (w *Window) UnFullscreen() {
|
|||||||
if !w.Form.IsFullScreen() {
|
if !w.Form.IsFullScreen() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.framelessWithDecorations {
|
||||||
|
win32.ExtendFrameIntoClientArea(w.Handle(), true)
|
||||||
|
}
|
||||||
w.Form.UnFullscreen()
|
w.Form.UnFullscreen()
|
||||||
w.SetMinSize(w.minWidth, w.minHeight)
|
w.SetMinSize(w.minWidth, w.minHeight)
|
||||||
w.SetMaxSize(w.maxWidth, w.maxHeight)
|
w.SetMaxSize(w.maxWidth, w.maxHeight)
|
||||||
@ -231,8 +246,8 @@ func (w *Window) WndProc(msg uint32, wparam, lparam uintptr) uintptr {
|
|||||||
// This Option is not affected by returning 0 in WM_NCCALCSIZE.
|
// 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.
|
// 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
|
// See: https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea#remarks
|
||||||
if winoptions := w.frontendOptions.Windows; winoptions == nil || !winoptions.DisableFramelessWindowDecorations {
|
if w.framelessWithDecorations {
|
||||||
win32.ExtendFrameIntoClientArea(w.Handle())
|
win32.ExtendFrameIntoClientArea(w.Handle(), true)
|
||||||
}
|
}
|
||||||
case w32.WM_NCCALCSIZE:
|
case w32.WM_NCCALCSIZE:
|
||||||
// Disable the standard frame by allowing the client area to take the full
|
// Disable the standard frame by allowing the client area to take the full
|
||||||
|
@ -19,7 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Added `EnableFraudulentWebsiteDetection` option to opt-in to scan services for fraudulent content, such as malware or phishing attempts. Older releases had the scan services per default activated. Added by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2269)
|
- Added `EnableFraudulentWebsiteDetection` option to opt-in to scan services for fraudulent content, such as malware or phishing attempts. Older releases had the scan services per default activated. Added by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2269)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Improved fullscreen mode for frameless window on Windows. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2279)
|
- Improved fullscreen mode for frameless window on Windows. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2279) and [PR](https://github.com/wailsapp/wails/pull/2288)
|
||||||
- On Windows unmaximising a window has no effect anymore when the window is in fullscreen mode, this makes it consistent with e.g. macOS. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2279)
|
- On Windows unmaximising a window has no effect anymore when the window is in fullscreen mode, this makes it consistent with e.g. macOS. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2279)
|
||||||
- Frameless resize now sets the cursor on documentElement, otherwise resizing cursor won't be shown outside of the body rectangle. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2289)
|
- Frameless resize now sets the cursor on documentElement, otherwise resizing cursor won't be shown outside of the body rectangle. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2289)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user