wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

dat.h (5654B)


      1 /* Copyright ©2007-2010 Kris Maglione <jg@suckless.org>
      2  * See LICENSE file for license details.
      3  */
      4 
      5 #define _XOPEN_SOURCE 600
      6 #define IXP_NO_P9_
      7 #include <assert.h>
      8 #include <regexp9.h>
      9 #include <stdbool.h>
     10 #include <stdint.h>
     11 #include <stdlib.h>
     12 #include <string.h>
     13 #include <unistd.h>
     14 #include <limits.h>
     15 #include <utf.h>
     16 #include <ixp.h>
     17 #include <stuff/x.h>
     18 #include <stuff/util.h>
     19 #include "debug.h"
     20 
     21 #define FONT		"fixed"
     22 #define FOCUSCOLORS	"#000000 #81654f #000000"
     23 #define NORMCOLORS	"#000000 #c1c48b #81654f"
     24 
     25 /* From CGO */
     26 #define assert_equal(x, y) typedef char _##x##_does_not_equal_##y[((x)-(y))*((x)-(y))*-2+1]
     27 
     28 enum Barpos {
     29 	BBottom,
     30 	BTop,
     31 };
     32 
     33 enum {
     34 	Coldefault, Colstack, Colmax, Collast
     35 };
     36 
     37 enum {
     38 	CurNormal,
     39 	CurNECorner, CurNWCorner, CurSECorner, CurSWCorner,
     40 	CurDHArrow, CurDVArrow, CurMove, CurInput, CurSizing,
     41 	CurTCross, CurIcon,
     42 	CurNone,
     43 	CurLast,
     44 };
     45 Cursor	cursor[CurLast];
     46 
     47 enum IncMode {
     48 	IIgnore,
     49 	IShow,
     50 	ISqueeze,
     51 };
     52 
     53 enum {
     54 	PDesktop,
     55 	PExtents,
     56 	PMonitors = PExtents + 4,
     57 	PState = PMonitors + 4,
     58 	PLast = PState + 3
     59 };
     60 
     61 enum ClientPermission {
     62 	PermActivate	= 1<<0,
     63 };
     64 
     65 enum {
     66 	PingTime = 10000,
     67 	PingPeriod = 4000,
     68 	PingPartition = 10,
     69 };
     70 
     71 enum Protocols {
     72 	ProtoDelete	= 1<<0,
     73 	ProtoTakeFocus	= 1<<1,
     74 	ProtoPing	= 1<<2,
     75 };
     76 
     77 enum {
     78 	SourceUnknown,
     79 	SourceClient,
     80 	SourcePager
     81 };
     82 
     83 enum EWMHType {
     84 	TypeDesktop	= 1<<0,
     85 	TypeDock	= 1<<1,
     86 	TypeToolbar	= 1<<2,
     87 	TypeMenu	= 1<<3,
     88 	TypeUtility	= 1<<4,
     89 	TypeSplash	= 1<<5,
     90 	TypeDialog	= 1<<6,
     91 	TypeNormal	= 1<<7,
     92 };
     93 
     94 enum {
     95 	UrgManager,
     96 	UrgClient,
     97 };
     98 
     99 extern char*	modes[];
    100 
    101 #define toggle(val, x)	\
    102 	((val) = ((x) == On     ? true   : \
    103 		  (x) == Off    ? false  : \
    104 		  (x) == Toggle ? !(val) : (val)))
    105 #define TOGGLE(x) \
    106 	((x) == On     ? "on"     : \
    107 	 (x) == Off    ? "off"    : \
    108 	 (x) == Toggle ? "toggle" : "<toggle>")
    109 enum {
    110 	Never = -1,
    111 	Off,
    112 	On,
    113 	/* Xlib defines this. :( */
    114 	// Always,
    115 	Toggle,
    116 };
    117 
    118 assert_equal(Always, 2);
    119 
    120 enum {
    121 	NCOL = 16,
    122 };
    123 
    124 /* Data Structures */
    125 typedef struct Area Area;
    126 typedef struct Bar Bar;
    127 typedef struct Client Client;
    128 typedef struct Divide Divide;
    129 typedef struct Frame Frame;
    130 typedef struct Group Group;
    131 typedef struct Key Key;
    132 typedef struct Rule Rule;
    133 typedef struct Ruleset Ruleset;
    134 typedef struct Ruleval Ruleval;
    135 typedef struct Strut Strut;
    136 typedef struct View View;
    137 typedef struct WMScreen WMScreen;
    138 
    139 struct Area {
    140 	Area*	next;
    141 	Area*	prev;
    142 	Frame*	frame;
    143 	Frame*	frame_old;
    144 	Frame*	stack;
    145 	Frame*	sel;
    146 	View*	view;
    147 	bool	floating;
    148 	ushort	id;
    149 	int	mode;
    150 	int	screen;
    151 	bool	max;
    152 	Rectangle	r;
    153 	Rectangle	r_old;
    154 };
    155 
    156 struct Bar {
    157 	Bar*	next;
    158 	Bar*	smaller;
    159 	char	buf[280];
    160 	char	text[256];
    161 	char	name[256];
    162 	int	bar;
    163 	ushort	id;
    164 	CTuple	colors;
    165 	Rectangle	r;
    166 	WMScreen*	screen;
    167 };
    168 
    169 struct Client {
    170 	Client*	next;
    171 	Frame*	frame;
    172 	Frame*	sel;
    173 	Window	w;
    174 	Window*	framewin;
    175 	XWindow	trans;
    176 	Regex	tagre;
    177 	Regex	tagvre;
    178 	Group*	group;
    179 	Strut*	strut;
    180 	Cursor	cursor;
    181 	Rectangle configr;
    182 	Rectangle r;
    183 	char**	retags;
    184 	char	class[256];
    185 	char	name[256];
    186 	char	props[512];
    187 	char	tags[256];
    188 	char	proplen[PLast];
    189 	long	propcache[PLast];
    190 	long	permission;
    191 	long	proto;
    192 	int	border;
    193 	int	dead;
    194 	int	floating;
    195 	int	fullscreen;
    196 	int	pid;
    197 	bool	borderless;
    198 	bool	fixedsize;
    199 	bool	nofocus;
    200 	bool	noinput;
    201 	bool	rgba;
    202 	bool	titleless;
    203 	bool	urgent;
    204 };
    205 
    206 struct Divide {
    207 	Divide*	next;
    208 	Window*	w;
    209 	Area*	left;
    210 	Area*	right;
    211 	bool	mapped;
    212 	int	x;
    213 };
    214 
    215 struct Frame {
    216 	Frame*	cnext;
    217 	Frame*	anext;
    218 	Frame*	aprev;
    219 	Frame*	anext_old;
    220 	Frame*	snext;
    221 	Frame*	sprev;
    222 	Client*	client;
    223 	View*	view;
    224 	Area*	area;
    225 	int	oldscreen;
    226 	int	oldarea;
    227 	int	screen;
    228 	int	column;
    229 	ushort	id;
    230 	bool	collapsed;
    231 	int	dy;
    232 	Rectangle	r;
    233 	Rectangle	colr;
    234 	Rectangle	colr_old;
    235 	Rectangle	floatr;
    236 	Rectangle	crect;
    237 	Rectangle	grabbox;
    238 	Rectangle	titlebar;
    239 };
    240 
    241 struct Group {
    242 	Group*	next;
    243 	XWindow	leader;
    244 	Client*	client;
    245 	int	ref;
    246 };
    247 
    248 struct Key {
    249 	Key*	next;
    250 	Key*	lnext;
    251 	Key*	tnext;
    252 	ushort	id;
    253 	char	name[128];
    254 	ulong	mod;
    255 	KeyCode	key;
    256 };
    257 
    258 struct Rule {
    259 	Rule*		next;
    260 	Reprog*		regex;
    261 	char*		value;
    262 	Ruleval*	values;
    263 };
    264 
    265 struct Ruleset {
    266 	Rule*	rule;
    267 	char*	string;
    268 	uint	size;
    269 };
    270 
    271 struct Ruleval {
    272 	Ruleval*	next;
    273 	char*		key;
    274 	char*		value;
    275 };
    276 
    277 struct Strut {
    278 	Rectangle	left;
    279 	Rectangle	right;
    280 	Rectangle	top;
    281 	Rectangle	bottom;
    282 };
    283 
    284 #define firstarea areas[screen->idx]
    285 #define screenr r[screen->idx]
    286 struct View {
    287 	View*	next;
    288 	char	name[256];
    289 	ushort	id;
    290 	Area*	floating;
    291 	Area**	areas;
    292 	Area*	sel;
    293 	Area*	oldsel;
    294 	Area*	revert;
    295 	int	selcol;
    296 	int	selscreen;
    297 	bool	dead;
    298 	bool	urgent;
    299 	Rectangle *r;
    300 	Rectangle *pad;
    301 };
    302 
    303 #ifndef EXTERN
    304 #  define EXTERN extern
    305 #endif
    306 
    307 /* global variables */
    308 typedef struct Defs Defs;
    309 EXTERN struct Defs {
    310 	CTuple	focuscolor;
    311 	CTuple	normcolor;
    312 	Font*	font;
    313 	char*	keys;
    314 	uint	keyssz;
    315 	Ruleset	colrules;
    316 	Ruleset	rules;
    317 	long	mod;
    318 	uint	border;
    319 	uint	snap;
    320 	int	colmode;
    321 	int	incmode;
    322 } def;
    323 
    324 enum {
    325 	BLeft, BRight
    326 };
    327 
    328 EXTERN struct WMScreen {
    329 	Bar*	bar[2];
    330 	Window*	barwin;
    331 	bool	barwin_rgba;
    332 	bool	showing;
    333 	int	barpos;
    334 	int	idx;
    335 
    336 	Rectangle r;
    337 	Rectangle brect;
    338 } **screens, *screen;
    339 EXTERN uint	nscreens;
    340 
    341 EXTERN struct {
    342 	Client*	focus;
    343 	Client*	hasgrab;
    344 	Image*	ibuf;
    345 	Image*	ibuf32;
    346 	bool	sel;
    347 } disp;
    348 
    349 EXTERN Client	c_magic;
    350 EXTERN Client	c_root;
    351 EXTERN Client*	client;
    352 EXTERN Divide*	divs;
    353 EXTERN Key*	key;
    354 EXTERN View*	selview;
    355 EXTERN View*	view;
    356 
    357 EXTERN Handlers	framehandler;
    358 
    359 /* IXP */
    360 EXTERN IxpServer srv;
    361 EXTERN Ixp9Srv	p9srv;
    362 
    363 /* X11 */
    364 EXTERN uint	numlock_mask;
    365 EXTERN uint	valid_mask;
    366 
    367 /* Misc */
    368 EXTERN char*	execstr;
    369 EXTERN char	hostname[HOST_NAME_MAX + 1];
    370 EXTERN long	ignoreenter;
    371 EXTERN bool	resizing;
    372 EXTERN int	starting;
    373 EXTERN char*	user;
    374 
    375 EXTERN Client*	kludge;
    376 
    377 extern char*	debugtab[];
    378