systray: Set _NET_SYSTEM_TRAY_ICON_SIZE

This commit is contained in:
o9000
2015-07-26 11:23:19 +02:00
parent ceafe9b281
commit e3939a56e1
3 changed files with 36 additions and 21 deletions

View File

@@ -96,6 +96,8 @@ void server_init_atoms ()
server.atom.MANAGER = XInternAtom(server.dsp, "MANAGER", False); server.atom.MANAGER = XInternAtom(server.dsp, "MANAGER", False);
server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_ORIENTATION", False); server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_ORIENTATION", False);
server.atom._NET_SYSTEM_TRAY_ICON_SIZE = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_ICON_SIZE", False);
server.atom._NET_SYSTEM_TRAY_PADDING = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_PADDING", False);
server.atom._XEMBED = XInternAtom(server.dsp, "_XEMBED", False); server.atom._XEMBED = XInternAtom(server.dsp, "_XEMBED", False);
server.atom._XEMBED_INFO = XInternAtom(server.dsp, "_XEMBED_INFO", False); server.atom._XEMBED_INFO = XInternAtom(server.dsp, "_XEMBED_INFO", False);
server.atom._NET_WM_PID = XInternAtom(server.dsp, "_NET_WM_PID", True); server.atom._NET_WM_PID = XInternAtom(server.dsp, "_NET_WM_PID", True);

View File

@@ -71,6 +71,8 @@ typedef struct Global_atom
Atom MANAGER; Atom MANAGER;
Atom _NET_SYSTEM_TRAY_MESSAGE_DATA; Atom _NET_SYSTEM_TRAY_MESSAGE_DATA;
Atom _NET_SYSTEM_TRAY_ORIENTATION; Atom _NET_SYSTEM_TRAY_ORIENTATION;
Atom _NET_SYSTEM_TRAY_ICON_SIZE;
Atom _NET_SYSTEM_TRAY_PADDING;
Atom _XEMBED; Atom _XEMBED;
Atom _XEMBED_INFO; Atom _XEMBED_INFO;
Atom _NET_WM_PID; Atom _NET_WM_PID;

View File

@@ -106,30 +106,22 @@ void init_systray()
systray.alpha = 100; systray.alpha = 100;
systray.brightness = systray.saturation = 0; systray.brightness = systray.saturation = 0;
} }
start_net();
} }
void init_systray_panel(void *p) void init_systray_panel(void *p)
{ {
systray.area.parent = p; Panel *panel = (Panel *)p;
systray.area.panel = p; systray.area.parent = panel;
systray.area.panel = panel;
if (!systray.area.bg) if (!systray.area.bg)
systray.area.bg = &g_array_index(backgrounds, Background, 0); systray.area.bg = &g_array_index(backgrounds, Background, 0);
GSList *l;
int count = 0;
for (l = systray.list_icons; l ; l = l->next) {
if (((TrayWindow*)l->data)->hide)
continue;
count++;
}
if (count == 0)
hide(&systray.area);
else
show(&systray.area); show(&systray.area);
refresh_systray = 0; systray.area.resize = 1;
systray.area.redraw = 1;
panel->area.resize = 1;
panel_refresh = 1;
refresh_systray = 1;
} }
@@ -163,6 +155,12 @@ int resize_systray(void *obj)
sysbar->icon_size = sysbar->icon_size - (2 * sysbar->area.bg->border.width) - (2 * sysbar->area.paddingy); sysbar->icon_size = sysbar->icon_size - (2 * sysbar->area.bg->border.width) - (2 * sysbar->area.paddingy);
if (systray_max_icon_size > 0 && sysbar->icon_size > systray_max_icon_size) if (systray_max_icon_size > 0 && sysbar->icon_size > systray_max_icon_size)
sysbar->icon_size = systray_max_icon_size; sysbar->icon_size = systray_max_icon_size;
if (systray.icon_size > 0) {
long icon_size = systray.icon_size;
XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ICON_SIZE, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &icon_size, 1);
}
count = 0; count = 0;
for (l = systray.list_icons; l ; l = l->next) { for (l = systray.list_icons; l ; l = l->next) {
if (((TrayWindow*)l->data)->hide) if (((TrayWindow*)l->data)->hide)
@@ -186,6 +184,11 @@ int resize_systray(void *obj)
sysbar->icons_per_column = count / sysbar->icons_per_row+ (count%sysbar->icons_per_row != 0); sysbar->icons_per_column = count / sysbar->icons_per_row+ (count%sysbar->icons_per_row != 0);
systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (sysbar->icon_size * sysbar->icons_per_column) + ((sysbar->icons_per_column-1) * systray.area.paddingx); systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (sysbar->icon_size * sysbar->icons_per_column) + ((sysbar->icons_per_column-1) * systray.area.paddingx);
} }
if (net_sel_win == None) {
start_net();
}
return 1; return 1;
} }
@@ -303,11 +306,19 @@ void start_net()
// init systray protocol // init systray protocol
net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0); net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0);
fprintf(stderr, "systray window %ld\n", net_sel_win);
// v0.3 trayer specification. tint2 always horizontal. // v0.3 trayer specification. tint2 always horizontal.
// Vertical panel will draw the systray horizontal. // Vertical panel will draw the systray horizontal.
long orient = 0; long orientation = 0;
XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ORIENTATION, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &orient, 1); XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ORIENTATION, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &orientation, 1);
if (systray.icon_size > 0) {
long icon_size = systray.icon_size;
XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ICON_SIZE, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &icon_size, 1);
}
long padding = 0;
XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_PADDING, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &padding, 1);
VisualID vid; VisualID vid;
if (systray_composited) if (systray_composited)
vid = XVisualIDFromVisual(server.visual32); vid = XVisualIDFromVisual(server.visual32);
@@ -563,7 +574,7 @@ gboolean add_icon(Window win)
} }
if (systray_profile) if (systray_profile)
fprintf(stderr, "XCreateWindow(...)\n"); fprintf(stderr, "XCreateWindow(...)\n");
Window parent = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, visual, mask, &set_attr); Window parent = XCreateWindow(server.dsp, panel->main_win, 0, 0, systray.icon_size, systray.icon_size, 0, attr.depth, InputOutput, visual, mask, &set_attr);
// Add the icon to the list // Add the icon to the list
TrayWindow *traywin = g_new0(TrayWindow, 1); TrayWindow *traywin = g_new0(TrayWindow, 1);