2008-06-14 18:12:16 +02:00
|
|
|
/*
|
|
|
|
* systray.c - systray widget
|
|
|
|
*
|
|
|
|
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <xcb/xcb.h>
|
2008-06-24 19:56:10 +02:00
|
|
|
#include <xcb/xcb_atom.h>
|
2008-06-14 18:12:16 +02:00
|
|
|
|
|
|
|
#include "widget.h"
|
2008-06-14 23:20:35 +02:00
|
|
|
#include "screen.h"
|
2008-06-14 18:12:16 +02:00
|
|
|
#include "common/xembed.h"
|
2008-06-30 18:55:14 +02:00
|
|
|
#include "common/atoms.h"
|
2008-06-14 18:12:16 +02:00
|
|
|
|
2008-06-24 19:56:10 +02:00
|
|
|
#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0
|
|
|
|
#define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1
|
|
|
|
|
2008-06-14 18:12:16 +02:00
|
|
|
extern awesome_t globalconf;
|
|
|
|
|
2008-10-22 17:32:17 +02:00
|
|
|
static area_t
|
|
|
|
systray_geometry(widget_t *widget, int screen, int height, int width)
|
2008-06-14 18:12:16 +02:00
|
|
|
{
|
2008-10-22 17:32:17 +02:00
|
|
|
area_t geometry;
|
|
|
|
int phys_screen = screen_virttophys(screen), i = 0;
|
2008-06-14 18:12:16 +02:00
|
|
|
|
2008-10-22 17:32:17 +02:00
|
|
|
geometry.height = height;
|
2008-08-05 15:29:16 +02:00
|
|
|
|
2008-10-22 17:32:17 +02:00
|
|
|
for(xembed_window_t *em = globalconf.embedded; em; em = em->next)
|
|
|
|
if(em->phys_screen == phys_screen)
|
|
|
|
i++;
|
2008-08-05 15:29:16 +02:00
|
|
|
|
2008-10-22 17:32:17 +02:00
|
|
|
/** \todo use class hints */
|
|
|
|
geometry.width = MIN(i * height, width);
|
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
systray_draw(widget_t *widget, draw_context_t *ctx,
|
|
|
|
area_t geometry, int screen, wibox_t *p)
|
|
|
|
{
|
|
|
|
uint32_t orient;
|
2008-06-14 18:12:16 +02:00
|
|
|
|
2008-09-21 10:13:21 +02:00
|
|
|
switch(p->position)
|
2008-06-14 18:12:16 +02:00
|
|
|
{
|
|
|
|
case Right:
|
2008-08-05 16:59:54 +02:00
|
|
|
case Left:
|
2008-06-24 19:56:10 +02:00
|
|
|
orient = _NET_SYSTEM_TRAY_ORIENTATION_VERT;
|
2008-06-14 18:12:16 +02:00
|
|
|
break;
|
|
|
|
default:
|
2008-06-24 19:56:10 +02:00
|
|
|
orient = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
|
2008-06-14 18:12:16 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
/* set wibox orientation */
|
2008-06-24 19:56:10 +02:00
|
|
|
/** \todo stop setting that property on each redraw */
|
|
|
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
2008-09-21 10:13:21 +02:00
|
|
|
globalconf.screens[p->sw.ctx.phys_screen].systray.window,
|
2008-06-30 18:55:14 +02:00
|
|
|
_NET_SYSTEM_TRAY_ORIENTATION, CARDINAL, 32, 1, &orient);
|
2008-06-14 18:12:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
widget_t *
|
|
|
|
systray_new(alignment_t align)
|
|
|
|
{
|
|
|
|
widget_t *w;
|
|
|
|
|
|
|
|
w = p_new(widget_t, 1);
|
|
|
|
widget_common_new(w);
|
|
|
|
w->align = align;
|
|
|
|
w->draw = systray_draw;
|
2008-10-22 17:32:17 +02:00
|
|
|
w->geometry = systray_geometry;
|
2008-06-14 18:12:16 +02:00
|
|
|
w->cache_flags = WIDGET_CACHE_EMBEDDED;
|
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|