awful.layout.suit.magnifier: fix typo
[awesome.git] / widgets / systray.c
blob88bfce5c10703dc16365236634ce6b00efc74e2f
1 /*
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.
22 #include <xcb/xcb.h>
23 #include <xcb/xcb_atom.h>
25 #include "widget.h"
26 #include "screen.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;
35 static area_t
36 systray_geometry(widget_t *widget, int screen, int height, int width)
38 area_t geometry;
39 int phys_screen = screen_virttophys(screen), n = 0;
41 geometry.height = height;
43 for(int i = 0; i < globalconf.embedded.len; i++)
44 if(globalconf.embedded.tab[i].phys_screen == phys_screen)
45 n++;
47 /** \todo use class hints */
48 geometry.width = MIN(n * height, width);
50 return geometry;
53 static void
54 systray_draw(widget_t *widget, draw_context_t *ctx,
55 area_t geometry, int screen, wibox_t *p)
57 uint32_t orient;
59 switch(p->position)
61 case Right:
62 case Left:
63 orient = _NET_SYSTEM_TRAY_ORIENTATION_VERT;
64 break;
65 default:
66 orient = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
67 break;
70 /* set wibox orientation */
71 /** \todo stop setting that property on each redraw */
72 xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
73 globalconf.screens[p->sw.ctx.phys_screen].systray.window,
74 _NET_SYSTEM_TRAY_ORIENTATION, CARDINAL, 32, 1, &orient);
77 /** Initialize a systray widget.
78 * \param w The widget to initialize.
79 * \return The same widget.
81 widget_t *
82 widget_systray(widget_t *w)
84 w->draw = systray_draw;
85 w->geometry = systray_geometry;
87 return w;
89 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80