Advertisement
Guest User

X

a guest
Dec 19th, 2009
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. // compile with:
  2. // gcc `xosd-config --cflags --libs` test3.c -o test3
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include <locale.h>
  8. #include <xosd.h>
  9.  
  10. #include <X11/Xlib.h>
  11. #include <time.h>
  12.  
  13. int basket_x = 160;
  14. int basket_y = 412;
  15. int ball_x = 0;
  16. int ball_y = 0;
  17.  
  18. int main (int argc, char *argv[])
  19. {
  20. xosd *osd;
  21. setlocale(LC_ALL, "");
  22. osd = xosd_create (2);
  23. xosd_set_font (osd, "-adobe-helvetica-bold-r-normal-*-*-320-*-*-p-*-*");
  24.  
  25. Display *display = XOpenDisplay(NULL);
  26. Window root, fromroot, tmpwin;
  27. int x, y,prev_x,prev_y, tmp;
  28. uint tmp2;
  29.  
  30. root = DefaultRootWindow(display);
  31. XQueryPointer(display, root, &fromroot, &tmpwin, &prev_x, &prev_y, &tmp, &tmp, &tmp2);
  32. char * the_text = malloc(200);
  33. while(1){
  34. XQueryPointer(display, root, &fromroot, &tmpwin, &x, &y, &tmp, &tmp, &tmp2);
  35. if(x!=prev_x || y!=prev_y){
  36. prev_x = x;
  37. prev_y = y;
  38. sprintf(the_text, "! %d %d !", x, y);
  39. xosd_set_vertical_offset (osd, y);
  40. xosd_set_horizontal_offset (osd, x);
  41. xosd_display (osd, 0, XOSD_string, the_text);
  42. }
  43. usleep(50000);
  44. }
  45.  
  46. sleep (8);
  47. xosd_destroy (osd);
  48. exit (0);
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement