2011-07-29 20:01:22 +02:00
|
|
|
/* cc transient.c -o transient -lX11 */
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
2020-09-04 09:46:51 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
2011-07-29 20:01:22 +02:00
|
|
|
|
2020-09-04 09:46:51 +02:00
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
Display* d;
|
|
|
|
Window r, f, t = None;
|
|
|
|
XSizeHints h;
|
|
|
|
XEvent e;
|
2011-07-29 20:01:22 +02:00
|
|
|
|
2020-09-04 09:46:51 +02:00
|
|
|
d = XOpenDisplay(NULL);
|
|
|
|
if (!d)
|
|
|
|
exit(1);
|
|
|
|
r = DefaultRootWindow(d);
|
2011-07-29 20:01:22 +02:00
|
|
|
|
2020-09-04 09:46:51 +02:00
|
|
|
f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0);
|
|
|
|
h.min_width = h.max_width = h.min_height = h.max_height = 400;
|
|
|
|
h.flags = PMinSize | PMaxSize;
|
|
|
|
XSetWMNormalHints(d, f, &h);
|
|
|
|
XStoreName(d, f, "floating");
|
|
|
|
XMapWindow(d, f);
|
2011-07-29 20:01:22 +02:00
|
|
|
|
2020-09-04 09:46:51 +02:00
|
|
|
XSelectInput(d, f, ExposureMask);
|
|
|
|
while (1) {
|
|
|
|
XNextEvent(d, &e);
|
2011-07-29 20:01:22 +02:00
|
|
|
|
2020-09-04 09:46:51 +02:00
|
|
|
if (t == None) {
|
|
|
|
sleep(5);
|
|
|
|
t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0);
|
|
|
|
XSetTransientForHint(d, t, f);
|
|
|
|
XStoreName(d, t, "transient");
|
|
|
|
XMapWindow(d, t);
|
|
|
|
XSelectInput(d, t, ExposureMask);
|
|
|
|
}
|
|
|
|
}
|
2011-07-29 20:01:22 +02:00
|
|
|
|
2020-09-04 09:46:51 +02:00
|
|
|
XCloseDisplay(d);
|
|
|
|
exit(0);
|
2011-07-29 20:01:22 +02:00
|
|
|
}
|