Add Some WindowState - #1349
Conversation
leaanthony
left a comment
There was a problem hiding this comment.
Thanks for submitting this! There's a few questions I had and a couple of suggestions. Am scheduling this in for v2.1
|
Great stuff! Thanks for all this hard work. I'm wondering if, at the API level, we should have |
|
That would be optimal for Windows. But I don't know how it is on macOS or Linux. I think it might be a possibility to offer this as a separate event as a callback when the state of the window changes. |
|
I think it should work on all platforms. Great idea on the events, just use the standard EventEmit call with "wails:window:maximised" etc. That's the convention 👍👍👍 |
|
Not sure why there's an emoji there. 🤣 |
|
@leaanthony I thought again and looked at Electron to understand how they map this case. |
| } | ||
|
|
||
| func (w *Window) IsMinimised() bool { | ||
| result := C.IsMinimised(w.asGTKWidget()) |
There was a problem hiding this comment.
Just wondering if this needs to be run on the main thread...
There was a problem hiding this comment.
I have not tested this yet. I am currently testing this in an Ubuntu VM. Windows and macOS works fine.
There was a problem hiding this comment.
Hey @zandercodes 👋 Just following up on the Linux testing. I can help with this if you need? It would be good to get this in!
There was a problem hiding this comment.
I've gone through and resolved the conflict. This should be good but let me know if there are issues 👍
There was a problem hiding this comment.
Hi @leaanthony, at the moment I don't have time to test this on Linux. But I will do it this week.
There was a problem hiding this comment.
Thanks. I might be able to. Will update here
|
Small status update. Merge conflicts are complicated to resolve. |
…llscreen Solve conflicts # Conflicts: # v2/internal/frontend/desktop/darwin/WailsContext.m # v2/internal/frontend/desktop/darwin/frontend.go # v2/internal/frontend/desktop/linux/window.go # v2/internal/frontend/desktop/windows/window.go
…llscreen Solve conflict # Conflicts: # v2/pkg/runtime/window.go
# Conflicts: # v2/internal/frontend/desktop/darwin/WailsContext.h # v2/internal/frontend/desktop/windows/win32/consts.go # v2/internal/frontend/desktop/windows/win32/window.go
# Conflicts: # v2/internal/frontend/devserver/devserver.go
# Conflicts: # v2/internal/frontend/dispatcher/systemcalls.go # v2/internal/frontend/runtime/desktop/window.js # v2/internal/frontend/runtime/package-lock.json # v2/internal/frontend/runtime/runtime_prod_desktop.js # v2/internal/frontend/runtime/wrapper/runtime.d.ts # v2/internal/frontend/runtime/wrapper/runtime.js
# Conflicts: # v2/cmd/wails/internal/commands/initialise/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.js # v2/internal/frontend/runtime/package-lock.json # v2/internal/frontend/runtime/runtime_dev_desktop.js
leaanthony
left a comment
There was a problem hiding this comment.
I can't see any show stoppers so far 👍 Just the merge conflict characters that are checked in 👍
| return int32(ret) | ||
| } | ||
|
|
||
| <<<<<<< HEAD |
|
I can test on Linux 👍 |
Yes, you can try, but i don´t know if it will work. |
|
Tested on Linux. Worked fine apart from when the window is fullscreen, I used this for testing - thought it might be useful: // Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
println("WindowIsFullscreen:", runtime.WindowIsFullscreen(a.ctx))
println("WindowIsMaximised:", runtime.WindowIsMaximised(a.ctx))
println("WindowIsMinimised:", runtime.WindowIsMinimised(a.ctx))
println("WindowIsNormal:", runtime.WindowIsNormal(a.ctx))
println("\n\n")
return fmt.Sprintf("Hello %s, It's show time!", name)
}and window.WindowState = function() {
WindowIsNormal().then((result) => {console.log("IsNormal: " + result);});
WindowIsMinimised().then((result) => {console.log("IsMinimised: " + result);});
WindowIsMaximised().then((result) => {console.log("IsMaximised: " + result);});
WindowIsFullscreen().then((result) => {console.log("IsFullscreen: " + result);});
}
window.testGo = function() {
WindowMinimise();
setTimeout(() => {
document.getElementsByTagName("button")[0].click();
WindowUnminimise();
}, 3000);
}
window.testJS = function() {
WindowMinimise();
setTimeout(() => {
WindowState();
WindowUnminimise();
}, 3000);
} |
Thanks for testing and fixing :D I'll finish the documentation for the website and then we can merge it. |
|
Do you want to just double check with those test methods to be sure? |
Good idea. I will test it again on windows and macos. So that we are sure that they really work. |
@leaanthony Works well on Windows and Mac |
|
Nice. Just let us know when the docs are ready and mark it ready for review 👍 |
# Conflicts: # v2/internal/frontend/runtime/package-lock.json # v2/internal/frontend/runtime/runtime_prod_desktop.js # v2/internal/messagedispatcher/dispatchclient.go
|
If @stffabi has no objections with this, I think we can merge in pre v2. |
Head branch was pushed to by a user without write access
|
Thanks for all your work on this! 🙏I did a quick update to the docs. Let's merge this and see how we go :-) |
Add Some WindowStates, States not tested.Add WindowStates for
Issue: #1348