mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
implement xorg GetCursorPosition.
This commit is contained in:
parent
2ac3f9876f
commit
5310acfbf0
@ -26,6 +26,10 @@ func (manager *DesktopManagerCtx) OnCursorPosition(listener func(x, y int)) {
|
|||||||
cursorListeners = append(cursorListeners, listener)
|
cursorListeners = append(cursorListeners, listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (manager *DesktopManagerCtx) GetCursorPosition() (int, int) {
|
||||||
|
return xorg.GetCursorPosition()
|
||||||
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) Scroll(x, y int) {
|
func (manager *DesktopManagerCtx) Scroll(x, y int) {
|
||||||
xorg.Scroll(x, y)
|
xorg.Scroll(x, y)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,15 @@ void XMove(int x, int y) {
|
|||||||
XSync(display, 0);
|
XSync(display, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XCursorPosition(int *x, int *y) {
|
||||||
|
Display *display = getXDisplay();
|
||||||
|
Window root = DefaultRootWindow(display);
|
||||||
|
Window window;
|
||||||
|
int i;
|
||||||
|
unsigned mask;
|
||||||
|
XQueryPointer(display, root, &root, &window, x, y, &i, &i, &mask);
|
||||||
|
}
|
||||||
|
|
||||||
void XScroll(int x, int y) {
|
void XScroll(int x, int y) {
|
||||||
int ydir = 4; /* Button 4 is up, 5 is down. */
|
int ydir = 4; /* Button 4 is up, 5 is down. */
|
||||||
int xdir = 6;
|
int xdir = 6;
|
||||||
|
@ -68,6 +68,17 @@ func Move(x, y int) {
|
|||||||
C.XMove(C.int(x), C.int(y))
|
C.XMove(C.int(x), C.int(y))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetCursorPosition() (int, int) {
|
||||||
|
mu.Lock()
|
||||||
|
defer mu.Unlock()
|
||||||
|
|
||||||
|
var x C.int
|
||||||
|
var y C.int
|
||||||
|
C.XCursorPosition(&x, &y)
|
||||||
|
|
||||||
|
return int(x), int(y)
|
||||||
|
}
|
||||||
|
|
||||||
func Scroll(x, y int) {
|
func Scroll(x, y int) {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
@ -16,6 +16,7 @@ int XDisplayOpen(char *input);
|
|||||||
void XDisplayClose(void);
|
void XDisplayClose(void);
|
||||||
|
|
||||||
void XMove(int x, int y);
|
void XMove(int x, int y);
|
||||||
|
void XCursorPosition(int *x, int *y);
|
||||||
void XScroll(int x, int y);
|
void XScroll(int x, int y);
|
||||||
void XButton(unsigned int button, int down);
|
void XButton(unsigned int button, int down);
|
||||||
void XKey(unsigned long key, int down);
|
void XKey(unsigned long key, int down);
|
||||||
|
@ -49,6 +49,7 @@ type DesktopManager interface {
|
|||||||
// xorg
|
// xorg
|
||||||
Move(x, y int)
|
Move(x, y int)
|
||||||
OnCursorPosition(listener func(x, y int))
|
OnCursorPosition(listener func(x, y int))
|
||||||
|
GetCursorPosition() (int, int)
|
||||||
Scroll(x, y int)
|
Scroll(x, y int)
|
||||||
ButtonDown(code int) error
|
ButtonDown(code int) error
|
||||||
KeyDown(code uint64) error
|
KeyDown(code uint64) error
|
||||||
|
Loading…
Reference in New Issue
Block a user