forked from djmasde/catwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
catwm.c
815 lines (706 loc) · 21.8 KB
/
catwm.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
/* catwm-0.0.5.c
*
* ( o o ) Made by cat...
* ( =^= )
* ( ) ... for cat!
* ( )
* ( ))))))________________ Cute And Tiny Window Manager
* ______________________________________________________________________________
*
* Copyright (c) 2014-2015, Dj_Dexter, Helmuth.Schmelzer@gmail.com
* Copyright (c) 2010, Rinaldini Julien, julien.rinaldini@heig-vd.ch
* Based in moetunes fork
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Some changes and additions by P. Newman 24.4.11
* - best not to email julien if you use this... :)
* Some changes and bugfixes by Dj_Dexter/djmasde 21.7.14
* Bug with desktop numbers:
* -before, only show 3 desktops
* -after, show to 9 desktops, configured with config.h
* -removed the next_desktop, and prev_desktop functions
* Now, numlock on, not affects the keyboard shortcuts
* Unmapnotify function for rare windows, Ex: thunderbird, firefox, etc...
*/
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/XF86keysym.h> //for multimedia keys
#include <X11/Xproto.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xlocale.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>
#include <string.h>
// imported from dminiwm.c and dwm.c
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define TABLENGTH(X) (sizeof(X)/sizeof(*X))
// for ignoring the numlock mask
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
enum { WM_PROTOCOLS, WM_DELETE_WINDOW, WM_COUNT };
typedef union {
const char** com;
const int i;
} Arg;
// Structs
struct key {
unsigned int mod;
KeySym keysym;
void (*function)(const Arg arg);
const Arg arg;
};
typedef struct client client;
struct client{
// Prev and next client
client *next;
client *prev;
// The window
Window win;
};
typedef struct desktop desktop;
struct desktop{
int master_size;
int mode;
client *head;
client *current;
};
// Functions
static void add_window(Window w);
static void change_desktop(const Arg arg);
static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e);
static void decrease();
static void destroynotify(XEvent *e);
static void die(const char* e);
static void unmapnotify(XEvent *e); // Thunderbird's write window just unmaps...
static unsigned long getcolor(const char* color);
static void grabkeys();
static void increase();
static void keypress(XEvent *e);
static void kill_client();
static void maprequest(XEvent *e);
static void move_down();
static void move_up();
static void next_win();
static void prev_win();
static void catkill(); //kill the cat, xD
static void remove_window(Window w);
static void save_desktop(int i);
static void select_desktop(int i);
static void send_kill_signal(Window w);
static void setup();
static void sigchld(int unused);
static void spawn(const Arg arg);
static void start();
static void swap_master();
static void toggle_fullscreen();
static void switch_vertical();
static void switch_horizontal();
static void tile();
static void update_current();
static int xerror(Display *dis, XErrorEvent *ee), (*xerrorxlib)(Display *, XErrorEvent *); //for error handler
static void logger(const char* e); //logger
static void cleanup(void); //imported from monsterwm.c
static void deletewindow(Window w); //imported from monsterwm.c
static Bool running = True;
static void wea(); //stupid quick and dirty anti not focus
static void client_to_desktop(const Arg arg); // to move window to any desktop, especified.
// Include configuration file (need struct key)
#include "config.h"
// Variable
static Display *dis;
unsigned int numlockmask; /* dynamic key lock mask */
static int current_desktop;
static int master_size;
static int mode;
static int sh;
static int sw;
static int screen;
static unsigned int win_focus;
static unsigned int win_unfocus;
static Window root;
static client *head;
static client *current;
static int holder; // for coming out of fullscreen mode back to what mode it was
// Events array
static void (*events[LASTEvent])(XEvent *e) = {
[KeyPress] = keypress,
[MapRequest] = maprequest,
[UnmapNotify] = unmapnotify,
[DestroyNotify] = destroynotify,
[ConfigureNotify] = configurenotify,
[ConfigureRequest] = configurerequest
};
// Desktop array
static desktop desktops[10];
/* ***************************** Window Management ******************************* */
void add_window(Window w) {
client *c,*t;
if(!(c = (client *)calloc(1,sizeof(client))))
die("Error calloc!");
if(head == NULL) {
c->next = NULL;
c->prev = NULL;
c->win = w;
head = c;
}
else {
if(ATTACH_ASIDE == 0) {
for(t=head;t->next;t=t->next);
c->next = NULL;
c->prev = t;
c->win = w;
t->next = c;
}
else {
for(t=head;t->prev;t=t->prev);
c->prev = NULL;
c->next = t;
c->win = w;
t->prev = c;
head = c;
}
}
current = c;
save_desktop(current_desktop);
}
void client_to_desktop(const Arg arg) {
client *tmp = current;
int tmp2 = current_desktop;
if(arg.i == current_desktop || current == NULL)
return;
// Add client to desktop
select_desktop(arg.i);
add_window(tmp->win);
save_desktop(arg.i);
// Remove client from current desktop
select_desktop(tmp2);
remove_window(current->win);
tile();
update_current();
change_desktop(arg);
}
void unmapnotify(XEvent *e) { // for thunderbird's write window and maybe others
XUnmapEvent *ev = &e->xunmap;
client *c;
if(ev->send_event == 1) {
for(c=head;c;c=c->next)
if(ev->window == c->win) {
remove_window(ev->window);
update_current();
//wtf! without this, in tiled mode, not get all size of the window
increase();
//Quick and dirty hack, for molest resize, if have more dialogs...
decrease();
//without this, windows like GnuStep style or others, catwm retakes the window
//and disappear the bug "ghost" window.
update_current();
return;
}
}
}
void swap_master() {
Window tmp;
if(head != NULL && current != NULL && current != head && mode != 1) {
tmp = head->win;
head->win = current->win;
current->win = tmp;
current = head;
save_desktop(current_desktop);
tile();
}
}
void move_down() {
Window tmp;
if(current == NULL || current->next == NULL || current->win == head->win || current->prev == NULL)
return;
tmp = current->win;
current->win = current->next->win;
current->next->win = tmp;
//keep the moved window activated
next_win();
save_desktop(current_desktop);
tile();
}
void move_up() {
Window tmp;
if(current == NULL || current->prev == head || current->win == head->win) {
fprintf(stdout, "%s\n","move_up not gonna be used");
return;
}
tmp = current->win;
current->win = current->prev->win;
current->prev->win = tmp;
prev_win();
save_desktop(current_desktop);
tile();
}
void next_win() {
client *c;
if(current != NULL && head != NULL) {
if(current->next == NULL)
c = head;
else
c = current->next;
current = c;
update_current();
}
}
void prev_win() {
client *c;
if(current != NULL && head != NULL) {
if(current->prev == NULL)
for(c=head;c->next;c=c->next);
else
c = current->prev;
current = c;
update_current();
}
}
void decrease() {
if(master_size > 50) {
master_size -= 10;
tile();
}
}
void increase() {
// if mode 2 = vertical stack prevents catwm crash with badsize X error.
if(mode != 2) {
if(master_size < sh-50) {
master_size += 10;
tile();
}
}
else {
// if mode 1 = horizontal stack resize, but no all, prevents catwm crash with badsize X error.
if(master_size < sw-50) {
master_size += 10;
tile();
}
}
}
void remove_window(Window w) {
client *c;
// CHANGE THIS UGLY CODE
for(c=head;c;c=c->next) {
if(c->win == w) {
if(c->prev == NULL && c->next == NULL) {
// free(head);
head = NULL;
current = NULL;
return;
}
if(c->prev == NULL) {
head = c->next;
c->next->prev = NULL;
current = c->next;
}
else if(c->next == NULL) {
c->prev->next = NULL;
current = c->prev;
}
else {
c->prev->next = c->next;
c->next->prev = c->prev;
current = c->prev;
}
//removed this, possible "steal the memory"
// free(c);
update_current();
return;
}
}
}
void kill_client() {
if(current != NULL) {
//send delete signal to window
XEvent ke;
ke.type = ClientMessage;
ke.xclient.window = current->win;
ke.xclient.message_type = XInternAtom(dis, "WM_PROTOCOLS", True);
ke.xclient.format = 32;
ke.xclient.data.l[0] = XInternAtom(dis, "WM_DELETE_WINDOW", True);
ke.xclient.data.l[1] = CurrentTime;
XSendEvent(dis, current->win, False, NoEventMask, &ke);
send_kill_signal(current->win);
}
}
unsigned long getcolor(const char* color) {
XColor c;
Colormap map = DefaultColormap(dis,screen);
if(!XAllocNamedColor(dis,map,color,&c,&c))
die("Error parsing color!");
return c.pixel;
}
void update_current() {
client *c;
for(c=head;c;c=c->next)
if(current == c) {
// "Enable" current window
XSetWindowBorderWidth(dis,c->win,BORDER_WIDTH);
XSetWindowBorder(dis,c->win,win_focus);
XSetInputFocus(dis,c->win,RevertToParent,CurrentTime);
XRaiseWindow(dis,c->win);
}
else
XSetWindowBorder(dis,c->win,win_unfocus);
XSync(dis, False);
}
/* **************************** Desktop Management ************************************* */
void change_desktop(const Arg arg) {
client *c;
if(arg.i == current_desktop)
return;
// Save current "properties"
save_desktop(current_desktop);
// Unmap all window
if(head != NULL)
for(c=head;c;c=c->next)
XUnmapWindow(dis,c->win);
// Take "properties" from the new desktop
select_desktop(arg.i);
// Map all windows
if(head != NULL)
for(c=head;c;c=c->next)
XMapWindow(dis,c->win);
tile();
update_current();
}
void save_desktop(int i) {
desktops[i].master_size = master_size;
desktops[i].mode = mode;
desktops[i].head = head;
desktops[i].current = current;
}
void select_desktop(int i) {
head = desktops[i].head;
current = desktops[i].current;
master_size = desktops[i].master_size;
mode = desktops[i].mode;
current_desktop = i;
}
void tile() {
client *c;
int n = 0;
int x = 0;
// If only one window
if(head != NULL && head->next == NULL) {
XMoveResizeWindow(dis,head->win,0,0,sw-4,sh-4);
}
else if(head != NULL) {
switch(mode) {
case 0: /* Horizontal */
// Master window
XMoveResizeWindow(dis,head->win,0,0,sw-4,master_size - BORDER_WIDTH);
// Stack
for(c=head->next;c;c=c->next) ++n;
for(c=head->next;c;c=c->next) {
XMoveResizeWindow(dis,c->win,x,master_size + BORDER_WIDTH,(sw/n) - BORDER_WIDTH,sh-master_size - (2 * BORDER_WIDTH));
x += sw/n;
}
break;
case 1: /* Fullscreen */
for(c=head;c;c=c->next) {
XMoveResizeWindow(dis,c->win,0,0,sw,sh);
}
break;
case 2: /* Vertical */
// Master window
XMoveResizeWindow(dis,head->win,0,0,master_size - BORDER_WIDTH,sh - BORDER_WIDTH);
// Stack
for(c=head->next;c;c=c->next) ++n;
for(c=head->next;c;c=c->next) {
XMoveResizeWindow(dis,c->win,master_size + BORDER_WIDTH,x,sw-master_size-(2*BORDER_WIDTH),(sh/n) - BORDER_WIDTH);
x += sh/n;
}
break;
default:
break;
}
}
}
void toggle_fullscreen() {
if(mode != 1) {
holder = mode;
mode = 1;
}
else {
mode = holder;
}
tile();
update_current();
}
void switch_vertical() {
mode = 2;
master_size = sw * MASTER_SIZE;
tile();
update_current();
}
void switch_horizontal() {
mode = 0;
master_size = sh * MASTER_SIZE;
tile();
update_current();
}
/* ********************** Keyboard Management ********************** */
void grabkeys() {
unsigned int i,j;
KeyCode code;
// numlock workaround
XModifierKeymap *modmap;
numlockmask = 0;
modmap = XGetModifierMapping(dis);
for (i=0;i<8;++i) {
for (j=0;j<modmap->max_keypermod;++j) {
if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dis, XK_Num_Lock))
numlockmask = (1 << i);
}
}
XFreeModifiermap(modmap);
XUngrabKey(dis, AnyKey, AnyModifier, root);
// For each shortcuts
for(i=0;i<TABLENGTH(keys);++i) {
code = XKeysymToKeycode(dis,keys[i].keysym);
XGrabKey(dis, code, keys[i].mod, root, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dis, code, keys[i].mod | LockMask, root, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dis, code, keys[i].mod | numlockmask, root, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dis, code, keys[i].mod | numlockmask | LockMask, root, True, GrabModeAsync, GrabModeAsync);
}
}
void keypress(XEvent *e) {
unsigned int i;
KeySym keysym;
XKeyEvent *ev = &e->xkey;
keysym = XkbKeycodeToKeysym(dis, (KeyCode)ev->keycode, 0, 0);
//fprintf(stderr, "pressed key %s\n", XKeysymToString(keysym));
for(i=0;i<TABLENGTH(keys); ++i) {
if(keysym == keys[i].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)) {
if(keys[i].function)
keys[i].function(keys[i].arg);
}
}
}
void configurenotify(XEvent *e) {
// Do nothing for the moment
}
/* ********************** Signal Management ************************** */
void configurerequest(XEvent *e) {
// Paste from DWM, thx again \o/
XConfigureRequestEvent *ev = &e->xconfigurerequest;
XWindowChanges wc;
wc.x = ev->x;
wc.y = ev->y;
wc.width = ev->width;
wc.height = ev->height;
wc.border_width = ev->border_width;
wc.sibling = ev->above;
wc.stack_mode = ev->detail;
XConfigureWindow(dis, ev->window, ev->value_mask, &wc);
}
void destroynotify(XEvent *e) {
int i=0;
client *c;
XDestroyWindowEvent *ev = &e->xdestroywindow;
// Uber (and ugly) hack ;)
for(c=head;c;c=c->next)
if(ev->window == c->win)
i++;
// End of the hack
if(i == 0)
return;
remove_window(ev->window);
tile();
update_current();
}
void die(const char* e) {
fprintf(stdout,"catwm-0.0.5: %s\n",e);
exit(1);
}
void maprequest(XEvent *e) {
XMapRequestEvent *ev = &e->xmaprequest;
// For fullscreen mplayer (and maybe some other program)
client *c;
for(c=head;c;c=c->next)
if(ev->window == c->win) {
XMapWindow(dis,ev->window);
return;
}
add_window(ev->window);
XMapWindow(dis,ev->window);
tile();
update_current();
}
void catkill() {
//Close connection to X, dwm style :)
XCloseDisplay(dis);
fprintf(stdout, "catwm-0.0.5: You are killed me!\n");
die("forced shutdown");
}
void send_kill_signal(Window w) {
XEvent ke;
ke.type = ClientMessage;
ke.xclient.window = w;
ke.xclient.message_type = XInternAtom(dis, "WM_PROTOCOLS", True);
ke.xclient.format = 32;
ke.xclient.data.l[0] = XInternAtom(dis, "WM_DELETE_WINDOW", True);
ke.xclient.data.l[1] = CurrentTime;
XSendEvent(dis, w, False, NoEventMask, &ke);
}
void setup() {
unsigned int i;
// Install a signal
sigchld(0);
// Screen and root window
screen = DefaultScreen(dis);
root = RootWindow(dis,screen);
// Screen width and height
sw = XDisplayWidth(dis,screen) - BORDER_WIDTH;
sh = XDisplayHeight(dis,screen) - PANEL_HEIGHT - BORDER_WIDTH;
// Colors
win_focus = getcolor(FOCUS);
win_unfocus = getcolor(UNFOCUS);
// Shortcuts
grabkeys();
// Default stack
mode = DEFAULT_MODE;
// For exiting
// bool_quit = 0;
// List of client
head = NULL;
current = NULL;
// Master size
if(mode == 0)
master_size = sh*MASTER_SIZE;
else
master_size = sw*MASTER_SIZE;
// Set up all desktop
// int i;
for(i=0;i<TABLENGTH(desktops);++i) {
desktops[i].master_size = master_size;
desktops[i].mode = mode;
desktops[i].head = head;
desktops[i].current = current;
}
// Select first dekstop by default
const Arg arg = {.i = 0};
current_desktop = arg.i;
change_desktop(arg);
// To catch maprequest and destroynotify (if other wm running)
XSelectInput(dis,root,SubstructureNotifyMask|SubstructureRedirectMask);
fprintf(stdout,"\n\n catwm-0.0.5: We're up and running!\n");
update_current();
}
void sigchld(int unused) {
// Again, thx to dwm ;)
if(signal(SIGCHLD, sigchld) == SIG_ERR)
die("Can't install SIGCHLD handler");
while(0 < waitpid(-1, NULL, WNOHANG));
}
void spawn(const Arg arg) {
if(fork() == 0) {
if(fork() == 0) {
if(dis)
close(ConnectionNumber(dis));
setsid();
execvp((char*)arg.com[0],(char**)arg.com);
}
exit(0);
}
}
void start() {
XEvent ev;
while(running && !XNextEvent(dis, &ev)) if (events[ev.type]) events[ev.type](&ev);
}
void wea() {
//quick and dirty anti not focus
decrease();
increase();
}
//for logging events...
void logger(const char* e) {
fprintf(stderr,"\n\033[0;34m:: catwm-0.0.5 : %s \033[0;m\n", e);
}
/* There's no way to check accesses to destroyed windows, thus those cases are ignored (especially on UnmapNotify's). Other types of errors call Xlibs default error handler, which may call exit. */
int xerror(Display *dis, XErrorEvent *ee) {
if(ee->error_code == BadWindow || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
return 0;
if(ee->error_code == BadAccess) {
logger("\033[0;31mIs Another Window Manager Running? Exiting!");
exit(1);
} else logger("\033[0;31mBad Window Error!");
return xerrorxlib(dis, ee); /* may call exit */
}
/**
* clients receiving a WM_DELETE_WINDOW message should behave as if
* the user selected "delete window" from a hypothetical menu and
* also perform any confirmation dialog with the user.
*/
void deletewindow(Window w) {
if(current != NULL) {
//send delete signal to window
XEvent ke;
ke.type = ClientMessage;
ke.xclient.window = current->win;
ke.xclient.message_type = XInternAtom(dis, "WM_PROTOCOLS", True);
ke.xclient.format = 32;
ke.xclient.data.l[0] = XInternAtom(dis, "WM_DELETE_WINDOW", True);
ke.xclient.data.l[1] = CurrentTime;
XSendEvent(dis, current->win, False, NoEventMask, &ke);
send_kill_signal(current->win);
}
}
/**
* remove all windows in all desktops by sending a delete window message
*/
void cleanup(void) {
Window root_return, parent_return, *children;
unsigned int nchildren;
XUngrabKey(dis, AnyKey, AnyModifier, root);
XQueryTree(dis, root, &root_return, &parent_return, &children, &nchildren);
for (unsigned int i = 0; i < nchildren; i++) deletewindow(children[i]);
if (children) XFree(children);
XSync(dis, False);
}
int main(int argc, char **argv) {
//exported from dwm.c
if(argc == 2 && !strcmp("-v", argv[1]))
die("© 2010 pyknite, © 2014-2015 Dj_Dexter, see LICENSE for details\n");
else if(argc != 1)
die("usage: catwm [-v]\n");
// Open display
if(!(dis = XOpenDisplay(NULL))) {
die("Cannot open display!");
}
// X error handler (if other wm is running in the same display)
XSetErrorHandler(xerror);
// Setup env
setup();
// Start wm
start();
cleanup();
//quick and dirty anti not focus
wea();
// Close display
// XCloseDisplay(dis);
return 0;
}