Skip to content

Commit

Permalink
[mac] fix always on top during window creation (#3841)
Browse files Browse the repository at this point in the history
* [mac] fix always on top during window creation

* Update changelog.md
  • Loading branch information
leaanthony authored Oct 20, 2024
1 parent 94e8f8b commit b27aed2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions mkdocs-website/docs/en/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Upgrade to `go-webview2` v1.0.16 by [leaanthony](https://github.com/leaanthony)
- Fixed `Screen` type to include `ID` not `Id` by [etesam913](https://github.com/etesam913) in [#3778](https://github.com/wailsapp/wails/pull/3778)

### Fixed
- Fixed `AlwaysOnTop` not working on Mac by [leaanthony](https://github.com/leaanthony)
in [#3841](https://github.com/wailsapp/wails/pull/3841)

## v3.0.0-alpha.7 - 2024-09-18

### Added
Expand Down
11 changes: 11 additions & 0 deletions v3/examples/window/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ func main() {
Show()
windowCounter++
})
myMenu.Add("New WebviewWindow (Always on top)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
AlwaysOnTop: true,
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
SetURL("https://wails.io").
Show()
windowCounter++
})
myMenu.Add("New WebviewWindow (Hide Maximise)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Expand Down
3 changes: 2 additions & 1 deletion v3/pkg/application/webview_window_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,6 @@ func (w *macosWebviewWindow) run() {
w.getWebviewPreferences(),
)
w.setTitle(options.Title)
w.setAlwaysOnTop(options.AlwaysOnTop)
w.setResizable(!options.DisableResize)
if options.MinWidth != 0 || options.MinHeight != 0 {
w.setMinSize(options.MinWidth, options.MinHeight)
Expand Down Expand Up @@ -1251,11 +1250,13 @@ func (w *macosWebviewWindow) run() {
if !options.Hidden {
C.windowShow(w.nsWindow)
w.setHasShadow(!options.Mac.DisableShadow)
w.setAlwaysOnTop(options.AlwaysOnTop)
} else {
// We have to wait until the window is shown before we can remove the shadow
var cancel func()
cancel = w.parent.OnWindowEvent(events.Mac.WindowDidBecomeKey, func(_ *WindowEvent) {
w.setHasShadow(!options.Mac.DisableShadow)
w.setAlwaysOnTop(options.AlwaysOnTop)
cancel()
})
}
Expand Down

0 comments on commit b27aed2

Please sign in to comment.