add control cut.

This commit is contained in:
Miroslav Šedivý 2022-01-30 17:53:22 +01:00
parent e8c7ab421a
commit 26ab7fa12d
3 changed files with 11 additions and 0 deletions

View File

@ -37,6 +37,7 @@ const (
CONTROL_KEYDOWN = "control/keydown"
CONTROL_KEYUP = "control/keyup"
// actions
CONTROL_CUT = "control/cut"
CONTROL_COPY = "control/copy"
CONTROL_PASTE = "control/paste"
CONTROL_SELECT_ALL = "control/select_all"

View File

@ -83,6 +83,14 @@ func (h *MessageHandlerCtx) controlKeyUp(session types.Session, payload *message
return h.desktop.KeyUp(payload.Keysym)
}
func (h *MessageHandlerCtx) controlCut(session types.Session) error {
if err := h.controlRequest(session); err != nil && !errors.Is(err, ErrIsAlreadyTheHost) {
return err
}
return h.desktop.KeyPress(xorg.XK_Control_L, xorg.XK_x)
}
func (h *MessageHandlerCtx) controlCopy(session types.Session) error {
if err := h.controlRequest(session); err != nil && !errors.Is(err, ErrIsAlreadyTheHost) {
return err

View File

@ -92,6 +92,8 @@ func (h *MessageHandlerCtx) Message(session types.Session, data types.WebSocketM
err = utils.Unmarshal(payload, data.Payload, func() error {
return h.controlKeyUp(session, payload)
})
case event.CONTROL_CUT:
err = h.controlCut(session)
case event.CONTROL_COPY:
err = h.controlCopy(session)
case event.CONTROL_PASTE: