Skip to content

Commit

Permalink
Dispatch ResizeEvent after drawing
Browse files Browse the repository at this point in the history
This commit changes the Unix screen to dispatch events after drawing.
This helps draw interceptors update its states in time before the user
gets the event.
  • Loading branch information
diamondburned committed Mar 5, 2021
1 parent f57619d commit fe2730f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tscreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (t tScreen) Init() error {
t.cells.Resize(w, h)
t.cursorx = -1
t.cursory = -1
t.resize()
t.resize(true)
t.Unlock()

if err := t.engage(); err != nil {
Expand Down Expand Up @@ -784,8 +784,9 @@ func (t tScreen) TPuts(s string) {
func (t tScreen) Show() {
t.Lock()
if !t.fini {
t.resize()
t.resize(false)
t.draw()
t.dispatchResizeEvent()
}
t.Unlock()
}
Expand Down Expand Up @@ -1526,8 +1527,9 @@ func (t tScreen) mainLoop(stopQ chan struct{}) {
t.Lock()
t.cx = -1
t.cy = -1
t.resize()
t.resize(false)
t.draw()
t.dispatchResizeEvent()
t.Unlock()
continue
case <-t.keytimer.C:
Expand Down Expand Up @@ -1595,10 +1597,11 @@ func (t tScreen) Sync() {
t.cx = -1
t.cy = -1
if !t.fini {
t.resize()
t.resize(false)
t.clear = true
t.cells.Invalidate()
t.draw()
t.dispatchResizeEvent()
}
t.Unlock()
}
Expand Down

0 comments on commit fe2730f

Please sign in to comment.