wmii

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

fns.h (8408B)


      1 /* Copyright ©2007-2010 Kris Maglione <jg@suckless.org>
      2  * See LICENSE file for license details.
      3  */
      4 
      5 #include <setjmp.h>
      6 
      7 #ifdef VARARGCK
      8 # pragma varargck	argpos	debug	2
      9 # pragma varargck	argpos	dprint	1
     10 # pragma varargck	argpos	event	1
     11 # pragma varargck	argpos	warning	1
     12 #
     13 # pragma varargck	type	"a"	Area*
     14 # pragma varargck	type	"C"	Client*
     15 # pragma varargck	type	"r"	void
     16 #endif
     17 
     18 #define _cond(cond, n) (cond) && __alive++ == n
     19 #define _cont(cont) (void)(__alive--, cont)
     20 
     21 #define with(type, var) \
     22 	for(type var=(type)-1; (var == (type)-1) && ((var=0) || true);)
     23 
     24 /* Grotesque, but worth it. */
     25 
     26 #define foreach_area(v, s, a) \
     27 	with(int, __alive)				\
     28 	with(Area*, __anext)				\
     29 	for(s=0; _cond(s <= nscreens, 0); _cont(s++))	\
     30 		for((a)=(s < nscreens ? (v)->areas[s] : v->floating), __anext=((a)?(a)->next:NULL); \
     31 		    _cond(a, 1);			\
     32 		    _cont(((a)=__anext) && (__anext=(a)->next)))
     33 
     34 #define foreach_column(v, s, a) \
     35 	with(int, __alive)				\
     36 	with(Area*, __anext)				\
     37 	for(s=0; _cond(s < nscreens, 0); _cont(s++))	\
     38 		for((a)=(v)->areas[s], __anext=((a)?(a)->next:NULL);	\
     39 		    _cond(a, 1);				\
     40 		    _cont(((a)=__anext) && (__anext=(a)->next)))
     41 
     42 #define foreach_frame(v, s, a, f) \
     43 	with(Frame*, __fnext)     \
     44 	foreach_area(v, s, a)     \
     45 		for((void)(((f)=(a)->frame) && (__fnext=(f)?((f)->anext):NULL));	\
     46 		    _cond(f, 2);					\
     47 		    _cont(((f)=__fnext) && (__fnext=(f)->anext)))
     48 
     49 #define btassert(arg, cond) \
     50 	(cond ? fprint(1, __FILE__":%d: failed assertion: " #cond "\n", __LINE__), backtrace(arg), true : false)
     51 
     52 /* area.c */
     53 int	afmt(Fmt*);
     54 void	area_attach(Area*, Frame*);
     55 Area*	area_create(View*, Area *pos, int scrn, uint w);
     56 void	area_destroy(Area*);
     57 void	area_detach(Frame*);
     58 Area*	area_find(View*, Rectangle, int, bool);
     59 void	area_focus(Area*);
     60 int	area_idx(Area*);
     61 void	area_moveto(Area*, Frame*);
     62 char*	area_name(Area*);
     63 Client*	area_selclient(Area*);
     64 void	area_setsel(Area*, Frame*);
     65 
     66 /* bar.c */
     67 Bar*	bar_create(Bar**, const char*);
     68 void	bar_destroy(Bar**, Bar*);
     69 void	bar_draw(WMScreen*);
     70 Bar*	bar_find(Bar*, const char*);
     71 void	bar_init(WMScreen*);
     72 void	bar_resize(WMScreen*);
     73 void	bar_sety(WMScreen*, int);
     74 void	bar_setbounds(WMScreen*, int, int);
     75 
     76 /* client.c */
     77 int	Cfmt(Fmt *f);
     78 bool	client_applytags(Client*, const char*);
     79 void	client_configure(Client*);
     80 Client*	client_create(XWindow, XWindowAttributes*);
     81 void	client_destroy(Client*);
     82 char*	client_extratags(Client*);
     83 bool	client_floats_p(Client*);
     84 void	client_focus(Client*);
     85 Frame*	client_groupframe(Client*, View*);
     86 void	client_kill(Client*, bool);
     87 void	client_manage(Client*);
     88 void	client_map(Client*);
     89 void	client_message(Client*, char*, long);
     90 bool	client_prop(Client*, Atom);
     91 void	client_reparent(Client*);
     92 void	client_resize(Client*, Rectangle);
     93 void	client_setcursor(Client*, Cursor);
     94 void	client_seturgent(Client*, int, int);
     95 void	client_setviews(Client*, char**);
     96 void	client_unmap(Client*, int state);
     97 Frame*	client_viewframe(Client *c, View *v);
     98 void	focus(Client*, bool user);
     99 void	fullscreen(Client*, int, long);
    100 void	group_init(Client*);
    101 Client*	group_leader(Group*);
    102 void	group_remove(Client*);
    103 int	client_mapframe(Client*);
    104 Client*	selclient(void);
    105 int	client_unmapframe(Client*);
    106 void	update_class(Client*);
    107 Client*	win2client(XWindow);
    108 Rectangle	client_grav(Client*, Rectangle);
    109 
    110 /* column.c */
    111 bool	column_setmode(Area*, const char*);
    112 char*	column_getmode(Area*);
    113 void	column_arrange(Area*, bool dirty);
    114 void	column_attach(Area*, Frame*);
    115 void	column_attachrect(Area*, Frame*, Rectangle);
    116 void	column_destroy(Area*);
    117 void	column_detach(Frame*);
    118 void	column_frob(Area*);
    119 void	column_insert(Area*, Frame*, Frame*);
    120 int	column_minwidth(void);
    121 Area*	column_new(View*, Area*, int, uint);
    122 void	column_remove(Frame*);
    123 void	column_resize(Area*, int);
    124 void	column_resizeframe(Frame*, Rectangle);
    125 void	column_settle(Area*);
    126 void	div_draw(Divide*);
    127 void	div_set(Divide*, int x);
    128 void	div_update_all(void);
    129 
    130 /* error.c */
    131 #define waserror() setjmp(*pusherror())
    132 void	error(char*, ...);
    133 void	nexterror(void);
    134 void	poperror(void);
    135 jmp_buf*	pusherror(void);
    136 
    137 /* event.c */
    138 void	debug_event(XEvent*);
    139 void	print_focus(const char*, Client*, const char*);
    140 
    141 /* ewmh.c */
    142 void	ewmh_checkresponsive(Client*);
    143 void	ewmh_destroyclient(Client*);
    144 void	ewmh_framesize(Client*);
    145 void	ewmh_getstrut(Client*);
    146 void	ewmh_getwintype(Client*);
    147 void	ewmh_init(void);
    148 void	ewmh_initclient(Client*);
    149 bool	ewmh_prop(Client*, Atom);
    150 long	ewmh_protocols(Window*);
    151 bool	ewmh_responsive_p(Client*);
    152 void	ewmh_updateclient(Client*);
    153 void	ewmh_updateclientlist(void);
    154 void	ewmh_updateclients(void);
    155 void	ewmh_updatestacking(void);
    156 void	ewmh_updatestate(Client*);
    157 void	ewmh_updateview(void);
    158 void	ewmh_updateviews(void);
    159 
    160 /* float.c */
    161 void	float_arrange(Area*);
    162 void	float_attach(Area*, Frame*);
    163 void	float_detach(Frame*);
    164 void	float_resizeframe(Frame*, Rectangle);
    165 Vector_rect*	unique_rects(Vector_rect*, Rectangle);
    166 Rectangle	max_rect(Vector_rect*);
    167 
    168 /* frame.c */
    169 Frame*	frame_create(Client*, View*);
    170 int	frame_delta_h(void);
    171 void	frame_draw(Frame*);
    172 void	frame_draw_all(void);
    173 void	frame_focus(Frame*);
    174 uint	frame_idx(Frame*);
    175 void	frame_insert(Frame*, Frame *pos);
    176 void	frame_remove(Frame*);
    177 void	frame_resize(Frame*, Rectangle);
    178 bool	frame_restack(Frame*, Frame*);
    179 void	frame_swap(Frame*, Frame*);
    180 int	ingrabbox_p(Frame*, int x, int y);
    181 void	move_focus(Frame*, Frame*);
    182 Rectangle constrain(Rectangle, int);
    183 Rectangle frame_client2rect(Client*, Rectangle, bool);
    184 WinHints  frame_gethints(Frame*);
    185 Rectangle frame_hints(Frame*, Rectangle, Align);
    186 Rectangle frame_rect2client(Client*, Rectangle, bool);
    187 
    188 /* fs.c */
    189 void	fs_attach(Ixp9Req*);
    190 void	fs_clunk(Ixp9Req*);
    191 void	fs_create(Ixp9Req*);
    192 void	fs_flush(Ixp9Req*);
    193 void	fs_freefid(IxpFid*);
    194 void	fs_open(Ixp9Req*);
    195 void	fs_read(Ixp9Req*);
    196 void	fs_remove(Ixp9Req*);
    197 void	fs_stat(Ixp9Req*);
    198 void	fs_walk(Ixp9Req*);
    199 void	fs_write(Ixp9Req*);
    200 void	event(const char*, ...);
    201 
    202 /* key.c */
    203 void	init_lock_keys(void);
    204 void	kpress(XWindow, ulong mod, KeyCode);
    205 void	update_keys(void);
    206 
    207 /* main.c */
    208 void	init_screens(void);
    209 void	spawn_command(const char*);
    210 
    211 /* message.c */
    212 char*	mask(char**, int*, int*);
    213 char*	message_bar(Bar*, IxpMsg*);
    214 char*	message_client(Client*, IxpMsg*);
    215 char*	message_root(void*, IxpMsg*);
    216 char*	message_view(View*, IxpMsg*);
    217 void	msg_debug(char*);
    218 void	msg_eatrunes(IxpMsg*, int (*)(Rune), int);
    219 char*	msg_getword(IxpMsg*, char*);
    220 void	msg_parsecolors(IxpMsg*, CTuple*);
    221 char*	msg_selectarea(Area*, IxpMsg*);
    222 char*	msg_sendclient(View*, IxpMsg*, bool swap);
    223 char*	readctl_bar(Bar*);
    224 char*	readctl_client(Client*);
    225 char*	readctl_root(void);
    226 char*	readctl_view(View*);
    227 Area*	strarea(View*, ulong, const char*);
    228 void	warning(const char*, ...);
    229 
    230 /* mouse.c */
    231 Window*	constraintwin(Rectangle);
    232 void	destroyconstraintwin(Window*);
    233 void	grab_button(XWindow, uint button, ulong mod);
    234 void	mouse_checkresize(Frame*, Point, bool);
    235 void	mouse_movegrabbox(Client*, bool);
    236 void	mouse_resize(Client*, Align, bool);
    237 void	mouse_resizecol(Divide*);
    238 bool	readmotion(Point*);
    239 int	readmouse(Point*, uint*);
    240 Align	snap_rect(const Rectangle *rects, int num, Rectangle *current, Align *mask, int snapw);
    241 
    242 /* print.c */
    243 int	Ffmt(Fmt*);
    244 
    245 /* root.c */
    246 void	root_init(void);
    247 
    248 /* screen.c */
    249 void*	findthing(Rectangle, int, Vector_ptr*, Rectangle(*)(void*), bool);
    250 int	ownerscreen(Rectangle);
    251 
    252 /* rule.c */
    253 void	update_rules(Rule**, char*);
    254 
    255 /* stack.c */
    256 bool	find(Area* *, Frame**, int, bool, bool);
    257 int	stack_count(Frame*, int*);
    258 Frame*	stack_find(Area*, Frame*, int, bool);
    259 void	stack_info(Frame*, Frame**, Frame**, int*, int*);
    260 void	stack_scale(Frame*, int);
    261 
    262 
    263 /* view.c */
    264 void	view_arrange(View*);
    265 void	view_attach(View*, Frame*);
    266 View*	view_create(const char*);
    267 void	view_destroy(View*);
    268 void	view_detach(Frame*);
    269 Area*	view_findarea(View*, int, int, bool);
    270 void	view_focus(WMScreen*, View*);
    271 bool	view_fullscreen_p(View*, int);
    272 char*	view_index(View*);
    273 void	view_init(View*, int iscreen);
    274 char**	view_names(void);
    275 uint	view_newcolwidth(View*, int, int);
    276 void	view_restack(View*);
    277 void	view_scale(View*, int, int);
    278 Client*	view_selclient(View*);
    279 void	view_select(const char*);
    280 void	view_update(View*);
    281 void	view_update_all(void);
    282 void	view_update_rect(View*);
    283 void	view_update_urgency(View*, char*);
    284 Rectangle*	view_rects(View*, uint *num, Frame *ignore);
    285 
    286 /* utf.c */
    287 char*	toutf8(const char*);
    288 char*	toutf8n(const char*, size_t);
    289 
    290 /* xdnd.c */
    291 void	xdnd_initwindow(Window*);
    292