mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
apps,ui/app: delete ui/app.Window.Ack
Replace it with a dummy event send on the synchronous event channel; a bit of cleverness for a simpler API. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -200,7 +200,6 @@ func (a *App) run() error {
|
||||
a.pqueue.Frame(root)
|
||||
a.faces.Frame()
|
||||
}
|
||||
a.w.Ack()
|
||||
}
|
||||
}
|
||||
return a.w.Err()
|
||||
|
||||
@@ -52,7 +52,6 @@ func init() {
|
||||
w.Draw(root)
|
||||
faces.Frame()
|
||||
}
|
||||
w.Ack()
|
||||
}
|
||||
if w.Err() != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
+18
-27
@@ -32,7 +32,6 @@ type Window struct {
|
||||
err error
|
||||
|
||||
events chan Event
|
||||
acks chan struct{}
|
||||
|
||||
mu sync.Mutex
|
||||
stage Stage
|
||||
@@ -55,11 +54,12 @@ var _ interface {
|
||||
setTextInput(s key.TextInputState)
|
||||
} = (*window)(nil)
|
||||
|
||||
var ackEvent Event
|
||||
|
||||
func newWindow(nw *window) *Window {
|
||||
w := &Window{
|
||||
driver: nw,
|
||||
events: make(chan Event),
|
||||
acks: make(chan struct{}),
|
||||
stage: StageInvisible,
|
||||
}
|
||||
return w
|
||||
@@ -69,30 +69,6 @@ func (w *Window) Events() <-chan Event {
|
||||
return w.events
|
||||
}
|
||||
|
||||
func (w *Window) Ack() {
|
||||
w.mu.Lock()
|
||||
st := w.stage
|
||||
needAck := w.skipAcks == 0
|
||||
if !needAck {
|
||||
w.skipAcks--
|
||||
}
|
||||
sync := w.syncGPU
|
||||
w.syncGPU = false
|
||||
w.mu.Unlock()
|
||||
if w.gpu != nil {
|
||||
switch {
|
||||
case st < StageVisible:
|
||||
w.gpu.Release()
|
||||
w.gpu = nil
|
||||
case sync:
|
||||
w.gpu.Refresh()
|
||||
}
|
||||
}
|
||||
if needAck {
|
||||
w.acks <- struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Window) Timings() string {
|
||||
return w.timings
|
||||
}
|
||||
@@ -258,7 +234,22 @@ func (w *Window) event(e Event) {
|
||||
w.updateAnimation()
|
||||
w.events <- e
|
||||
if needAck {
|
||||
<-w.acks
|
||||
// Send a dummy event; when it gets through we
|
||||
// know the application has processed the actual event.
|
||||
w.events <- ackEvent
|
||||
}
|
||||
if w.gpu != nil {
|
||||
w.mu.Lock()
|
||||
sync := w.syncGPU
|
||||
w.syncGPU = false
|
||||
w.mu.Unlock()
|
||||
switch {
|
||||
case stage < StageVisible:
|
||||
w.gpu.Release()
|
||||
w.gpu = nil
|
||||
case sync:
|
||||
w.gpu.Refresh()
|
||||
}
|
||||
}
|
||||
if stage == StageDead {
|
||||
close(w.events)
|
||||
|
||||
Reference in New Issue
Block a user