X11: Use XSync to improve reliability
This commit is contained in:
parent
1aa8f92cc8
commit
85b6d6ea9d
1 changed files with 4 additions and 5 deletions
|
|
@ -147,7 +147,7 @@ func (p *x11Controller) changeKeyMappingLocked(keysymsPerKeycode C.int,
|
||||||
}
|
}
|
||||||
C.XChangeKeyboardMapping(p.display, C.int(keycode), keysymsPerKeycode,
|
C.XChangeKeyboardMapping(p.display, C.int(keycode), keysymsPerKeycode,
|
||||||
(*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1)
|
(*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1)
|
||||||
C.XFlush(p.display)
|
C.XSync(p.display, C.False)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *x11Controller) getModKeycodesLocked() map[uint]C.KeyCode {
|
func (p *x11Controller) getModKeycodesLocked() map[uint]C.KeyCode {
|
||||||
|
|
@ -236,7 +236,6 @@ func (p *x11Controller) keyboardKeys(keys []Keysym) error {
|
||||||
var root, child C.Window
|
var root, child C.Window
|
||||||
var rootX, rootY, x, y C.int
|
var rootX, rootY, x, y C.int
|
||||||
var activeMods C.uint
|
var activeMods C.uint
|
||||||
C.XSync(p.display, C.False)
|
|
||||||
C.XQueryPointer(p.display, rootWindow, &root, &child, &rootX, &rootY,
|
C.XQueryPointer(p.display, rootWindow, &root, &child, &rootX, &rootY,
|
||||||
&x, &y, &activeMods)
|
&x, &y, &activeMods)
|
||||||
keycode, mods := p.findKeycodeLocked(keyboard, modKeycodes, activeMods,
|
keycode, mods := p.findKeycodeLocked(keyboard, modKeycodes, activeMods,
|
||||||
|
|
@ -265,7 +264,7 @@ func (p *x11Controller) keyboardKeys(keys []Keysym) error {
|
||||||
C.XTestFakeKeyEvent(p.display, C.uint(keycode), C.False, 0)
|
C.XTestFakeKeyEvent(p.display, C.uint(keycode), C.False, 0)
|
||||||
p.sendModsLocked(modKeycodes, pressMods, false)
|
p.sendModsLocked(modKeycodes, pressMods, false)
|
||||||
p.sendModsLocked(modKeycodes, releaseMods, true)
|
p.sendModsLocked(modKeycodes, releaseMods, true)
|
||||||
C.XFlush(p.display)
|
C.XSync(p.display, C.False)
|
||||||
if keycode == emptyKeycode {
|
if keycode == emptyKeycode {
|
||||||
// race condition!
|
// race condition!
|
||||||
time.Sleep(keyboardMappingDelay)
|
time.Sleep(keyboardMappingDelay)
|
||||||
|
|
@ -309,7 +308,7 @@ func (p *x11Controller) sendButton(button uint, press bool) error {
|
||||||
pressC = C.True
|
pressC = C.True
|
||||||
}
|
}
|
||||||
C.XTestFakeButtonEvent(p.display, C.uint(button), pressC, 0)
|
C.XTestFakeButtonEvent(p.display, C.uint(button), pressC, 0)
|
||||||
C.XFlush(p.display)
|
C.XSync(p.display, C.False)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -333,7 +332,7 @@ func (p *x11Controller) PointerMove(deltaX, deltaY int) error {
|
||||||
return errors.New("X server connection closed")
|
return errors.New("X server connection closed")
|
||||||
}
|
}
|
||||||
C.XTestFakeRelativeMotionEvent(p.display, C.int(deltaX), C.int(deltaY), 0)
|
C.XTestFakeRelativeMotionEvent(p.display, C.int(deltaX), C.int(deltaY), 0)
|
||||||
C.XFlush(p.display)
|
C.XSync(p.display, C.False)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue