mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
Register systray only if systray widgets are attached. (FS#503)
Signed-off-by: Daniel Graña <dangra@gmail.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
72261c9750
commit
f47b816996
6 changed files with 62 additions and 7 deletions
2
event.h
2
event.h
|
@ -22,6 +22,7 @@
|
|||
#ifndef AWESOME_EVENT_H
|
||||
#define AWESOME_EVENT_H
|
||||
|
||||
#include "systray.h"
|
||||
#include "objects/wibox.h"
|
||||
#include "objects/client.h"
|
||||
|
||||
|
@ -30,6 +31,7 @@ awesome_refresh(void)
|
|||
{
|
||||
banning_refresh();
|
||||
wibox_refresh();
|
||||
systray_refresh();
|
||||
stack_refresh();
|
||||
return xcb_flush(globalconf.connection);
|
||||
}
|
||||
|
|
|
@ -412,6 +412,8 @@ wibox_map(wibox_t *wibox)
|
|||
static void
|
||||
wibox_systray_refresh(wibox_t *wibox)
|
||||
{
|
||||
wibox->has_systray = false;
|
||||
|
||||
if(!wibox->screen)
|
||||
return;
|
||||
|
||||
|
@ -426,6 +428,8 @@ wibox_systray_refresh(wibox_t *wibox)
|
|||
xembed_window_t *em;
|
||||
int phys_screen = wibox->ctx.phys_screen;
|
||||
|
||||
wibox->has_systray = true;
|
||||
|
||||
if(wibox->visible
|
||||
&& systray->widget->isvisible
|
||||
&& systray->geometry.width)
|
||||
|
|
|
@ -65,6 +65,8 @@ struct wibox_t
|
|||
/** The window's content and border */
|
||||
image_t *bounding;
|
||||
} shape;
|
||||
/** Has wibox an attached systray **/
|
||||
bool has_systray;
|
||||
};
|
||||
|
||||
void wibox_unref_simplified(wibox_t **);
|
||||
|
|
1
screen.h
1
screen.h
|
@ -40,6 +40,7 @@ struct a_screen
|
|||
xcb_window_t window;
|
||||
/** Systray window parent */
|
||||
xcb_window_t parent;
|
||||
bool registered;
|
||||
} systray;
|
||||
/** Previously focused client */
|
||||
client_t *prev_client_focus;
|
||||
|
|
58
systray.c
58
systray.c
|
@ -27,6 +27,8 @@
|
|||
#include "systray.h"
|
||||
#include "xwindow.h"
|
||||
#include "objects/widget.h"
|
||||
#include "objects/wibox.h"
|
||||
#include "common/array.h"
|
||||
#include "common/atoms.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
|
@ -37,6 +39,46 @@
|
|||
*/
|
||||
void
|
||||
systray_init(int phys_screen)
|
||||
{
|
||||
xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen);
|
||||
|
||||
globalconf.screens.tab[phys_screen].systray.window = xcb_generate_id(globalconf.connection);
|
||||
xcb_create_window(globalconf.connection, xscreen->root_depth,
|
||||
globalconf.screens.tab[phys_screen].systray.window,
|
||||
xscreen->root,
|
||||
-1, -1, 1, 1, 0,
|
||||
XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
/** Refresh all systrays registrations per physical screen
|
||||
*/
|
||||
void
|
||||
systray_refresh()
|
||||
{
|
||||
bool has_systray;
|
||||
int nscreen = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
|
||||
|
||||
for(int phys_screen = 0; phys_screen < nscreen; phys_screen++)
|
||||
{
|
||||
has_systray = false;
|
||||
foreach(w, globalconf.wiboxes)
|
||||
if(phys_screen == (*w)->ctx.phys_screen)
|
||||
has_systray |= (*w)->has_systray;
|
||||
|
||||
if(has_systray)
|
||||
systray_register(phys_screen);
|
||||
else
|
||||
systray_cleanup(phys_screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Register systray in X.
|
||||
* \param phys_screen Physical screen.
|
||||
*/
|
||||
void
|
||||
systray_register(int phys_screen)
|
||||
{
|
||||
xcb_client_message_event_t ev;
|
||||
xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen);
|
||||
|
@ -45,6 +87,11 @@ systray_init(int phys_screen)
|
|||
xcb_intern_atom_reply_t *atom_systray_r;
|
||||
xcb_atom_t atom_systray;
|
||||
|
||||
/* Set registered even if it fails to don't try again unless forced */
|
||||
if(globalconf.screens.tab[phys_screen].systray.registered)
|
||||
return;
|
||||
globalconf.screens.tab[phys_screen].systray.registered = true;
|
||||
|
||||
/* Send requests */
|
||||
if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", phys_screen)))
|
||||
{
|
||||
|
@ -57,13 +104,6 @@ systray_init(int phys_screen)
|
|||
|
||||
p_delete(&atom_name);
|
||||
|
||||
globalconf.screens.tab[phys_screen].systray.window = xcb_generate_id(globalconf.connection);
|
||||
xcb_create_window(globalconf.connection, xscreen->root_depth,
|
||||
globalconf.screens.tab[phys_screen].systray.window,
|
||||
xscreen->root,
|
||||
-1, -1, 1, 1, 0,
|
||||
XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL);
|
||||
|
||||
/* Fill event */
|
||||
p_clear(&ev, 1);
|
||||
ev.response_type = XCB_CLIENT_MESSAGE;
|
||||
|
@ -101,6 +141,10 @@ systray_cleanup(int phys_screen)
|
|||
xcb_intern_atom_reply_t *atom_systray_r;
|
||||
char *atom_name;
|
||||
|
||||
if(!globalconf.screens.tab[phys_screen].systray.registered)
|
||||
return;
|
||||
globalconf.screens.tab[phys_screen].systray.registered = false;
|
||||
|
||||
if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", phys_screen))
|
||||
|| !(atom_systray_r = xcb_intern_atom_reply(globalconf.connection,
|
||||
xcb_intern_atom_unchecked(globalconf.connection,
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "common/xembed.h"
|
||||
|
||||
void systray_init(int);
|
||||
void systray_refresh(void);
|
||||
void systray_register(int);
|
||||
void systray_cleanup(int);
|
||||
int systray_request_handle(xcb_window_t, int, xembed_info_t *);
|
||||
bool systray_iskdedockapp(xcb_window_t);
|
||||
|
|
Loading…
Reference in a new issue