annotate aewl.c @ 773:d2e56ce18f5b

remove static since its only one source file now; removed empty lines
author meillo@marmaro.de
date Sat, 06 Dec 2008 11:28:48 +0100
parents 0c1e9952a278
children a3399a8964c7
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>
759
45f23169563e renamed dwm to aewl
meillo@marmaro.de
parents: 758
diff changeset
2 * (C)opyright MMVIII markus schnalke <meillo at marmaro dot de>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
3 * 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
4 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
5 * 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
6 * 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
7 * 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
8 * 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
9 * 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
10 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
11 * 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
12 * 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
13 * 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
14 * 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
15 * 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
16 * 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
17 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
18 * 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
19 * 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
20 * doubly-linked client list, the focus history is remembered through a global
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
21 * stack list. [...]
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
22 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
23 * Keys and tagging rules are organized as arrays and defined in the config.h
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
24 * file. [...] The current mode is represented by the arrange() function
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
25 * pointer, which wether points to [domax()] or dotile().
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
26 *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
27 * To understand everything else, start reading main.c:main().
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
28 *
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
29 * -- and now about aewl --
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
30 *
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
31 * aewl is a stripped down dwm. It stated as a patchset, but finally forked off
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
32 * completely. The reason for this was the increasing gap between my wish to
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
33 * stay where dwm was, and dwm direction to go further. Further more did I
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
34 * always use only a small subset of dwm's features, so condencing dwm had been
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
35 * my wish for a long time.
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
36 *
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
37 * In aewl clients are either tagged or not (only one tag). Visible are either
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
38 * all tagged clients or all without the tag.
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
39 */
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
40
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
41
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
42 #include <errno.h>
619
bda4880c462d with this patch everything works fine for me
arg@mig29
parents: 616
diff changeset
43 #include <locale.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
44 #include <stdio.h>
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
45 #include <stdarg.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
46 #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
47 #include <string.h>
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
48 #include <unistd.h>
138
c1185dc7a36e some cleanups/fixes inspired by Jukka Salmi's feedback
arg@10ksloc.org
parents: 137
diff changeset
49 #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
50 #include <sys/types.h>
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
51 #include <sys/wait.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
52 #include <X11/cursorfont.h>
291
8e6e0aa5e2ae removed NUMLOCKMASK, added dynamically calculated numlockmask instead
Anselm R.Garbe <arg@10ksloc.org>
parents: 281
diff changeset
53 #include <X11/keysym.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
54 #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
55 #include <X11/Xlib.h>
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
56 #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
57 #include <X11/Xutil.h>
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
58
769
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
59 #include "config.h"
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
60
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
61
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
62 /* 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
63 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
64
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
65 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
66 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
67 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
764
15660880e23d removed unnessasary color pair
meillo@marmaro.de
parents: 763
diff changeset
68 enum { ColFG, ColBG, ColLast }; /* color */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
69
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
70 typedef struct {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
71 int ascent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
72 int descent;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
73 int height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
74 XFontSet set;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
75 XFontStruct *xfont;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
76 } Fnt;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
77
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
78 typedef struct {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
79 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
80 unsigned long norm[ColLast];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
81 unsigned long sel[ColLast];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
82 Drawable drawable;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
83 Fnt font;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
84 GC gc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
85 } 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
86
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
87 typedef struct Client Client;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
88 struct Client {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
89 char name[256];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
90 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
91 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
92 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
93 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
94 long flags;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
95 unsigned int border;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
96 Bool isfixed, isfloat, ismax;
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
97 Bool tag;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
98 Client *next;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
99 Client *prev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
100 Client *snext;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
101 Window win;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
102 };
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
103
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
104 typedef struct {
767
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
105 const char* class;
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
106 const char* instance;
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
107 const char* title;
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
108 int tag;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
109 Bool isfloat;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
110 } Rule;
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
113 typedef struct {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
114 unsigned long mod;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
115 KeySym keysym;
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
116 void (*func)(const char* cmd);
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
117 const char* cmd;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
118 } Key;
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
121 #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
122 #define MOUSEMASK (BUTTONMASK | PointerMotionMask)
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
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 */
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
127 int bh; /* bar height */
754
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 */
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
131 unsigned int numlockmask; /* dynamic lock mask */
754
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];
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
135 Bool running = True;
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
136 Bool selscreen = True;
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
137 Bool seltag;
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
138 Client* clients = NULL; /* global client list */
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
139 Client* stack = NULL; /* global client stack */
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
140 Client* sel = NULL; /* selected client */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
141 Cursor cursor[CurLast];
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
142 DC dc = {0}; /* global draw context */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
143 Display *dpy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
144 Window root, barwin;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
145
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
146 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
147 static Bool otherwm, readin;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
148 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
149
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
150
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
151
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
162 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
163 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
164 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
165 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
166
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
167 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
168 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
169
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
170 void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
171 int xerror(Display *dsply, XErrorEvent *ee); /* X error handler */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
172
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
173 Client *getnext(Client *c); /* returns next visible client */
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
174 void settag(Client *c, Client *trans); /* sets tag of c */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
175
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
176 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
177 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
178
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
179 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
180 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
181 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
182 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
183 void restack(void); /* restores z layers of all clients */
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
184
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
185 void toggleview(void); /* toggle the view */
760
014c4cb1ae4a removed some compiler warnings
meillo@marmaro.de
parents: 759
diff changeset
186 void focusnext(void); /* focuses next visible client */
014c4cb1ae4a removed some compiler warnings
meillo@marmaro.de
parents: 759
diff changeset
187 void zoom(void); /* zooms the focused client to master area */
014c4cb1ae4a removed some compiler warnings
meillo@marmaro.de
parents: 759
diff changeset
188 void killclient(void); /* kill c nicely */
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
189 void quit(void); /* quit nicely */
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
190 void togglemode(void); /* toggles global arrange function (dotile/domax) */
760
014c4cb1ae4a removed some compiler warnings
meillo@marmaro.de
parents: 759
diff changeset
191 void togglefloat(void); /* toggles focusesd client between floating/non-floating state */
014c4cb1ae4a removed some compiler warnings
meillo@marmaro.de
parents: 759
diff changeset
192 void incnmaster(void); /* increments nmaster */
014c4cb1ae4a removed some compiler warnings
meillo@marmaro.de
parents: 759
diff changeset
193 void decnmaster(void); /* decrements nmaster */
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
194 void toggletag(void); /* toggles tag of c */
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
195 void spawn(const char* cmd); /* forks a new subprocess with cmd */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
196
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
197
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
198
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
199 RULES
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
200 KEYS
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
201
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
202
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
203
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
204
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
205
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
206
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
207
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
208
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
209
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
210 /* from view.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
211
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
212 Client *
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
213 nexttiled(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
214 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
215 return c;
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
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
218 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
219 togglemax(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
220 XEvent ev;
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 if(c->isfixed)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
223 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
224
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
225 if((c->ismax = !c->ismax)) {
769
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
226 c->rx = c->x;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
227 c->ry = c->y;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
228 c->rw = c->w;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
229 c->rh = c->h;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
230 c->x = wax;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
231 c->y = way;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
232 c->w = waw - 2 * BORDERPX;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
233 c->h = wah - 2 * BORDERPX;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
234 } else {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
235 c->x = c->rx;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
236 c->y = c->ry;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
237 c->w = c->rw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
238 c->h = c->rh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
239 }
769
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
240 resize(c, False);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
241 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
242 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
243
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
246
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
247 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
248 detach(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
249 if(c->prev)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
250 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
251 if(c->next)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
252 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
253 if(c == clients)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
254 clients = c->next;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
255 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
256 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
257
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
258 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
259 dotile(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
260 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
261 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
262
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
263 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
264 n++;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
265 /* window geoms */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
266 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
267 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
268 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
269 tw = waw - mw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
270
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
271 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
272 if(isvisible(c)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
273 if(c->isfloat) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
274 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
275 continue;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
276 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
277 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
278 c->x = wax;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
279 c->y = way;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
280 if(i < nmaster) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
281 c->y += i * mh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
282 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
283 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
284 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
285 else { /* tile window */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
286 c->x += mw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
287 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
288 if(th > 2 * BORDERPX) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
289 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
290 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
291 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
292 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
293 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
294 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
295 resize(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
296 i++;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
297 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
298 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
299 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
300 if(!sel || !isvisible(sel)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
301 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
302 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
303 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
304 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
305 }
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 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
308 domax(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
309 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
310
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
311 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
312 if(isvisible(c)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
313 if(c->isfloat) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
314 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
315 continue;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
316 }
768
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
317 c->ismax = True;
769
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
318 c->x = wax;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
319 c->y = way;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
320 c->w = waw - 2 * BORDERPX;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
321 c->h = wah - 2 * BORDERPX;
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
322 resize(c, False);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
323 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
324 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
325 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
326 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
327 if(!sel || !isvisible(sel)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
328 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
329 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
330 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
331 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
332 }
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 void
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
335 focusnext() {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
336 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
337
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
338 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
339 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
340 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
341 c = getnext(clients);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
342 if(c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
343 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
344 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
345 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
346 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
347
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
348 void
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
349 incnmaster() {
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
350 if(wah / (nmaster + 1) <= 2 * BORDERPX)
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
351 return;
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
352 nmaster++;
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
353 if(sel)
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
354 arrange();
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
355 else
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
356 drawstatus();
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
357 }
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
358
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
359 void
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
360 decnmaster() {
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
361 if(nmaster <= 1)
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
362 return;
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
363 nmaster--;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
364 if(sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
365 arrange();
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 drawstatus();
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 Bool
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
371 isvisible(Client *c) {
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
372 return (c->tag == seltag);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
373 }
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 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
376 restack(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
377 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
378 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
379
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
380 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
381 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
382 return;
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
383 if(sel->isfloat)
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
384 XRaiseWindow(dpy, sel->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
385
768
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
386 if(!sel->isfloat)
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
387 XLowerWindow(dpy, sel->win);
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
388 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
389 if(c == sel)
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
390 continue;
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
391 XLowerWindow(dpy, c->win);
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
392 }
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
393
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
394 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
395 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
396 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
397
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
398 void
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
399 togglefloat() {
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
400 if (!sel)
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
401 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
402 sel->isfloat = !sel->isfloat;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
403 arrange();
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
406 void
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
407 togglemode() {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
408 /* 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
409 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
410 if(sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
411 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
412 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
413 drawstatus();
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
416 void
755
cdd895c163bd tag and seltag is now only bool
meillo@marmaro.de
parents: 754
diff changeset
417 toggleview() {
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
418 seltag = !seltag;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
419 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
420 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
421
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
422 void
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
423 zoom() {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
424 unsigned int n;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
425 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
426
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
427 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
428 return;
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
429 if(sel->isfloat) {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
430 togglemax(sel);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
431 return;
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 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
434 n++;
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((c = sel) == nexttiled(clients))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
437 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
438 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
439 detach(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
440 if(clients)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
441 clients->prev = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
442 c->next = clients;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
443 clients = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
444 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
445 arrange();
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 /* from util.c */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
449
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
450 void *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
451 emallocz(unsigned int size) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
452 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
453
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
454 if(!res)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
455 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
456 return res;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
457 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
458
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
459 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
460 eprint(const char *errstr, ...) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
461 va_list ap;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
462
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
463 va_start(ap, errstr);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
464 vfprintf(stderr, errstr, ap);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
465 va_end(ap);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
466 exit(EXIT_FAILURE);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
467 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
468
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
469 void
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
470 spawn(const char* cmd) {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
471 static char *shell = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
472
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
473 if(!cmd)
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
474 return;
769
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
475 if(!(shell = getenv("SHELL")))
49aa8ccceefa cleanups in domax and more
meillo@marmaro.de
parents: 768
diff changeset
476 shell = "/bin/sh";
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
477 /* 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
478 * 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
479 if(fork() == 0) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
480 if(fork() == 0) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
481 if(dpy)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
482 close(ConnectionNumber(dpy));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
483 setsid();
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
484 execl(shell, shell, "-c", cmd, (char *)NULL);
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
485 fprintf(stderr, "aewl: execl '%s -c %s'", shell, cmd);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
486 perror(" failed");
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 exit(0);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
489 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
490 wait(0);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
491 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
492
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
493 /* 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
494
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
495 Client *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
496 getnext(Client *c) {
768
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
497 while(c && !isvisible(c)) {
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
498 c = c->next;
a1c6805aa018 simplified and corrected domax() and restack()
meillo@marmaro.de
parents: 767
diff changeset
499 }
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
500 return c;
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 void
767
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
504 settag(Client *c, Client *trans) {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
505 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
506 XClassHint ch = { 0 };
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
507
767
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
508 if(trans) {
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
509 c->tag = trans->tag;
767
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
510 return;
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
511 }
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
512 c->tag = seltag; /* default */
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
513 XGetClassHint(dpy, c->win, &ch);
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
514 len = sizeof rule / sizeof rule[0];
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
515 for(i = 0; i < len; i++) {
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
516 if((rule[i].title && strstr(c->name, rule[i].title))
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
517 || (ch.res_class && rule[i].class && strstr(ch.res_class, rule[i].class))
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
518 || (ch.res_name && rule[i].instance && strstr(ch.res_name, rule[i].instance))) {
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
519 c->isfloat = rule[i].isfloat;
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
520 if (rule[i].tag < 0) {
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
521 c->tag = seltag;
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
522 } else if (rule[i].tag) {
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
523 c->tag = True;
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
524 } else {
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
525 c->tag = False;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
526 }
767
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
527 break;
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
528 }
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
529 }
767
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
530 if(ch.res_class)
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
531 XFree(ch.res_class);
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
532 if(ch.res_name)
706991d15451 removed rexexp for old strstr matching; simplifications
meillo@marmaro.de
parents: 766
diff changeset
533 XFree(ch.res_name);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
534 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
535
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
536 void
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
537 toggletag() {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
538 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
539 return;
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
540 sel->tag = !sel->tag;
755
cdd895c163bd tag and seltag is now only bool
meillo@marmaro.de
parents: 754
diff changeset
541 toggleview();
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
542 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
543
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
544 /* from event.c */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
545
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
546 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
547 movemouse(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
548 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
549 unsigned int dui;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
550 Window dummy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
551 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
552
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
553 ocx = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
554 ocy = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
555 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
556 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
557 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
558 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
559 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
560 for(;;) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
561 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
562 switch (ev.type) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
563 case ButtonRelease:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
564 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
565 XUngrabPointer(dpy, CurrentTime);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
566 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
567 case ConfigureRequest:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
568 case Expose:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
569 case MapRequest:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
570 handler[ev.type](&ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
571 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
572 case MotionNotify:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
573 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
574 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
575 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
576 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
577 c->x = wax;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
578 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
579 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
580 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
581 c->y = way;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
582 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
583 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
584 resize(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
585 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
586 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
587 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
588 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
589
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
590 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
591 resizemouse(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
592 int ocx, ocy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
593 int nw, nh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
594 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
595
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
596 ocx = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
597 ocy = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
598 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
599 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
600 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
601 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
602 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
603 for(;;) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
604 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
605 switch(ev.type) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
606 case ButtonRelease:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
607 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
608 XUngrabPointer(dpy, CurrentTime);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
609 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
610 case ConfigureRequest:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
611 case Expose:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
612 case MapRequest:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
613 handler[ev.type](&ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
614 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
615 case MotionNotify:
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
616 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
617 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
618 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
619 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
620 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
621 resize(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
622 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
623 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
624 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
625 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
626
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
627 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
628 buttonpress(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
629 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
630 XButtonPressedEvent *ev = &e->xbutton;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
631
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
632 if(barwin == ev->window) {
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
633 return;
763
17428bca4a12 removed group-toggle by mouse; small cleanup
meillo@marmaro.de
parents: 762
diff changeset
634 }
17428bca4a12 removed group-toggle by mouse; small cleanup
meillo@marmaro.de
parents: 762
diff changeset
635 if((c = getclient(ev->window))) {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
636 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
637 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
638 return;
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
639 if(ev->button == Button1 && c->isfloat) {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
640 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
641 movemouse(c);
761
59ce221b9a37 removed global float (dofloat); number of tags is fixed (2)
meillo@marmaro.de
parents: 760
diff changeset
642 } else if(ev->button == Button3 && c->isfloat && !c->isfixed) {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
643 restack();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
644 resizemouse(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
645 }
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 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
648
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
649 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
650 configurerequest(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
651 unsigned long newmask;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
652 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
653 XConfigureRequestEvent *ev = &e->xconfigurerequest;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
654 XWindowChanges wc;
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 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
657 c->ismax = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
658 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
659 c->x = ev->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
660 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
661 c->y = ev->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
662 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
663 c->w = ev->width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
664 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
665 c->h = ev->height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
666 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
667 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
668 wc.x = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
669 wc.y = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
670 wc.width = c->w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
671 wc.height = c->h;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
672 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
673 if(newmask)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
674 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
675 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
676 configure(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
677 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
678 if(c->isfloat) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
679 resize(c, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
680 if(!isvisible(c))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
681 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
682 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
683 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
684 arrange();
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
685 } else {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
686 wc.x = ev->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
687 wc.y = ev->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
688 wc.width = ev->width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
689 wc.height = ev->height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
690 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
691 wc.sibling = ev->above;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
692 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
693 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
694 XSync(dpy, False);
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
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
698 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
699 destroynotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
700 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
701 XDestroyWindowEvent *ev = &e->xdestroywindow;
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 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
704 unmanage(c);
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
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
707 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
708 enternotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
709 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
710 XCrossingEvent *ev = &e->xcrossing;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
711
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
712 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
713 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
714 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
715 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
716 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
717 selscreen = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
718 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
719 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
720 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
721 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
722
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
723 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
724 expose(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
725 XExposeEvent *ev = &e->xexpose;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
726
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
727 if(ev->count == 0) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
728 if(barwin == ev->window)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
729 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
730 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
731 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
732
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
733 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
734 keypress(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
735 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
736 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
737 KeySym keysym;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
738 XKeyEvent *ev = &e->xkey;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
739
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
740 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
741 for(i = 0; i < len; i++) {
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
742 if(keysym == key[i].keysym && CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
743 if(key[i].func)
758
bc512840e5a5 removed union arg (using const char* cmd now)
meillo@marmaro.de
parents: 756
diff changeset
744 key[i].func(key[i].cmd);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
745 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
746 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
747 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
748
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
749 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
750 leavenotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
751 XCrossingEvent *ev = &e->xcrossing;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
752
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
753 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
754 selscreen = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
755 focus(NULL);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
756 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
757 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
758
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
759 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
760 mappingnotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
761 XMappingEvent *ev = &e->xmapping;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
762
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
763 XRefreshKeyboardMapping(ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
764 if(ev->request == MappingKeyboard)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
765 grabkeys();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
766 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
767
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
768 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
769 maprequest(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
770 static XWindowAttributes wa;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
771 XMapRequestEvent *ev = &e->xmaprequest;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
772
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
773 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
774 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
775 if(wa.override_redirect) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
776 XSelectInput(dpy, ev->window,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
777 (StructureNotifyMask | PropertyChangeMask));
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
778 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
779 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
780 if(!getclient(ev->window))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
781 manage(ev->window, &wa);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
782 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
783
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
784 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
785 propertynotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
786 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
787 Window trans;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
788 XPropertyEvent *ev = &e->xproperty;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
789
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
790 if(ev->state == PropertyDelete)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
791 return; /* ignore */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
792 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
793 switch (ev->atom) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
794 default: break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
795 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
796 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
797 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
798 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
799 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
800 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
801 updatesizehints(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
802 break;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
803 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
804 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
805 updatetitle(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
806 if(c == sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
807 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
808 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
809 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
810 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
811
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
812 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
813 unmapnotify(XEvent *e) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
814 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
815 XUnmapEvent *ev = &e->xunmap;
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((c = getclient(ev->window)))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
818 unmanage(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
819 }
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
823 void (*handler[LASTEvent]) (XEvent *) = {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
824 [ButtonPress] = buttonpress,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
825 [ConfigureRequest] = configurerequest,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
826 [DestroyNotify] = destroynotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
827 [EnterNotify] = enternotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
828 [LeaveNotify] = leavenotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
829 [Expose] = expose,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
830 [KeyPress] = keypress,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
831 [MappingNotify] = mappingnotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
832 [MapRequest] = maprequest,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
833 [PropertyNotify] = propertynotify,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
834 [UnmapNotify] = unmapnotify
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
835 };
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 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
838 grabkeys(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
839 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
840 unsigned int i;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
841 KeyCode code;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
842
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
843 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
844 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
845 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
846 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
847 GrabModeAsync, GrabModeAsync);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
848 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
849 GrabModeAsync, GrabModeAsync);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
850 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
851 GrabModeAsync, GrabModeAsync);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
852 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
853 GrabModeAsync, GrabModeAsync);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
854 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
855 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
856
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
857 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
858 procevent(void) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
859 XEvent ev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
860
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
861 while(XPending(dpy)) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
862 XNextEvent(dpy, &ev);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
863 if(handler[ev.type])
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
864 (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
865 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
866 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
867
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
868 /* from draw.c */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
869
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
870 unsigned int
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
871 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
872 XRectangle r;
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 if(dc.font.set) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
875 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
876 return r.width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
877 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
878 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
879 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
880
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
881 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
882 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
883 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
884 static char buf[256];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
885 unsigned int len, olen;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
886 XGCValues gcv;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
887 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
888
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
889 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
890 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
891 if(!text)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
892 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
893 w = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
894 olen = len = strlen(text);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
895 if(len >= sizeof buf)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
896 len = sizeof buf - 1;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
897 memcpy(buf, text, len);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
898 buf[len] = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
899 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
900 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
901 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
902 /* shorten text if necessary */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
903 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
904 buf[--len] = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
905 if(len < olen) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
906 if(len > 1)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
907 buf[len - 1] = '.';
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
908 if(len > 2)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
909 buf[len - 2] = '.';
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
910 if(len > 3)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
911 buf[len - 3] = '.';
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 if(w > dc.w)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
914 return; /* too long */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
915 gcv.foreground = col[ColFG];
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
916 if(dc.font.set) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
917 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
918 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
919 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
920 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
921 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
922 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
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
926 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
927 drawstatus(void) {
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
928 int x;
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
929 unsigned long black[ColLast];
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
930 black[ColBG] = getcolor("#000000");
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
931 black[ColFG] = getcolor("#ffffff");
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
932
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
933 /* views */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
934 dc.x = dc.y = 0;
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
935 dc.w = textw(NAMETAGGED);
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
936 drawtext(NAMETAGGED, ( seltag ? dc.sel : dc.norm ));
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
937
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
938 dc.x += dc.w;
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
939 dc.w = BORDERPX;
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
940 drawtext(NULL, black);
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
941
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
942 dc.x += dc.w;
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
943 dc.w = textw(NAMEUNTAGGED);
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
944 drawtext(NAMEUNTAGGED, ( seltag ? dc.norm : dc.sel ));
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
945
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
946 dc.x += dc.w;
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
947 dc.w = BORDERPX;
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
948 drawtext(NULL, black);
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
949
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
950 /* status text */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
951 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
952 dc.w = textw(stext);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
953 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
954 if(dc.x < x) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
955 dc.x = x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
956 dc.w = sw - x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
957 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
958 drawtext(stext, dc.norm);
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
959
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
960 /* client title */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
961 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
962 dc.x = x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
963 drawtext(sel ? sel->name : NULL, dc.norm);
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
964
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
965 dc.x += dc.w;
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
966 dc.w = BORDERPX;
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
967 drawtext(NULL, black);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
968 }
771
59a6f0ba5478 beautified status bar
meillo@marmaro.de
parents: 770
diff changeset
969
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
970 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
971 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
972 }
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 unsigned long
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
975 getcolor(const char *colstr) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
976 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
977 XColor color;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
978
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
979 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
980 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
981 return color.pixel;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
982 }
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 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
985 setfont(const char *fontstr) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
986 char *def, **missing;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
987 int i, n;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
988
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
989 missing = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
990 if(dc.font.set)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
991 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
992 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
993 if(missing) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
994 while(n--)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
995 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
996 XFreeStringList(missing);
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(dc.font.set) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
999 XFontSetExtents *font_extents;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1000 XFontStruct **xfonts;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1001 char **font_names;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1002 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
1003 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
1004 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
1005 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
1006 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
1007 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
1008 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
1009 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
1010 xfonts++;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1011 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1012 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1013 if(dc.font.xfont)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1014 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
1015 dc.font.xfont = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1016 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
1017 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
1018 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
1019 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
1020 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1021 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
1022 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1023
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1024 unsigned int
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1025 textw(const char *text) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1026 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
1027 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1028
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1029 /* from client.c */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1030
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1031 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1032 detachstack(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1033 Client **tc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1034 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
1035 *tc = c->snext;
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
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1038 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1039 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
1040 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
1041
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1042 if(focused) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1043 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
1044 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1045 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
1046 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1047 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
1048 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1049 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
1050 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1051
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1052 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
1053 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1054 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
1055 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1056 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
1057 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1058 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
1059 GrabModeAsync, GrabModeSync, None, None);
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 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
1062 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1063 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
1064 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1065 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
1066 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1067 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
1068 GrabModeAsync, GrabModeSync, None, None);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1069 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1070 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
1071 GrabModeAsync, GrabModeSync, None, None);
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
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1075 void
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1076 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
1077 long data[] = {state, None};
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1078 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
1079 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
1080 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1081
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1082 int
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1083 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
1084 return 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1085 }
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 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1088 configure(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1089 XEvent synev;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1090
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1091 synev.type = ConfigureNotify;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1092 synev.xconfigure.display = dpy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1093 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
1094 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
1095 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
1096 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
1097 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
1098 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
1099 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
1100 synev.xconfigure.above = None;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1101 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
1102 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1103
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1104 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1105 focus(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1106 if(c && !isvisible(c))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1107 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1108 if(sel && sel != c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1109 grabbuttons(sel, False);
764
15660880e23d removed unnessasary color pair
meillo@marmaro.de
parents: 763
diff changeset
1110 XSetWindowBorder(dpy, sel->win, dc.norm[ColBG]);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1111 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1112 if(c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1113 detachstack(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1114 c->snext = stack;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1115 stack = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1116 grabbuttons(c, True);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1117 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1118 sel = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1119 drawstatus();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1120 if(!selscreen)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1121 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1122 if(c) {
764
15660880e23d removed unnessasary color pair
meillo@marmaro.de
parents: 763
diff changeset
1123 XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1124 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
1125 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1126 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
1127 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1128 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1129
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1130 Client *
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1131 getclient(Window w) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1132 Client *c;
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 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
1135 if(c->win == w) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1136 return c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1137 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1138 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1139 return NULL;
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1142 Bool
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1143 isprotodel(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1144 int i, n;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1145 Atom *protocols;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1146 Bool ret = False;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1147
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1148 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
1149 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
1150 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
1151 ret = True;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1152 XFree(protocols);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1153 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1154 return ret;
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
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1157 void
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
1158 killclient() {
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1159 if(!sel)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1160 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1161 if(isprotodel(sel))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1162 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
1163 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1164 XKillClient(dpy, sel->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1165 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1166
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1167 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1168 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
1169 Client *c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1170 Window trans;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1171
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1172 c = emallocz(sizeof(Client));
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
1173 c->tag = True;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1174 c->win = w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1175 c->x = wa->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1176 c->y = wa->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1177 c->w = wa->width;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1178 c->h = wa->height;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1179 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
1180 c->border = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1181 c->x = sx;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1182 c->y = sy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1183 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1184 c->border = BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1185 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
1186 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
1187 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
1188 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
1189 if(c->x < wax)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1190 c->x = wax;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1191 if(c->y < way)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1192 c->y = way;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1193 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1194 updatesizehints(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1195 XSelectInput(dpy, c->win,
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1196 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1197 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
1198 grabbuttons(c, False);
764
15660880e23d removed unnessasary color pair
meillo@marmaro.de
parents: 763
diff changeset
1199 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1200 updatetitle(c);
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
1201 settag(c, getclient(trans));
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1202 if(!c->isfloat)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1203 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
1204 if(clients)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1205 clients->prev = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1206 c->next = clients;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1207 c->snext = stack;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1208 stack = clients = c;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1209 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
1210 XMapWindow(dpy, c->win);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1211 setclientstate(c, NormalState);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1212 if(isvisible(c))
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1213 focus(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1214 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1215 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1216
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1217 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1218 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
1219 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
1220 XWindowChanges wc;
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 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
1223 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1224 if(sizehints) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1225 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
1226 c->w = c->minw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1227 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
1228 c->h = c->minh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1229 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
1230 c->w = c->maxw;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1231 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
1232 c->h = c->maxh;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1233 /* 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
1234 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
1235 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
1236 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
1237 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
1238 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
1239 actual = dx / dy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1240 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
1241 if(actual < min) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1242 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
1243 dx = dy * min;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1244 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
1245 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
1246 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1247 else if(actual > max) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1248 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
1249 dx = dy * min;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1250 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
1251 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
1252 }
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 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1255 if(c->incw)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1256 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
1257 if(c->inch)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1258 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
1259 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1260 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
1261 c->border = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1262 else
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1263 c->border = BORDERPX;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1264 /* offscreen appearance fixes */
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1265 if(c->x > sw)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1266 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
1267 if(c->y > sh)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1268 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
1269 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
1270 c->x = sx;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1271 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
1272 c->y = sy;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1273 wc.x = c->x;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1274 wc.y = c->y;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1275 wc.width = c->w;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1276 wc.height = c->h;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1277 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
1278 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
1279 configure(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1280 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1281 }
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 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1284 updatesizehints(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1285 long msize;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1286 XSizeHints size;
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 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
1289 size.flags = PSize;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1290 c->flags = size.flags;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1291 if(c->flags & PBaseSize) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1292 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
1293 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
1294 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1295 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
1296 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1297 if(c->flags & PResizeInc) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1298 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
1299 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
1300 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1301 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
1302 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1303 if(c->flags & PMaxSize) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1304 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
1305 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
1306 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1307 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
1308 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1309 if(c->flags & PMinSize) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1310 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
1311 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
1312 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1313 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
1314 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1315 if(c->flags & PAspect) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1316 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
1317 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
1318 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
1319 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
1320 } else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1321 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
1322 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1323 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
1324 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
1325 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1326
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1327 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1328 updatetitle(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1329 char **list = NULL;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1330 int n;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1331 XTextProperty name;
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 name.nitems = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1334 c->name[0] = 0;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1335 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
1336 if(!name.nitems)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1337 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
1338 if(!name.nitems)
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1339 return;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1340 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
1341 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
1342 else {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1343 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
1344 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
1345 XFreeStringList(list);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1346 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1347 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1348 XFree(name.value);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1349 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1350
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1351 void
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1352 unmanage(Client *c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1353 Client *nc;
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1354
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1355 /* 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
1356 XGrabServer(dpy);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1357 XSetErrorHandler(xerrordummy);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1358 detach(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1359 detachstack(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1360 if(sel == c) {
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1361 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
1362 focus(nc);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1363 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1364 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
1365 setclientstate(c, WithdrawnState);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1366 free(c);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1367 XSync(dpy, False);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1368 XSetErrorHandler(xerror);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1369 XUngrabServer(dpy);
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1370 arrange();
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1371 }
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1372
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1373 /* from main.c */
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1374
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1375 void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 473
diff changeset
1376 cleanup(void) {
302
3b11e32e8d7e we close stdin as well
Anselm R.Garbe <arg@10ksloc.org>
parents: 295
diff changeset
1377 close(STDIN_FILENO);
645
8e6d75c68b69 changed arg's color scheme
arg@mig29
parents: 644
diff changeset
1378 while(stack) {
708
a2d568a5cdb8 applied Sanders all5.patch (thanks for your weekend session, Sander!)
Anselm R. Garbe <arg@suckless.org>
parents: 697
diff changeset
1379 resize(stack, True);
645
8e6d75c68b69 changed arg's color scheme
arg@mig29
parents: 644
diff changeset
1380 unmanage(stack);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1381 }
295
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1382 if(dc.font.set)
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1383 XFreeFontSet(dpy, dc.font.set);
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1384 else
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1385 XFreeFont(dpy, dc.font.xfont);
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1386 XUngrabKey(dpy, AnyKey, AnyModifier, root);
295
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1387 XFreePixmap(dpy, dc.drawable);
7565875d07d3 extended cleanup
Anselm R.Garbe <arg@10ksloc.org>
parents: 293
diff changeset
1388 XFreeGC(dpy, dc.gc);
309
204427dcc087 corrected order of cleanup code
Anselm R.Garbe <arg@10ksloc.org>
parents: 302
diff changeset
1389 XDestroyWindow(dpy, barwin);
616
f617c75a8405 improved the memory leak prevention
arg@mig29
parents: 583
diff changeset
1390 XFreeCursor(dpy, cursor[CurNormal]);
f617c75a8405 improved the memory leak prevention
arg@mig29
parents: 583
diff changeset
1391 XFreeCursor(dpy, cursor[CurResize]);
f617c75a8405 improved the memory leak prevention
arg@mig29
parents: 583
diff changeset
1392 XFreeCursor(dpy, cursor[CurMove]);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1393 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1394 XSync(dpy, False);
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1395 }
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1396
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1397 void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 473
diff changeset
1398 scan(void) {
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1399 unsigned int i, num;
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1400 Window *wins, d1, d2;
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1401 XWindowAttributes wa;
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1402
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1403 wins = NULL;
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1404 if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1405 for(i = 0; i < num; i++) {
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1406 if(!XGetWindowAttributes(dpy, wins[i], &wa))
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1407 continue;
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1408 if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1409 continue;
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1410 if(wa.map_state == IsViewable)
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
1411 manage(wins[i], &wa);
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1412 }
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1413 }
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1414 if(wins)
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1415 XFree(wins);
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1416 }
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1417
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1418 void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 473
diff changeset
1419 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
1420 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
1421 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
1422 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
1423 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
1424 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
1425
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1426 /* 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
1427 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
1428 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
1429 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
1430 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
1431 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
1432 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
1433 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
1434 /* 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
1435 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
1436 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
1437 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1438 /* init modifier map */
679
5f0134b88b8d small fix of initial numlockmask value
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
1439 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
1440 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
1441 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
1442 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
1443 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
1444 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
1445 }
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1446 }
616
f617c75a8405 improved the memory leak prevention
arg@mig29
parents: 583
diff changeset
1447 XFreeModifiermap(modmap);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1448 /* 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
1449 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
1450 | 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
1451 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
1452 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
1453 grabkeys();
766
3f7c68a720b5 undone naming change: "group" is "tag" again (but without plural)
meillo@marmaro.de
parents: 764
diff changeset
1454 seltag = 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
1455 /* style */
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1456 dc.norm[ColBG] = getcolor(NORMBGCOLOR);
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1457 dc.norm[ColFG] = getcolor(NORMFGCOLOR);
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1458 dc.sel[ColBG] = getcolor(SELBGCOLOR);
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1459 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
1460 setfont(FONT);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1461 /* 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
1462 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
1463 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
1464 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
1465 nmaster = NMASTER;
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1466 arrange = DEFMODE;
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1467 /* bar */
353
8a06efe5b563 new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents: 352
diff changeset
1468 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
1469 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
1470 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
1471 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
1472 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
1473 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
1474 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
1475 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
1476 XMapRaised(dpy, barwin);
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
1477 strcpy(stext, "aewl-"VERSION);
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 532
diff changeset
1478 /* windowarea */
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 532
diff changeset
1479 wax = sx;
754
4c12dccc288d this is the (second) begin of aewl - my personal stipped down dwm
meillo@marmaro.de
parents: 744
diff changeset
1480 way = sy + bh;
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 532
diff changeset
1481 wah = sh - bh;
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 532
diff changeset
1482 waw = sw;
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1483 /* 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
1484 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
1485 dc.gc = XCreateGC(dpy, root, 0, 0);
344
93192711a36a changing tag indicator through underline
Anselm R. Garbe <arg@10kloc.org>
parents: 339
diff changeset
1486 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
1487 /* multihead support */
716
4ce65f61f01b renamed activescreen into selscreen
Anselm R. Garbe <arg@suckless.org>
parents: 714
diff changeset
1488 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
1489 }
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 329
diff changeset
1490
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1491 /*
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1492 * 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
1493 * is already running.
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1494 */
773
d2e56ce18f5b remove static since its only one source file now; removed empty lines
meillo@marmaro.de
parents: 772
diff changeset
1495 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
1496 xerrorstart(Display *dsply, XErrorEvent *ee) {
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1497 otherwm = True;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1498 return -1;
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1499 }
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1500
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1501 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
1502 sendevent(Window w, Atom a, long value) {
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1503 XEvent e;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1504
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1505 e.type = ClientMessage;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1506 e.xclient.window = w;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1507 e.xclient.message_type = a;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1508 e.xclient.format = 32;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1509 e.xclient.data.l[0] = value;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1510 e.xclient.data.l[1] = CurrentTime;
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1511 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
1512 XSync(dpy, False);
13
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1513 }
5cc5e55a132d added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 10
diff changeset
1514
76
4bd49f404f10 proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents: 75
diff changeset
1515 void
756
bff1012527b3 removed unnecessary Arg* parametersadded decnmaster
meillo@marmaro.de
parents: 755
diff changeset
1516 quit() {
302
3b11e32e8d7e we close stdin as well
Anselm R.Garbe <arg@10ksloc.org>
parents: 295
diff changeset
1517 readin = running = False;
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1518 }
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1519
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
1520 /* 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
1521 * 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
1522 * default error handler, which may call exit.
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1523 */
10
703255003abb changed how manage client works
Anselm R. Garbe <garbeam@wmii.de>
parents: 9
diff changeset
1524 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
1525 xerror(Display *dpy, XErrorEvent *ee) {
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1526 if(ee->error_code == BadWindow
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1527 || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1528 || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1529 || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1530 || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1531 || (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
1532 || (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
1533 || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1534 return 0;
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
1535 fprintf(stderr, "aewl: fatal error: request code=%d, error code=%d\n",
123
61490330e90a cleaned up code
arg@10ksloc.org
parents: 99
diff changeset
1536 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
1537 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
1538 }
f96fb3fd8203 added grid mode on Mod1Mask g
Anselm R. Garbe <garbeam@wmii.de>
parents: 26
diff changeset
1539
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1540 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
1541 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
1542 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
1543 int r, xfd;
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
1544 fd_set rd;
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1545
137
77922a389fa8 simplified main.c, switching back to single urxvt usage
arg@10ksloc.org
parents: 126
diff changeset
1546 if(argc == 2 && !strncmp("-v", argv[1], 3)) {
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
1547 fputs("aewl-"VERSION", Copyright 2008 markus schnalke <meillo@marmaro.de>\n", stdout);
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
1548 fputs("forked off dwm-3.4, (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
1549 exit(EXIT_SUCCESS);
755
cdd895c163bd tag and seltag is now only bool
meillo@marmaro.de
parents: 754
diff changeset
1550 } else if(argc != 1) {
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
1551 eprint("usage: aewl [-v]\n");
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1552 }
619
bda4880c462d with this patch everything works fine for me
arg@mig29
parents: 616
diff changeset
1553 setlocale(LC_CTYPE, "");
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1554 dpy = XOpenDisplay(0);
755
cdd895c163bd tag and seltag is now only bool
meillo@marmaro.de
parents: 754
diff changeset
1555 if(!dpy) {
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
1556 eprint("aewl: cannot open display\n");
755
cdd895c163bd tag and seltag is now only bool
meillo@marmaro.de
parents: 754
diff changeset
1557 }
265
573b1c4a71a4 reducing ConnectionNumber calls to a bare minimum
Anselm R.Garbe <arg@10ksloc.org>
parents: 262
diff changeset
1558 xfd = ConnectionNumber(dpy);
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1559 screen = DefaultScreen(dpy);
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1560 root = RootWindow(dpy, screen);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1561 otherwm = False;
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1562 XSetErrorHandler(xerrorstart);
197
c13f374f836c slight fix
arg@10ksloc.org
parents: 191
diff changeset
1563 /* this causes an error if some other window manager is running */
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1564 XSelectInput(dpy, root, SubstructureRedirectMask);
78
0d71fb80b592 changing XFlush into XSync
Anselm R. Garbe <garbeam@wmii.de>
parents: 77
diff changeset
1565 XSync(dpy, False);
755
cdd895c163bd tag and seltag is now only bool
meillo@marmaro.de
parents: 754
diff changeset
1566 if(otherwm) {
772
0c1e9952a278 naming change from dwm to aewl; cleanups
meillo@marmaro.de
parents: 771
diff changeset
1567 eprint("aewl: another window manager is already running\n");
755
cdd895c163bd tag and seltag is now only bool
meillo@marmaro.de
parents: 754
diff changeset
1568 }
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1569
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1570 XSync(dpy, False);
78
0d71fb80b592 changing XFlush into XSync
Anselm R. Garbe <garbeam@wmii.de>
parents: 77
diff changeset
1571 XSetErrorHandler(NULL);
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1572 xerrorxlib = XSetErrorHandler(xerror);
275
425cd4490c1e some other small fixes
Anselm R.Garbe <arg@10ksloc.org>
parents: 274
diff changeset
1573 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
1574 setup();
74
5370ef170cc9 sanitized names
Anselm R. Garbe <garbeam@wmii.de>
parents: 73
diff changeset
1575 drawstatus();
75
f08271b7cb20 rearranged several stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 74
diff changeset
1576 scan();
3
e969f3575b7a several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents: 2
diff changeset
1577
214
51ac019cf587 small fix of a comment
arg@10ksloc.org
parents: 203
diff changeset
1578 /* main event loop, also reads status text from stdin */
242
cd15de32e173 prepared 0.8
Anselm R.Garbe <arg@10ksloc.org>
parents: 237
diff changeset
1579 XSync(dpy, False);
292
4aa632b6ba66 changed main event loop
Anselm R.Garbe <arg@10ksloc.org>
parents: 291
diff changeset
1580 procevent();
302
3b11e32e8d7e we close stdin as well
Anselm R.Garbe <arg@10ksloc.org>
parents: 295
diff changeset
1581 readin = True;
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 3
diff changeset
1582 while(running) {
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
1583 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
1584 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
1585 FD_SET(STDIN_FILENO, &rd);
265
573b1c4a71a4 reducing ConnectionNumber calls to a bare minimum
Anselm R.Garbe <arg@10ksloc.org>
parents: 262
diff changeset
1586 FD_SET(xfd, &rd);
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1587 if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1588 if(errno == EINTR)
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1589 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
1590 eprint("select failed\n");
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1591 }
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1592 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
1593 switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1594 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
1595 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
1596 stext[sizeof stext - 1] = '\0';
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1597 readin = False;
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1598 break;
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1599 case 0:
583
f4285a97e3e6 applied Jukka's patch preventing some cornercases and making the EOF error message correct
arg@mig29
parents: 582
diff changeset
1600 strncpy(stext, "EOF", 4);
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1601 readin = False;
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1602 break;
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1603 default:
582
70472540c443 applied yet another proposal of Manuel
arg@mig29
parents: 581
diff changeset
1604 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
1605 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
1606 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
1607 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
1608 }
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1609 drawstatus();
59
5d4653de9a1c implemented dwm reading status text from stdin
Anselm R. Garbe <garbeam@wmii.de>
parents: 58
diff changeset
1610 }
578
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1611 if(FD_ISSET(xfd, &rd))
8cb54d02a5b6 applied Manuels patch (thanks to Manuel!)
arg@mig29
parents: 570
diff changeset
1612 procevent();
5
e5018cae273f added several other stuff
Anselm R. Garbe <garbeam@wmii.de>
parents: 3
diff changeset
1613 }
0
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1614 cleanup();
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1615 XCloseDisplay(dpy);
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1616 return 0;
491f34c11291 initial import
Anselm R. Garbe <garbeam@wmii.de>
parents:
diff changeset
1617 }