transient.c
author Stiletto <blasux@blasux.ru>
Sat, 25 Oct 2014 15:12:32 +0400
branchstil
changeset 1542 a699915c007f
parent 1539 e2a9bd720b6e
permissions -rw-r--r--
Make automatic tag switching optional
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1539
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     1
/* cc transient.c -o transient -lX11 */
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     2
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     3
#include <stdlib.h>
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     4
#include <unistd.h>
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     5
#include <X11/Xlib.h>
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     6
#include <X11/Xutil.h>
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     7
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     8
int main(void) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     9
	Display *d;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    10
	Window r, f, t = None;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    11
	XSizeHints h;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    12
	XEvent e;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    13
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    14
	d = XOpenDisplay(NULL);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    15
	if (!d)
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    16
		exit(1);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    17
	r = DefaultRootWindow(d);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    18
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    19
	f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    20
	h.min_width = h.max_width = h.min_height = h.max_height = 400;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    21
	h.flags = PMinSize | PMaxSize;
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    22
	XSetWMNormalHints(d, f, &h);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    23
	XStoreName(d, f, "floating");
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    24
	XMapWindow(d, f);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    25
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    26
	XSelectInput(d, f, ExposureMask);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    27
	while (1) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    28
		XNextEvent(d, &e);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    29
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    30
		if (t == None) {
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    31
			sleep(5);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    32
			t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    33
			XSetTransientForHint(d, t, f);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    34
			XStoreName(d, t, "transient");
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    35
			XMapWindow(d, t);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    36
			XSelectInput(d, t, ExposureMask);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    37
		}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    38
	}
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    39
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    40
	XCloseDisplay(d);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    41
	exit(0);
e2a9bd720b6e Imported dwm 6.0 from snapshot
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    42
}