mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
format Go source code.
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
package desktop
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
@ -58,7 +58,7 @@ func (manager *DesktopManagerCtx) ClipboardSetBinary(mime string, data []byte) e
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stderr = &stderr
|
||||
|
||||
stdin, err := cmd.StdinPipe()
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
const (
|
||||
DROP_MOVE_REPEAT = 4
|
||||
DROP_DELAY = 100 * time.Millisecond
|
||||
DROP_DELAY = 100 * time.Millisecond
|
||||
)
|
||||
|
||||
func (manager *DesktopManagerCtx) DropFiles(x int, y int, files []string) bool {
|
||||
@ -49,10 +49,10 @@ func (manager *DesktopManagerCtx) DropFiles(x int, y int, files []string) bool {
|
||||
go drop.OpenWindow(files)
|
||||
|
||||
select {
|
||||
case succeeded := <- finished:
|
||||
case succeeded := <-finished:
|
||||
return succeeded
|
||||
case <-time.After(1 * time.Second):
|
||||
drop.CloseWindow();
|
||||
drop.CloseWindow()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func OpenWindow(files []string) {
|
||||
defer mu.Unlock()
|
||||
|
||||
size := C.int(len(files))
|
||||
urisUnsafe := C.dragUrisMake(size);
|
||||
urisUnsafe := C.dragUrisMake(size)
|
||||
defer C.dragUrisFree(urisUnsafe, size)
|
||||
|
||||
for i, file := range files {
|
||||
|
@ -2,8 +2,8 @@ package desktop
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -19,19 +19,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,
|
||||
"key", "--clearmodifiers", "ctrl+l",
|
||||
"type", "--args", "1", uri + "//",
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"key", "Delete", // remove autocomplete results
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"key", "Return",
|
||||
"sleep", FILE_CHOOSER_DIALOG_LONG_SLEEP,
|
||||
"key", "Down",
|
||||
"key", "--clearmodifiers", "ctrl+a",
|
||||
"key", "Return",
|
||||
"sleep", FILE_CHOOSER_DIALOG_LONG_SLEEP,
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"key", "--clearmodifiers", "ctrl+l",
|
||||
"type", "--args", "1", uri+"//",
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"key", "Delete", // remove autocomplete results
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"key", "Return",
|
||||
"sleep", FILE_CHOOSER_DIALOG_LONG_SLEEP,
|
||||
"key", "Down",
|
||||
"key", "--clearmodifiers", "ctrl+a",
|
||||
"key", "Return",
|
||||
"sleep", FILE_CHOOSER_DIALOG_LONG_SLEEP,
|
||||
).Run()
|
||||
|
||||
if err1 != nil {
|
||||
@ -41,7 +41,7 @@ func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
||||
// TODO: Use native API.
|
||||
err2 := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME,
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME,
|
||||
).Run()
|
||||
|
||||
// if last command didn't return error, consider dialog as still open
|
||||
@ -61,7 +61,7 @@ func (manager *DesktopManagerCtx) CloseFileChooserDialog() {
|
||||
// TODO: Use native API.
|
||||
err := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
||||
).Run()
|
||||
|
||||
if err != nil {
|
||||
@ -92,7 +92,7 @@ func (manager *DesktopManagerCtx) IsFileChooserDialogOpened() bool {
|
||||
// TODO: Use native API.
|
||||
err := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME,
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME,
|
||||
).Run()
|
||||
|
||||
return err == nil
|
||||
|
@ -2,37 +2,37 @@ package desktop
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/kataras/go-events"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"demodesk/neko/internal/config"
|
||||
"demodesk/neko/internal/desktop/xorg"
|
||||
"demodesk/neko/internal/desktop/xevent"
|
||||
"demodesk/neko/internal/desktop/xorg"
|
||||
)
|
||||
|
||||
var mu = sync.Mutex{}
|
||||
|
||||
type DesktopManagerCtx struct {
|
||||
logger zerolog.Logger
|
||||
cleanup *time.Ticker
|
||||
shutdown chan bool
|
||||
emmiter events.EventEmmiter
|
||||
display string
|
||||
config *config.Desktop
|
||||
logger zerolog.Logger
|
||||
cleanup *time.Ticker
|
||||
shutdown chan bool
|
||||
emmiter events.EventEmmiter
|
||||
display string
|
||||
config *config.Desktop
|
||||
}
|
||||
|
||||
func New(display string, config *config.Desktop) *DesktopManagerCtx {
|
||||
return &DesktopManagerCtx{
|
||||
logger: log.With().Str("module", "desktop").Logger(),
|
||||
cleanup: time.NewTicker(1 * time.Second),
|
||||
shutdown: make(chan bool),
|
||||
emmiter: events.New(),
|
||||
display: display,
|
||||
config: config,
|
||||
logger: log.With().Str("module", "desktop").Logger(),
|
||||
cleanup: time.NewTicker(1 * time.Second),
|
||||
shutdown: make(chan bool),
|
||||
emmiter: events.New(),
|
||||
display: display,
|
||||
config: config,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,9 @@ package xevent
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
"strings"
|
||||
|
||||
"github.com/kataras/go-events"
|
||||
)
|
||||
|
@ -2,11 +2,11 @@ package desktop
|
||||
|
||||
import (
|
||||
"image"
|
||||
"regexp"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
||||
"demodesk/neko/internal/types"
|
||||
"demodesk/neko/internal/desktop/xorg"
|
||||
"demodesk/neko/internal/types"
|
||||
)
|
||||
|
||||
// TODO: Refactor.
|
||||
@ -119,7 +119,7 @@ func (manager *DesktopManagerCtx) GetKeyboardModifiers() types.KeyboardModifiers
|
||||
CapsLock := (modifiers & xorg.KBD_CAPS_LOCK) != 0
|
||||
|
||||
return types.KeyboardModifiers{
|
||||
NumLock: &NumLock,
|
||||
NumLock: &NumLock,
|
||||
CapsLock: &CapsLock,
|
||||
}
|
||||
}
|
||||
|
@ -236,13 +236,13 @@ func GetCursorImage() *types.CursorImage {
|
||||
height := uint16(cur.height)
|
||||
|
||||
return &types.CursorImage{
|
||||
Width: width,
|
||||
Width: width,
|
||||
Height: height,
|
||||
Xhot: uint16(cur.xhot),
|
||||
Yhot: uint16(cur.yhot),
|
||||
Xhot: uint16(cur.xhot),
|
||||
Yhot: uint16(cur.yhot),
|
||||
Serial: uint64(cur.cursor_serial),
|
||||
// Xlib stores 32-bit data in longs, even if longs are 64-bits long.
|
||||
Pixels: C.GoBytes(unsafe.Pointer(cur.pixels), C.int(width * height * 8)),
|
||||
Pixels: C.GoBytes(unsafe.Pointer(cur.pixels), C.int(width*height*8)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ func GetScreenshotImage() *image.RGBA {
|
||||
|
||||
var w, h C.int
|
||||
pixelsUnsafe := C.XGetScreenshot(&w, &h)
|
||||
pixels := C.GoBytes(unsafe.Pointer(pixelsUnsafe), w * h * 3)
|
||||
pixels := C.GoBytes(unsafe.Pointer(pixelsUnsafe), w*h*3)
|
||||
defer C.free(unsafe.Pointer(pixelsUnsafe))
|
||||
|
||||
width := int(w)
|
||||
@ -288,7 +288,7 @@ func goSetScreenRates(index C.int, rate_index C.int, rateC C.short) {
|
||||
rate := int16(rateC)
|
||||
|
||||
// filter out all irrelevant rates
|
||||
if rate > 60 || (rate > 30 && rate % 10 != 0){
|
||||
if rate > 60 || (rate > 30 && rate%10 != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user