Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mac] fix always on top during window creation #3841

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading