Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <X11/Xlib.h>
- #include <array>
- std::array<int, 2> getScreenSize(Display* p_display)
- {
- std::array<int, 2> screen_size{ { -1, -1 } };
- Screen* pscr = NULL;
- pscr = DefaultScreenOfDisplay( p_display );
- if ( !pscr ) {
- fprintf(stderr, "Failed to obtain the default screen of given display.\n");
- return screen_size;
- }
- screen_size[0] = pscr->width;
- screen_size[1] = pscr->height;
- return screen_size;
- }
- int main(){
- std::array<int, 2> screen_size;
- std::array<int, 2> cursor_pos;
- Display *dpy;
- Window root;
- Window ret_root;
- Window ret_child;
- unsigned int mask;
- int empty;
- dpy = XOpenDisplay(NULL);
- root = XDefaultRootWindow(dpy);
- screen_size = getScreenSize(dpy);
- if(XQueryPointer(dpy, root, &ret_root, &ret_child, &cursor_pos[0], &cursor_pos[1],&empty, &empty, &mask)){
- printf("+%d+%d\n", cursor_pos[0], cursor_pos[1]);
- usleep(499999);
- }
- else{
- printf("CO DO LUJA?!");
- }
- printf (" Screen: width = %d, height = %d \n", screen_size[0], screen_size[1]);
- if(XQueryPointer(dpy, root, &ret_root, &ret_child, &cursor_pos[0], &cursor_pos[1],&empty, &empty, &mask)){
- printf("+%d+%d\n", cursor_pos[0], cursor_pos[1]);
- usleep(499999);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement