mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
code fmt change.
This commit is contained in:
@ -6,10 +6,11 @@ import (
|
||||
"demodesk/neko/internal/desktop/drop"
|
||||
)
|
||||
|
||||
const (
|
||||
DROP_MOVE_REPEAT = 4
|
||||
DROP_DELAY = 100 * time.Millisecond
|
||||
)
|
||||
// repeat move event multiple times
|
||||
const dropMoveRepeat = 4
|
||||
|
||||
// wait after each repeated move event
|
||||
const dropMoveDelay = 100 * time.Millisecond
|
||||
|
||||
func (manager *DesktopManagerCtx) DropFiles(x int, y int, files []string) bool {
|
||||
mu.Lock()
|
||||
@ -31,9 +32,9 @@ func (manager *DesktopManagerCtx) DropFiles(x int, y int, files []string) bool {
|
||||
})
|
||||
|
||||
drop.Emmiter.Once("begin", func(payload ...interface{}) {
|
||||
for i := 0; i < DROP_MOVE_REPEAT; i++ {
|
||||
for i := 0; i < dropMoveRepeat; i++ {
|
||||
manager.Move(x, y)
|
||||
time.Sleep(DROP_DELAY)
|
||||
time.Sleep(dropMoveDelay)
|
||||
}
|
||||
|
||||
//nolint
|
||||
|
@ -6,11 +6,14 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
FILE_CHOOSER_DIALOG_NAME = "Open File"
|
||||
FILE_CHOOSER_DIALOG_SHORT_SLEEP = "0.2"
|
||||
FILE_CHOOSER_DIALOG_LONG_SLEEP = "0.4"
|
||||
)
|
||||
// name of the window that is being controlled
|
||||
const fileChooserDialogName = "Open File"
|
||||
|
||||
// short sleep value between fake user interactions
|
||||
const fileChooserDialogShortSleep = "0.2"
|
||||
|
||||
// long sleep value between fake user interactions
|
||||
const fileChooserDialogLongSleep = "0.4"
|
||||
|
||||
func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
||||
mu.Lock()
|
||||
@ -19,19 +22,19 @@ func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
||||
// TODO: Use native API.
|
||||
err1 := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"search", "--name", fileChooserDialogName, "windowfocus",
|
||||
"sleep", fileChooserDialogShortSleep,
|
||||
"key", "--clearmodifiers", "ctrl+l",
|
||||
"type", "--args", "1", uri+"//",
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"sleep", fileChooserDialogShortSleep,
|
||||
"key", "Delete", // remove autocomplete results
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"sleep", fileChooserDialogShortSleep,
|
||||
"key", "Return",
|
||||
"sleep", FILE_CHOOSER_DIALOG_LONG_SLEEP,
|
||||
"sleep", fileChooserDialogLongSleep,
|
||||
"key", "Down",
|
||||
"key", "--clearmodifiers", "ctrl+a",
|
||||
"key", "Return",
|
||||
"sleep", FILE_CHOOSER_DIALOG_LONG_SLEEP,
|
||||
"sleep", fileChooserDialogLongSleep,
|
||||
).Run()
|
||||
|
||||
if err1 != nil {
|
||||
@ -41,7 +44,7 @@ func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
||||
// TODO: Use native API.
|
||||
err2 := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME,
|
||||
"search", "--name", fileChooserDialogName,
|
||||
).Run()
|
||||
|
||||
// if last command didn't return error, consider dialog as still open
|
||||
@ -61,7 +64,7 @@ func (manager *DesktopManagerCtx) CloseFileChooserDialog() {
|
||||
// TODO: Use native API.
|
||||
err := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
||||
"search", "--name", fileChooserDialogName, "windowfocus",
|
||||
).Run()
|
||||
|
||||
if err != nil {
|
||||
@ -92,7 +95,7 @@ func (manager *DesktopManagerCtx) IsFileChooserDialogOpened() bool {
|
||||
// TODO: Use native API.
|
||||
err := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME,
|
||||
"search", "--name", fileChooserDialogName,
|
||||
).Run()
|
||||
|
||||
return err == nil
|
||||
|
@ -95,19 +95,19 @@ func (manager *DesktopManagerCtx) GetKeyboardMap() (*types.KeyboardMap, error) {
|
||||
|
||||
func (manager *DesktopManagerCtx) SetKeyboardModifiers(mod types.KeyboardModifiers) {
|
||||
if mod.NumLock != nil {
|
||||
xorg.SetKeyboardModifier(xorg.KBD_NUM_LOCK, *mod.NumLock)
|
||||
xorg.SetKeyboardModifier(xorg.KbdModNumLock, *mod.NumLock)
|
||||
}
|
||||
|
||||
if mod.CapsLock != nil {
|
||||
xorg.SetKeyboardModifier(xorg.KBD_CAPS_LOCK, *mod.CapsLock)
|
||||
xorg.SetKeyboardModifier(xorg.KbdModCapsLock, *mod.CapsLock)
|
||||
}
|
||||
}
|
||||
|
||||
func (manager *DesktopManagerCtx) GetKeyboardModifiers() types.KeyboardModifiers {
|
||||
modifiers := xorg.GetKeyboardModifiers()
|
||||
|
||||
NumLock := (modifiers & xorg.KBD_NUM_LOCK) != 0
|
||||
CapsLock := (modifiers & xorg.KBD_CAPS_LOCK) != 0
|
||||
NumLock := (modifiers & xorg.KbdModNumLock) != 0
|
||||
CapsLock := (modifiers & xorg.KbdModCapsLock) != 0
|
||||
|
||||
return types.KeyboardModifiers{
|
||||
NumLock: &NumLock,
|
||||
|
@ -19,11 +19,11 @@ import (
|
||||
"demodesk/neko/internal/types"
|
||||
)
|
||||
|
||||
type KbdModifiers uint8
|
||||
type KbdMod uint8
|
||||
|
||||
const (
|
||||
KBD_CAPS_LOCK KbdModifiers = 2
|
||||
KBD_NUM_LOCK KbdModifiers = 16
|
||||
KbdModCapsLock KbdMod = 2
|
||||
KbdModNumLock KbdMod = 16
|
||||
)
|
||||
|
||||
var ScreenConfigurations = make(map[int]types.ScreenConfiguration)
|
||||
@ -213,7 +213,7 @@ func GetScreenSize() *types.ScreenSize {
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetKeyboardModifier(mod KbdModifiers, active bool) {
|
||||
func SetKeyboardModifier(mod KbdMod, active bool) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
@ -225,11 +225,11 @@ func SetKeyboardModifier(mod KbdModifiers, active bool) {
|
||||
C.XSetKeyboardModifier(C.int(mod), num)
|
||||
}
|
||||
|
||||
func GetKeyboardModifiers() KbdModifiers {
|
||||
func GetKeyboardModifiers() KbdMod {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
return KbdModifiers(C.XGetKeyboardModifiers())
|
||||
return KbdMod(C.XGetKeyboardModifiers())
|
||||
}
|
||||
|
||||
func GetCursorImage() *types.CursorImage {
|
||||
|
Reference in New Issue
Block a user