mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-16 15:45:50 +01:00
* fix: prevent window menu crash on Wayland by realizing window before showing On Wayland with GTK3, the appmenu-gtk-module tries to set DBus properties for global menu integration before the window is fully realized, causing a crash with the error "GDK_IS_WAYLAND_WINDOW (window) assertion failed". The fix calls gtk_widget_realize() before gtk_widget_show_all() to ensure the window has a valid GdkWindow when the menu system accesses it. This fix is applied to both the CGO and purego implementations. Fixes wailsapp/wails#4769 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: add Wayland detection to wails3 doctor and test for #4769 - Add Wayland session detection row to `wails3 doctor` output on Linux - Create test project v3/test/4769-menu to manually verify the menu fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: sanitize GTK application name to prevent crashes with invalid characters Application names containing spaces, parentheses, hash symbols, or other invalid characters would cause GTK to fail with an assertion error. Added sanitizeAppName() function that: - Replaces invalid characters with underscores - Handles leading digits - Removes consecutive underscores - Defaults to "wailsapp" if empty 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
_ "embed"
|
|
"log"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
)
|
|
|
|
//go:embed assets/*
|
|
var assets embed.FS
|
|
|
|
func main() {
|
|
app := application.New(application.Options{
|
|
Name: "Menu Wayland Test (#4769)",
|
|
Description: "Test for window menu crash on Wayland",
|
|
Assets: application.AssetOptions{
|
|
Handler: application.BundledAssetFileServer(assets),
|
|
},
|
|
})
|
|
|
|
// Create a menu - this would crash on Wayland before the fix
|
|
menu := app.NewMenu()
|
|
|
|
fileMenu := menu.AddSubmenu("File")
|
|
fileMenu.Add("New").OnClick(func(ctx *application.Context) {
|
|
log.Println("New clicked")
|
|
})
|
|
fileMenu.Add("Open").OnClick(func(ctx *application.Context) {
|
|
log.Println("Open clicked")
|
|
})
|
|
fileMenu.AddSeparator()
|
|
fileMenu.Add("Exit").OnClick(func(ctx *application.Context) {
|
|
app.Quit()
|
|
})
|
|
|
|
editMenu := menu.AddSubmenu("Edit")
|
|
editMenu.Add("Cut").OnClick(func(ctx *application.Context) {
|
|
log.Println("Cut clicked")
|
|
})
|
|
editMenu.Add("Copy").OnClick(func(ctx *application.Context) {
|
|
log.Println("Copy clicked")
|
|
})
|
|
editMenu.Add("Paste").OnClick(func(ctx *application.Context) {
|
|
log.Println("Paste clicked")
|
|
})
|
|
|
|
helpMenu := menu.AddSubmenu("Help")
|
|
helpMenu.Add("About").OnClick(func(ctx *application.Context) {
|
|
log.Println("About clicked")
|
|
})
|
|
|
|
// Create window with menu attached via Linux options
|
|
// This tests the fix for issue #4769
|
|
app.Window.NewWithOptions(application.WebviewWindowOptions{
|
|
Title: "Menu Wayland Test (#4769)",
|
|
Width: 800,
|
|
Height: 600,
|
|
Linux: application.LinuxWindow{
|
|
Menu: menu,
|
|
},
|
|
})
|
|
|
|
log.Println("Starting application - if you see this on Wayland, the fix works!")
|
|
err := app.Run()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|