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:
@ -21,6 +21,15 @@ void XMove(int x, int y) {
|
||||
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) {
|
||||
int ydir = 4; /* Button 4 is up, 5 is down. */
|
||||
int xdir = 6;
|
||||
|
@ -68,6 +68,17 @@ func Move(x, y int) {
|
||||
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) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
@ -16,6 +16,7 @@ int XDisplayOpen(char *input);
|
||||
void XDisplayClose(void);
|
||||
|
||||
void XMove(int x, int y);
|
||||
void XCursorPosition(int *x, int *y);
|
||||
void XScroll(int x, int y);
|
||||
void XButton(unsigned int button, int down);
|
||||
void XKey(unsigned long key, int down);
|
||||
|
Reference in New Issue
Block a user