Столкнулся с такой трудностью (так как в прграмировании на си полный ноль). Получается вывод координат если мышка хотябы двинулась, а мне требуется считать кординаты мышки без каких то лишних манипуляций с ней, то есть запустил и получил координаты.
Код: Выделить всё
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
Display *display;
int screen_number;
GC gc;
XEvent report;
int new_x, new_y;
if ( ( display = XOpenDisplay ( NULL ) ) == NULL ) {
puts ("Can not connect to the X server!\n");
exit ( 1 );
}
screen_number = DefaultScreen ( display );
XSelectInput ( display,XRootWindow (display, screen_number) ,PointerMotionMask);
XNextEvent ( display, &report );
gc = XCreateGC ( display, XRootWindow (display, screen_number), 0 , NULL );
new_x = report.xbutton.x;
new_y = report.xbutton.y;
printf("Mouse button pressed at %i, %i\n", new_x, new_y);
exit ( 0 );
XFreeGC ( display, gc );
return 0;
}