Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/os_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ import "C"
import (
"errors"
"fmt"
"gioui.org/io/transfer"
"image"
"image/color"
"io"
Expand All @@ -147,6 +146,7 @@ import (
"gioui.org/io/pointer"
"gioui.org/io/semantic"
"gioui.org/io/system"
"gioui.org/io/transfer"
"gioui.org/unit"
)

Expand Down Expand Up @@ -527,13 +527,17 @@ func Java_org_gioui_GioView_onStopView(env *C.JNIEnv, class C.jclass, handle C.j
w := cgo.Handle(handle).Value().(*window)
w.started = false
w.visible = false
w.focused = false

w.sendConfigEvent()
}

//export Java_org_gioui_GioView_onStartView
func Java_org_gioui_GioView_onStartView(env *C.JNIEnv, class C.jclass, handle C.jlong) {
w := cgo.Handle(handle).Value().(*window)
w.started = true
w.focused = true

if w.win != nil {
w.setVisible(env)
}
Expand Down
7 changes: 7 additions & 0 deletions app/os_ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ func onCreate(view, controller C.CFTypeRef) {
w := &window{
view: view,
w: wopts.window,
config: Config{
Focused: true,
},
}
w.loop = newEventLoop(w.w, w.wakeup)
w.w.SetDriver(w)
Expand Down Expand Up @@ -196,13 +199,17 @@ func (w *window) draw(sync bool) {
func onStop(h C.uintptr_t) {
w := viewFor(h)
w.hidden = true
w.config.Focused = false
w.ProcessEvent(ConfigEvent{Config: w.config})
}

//export onStart
func onStart(h C.uintptr_t) {
w := viewFor(h)
w.hidden = false
w.config.Focused = true
w.draw(true)
w.ProcessEvent(ConfigEvent{Config: w.config})
}

//export onDestroy
Expand Down
8 changes: 6 additions & 2 deletions app/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,15 @@ func (w *Window) processEvent(e event.Event) bool {
w.decorations.Config = e2.Config
e2.Config = w.effectiveConfig()
w.coalesced.cfg = &e2

handled := false
if f := w.decorations.Config.Focused; f != wasFocused {
w.queue.Queue(key.FocusEvent{Focus: f})
// Ensures focus change is processed on android.
handled = true
}
t, handled := w.queue.WakeupTime()
if handled {
t, h := w.queue.WakeupTime()
if handled || h {
w.setNextFrame(t)
w.updateAnimation()
}
Expand Down