Advertisement
kellex

X11 Secure Template

Sep 17th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. //g++ -o template template.cpp -L/usr/X11R6/lib -lX11
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include <X11/Xlib.h>
  6. #include <assert.h>
  7. #include <unistd.h>
  8. #include <math.h>
  9.  
  10. #define NIL (0)
  11.  
  12. using namespace std;
  13.  
  14. int main(){
  15.  
  16. Display *dpy = XOpenDisplay(NIL);
  17. assert(dpy);
  18.  
  19. int blackColor = BlackPixel(dpy,DefaultScreen(dpy));
  20. int whiteColor = WhitePixel(dpy,DefaultScreen(dpy));
  21.  
  22. printf("Window height, width: \n");
  23. int height,width;
  24. scanf("%d %d",&height,&width);
  25.  
  26. Window w = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,height,width,0,whiteColor,whiteColor);
  27. XSelectInput(dpy,w,StructureNotifyMask);
  28. XMapWindow(dpy,w);
  29.  
  30. GC gc = XCreateGC(dpy,w,0,NIL);
  31. XSetForeground(dpy,gc,blackColor);
  32.  
  33. for(;;){
  34.     XEvent e;
  35.     XNextEvent(dpy,&e);
  36.     if(e.type == MapNotify)
  37.         break;
  38. }
  39.  
  40. //Main goes here...
  41.  
  42. XFlush(dpy);
  43. sleep(1);
  44. cin.ignore().get();
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement