2 * systray.c - systray 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.
23 #include <xcb/xcb_atom.h>
27 #include "common/xembed.h"
28 #include "common/atoms.h"
30 #define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
31 #define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1
33 extern awesome_t globalconf
;
36 systray_draw(draw_context_t
*ctx
,
37 int screen
__attribute__ ((unused
)),
39 int offset
, int used
__attribute__ ((unused
)),
44 /* p is always a statusbar, titlebars are forbidden */
45 statusbar_t
*sb
= (statusbar_t
*) p
;
47 /* we are on a statusbar */
48 assert(type
== AWESOME_TYPE_STATUSBAR
);
50 w
->area
.height
= ctx
->height
;
52 if(ctx
->width
- used
> 0)
56 for(em
= globalconf
.embedded
; em
; em
= em
->next
)
57 if(em
->phys_screen
== sb
->phys_screen
)
59 /** \todo use clas hints */
60 w
->area
.width
= MIN(i
* ctx
->height
, ctx
->width
- used
);
65 w
->area
.x
= widget_calculate_offset(ctx
->width
,
75 orient
= _NET_SYSTEM_TRAY_ORIENTATION_VERT
;
78 orient
= _NET_SYSTEM_TRAY_ORIENTATION_HORZ
;
82 /* set statusbar orientation */
83 /** \todo stop setting that property on each redraw */
84 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
85 globalconf
.screens
[sb
->phys_screen
].systray
.window
,
86 _NET_SYSTEM_TRAY_ORIENTATION
, CARDINAL
, 32, 1, &orient
);
92 systray_new(alignment_t align
)
96 w
= p_new(widget_t
, 1);
99 w
->draw
= systray_draw
;
100 w
->cache_flags
= WIDGET_CACHE_EMBEDDED
;
104 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80