*fix* issue 175

*fix* a bug I introduced with one of my previous checkins...



git-svn-id: http://tint2.googlecode.com/svn/trunk@313 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
Andreas.Fink85
2010-01-03 13:14:25 +00:00
parent a0cf313f08
commit fad21d3c1c
11 changed files with 52 additions and 12 deletions

View File

@@ -79,6 +79,7 @@ systray = 1
systray_padding = 7 8 5 systray_padding = 7 8 5
systray_background_id = 1 systray_background_id = 1
systray_sort = left2right systray_sort = left2right
systray_icon_size = 0
#--------------------------------------------- #---------------------------------------------
# TOOLTIP # TOOLTIP

View File

@@ -77,6 +77,7 @@ systray = 1
systray_padding = 8 4 5 systray_padding = 8 4 5
systray_background_id = 1 systray_background_id = 1
systray_sort = left2right systray_sort = left2right
systray_icon_size = 0
#--------------------------------------------- #---------------------------------------------
# BATTERY # BATTERY

View File

@@ -75,6 +75,7 @@ systray = 1
systray_padding = 8 6 5 systray_padding = 8 6 5
systray_background_id = 0 systray_background_id = 0
systray_sort = left2right systray_sort = left2right
systray_icon_size = 0
#--------------------------------------------- #---------------------------------------------
# BATTERY # BATTERY

View File

@@ -72,6 +72,7 @@ systray = 1
systray_padding = 6 5 5 systray_padding = 6 5 5
systray_background_id =2 systray_background_id =2
systray_sort = left2right systray_sort = left2right
systray_icon_size = 0
#--------------------------------------------- #---------------------------------------------
# BATTERY # BATTERY

View File

@@ -65,6 +65,7 @@ systray = 1
systray_padding = 0 4 5 systray_padding = 0 4 5
systray_background_id = 0 systray_background_id = 0
systray_sort = left2right systray_sort = left2right
systray_icon_size = 0
#--------------------------------------------- #---------------------------------------------
# CLOCK # CLOCK

View File

@@ -65,6 +65,7 @@ systray = 1
systray_padding = 2 8 0 systray_padding = 2 8 0
systray_background_id = 1 systray_background_id = 1
systray_sort = left2right systray_sort = left2right
systray_icon_size = 0
#--------------------------------------------- #---------------------------------------------
# CLOCK # CLOCK

View File

@@ -74,6 +74,7 @@ systray = 1
systray_padding = 4 2 3 systray_padding = 4 2 3
systray_background_id = 0 systray_background_id = 0
systray_sort = left2right systray_sort = left2right
systray_icon_size = 0
#--------------------------------------------- #---------------------------------------------
# CLOCK # CLOCK

View File

@@ -542,6 +542,9 @@ void add_entry (char *key, char *value)
else if (strcmp(value, "right2left") == 0) else if (strcmp(value, "right2left") == 0)
systray.sort = 3; systray.sort = 3;
} }
else if (strcmp(key, "systray_icon_size") == 0) {
systray_max_icon_size = atoi(value);
}
/* Tooltip */ /* Tooltip */
else if (strcmp (key, "tooltip") == 0) else if (strcmp (key, "tooltip") == 0)

View File

@@ -47,6 +47,7 @@ Window net_sel_win = None, hint_win = None;
Systraybar systray; Systraybar systray;
int refresh_systray; int refresh_systray;
int systray_enabled; int systray_enabled;
int systray_max_icon_size = 0;
void init_systray() void init_systray()
@@ -111,6 +112,8 @@ void resize_systray(void *obj)
else else
icon_size = sysbar->area.width; icon_size = sysbar->area.width;
icon_size = icon_size - (2 * sysbar->area.pix.border.width) - (2 * sysbar->area.paddingy); icon_size = icon_size - (2 * sysbar->area.pix.border.width) - (2 * sysbar->area.paddingy);
if (systray_max_icon_size > 0 && icon_size > systray_max_icon_size)
icon_size = systray_max_icon_size;
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)
@@ -120,7 +123,11 @@ void resize_systray(void *obj)
if (panel_horizontal) { if (panel_horizontal) {
if (!count) systray.area.width = 0; if (!count) systray.area.width = 0;
else systray.area.width = (2 * systray.area.pix.border.width) + (2 * systray.area.paddingxlr) + (icon_size * count) + ((count-1) * systray.area.paddingx); else {
int icons_per_column = (sysbar->area.height - 2*sysbar->area.pix.border.width - 2*sysbar->area.paddingy + sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
int row_count = count / icons_per_column + (count%icons_per_column != 0);
systray.area.width = (2 * systray.area.pix.border.width) + (2 * systray.area.paddingxlr) + (icon_size * row_count) + ((row_count-1) * systray.area.paddingx);
}
systray.area.posx = panel->area.width - panel->area.pix.border.width - panel->area.paddingxlr - systray.area.width; systray.area.posx = panel->area.width - panel->area.pix.border.width - panel->area.paddingxlr - systray.area.width;
if (panel->clock.area.on_screen) if (panel->clock.area.on_screen)
@@ -132,7 +139,11 @@ void resize_systray(void *obj)
} }
else { else {
if (!count) systray.area.height = 0; if (!count) systray.area.height = 0;
else systray.area.height = (2 * systray.area.pix.border.width) + (2 * systray.area.paddingxlr) + (icon_size * count) + ((count-1) * systray.area.paddingx); else {
int icons_per_row = (sysbar->area.width - 2*sysbar->area.pix.border.width - 2*sysbar->area.paddingy + sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
int column_count = count / icons_per_row+ (count%icons_per_row != 0);
systray.area.height = (2 * systray.area.pix.border.width) + (2 * systray.area.paddingxlr) + (icon_size * column_count) + ((column_count-1) * systray.area.paddingx);
}
systray.area.posy = panel->area.pix.border.width + panel->area.paddingxlr; systray.area.posy = panel->area.pix.border.width + panel->area.paddingxlr;
if (panel->clock.area.on_screen) if (panel->clock.area.on_screen)
@@ -143,14 +154,18 @@ void resize_systray(void *obj)
#endif #endif
} }
int max_line_pos;
if (panel_horizontal) { if (panel_horizontal) {
max_line_pos = sysbar->area.posy+sysbar->area.height - sysbar->area.pix.border.width - sysbar->area.paddingy - icon_size;
posy = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy; posy = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
posx = systray.area.posx + systray.area.pix.border.width + systray.area.paddingxlr; posx = systray.area.posx + systray.area.pix.border.width + systray.area.paddingxlr;
} }
else { else {
max_line_pos = sysbar->area.posx+sysbar->area.width - sysbar->area.pix.border.width - sysbar->area.paddingy - icon_size;
posx = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy; posx = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
posy = systray.area.posy + systray.area.pix.border.width + systray.area.paddingxlr; posy = systray.area.posy + systray.area.pix.border.width + systray.area.paddingxlr;
} }
for (l = systray.list_icons; l ; l = l->next) { for (l = systray.list_icons; l ; l = l->next) {
traywin = (TrayWindow*)l->data; traywin = (TrayWindow*)l->data;
if (traywin->hide) continue; if (traywin->hide) continue;
@@ -159,10 +174,22 @@ void resize_systray(void *obj)
traywin->x = posx; traywin->x = posx;
traywin->width = icon_size; traywin->width = icon_size;
traywin->height = icon_size; traywin->height = icon_size;
if (panel_horizontal) if (panel_horizontal) {
posx += (icon_size + systray.area.paddingx); if (posy + icon_size + sysbar->area.paddingxlr < max_line_pos)
else posy += icon_size + sysbar->area.paddingx;
posy += (icon_size + systray.area.paddingx); else {
posx += (icon_size + systray.area.paddingx);
posy = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
}
}
else {
if (posx + icon_size + sysbar->area.paddingxlr < max_line_pos)
posx += icon_size + systray.area.paddingx;
else {
posy += (icon_size + systray.area.paddingx);
posx = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
}
}
// position and size the icon window // position and size the icon window
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size); XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
@@ -305,7 +332,6 @@ gboolean add_icon(Window id)
error = FALSE; error = FALSE;
int wrong_format = 0; int wrong_format = 0;
old = XSetErrorHandler(window_error_handler);
XWindowAttributes attr; XWindowAttributes attr;
XGetWindowAttributes(server.dsp, id, &attr); XGetWindowAttributes(server.dsp, id, &attr);
XSetWindowAttributes set_attr; XSetWindowAttributes set_attr;
@@ -319,6 +345,7 @@ gboolean add_icon(Window id)
parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, attr.visual, mask, &set_attr); parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, attr.visual, mask, &set_attr);
else else
parent_window = panel->main_win; parent_window = panel->main_win;
old = XSetErrorHandler(window_error_handler);
XReparentWindow(server.dsp, id, parent_window, 0, 0); XReparentWindow(server.dsp, id, parent_window, 0, 0);
XSync(server.dsp, False); XSync(server.dsp, False);
XSetErrorHandler(old); XSetErrorHandler(old);

View File

@@ -45,6 +45,7 @@ extern Window net_sel_win;
extern Systraybar systray; extern Systraybar systray;
extern int refresh_systray; extern int refresh_systray;
extern int systray_enabled; extern int systray_enabled;
extern int systray_max_icon_size;
void init_systray(); void init_systray();
void init_systray_panel(void *p); void init_systray_panel(void *p);

View File

@@ -73,7 +73,6 @@ void init (int argc, char *argv[])
snapshot_path = strdup(argv[i]); snapshot_path = strdup(argv[i]);
} }
} }
// Set signal handler // Set signal handler
struct sigaction sa = { .sa_handler = signal_handler }; struct sigaction sa = { .sa_handler = signal_handler };
sigaction(SIGUSR1, &sa, 0); sigaction(SIGUSR1, &sa, 0);
@@ -89,11 +88,13 @@ void init (int argc, char *argv[])
sigaddset(&block_mask, SIGUSR1); sigaddset(&block_mask, SIGUSR1);
sigprocmask(SIG_BLOCK, &block_mask, 0); sigprocmask(SIG_BLOCK, &block_mask, 0);
// set global data // set global data
memset(&server, 0, sizeof(Server_global)); memset(&server, 0, sizeof(Server_global));
// memset(&systray, 0, sizeof(Systraybar)); memset(&systray, 0, sizeof(Systraybar));
}
void init_X11()
{
server.dsp = XOpenDisplay (NULL); server.dsp = XOpenDisplay (NULL);
if (!server.dsp) { if (!server.dsp) {
fprintf(stderr, "tint2 exit : could not open display.\n"); fprintf(stderr, "tint2 exit : could not open display.\n");
@@ -119,6 +120,7 @@ void init (int argc, char *argv[])
gchar *path; gchar *path;
const gchar * const *data_dirs; const gchar * const *data_dirs;
data_dirs = g_get_system_data_dirs (); data_dirs = g_get_system_data_dirs ();
int i;
for (i = 0; data_dirs[i] != NULL; i++) { for (i = 0; data_dirs[i] != NULL; i++) {
path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL); path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS)) if (g_file_test (path, G_FILE_TEST_EXISTS))
@@ -681,6 +683,7 @@ int main (int argc, char *argv[])
GSList *it; GSList *it;
const struct timespec* timeout; const struct timespec* timeout;
init (argc, argv);
init_config(); init_config();
i = 0; i = 0;
if (config_path) if (config_path)
@@ -693,8 +696,7 @@ int main (int argc, char *argv[])
exit(1); exit(1);
} }
init (argc, argv); init_X11();
init_panel(); init_panel();
cleanup_config(); cleanup_config();
if (snapshot_path) { if (snapshot_path) {