Turn off atomic update during direct transmission

This commit is contained in:
Kovid Goyal 2023-03-27 20:54:03 +05:30
parent 80204c6056
commit 94db6053d5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 17 additions and 1 deletions

View File

@ -327,8 +327,13 @@ func (self *ImageCollection) new_graphics_command() *GraphicsCommand {
}
func transmit_by_escape_code(lp *loop.Loop, image_id uint32, temp_file_map map[uint32]*temp_resource, frame *images.ImageFrame, gc *GraphicsCommand) {
atomic := lp.IsAtomicUpdateActive()
lp.EndAtomicUpdate()
gc.SetTransmission(GRT_transmission_direct)
gc.WriteWithPayloadToLoop(lp, frame.Data())
if atomic {
lp.StartAtomicUpdate()
}
}
func transmit_by_shm(lp *loop.Loop, image_id uint32, temp_file_map map[uint32]*temp_resource, frame *images.ImageFrame, gc *GraphicsCommand) {

View File

@ -62,6 +62,7 @@ type Loop struct {
on_SIGTSTP func() error
style_cache map[string]func(...any) string
style_ctx style.Context
atomic_update_active bool
// Suspend the loop restoring terminal state. Call the return resume function to restore the loop
Suspend func() (func() error, error)
@ -290,11 +291,20 @@ func (self *Loop) Beep() {
}
func (self *Loop) StartAtomicUpdate() {
if self.atomic_update_active {
self.EndAtomicUpdate()
}
self.QueueWriteString(PENDING_UPDATE.EscapeCodeToSet())
self.atomic_update_active = true
}
func (self *Loop) IsAtomicUpdateActive() bool { return self.atomic_update_active }
func (self *Loop) EndAtomicUpdate() {
self.QueueWriteString(PENDING_UPDATE.EscapeCodeToReset())
if self.atomic_update_active {
self.QueueWriteString(PENDING_UPDATE.EscapeCodeToReset())
self.atomic_update_active = false
}
}
func (self *Loop) SetCursorShape(shape CursorShapes, blink bool) {

View File

@ -286,6 +286,7 @@ func (self *Loop) run() (err error) {
self.death_signal = SIGNULL
self.escape_code_parser.Reset()
self.exit_code = 0
self.atomic_update_active = false
self.timers = make([]*timer, 0, 1)
no_timeout_channel := make(<-chan time.Time)
finalizer := ""