Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //g++ -o template template.cpp -L/usr/X11R6/lib -lX11
- #include <stdlib.h>
- #include <stdio.h>
- #include <iostream>
- #include <X11/Xlib.h>
- #include <assert.h>
- #include <unistd.h>
- #include <math.h>
- #define NIL (0)
- using namespace std;
- int main(){
- Display *dpy = XOpenDisplay(NIL);
- assert(dpy);
- int blackColor = BlackPixel(dpy,DefaultScreen(dpy));
- int whiteColor = WhitePixel(dpy,DefaultScreen(dpy));
- printf("Window height, width: \n");
- int height,width;
- scanf("%d %d",&height,&width);
- Window w = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,height,width,0,whiteColor,whiteColor);
- XSelectInput(dpy,w,StructureNotifyMask);
- XMapWindow(dpy,w);
- GC gc = XCreateGC(dpy,w,0,NIL);
- XSetForeground(dpy,gc,blackColor);
- for(;;){
- XEvent e;
- XNextEvent(dpy,&e);
- if(e.type == MapNotify)
- break;
- }
- //Main goes here...
- XFlush(dpy);
- sleep(1);
- cin.ignore().get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement