2 * draw.c - draw functions
4 * Copyright © 2007 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "statusbar.h"
28 extern Client
*clients
, *sel
, *stack
; /* global client list and stack */
30 /** Check if at least a client is tagged with tag number t
32 * \return True or False
35 isoccupied(unsigned int t
)
39 for(c
= clients
; c
; c
= c
->next
)
46 drawstatusbar(Display
*disp
, DC
*drawcontext
, awesome_config
* awesomeconf
)
49 drawcontext
->x
= drawcontext
->y
= 0;
50 for(i
= 0; i
< awesomeconf
->ntags
; i
++)
52 drawcontext
->w
= textw(drawcontext
->font
.set
, drawcontext
->font
.xfont
, awesomeconf
->tags
[i
], drawcontext
->font
.height
);
53 if(awesomeconf
->selected_tags
[i
])
55 drawtext(disp
, *drawcontext
, awesomeconf
->statusbar
.drawable
, awesomeconf
->tags
[i
], drawcontext
->sel
);
56 drawsquare(sel
&& sel
->tags
[i
], isoccupied(i
), drawcontext
->sel
, disp
, *drawcontext
, &awesomeconf
->statusbar
);
60 drawtext(disp
, *drawcontext
, awesomeconf
->statusbar
.drawable
, awesomeconf
->tags
[i
], drawcontext
->norm
);
61 drawsquare(sel
&& sel
->tags
[i
], isoccupied(i
), drawcontext
->norm
, disp
, *drawcontext
, &awesomeconf
->statusbar
);
63 drawcontext
->x
+= drawcontext
->w
;
65 drawcontext
->w
= awesomeconf
->statusbar
.width
;
66 drawtext(disp
, *drawcontext
, awesomeconf
->statusbar
.drawable
, awesomeconf
->current_layout
->symbol
, drawcontext
->norm
);
67 x
= drawcontext
->x
+ drawcontext
->w
;
68 drawcontext
->w
= textw(drawcontext
->font
.set
, drawcontext
->font
.xfont
, awesomeconf
->statustext
, drawcontext
->font
.height
);
69 drawcontext
->x
= DisplayWidth(disp
, DefaultScreen(disp
)) - drawcontext
->w
;
70 if(drawcontext
->x
< x
)
73 drawcontext
->w
= DisplayWidth(disp
, DefaultScreen(disp
)) - x
;
75 drawtext(disp
, *drawcontext
, awesomeconf
->statusbar
.drawable
, awesomeconf
->statustext
, drawcontext
->norm
);
76 if((drawcontext
->w
= drawcontext
->x
- x
) > awesomeconf
->statusbar
.height
)
81 drawtext(disp
, *drawcontext
, awesomeconf
->statusbar
.drawable
, sel
->name
, drawcontext
->sel
);
82 drawsquare(sel
->ismax
, sel
->isfloating
, drawcontext
->sel
, disp
, *drawcontext
, &awesomeconf
->statusbar
);
85 drawtext(disp
, *drawcontext
, awesomeconf
->statusbar
.drawable
, NULL
, drawcontext
->norm
);
87 XCopyArea(disp
, awesomeconf
->statusbar
.drawable
, awesomeconf
->statusbar
.window
, drawcontext
->gc
, 0, 0, DisplayWidth(disp
, DefaultScreen(disp
)), awesomeconf
->statusbar
.height
, 0, 0);
93 updatebarpos(Display
*disp
, Statusbar statusbar
)
98 switch (statusbar
.position
)
101 XMoveWindow(disp
, statusbar
.window
, 0, 0);
104 si
= get_display_info(disp
, statusbar
);
105 XMoveWindow(disp
, statusbar
.window
, 0, si
->height
);
109 XMoveWindow(disp
, statusbar
.window
, 0, 0 - statusbar
.height
);
113 while(XCheckMaskEvent(disp
, EnterWindowMask
, &ev
));
117 uicb_togglebar(Display
*disp
,
119 awesome_config
*awesomeconf
,
120 const char *arg
__attribute__ ((unused
)))
122 if(awesomeconf
->statusbar
.position
== BarOff
)
123 awesomeconf
->statusbar
.position
= (awesomeconf
->statusbar
.position
== BarOff
) ? BarTop
: awesomeconf
->statusbar_default_position
;
125 awesomeconf
->statusbar
.position
= BarOff
;
126 updatebarpos(disp
, awesomeconf
->statusbar
);
127 arrange(disp
, drawcontext
, awesomeconf
);