XUnmapWindow(Display*, Window) - is used to unmap(hime) a Xwindow.
/* CPP program to map & unmap a Xwindow */
/* FileName: MapUnMap.cpp */
#include<X11/Xlib.h>
#include<assert.h>
#include<unistd.h>
#include<iostream>
#include<stdio.h>
#define NIL (0)
int main()
{
Display *dpy = XOpenDisplay(NIL);
assert(dpy);
int blackColor = BlackPixel(dpy, DefaultScreen(dpy));
int whiteColor = WhitePixel(dpy, DefaultScreen(dpy));
Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0,
200, 100, 0, blackColor, blackColor);
XSelectInput(dpy, w, StructureNotifyMask);
XMapWindow(dpy, w);
sleep(2);
printf( "Mapping : : 0x%x\n", (unsigned int)w);
int count=1;
GC gc = XCreateGC(dpy, w, 0, NIL);
XSetForeground(dpy, gc, whiteColor);
XEvent event;
while ( 1 ) {
XNextEvent( dpy, &event );
if ( event.type == MapNotify ) {
XMapEvent *mapevent = (XMapEvent *)&event;
printf( "UnMapping : 0x%x\n", (unsigned int)(mapevent->window) );
++count;
XUnmapWindow(dpy, w);
sleep(2);
}
if ( event.type == UnmapNotify ) {
XUnmapEvent *unmapwindowevent = (XUnmapEvent *)&event;
printf( "Mapping : 0x%x\n", (unsigned int)(unmapwindowevent->window) );
++count;
XMapWindow(dpy, w);
sleep(2);
}
if(count==10)
break;
}
XFlush(dpy);
sleep(3);
return 0;
}
./a.out
No comments:
Post a Comment