2 * systray.c - systray widget
4 * Copyright © 2008-2009 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>
29 #include "globalconf.h"
30 #include "common/xembed.h"
31 #include "common/atoms.h"
33 #define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
34 #define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1
43 systray_extents(lua_State
*L
, widget_t
*widget
)
45 int screen
= luaL_optnumber(L
, -1, 1) - 1;
46 luaA_checkscreen(screen
);
49 int phys_screen
= screen_virttophys(screen
), n
= 0;
50 systray_data_t
*d
= widget
->data
;
52 for(int i
= 0; i
< globalconf
.embedded
.len
; i
++)
53 if(globalconf
.embedded
.tab
[i
].phys_screen
== phys_screen
)
56 /** \todo use class hints */
57 geometry
.width
= d
->height
* n
;
58 geometry
.height
= d
->height
;
59 geometry
.x
= geometry
.y
= 0;
65 systray_draw(widget_t
*widget
, draw_context_t
*ctx
,
66 area_t geometry
, wibox_t
*p
)
74 orient
= _NET_SYSTEM_TRAY_ORIENTATION_VERT
;
77 orient
= _NET_SYSTEM_TRAY_ORIENTATION_HORZ
;
81 systray_data_t
*d
= widget
->data
;
83 if (p
->orientation
== East
)
84 d
->height
= p
->geometry
.height
;
86 d
->height
= p
->geometry
.width
;
88 /* set wibox orientation */
89 /** \todo stop setting that property on each redraw */
90 xcb_change_property(globalconf
.connection
, XCB_PROP_MODE_REPLACE
,
91 globalconf
.screens
.tab
[p
->ctx
.phys_screen
].systray
.window
,
92 _NET_SYSTEM_TRAY_ORIENTATION
, XCB_ATOM_CARDINAL
, 32, 1, &orient
);
95 /** Delete a systray widget.
96 * \param w The widget to destroy.
99 systray_destructor(widget_t
*w
)
101 systray_data_t
*d
= w
->data
;
105 /** Initialize a systray widget.
106 * \param w The widget to initialize.
107 * \return The same widget.
110 widget_systray(widget_t
*w
)
112 w
->draw
= systray_draw
;
113 w
->extents
= systray_extents
;
114 w
->destructor
= systray_destructor
;
116 systray_data_t
*d
= w
->data
= p_new(systray_data_t
, 1);
121 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80