Closed jddk closed 1 year ago
Thanks for opening this. What's Pinyin, and what is the expected behaviour here?
@leaanthony Pinyin is one of the input method of Chinese, it can use some characters to match Chinese words. When you are using Pinyin, there would be a float window showing the matching words of your input(just like the "good" part of the Description image) But currently @jddk using wails demo, input in the demo and found no float window(just like the "wails bad" part of the Description image)
But it cannot reproduce on my computer, I try both "Apple Pinyin" and "squirrel", and they both work perfectly with wails. 1, wails with Squirrel: 2, wails with Apple Pinyin:
Some information of my env:
# uname -a
Darwin [MacBook-Pro.local](http://macbook-pro.local/) 21.6.0 Darwin Kernel Version 21.6.0: Thu Jun 8 23:57:12 PDT 2023; root:xnu-8020.240.18.701.6~1/RELEASE_X86_64 x86_64
# go version
go version go1.20.4 darwin/amd64
#xcode-select -v
xcode-select version 2395
#node -v
v20.1.0
in main.go , set AlwaysOnTop: true, Pinyin pop-ups are applied to cover
func main() {
// Create an instance of the app structure
app := NewApp()
// Create application with options
err := wails.Run(&options.App{
Title: "✍️临时记",
Width: 400,
Height: 300,
AlwaysOnTop: true, //add this
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 0},
OnStartup: app.startup,
Bind: []interface{}{
app,
},
})
if err != nil {
println("Error:", err.Error())
}
}
@jddk I try AlwaysOnTop, and reproduce with "Apple Pinyin":
but it still works well with My "squirrel":
I think the main problem is the Window Level. In wails, on MacOS, AlwaysOnTop option will set Window Level to NSStatusWindowLevel, and higher level window will always cover lower level window, my squirrel input method using window level of "NSScreenSaverWindowLevel + 1"(higher than NSStatusWindowLevel of wails), so it would not be covered, however, I think the "Apple Pinyin" use a lower level, so it will be covered.
valid options of Window Level:
- NSNormalWindowLevel
- NSFloatingWindowLevel
- NSSubmenuWindowLevel
- NSTornOffMenuWindowLevel
- NSModalPanelWindowLevel
- NSMainMenuWindowLevel
- NSStatusWindowLevel
- NSPopUpMenuWindowLevel
- NSScreenSaverWindowLevel
- kCGDesktopWindowLevel
@leaanthony @jddk I think this can be solved by one of these solutions: 1, allow user to set the window level of AlwaysOnTop option. 2, find out what level "Apple Pinyin" are using, and replace wails' NSStatusWindowLevel to a lower level, so it would not covered "Apple Pinyin" again.
For convenience, the SetAlwaysOnTop method is here: https://github.com/wailsapp/wails/blob/e31ad83472262d5ca023bf8899f8f099e420f94e/v2/internal/frontend/desktop/darwin/WailsContext.m#L407C1-L413C2
Thanks for the detailed explanation - I didn't really understand the issue. I think this is something we should make configurable. Not sure what that looks like cross platform. Perhaps it's just a different call... what do other frameworks do?
Thanks for the detailed explanation - I didn't really understand the issue. I think this is something we should make configurable. Not sure what that looks like cross platform. Perhaps it's just a different call... what do other frameworks do?
electron seems to be used NSFloatingWindowLevel https://github.com/electron/electron/blob/e61359598214399cab97ca6a8ad541983059c331/shell/browser/native_window_mac.mm#L941-L948. And I change the
// Set NSWindow always on top
void windowSetAlwaysOnTop(void* nsWindow, bool alwaysOnTop) {
// Set window always on top on main thread
[(WebviewWindow*)nsWindow setLevel:alwaysOnTop ? NSStatusWindowLevel : NSNormalWindowLevel];
}
to
// Set NSWindow always on top
void windowSetAlwaysOnTop(void* nsWindow, bool alwaysOnTop) {
// Set window always on top on main thread
[(WebviewWindow*)nsWindow setLevel:alwaysOnTop ? NSFloatingWindowLevel : NSNormalWindowLevel];
}
and it worked.
Awesome! Please feel free to open a PR 🙏
Description
input Simplified Chinese input cannot display floating Windows
To Reproduce
Expected behaviour
use macbook
Screenshots
No response
Attempted Fixes
No response
System Details
Additional context
No response