1 /* Copyright (c) 1994-1996 David Hogan, see README for licence details */
2 /* Many changes by Lars Bernhardsson. */
3 /* Less changes by Florian Forster <octopus@verplant.org> */
4 
5 #define VERSION		"larswm 7.5.3 [15-JUL-2004] by Lars Bernhardsson <lab@fnurt.net>"
6 
7 #define BORDER		2
8 #define TILE_PAD	2
9 
10 #define L_OFF_R 32768
11 #define L_OFF_G 32768
12 #define L_OFF_B 32768
13 
14 #define L_ON_R 65535
15 #define L_ON_G 0
16 #define L_ON_B 0
17 
18 #define L_DELTA 16384
19 
20 #define L_TOP(x) (unsigned short) (((x) + L_DELTA) > 65535 ? 65535 : (x) + L_DELTA)
21 #define L_BOT(x) (unsigned short) (((x) - L_DELTA) < 0 ? 0 : (x) - L_DELTA)
22 
23 #define BAR_HEIGHT	(2 + font->ascent + font->descent)
24 #define BAR_TEXT_Y	(1 + font->ascent)
25 
26 #define BAR_X(s)	0
27 #define BAR_Y(s)	(DisplayHeight (dpy, (s)->num) - BAR_HEIGHT)
28 #define BAR_WIDTH(s)	(DisplayWidth (dpy, (s)->num))
29 
30 #define DEFSHELL	"/bin/sh"
31 
32 #define DEFRC		"/etc/X11/larswmrc"
33 
34 #define MAXSCREENS	4
35 #define MAXDESKTOPS	16
36 
37 #define MAXFLOATCLASS	64
38 #define MAXTOOLCLASS	64
39 #define MAXSTICKYCLASS	64
40 #define MAXNOTILECLASS	64
41 #define MAXDTCLASS	64
42 
43 #define MAXHIDDEN	64
44 
45 #define MAXAPPS		64
46 #define MAXBTNAPPS	3
47 
48 /* for zooming */
49 #define DIM_VERT	1
50 #define DIM_HORIZ	2
51 #define DIM_OUTSIDE     4
52 
53 /* to keep track of if a window is zoomed max */
54 /* height/width/both or select zoomed */
55 #define ZOOM_UNZOOMED 0
56 #define ZOOM_NORMAL 1
57 #define ZOOM_SELECT 2
58 
59 typedef struct Client Client;
60 typedef struct ScreenInfo ScreenInfo;
61 typedef struct Prefs Prefs;
62 
63 struct Client
64 {
65   Window window;
66   Window parent;
67   Window trans;
68   Client *next;
69 
70   int x;
71   int y;
72   int dx;
73   int dy;
74   int border;
75 
76   int zx;
77   int zy;
78   int zdx;
79   int zdy;
80   int iszoom;
81   int isleft;
82   int isaside;
83   int ax;
84   int ay;
85 
86   XSizeHints size;
87   int min_dx;
88   int min_dy;
89 
90   int state;
91   int hidden;
92   int init;
93   int reparenting;
94   int proto;
95   int desktop;
96   int isfloat;
97   int istool;
98   int issticky;
99   int isshaped;
100   int isnotile;
101 
102   char *label;
103   char *instance;
104   char *class;
105   char *name;
106   char *iconname;
107 
108   Colormap cmap;
109   int ncmapwins;
110   Window *cmapwins;
111   Colormap *wmcmaps;
112   ScreenInfo *screen;
113 };
114 
115 #define hidden(c)	((c)->state == IconicState)
116 #define withdrawn(c)	((c)->state == WithdrawnState)
117 #define normal(c)	((c)->state == NormalState)
118 
119 /* c->proto */
120 #define Pdelete 	1
121 #define Ptakefocus	2
122 
123 struct ScreenInfo
124 {
125   int num;
126   Window root;
127   Window barwin;
128   Colormap def_cmap;
129   GC gc;
130 #ifdef THREE_D
131   GC topwhitegc;
132   GC botwhitegc;
133   GC topblackgc;
134   GC botblackgc;
135 #endif
136   unsigned long black;
137   unsigned long white;
138 #ifdef THREE_D
139   unsigned long topwhite;
140   unsigned long botwhite;
141   unsigned long topblack;
142   unsigned long botblack;
143 #endif
144   int min_cmaps;
145   Cursor place;
146   Cursor sweep;
147   char display[256];
148 
149   int desktop;
150   int tile_height;
151   int res_height;
152 
153   int bigmr[MAXDESKTOPS];
154   int clickthru[MAXDESKTOPS];
155   int tile_resize[MAXDESKTOPS];
156   int skip_focus[MAXDESKTOPS];
157   int left_track_width[MAXDESKTOPS];
158   int notile_raised[MAXDESKTOPS];
159   Client *focused[MAXDESKTOPS];
160   Client *notilefocused[MAXDESKTOPS];
161 };
162 
163 struct Prefs
164 {
165   int clickthru[MAXSCREENS][MAXDESKTOPS];
166   int tile_resize[MAXSCREENS][MAXDESKTOPS];
167   int skip_focus[MAXSCREENS][MAXDESKTOPS];
168   int left_track_width[MAXSCREENS][MAXDESKTOPS];
169 
170   int desktops;
171   char *dtname[MAXSCREENS][MAXDESKTOPS];
172 
173   char *bgstr;
174   char *fgstr;
175   char *fname;
176 
177   char *application[MAXAPPS];
178   char *btnapplication[MAXBTNAPPS];
179 
180   char *floatclass[MAXFLOATCLASS];
181   char *toolclass[MAXTOOLCLASS];
182   char *notileclass[MAXNOTILECLASS];
183   char *stickyclass[MAXSTICKYCLASS];
184   char *dtclass[MAXDTCLASS];
185   int dtnum[MAXDTCLASS];
186 
187   /* keycodes for shortcuts */
188   KeySym prev_screen_key;
189   unsigned long prev_screen_mod;
190 
191   KeySym next_screen_key;
192   unsigned long next_screen_mod;
193 
194   KeySym prev_desktop_key;
195   unsigned long prev_desktop_mod;
196 
197   KeySym next_desktop_key;
198   unsigned long next_desktop_mod;
199 
200   KeySym prev_desktop_drag_key;
201   unsigned long prev_desktop_drag_mod;
202 
203   KeySym next_desktop_drag_key;
204   unsigned long next_desktop_drag_mod;
205 
206   KeySym prev_window_key;
207   unsigned long prev_window_mod;
208 
209   KeySym next_window_key;
210   unsigned long next_window_mod;
211 
212   KeySym raise_notile_key;
213   unsigned long raise_notile_mod;
214 
215   KeySym move_northwest_key;
216   unsigned long move_northwest_mod;
217 
218   KeySym move_north_key;
219   unsigned long move_north_mod;
220 
221   KeySym move_northeast_key;
222   unsigned long move_northeast_mod;
223 
224   KeySym move_west_key;
225   unsigned long move_west_mod;
226 
227   KeySym move_center_key;
228   unsigned long move_center_mod;
229 
230   KeySym move_east_key;
231   unsigned long move_east_mod;
232 
233   KeySym move_southwest_key;
234   unsigned long move_southwest_mod;
235 
236   KeySym move_south_key;
237   unsigned long move_south_mod;
238 
239   KeySym move_southeast_key;
240   unsigned long move_southeast_mod;
241 
242   KeySym move_select_key;
243   unsigned long move_select_mod;
244 
245   KeySym move_aside_key;
246   unsigned long move_aside_mod;
247 
248   KeySym move_aside_other_key;
249   unsigned long move_aside_other_mod;
250 
251   KeySym move_sd_key;
252   unsigned long move_sd_mod;
253 
254   KeySym toggle_inc_key;
255   unsigned long toggle_inc_mod;
256 
257   KeySym move_up_key;
258   unsigned long move_up_mod;
259 
260   KeySym move_down_key;
261   unsigned long move_down_mod;
262 
263   KeySym move_left_key;
264   unsigned long move_left_mod;
265 
266   KeySym move_right_key;
267   unsigned long move_right_mod;
268 
269   KeySym grow_vert_key;
270   unsigned long grow_vert_mod;
271 
272   KeySym shrink_vert_key;
273   unsigned long shrink_vert_mod;
274 
275   KeySym grow_horiz_key;
276   unsigned long grow_horiz_mod;
277 
278   KeySym shrink_horiz_key;
279   unsigned long shrink_horiz_mod;
280 
281   KeySym grow_both_key;
282   unsigned long grow_both_mod;
283 
284   KeySym shrink_both_key;
285   unsigned long shrink_both_mod;
286 
287   KeySym zoom_vert_key;
288   unsigned long zoom_vert_mod;
289 
290   KeySym zoom_horiz_key;
291   unsigned long zoom_horiz_mod;
292 
293   KeySym zoom_full_key;
294   unsigned long zoom_full_mod;
295 
296   KeySym zoom_full2_key;
297   unsigned long zoom_full2_mod;
298 
299   KeySym hide_key;
300   unsigned long hide_mod;
301 
302   KeySym unhide_key;
303   unsigned long unhide_mod;
304 
305   KeySym close_key;
306   unsigned long close_mod;
307 
308   KeySym goto_desktop_key[MAXDESKTOPS];
309   unsigned long goto_desktop_mod[MAXDESKTOPS];
310 
311   KeySym application_key[MAXAPPS];
312   unsigned long application_mod[MAXAPPS];
313 };
314 
315 /* main.c */
316 extern Display *dpy;
317 extern ScreenInfo *screens;
318 extern int num_screens;
319 extern int initting;
320 extern XFontStruct *font;
321 extern char **myargv;
322 extern Bool shape;
323 extern char *shell;
324 
325 extern Atom exit_larswm;
326 extern Atom restart_larswm;
327 extern Atom bartext_larswm;
328 
329 extern Atom wm_state;
330 extern Atom wm_change_state;
331 extern Atom wm_protocols;
332 extern Atom wm_delete;
333 extern Atom wm_colormaps;
334 
335 /* client.c */
336 extern Client *clients;
337 extern Client *current;
338 extern Client *prev_current;
339 
340 /* buttons.c */
341 extern Client *hiddenc[];
342 extern int numhidden;
343 
344 /* error.c */
345 extern int ignore_badwindow;
346 
347 /* prefs.c */
348 extern Prefs prefs;
349 
350 /* bar.c */
351 extern int bar_hidden;
352