add xgetnewwindow, which waits the creation of a new window in the xorg server
This commit is contained in:
parent
ca3faec6ce
commit
decef894bd
|
@ -0,0 +1,29 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
Display* display = XOpenDisplay(NULL);
|
||||
if(!display) {
|
||||
printf("Error: Unable to open display.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int screen = DefaultScreen(display);
|
||||
Window root = RootWindow(display, screen);
|
||||
|
||||
/* SubstructureNotifyMask allows us to be notified of CreateNotify events */
|
||||
XSelectInput(display, root, SubstructureNotifyMask);
|
||||
|
||||
XEvent event;
|
||||
for(;;) {
|
||||
XNextEvent(display, &event);
|
||||
if(event.type == CreateNotify) {
|
||||
/* print window id */
|
||||
printf("0x%x\n", event.xcreatewindow.window);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XCloseDisplay(display);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
.TH XGETNEWWINDOW 1 xgetnewwindow
|
||||
.SH NAME
|
||||
xgetnewwindow
|
||||
.SH SYNOPSIS
|
||||
xgetnewwindow blocks until it recieves a CreateNotify event; that is, until a new window is created within the current Xorg instance. Once a new window is created, xgetnewwindow prints the window id (in hexadecimal) to stdout and exits.
|
||||
.SH EXIT CODES
|
||||
1 for abnormal termination, 0 for success.
|
||||
.SH AUTHOR
|
||||
randomuser
|
||||
|
Loading…
Reference in New Issue