break long lines

This commit is contained in:
Unrud 2018-07-31 20:18:47 +02:00
parent a296bd1188
commit 26337f3a0e
3 changed files with 22 additions and 10 deletions

View file

@ -61,7 +61,8 @@ func FindDefaultHost() string {
if fallbackAddr == "" { if fallbackAddr == "" {
fallbackAddr = ip.String() fallbackAddr = ip.String()
} }
for _, linkLocalPrefix := range []string{"169.254.", "fe8", "fe9", "fea", "feb"} { for _, linkLocalPrefix := range []string{
"169.254.", "fe8", "fe9", "fea", "feb"} {
if strings.HasPrefix(ip.String(), linkLocalPrefix) { if strings.HasPrefix(ip.String(), linkLocalPrefix) {
continue addrs continue addrs
} }

View file

@ -98,7 +98,9 @@ func (p *windowsPlugin) KeyboardText(text string) error {
inputs[i].dwFlags |= keyeventfKeyup inputs[i].dwFlags |= keyeventfKeyup
} }
} }
if r, _, err := p.sendInputProc.Call(uintptr(len(inputs)), uintptr(unsafe.Pointer(&inputs[0])), unsafe.Sizeof(inputs[0])); int(r) != len(inputs) { if r, _, err := p.sendInputProc.Call(uintptr(len(inputs)),
uintptr(unsafe.Pointer(&inputs[0])),
unsafe.Sizeof(inputs[0])); int(r) != len(inputs) {
return err return err
} }
return nil return nil
@ -124,7 +126,8 @@ func (p *windowsPlugin) PointerButton(button uint, press bool) error {
} else if button == 3 { } else if button == 3 {
input.dwFlags = mouseeventfRightup input.dwFlags = mouseeventfRightup
} }
if r, _, err := p.sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)), unsafe.Sizeof(input)); int(r) != 1 { if r, _, err := p.sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)),
unsafe.Sizeof(input)); int(r) != 1 {
return err return err
} }
return nil return nil
@ -137,7 +140,8 @@ func (p *windowsPlugin) PointerMove(deltaX, deltaY int) error {
dy: int32(deltaY), dy: int32(deltaY),
dwFlags: mouseeventfMove, dwFlags: mouseeventfMove,
} }
if r, _, err := p.sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)), unsafe.Sizeof(input)); int(r) != 1 { if r, _, err := p.sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)),
unsafe.Sizeof(input)); int(r) != 1 {
return err return err
} }
return nil return nil
@ -162,7 +166,9 @@ func (p *windowsPlugin) PointerScroll(stepsHorizontal, stepsVertical int) error
if len(inputs) == 0 { if len(inputs) == 0 {
return nil return nil
} }
if r, _, err := p.sendInputProc.Call(uintptr(len(inputs)), uintptr(unsafe.Pointer(&inputs[0])), unsafe.Sizeof(inputs[0])); int(r) != len(inputs) { if r, _, err := p.sendInputProc.Call(uintptr(len(inputs)),
uintptr(unsafe.Pointer(&inputs[0])),
unsafe.Sizeof(inputs[0])); int(r) != len(inputs) {
return err return err
} }
return nil return nil

View file

@ -71,7 +71,8 @@ func (p *x11Plugin) KeyboardText(text string) error {
var minKeycodes, maxKeycodes C.int var minKeycodes, maxKeycodes C.int
C.XDisplayKeycodes(p.display, &minKeycodes, &maxKeycodes) C.XDisplayKeycodes(p.display, &minKeycodes, &maxKeycodes)
var keysymsPerKeycode C.int var keysymsPerKeycode C.int
keysyms := C.XGetKeyboardMapping(p.display, C.KeyCode(minKeycodes), maxKeycodes-minKeycodes+1, &keysymsPerKeycode) keysyms := C.XGetKeyboardMapping(p.display, C.KeyCode(minKeycodes),
maxKeycodes-minKeycodes+1, &keysymsPerKeycode)
if keysyms == nil { if keysyms == nil {
return errors.New("failed to get keyboard mapping") return errors.New("failed to get keyboard mapping")
} }
@ -79,8 +80,10 @@ func (p *x11Plugin) KeyboardText(text string) error {
keycodes: keycodes:
for keycode := C.KeyCode(minKeycodes); keycode <= C.KeyCode(maxKeycodes); keycode++ { for keycode := C.KeyCode(minKeycodes); keycode <= C.KeyCode(maxKeycodes); keycode++ {
for i := 0; i < int(keysymsPerKeycode); i++ { for i := 0; i < int(keysymsPerKeycode); i++ {
keysymsIndex := int(keycode-C.KeyCode(minKeycodes))*int(keysymsPerKeycode) + i keysymsIndex := int(keycode-
keysym := *(*C.KeySym)(unsafe.Pointer(uintptr(unsafe.Pointer(keysyms)) + uintptr(keysymsIndex)*unsafe.Sizeof(*keysyms))) C.KeyCode(minKeycodes))*int(keysymsPerKeycode) + i
keysym := *(*C.KeySym)(unsafe.Pointer(uintptr(unsafe.Pointer(keysyms)) +
uintptr(keysymsIndex)*unsafe.Sizeof(*keysyms)))
if keysym != 0 { if keysym != 0 {
continue keycodes continue keycodes
} }
@ -98,7 +101,8 @@ keycodes:
for i := range keycodeMapping { for i := range keycodeMapping {
keycodeMapping[i] = keysym keycodeMapping[i] = keysym
} }
C.XChangeKeyboardMapping(p.display, C.int(emptyKeycode), keysymsPerKeycode, (*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1) C.XChangeKeyboardMapping(p.display, C.int(emptyKeycode), keysymsPerKeycode,
(*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1)
C.XTestFakeKeyEvent(p.display, C.uint(emptyKeycode), C.True, 0) C.XTestFakeKeyEvent(p.display, C.uint(emptyKeycode), C.True, 0)
C.XTestFakeKeyEvent(p.display, C.uint(emptyKeycode), C.False, 0) C.XTestFakeKeyEvent(p.display, C.uint(emptyKeycode), C.False, 0)
// race condition! // race condition!
@ -108,7 +112,8 @@ keycodes:
for i := range keycodeMapping { for i := range keycodeMapping {
keycodeMapping[i] = 0 keycodeMapping[i] = 0
} }
C.XChangeKeyboardMapping(p.display, C.int(emptyKeycode), keysymsPerKeycode, (*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1) C.XChangeKeyboardMapping(p.display, C.int(emptyKeycode), keysymsPerKeycode,
(*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1)
C.XFlush(p.display) C.XFlush(p.display)
return nil return nil
} }