We have blinking a window till it will not detect by libwnck
We have blinking a window till it will not detect by libwnck (detecting of windows is appeared each 1 or 0.5 sec) We can avoid usage of libwnck and use X11 native event.
E.g. Usage such code. In this case window will be immediately detected and processed. Blinking of window will not exists in this case.
XEvent event;
XSetWindowAttributes nattrs;
fd_set in_fds;
int x11_fd;
/* open connection with the server */
display = XOpenDisplay(NULL);
if (!display) {
fprintf(stderr, "Cannot open display\n");
return 1;
}
/* create window */
rootWindow = DefaultRootWindow(display);
XSelectInput(display, rootWindow, CreateNotify);
nattrs.event_mask = SubstructureNotifyMask;
XChangeWindowAttributes(display, rootWindow, CWEventMask, &nattrs);
XFlush(display); /// required!
x11_fd = ConnectionNumber(display);
/* event loop */
while (run) {
FD_ZERO(&in_fds);
FD_SET(x11_fd, &in_fds);
if (select(x11_fd + 1, &in_fds, NULL, NULL, NULL) < 0) {
if (errno == EINTR)
continue;
fprintf(stderr, "Select failed: %m\n");
break;
}
while (XPending(display)) {
XNextEvent(display, &event);
if (event.type == CreateNotify) { /// mapping notify sent to all clients
if (!is_bad_window(display, event.xcreatewindow.window)) {
char *wname = NULL;
XClassHint *hint = XAllocClassHint();
if (!hint)
continue;
Screen *screen = XScreenOfDisplay(display,
XDefaultScreen(display));
window_create_cb(screen, event.xcreatewindow.window);
}
}
}
}
XCloseDisplay(display);
return EXIT_SUCCESS;
hmm, that indeed does look very nice, yes - But, it uses a mainloop and a event system of its own - I don't know how much work it would be integrating with the stuff that currently is implemented using the libwnck library right now - it might be that I must pretty much replace all that is currently implemented using libwnck, and that is for sure a pretty massive task...
Indeed, but I think it will work more quickly, take not match resources and don't using libwnck =)