diff --git a/mkdocs-website/docs/en/changelog.md b/mkdocs-website/docs/en/changelog.md index 84b224373..732b870c2 100644 --- a/mkdocs-website/docs/en/changelog.md +++ b/mkdocs-website/docs/en/changelog.md @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- [windows] Window class name option by [windom](https://github.com/windom/) in [#3682](https://github.com/wailsapp/wails/pull/3682) + ### Fixed - [windows] Fixed syso icon file generation bug by [atterpac](https://github.com/atterpac) in [#3675](https://github.com/wailsapp/wails/pull/3675) diff --git a/v3/pkg/application/application.go b/v3/pkg/application/application.go index c67557c6e..540b749a9 100644 --- a/v3/pkg/application/application.go +++ b/v3/pkg/application/application.go @@ -168,6 +168,9 @@ func mergeApplicationDefaults(o *Options) { if o.Description == "" { o.Description = "An application written using Wails" } + if o.Windows.WndClass == "" { + o.Windows.WndClass = "WailsWebviewWindow" + } } type ( diff --git a/v3/pkg/application/application_options.go b/v3/pkg/application/application_options.go index c9580f158..cfda959b2 100644 --- a/v3/pkg/application/application_options.go +++ b/v3/pkg/application/application_options.go @@ -182,6 +182,10 @@ type MacOptions struct { // WindowsOptions contains options for Windows applications. type WindowsOptions struct { + // Window class name + // Default: WailsWebviewWindow + WndClass string + // WndProcInterceptor is a function that will be called for every message sent in the application. // Use this to hook into the main message loop. This is useful for handling custom window messages. // If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop. diff --git a/v3/pkg/application/application_windows.go b/v3/pkg/application/application_windows.go index ddc9a58fb..c043756b0 100644 --- a/v3/pkg/application/application_windows.go +++ b/v3/pkg/application/application_windows.go @@ -16,12 +16,8 @@ import ( "github.com/wailsapp/wails/v3/pkg/events" "github.com/wailsapp/wails/v3/pkg/w32" - - "github.com/samber/lo" ) -var windowClassName = lo.Must(syscall.UTF16PtrFromString("WailsWebviewWindow")) - type windowsApp struct { parent *App @@ -212,7 +208,7 @@ func (m *windowsApp) init() { m.windowClass.Background = w32.COLOR_BTNFACE + 1 m.windowClass.Icon = icon m.windowClass.Cursor = w32.LoadCursorWithResourceID(0, w32.IDC_ARROW) - m.windowClass.ClassName = windowClassName + m.windowClass.ClassName = w32.MustStringToUTF16Ptr(m.parent.options.Windows.WndClass) m.windowClass.MenuName = nil m.windowClass.IconSm = icon diff --git a/v3/pkg/application/mainthread_windows.go b/v3/pkg/application/mainthread_windows.go index fd59ff1e7..ddee96339 100644 --- a/v3/pkg/application/mainthread_windows.go +++ b/v3/pkg/application/mainthread_windows.go @@ -34,7 +34,7 @@ func (m *windowsApp) initMainLoop() { // > Because the system directs messages to individual windows in an application, a thread must create at least one window before starting its message loop. m.mainThreadWindowHWND = w32.CreateWindowEx( 0, - windowClassName, + w32.MustStringToUTF16Ptr(m.parent.options.Windows.WndClass), w32.MustStringToUTF16Ptr("__wails_hidden_mainthread"), w32.WS_DISABLED, w32.CW_USEDEFAULT, diff --git a/v3/pkg/application/systemtray_windows.go b/v3/pkg/application/systemtray_windows.go index 36668f961..9262abf06 100644 --- a/v3/pkg/application/systemtray_windows.go +++ b/v3/pkg/application/systemtray_windows.go @@ -150,7 +150,7 @@ func (s *windowsSystemTray) setMenu(menu *Menu) { func (s *windowsSystemTray) run() { s.hwnd = w32.CreateWindowEx( 0, - windowClassName, + w32.MustStringToUTF16Ptr(globalApplication.options.Windows.WndClass), nil, 0, 0, diff --git a/v3/pkg/application/webview_window_windows.go b/v3/pkg/application/webview_window_windows.go index 3999ffe6c..647e6b566 100644 --- a/v3/pkg/application/webview_window_windows.go +++ b/v3/pkg/application/webview_window_windows.go @@ -249,7 +249,7 @@ func (w *windowsWebviewWindow) run() { w.hwnd = w32.CreateWindowEx( uint(exStyle), - windowClassName, + w32.MustStringToUTF16Ptr(globalApplication.options.Windows.WndClass), w32.MustStringToUTF16Ptr(options.Title), style, startX,