XDestroyWindow can not really close the window
pengyixiang
yxpengi386 at 163.com
Fri May 11 01:17:36 UTC 2018
Hello, everyone!
I'm a newbie in xlib, I need to close the window while won't close the program, [1] is my test code, here's the result in [2], XDestroyWindow passed, but the window haven't close, Haven't I get the key to code it?
[1]
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
int main(void)
{
Display *display;
Window window;
XEvent event;
char *msg = "Hello, World!";
int s;
/* open connection with the server */
display = XOpenDisplay(NULL);
if (display == NULL)
{
fprintf(stderr, "Cannot open display\n");
exit(1);
}
s = DefaultScreen(display);
/* create window */
window = XCreateSimpleWindow(display, RootWindow(display, s), 10, 10, 200, 200, 1,
BlackPixel(display, s), WhitePixel(display, s));
/* select kind of events we are interested in */
XSelectInput(display, window, ExposureMask | KeyPressMask);
/* map (show) the window */
XMapWindow(display, window);
/* event loop */
for (;;)
{
XNextEvent(display, &event);
printf("get next event\n");
XDestroyWindow(display, window);
printf("window destroyed\n");
while(1) {
sched_yield();
}
return 0;
}
[2] https://i.stack.imgur.com/3ydc7.png
--
Best Wishes,
Pencc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg/attachments/20180511/436bed6c/attachment.html>
More information about the xorg
mailing list