mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
app/internal/window: [wasm] add support for StageEvent
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
type window struct {
|
type window struct {
|
||||||
window js.Value
|
window js.Value
|
||||||
|
document js.Value
|
||||||
clipboard js.Value
|
clipboard js.Value
|
||||||
cnv js.Value
|
cnv js.Value
|
||||||
tarea js.Value
|
tarea js.Value
|
||||||
@@ -48,6 +49,7 @@ func NewWindow(win Callbacks, opts *Options) error {
|
|||||||
cont.Call("appendChild", tarea)
|
cont.Call("appendChild", tarea)
|
||||||
w := &window{
|
w := &window{
|
||||||
cnv: cnv,
|
cnv: cnv,
|
||||||
|
document: doc,
|
||||||
tarea: tarea,
|
tarea: tarea,
|
||||||
window: js.Global().Get("window"),
|
window: js.Global().Get("window"),
|
||||||
clipboard: js.Global().Get("navigator").Get("clipboard"),
|
clipboard: js.Global().Get("navigator").Get("clipboard"),
|
||||||
@@ -138,6 +140,17 @@ func (w *window) addEventListeners() {
|
|||||||
|
|
||||||
return w.browserHistory.Call("back")
|
return w.browserHistory.Call("back")
|
||||||
})
|
})
|
||||||
|
w.addEventListener(w.document, "visibilitychange", func(this js.Value, args []js.Value) interface{} {
|
||||||
|
ev := system.StageEvent{}
|
||||||
|
switch w.document.Get("visibilityState").String() {
|
||||||
|
case "hidden", "prerender", "unloaded":
|
||||||
|
ev.Stage = system.StagePaused
|
||||||
|
default:
|
||||||
|
ev.Stage = system.StageRunning
|
||||||
|
}
|
||||||
|
w.w.Event(ev)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
w.addEventListener(w.cnv, "mousemove", func(this js.Value, args []js.Value) interface{} {
|
w.addEventListener(w.cnv, "mousemove", func(this js.Value, args []js.Value) interface{} {
|
||||||
w.pointerEvent(pointer.Move, 0, 0, args[0])
|
w.pointerEvent(pointer.Move, 0, 0, args[0])
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user