2 * focustitle.c - focus title widget
4 * Copyright © 2007 Aldo Cortesi <aldo@nullcube.com>
5 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 extern AwesomeConf globalconf
;
42 focustitle_draw(Widget
*widget
, DrawCtx
*ctx
, int offset
, int used
)
44 Data
*d
= widget
->data
;
45 Client
*sel
= focus_get_current_client(widget
->statusbar
->screen
);
47 if(!widget
->user_supplied_x
)
48 widget
->area
.x
= widget_calculate_offset(widget
->statusbar
->width
,
53 if(!widget
->user_supplied_y
)
58 draw_text(ctx
, widget
->area
.x
, widget
->area
.y
,
59 widget
->statusbar
->width
- used
,
60 widget
->statusbar
->height
,
62 widget
->font
->height
/ 2, widget
->font
, sel
->name
,
64 if(sel
->isfloating
|| sel
->ismax
)
65 draw_circle(ctx
, widget
->area
.x
, widget
->area
.y
,
66 (widget
->font
->height
+ 2) / 4,
70 draw_rectangle(ctx
, widget
->area
.x
, widget
->area
.y
,
71 widget
->statusbar
->width
- used
, widget
->statusbar
->height
, True
, d
->bg
);
73 widget
->area
.width
= widget
->statusbar
->width
- used
;
74 widget
->area
.height
= widget
->statusbar
->height
;
76 return widget
->area
.width
;
80 focustitle_new(Statusbar
*statusbar
, cfg_t
*config
)
85 int phys_screen
= get_phys_screen(statusbar
->screen
);
88 widget_common_new(w
, statusbar
, config
);
89 w
->draw
= focustitle_draw
;
90 w
->alignment
= AlignFlex
;
91 w
->data
= d
= p_new(Data
, 1);
93 if((buf
= cfg_getstr(config
, "fg")))
94 d
->fg
= initxcolor(phys_screen
, buf
);
96 d
->fg
= globalconf
.screens
[statusbar
->screen
].colors_selected
[ColFG
];
98 if((buf
= cfg_getstr(config
, "bg")))
99 d
->bg
= initxcolor(phys_screen
, buf
);
101 d
->bg
= globalconf
.screens
[statusbar
->screen
].colors_selected
[ColBG
];
103 d
->align
= draw_get_align(cfg_getstr(config
, "align"));
105 if((buf
= cfg_getstr(config
, "font")))
106 w
->font
= XftFontOpenName(globalconf
.display
, get_phys_screen(statusbar
->screen
), buf
);
109 w
->font
= globalconf
.screens
[statusbar
->screen
].font
;
111 /* Set cache property */
112 w
->cache
.flags
= WIDGET_CACHE_CLIENTS
| WIDGET_CACHE_TAGS
;
117 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80