Files

55 lines
1.1 KiB
Go

package xorg
import (
"errors"
"git.stormux.org/storm/cthulhu/internal/input"
)
func (listener *CommandListener) SetSecureInputActive(active bool) {
listener.secureMutex.Lock()
defer listener.secureMutex.Unlock()
listener.secure.Store(active)
if active {
listener.browse.Store(false)
listener.nativeButtonFocus.Store(false)
}
for {
select {
case <-listener.commands:
case <-listener.lockStates:
default:
return
}
}
}
func (listener *CommandListener) publish_lock_state(state input.LockState) {
listener.secureMutex.Lock()
defer listener.secureMutex.Unlock()
if listener.secure.Load() {
return
}
select {
case listener.lockStates <- state:
default:
select {
case listener.failures <- errors.New("X11 lock state queue overflow"):
default:
}
}
}
func (listener *CommandListener) enqueueSecureCommand(command input.CommandEvent) bool {
listener.secureMutex.Lock()
defer listener.secureMutex.Unlock()
if listener.secure.Load() {
return true
}
select {
case listener.commands <- command:
return true
default:
return false
}
}