-
Notifications
You must be signed in to change notification settings - Fork 0
/
ntwm.c
94 lines (79 loc) · 1.55 KB
/
ntwm.c
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* ntwm.c: ntwm core
*/
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
#include <X11/extensions/Xrandr.h>
#include "config.h"
#include "logging.h"
#include "libspool.h"
int running = 1;
int has_thrown = 0;
int above_enabled = 0;
int last_err = 0;
int mode_index = 0;
int monitor_width;
int monitor_height;
int rr_event_base;
int rr_error_base;
Display *dpy;
Screen *screen;
XEvent e;
Window focused;
Window root;
Window above;
Atom atoms[8];
pool *monitors;
pool *bars;
#include "util.h"
#include "x.h"
#include "multihead.h"
#include "modes.h"
#include "tiling.h"
#include "events.h"
int main(){
info("ntwm v" VER " starting up.");
x_init();
if(!last_err && running){
multihead_setup();
spawn(autostartcmd);
tile_existing(map_request);
}
while(running){
XNextEvent(dpy, &e);
switch(e.type){
case MapRequest:
map_request(&e);
break;
case ConfigureRequest:
configure_request(&e);
break;
case UnmapNotify:
unmap_notify(&e);
break;
case EnterNotify:
enter_notify(&e);
break;
case KeyPress:
key_press(&e);
break;
case ClientMessage:
client_message(&e);
break;
default:
if(e.type == rr_event_base + RRScreenChangeNotify){
screenchange_notify(&e);
}
break;
}
}
info("ntwm shutting down.");
multihead_free();
return last_err;
}