mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
xevent on clipboard updated.
This commit is contained in:
parent
e9912ea87f
commit
9394b361bd
@ -175,47 +175,19 @@ func (ws *WebSocketHandler) Start() {
|
||||
}
|
||||
})
|
||||
|
||||
ws.wg.Add(1)
|
||||
go func() {
|
||||
defer func() {
|
||||
ws.logger.Info().Msg("shutdown")
|
||||
ws.wg.Done()
|
||||
}()
|
||||
|
||||
current := ws.desktop.ReadClipboard()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ws.shutdown:
|
||||
return
|
||||
default:
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
if !ws.sessions.HasHost() {
|
||||
continue
|
||||
}
|
||||
|
||||
text := ws.desktop.ReadClipboard()
|
||||
if text == current {
|
||||
continue
|
||||
}
|
||||
|
||||
ws.desktop.OnClipboardUpdated(func() {
|
||||
session, ok := ws.sessions.GetHost()
|
||||
if ok {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
err := session.Send(message.Clipboard{
|
||||
Event: event.CONTROL_CLIPBOARD,
|
||||
Text: text,
|
||||
Text: ws.desktop.ReadClipboard(),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
ws.logger.Err(err).Msg("unable to synchronize clipboard")
|
||||
}
|
||||
}
|
||||
|
||||
current = text
|
||||
}
|
||||
}
|
||||
}()
|
||||
ws.logger.Err(err).Msg("sync clipboard")
|
||||
})
|
||||
}
|
||||
|
||||
func (ws *WebSocketHandler) Shutdown() error {
|
||||
|
Loading…
Reference in New Issue
Block a user