blob: e20b2d9be3befad32a75a56ff5d3318e932d4290 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* FastWM v1.0
* cr4at4d by MLevankov
* The fast WM for BSD/Linux
*/
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/keysymdef.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Display* dpy;
XEvent e;
Window w;
Cursor c;
int s;
char* terminal[] = {"st", NULL};
int running = 0;
int
main()
{
printf("FastWM v1.0\ncr4at4d by MLevankov\n");
printf("Opening display...\n");
if (!(dpy = XOpenDisplay(getenv("DISPLAY"))))
{
printf("Display not found\n");
return 1;
}
s = DefaultScreen(dpy);
w = RootWindow(dpy, s);
XSelectInput(dpy, w, SubstructureRedirectMask | ButtonPressMask | KeyPressMask);
c = XCreateFontCursor(dpy, XC_left_ptr);
XDefineCursor(dpy, w, c);
XFlush(dpy);
running = 1;
while (running)
{
XNextEvent(dpy, &e);
switch (e.type)
{
case KeyPress:
/* mod4mask = super */
if ((e.xkey.state & Mod4Mask) && e.xkey.keycode == 28)
{
if (fork() == 0)
{
setsid();
execvp(terminal[0], terminal);
}
}
if ((e.xkey.state & Mod4Mask) && e.xkey.keycode == 24)
{
running = 0;
}
break;
case MapRequest:
XMapWindow(dpy, e.xmaprequest.window);
break;
}
}
XFreeCursor(dpy, c);
XCloseDisplay(dpy);
return 0;
}
|