2 * appicon.c - application icon widget
4 * Copyright © 2008 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.
26 extern awesome_t globalconf
;
28 /** Draw a application icon widget.
29 * \param ctx The draw context.
30 * \param screen The screen.
31 * \param w The widget node we are linked from.
32 * \param offset Offset to draw at.
33 * \param used The size used on the element.
34 * \param p A pointer to the object we're draw onto.
35 * \param type The type of the object.
36 * \return The width used.
39 appicon_draw(draw_context_t
*ctx
, int screen
__attribute__ ((unused
)),
42 void *p
, awesome_type_t type
)
50 case AWESOME_TYPE_STATUSBAR
:
51 c
= globalconf
.screen_focus
->client_focus
;
53 case AWESOME_TYPE_TITLEBAR
:
54 c
= client_getbytitlebar(p
);
60 if((image
= draw_image_new(c
->icon_path
)))
62 w
->area
.width
= ((double) ctx
->height
/ (double) image
->height
) * image
->width
;
63 w
->area
.x
= widget_calculate_offset(ctx
->width
,
67 draw_image(ctx
, w
->area
.x
,
68 w
->area
.y
, ctx
->height
, image
);
69 draw_image_delete(&image
);
71 else if((icon
= ewmh_get_window_icon(c
->win
)))
73 w
->area
.width
= ((double) ctx
->height
/ (double) icon
->height
)
75 w
->area
.x
= widget_calculate_offset(ctx
->width
,
79 draw_image_from_argb_data(ctx
,
82 icon
->width
, icon
->height
,
83 ctx
->height
, icon
->image
);
84 netwm_icon_delete(&icon
);
93 /** Create a new appicon widget.
94 * \param align Widget alignment.
95 * \return A brand new widget.
98 appicon_new(alignment_t align
)
102 w
= p_new(widget_t
, 1);
103 widget_common_new(w
);
105 w
->draw
= appicon_draw
;
110 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80