systray: attach systray to external window, not statusbar

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-15 10:25:26 +02:00
parent 6648a1edea
commit f418cb0c2e
6 changed files with 41 additions and 47 deletions

View File

@ -413,6 +413,7 @@ main(int argc, char **argv)
XCB_CW_EVENT_MASK | XCB_CW_CURSOR,
change_win_vals);
ewmh_set_supported_hints(screen_nbr);
systray_init(screen_nbr);
}
/* call this to at least grab root window clicks */

View File

@ -124,9 +124,9 @@ for s = 1, screen.count() do
mystatusbar[s]:widget_add(mymenubox)
mystatusbar[s]:widget_add(mytextbox)
mystatusbar[s]:widget_add(mylayoutbox[s])
mystatusbar[s]:widget_add(mysystray)
mystatusbar[s]:add(s)
end
mystatusbar[screen.count()]:widget_add(mysystray)
-- }}}
-- {{{ Mouse bindings

View File

@ -372,8 +372,8 @@ typedef struct
statusbar_t *statusbar;
/** Padding */
padding_t padding;
/** Statusbar that contains the systray */
statusbar_t *systray;
/** Window that contains the systray */
simple_window_t *systray;
} screen_t;
/** Main configuration structure */

View File

@ -27,11 +27,46 @@
#include "window.h"
#include "widget.h"
#include "common/xembed.h"
#include "common/swindow.h"
#define SYSTEM_TRAY_REQUEST_DOCK 0 /* Begin icon docking */
extern awesome_t globalconf;
void
systray_init(int phys_screen)
{
xutil_intern_atom_request_t atom_systray_q, atom_manager_q;
xcb_atom_t atom_systray;
xcb_client_message_event_t ev;
char atom_name[22];
/* Send requests */
atom_manager_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, atom_name);
snprintf(atom_name, sizeof(atom_name), "_NET_SYSTEM_TRAY_S%d", phys_screen);
atom_systray_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, atom_name);
globalconf.screens[phys_screen].systray = simplewindow_new(globalconf.connection, phys_screen,
-1, -1, 1, 1, 0);
/* Fill event */
ev.format = 32;
ev.data.data32[0] = XCB_CURRENT_TIME;
ev.data.data32[2] = globalconf.screens[phys_screen].systray->window;
ev.data.data32[3] = ev.data.data32[4] = 0;
ev.response_type = xutil_intern_atom_reply(globalconf.connection,
&globalconf.atoms, atom_manager_q);
ev.data.data32[1] = atom_systray = xutil_intern_atom_reply(globalconf.connection,
&globalconf.atoms,
atom_systray_q);
xcb_set_selection_owner(globalconf.connection,
globalconf.screens[phys_screen].systray->window,
atom_systray,
XCB_CURRENT_TIME);
}
/** Handle a systray request.
* \param embed_win The window to embed.
*/
@ -66,7 +101,7 @@ systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *i
/** \todo we should create a dedicated window for that */
if(globalconf.screens[phys_screen].systray)
xembed_embedded_notify(globalconf.connection, em->win,
globalconf.screens[phys_screen].systray->sw->window,
globalconf.screens[phys_screen].systray->window,
MIN(XEMBED_VERSION, em->info.version));
if(em->info.flags & XEMBED_MAPPED)

View File

@ -25,6 +25,7 @@
#include <xcb/xcb.h>
#include "common/xembed.h"
void systray_init(int);
int systray_request_handle(xcb_window_t, int, xembed_info_t *);
int systray_process_client_message(xcb_client_message_event_t *);
int xembed_process_client_message(xcb_client_message_event_t *);

View File

@ -27,39 +27,6 @@
extern awesome_t globalconf;
static bool
systray_init(statusbar_t *sb)
{
xutil_intern_atom_request_t atom_systray_q, atom_manager_q;
xcb_atom_t atom_systray;
xcb_client_message_event_t ev;
char atom_name[22];
/* Send requests */
atom_manager_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, atom_name);
snprintf(atom_name, sizeof(atom_name), "_NET_SYSTEM_TRAY_S%d", sb->sw->phys_screen);
atom_systray_q = xutil_intern_atom(globalconf.connection, &globalconf.atoms, atom_name);
/* Fill event */
ev.format = 32;
ev.data.data32[0] = XCB_CURRENT_TIME;
ev.data.data32[2] = sb->sw->window;
ev.data.data32[3] = ev.data.data32[4] = 0;
ev.response_type = xutil_intern_atom_reply(globalconf.connection,
&globalconf.atoms, atom_manager_q);
ev.data.data32[1] = atom_systray = xutil_intern_atom_reply(globalconf.connection,
&globalconf.atoms,
atom_systray_q);
xcb_set_selection_owner(globalconf.connection,
sb->sw->window,
atom_systray,
XCB_CURRENT_TIME);
return true;
}
static int
systray_draw(draw_context_t *ctx,
int screen __attribute__ ((unused)),
@ -75,16 +42,6 @@ systray_draw(draw_context_t *ctx,
phys_screen = screen_virttophys(screen);
/* only init and take systray handling if noone has it and if we have a
* window to handle others... windows. */
if(!globalconf.screens[phys_screen].systray && sb->sw)
{
globalconf.screens[phys_screen].systray = sb;
systray_init(sb);
}
else if(globalconf.screens[phys_screen].systray != p)
return (w->area.width = 0);
for(em = globalconf.embedded; em; em = em->next)
i++;