annotate dwm.c @ 754:4c12dccc288d

this is the (second) begin of aewl - my personal stipped down dwm
author meillo@marmaro.de
date Thu, 29 May 2008 23:12:30 +0200
parents main.c@628c5bac7f3b
children cdd895c163bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
644
1ed8c40dde36 corrections
arg@mig29
parents: 643
diff changeset
1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
2 * See LICENSE file for license details.
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
3 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
4 * dynamic window manager is designed like any other X client as well. It is
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
5 * driven through handling X events. In contrast to other X clients, a window
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
6 * manager selects for SubstructureRedirectMask on the root window, to receive
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
7 * events about window (dis-)appearance. Only one X connection at a time is
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
8 * allowed to select for this event mask.
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
9 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
10 * Calls to fetch an X event from the event queue are blocking. Due reading
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
11 * status text from standard input, a select()-driven main loop has been
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
12 * implemented which selects for reads on the X connection and STDIN_FILENO to
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
13 * handle all data smoothly. The event handlers of dwm are organized in an
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
14 * array which is accessed whenever a new event has been fetched. This allows
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
15 * event dispatching in O(1) time.
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
16 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
17 * Each child of the root window is called a client, except windows which have
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
18 * set the override_redirect flag. Clients are organized in a global
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
19 * doubly-linked client list, the focus history is remembered through a global
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
20 * stack list. Each client contains an array of Bools of the same size as the
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
21 * global tags array to indicate the tags of a client. For each client dwm
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
22 * creates a small title window, which is resized whenever the (_NET_)WM_NAME
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
23 * properties are updated or the client is moved/resized.
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
24 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
25 * Keys and tagging rules are organized as arrays and defined in the config.h
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
26 * file. These arrays are kept static in event.o and tag.o respectively,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
27 * because no other part of dwm needs access to them. The current mode is
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
28 * represented by the arrange() function pointer, which wether points to
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
29 * dofloat() or dotile().
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
30 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
31 * To understand everything else, start reading main.c:main().
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
32 */
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
33
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
34 #include "config.h"
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
35 #include <errno.h>
619
bda4880c462d with this patch everything works fine for me
arg@mig29
parents: 616
diff changeset
36 #include <locale.h>
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
37 #include <regex.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
38 #include <stdio.h>
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
39 #include <stdarg.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
40 #include <stdlib.h>
57
f005d46462e8 implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
Anselm R. Garbe <garbeam@wmii.de>
parents: 52
diff changeset
41 #include <string.h>
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
42 #include <unistd.h>
138
c1185dc7a36e some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents: 137
diff changeset
43 #include <sys/select.h>
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
44 #include <sys/types.h>
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
45 #include <sys/wait.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
46 #include <X11/cursorfont.h>
291
8e6e0aa5e2ae removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents: 281
diff changeset
47 #include <X11/keysym.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
48 #include <X11/Xatom.h>
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
49 #include <X11/Xlib.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
50 #include <X11/Xproto.h>
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
51 #include <X11/Xutil.h>
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
52
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
53 /* mask shorthands, used in event.c and client.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
54 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
55
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
56 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
57 enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
58 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
59 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
60
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
61 typedef union {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
62 const char *cmd;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
63 int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
64 } Arg; /* argument type */
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
65
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
66 typedef struct {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
67 int ascent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
68 int descent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
69 int height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
70 XFontSet set;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
71 XFontStruct *xfont;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
72 } Fnt;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
73
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
74 typedef struct {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
75 int x, y, w, h;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
76 unsigned long norm[ColLast];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
77 unsigned long sel[ColLast];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
78 Drawable drawable;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
79 Fnt font;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
80 GC gc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
81 } DC; /* draw context */
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
82
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
83 typedef struct Client Client;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
84 struct Client {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
85 char name[256];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
86 int x, y, w, h;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
87 int rx, ry, rw, rh; /* revert geometry */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
88 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
89 int minax, minay, maxax, maxay;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
90 long flags;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
91 unsigned int border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
92 Bool isfixed, isfloat, ismax;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
93 Bool *tags;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
94 Client *next;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
95 Client *prev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
96 Client *snext;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
97 Window win;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
98 };
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
99
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
100 typedef struct {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
101 const char *clpattern;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
102 const char *tpattern;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
103 Bool isfloat;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
104 } Rule;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
105
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
106 typedef struct {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
107 regex_t *clregex;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
108 regex_t *tregex;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
109 } RReg;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
110
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
111
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
112 typedef struct {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
113 unsigned long mod;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
114 KeySym keysym;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
115 void (*func)(Arg *arg);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
116 Arg arg;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
117 } Key;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
118
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
119
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
120 #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
121 #define MOUSEMASK (BUTTONMASK | PointerMotionMask)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
122
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
123
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
124
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
125 const char *tags[]; /* all tags */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
126 char stext[256]; /* status text */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
127 int bh, bmw; /* bar height, bar mode label width */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
128 int screen, sx, sy, sw, sh; /* screen geometry */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
129 int wax, way, wah, waw; /* windowarea geometry */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
130 unsigned int nmaster; /* number of master clients */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
131 unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
132 void (*handler[LASTEvent])(XEvent *); /* event handler */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
133 void (*arrange)(void); /* arrange function, indicates mode */
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
134 Atom wmatom[WMLast], netatom[NetLast];
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
135 Bool running, selscreen, *seltag; /* seltag is array of Bool */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
136 Client *clients, *sel, *stack; /* global client list and stack */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
137 Cursor cursor[CurLast];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
138 DC dc; /* global draw context */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
139 Display *dpy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
140 Window root, barwin;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
141
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
142 Bool running = True;
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
143 Bool selscreen = True;
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
144 Client *clients = NULL;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
145 Client *sel = NULL;
446
a2e587651c79 using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
146 Client *stack = NULL;
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
147 DC dc = {0};
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
148
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
149 static int (*xerrorxlib)(Display *, XErrorEvent *);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
150 static Bool otherwm, readin;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
151 static RReg *rreg = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
152 static unsigned int len = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
153
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
154
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
155 TAGS
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
156 RULES
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
157
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
158
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
159 /* client.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
160 void configure(Client *c); /* send synthetic configure event */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
161 void focus(Client *c); /* focus c, c may be NULL */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
162 Client *getclient(Window w); /* return client of w */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
163 Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
164 void killclient(Arg *arg); /* kill c nicely */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
165 void manage(Window w, XWindowAttributes *wa); /* manage new client */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
166 void resize(Client *c, Bool sizehints); /* resize c*/
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
167 void updatesizehints(Client *c); /* update the size hint variables of c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
168 void updatetitle(Client *c); /* update the name of c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
169 void unmanage(Client *c); /* destroy c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
170
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
171 /* draw.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
172 void drawstatus(void); /* draw the bar */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
173 unsigned long getcolor(const char *colstr); /* return color of colstr */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
174 void setfont(const char *fontstr); /* set the font for DC */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
175 unsigned int textw(const char *text); /* return the width of text in px*/
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
176
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
177 /* event.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
178 void grabkeys(void); /* grab all keys defined in config.h */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
179 void procevent(void); /* process pending X events */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
180
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
181 /* main.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
182 void quit(Arg *arg); /* quit dwm nicely */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
183 void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
184 int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
185
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
186 /* tag.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
187 void initrregs(void); /* initialize regexps of rules defined in config.h */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
188 Client *getnext(Client *c); /* returns next visible client */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
189 Client *getprev(Client *c); /* returns previous visible client */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
190 void settags(Client *c, Client *trans); /* sets tags of c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
191 void tag(Arg *arg); /* tags c with arg's index */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
192 void toggletag(Arg *arg); /* toggles c tags with arg's index */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
193 void viewnext(Arg *arg); /* view next tag(s) */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
194
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
195 /* util.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
196 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
197 void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
198 void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
199
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
200 /* view.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
201 void detach(Client *c); /* detaches c from global client list */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
202 void dofloat(void); /* arranges all windows floating */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
203 void dotile(void); /* arranges all windows tiled */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
204 void domax(void); /* arranges all windows fullscreen */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
205 void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
206 void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
207 Bool isvisible(Client *c); /* returns True if client is visible */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
208 void restack(void); /* restores z layers of all clients */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
209 void togglefloat(Arg *arg); /* toggles focusesd client between floating/non-floating state */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
210 void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
211 void view(Arg *arg); /* views the tag with arg's index */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
212 void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
213
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
214
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
215
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
216
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
217
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
218
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
219
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
220
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
221
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
222
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
223 /* from view.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
224 /* static */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
225
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
226 static Client *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
227 nexttiled(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
228 for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
229 return c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
230 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
231
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
232 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
233 togglemax(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
234 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
235
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
236 if(c->isfixed)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
237 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
238
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
239 if((c->ismax = !c->ismax)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
240 c->rx = c->x; c->x = wax;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
241 c->ry = c->y; c->y = way;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
242 c->rw = c->w; c->w = waw - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
243 c->rh = c->h; c->h = wah - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
244 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
245 else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
246 c->x = c->rx;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
247 c->y = c->ry;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
248 c->w = c->rw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
249 c->h = c->rh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
250 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
251 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
252 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
253 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
254
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
255
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
256
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
257 void (*arrange)(void) = DEFMODE;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
258
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
259 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
260 detach(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
261 if(c->prev)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
262 c->prev->next = c->next;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
263 if(c->next)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
264 c->next->prev = c->prev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
265 if(c == clients)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
266 clients = c->next;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
267 c->next = c->prev = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
268 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
269
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
270 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
271 dofloat(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
272 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
273
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
274 for(c = clients; c; c = c->next) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
275 if(isvisible(c)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
276 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
277 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
278 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
279 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
280 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
281 if(!sel || !isvisible(sel)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
282 for(c = stack; c && !isvisible(c); c = c->snext);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
283 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
284 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
285 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
286 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
287
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
288 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
289 dotile(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
290 unsigned int i, n, mw, mh, tw, th;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
291 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
292
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
293 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
294 n++;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
295 /* window geoms */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
296 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
297 mw = (n > nmaster) ? waw / 2 : waw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
298 th = (n > nmaster) ? wah / (n - nmaster) : 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
299 tw = waw - mw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
300
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
301 for(i = 0, c = clients; c; c = c->next)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
302 if(isvisible(c)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
303 if(c->isfloat) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
304 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
305 continue;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
306 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
307 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
308 c->x = wax;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
309 c->y = way;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
310 if(i < nmaster) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
311 c->y += i * mh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
312 c->w = mw - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
313 c->h = mh - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
314 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
315 else { /* tile window */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
316 c->x += mw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
317 c->w = tw - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
318 if(th > 2 * BORDERPX) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
319 c->y += (i - nmaster) * th;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
320 c->h = th - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
321 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
322 else /* fallback if th <= 2 * BORDERPX */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
323 c->h = wah - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
324 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
325 resize(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
326 i++;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
327 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
328 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
329 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
330 if(!sel || !isvisible(sel)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
331 for(c = stack; c && !isvisible(c); c = c->snext);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
332 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
333 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
334 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
335 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
336
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
337 /* begin code by mitch */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
338 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
339 arrangemax(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
340 if(c == sel) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
341 c->ismax = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
342 c->x = sx;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
343 c->y = bh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
344 c->w = sw - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
345 c->h = sh - bh - 2 * BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
346 XRaiseWindow(dpy, c->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
347 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
348 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
349 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
350 XLowerWindow(dpy, c->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
351 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
352 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
353
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
354 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
355 domax(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
356 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
357
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
358 for(c = clients; c; c = c->next) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
359 if(isvisible(c)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
360 if(c->isfloat) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
361 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
362 continue;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
363 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
364 arrangemax(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
365 resize(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
366 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
367 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
368 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
369
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
370 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
371 if(!sel || !isvisible(sel)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
372 for(c = stack; c && !isvisible(c); c = c->snext);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
373 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
374 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
375 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
376 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
377 /* end code by mitch */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
378
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
379 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
380 focusnext(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
381 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
382
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
383 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
384 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
385 if(!(c = getnext(sel->next)))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
386 c = getnext(clients);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
387 if(c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
388 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
389 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
390 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
391 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
392
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
393 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
394 incnmaster(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
395 if((arrange == dofloat) || (nmaster + arg->i < 1)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
396 || (wah / (nmaster + arg->i) <= 2 * BORDERPX))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
397 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
398 nmaster += arg->i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
399 if(sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
400 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
401 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
402 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
403 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
404
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
405 Bool
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
406 isvisible(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
407 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
408
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
409 for(i = 0; i < ntags; i++)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
410 if(c->tags[i] && seltag[i])
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
411 return True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
412 return False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
413 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
414
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
415 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
416 restack(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
417 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
418 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
419
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
420 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
421 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
422 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
423 if(sel->isfloat || arrange == dofloat)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
424 XRaiseWindow(dpy, sel->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
425
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
426 /* begin code by mitch */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
427 if(arrange == domax) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
428 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
429 arrangemax(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
430 resize(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
431 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
432
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
433 } else if (arrange == dotile) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
434 /* end code by mitch */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
435
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
436 if(!sel->isfloat)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
437 XLowerWindow(dpy, sel->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
438 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
439 if(c == sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
440 continue;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
441 XLowerWindow(dpy, c->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
442 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
443 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
444 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
445 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
446 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
447
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
448 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
449 togglefloat(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
450 if (!sel || arrange == dofloat)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
451 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
452 sel->isfloat = !sel->isfloat;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
453 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
454 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
455
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
456 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
457 togglemode(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
458 /* only toggle between tile and max - float is just available through togglefloat */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
459 arrange = (arrange == dotile) ? domax : dotile;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
460 if(sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
461 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
462 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
463 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
464 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
465
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
466 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
467 view(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
468 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
469
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
470 for(i = 0; i < ntags; i++)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
471 seltag[i] = (arg->i == -1) ? True : False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
472 if(arg->i >= 0 && arg->i < ntags)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
473 seltag[arg->i] = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
474 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
475 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
476
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
477 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
478 zoom(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
479 unsigned int n;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
480 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
481
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
482 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
483 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
484 if(sel->isfloat || (arrange == dofloat)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
485 togglemax(sel);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
486 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
487 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
488 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
489 n++;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
490
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
491 if((c = sel) == nexttiled(clients))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
492 if(!(c = nexttiled(c->next)))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
493 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
494 detach(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
495 if(clients)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
496 clients->prev = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
497 c->next = clients;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
498 clients = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
499 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
500 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
501 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
502
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
503
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
504
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
505
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
506
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
507
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
508
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
509
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
510
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
511
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
512
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
513
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
514
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
515
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
516
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
517
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
518 /* from util.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
519
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
520
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
521 void *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
522 emallocz(unsigned int size) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
523 void *res = calloc(1, size);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
524
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
525 if(!res)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
526 eprint("fatal: could not malloc() %u bytes\n", size);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
527 return res;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
528 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
529
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
530 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
531 eprint(const char *errstr, ...) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
532 va_list ap;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
533
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
534 va_start(ap, errstr);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
535 vfprintf(stderr, errstr, ap);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
536 va_end(ap);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
537 exit(EXIT_FAILURE);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
538 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
539
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
540 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
541 spawn(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
542 static char *shell = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
543
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
544 if(!shell && !(shell = getenv("SHELL")))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
545 shell = "/bin/sh";
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
546 if(!arg->cmd)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
547 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
548 /* The double-fork construct avoids zombie processes and keeps the code
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
549 * clean from stupid signal handlers. */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
550 if(fork() == 0) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
551 if(fork() == 0) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
552 if(dpy)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
553 close(ConnectionNumber(dpy));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
554 setsid();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
555 execl(shell, shell, "-c", arg->cmd, (char *)NULL);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
556 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
557 perror(" failed");
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
558 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
559 exit(0);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
560 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
561 wait(0);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
562 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
563
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
564
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
565
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
566
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
567
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
568
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
569
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
570
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
571
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
572
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
573
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
574
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
575
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
576 /* from tag.c */
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
577
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
578 /* static */
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
579
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
580 Client *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
581 getnext(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
582 for(; c && !isvisible(c); c = c->next);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
583 return c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
584 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
585
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
586 Client *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
587 getprev(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
588 for(; c && !isvisible(c); c = c->prev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
589 return c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
590 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
591
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
592 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
593 initrregs(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
594 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
595 regex_t *reg;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
596
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
597 if(rreg)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
598 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
599 len = sizeof rule / sizeof rule[0];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
600 rreg = emallocz(len * sizeof(RReg));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
601 for(i = 0; i < len; i++) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
602 if(rule[i].clpattern) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
603 reg = emallocz(sizeof(regex_t));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
604 if(regcomp(reg, rule[i].clpattern, REG_EXTENDED))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
605 free(reg);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
606 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
607 rreg[i].clregex = reg;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
608 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
609 if(rule[i].tpattern) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
610 reg = emallocz(sizeof(regex_t));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
611 if(regcomp(reg, rule[i].tpattern, REG_EXTENDED))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
612 free(reg);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
613 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
614 rreg[i].tregex = reg;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
615 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
616 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
617 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
618
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
619 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
620 settags(Client *c, Client *trans) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
621 char prop[512];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
622 unsigned int i, j;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
623 regmatch_t tmp;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
624 Bool matched = trans != NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
625 XClassHint ch = { 0 };
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
626
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
627 if(matched) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
628 for(i = 0; i < ntags; i++)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
629 c->tags[i] = trans->tags[i];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
630 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
631 else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
632 XGetClassHint(dpy, c->win, &ch);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
633 snprintf(prop, sizeof prop, "%s:%s:%s",
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
634 ch.res_class ? ch.res_class : "",
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
635 ch.res_name ? ch.res_name : "", c->name);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
636 for(i = 0; i < len; i++)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
637 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
638 c->isfloat = rule[i].isfloat;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
639 for(j = 0; rreg[i].tregex && j < ntags; j++) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
640 if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
641 matched = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
642 c->tags[j] = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
643 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
644 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
645 break; /* perform only the first rule matching */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
646 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
647 if(ch.res_class)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
648 XFree(ch.res_class);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
649 if(ch.res_name)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
650 XFree(ch.res_name);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
651 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
652 if(!matched)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
653 for(i = 0; i < ntags; i++)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
654 c->tags[i] = seltag[i];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
655 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
656
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
657 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
658 tag(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
659 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
660
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
661 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
662 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
663 for(i = 0; i < ntags; i++)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
664 sel->tags[i] = (arg->i == -1) ? True : False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
665 if(arg->i >= 0 && arg->i < ntags)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
666 sel->tags[arg->i] = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
667 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
668 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
669
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
670 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
671 toggletag(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
672 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
673
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
674 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
675 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
676 sel->tags[arg->i] = !sel->tags[arg->i];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
677 for(i = 0; i < ntags && !sel->tags[i]; i++);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
678 if(i == ntags)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
679 sel->tags[arg->i] = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
680 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
681 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
682
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
683 /* begin code by jukka */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
684 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
685 viewnext(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
686 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
687 Bool last = seltag[ntags-1];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
688
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
689 for (i=ntags-1; i>0; --i)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
690 seltag[i] = seltag[i-1];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
691 seltag[0] = last;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
692 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
693 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
694 /* end code by jukka */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
695
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
696
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
697
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
698
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
699
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
700
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
701
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
702
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
703
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
704
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
705
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
706
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
707
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
708
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
709
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
710
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
711 /* from event.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
712 /* static */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
713
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
714 KEYS
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
715
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
716
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
717
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
718 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
719 movemouse(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
720 int x1, y1, ocx, ocy, di;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
721 unsigned int dui;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
722 Window dummy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
723 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
724
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
725 ocx = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
726 ocy = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
727 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
728 None, cursor[CurMove], CurrentTime) != GrabSuccess)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
729 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
730 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
731 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
732 for(;;) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
733 XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
734 switch (ev.type) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
735 case ButtonRelease:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
736 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
737 XUngrabPointer(dpy, CurrentTime);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
738 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
739 case ConfigureRequest:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
740 case Expose:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
741 case MapRequest:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
742 handler[ev.type](&ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
743 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
744 case MotionNotify:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
745 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
746 c->x = ocx + (ev.xmotion.x - x1);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
747 c->y = ocy + (ev.xmotion.y - y1);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
748 if(abs(wax + c->x) < SNAP)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
749 c->x = wax;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
750 else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
751 c->x = wax + waw - c->w - 2 * c->border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
752 if(abs(way - c->y) < SNAP)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
753 c->y = way;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
754 else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
755 c->y = way + wah - c->h - 2 * c->border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
756 resize(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
757 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
758 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
759 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
760 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
761
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
762 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
763 resizemouse(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
764 int ocx, ocy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
765 int nw, nh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
766 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
767
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
768 ocx = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
769 ocy = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
770 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
771 None, cursor[CurResize], CurrentTime) != GrabSuccess)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
772 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
773 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
774 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
775 for(;;) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
776 XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
777 switch(ev.type) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
778 case ButtonRelease:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
779 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
780 XUngrabPointer(dpy, CurrentTime);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
781 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
782 case ConfigureRequest:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
783 case Expose:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
784 case MapRequest:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
785 handler[ev.type](&ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
786 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
787 case MotionNotify:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
788 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
789 nw = ev.xmotion.x - ocx - 2 * c->border + 1;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
790 c->w = nw > 0 ? nw : 1;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
791 nh = ev.xmotion.y - ocy - 2 * c->border + 1;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
792 c->h = nh > 0 ? nh : 1;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
793 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
794 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
795 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
796 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
797 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
798
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
799 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
800 buttonpress(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
801 int x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
802 Arg a;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
803 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
804 XButtonPressedEvent *ev = &e->xbutton;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
805
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
806 if(barwin == ev->window) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
807 x = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
808 for(a.i = 0; a.i < ntags; a.i++) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
809 x += textw(tags[a.i]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
810 if(ev->x < x) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
811 if(ev->button == Button1) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
812 view(&a);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
813 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
814 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
815 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
816 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
817 if(ev->x < x + bmw)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
818 if (ev->button == Button1) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
819 togglemode(NULL);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
820 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
821 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
822 else if((c = getclient(ev->window))) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
823 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
824 if(CLEANMASK(ev->state) != MODKEY)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
825 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
826 if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
827 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
828 movemouse(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
829 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
830 else if(ev->button == Button2)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
831 zoom(NULL);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
832 else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
833 !c->isfixed) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
834 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
835 resizemouse(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
836 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
837 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
838 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
839
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
840 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
841 configurerequest(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
842 unsigned long newmask;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
843 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
844 XConfigureRequestEvent *ev = &e->xconfigurerequest;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
845 XWindowChanges wc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
846
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
847 if((c = getclient(ev->window))) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
848 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
849 if(ev->value_mask & CWX)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
850 c->x = ev->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
851 if(ev->value_mask & CWY)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
852 c->y = ev->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
853 if(ev->value_mask & CWWidth)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
854 c->w = ev->width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
855 if(ev->value_mask & CWHeight)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
856 c->h = ev->height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
857 if(ev->value_mask & CWBorderWidth)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
858 c->border = ev->border_width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
859 wc.x = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
860 wc.y = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
861 wc.width = c->w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
862 wc.height = c->h;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
863 newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
864 if(newmask)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
865 XConfigureWindow(dpy, c->win, newmask, &wc);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
866 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
867 configure(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
868 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
869 if(c->isfloat) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
870 resize(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
871 if(!isvisible(c))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
872 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
873 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
874 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
875 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
876 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
877 else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
878 wc.x = ev->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
879 wc.y = ev->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
880 wc.width = ev->width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
881 wc.height = ev->height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
882 wc.border_width = ev->border_width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
883 wc.sibling = ev->above;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
884 wc.stack_mode = ev->detail;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
885 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
886 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
887 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
888 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
889
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
890 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
891 destroynotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
892 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
893 XDestroyWindowEvent *ev = &e->xdestroywindow;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
894
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
895 if((c = getclient(ev->window)))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
896 unmanage(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
897 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
898
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
899 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
900 enternotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
901 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
902 XCrossingEvent *ev = &e->xcrossing;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
903
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
904 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
905 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
906 if((c = getclient(ev->window)) && isvisible(c))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
907 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
908 else if(ev->window == root) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
909 selscreen = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
910 for(c = stack; c && !isvisible(c); c = c->snext);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
911 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
912 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
913 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
914
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
915 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
916 expose(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
917 XExposeEvent *ev = &e->xexpose;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
918
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
919 if(ev->count == 0) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
920 if(barwin == ev->window)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
921 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
922 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
923 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
924
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
925 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
926 keypress(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
927 static unsigned int len = sizeof key / sizeof key[0];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
928 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
929 KeySym keysym;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
930 XKeyEvent *ev = &e->xkey;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
931
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
932 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
933 for(i = 0; i < len; i++) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
934 if(keysym == key[i].keysym
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
935 && CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
936 {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
937 if(key[i].func)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
938 key[i].func(&key[i].arg);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
939 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
940 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
941 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
942
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
943 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
944 leavenotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
945 XCrossingEvent *ev = &e->xcrossing;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
946
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
947 if((ev->window == root) && !ev->same_screen) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
948 selscreen = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
949 focus(NULL);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
950 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
951 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
952
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
953 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
954 mappingnotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
955 XMappingEvent *ev = &e->xmapping;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
956
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
957 XRefreshKeyboardMapping(ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
958 if(ev->request == MappingKeyboard)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
959 grabkeys();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
960 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
961
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
962 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
963 maprequest(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
964 static XWindowAttributes wa;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
965 XMapRequestEvent *ev = &e->xmaprequest;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
966
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
967 if(!XGetWindowAttributes(dpy, ev->window, &wa))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
968 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
969 if(wa.override_redirect) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
970 XSelectInput(dpy, ev->window,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
971 (StructureNotifyMask | PropertyChangeMask));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
972 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
973 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
974 if(!getclient(ev->window))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
975 manage(ev->window, &wa);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
976 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
977
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
978 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
979 propertynotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
980 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
981 Window trans;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
982 XPropertyEvent *ev = &e->xproperty;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
983
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
984 if(ev->state == PropertyDelete)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
985 return; /* ignore */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
986 if((c = getclient(ev->window))) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
987 switch (ev->atom) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
988 default: break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
989 case XA_WM_TRANSIENT_FOR:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
990 XGetTransientForHint(dpy, c->win, &trans);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
991 if(!c->isfloat && (c->isfloat = (trans != 0)))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
992 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
993 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
994 case XA_WM_NORMAL_HINTS:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
995 updatesizehints(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
996 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
997 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
998 if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
999 updatetitle(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1000 if(c == sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1001 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1002 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1003 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1004 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1005
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1006 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1007 unmapnotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1008 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1009 XUnmapEvent *ev = &e->xunmap;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1010
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1011 if((c = getclient(ev->window)))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1012 unmanage(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1013 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1014
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1015
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1016
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1017 void (*handler[LASTEvent]) (XEvent *) = {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1018 [ButtonPress] = buttonpress,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1019 [ConfigureRequest] = configurerequest,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1020 [DestroyNotify] = destroynotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1021 [EnterNotify] = enternotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1022 [LeaveNotify] = leavenotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1023 [Expose] = expose,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1024 [KeyPress] = keypress,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1025 [MappingNotify] = mappingnotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1026 [MapRequest] = maprequest,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1027 [PropertyNotify] = propertynotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1028 [UnmapNotify] = unmapnotify
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1029 };
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1030
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1031 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1032 grabkeys(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1033 static unsigned int len = sizeof key / sizeof key[0];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1034 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1035 KeyCode code;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1036
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1037 XUngrabKey(dpy, AnyKey, AnyModifier, root);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1038 for(i = 0; i < len; i++) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1039 code = XKeysymToKeycode(dpy, key[i].keysym);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1040 XGrabKey(dpy, code, key[i].mod, root, True,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1041 GrabModeAsync, GrabModeAsync);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1042 XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1043 GrabModeAsync, GrabModeAsync);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1044 XGrabKey(dpy, code, key[i].mod | numlockmask, root, True,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1045 GrabModeAsync, GrabModeAsync);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1046 XGrabKey(dpy, code, key[i].mod | numlockmask | LockMask, root, True,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1047 GrabModeAsync, GrabModeAsync);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1048 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1049 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1050
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1051 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1052 procevent(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1053 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1054
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1055 while(XPending(dpy)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1056 XNextEvent(dpy, &ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1057 if(handler[ev.type])
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1058 (handler[ev.type])(&ev); /* call handler */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1059 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1060 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1061
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1062
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1063
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1064
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1065
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1066
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1067
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1068
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1069
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1070
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1071
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1072
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1073
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1074
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1075
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1076 /* from draw.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1077 /* static */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1078
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1079 static unsigned int
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1080 textnw(const char *text, unsigned int len) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1081 XRectangle r;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1082
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1083 if(dc.font.set) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1084 XmbTextExtents(dc.font.set, text, len, NULL, &r);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1085 return r.width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1086 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1087 return XTextWidth(dc.font.xfont, text, len);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1088 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1089
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1090 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1091 drawtext(const char *text, unsigned long col[ColLast]) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1092 int x, y, w, h;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1093 static char buf[256];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1094 unsigned int len, olen;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1095 XGCValues gcv;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1096 XRectangle r = { dc.x, dc.y, dc.w, dc.h };
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1097
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1098 XSetForeground(dpy, dc.gc, col[ColBG]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1099 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1100 if(!text)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1101 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1102 w = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1103 olen = len = strlen(text);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1104 if(len >= sizeof buf)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1105 len = sizeof buf - 1;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1106 memcpy(buf, text, len);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1107 buf[len] = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1108 h = dc.font.ascent + dc.font.descent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1109 y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1110 x = dc.x + (h / 2);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1111 /* shorten text if necessary */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1112 while(len && (w = textnw(buf, len)) > dc.w - h)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1113 buf[--len] = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1114 if(len < olen) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1115 if(len > 1)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1116 buf[len - 1] = '.';
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1117 if(len > 2)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1118 buf[len - 2] = '.';
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1119 if(len > 3)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1120 buf[len - 3] = '.';
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1121 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1122 if(w > dc.w)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1123 return; /* too long */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1124 gcv.foreground = col[ColFG];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1125 if(dc.font.set) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1126 XChangeGC(dpy, dc.gc, GCForeground, &gcv);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1127 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1128 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1129 gcv.font = dc.font.xfont->fid;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1130 XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1131 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1132 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1133 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1134
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1135
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1136
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1137 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1138 drawstatus(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1139 int i, x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1140
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1141 dc.x = dc.y = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1142 for(i = 0; i < ntags; i++) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1143 dc.w = textw(tags[i]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1144 drawtext(tags[i], (seltag[i] ? dc.sel : dc.norm));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1145 dc.x += dc.w + 1;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1146 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1147 dc.w = bmw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1148 drawtext("", dc.norm);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1149 x = dc.x + dc.w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1150 dc.w = textw(stext);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1151 dc.x = sw - dc.w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1152 if(dc.x < x) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1153 dc.x = x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1154 dc.w = sw - x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1155 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1156 drawtext(stext, dc.norm);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1157 if((dc.w = dc.x - x) > bh) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1158 dc.x = x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1159 drawtext(sel ? sel->name : NULL, dc.norm);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1160 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1161 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1162 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1163 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1164
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1165 unsigned long
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1166 getcolor(const char *colstr) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1167 Colormap cmap = DefaultColormap(dpy, screen);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1168 XColor color;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1169
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1170 if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1171 eprint("error, cannot allocate color '%s'\n", colstr);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1172 return color.pixel;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1173 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1174
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1175 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1176 setfont(const char *fontstr) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1177 char *def, **missing;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1178 int i, n;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1179
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1180 missing = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1181 if(dc.font.set)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1182 XFreeFontSet(dpy, dc.font.set);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1183 dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1184 if(missing) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1185 while(n--)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1186 fprintf(stderr, "missing fontset: %s\n", missing[n]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1187 XFreeStringList(missing);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1188 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1189 if(dc.font.set) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1190 XFontSetExtents *font_extents;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1191 XFontStruct **xfonts;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1192 char **font_names;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1193 dc.font.ascent = dc.font.descent = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1194 font_extents = XExtentsOfFontSet(dc.font.set);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1195 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1196 for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1197 if(dc.font.ascent < (*xfonts)->ascent)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1198 dc.font.ascent = (*xfonts)->ascent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1199 if(dc.font.descent < (*xfonts)->descent)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1200 dc.font.descent = (*xfonts)->descent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1201 xfonts++;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1202 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1203 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1204 if(dc.font.xfont)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1205 XFreeFont(dpy, dc.font.xfont);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1206 dc.font.xfont = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1207 if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1208 eprint("error, cannot load font: '%s'\n", fontstr);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1209 dc.font.ascent = dc.font.xfont->ascent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1210 dc.font.descent = dc.font.xfont->descent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1211 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1212 dc.font.height = dc.font.ascent + dc.font.descent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1213 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1214
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1215 unsigned int
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1216 textw(const char *text) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1217 return textnw(text, strlen(text)) + dc.font.height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1218 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1219
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1220
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1221
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1222
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1223
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1224
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1225
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1226
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1227
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1228
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1229
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1230 /* from client.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1231 /* static */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1232
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1233 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1234 detachstack(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1235 Client **tc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1236 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1237 *tc = c->snext;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1238 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1239
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1240 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1241 grabbuttons(Client *c, Bool focused) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1242 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1243
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1244 if(focused) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1245 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1246 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1247 XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1248 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1249 XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1250 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1251 XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1252 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1253
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1254 XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1255 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1256 XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1257 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1258 XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1259 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1260 XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1261 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1262
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1263 XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1264 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1265 XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1266 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1267 XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1268 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1269 XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1270 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1271 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1272 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1273 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1274 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1275 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1276
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1277 static void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1278 setclientstate(Client *c, long state) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1279 long data[] = {state, None};
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1280 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1281 PropModeReplace, (unsigned char *)data, 2);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1282 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1283
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1284 static int
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1285 xerrordummy(Display *dsply, XErrorEvent *ee) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1286 return 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1287 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1288
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1289
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1290
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1291 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1292 configure(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1293 XEvent synev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1294
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1295 synev.type = ConfigureNotify;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1296 synev.xconfigure.display = dpy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1297 synev.xconfigure.event = c->win;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1298 synev.xconfigure.window = c->win;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1299 synev.xconfigure.x = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1300 synev.xconfigure.y = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1301 synev.xconfigure.width = c->w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1302 synev.xconfigure.height = c->h;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1303 synev.xconfigure.border_width = c->border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1304 synev.xconfigure.above = None;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1305 XSendEvent(dpy, c->win, True, NoEventMask, &synev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1306 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1307
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1308 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1309 focus(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1310 if(c && !isvisible(c))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1311 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1312 if(sel && sel != c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1313 grabbuttons(sel, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1314 XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1315 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1316 if(c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1317 detachstack(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1318 c->snext = stack;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1319 stack = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1320 grabbuttons(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1321 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1322 sel = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1323 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1324 if(!selscreen)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1325 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1326 if(c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1327 XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1328 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1329 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1330 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1331 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1332 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1333
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1334 Client *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1335 getclient(Window w) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1336 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1337
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1338 for(c = clients; c; c = c->next) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1339 if(c->win == w) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1340 return c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1341 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1342 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1343 return NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1344 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1345
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1346 Bool
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1347 isprotodel(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1348 int i, n;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1349 Atom *protocols;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1350 Bool ret = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1351
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1352 if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1353 for(i = 0; !ret && i < n; i++)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1354 if(protocols[i] == wmatom[WMDelete])
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1355 ret = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1356 XFree(protocols);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1357 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1358 return ret;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1359 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1360
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1361 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1362 killclient(Arg *arg) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1363 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1364 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1365 if(isprotodel(sel))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1366 sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1367 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1368 XKillClient(dpy, sel->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1369 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1370
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1371 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1372 manage(Window w, XWindowAttributes *wa) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1373 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1374 Window trans;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1375
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1376 c = emallocz(sizeof(Client));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1377 c->tags = emallocz(ntags * sizeof(Bool));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1378 c->win = w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1379 c->x = wa->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1380 c->y = wa->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1381 c->w = wa->width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1382 c->h = wa->height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1383 if(c->w == sw && c->h == sh) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1384 c->border = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1385 c->x = sx;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1386 c->y = sy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1387 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1388 c->border = BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1389 if(c->x + c->w + 2 * c->border > wax + waw)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1390 c->x = wax + waw - c->w - 2 * c->border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1391 if(c->y + c->h + 2 * c->border > way + wah)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1392 c->y = way + wah - c->h - 2 * c->border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1393 if(c->x < wax)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1394 c->x = wax;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1395 if(c->y < way)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1396 c->y = way;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1397 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1398 updatesizehints(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1399 XSelectInput(dpy, c->win,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1400 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1401 XGetTransientForHint(dpy, c->win, &trans);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1402 grabbuttons(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1403 XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1404 updatetitle(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1405 settags(c, getclient(trans));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1406 if(!c->isfloat)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1407 c->isfloat = trans || c->isfixed;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1408 if(clients)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1409 clients->prev = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1410 c->next = clients;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1411 c->snext = stack;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1412 stack = clients = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1413 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1414 XMapWindow(dpy, c->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1415 setclientstate(c, NormalState);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1416 if(isvisible(c))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1417 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1418 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1419 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1420
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1421 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1422 resize(Client *c, Bool sizehints) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1423 float actual, dx, dy, max, min;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1424 XWindowChanges wc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1425
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1426 if(c->w <= 0 || c->h <= 0)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1427 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1428 if(sizehints) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1429 if(c->minw && c->w < c->minw)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1430 c->w = c->minw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1431 if(c->minh && c->h < c->minh)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1432 c->h = c->minh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1433 if(c->maxw && c->w > c->maxw)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1434 c->w = c->maxw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1435 if(c->maxh && c->h > c->maxh)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1436 c->h = c->maxh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1437 /* inspired by algorithm from fluxbox */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1438 if(c->minay > 0 && c->maxay && (c->h - c->baseh) > 0) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1439 dx = (float)(c->w - c->basew);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1440 dy = (float)(c->h - c->baseh);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1441 min = (float)(c->minax) / (float)(c->minay);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1442 max = (float)(c->maxax) / (float)(c->maxay);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1443 actual = dx / dy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1444 if(max > 0 && min > 0 && actual > 0) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1445 if(actual < min) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1446 dy = (dx * min + dy) / (min * min + 1);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1447 dx = dy * min;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1448 c->w = (int)dx + c->basew;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1449 c->h = (int)dy + c->baseh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1450 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1451 else if(actual > max) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1452 dy = (dx * min + dy) / (max * max + 1);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1453 dx = dy * min;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1454 c->w = (int)dx + c->basew;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1455 c->h = (int)dy + c->baseh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1456 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1457 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1458 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1459 if(c->incw)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1460 c->w -= (c->w - c->basew) % c->incw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1461 if(c->inch)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1462 c->h -= (c->h - c->baseh) % c->inch;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1463 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1464 if(c->w == sw && c->h == sh)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1465 c->border = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1466 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1467 c->border = BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1468 /* offscreen appearance fixes */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1469 if(c->x > sw)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1470 c->x = sw - c->w - 2 * c->border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1471 if(c->y > sh)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1472 c->y = sh - c->h - 2 * c->border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1473 if(c->x + c->w + 2 * c->border < sx)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1474 c->x = sx;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1475 if(c->y + c->h + 2 * c->border < sy)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1476 c->y = sy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1477 wc.x = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1478 wc.y = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1479 wc.width = c->w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1480 wc.height = c->h;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1481 wc.border_width = c->border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1482 XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1483 configure(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1484 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1485 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1486
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1487 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1488 updatesizehints(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1489 long msize;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1490 XSizeHints size;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1491
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1492 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1493 size.flags = PSize;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1494 c->flags = size.flags;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1495 if(c->flags & PBaseSize) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1496 c->basew = size.base_width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1497 c->baseh = size.base_height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1498 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1499 c->basew = c->baseh = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1500 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1501 if(c->flags & PResizeInc) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1502 c->incw = size.width_inc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1503 c->inch = size.height_inc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1504 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1505 c->incw = c->inch = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1506 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1507 if(c->flags & PMaxSize) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1508 c->maxw = size.max_width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1509 c->maxh = size.max_height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1510 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1511 c->maxw = c->maxh = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1512 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1513 if(c->flags & PMinSize) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1514 c->minw = size.min_width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1515 c->minh = size.min_height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1516 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1517 c->minw = c->minh = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1518 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1519 if(c->flags & PAspect) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1520 c->minax = size.min_aspect.x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1521 c->minay = size.min_aspect.y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1522 c->maxax = size.max_aspect.x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1523 c->maxay = size.max_aspect.y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1524 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1525 c->minax = c->minay = c->maxax = c->maxay = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1526 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1527 c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1528 c->maxw == c->minw && c->maxh == c->minh);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1529 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1530
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1531 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1532 updatetitle(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1533 char **list = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1534 int n;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1535 XTextProperty name;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1536
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1537 name.nitems = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1538 c->name[0] = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1539 XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1540 if(!name.nitems)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1541 XGetWMName(dpy, c->win, &name);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1542 if(!name.nitems)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1543 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1544 if(name.encoding == XA_STRING)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1545 strncpy(c->name, (char *)name.value, sizeof c->name);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1546 else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1547 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1548 strncpy(c->name, *list, sizeof c->name);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1549 XFreeStringList(list);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1550 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1551 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1552 XFree(name.value);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1553 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1554
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1555 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1556 unmanage(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1557 Client *nc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1558
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1559 /* The server grab construct avoids race conditions. */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1560 XGrabServer(dpy);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1561 XSetErrorHandler(xerrordummy);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1562 detach(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1563 detachstack(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1564 if(sel == c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1565 for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1566 focus(nc);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1567 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1568 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1569 setclientstate(c, WithdrawnState);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1570 free(c->tags);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1571 free(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1572 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1573 XSetErrorHandler(xerror);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1574 XUngrabServer(dpy);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1575 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1576 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1577
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1578
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1579
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1580
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1581
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1582
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1583
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1584
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1585
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1586
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1587
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1588
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1589
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1590
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1591
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1592
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1593
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1594
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1595
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1596 /* static */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1597
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1598
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1599 static void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 473
diff changeset
1600 cleanup(void) {
302
3b11e32e8d7e we close stdin as well
Anselm R.Garbe <arg@10ksloc.org>
parents: 295
diff changeset
1601 close(STDIN_FILENO);
645
8e6d75c68b69 changed arg's color scheme
arg@mig29
parents: 644
diff changeset
1602 while(stack) {
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 697
diff changeset
1603 resize(stack, True);
645
8e6d75c68b69 changed arg's color scheme
arg@mig29
parents: 644
diff changeset
1604 unmanage(stack);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1605 }
295
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1606 if(dc.font.set)
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1607 XFreeFontSet(dpy, dc.font.set);
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1608 else
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1609 XFreeFont(dpy, dc.font.xfont);
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1610 XUngrabKey(dpy, AnyKey, AnyModifier, root);
295
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1611 XFreePixmap(dpy, dc.drawable);
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1612 XFreeGC(dpy, dc.gc);
309
204427dcc087 corrected order of cleanup code
Anselm R.Garbe <arg@10ksloc.org>
parents: 302
diff changeset
1613 XDestroyWindow(dpy, barwin);
616
f617c75a8405 improved the memory leak prevention
arg@mig29
parents: 583
diff changeset
1614 XFreeCursor(dpy, cursor[CurNormal]);
f617c75a8405 improved the memory leak prevention
arg@mig29
parents: 583
diff changeset
1615 XFreeCursor(dpy, cursor[CurResize]);
f617c75a8405 improved the memory leak prevention
arg@mig29
parents: 583
diff changeset
1616 XFreeCursor(dpy, cursor[CurMove]);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1617 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1618 XSync(dpy, False);
433
a6b8994af164 small fix
Anselm R. Garbe <arg@10kloc.org>
parents: 400
diff changeset
1619 free(seltag);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1620 }
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1621
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1622 static void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 473
diff changeset
1623 scan(void) {
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1624 unsigned int i, num;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1625 Window *wins, d1, d2;
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1626 XWindowAttributes wa;
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1627
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1628 wins = NULL;
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1629 if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1630 for(i = 0; i < num; i++) {
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1631 if(!XGetWindowAttributes(dpy, wins[i], &wa))
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1632 continue;
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1633 if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1634 continue;
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1635 if(wa.map_state == IsViewable)
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
1636 manage(wins[i], &wa);
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1637 }
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1638 }
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1639 if(wins)
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1640 XFree(wins);
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1641 }
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1642
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1643 static void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 473
diff changeset
1644 setup(void) {
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1645 int i, j;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1646 unsigned int mask;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1647 Window w;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1648 XModifierKeymap *modmap;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1649 XSetWindowAttributes wa;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1650
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1651 /* init atoms */
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1652 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1653 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
725
d99be681d502 handling WM_STATE seems to make DnD in gtk/qt apps working, well let's handle this in dwm as well
Anselm R. Garbe <arg@suckless.org>
parents: 716
diff changeset
1654 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1655 netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1656 netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1657 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1658 PropModeReplace, (unsigned char *) netatom, NetLast);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1659 /* init cursors */
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1660 cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1661 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1662 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1663 /* init modifier map */
679
5f0134b88b8d small fix of initial numlockmask value
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
1664 numlockmask = 0;
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1665 modmap = XGetModifierMapping(dpy);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1666 for (i = 0; i < 8; i++) {
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1667 for (j = 0; j < modmap->max_keypermod; j++) {
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1668 if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1669 numlockmask = (1 << i);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1670 }
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1671 }
616
f617c75a8405 improved the memory leak prevention
arg@mig29
parents: 583
diff changeset
1672 XFreeModifiermap(modmap);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1673 /* select for events */
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 458
diff changeset
1674 wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 458
diff changeset
1675 | EnterWindowMask | LeaveWindowMask;
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1676 wa.cursor = cursor[CurNormal];
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1677 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1678 grabkeys();
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1679 initrregs();
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1680 for(ntags = 0; tags[ntags]; ntags++);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1681 seltag = emallocz(sizeof(Bool) * ntags);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1682 seltag[0] = True;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1683 /* style */
689
cbec08a54a15 implemented new color scheme accordingly to Sanders proposal
Anselm R. Garbe <arg@suckless.org>
parents: 688
diff changeset
1684 dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1685 dc.norm[ColBG] = getcolor(NORMBGCOLOR);
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1686 dc.norm[ColFG] = getcolor(NORMFGCOLOR);
689
cbec08a54a15 implemented new color scheme accordingly to Sanders proposal
Anselm R. Garbe <arg@suckless.org>
parents: 688
diff changeset
1687 dc.sel[ColBorder] = getcolor(SELBORDERCOLOR);
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1688 dc.sel[ColBG] = getcolor(SELBGCOLOR);
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1689 dc.sel[ColFG] = getcolor(SELFGCOLOR);
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1690 setfont(FONT);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1691 /* geometry */
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1692 sx = sy = 0;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1693 sw = DisplayWidth(dpy, screen);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1694 sh = DisplayHeight(dpy, screen);
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 645
diff changeset
1695 nmaster = NMASTER;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1696 bmw = 1;
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1697 /* bar */
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1698 dc.h = bh = dc.font.height + 2;
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1699 wa.override_redirect = 1;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1700 wa.background_pixmap = ParentRelative;
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1701 wa.event_mask = ButtonPressMask | ExposureMask;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1702 barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0,
739
7834ffd650d5 added TOPBAR option for making the bar appear what the user likes
Anselm R. Garbe <arg@suckless.org>
parents: 737
diff changeset
1703 DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1704 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1705 XDefineCursor(dpy, barwin, cursor[CurNormal]);
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1706 XMapRaised(dpy, barwin);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1707 strcpy(stext, "dwm-"VERSION);
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 532
diff changeset
1708 /* windowarea */
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 532
diff changeset
1709 wax = sx;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1710 way = sy + bh;
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 532
diff changeset
1711 wah = sh - bh;
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 532
diff changeset
1712 waw = sw;
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1713 /* pixmap for everything */
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1714 dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1715 dc.gc = XCreateGC(dpy, root, 0, 0);
344
93192711a36a changing tag indicator through underline
Anselm R. Garbe <arg@10kloc.org>
parents: 339
diff changeset
1716 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1717 /* multihead support */
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
1718 selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1719 }
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1720
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1721 /*
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1722 * Startup Error handler to check if another window manager
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1723 * is already running.
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1724 */
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1725 static int
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 458
diff changeset
1726 xerrorstart(Display *dsply, XErrorEvent *ee) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1727 otherwm = True;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1728 return -1;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1729 }
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1730
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1731
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
1732
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1733 void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 458
diff changeset
1734 sendevent(Window w, Atom a, long value) {
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1735 XEvent e;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1736
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1737 e.type = ClientMessage;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1738 e.xclient.window = w;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1739 e.xclient.message_type = a;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1740 e.xclient.format = 32;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1741 e.xclient.data.l[0] = value;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1742 e.xclient.data.l[1] = CurrentTime;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1743 XSendEvent(dpy, w, False, NoEventMask, &e);
79
aabebd6e61f3 fixed XSync handling and finished man page
Anselm R. Garbe <garbeam@wmii.de>
parents: 78
diff changeset
1744 XSync(dpy, False);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1745 }
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1746
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1747 void
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 458
diff changeset
1748 quit(Arg *arg) {
302
3b11e32e8d7e we close stdin as well
Anselm R.Garbe <arg@10ksloc.org>
parents: 295
diff changeset
1749 readin = running = False;
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1750 }
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1751
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1752 /* There's no way to check accesses to destroyed windows, thus those cases are
84
052fe7498930 ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents: 79
diff changeset
1753 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs
455
4e3e22673073 fixed some other comments, now also the code side seems to be at a level to be reviewed by experienced programmers
Anselm R. Garbe <arg@10kloc.org>
parents: 446
diff changeset
1754 * default error handler, which may call exit.
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1755 */
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
1756 int
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 458
diff changeset
1757 xerror(Display *dpy, XErrorEvent *ee) {
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1758 if(ee->error_code == BadWindow
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1759 || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1760 || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1761 || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1762 || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1763 || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
458
81fcd7ddafee applied Christof Musik's multihead patch for a pathologic cornercase
Anselm R. Garbe <arg@10kloc.org>
parents: 455
diff changeset
1764 || (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
81fcd7ddafee applied Christof Musik's multihead patch for a pathologic cornercase
Anselm R. Garbe <arg@10kloc.org>
parents: 455
diff changeset
1765 || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1766 return 0;
34
cd30cce52b78 added logo+description
Anselm R. Garbe <garbeam@wmii.de>
parents: 33
diff changeset
1767 fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1768 ee->request_code, ee->error_code);
455
4e3e22673073 fixed some other comments, now also the code side seems to be at a level to be reviewed by experienced programmers
Anselm R. Garbe <arg@10kloc.org>
parents: 446
diff changeset
1769 return xerrorxlib(dpy, ee); /* may call exit */
27
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
1770 }
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
1771
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1772 int
461
9d23330a5268 removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents: 458
diff changeset
1773 main(int argc, char *argv[]) {
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 580
diff changeset
1774 char *p;
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1775 int r, xfd;
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
1776 fd_set rd;
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1777
137
77922a389fa8 simplified main.c, switching back to single urxvt usage
arg@10ksloc.org
parents: 126
diff changeset
1778 if(argc == 2 && !strncmp("-v", argv[1], 3)) {
644
1ed8c40dde36 corrections
arg@mig29
parents: 643
diff changeset
1779 fputs("dwm-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout);
137
77922a389fa8 simplified main.c, switching back to single urxvt usage
arg@10ksloc.org
parents: 126
diff changeset
1780 exit(EXIT_SUCCESS);
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1781 }
137
77922a389fa8 simplified main.c, switching back to single urxvt usage
arg@10ksloc.org
parents: 126
diff changeset
1782 else if(argc != 1)
77922a389fa8 simplified main.c, switching back to single urxvt usage
arg@10ksloc.org
parents: 126
diff changeset
1783 eprint("usage: dwm [-v]\n");
619
bda4880c462d with this patch everything works fine for me
arg@mig29
parents: 616
diff changeset
1784 setlocale(LC_CTYPE, "");
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1785 dpy = XOpenDisplay(0);
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1786 if(!dpy)
197
c13f374f836c slight fix
arg@10ksloc.org
parents: 191
diff changeset
1787 eprint("dwm: cannot open display\n");
265
573b1c4a71a4 reducing ConnectionNumber calls to a bare minimum
Anselm R.Garbe <arg@10ksloc.org>
parents: 262
diff changeset
1788 xfd = ConnectionNumber(dpy);
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1789 screen = DefaultScreen(dpy);
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1790 root = RootWindow(dpy, screen);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1791 otherwm = False;
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1792 XSetErrorHandler(xerrorstart);
197
c13f374f836c slight fix
arg@10ksloc.org
parents: 191
diff changeset
1793 /* this causes an error if some other window manager is running */
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1794 XSelectInput(dpy, root, SubstructureRedirectMask);
78
0d71fb80b592 changing XFlush into XSync
Anselm R. Garbe <garbeam@wmii.de>
parents: 77
diff changeset
1795 XSync(dpy, False);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1796 if(otherwm)
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1797 eprint("dwm: another window manager is already running\n");
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1798
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1799 XSync(dpy, False);
78
0d71fb80b592 changing XFlush into XSync
Anselm R. Garbe <garbeam@wmii.de>
parents: 77
diff changeset
1800 XSetErrorHandler(NULL);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1801 xerrorxlib = XSetErrorHandler(xerror);
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
1802 XSync(dpy, False);
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1803 setup();
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
1804 drawstatus();
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1805 scan();
3
e969f3575b7a several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents: 2
diff changeset
1806
214
51ac019cf587 small fix of a comment
arg@10ksloc.org
parents: 203
diff changeset
1807 /* main event loop, also reads status text from stdin */
242
cd15de32e173 prepared 0.8
Anselm R.Garbe <arg@10ksloc.org>
parents: 237
diff changeset
1808 XSync(dpy, False);
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1809 procevent();
302
3b11e32e8d7e we close stdin as well
Anselm R.Garbe <arg@10ksloc.org>
parents: 295
diff changeset
1810 readin = True;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 3
diff changeset
1811 while(running) {
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
1812 FD_ZERO(&rd);
164
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 162
diff changeset
1813 if(readin)
21071ae1fe68 made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents: 162
diff changeset
1814 FD_SET(STDIN_FILENO, &rd);
265
573b1c4a71a4 reducing ConnectionNumber calls to a bare minimum
Anselm R.Garbe <arg@10ksloc.org>
parents: 262
diff changeset
1815 FD_SET(xfd, &rd);
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1816 if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1817 if(errno == EINTR)
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1818 continue;
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 580
diff changeset
1819 eprint("select failed\n");
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1820 }
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1821 if(FD_ISSET(STDIN_FILENO, &rd)) {
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 580
diff changeset
1822 switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1823 case -1:
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 580
diff changeset
1824 strncpy(stext, strerror(errno), sizeof stext - 1);
583
f4285a97e3e6 applied Jukka's patch preventing some cornercases and making the EOF error message correct
arg@mig29
parents: 582
diff changeset
1825 stext[sizeof stext - 1] = '\0';
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1826 readin = False;
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1827 break;
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1828 case 0:
583
f4285a97e3e6 applied Jukka's patch preventing some cornercases and making the EOF error message correct
arg@mig29
parents: 582
diff changeset
1829 strncpy(stext, "EOF", 4);
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1830 readin = False;
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1831 break;
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1832 default:
582
70472540c443 applied yet another proposal of Manuel
arg@mig29
parents: 581
diff changeset
1833 for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0');
744
628c5bac7f3b pneubeck pointed out an obvious thing, that a second p = stext + strlen(stext) - 1 is unnecessary
Anselm R. Garbe <arg@suckless.org>
parents: 740
diff changeset
1834 for(; p >= stext && *p != '\n'; --p);
581
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 580
diff changeset
1835 if(p > stext)
601842ee4484 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents: 580
diff changeset
1836 strncpy(stext, p + 1, sizeof stext);
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
1837 }
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1838 drawstatus();
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
1839 }
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1840 if(FD_ISSET(xfd, &rd))
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1841 procevent();
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 3
diff changeset
1842 }
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1843 cleanup();
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1844 XCloseDisplay(dpy);
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1845 return 0;
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1846 }