add layout variant.

This commit is contained in:
Miroslav Šedivý 2021-01-12 23:52:44 +01:00
parent 7f18c5842d
commit 71dbdc06f5
5 changed files with 10 additions and 8 deletions

View File

@ -9,6 +9,7 @@ import (
type KeyboardLayoutData struct {
Layout string `json:"layout"`
Variant string `json:"variant"`
}
type KeyboardModifiersData struct {
@ -22,7 +23,7 @@ func (h *RoomHandler) keyboardLayoutSet(w http.ResponseWriter, r *http.Request)
return
}
err := h.desktop.SetKeyboardLayout(data.Layout)
err := h.desktop.SetKeyboardLayout(data.Layout, data.Variant)
if err != nil{
utils.HttpInternalServerError(w, "Unable to change keyboard layout.")
return

View File

@ -55,9 +55,9 @@ func (manager *DesktopManagerCtx) ChangeScreenSize(width int, height int, rate i
return xorg.ChangeScreenSize(width, height, rate)
}
func (manager *DesktopManagerCtx) SetKeyboardLayout(layout string) error {
func (manager *DesktopManagerCtx) SetKeyboardLayout(layout string, variant string) error {
// TOOD: Use native API.
cmd := exec.Command("setxkbmap", layout)
cmd := exec.Command("setxkbmap", "-layout", layout, "-variant", variant)
_, err := cmd.Output()
return err
}

View File

@ -43,7 +43,7 @@ type DesktopManager interface {
ResetKeys()
ScreenConfigurations() map[int]ScreenConfiguration
GetScreenSize() *ScreenSize
SetKeyboardLayout(layout string) error
SetKeyboardLayout(layout string, variant string) error
SetKeyboardModifiers(mod KeyboardModifiers)
GetKeyboardModifiers() KeyboardModifiers
GetCursorImage() *CursorImage

View File

@ -142,6 +142,7 @@ type KeyboardModifiers struct {
type KeyboardLayout struct {
Event string `json:"event,omitempty"`
Layout string `json:"layout"`
Variant string `json:"variant"`
}
/////////////////////////////

View File

@ -12,7 +12,7 @@ func (h *MessageHandlerCtx) keyboardLayout(session types.Session, payload *messa
return nil
}
return h.desktop.SetKeyboardLayout(payload.Layout)
return h.desktop.SetKeyboardLayout(payload.Layout, payload.Variant)
}
func (h *MessageHandlerCtx) keyboardModifiers(session types.Session, payload *message.KeyboardModifiers) error {