all repos — tint2 @ babda8e268d485c63d0c9267107242baa6d36841

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

support skip_taskbar by Andreas.Fink85

git-svn-id: http://tint2.googlecode.com/svn/trunk@169 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
lorthiois@bbsoft.fr lorthiois@bbsoft.fr@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

babda8e268d485c63d0c9267107242baa6d36841

parent

a17b62f76fb3ac482ef8b19743450e97022f6a94

M ChangeLogChangeLog

@@ -1,3 +1,7 @@

+2009-09-07 +- fixed issue 117 : support skip_taskbar by Andreas.Fink85 +- cleanup : switch space to tab + 2009-09-01 - fixed segfault
M src/battery/battery.csrc/battery/battery.c

@@ -94,9 +94,9 @@ g_free(path1);

} FILE *fp; - Panel *panel; - Battery *battery; - int i, bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink; + Panel *panel; + Battery *battery; + int i, bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink; for (i=0 ; i < nb_panel ; i++) { panel = &panel1[i];

@@ -268,7 +268,7 @@

void resize_battery(void *obj) { - Battery *battery = obj; + Battery *battery = obj; PangoLayout *layout; int percentage_width, time_width, new_width;
M src/clock/clock.csrc/clock/clock.c

@@ -56,9 +56,9 @@

void init_clock() { - Panel *panel; - Clock *clock; - int i, time_height, time_height_ink, date_height, date_height_ink; + Panel *panel; + Clock *clock; + int i, time_height, time_height_ink, date_height, date_height_ink; init_precision(); // update clock to force update (-time_precision)

@@ -68,8 +68,8 @@ time_clock.tv_sec = stv.tv_sec - time_precision;

time_clock.tv_sec -= time_clock.tv_sec % time_precision; for (i=0 ; i < nb_panel ; i++) { - panel = &panel1[i]; - clock = &panel->clock; + panel = &panel1[i]; + clock = &panel->clock; if (!clock->area.on_screen) continue;

@@ -114,64 +114,64 @@

void draw_clock (void *obj, cairo_t *c, int active) { - Clock *clock = obj; - PangoLayout *layout; + Clock *clock = obj; + PangoLayout *layout; - layout = pango_cairo_create_layout (c); + layout = pango_cairo_create_layout (c); - // draw layout - pango_layout_set_font_description (layout, time1_font_desc); - pango_layout_set_width (layout, clock->area.width * PANGO_SCALE); - pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); - pango_layout_set_text (layout, buf_time, strlen(buf_time)); + // draw layout + pango_layout_set_font_description (layout, time1_font_desc); + pango_layout_set_width (layout, clock->area.width * PANGO_SCALE); + pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); + pango_layout_set_text (layout, buf_time, strlen(buf_time)); - cairo_set_source_rgba (c, clock->font.color[0], clock->font.color[1], clock->font.color[2], clock->font.alpha); + cairo_set_source_rgba (c, clock->font.color[0], clock->font.color[1], clock->font.color[2], clock->font.alpha); - pango_cairo_update_layout (c, layout); - cairo_move_to (c, 0, clock->time1_posy); - pango_cairo_show_layout (c, layout); + pango_cairo_update_layout (c, layout); + cairo_move_to (c, 0, clock->time1_posy); + pango_cairo_show_layout (c, layout); - if (time2_format) { - pango_layout_set_font_description (layout, time2_font_desc); - pango_layout_set_indent(layout, 0); - pango_layout_set_text (layout, buf_date, strlen(buf_date)); - pango_layout_set_width (layout, clock->area.width * PANGO_SCALE); + if (time2_format) { + pango_layout_set_font_description (layout, time2_font_desc); + pango_layout_set_indent(layout, 0); + pango_layout_set_text (layout, buf_date, strlen(buf_date)); + pango_layout_set_width (layout, clock->area.width * PANGO_SCALE); - pango_cairo_update_layout (c, layout); - cairo_move_to (c, 0, clock->time2_posy); - pango_cairo_show_layout (c, layout); - } + pango_cairo_update_layout (c, layout); + cairo_move_to (c, 0, clock->time2_posy); + pango_cairo_show_layout (c, layout); + } - g_object_unref (layout); + g_object_unref (layout); } void resize_clock (void *obj) { - Clock *clock = obj; - PangoLayout *layout; - int time_width, date_width, new_width; + Clock *clock = obj; + PangoLayout *layout; + int time_width, date_width, new_width; - clock->area.redraw = 1; - time_width = date_width = 0; - strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec)); - if (time2_format) - strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec)); + clock->area.redraw = 1; + time_width = date_width = 0; + strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec)); + if (time2_format) + strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec)); // vertical panel doen't adjust width if (!panel_horizontal) return; - //printf(" resize_clock\n"); - cairo_surface_t *cs; - cairo_t *c; + //printf(" resize_clock\n"); + cairo_surface_t *cs; + cairo_t *c; Pixmap pmap; pmap = XCreatePixmap (server.dsp, server.root_win, clock->area.width, clock->area.height, server.depth); - cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, clock->area.width, clock->area.height); - c = cairo_create (cs); - layout = pango_cairo_create_layout (c); + cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, clock->area.width, clock->area.height); + c = cairo_create (cs); + layout = pango_cairo_create_layout (c); - // check width + // check width pango_layout_set_font_description (layout, time1_font_desc); pango_layout_set_indent(layout, 0); pango_layout_set_text (layout, buf_time, strlen(buf_time));

@@ -187,28 +187,28 @@ if (time_width > date_width) new_width = time_width;

else new_width = date_width; new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width); - if (new_width > clock->area.width || new_width < (clock->area.width-6)) { - Panel *panel = ((Area*)obj)->panel; + if (new_width > clock->area.width || new_width < (clock->area.width-6)) { + Panel *panel = ((Area*)obj)->panel; - // resize clock - // we try to limit the number of resize - // printf("clock_width %d, new_width %d\n", clock->area.width, new_width); + // resize clock + // we try to limit the number of resize + // printf("clock_width %d, new_width %d\n", clock->area.width, new_width); clock->area.width = new_width + 1; clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width; - // resize other objects on panel + // resize other objects on panel panel->area.resize = 1; #ifdef ENABLE_BATTERY panel->battery.area.resize = 1; #endif systray.area.resize = 1; panel_refresh = 1; - } + } - g_object_unref (layout); - cairo_destroy (c); - cairo_surface_destroy (cs); - XFreePixmap (server.dsp, pmap); + g_object_unref (layout); + cairo_destroy (c); + cairo_surface_destroy (cs); + XFreePixmap (server.dsp, pmap); }
M src/config.csrc/config.c

@@ -77,11 +77,11 @@ void init_config()

{ cleanup_panel(); - // get monitor and desktop config - get_monitors_and_desktops(); + // get monitor and desktop config + get_monitors_and_desktops(); - // append full transparency background - list_back = g_slist_append(0, calloc(1, sizeof(Area))); + // append full transparency background + list_back = g_slist_append(0, calloc(1, sizeof(Area))); panel_config = calloc(1, sizeof(Panel)); systray.sort = 1;

@@ -97,50 +97,50 @@ {

free(panel_config); panel_config = 0; - // cleanup background list - GSList *l0; - for (l0 = list_back; l0 ; l0 = l0->next) { - free(l0->data); - } - g_slist_free(list_back); - list_back = NULL; + // cleanup background list + GSList *l0; + for (l0 = list_back; l0 ; l0 = l0->next) { + free(l0->data); + } + g_slist_free(list_back); + list_back = NULL; } void copy_file(const char *pathSrc, const char *pathDest) { - FILE *fileSrc, *fileDest; - char line[100]; - int nb; + FILE *fileSrc, *fileDest; + char line[100]; + int nb; - fileSrc = fopen(pathSrc, "rb"); - if (fileSrc == NULL) return; + fileSrc = fopen(pathSrc, "rb"); + if (fileSrc == NULL) return; - fileDest = fopen(pathDest, "wb"); - if (fileDest == NULL) return; + fileDest = fopen(pathDest, "wb"); + if (fileDest == NULL) return; - while ((nb = fread(line, 1, 100, fileSrc)) > 0) fwrite(line, 1, nb, fileDest); + while ((nb = fread(line, 1, 100, fileSrc)) > 0) fwrite(line, 1, nb, fileDest); - fclose (fileDest); - fclose (fileSrc); + fclose (fileDest); + fclose (fileSrc); } void extract_values (const char *value, char **value1, char **value2, char **value3) { - char *b=0, *c=0; + char *b=0, *c=0; - if (*value1) free (*value1); - if (*value2) free (*value2); - if (*value3) free (*value3); + if (*value1) free (*value1); + if (*value2) free (*value2); + if (*value3) free (*value3); - if ((b = strchr (value, ' '))) { - b[0] = '\0'; - b++; + if ((b = strchr (value, ' '))) { + b[0] = '\0'; + b++; } else { - *value2 = 0; - *value3 = 0; + *value2 = 0; + *value3 = 0; } *value1 = strdup (value); g_strstrip(*value1);

@@ -167,182 +167,182 @@

int hex_char_to_int (char c) { - int r; + int r; - if (c >= '0' && c <= '9') r = c - '0'; - else if (c >= 'a' && c <= 'f') r = c - 'a' + 10; - else if (c >= 'A' && c <= 'F') r = c - 'A' + 10; - else r = 0; + if (c >= '0' && c <= '9') r = c - '0'; + else if (c >= 'a' && c <= 'f') r = c - 'a' + 10; + else if (c >= 'A' && c <= 'F') r = c - 'A' + 10; + else r = 0; - return r; + return r; } int hex_to_rgb (char *hex, int *r, int *g, int *b) { - int len; + int len; - if (hex == NULL || hex[0] != '#') return (0); + if (hex == NULL || hex[0] != '#') return (0); - len = strlen (hex); - if (len == 3 + 1) { - *r = hex_char_to_int (hex[1]); - *g = hex_char_to_int (hex[2]); - *b = hex_char_to_int (hex[3]); - } - else if (len == 6 + 1) { - *r = hex_char_to_int (hex[1]) * 16 + hex_char_to_int (hex[2]); - *g = hex_char_to_int (hex[3]) * 16 + hex_char_to_int (hex[4]); - *b = hex_char_to_int (hex[5]) * 16 + hex_char_to_int (hex[6]); - } - else if (len == 12 + 1) { - *r = hex_char_to_int (hex[1]) * 16 + hex_char_to_int (hex[2]); - *g = hex_char_to_int (hex[5]) * 16 + hex_char_to_int (hex[6]); - *b = hex_char_to_int (hex[9]) * 16 + hex_char_to_int (hex[10]); - } - else return 0; + len = strlen (hex); + if (len == 3 + 1) { + *r = hex_char_to_int (hex[1]); + *g = hex_char_to_int (hex[2]); + *b = hex_char_to_int (hex[3]); + } + else if (len == 6 + 1) { + *r = hex_char_to_int (hex[1]) * 16 + hex_char_to_int (hex[2]); + *g = hex_char_to_int (hex[3]) * 16 + hex_char_to_int (hex[4]); + *b = hex_char_to_int (hex[5]) * 16 + hex_char_to_int (hex[6]); + } + else if (len == 12 + 1) { + *r = hex_char_to_int (hex[1]) * 16 + hex_char_to_int (hex[2]); + *g = hex_char_to_int (hex[5]) * 16 + hex_char_to_int (hex[6]); + *b = hex_char_to_int (hex[9]) * 16 + hex_char_to_int (hex[10]); + } + else return 0; - return 1; + return 1; } void get_color (char *hex, double *rgb) { - int r, g, b; - hex_to_rgb (hex, &r, &g, &b); + int r, g, b; + hex_to_rgb (hex, &r, &g, &b); - rgb[0] = (r / 255.0); - rgb[1] = (g / 255.0); - rgb[2] = (b / 255.0); + rgb[0] = (r / 255.0); + rgb[1] = (g / 255.0); + rgb[2] = (b / 255.0); } void get_action (char *event, int *action) { - if (strcmp (event, "none") == 0) - *action = NONE; - else if (strcmp (event, "close") == 0) - *action = CLOSE; - else if (strcmp (event, "toggle") == 0) - *action = TOGGLE; - else if (strcmp (event, "iconify") == 0) - *action = ICONIFY; - else if (strcmp (event, "shade") == 0) - *action = SHADE; - else if (strcmp (event, "toggle_iconify") == 0) - *action = TOGGLE_ICONIFY; - else if (strcmp (event, "maximize_restore") == 0) - *action = MAXIMIZE_RESTORE; - else if (strcmp (event, "desktop_left") == 0) - *action = DESKTOP_LEFT; - else if (strcmp (event, "desktop_right") == 0) - *action = DESKTOP_RIGHT; + if (strcmp (event, "none") == 0) + *action = NONE; + else if (strcmp (event, "close") == 0) + *action = CLOSE; + else if (strcmp (event, "toggle") == 0) + *action = TOGGLE; + else if (strcmp (event, "iconify") == 0) + *action = ICONIFY; + else if (strcmp (event, "shade") == 0) + *action = SHADE; + else if (strcmp (event, "toggle_iconify") == 0) + *action = TOGGLE_ICONIFY; + else if (strcmp (event, "maximize_restore") == 0) + *action = MAXIMIZE_RESTORE; + else if (strcmp (event, "desktop_left") == 0) + *action = DESKTOP_LEFT; + else if (strcmp (event, "desktop_right") == 0) + *action = DESKTOP_RIGHT; } void add_entry (char *key, char *value) { - char *value1=0, *value2=0, *value3=0; + char *value1=0, *value2=0, *value3=0; - /* Background and border */ - if (strcmp (key, "rounded") == 0) { - // 'rounded' is the first parameter => alloc a new background - Area *a = calloc(1, sizeof(Area)); - a->pix.border.rounded = atoi (value); - list_back = g_slist_append(list_back, a); - } - else if (strcmp (key, "border_width") == 0) { - Area *a = g_slist_last(list_back)->data; - a->pix.border.width = atoi (value); - } - else if (strcmp (key, "background_color") == 0) { - Area *a = g_slist_last(list_back)->data; - extract_values(value, &value1, &value2, &value3); - get_color (value1, a->pix.back.color); - if (value2) a->pix.back.alpha = (atoi (value2) / 100.0); - else a->pix.back.alpha = 0.5; - } - else if (strcmp (key, "border_color") == 0) { - Area *a = g_slist_last(list_back)->data; - extract_values(value, &value1, &value2, &value3); - get_color (value1, a->pix.border.color); - if (value2) a->pix.border.alpha = (atoi (value2) / 100.0); - else a->pix.border.alpha = 0.5; - } + /* Background and border */ + if (strcmp (key, "rounded") == 0) { + // 'rounded' is the first parameter => alloc a new background + Area *a = calloc(1, sizeof(Area)); + a->pix.border.rounded = atoi (value); + list_back = g_slist_append(list_back, a); + } + else if (strcmp (key, "border_width") == 0) { + Area *a = g_slist_last(list_back)->data; + a->pix.border.width = atoi (value); + } + else if (strcmp (key, "background_color") == 0) { + Area *a = g_slist_last(list_back)->data; + extract_values(value, &value1, &value2, &value3); + get_color (value1, a->pix.back.color); + if (value2) a->pix.back.alpha = (atoi (value2) / 100.0); + else a->pix.back.alpha = 0.5; + } + else if (strcmp (key, "border_color") == 0) { + Area *a = g_slist_last(list_back)->data; + extract_values(value, &value1, &value2, &value3); + get_color (value1, a->pix.border.color); + if (value2) a->pix.border.alpha = (atoi (value2) / 100.0); + else a->pix.border.alpha = 0.5; + } - /* Panel */ - else if (strcmp (key, "panel_monitor") == 0) { - if (strcmp (value, "all") == 0) panel_config->monitor = -1; - else { - panel_config->monitor = atoi (value); - if (panel_config->monitor > 0) panel_config->monitor -= 1; + /* Panel */ + else if (strcmp (key, "panel_monitor") == 0) { + if (strcmp (value, "all") == 0) panel_config->monitor = -1; + else { + panel_config->monitor = atoi (value); + if (panel_config->monitor > 0) panel_config->monitor -= 1; } - } - else if (strcmp (key, "panel_size") == 0) { - extract_values(value, &value1, &value2, &value3); + } + else if (strcmp (key, "panel_size") == 0) { + extract_values(value, &value1, &value2, &value3); char *b; if ((b = strchr (value1, '%'))) { b[0] = '\0'; - panel_config->pourcentx = 1; + panel_config->pourcentx = 1; } - panel_config->initial_width = atof(value1); - if (value2) { + panel_config->initial_width = atof(value1); + if (value2) { if ((b = strchr (value2, '%'))) { b[0] = '\0'; panel_config->pourcenty = 1; } - panel_config->initial_height = atof(value2); + panel_config->initial_height = atof(value2); } - } - else if (strcmp (key, "panel_margin") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config->marginx = atoi (value1); - if (value2) panel_config->marginy = atoi (value2); - } - else if (strcmp (key, "panel_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config->area.paddingxlr = panel_config->area.paddingx = atoi (value1); - if (value2) panel_config->area.paddingy = atoi (value2); - if (value3) panel_config->area.paddingx = atoi (value3); - } - else if (strcmp (key, "panel_position") == 0) { - extract_values(value, &value1, &value2, &value3); - if (strcmp (value1, "top") == 0) panel_position = TOP; - else { + } + else if (strcmp (key, "panel_margin") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config->marginx = atoi (value1); + if (value2) panel_config->marginy = atoi (value2); + } + else if (strcmp (key, "panel_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config->area.paddingxlr = panel_config->area.paddingx = atoi (value1); + if (value2) panel_config->area.paddingy = atoi (value2); + if (value3) panel_config->area.paddingx = atoi (value3); + } + else if (strcmp (key, "panel_position") == 0) { + extract_values(value, &value1, &value2, &value3); + if (strcmp (value1, "top") == 0) panel_position = TOP; + else { if (strcmp (value1, "bottom") == 0) panel_position = BOTTOM; else panel_position = CENTER; } - if (!value2) panel_position |= CENTER; - else { - if (strcmp (value2, "left") == 0) panel_position |= LEFT; - else { - if (strcmp (value2, "right") == 0) panel_position |= RIGHT; - else panel_position |= CENTER; - } - } - if (!value3) panel_horizontal = 1; - else { - if (strcmp (value3, "vertical") == 0) panel_horizontal = 0; - else panel_horizontal = 1; + if (!value2) panel_position |= CENTER; + else { + if (strcmp (value2, "left") == 0) panel_position |= LEFT; + else { + if (strcmp (value2, "right") == 0) panel_position |= RIGHT; + else panel_position |= CENTER; + } + } + if (!value3) panel_horizontal = 1; + else { + if (strcmp (value3, "vertical") == 0) panel_horizontal = 0; + else panel_horizontal = 1; } - } - else if (strcmp (key, "font_shadow") == 0) - panel_config->g_task.font_shadow = atoi (value); - else if (strcmp (key, "panel_background_id") == 0) { - int id = atoi (value); - Area *a = g_slist_nth_data(list_back, id); - memcpy(&panel_config->area.pix.back, &a->pix.back, sizeof(Color)); - memcpy(&panel_config->area.pix.border, &a->pix.border, sizeof(Border)); - } - else if (strcmp (key, "wm_menu") == 0) - wm_menu = atoi (value); - else if (strcmp (key, "urgent_nb_of_blink") == 0) - max_tick_urgent = (atoi (value) * 2) + 1; + } + else if (strcmp (key, "font_shadow") == 0) + panel_config->g_task.font_shadow = atoi (value); + else if (strcmp (key, "panel_background_id") == 0) { + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&panel_config->area.pix.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->area.pix.border, &a->pix.border, sizeof(Border)); + } + else if (strcmp (key, "wm_menu") == 0) + wm_menu = atoi (value); + else if (strcmp (key, "urgent_nb_of_blink") == 0) + max_tick_urgent = (atoi (value) * 2) + 1; - /* Battery */ - else if (strcmp (key, "battery") == 0) { + /* Battery */ + else if (strcmp (key, "battery") == 0) { #ifdef ENABLE_BATTERY if(atoi(value) == 1) panel_config->battery.area.on_screen = 1;

@@ -350,105 +350,105 @@ #else

if(atoi(value) == 1) fprintf(stderr, "tint2 is build without battery support\n"); #endif - } - else if (strcmp (key, "battery_low_status") == 0) { + } + else if (strcmp (key, "battery_low_status") == 0) { #ifdef ENABLE_BATTERY battery_low_status = atoi(value); if(battery_low_status < 0 || battery_low_status > 100) battery_low_status = 0; #endif - } - else if (strcmp (key, "battery_low_cmd") == 0) { + } + else if (strcmp (key, "battery_low_cmd") == 0) { #ifdef ENABLE_BATTERY - if (battery_low_cmd) g_free(battery_low_cmd); - if (strlen(value) > 0) battery_low_cmd = strdup (value); - else battery_low_cmd = 0; + if (battery_low_cmd) g_free(battery_low_cmd); + if (strlen(value) > 0) battery_low_cmd = strdup (value); + else battery_low_cmd = 0; #endif - } - else if (strcmp (key, "bat1_font") == 0) { + } + else if (strcmp (key, "bat1_font") == 0) { #ifdef ENABLE_BATTERY - if (save_file_config) old_bat1_font = strdup (value); - if (bat1_font_desc) pango_font_description_free(bat1_font_desc); - bat1_font_desc = pango_font_description_from_string (value); + if (save_file_config) old_bat1_font = strdup (value); + if (bat1_font_desc) pango_font_description_free(bat1_font_desc); + bat1_font_desc = pango_font_description_from_string (value); #endif - } - else if (strcmp (key, "bat2_font") == 0) { + } + else if (strcmp (key, "bat2_font") == 0) { #ifdef ENABLE_BATTERY - if (save_file_config) old_bat2_font = strdup (value); - if (bat2_font_desc) pango_font_description_free(bat2_font_desc); - bat2_font_desc = pango_font_description_from_string (value); + if (save_file_config) old_bat2_font = strdup (value); + if (bat2_font_desc) pango_font_description_free(bat2_font_desc); + bat2_font_desc = pango_font_description_from_string (value); #endif - } - else if (strcmp (key, "battery_font_color") == 0) { + } + else if (strcmp (key, "battery_font_color") == 0) { #ifdef ENABLE_BATTERY - extract_values(value, &value1, &value2, &value3); - get_color (value1, panel_config->battery.font.color); - if (value2) panel_config->battery.font.alpha = (atoi (value2) / 100.0); - else panel_config->battery.font.alpha = 0.5; + extract_values(value, &value1, &value2, &value3); + get_color (value1, panel_config->battery.font.color); + if (value2) panel_config->battery.font.alpha = (atoi (value2) / 100.0); + else panel_config->battery.font.alpha = 0.5; #endif - } - else if (strcmp (key, "battery_padding") == 0) { + } + else if (strcmp (key, "battery_padding") == 0) { #ifdef ENABLE_BATTERY - extract_values(value, &value1, &value2, &value3); - panel_config->battery.area.paddingxlr = panel_config->battery.area.paddingx = atoi (value1); - if (value2) panel_config->battery.area.paddingy = atoi (value2); - if (value3) panel_config->battery.area.paddingx = atoi (value3); + extract_values(value, &value1, &value2, &value3); + panel_config->battery.area.paddingxlr = panel_config->battery.area.paddingx = atoi (value1); + if (value2) panel_config->battery.area.paddingy = atoi (value2); + if (value3) panel_config->battery.area.paddingx = atoi (value3); #endif - } - else if (strcmp (key, "battery_background_id") == 0) { + } + else if (strcmp (key, "battery_background_id") == 0) { #ifdef ENABLE_BATTERY - int id = atoi (value); - Area *a = g_slist_nth_data(list_back, id); - memcpy(&panel_config->battery.area.pix.back, &a->pix.back, sizeof(Color)); - memcpy(&panel_config->battery.area.pix.border, &a->pix.border, sizeof(Border)); + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&panel_config->battery.area.pix.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->battery.area.pix.border, &a->pix.border, sizeof(Border)); #endif - } + } - /* Clock */ - else if (strcmp (key, "time1_format") == 0) { - if (time1_format) g_free(time1_format); - if (strlen(value) > 0) { - time1_format = strdup (value); - panel_config->clock.area.on_screen = 1; + /* Clock */ + else if (strcmp (key, "time1_format") == 0) { + if (time1_format) g_free(time1_format); + if (strlen(value) > 0) { + time1_format = strdup (value); + panel_config->clock.area.on_screen = 1; } - else { - time1_format = 0; - panel_config->clock.area.on_screen = 0; + else { + time1_format = 0; + panel_config->clock.area.on_screen = 0; } - } - else if (strcmp (key, "time2_format") == 0) { - if (time2_format) g_free(time2_format); - if (strlen(value) > 0) time2_format = strdup (value); - else time2_format = 0; - } - else if (strcmp (key, "time1_font") == 0) { - if (save_file_config) old_time1_font = strdup (value); - if (time1_font_desc) pango_font_description_free(time1_font_desc); - time1_font_desc = pango_font_description_from_string (value); - } - else if (strcmp (key, "time2_font") == 0) { - if (save_file_config) old_time2_font = strdup (value); - if (time2_font_desc) pango_font_description_free(time2_font_desc); - time2_font_desc = pango_font_description_from_string (value); - } - else if (strcmp (key, "clock_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color (value1, panel_config->clock.font.color); - if (value2) panel_config->clock.font.alpha = (atoi (value2) / 100.0); - else panel_config->clock.font.alpha = 0.5; - } - else if (strcmp (key, "clock_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config->clock.area.paddingxlr = panel_config->clock.area.paddingx = atoi (value1); - if (value2) panel_config->clock.area.paddingy = atoi (value2); - if (value3) panel_config->clock.area.paddingx = atoi (value3); - } - else if (strcmp (key, "clock_background_id") == 0) { - int id = atoi (value); - Area *a = g_slist_nth_data(list_back, id); - memcpy(&panel_config->clock.area.pix.back, &a->pix.back, sizeof(Color)); - memcpy(&panel_config->clock.area.pix.border, &a->pix.border, sizeof(Border)); - } + } + else if (strcmp (key, "time2_format") == 0) { + if (time2_format) g_free(time2_format); + if (strlen(value) > 0) time2_format = strdup (value); + else time2_format = 0; + } + else if (strcmp (key, "time1_font") == 0) { + if (save_file_config) old_time1_font = strdup (value); + if (time1_font_desc) pango_font_description_free(time1_font_desc); + time1_font_desc = pango_font_description_from_string (value); + } + else if (strcmp (key, "time2_font") == 0) { + if (save_file_config) old_time2_font = strdup (value); + if (time2_font_desc) pango_font_description_free(time2_font_desc); + time2_font_desc = pango_font_description_from_string (value); + } + else if (strcmp (key, "clock_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, panel_config->clock.font.color); + if (value2) panel_config->clock.font.alpha = (atoi (value2) / 100.0); + else panel_config->clock.font.alpha = 0.5; + } + else if (strcmp (key, "clock_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config->clock.area.paddingxlr = panel_config->clock.area.paddingx = atoi (value1); + if (value2) panel_config->clock.area.paddingy = atoi (value2); + if (value3) panel_config->clock.area.paddingx = atoi (value3); + } + else if (strcmp (key, "clock_background_id") == 0) { + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&panel_config->clock.area.pix.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->clock.area.pix.border, &a->pix.border, sizeof(Border)); + } else if (strcmp(key, "clock_lclick_command") == 0) { if (clock_lclick_command) g_free(clock_lclick_command); if (strlen(value) > 0) clock_lclick_command = strdup(value);

@@ -460,112 +460,112 @@ if (strlen(value) > 0) clock_rclick_command = strdup(value);

else clock_rclick_command = 0; } - /* Taskbar */ - else if (strcmp (key, "taskbar_mode") == 0) { - if (strcmp (value, "multi_desktop") == 0) panel_mode = MULTI_DESKTOP; - else panel_mode = SINGLE_DESKTOP; - } - else if (strcmp (key, "taskbar_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config->g_taskbar.paddingxlr = panel_config->g_taskbar.paddingx = atoi (value1); - if (value2) panel_config->g_taskbar.paddingy = atoi (value2); - if (value3) panel_config->g_taskbar.paddingx = atoi (value3); - } - else if (strcmp (key, "taskbar_background_id") == 0) { - int id = atoi (value); - Area *a = g_slist_nth_data(list_back, id); - memcpy(&panel_config->g_taskbar.pix.back, &a->pix.back, sizeof(Color)); - memcpy(&panel_config->g_taskbar.pix.border, &a->pix.border, sizeof(Border)); - } - else if (strcmp (key, "taskbar_active_background_id") == 0) { - int id = atoi (value); - Area *a = g_slist_nth_data(list_back, id); - memcpy(&panel_config->g_taskbar.pix_active.back, &a->pix.back, sizeof(Color)); - memcpy(&panel_config->g_taskbar.pix_active.border, &a->pix.border, sizeof(Border)); + /* Taskbar */ + else if (strcmp (key, "taskbar_mode") == 0) { + if (strcmp (value, "multi_desktop") == 0) panel_mode = MULTI_DESKTOP; + else panel_mode = SINGLE_DESKTOP; + } + else if (strcmp (key, "taskbar_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config->g_taskbar.paddingxlr = panel_config->g_taskbar.paddingx = atoi (value1); + if (value2) panel_config->g_taskbar.paddingy = atoi (value2); + if (value3) panel_config->g_taskbar.paddingx = atoi (value3); + } + else if (strcmp (key, "taskbar_background_id") == 0) { + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&panel_config->g_taskbar.pix.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->g_taskbar.pix.border, &a->pix.border, sizeof(Border)); + } + else if (strcmp (key, "taskbar_active_background_id") == 0) { + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&panel_config->g_taskbar.pix_active.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->g_taskbar.pix_active.border, &a->pix.border, sizeof(Border)); panel_config->g_taskbar.use_active = 1; - } + } - /* Task */ - else if (strcmp (key, "task_text") == 0) - panel_config->g_task.text = atoi (value); - else if (strcmp (key, "task_icon") == 0) - panel_config->g_task.icon = atoi (value); - else if (strcmp (key, "task_centered") == 0) - panel_config->g_task.centered = atoi (value); - else if (strcmp (key, "task_width") == 0) { + /* Task */ + else if (strcmp (key, "task_text") == 0) + panel_config->g_task.text = atoi (value); + else if (strcmp (key, "task_icon") == 0) + panel_config->g_task.icon = atoi (value); + else if (strcmp (key, "task_centered") == 0) + panel_config->g_task.centered = atoi (value); + else if (strcmp (key, "task_width") == 0) { // old parameter : just for backward compatibility - panel_config->g_task.maximum_width = atoi (value); - panel_config->g_task.maximum_height = 30; + panel_config->g_task.maximum_width = atoi (value); + panel_config->g_task.maximum_height = 30; } - else if (strcmp (key, "task_maximum_size") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config->g_task.maximum_width = atoi (value1); + else if (strcmp (key, "task_maximum_size") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config->g_task.maximum_width = atoi (value1); panel_config->g_task.maximum_height = 30; if (value2) - panel_config->g_task.maximum_height = atoi (value2); + panel_config->g_task.maximum_height = atoi (value2); } - else if (strcmp (key, "task_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - panel_config->g_task.area.paddingxlr = panel_config->g_task.area.paddingx = atoi (value1); - if (value2) panel_config->g_task.area.paddingy = atoi (value2); - if (value3) panel_config->g_task.area.paddingx = atoi (value3); - } - else if (strcmp (key, "task_font") == 0) { - if (save_file_config) old_task_font = strdup (value); - if (panel_config->g_task.font_desc) pango_font_description_free(panel_config->g_task.font_desc); - panel_config->g_task.font_desc = pango_font_description_from_string (value); - } - else if (strcmp (key, "task_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color (value1, panel_config->g_task.font.color); - if (value2) panel_config->g_task.font.alpha = (atoi (value2) / 100.0); - else panel_config->g_task.font.alpha = 0.1; - } - else if (strcmp (key, "task_active_font_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color (value1, panel_config->g_task.font_active.color); - if (value2) panel_config->g_task.font_active.alpha = (atoi (value2) / 100.0); - else panel_config->g_task.font_active.alpha = 0.1; - } - else if (strcmp (key, "task_icon_hsb") == 0) { - extract_values(value, &value1, &value2, &value3); + else if (strcmp (key, "task_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config->g_task.area.paddingxlr = panel_config->g_task.area.paddingx = atoi (value1); + if (value2) panel_config->g_task.area.paddingy = atoi (value2); + if (value3) panel_config->g_task.area.paddingx = atoi (value3); + } + else if (strcmp (key, "task_font") == 0) { + if (save_file_config) old_task_font = strdup (value); + if (panel_config->g_task.font_desc) pango_font_description_free(panel_config->g_task.font_desc); + panel_config->g_task.font_desc = pango_font_description_from_string (value); + } + else if (strcmp (key, "task_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, panel_config->g_task.font.color); + if (value2) panel_config->g_task.font.alpha = (atoi (value2) / 100.0); + else panel_config->g_task.font.alpha = 0.1; + } + else if (strcmp (key, "task_active_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, panel_config->g_task.font_active.color); + if (value2) panel_config->g_task.font_active.alpha = (atoi (value2) / 100.0); + else panel_config->g_task.font_active.alpha = 0.1; + } + else if (strcmp (key, "task_icon_hsb") == 0) { + extract_values(value, &value1, &value2, &value3); panel_config->g_task.hue = atoi(value1); panel_config->g_task.saturation = atoi(value2); panel_config->g_task.brightness = atoi(value3); - } - else if (strcmp (key, "task_active_icon_hsb") == 0) { - extract_values(value, &value1, &value2, &value3); + } + else if (strcmp (key, "task_active_icon_hsb") == 0) { + extract_values(value, &value1, &value2, &value3); panel_config->g_task.hue_active = atoi(value1); panel_config->g_task.saturation_active = atoi(value2); panel_config->g_task.brightness_active = atoi(value3); - } - else if (strcmp (key, "task_background_id") == 0) { - int id = atoi (value); - Area *a = g_slist_nth_data(list_back, id); - memcpy(&panel_config->g_task.area.pix.back, &a->pix.back, sizeof(Color)); - memcpy(&panel_config->g_task.area.pix.border, &a->pix.border, sizeof(Border)); - } - else if (strcmp (key, "task_active_background_id") == 0) { - int id = atoi (value); - Area *a = g_slist_nth_data(list_back, id); - memcpy(&panel_config->g_task.area.pix_active.back, &a->pix.back, sizeof(Color)); - memcpy(&panel_config->g_task.area.pix_active.border, &a->pix.border, sizeof(Border)); - } + } + else if (strcmp (key, "task_background_id") == 0) { + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&panel_config->g_task.area.pix.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->g_task.area.pix.border, &a->pix.border, sizeof(Border)); + } + else if (strcmp (key, "task_active_background_id") == 0) { + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&panel_config->g_task.area.pix_active.back, &a->pix.back, sizeof(Color)); + memcpy(&panel_config->g_task.area.pix_active.border, &a->pix.border, sizeof(Border)); + } - /* Systray */ - else if (strcmp (key, "systray_padding") == 0) { - extract_values(value, &value1, &value2, &value3); - systray.area.paddingxlr = systray.area.paddingx = atoi (value1); - if (value2) systray.area.paddingy = atoi (value2); - if (value3) systray.area.paddingx = atoi (value3); - systray.area.on_screen = 1; - } - else if (strcmp (key, "systray_background_id") == 0) { - int id = atoi (value); - Area *a = g_slist_nth_data(list_back, id); - memcpy(&systray.area.pix.back, &a->pix.back, sizeof(Color)); - memcpy(&systray.area.pix.border, &a->pix.border, sizeof(Border)); - } + /* Systray */ + else if (strcmp (key, "systray_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + systray.area.paddingxlr = systray.area.paddingx = atoi (value1); + if (value2) systray.area.paddingy = atoi (value2); + if (value3) systray.area.paddingx = atoi (value3); + systray.area.on_screen = 1; + } + else if (strcmp (key, "systray_background_id") == 0) { + int id = atoi (value); + Area *a = g_slist_nth_data(list_back, id); + memcpy(&systray.area.pix.back, &a->pix.back, sizeof(Color)); + memcpy(&systray.area.pix.border, &a->pix.border, sizeof(Border)); + } else if (strcmp(key, "systray_sort") == 0) { if (strcmp(value, "desc") == 0) systray.sort = -1;

@@ -573,162 +573,162 @@ else

systray.sort = 1; } - /* Mouse actions */ - else if (strcmp (key, "mouse_middle") == 0) - get_action (value, &mouse_middle); - else if (strcmp (key, "mouse_right") == 0) - get_action (value, &mouse_right); - else if (strcmp (key, "mouse_scroll_up") == 0) - get_action (value, &mouse_scroll_up); - else if (strcmp (key, "mouse_scroll_down") == 0) - get_action (value, &mouse_scroll_down); + /* Mouse actions */ + else if (strcmp (key, "mouse_middle") == 0) + get_action (value, &mouse_middle); + else if (strcmp (key, "mouse_right") == 0) + get_action (value, &mouse_right); + else if (strcmp (key, "mouse_scroll_up") == 0) + get_action (value, &mouse_scroll_up); + else if (strcmp (key, "mouse_scroll_down") == 0) + get_action (value, &mouse_scroll_down); - /* Read tint-0.6 config for backward compatibility */ - else if (strcmp (key, "panel_mode") == 0) { + /* Read tint-0.6 config for backward compatibility */ + else if (strcmp (key, "panel_mode") == 0) { save_file_config = 1; - if (strcmp (value, "single_desktop") == 0) panel_mode = SINGLE_DESKTOP; - else panel_mode = MULTI_DESKTOP; - } - else if (strcmp (key, "panel_rounded") == 0) { - Area *a = calloc(1, sizeof(Area)); - a->pix.border.rounded = atoi (value); - list_back = g_slist_append(list_back, a); - } - else if (strcmp (key, "panel_border_width") == 0) { - Area *a = g_slist_last(list_back)->data; - a->pix.border.width = atoi (value); - } - else if (strcmp (key, "panel_background_color") == 0) { - Area *a = g_slist_last(list_back)->data; - extract_values(value, &value1, &value2, &value3); - get_color (value1, a->pix.back.color); - if (value2) a->pix.back.alpha = (atoi (value2) / 100.0); - else a->pix.back.alpha = 0.5; - } - else if (strcmp (key, "panel_border_color") == 0) { - Area *a = g_slist_last(list_back)->data; - extract_values(value, &value1, &value2, &value3); - get_color (value1, a->pix.border.color); - if (value2) a->pix.border.alpha = (atoi (value2) / 100.0); - else a->pix.border.alpha = 0.5; - } - else if (strcmp (key, "task_text_centered") == 0) - panel_config->g_task.centered = atoi (value); - else if (strcmp (key, "task_margin") == 0) { - panel_config->g_taskbar.paddingxlr = 0; - panel_config->g_taskbar.paddingx = atoi (value); - } - else if (strcmp (key, "task_icon_size") == 0) - old_task_icon_size = atoi (value); - else if (strcmp (key, "task_rounded") == 0) { - area_task = calloc(1, sizeof(Area)); - area_task->pix.border.rounded = atoi (value); - list_back = g_slist_append(list_back, area_task); + if (strcmp (value, "single_desktop") == 0) panel_mode = SINGLE_DESKTOP; + else panel_mode = MULTI_DESKTOP; + } + else if (strcmp (key, "panel_rounded") == 0) { + Area *a = calloc(1, sizeof(Area)); + a->pix.border.rounded = atoi (value); + list_back = g_slist_append(list_back, a); + } + else if (strcmp (key, "panel_border_width") == 0) { + Area *a = g_slist_last(list_back)->data; + a->pix.border.width = atoi (value); + } + else if (strcmp (key, "panel_background_color") == 0) { + Area *a = g_slist_last(list_back)->data; + extract_values(value, &value1, &value2, &value3); + get_color (value1, a->pix.back.color); + if (value2) a->pix.back.alpha = (atoi (value2) / 100.0); + else a->pix.back.alpha = 0.5; + } + else if (strcmp (key, "panel_border_color") == 0) { + Area *a = g_slist_last(list_back)->data; + extract_values(value, &value1, &value2, &value3); + get_color (value1, a->pix.border.color); + if (value2) a->pix.border.alpha = (atoi (value2) / 100.0); + else a->pix.border.alpha = 0.5; + } + else if (strcmp (key, "task_text_centered") == 0) + panel_config->g_task.centered = atoi (value); + else if (strcmp (key, "task_margin") == 0) { + panel_config->g_taskbar.paddingxlr = 0; + panel_config->g_taskbar.paddingx = atoi (value); + } + else if (strcmp (key, "task_icon_size") == 0) + old_task_icon_size = atoi (value); + else if (strcmp (key, "task_rounded") == 0) { + area_task = calloc(1, sizeof(Area)); + area_task->pix.border.rounded = atoi (value); + list_back = g_slist_append(list_back, area_task); - area_task_active = calloc(1, sizeof(Area)); - area_task_active->pix.border.rounded = atoi (value); - list_back = g_slist_append(list_back, area_task_active); - } - else if (strcmp (key, "task_background_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color (value1, area_task->pix.back.color); - if (value2) area_task->pix.back.alpha = (atoi (value2) / 100.0); - else area_task->pix.back.alpha = 0.5; - } - else if (strcmp (key, "task_active_background_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color (value1, area_task_active->pix.back.color); - if (value2) area_task_active->pix.back.alpha = (atoi (value2) / 100.0); - else area_task_active->pix.back.alpha = 0.5; - } - else if (strcmp (key, "task_border_width") == 0) { - area_task->pix.border.width = atoi (value); - area_task_active->pix.border.width = atoi (value); - } - else if (strcmp (key, "task_border_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color (value1, area_task->pix.border.color); - if (value2) area_task->pix.border.alpha = (atoi (value2) / 100.0); - else area_task->pix.border.alpha = 0.5; - } - else if (strcmp (key, "task_active_border_color") == 0) { - extract_values(value, &value1, &value2, &value3); - get_color (value1, area_task_active->pix.border.color); - if (value2) area_task_active->pix.border.alpha = (atoi (value2) / 100.0); - else area_task_active->pix.border.alpha = 0.5; - } + area_task_active = calloc(1, sizeof(Area)); + area_task_active->pix.border.rounded = atoi (value); + list_back = g_slist_append(list_back, area_task_active); + } + else if (strcmp (key, "task_background_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, area_task->pix.back.color); + if (value2) area_task->pix.back.alpha = (atoi (value2) / 100.0); + else area_task->pix.back.alpha = 0.5; + } + else if (strcmp (key, "task_active_background_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, area_task_active->pix.back.color); + if (value2) area_task_active->pix.back.alpha = (atoi (value2) / 100.0); + else area_task_active->pix.back.alpha = 0.5; + } + else if (strcmp (key, "task_border_width") == 0) { + area_task->pix.border.width = atoi (value); + area_task_active->pix.border.width = atoi (value); + } + else if (strcmp (key, "task_border_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, area_task->pix.border.color); + if (value2) area_task->pix.border.alpha = (atoi (value2) / 100.0); + else area_task->pix.border.alpha = 0.5; + } + else if (strcmp (key, "task_active_border_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, area_task_active->pix.border.color); + if (value2) area_task_active->pix.border.alpha = (atoi (value2) / 100.0); + else area_task_active->pix.border.alpha = 0.5; + } - else - fprintf(stderr, "tint2 : invalid option \"%s\", correct your config file\n", key); + else + fprintf(stderr, "tint2 : invalid option \"%s\", correct your config file\n", key); - if (value1) free (value1); - if (value2) free (value2); - if (value3) free (value3); + if (value1) free (value1); + if (value2) free (value2); + if (value3) free (value3); } int parse_line (const char *line) { - char *a, *b, *key, *value; + char *a, *b, *key, *value; - /* Skip useless lines */ - if ((line[0] == '#') || (line[0] == '\n')) return 0; - if (!(a = strchr (line, '='))) return 0; + /* Skip useless lines */ + if ((line[0] == '#') || (line[0] == '\n')) return 0; + if (!(a = strchr (line, '='))) return 0; - /* overwrite '=' with '\0' */ - a[0] = '\0'; - key = strdup (line); - a++; + /* overwrite '=' with '\0' */ + a[0] = '\0'; + key = strdup (line); + a++; - /* overwrite '\n' with '\0' if '\n' present */ - if ((b = strchr (a, '\n'))) b[0] = '\0'; + /* overwrite '\n' with '\0' if '\n' present */ + if ((b = strchr (a, '\n'))) b[0] = '\0'; - value = strdup (a); + value = strdup (a); - g_strstrip(key); - g_strstrip(value); + g_strstrip(key); + g_strstrip(value); - add_entry (key, value); + add_entry (key, value); - free (key); - free (value); - return 1; + free (key); + free (value); + return 1; } void config_finish () { - if (panel_config->monitor > (server.nb_monitor-1)) { + if (panel_config->monitor > (server.nb_monitor-1)) { // server.nb_monitor minimum value is 1 (see get_monitors_and_desktops()) // and panel_config->monitor is higher fprintf(stderr, "warning : monitor not found. tint2 default to monitor 1.\n"); panel_config->monitor = 0; - } + } // alloc panels - int i; - if (panel_config->monitor >= 0) { - // one monitor - nb_panel = 1; - panel1 = calloc(nb_panel, sizeof(Panel)); - memcpy(panel1, panel_config, sizeof(Panel)); - panel1->monitor = panel_config->monitor; + int i; + if (panel_config->monitor >= 0) { + // one monitor + nb_panel = 1; + panel1 = calloc(nb_panel, sizeof(Panel)); + memcpy(panel1, panel_config, sizeof(Panel)); + panel1->monitor = panel_config->monitor; } else { - // all monitors - nb_panel = server.nb_monitor; - panel1 = calloc(nb_panel, sizeof(Panel)); + // all monitors + nb_panel = server.nb_monitor; + panel1 = calloc(nb_panel, sizeof(Panel)); - for (i=0 ; i < nb_panel ; i++) { - memcpy(&panel1[i], panel_config, sizeof(Panel)); - panel1[i].monitor = i; + for (i=0 ; i < nb_panel ; i++) { + memcpy(&panel1[i], panel_config, sizeof(Panel)); + panel1[i].monitor = i; } } // TODO: user can configure layout => ordered objects in panel.area.list // clock and systray before taskbar because resize(clock) can resize others object ?? - init_panel(); + init_panel(); init_clock(); #ifdef ENABLE_BATTERY init_battery();

@@ -745,21 +745,21 @@

int config_read () { - const gchar * const * system_dirs; - char *path1; - gint i; + const gchar * const * system_dirs; + char *path1; + gint i; save_file_config = 0; - // follow XDG specification + // follow XDG specification deb: - // check tint2rc in user directory - path1 = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL); - if (g_file_test (path1, G_FILE_TEST_EXISTS)) { + // check tint2rc in user directory + path1 = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL); + if (g_file_test (path1, G_FILE_TEST_EXISTS)) { i = config_read_file (path1); config_path = strdup(path1); g_free(path1); - return i; + return i; } g_free(path1);

@@ -810,18 +810,18 @@

int config_read_file (const char *path) { - FILE *fp; - char line[80]; + FILE *fp; + char line[80]; - if ((fp = fopen(path, "r")) == NULL) return 0; + if ((fp = fopen(path, "r")) == NULL) return 0; old_task_font = 0; old_time1_font = 0; old_time2_font = 0; - while (fgets(line, sizeof(line), fp) != NULL) - parse_line (line); + while (fgets(line, sizeof(line), fp) != NULL) + parse_line (line); - fclose (fp); + fclose (fp); if (save_file_config) save_config();

@@ -838,108 +838,108 @@ if (old_time2_font) {

g_free(old_time2_font); old_time2_font = 0; } - return 1; + return 1; } void save_config () { - fprintf(stderr, "tint2 : convert user's config file\n"); + fprintf(stderr, "tint2 : convert user's config file\n"); - char *path, *dir; - FILE *fp; + char *path, *dir; + FILE *fp; if (old_task_icon_size) { panel_config->g_task.area.paddingy = ((int)panel_config->initial_height - (2 * panel_config->area.paddingy) - old_task_icon_size) / 2; } - dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL); + dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL); if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) g_mkdir(dir, 0777); g_free(dir); - path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL); - fp = fopen(path, "w"); - g_free(path); - if (fp == NULL) return; + path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL); + fp = fopen(path, "w"); + g_free(path); + if (fp == NULL) return; - fputs("#---------------------------------------------\n", fp); - fputs("# TINT2 CONFIG FILE\n", fp); - fputs("#---------------------------------------------\n\n", fp); - fputs("#---------------------------------------------\n", fp); - fputs("# BACKGROUND AND BORDER\n", fp); - fputs("#---------------------------------------------\n", fp); - GSList *l0; - Area *a; - l0 = list_back->next; - while (l0) { - a = l0->data; + fputs("#---------------------------------------------\n", fp); + fputs("# TINT2 CONFIG FILE\n", fp); + fputs("#---------------------------------------------\n\n", fp); + fputs("#---------------------------------------------\n", fp); + fputs("# BACKGROUND AND BORDER\n", fp); + fputs("#---------------------------------------------\n", fp); + GSList *l0; + Area *a; + l0 = list_back->next; + while (l0) { + a = l0->data; fprintf(fp, "rounded = %d\n", a->pix.border.rounded); fprintf(fp, "border_width = %d\n", a->pix.border.width); fprintf(fp, "background_color = #%02x%02x%02x %d\n", (int)(a->pix.back.color[0]*255), (int)(a->pix.back.color[1]*255), (int)(a->pix.back.color[2]*255), (int)(a->pix.back.alpha*100)); fprintf(fp, "border_color = #%02x%02x%02x %d\n\n", (int)(a->pix.border.color[0]*255), (int)(a->pix.border.color[1]*255), (int)(a->pix.border.color[2]*255), (int)(a->pix.border.alpha*100)); - l0 = l0->next; - } + l0 = l0->next; + } - fputs("#---------------------------------------------\n", fp); - fputs("# PANEL\n", fp); - fputs("#---------------------------------------------\n", fp); - fputs("panel_monitor = all\n", fp); - if (panel_position & BOTTOM) fputs("panel_position = bottom", fp); - else fputs("panel_position = top", fp); - if (panel_position & LEFT) fputs(" left horizontal\n", fp); - else if (panel_position & RIGHT) fputs(" right horizontal\n", fp); - else fputs(" center horizontal\n", fp); + fputs("#---------------------------------------------\n", fp); + fputs("# PANEL\n", fp); + fputs("#---------------------------------------------\n", fp); + fputs("panel_monitor = all\n", fp); + if (panel_position & BOTTOM) fputs("panel_position = bottom", fp); + else fputs("panel_position = top", fp); + if (panel_position & LEFT) fputs(" left horizontal\n", fp); + else if (panel_position & RIGHT) fputs(" right horizontal\n", fp); + else fputs(" center horizontal\n", fp); fprintf(fp, "panel_size = %d %d\n", (int)panel_config->initial_width, (int)panel_config->initial_height); fprintf(fp, "panel_margin = %d %d\n", panel_config->marginx, panel_config->marginy); - fprintf(fp, "panel_padding = %d %d %d\n", panel_config->area.paddingxlr, panel_config->area.paddingy, panel_config->area.paddingx); - fprintf(fp, "font_shadow = %d\n", panel_config->g_task.font_shadow); - fputs("panel_background_id = 1\n", fp); - fputs("wm_menu = 0\n", fp); + fprintf(fp, "panel_padding = %d %d %d\n", panel_config->area.paddingxlr, panel_config->area.paddingy, panel_config->area.paddingx); + fprintf(fp, "font_shadow = %d\n", panel_config->g_task.font_shadow); + fputs("panel_background_id = 1\n", fp); + fputs("wm_menu = 0\n", fp); - fputs("\n#---------------------------------------------\n", fp); - fputs("# TASKBAR\n", fp); - fputs("#---------------------------------------------\n", fp); - if (panel_mode == MULTI_DESKTOP) fputs("taskbar_mode = multi_desktop\n", fp); - else fputs("taskbar_mode = single_desktop\n", fp); - fprintf(fp, "taskbar_padding = 0 0 %d\n", panel_config->g_taskbar.paddingx); - fputs("taskbar_background_id = 0\n", fp); + fputs("\n#---------------------------------------------\n", fp); + fputs("# TASKBAR\n", fp); + fputs("#---------------------------------------------\n", fp); + if (panel_mode == MULTI_DESKTOP) fputs("taskbar_mode = multi_desktop\n", fp); + else fputs("taskbar_mode = single_desktop\n", fp); + fprintf(fp, "taskbar_padding = 0 0 %d\n", panel_config->g_taskbar.paddingx); + fputs("taskbar_background_id = 0\n", fp); - fputs("\n#---------------------------------------------\n", fp); - fputs("# TASK\n", fp); - fputs("#---------------------------------------------\n", fp); + fputs("\n#---------------------------------------------\n", fp); + fputs("# TASK\n", fp); + fputs("#---------------------------------------------\n", fp); if (old_task_icon_size) fputs("task_icon = 1\n", fp); else fputs("task_icon = 0\n", fp); fputs("task_text = 1\n", fp); - fprintf(fp, "task_maximum_size = %d %d\n", panel_config->g_task.maximum_width, panel_config->g_task.maximum_height); - fprintf(fp, "task_centered = %d\n", panel_config->g_task.centered); - fprintf(fp, "task_padding = %d %d\n", panel_config->g_task.area.paddingx, panel_config->g_task.area.paddingy); - fprintf(fp, "task_font = %s\n", old_task_font); + fprintf(fp, "task_maximum_size = %d %d\n", panel_config->g_task.maximum_width, panel_config->g_task.maximum_height); + fprintf(fp, "task_centered = %d\n", panel_config->g_task.centered); + fprintf(fp, "task_padding = %d %d\n", panel_config->g_task.area.paddingx, panel_config->g_task.area.paddingy); + fprintf(fp, "task_font = %s\n", old_task_font); fprintf(fp, "task_font_color = #%02x%02x%02x %d\n", (int)(panel_config->g_task.font.color[0]*255), (int)(panel_config->g_task.font.color[1]*255), (int)(panel_config->g_task.font.color[2]*255), (int)(panel_config->g_task.font.alpha*100)); fprintf(fp, "task_active_font_color = #%02x%02x%02x %d\n", (int)(panel_config->g_task.font_active.color[0]*255), (int)(panel_config->g_task.font_active.color[1]*255), (int)(panel_config->g_task.font_active.color[2]*255), (int)(panel_config->g_task.font_active.alpha*100)); - fputs("task_background_id = 2\n", fp); - fputs("task_active_background_id = 3\n", fp); + fputs("task_background_id = 2\n", fp); + fputs("task_active_background_id = 3\n", fp); - fputs("\n#---------------------------------------------\n", fp); - fputs("# SYSTRAYBAR\n", fp); - fputs("#---------------------------------------------\n", fp); - fputs("systray_padding = 4 3 4\n", fp); - fputs("systray_background_id = 0\n", fp); + fputs("\n#---------------------------------------------\n", fp); + fputs("# SYSTRAYBAR\n", fp); + fputs("#---------------------------------------------\n", fp); + fputs("systray_padding = 4 3 4\n", fp); + fputs("systray_background_id = 0\n", fp); - fputs("\n#---------------------------------------------\n", fp); - fputs("# CLOCK\n", fp); - fputs("#---------------------------------------------\n", fp); + fputs("\n#---------------------------------------------\n", fp); + fputs("# CLOCK\n", fp); + fputs("#---------------------------------------------\n", fp); if (time1_format) fprintf(fp, "time1_format = %s\n", time1_format); else fputs("#time1_format = %H:%M\n", fp); - fprintf(fp, "time1_font = %s\n", old_time1_font); + fprintf(fp, "time1_font = %s\n", old_time1_font); if (time2_format) fprintf(fp, "time2_format = %s\n", time2_format); else fputs("#time2_format = %A %d %B\n", fp); - fprintf(fp, "time2_font = %s\n", old_time2_font); + fprintf(fp, "time2_font = %s\n", old_time2_font); fprintf(fp, "clock_font_color = #%02x%02x%02x %d\n", (int)(panel_config->clock.font.color[0]*255), (int)(panel_config->clock.font.color[1]*255), (int)(panel_config->clock.font.color[2]*255), (int)(panel_config->clock.font.alpha*100)); - fputs("clock_padding = 2 2\n", fp); - fputs("clock_background_id = 0\n", fp); - fputs("#clock_lclick_command = xclock\n", fp); - fputs("clock_rclick_command = orage\n", fp); + fputs("clock_padding = 2 2\n", fp); + fputs("clock_background_id = 0\n", fp); + fputs("#clock_lclick_command = xclock\n", fp); + fputs("clock_rclick_command = orage\n", fp); #ifdef ENABLE_BATTERY fputs("\n#---------------------------------------------\n", fp);

@@ -955,38 +955,38 @@ fputs("battery_padding = 2 2\n", fp);

fputs("battery_background_id = 0\n", fp); #endif - fputs("\n#---------------------------------------------\n", fp); - fputs("# MOUSE ACTION ON TASK\n", fp); - fputs("#---------------------------------------------\n", fp); - if (mouse_middle == NONE) fputs("mouse_middle = none\n", fp); - else if (mouse_middle == CLOSE) fputs("mouse_middle = close\n", fp); - else if (mouse_middle == TOGGLE) fputs("mouse_middle = toggle\n", fp); - else if (mouse_middle == ICONIFY) fputs("mouse_middle = iconify\n", fp); - else if (mouse_middle == SHADE) fputs("mouse_middle = shade\n", fp); - else fputs("mouse_middle = toggle_iconify\n", fp); + fputs("\n#---------------------------------------------\n", fp); + fputs("# MOUSE ACTION ON TASK\n", fp); + fputs("#---------------------------------------------\n", fp); + if (mouse_middle == NONE) fputs("mouse_middle = none\n", fp); + else if (mouse_middle == CLOSE) fputs("mouse_middle = close\n", fp); + else if (mouse_middle == TOGGLE) fputs("mouse_middle = toggle\n", fp); + else if (mouse_middle == ICONIFY) fputs("mouse_middle = iconify\n", fp); + else if (mouse_middle == SHADE) fputs("mouse_middle = shade\n", fp); + else fputs("mouse_middle = toggle_iconify\n", fp); - if (mouse_right == NONE) fputs("mouse_right = none\n", fp); - else if (mouse_right == CLOSE) fputs("mouse_right = close\n", fp); - else if (mouse_right == TOGGLE) fputs("mouse_right = toggle\n", fp); - else if (mouse_right == ICONIFY) fputs("mouse_right = iconify\n", fp); - else if (mouse_right == SHADE) fputs("mouse_right = shade\n", fp); - else fputs("mouse_right = toggle_iconify\n", fp); + if (mouse_right == NONE) fputs("mouse_right = none\n", fp); + else if (mouse_right == CLOSE) fputs("mouse_right = close\n", fp); + else if (mouse_right == TOGGLE) fputs("mouse_right = toggle\n", fp); + else if (mouse_right == ICONIFY) fputs("mouse_right = iconify\n", fp); + else if (mouse_right == SHADE) fputs("mouse_right = shade\n", fp); + else fputs("mouse_right = toggle_iconify\n", fp); - if (mouse_scroll_up == NONE) fputs("mouse_scroll_up = none\n", fp); - else if (mouse_scroll_up == CLOSE) fputs("mouse_scroll_up = close\n", fp); - else if (mouse_scroll_up == TOGGLE) fputs("mouse_scroll_up = toggle\n", fp); - else if (mouse_scroll_up == ICONIFY) fputs("mouse_scroll_up = iconify\n", fp); - else if (mouse_scroll_up == SHADE) fputs("mouse_scroll_up = shade\n", fp); - else fputs("mouse_scroll_up = toggle_iconify\n", fp); + if (mouse_scroll_up == NONE) fputs("mouse_scroll_up = none\n", fp); + else if (mouse_scroll_up == CLOSE) fputs("mouse_scroll_up = close\n", fp); + else if (mouse_scroll_up == TOGGLE) fputs("mouse_scroll_up = toggle\n", fp); + else if (mouse_scroll_up == ICONIFY) fputs("mouse_scroll_up = iconify\n", fp); + else if (mouse_scroll_up == SHADE) fputs("mouse_scroll_up = shade\n", fp); + else fputs("mouse_scroll_up = toggle_iconify\n", fp); - if (mouse_scroll_down == NONE) fputs("mouse_scroll_down = none\n", fp); - else if (mouse_scroll_down == CLOSE) fputs("mouse_scroll_down = close\n", fp); - else if (mouse_scroll_down == TOGGLE) fputs("mouse_scroll_down = toggle\n", fp); - else if (mouse_scroll_down == ICONIFY) fputs("mouse_scroll_down = iconify\n", fp); - else if (mouse_scroll_down == SHADE) fputs("mouse_scroll_down = shade\n", fp); - else fputs("mouse_scroll_down = toggle_iconify\n", fp); + if (mouse_scroll_down == NONE) fputs("mouse_scroll_down = none\n", fp); + else if (mouse_scroll_down == CLOSE) fputs("mouse_scroll_down = close\n", fp); + else if (mouse_scroll_down == TOGGLE) fputs("mouse_scroll_down = toggle\n", fp); + else if (mouse_scroll_down == ICONIFY) fputs("mouse_scroll_down = iconify\n", fp); + else if (mouse_scroll_down == SHADE) fputs("mouse_scroll_down = shade\n", fp); + else fputs("mouse_scroll_down = toggle_iconify\n", fp); - fputs("\n\n", fp); - fclose (fp); + fputs("\n\n", fp); + fclose (fp); }
M src/panel.csrc/panel.c

@@ -69,21 +69,21 @@

p->area.parent = p; p->area.panel = p; p->area.on_screen = 1; - p->area.resize = 1; + p->area.resize = 1; p->area._resize = resize_panel; p->g_taskbar.parent = p; p->g_taskbar.panel = p; p->g_task.area.panel = p; // add childs - if (p->clock.area.on_screen) + if (p->clock.area.on_screen) p->area.list = g_slist_append(p->area.list, &p->clock); #ifdef ENABLE_BATTERY if (p->battery.area.on_screen) p->area.list = g_slist_append(p->area.list, &p->battery); #endif - // systray only on first panel - if (systray.area.on_screen && i == 0) + // systray only on first panel + if (systray.area.on_screen && i == 0) p->area.list = g_slist_append(p->area.list, &systray); // full width mode

@@ -168,12 +168,12 @@ task_active = 0;

task_drag = 0; task_urgent = 0; cleanup_systray(); - cleanup_taskbar(); + cleanup_taskbar(); // font allocated once - if (panel1[0].g_task.font_desc) { - pango_font_description_free(panel1[0].g_task.font_desc); - panel1[0].g_task.font_desc = 0; + if (panel1[0].g_task.font_desc) { + pango_font_description_free(panel1[0].g_task.font_desc); + panel1[0].g_task.font_desc = 0; } int i;

@@ -182,8 +182,8 @@ for (i=0 ; i < nb_panel ; i++) {

p = &panel1[i]; free_area(&p->area); - free_area(&p->g_task.area); - free_area(&p->g_taskbar); + free_area(&p->g_task.area); + free_area(&p->g_taskbar); if (p->temp_pmap) { XFreePixmap(server.dsp, p->temp_pmap);

@@ -195,17 +195,17 @@ p->main_win = 0;

} } - if (panel1) free(panel1); - panel1 = 0; + if (panel1) free(panel1); + panel1 = 0; } void resize_panel(void *obj) { - Panel *panel = (Panel*)obj; + Panel *panel = (Panel*)obj; if (panel_horizontal) { - int taskbar_width, modulo_width = 0; + int taskbar_width, modulo_width = 0; taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); if (panel->clock.area.on_screen && panel->clock.area.width)

@@ -241,7 +241,7 @@ posx += panel->taskbar[i].area.width + panel->area.paddingx;

} } else { - int taskbar_height, modulo_height = 0; + int taskbar_height, modulo_height = 0; int i, posy; taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);

@@ -280,8 +280,8 @@

void visible_object() { - Panel *panel; - int i, j; + Panel *panel; + int i, j; for (i=0 ; i < nb_panel ; i++) { panel = &panel1[i];

@@ -304,22 +304,22 @@

void set_panel_properties(Panel *p) { - XStoreName (server.dsp, p->main_win, "tint2"); + XStoreName (server.dsp, p->main_win, "tint2"); - // TODO: check if the name is really needed for a panel/taskbar ? - gsize len; - gchar *name = g_locale_to_utf8("tint2", -1, NULL, &len, NULL); - if (name != NULL) { - XChangeProperty(server.dsp, p->main_win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 8, PropModeReplace, (unsigned char *) name, (int) len); - g_free(name); - } + // TODO: check if the name is really needed for a panel/taskbar ? + gsize len; + gchar *name = g_locale_to_utf8("tint2", -1, NULL, &len, NULL); + if (name != NULL) { + XChangeProperty(server.dsp, p->main_win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 8, PropModeReplace, (unsigned char *) name, (int) len); + g_free(name); + } - // Dock - long val = server.atom._NET_WM_WINDOW_TYPE_DOCK; - XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1); + // Dock + long val = server.atom._NET_WM_WINDOW_TYPE_DOCK; + XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1); - // Reserved space - long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + // Reserved space + long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; if (panel_horizontal) { if (panel_position & TOP) { struts[2] = p->area.height + p->marginy;

@@ -348,69 +348,69 @@ // p->area.width - 1 allowed full screen on monitor 2

struts[7] = p->posy + p->area.height - 1; } } - // Old specification : fluxbox need _NET_WM_STRUT. - XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4); - XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12); + // Old specification : fluxbox need _NET_WM_STRUT. + XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4); + XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12); - // Sticky and below other window - val = 0xFFFFFFFF; - XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1); - Atom state[4]; - state[0] = server.atom._NET_WM_STATE_SKIP_PAGER; - state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR; - state[2] = server.atom._NET_WM_STATE_STICKY; - state[3] = server.atom._NET_WM_STATE_BELOW; - XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4); + // Sticky and below other window + val = 0xFFFFFFFF; + XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1); + Atom state[4]; + state[0] = server.atom._NET_WM_STATE_SKIP_PAGER; + state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR; + state[2] = server.atom._NET_WM_STATE_STICKY; + state[3] = server.atom._NET_WM_STATE_BELOW; + XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4); - // Fixed position - XSizeHints size_hints; - size_hints.flags = PPosition; - XChangeProperty (server.dsp, p->main_win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4); + // Fixed position + XSizeHints size_hints; + size_hints.flags = PPosition; + XChangeProperty (server.dsp, p->main_win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4); - // Unfocusable - XWMHints wmhints; - wmhints.flags = InputHint; - wmhints.input = False; - XChangeProperty (server.dsp, p->main_win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4); + // Unfocusable + XWMHints wmhints; + wmhints.flags = InputHint; + wmhints.input = False; + XChangeProperty (server.dsp, p->main_win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4); - // Undecorated - long prop[5] = { 2, 0, 0, 0, 0 }; - XChangeProperty(server.dsp, p->main_win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5); + // Undecorated + long prop[5] = { 2, 0, 0, 0, 0 }; + XChangeProperty(server.dsp, p->main_win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5); } void set_panel_background(Panel *p) { - get_root_pixmap(); + get_root_pixmap(); - if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap); - p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth); + if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap); + p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth); - // copy background (server.root_pmap) in panel.area.pix.pmap - Window dummy; - int x, y; - XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); - XSetTSOrigin(server.dsp, server.gc, -x, -y) ; - XFillRectangle(server.dsp, p->area.pix.pmap, server.gc, 0, 0, p->area.width, p->area.height); + // copy background (server.root_pmap) in panel.area.pix.pmap + Window dummy; + int x, y; + XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); + XSetTSOrigin(server.dsp, server.gc, -x, -y) ; + XFillRectangle(server.dsp, p->area.pix.pmap, server.gc, 0, 0, p->area.width, p->area.height); - // draw background panel - cairo_surface_t *cs; - cairo_t *c; - cs = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height); - c = cairo_create (cs); + // draw background panel + cairo_surface_t *cs; + cairo_t *c; + cs = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height); + c = cairo_create (cs); - draw_background(&p->area, c, 0); + draw_background(&p->area, c, 0); - cairo_destroy (c); - cairo_surface_destroy (cs); + cairo_destroy (c); + cairo_surface_destroy (cs); // redraw panel's object - GSList *l0; - Area *a; + GSList *l0; + Area *a; for (l0 = p->area.list; l0 ; l0 = l0->next) { - a = l0->data; - set_redraw(a); - } + a = l0->data; + set_redraw(a); + } }
M src/server.csrc/server.c

@@ -33,46 +33,46 @@

void server_init_atoms () { - server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False); - server.atom._NET_CURRENT_DESKTOP = XInternAtom (server.dsp, "_NET_CURRENT_DESKTOP", False); - server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom (server.dsp, "_NET_NUMBER_OF_DESKTOPS", False); - server.atom._NET_DESKTOP_GEOMETRY = XInternAtom (server.dsp, "_NET_DESKTOP_GEOMETRY", False); - server.atom._NET_DESKTOP_VIEWPORT = XInternAtom (server.dsp, "_NET_DESKTOP_VIEWPORT", False); - server.atom._NET_ACTIVE_WINDOW = XInternAtom (server.dsp, "_NET_ACTIVE_WINDOW", False); - server.atom._NET_WM_WINDOW_TYPE = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE", False); - server.atom._NET_WM_STATE_SKIP_PAGER = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_PAGER", False); - server.atom._NET_WM_STATE_SKIP_TASKBAR = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_TASKBAR", False); - server.atom._NET_WM_STATE_STICKY = XInternAtom (server.dsp, "_NET_WM_STATE_STICKY", False); - server.atom._NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom (server.dsp, "_NET_WM_STATE_DEMANDS_ATTENTION", False); - server.atom._NET_WM_WINDOW_TYPE_DOCK = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DOCK", False); - server.atom._NET_WM_WINDOW_TYPE_DESKTOP = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DESKTOP", False); - server.atom._NET_WM_WINDOW_TYPE_TOOLBAR = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); - server.atom._NET_WM_WINDOW_TYPE_MENU = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_MENU", False); - server.atom._NET_WM_WINDOW_TYPE_SPLASH = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_SPLASH", False); - server.atom._NET_WM_WINDOW_TYPE_DIALOG = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DIALOG", False); - server.atom._NET_WM_WINDOW_TYPE_NORMAL = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_NORMAL", False); - server.atom._NET_WM_DESKTOP = XInternAtom (server.dsp, "_NET_WM_DESKTOP", False); - server.atom.WM_STATE = XInternAtom (server.dsp, "WM_STATE", False); - server.atom._NET_WM_STATE = XInternAtom (server.dsp, "_NET_WM_STATE", False); - server.atom._NET_WM_STATE_MAXIMIZED_VERT = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_VERT", False); - server.atom._NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_HORZ", False); - server.atom._NET_WM_STATE_SHADED = XInternAtom (server.dsp, "_NET_WM_STATE_SHADED", False); - server.atom._NET_WM_STATE_BELOW = XInternAtom (server.dsp, "_NET_WM_STATE_BELOW", False); - server.atom._NET_WM_STATE_MODAL = XInternAtom (server.dsp, "_NET_WM_STATE_MODAL", False); - server.atom._NET_CLIENT_LIST = XInternAtom (server.dsp, "_NET_CLIENT_LIST", False); - server.atom._NET_WM_VISIBLE_NAME = XInternAtom (server.dsp, "_NET_WM_VISIBLE_NAME", False); - server.atom._NET_WM_NAME = XInternAtom (server.dsp, "_NET_WM_NAME", False); - server.atom._NET_WM_STRUT = XInternAtom (server.dsp, "_NET_WM_STRUT", False); - server.atom._NET_WM_ICON = XInternAtom (server.dsp, "_NET_WM_ICON", False); - server.atom._NET_CLOSE_WINDOW = XInternAtom (server.dsp, "_NET_CLOSE_WINDOW", False); - server.atom.UTF8_STRING = XInternAtom (server.dsp, "UTF8_STRING", False); - server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_SUPPORTING_WM_CHECK", False); - server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_WM_NAME", False); - server.atom._WIN_LAYER = XInternAtom (server.dsp, "_WIN_LAYER", False); - server.atom._NET_WM_STRUT_PARTIAL = XInternAtom (server.dsp, "_NET_WM_STRUT_PARTIAL", False); - server.atom.WM_NAME = XInternAtom(server.dsp, "WM_NAME", False); - server.atom.__SWM_VROOT = XInternAtom(server.dsp, "__SWM_VROOT", False); - server.atom._MOTIF_WM_HINTS = XInternAtom(server.dsp, "_MOTIF_WM_HINTS", False); + server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False); + server.atom._NET_CURRENT_DESKTOP = XInternAtom (server.dsp, "_NET_CURRENT_DESKTOP", False); + server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom (server.dsp, "_NET_NUMBER_OF_DESKTOPS", False); + server.atom._NET_DESKTOP_GEOMETRY = XInternAtom (server.dsp, "_NET_DESKTOP_GEOMETRY", False); + server.atom._NET_DESKTOP_VIEWPORT = XInternAtom (server.dsp, "_NET_DESKTOP_VIEWPORT", False); + server.atom._NET_ACTIVE_WINDOW = XInternAtom (server.dsp, "_NET_ACTIVE_WINDOW", False); + server.atom._NET_WM_WINDOW_TYPE = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE", False); + server.atom._NET_WM_STATE_SKIP_PAGER = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_PAGER", False); + server.atom._NET_WM_STATE_SKIP_TASKBAR = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_TASKBAR", False); + server.atom._NET_WM_STATE_STICKY = XInternAtom (server.dsp, "_NET_WM_STATE_STICKY", False); + server.atom._NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom (server.dsp, "_NET_WM_STATE_DEMANDS_ATTENTION", False); + server.atom._NET_WM_WINDOW_TYPE_DOCK = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DOCK", False); + server.atom._NET_WM_WINDOW_TYPE_DESKTOP = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DESKTOP", False); + server.atom._NET_WM_WINDOW_TYPE_TOOLBAR = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); + server.atom._NET_WM_WINDOW_TYPE_MENU = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_MENU", False); + server.atom._NET_WM_WINDOW_TYPE_SPLASH = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_SPLASH", False); + server.atom._NET_WM_WINDOW_TYPE_DIALOG = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DIALOG", False); + server.atom._NET_WM_WINDOW_TYPE_NORMAL = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_NORMAL", False); + server.atom._NET_WM_DESKTOP = XInternAtom (server.dsp, "_NET_WM_DESKTOP", False); + server.atom.WM_STATE = XInternAtom (server.dsp, "WM_STATE", False); + server.atom._NET_WM_STATE = XInternAtom (server.dsp, "_NET_WM_STATE", False); + server.atom._NET_WM_STATE_MAXIMIZED_VERT = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_VERT", False); + server.atom._NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_HORZ", False); + server.atom._NET_WM_STATE_SHADED = XInternAtom (server.dsp, "_NET_WM_STATE_SHADED", False); + server.atom._NET_WM_STATE_BELOW = XInternAtom (server.dsp, "_NET_WM_STATE_BELOW", False); + server.atom._NET_WM_STATE_MODAL = XInternAtom (server.dsp, "_NET_WM_STATE_MODAL", False); + server.atom._NET_CLIENT_LIST = XInternAtom (server.dsp, "_NET_CLIENT_LIST", False); + server.atom._NET_WM_VISIBLE_NAME = XInternAtom (server.dsp, "_NET_WM_VISIBLE_NAME", False); + server.atom._NET_WM_NAME = XInternAtom (server.dsp, "_NET_WM_NAME", False); + server.atom._NET_WM_STRUT = XInternAtom (server.dsp, "_NET_WM_STRUT", False); + server.atom._NET_WM_ICON = XInternAtom (server.dsp, "_NET_WM_ICON", False); + server.atom._NET_CLOSE_WINDOW = XInternAtom (server.dsp, "_NET_CLOSE_WINDOW", False); + server.atom.UTF8_STRING = XInternAtom (server.dsp, "UTF8_STRING", False); + server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_SUPPORTING_WM_CHECK", False); + server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_WM_NAME", False); + server.atom._WIN_LAYER = XInternAtom (server.dsp, "_WIN_LAYER", False); + server.atom._NET_WM_STRUT_PARTIAL = XInternAtom (server.dsp, "_NET_WM_STRUT_PARTIAL", False); + server.atom.WM_NAME = XInternAtom(server.dsp, "WM_NAME", False); + server.atom.__SWM_VROOT = XInternAtom(server.dsp, "__SWM_VROOT", False); + server.atom._MOTIF_WM_HINTS = XInternAtom(server.dsp, "_MOTIF_WM_HINTS", False); // systray protocol name_trayer = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.dsp));

@@ -94,65 +94,65 @@

void send_event32 (Window win, Atom at, long data1, long data2, long data3) { - XEvent event; + XEvent event; - event.xclient.type = ClientMessage; - event.xclient.serial = 0; - event.xclient.send_event = True; - event.xclient.display = server.dsp; - event.xclient.window = win; - event.xclient.message_type = at; + event.xclient.type = ClientMessage; + event.xclient.serial = 0; + event.xclient.send_event = True; + event.xclient.display = server.dsp; + event.xclient.window = win; + event.xclient.message_type = at; - event.xclient.format = 32; - event.xclient.data.l[0] = data1; - event.xclient.data.l[1] = data2; - event.xclient.data.l[2] = data3; - event.xclient.data.l[3] = 0; - event.xclient.data.l[4] = 0; + event.xclient.format = 32; + event.xclient.data.l[0] = data1; + event.xclient.data.l[1] = data2; + event.xclient.data.l[2] = data3; + event.xclient.data.l[3] = 0; + event.xclient.data.l[4] = 0; - XSendEvent(server.dsp, server.root_win, False, SubstructureRedirectMask|SubstructureNotifyMask, &event); + XSendEvent(server.dsp, server.root_win, False, SubstructureRedirectMask|SubstructureNotifyMask, &event); } int get_property32 (Window win, Atom at, Atom type) { - Atom type_ret; - int format_ret = 0, data = 0; - unsigned long nitems_ret = 0; - unsigned long bafter_ret = 0; - unsigned char *prop_value = 0; - int result; + Atom type_ret; + int format_ret = 0, data = 0; + unsigned long nitems_ret = 0; + unsigned long bafter_ret = 0; + unsigned char *prop_value = 0; + int result; - if (!win) return 0; + if (!win) return 0; - result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value); + result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value); - if (result == Success && prop_value) { - data = ((gulong*)prop_value)[0]; - XFree (prop_value); - } - return data; + if (result == Success && prop_value) { + data = ((gulong*)prop_value)[0]; + XFree (prop_value); + } + return data; } void *server_get_property (Window win, Atom at, Atom type, int *num_results) { - Atom type_ret; - int format_ret = 0; - unsigned long nitems_ret = 0; - unsigned long bafter_ret = 0; - unsigned char *prop_value; - int result; + Atom type_ret; + int format_ret = 0; + unsigned long nitems_ret = 0; + unsigned long bafter_ret = 0; + unsigned char *prop_value; + int result; - if (!win) return 0; + if (!win) return 0; - result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value); + result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value); - /* Send back resultcount */ - if (num_results) *num_results = nitems_ret; + /* Send back resultcount */ + if (num_results) *num_results = nitems_ret; - if (result == Success && prop_value) return prop_value; - else return 0; + if (result == Success && prop_value) return prop_value; + else return 0; }

@@ -160,7 +160,7 @@ void get_root_pixmap()

{ Pixmap ret = None; - unsigned long *res; + unsigned long *res; int c = 2; do {

@@ -168,7 +168,7 @@ res = server_get_property (server.root_win, server.atom._XROOTPMAP_ID, XA_PIXMAP, 0);

if (res) { ret = *((Pixmap*)res); XFree(res); - break; + break; } } while (--c > 0); server.root_pmap = ret;

@@ -190,49 +190,49 @@

int compareMonitor(const void *monitor1, const void *monitor2) { - Monitor *m1 = (Monitor*)monitor1; - Monitor *m2 = (Monitor*)monitor2; + Monitor *m1 = (Monitor*)monitor1; + Monitor *m2 = (Monitor*)monitor2; - if (m1->x < m2->x) { - return -1; - } - else - if (m1->x > m2->x) { - return 1; - } - else - if (m1->width < m2->width) { - return 1; - } - else - if (m1->width > m2->width) { - return -1; - } - else { - return 0; - } + if (m1->x < m2->x) { + return -1; + } + else + if (m1->x > m2->x) { + return 1; + } + else + if (m1->width < m2->width) { + return 1; + } + else + if (m1->width > m2->width) { + return -1; + } + else { + return 0; + } } void get_monitors_and_desktops() { - int i; + int i; - if (server.monitor) free(server.monitor); - server.nb_monitor = 0; - server.monitor = 0; + if (server.monitor) free(server.monitor); + server.nb_monitor = 0; + server.monitor = 0; - int nb_monitor; - if (XineramaIsActive(server.dsp)) { - XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor); + int nb_monitor; + if (XineramaIsActive(server.dsp)) { + XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor); - if (info) { + if (info) { int nb=0, j; - i = 0; - server.monitor = calloc(nb_monitor, sizeof(Monitor)); - while (i < nb_monitor) { - for (j = 0; j < i; j++) { + i = 0; + server.monitor = calloc(nb_monitor, sizeof(Monitor)); + while (i < nb_monitor) { + for (j = 0; j < i; j++) { if (info[i].x_org >= info[j].x_org && info[i].y_org >= info[j].y_org && (info[i].x_org+info[i].width) <= (info[j].x_org+info[j].width) && (info[i].y_org+info[i].height) <= (info[j].y_org+info[j].height)) { if (info[i].x_org == info[j].x_org && info[i].y_org == info[j].y_org && info[i].width == info[j].width && info[i].height == info[j].height && nb == 0) { // add the first monitor

@@ -240,48 +240,48 @@ break;

} else { // doesn't count monitor 'i' because it's included into another one - //fprintf(stderr, "monitor %d included into another one\n", i); - goto next; + //fprintf(stderr, "monitor %d included into another one\n", i); + goto next; } } } - server.monitor[nb].x = info[i].x_org; - server.monitor[nb].y = info[i].y_org; - server.monitor[nb].width = info[i].width; - server.monitor[nb].height = info[i].height; + server.monitor[nb].x = info[i].x_org; + server.monitor[nb].y = info[i].y_org; + server.monitor[nb].width = info[i].width; + server.monitor[nb].height = info[i].height; nb++; next: i++; - } - XFree(info); - server.nb_monitor = nb; + } + XFree(info); + server.nb_monitor = nb; - // ordered monitor according to coordinate - qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor); - } - } + // ordered monitor according to coordinate + qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor); + } + } - if (!server.nb_monitor) { - server.nb_monitor = 1; - server.monitor = calloc(server.nb_monitor, sizeof(Monitor)); - server.monitor[0].x = server.monitor[0].y = 0; - server.monitor[0].width = DisplayWidth (server.dsp, server.screen); - server.monitor[0].height = DisplayHeight (server.dsp, server.screen); - } + if (!server.nb_monitor) { + server.nb_monitor = 1; + server.monitor = calloc(server.nb_monitor, sizeof(Monitor)); + server.monitor[0].x = server.monitor[0].y = 0; + server.monitor[0].width = DisplayWidth (server.dsp, server.screen); + server.monitor[0].height = DisplayHeight (server.dsp, server.screen); + } // detect number of desktops // wait 15s to leave some time for window manager startup - for (i=0 ; i < 15 ; i++) { - server.nb_desktop = server_get_number_of_desktop (); - if (server.nb_desktop > 0) break; - sleep(1); - } - if (server.nb_desktop == 0) { - server.nb_desktop = 1; - fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n"); - } - fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", server.nb_monitor, server.nb_desktop); + for (i=0 ; i < 15 ; i++) { + server.nb_desktop = server_get_number_of_desktop (); + if (server.nb_desktop > 0) break; + sleep(1); + } + if (server.nb_desktop == 0) { + server.nb_desktop = 1; + fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n"); + } + fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", server.nb_monitor, server.nb_desktop); }
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -78,14 +78,14 @@

void cleanup_systray() { - if (systray.list_icons) { + if (systray.list_icons) { // remove_icon change systray.list_icons while(systray.list_icons) remove_icon((TrayWindow*)systray.list_icons->data); - g_slist_free(systray.list_icons); - systray.list_icons = 0; - } + g_slist_free(systray.list_icons); + systray.list_icons = 0; + } free_area(&systray.area); cleanup_net();

@@ -199,7 +199,7 @@ return 0;

} // 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); // v0.2 trayer specification. tint2 always orizontal. // TODO : vertical panel ??

@@ -210,11 +210,11 @@ XSetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN, net_sel_win, CurrentTime);

if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) { fprintf(stderr, "tint2 : can't get systray manager\n"); return 0; - } + } - XClientMessageEvent ev; + XClientMessageEvent ev; ev.type = ClientMessage; - ev.window = server.root_win; + ev.window = server.root_win; ev.message_type = server.atom.MANAGER; ev.format = 32; ev.data.l[0] = CurrentTime;

@@ -230,8 +230,8 @@

void cleanup_net() { if (net_sel_win != None) { - XDestroyWindow(server.dsp, net_sel_win); - net_sel_win = None; + XDestroyWindow(server.dsp, net_sel_win); + net_sel_win = None; } }

@@ -319,9 +319,9 @@

traywin = g_new0(TrayWindow, 1); traywin->id = id; -// systray.list_icons = g_slist_prepend(systray.list_icons, traywin); + // systray.list_icons = g_slist_prepend(systray.list_icons, traywin); systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows); - systray.area.resize = 1; + systray.area.resize = 1; systray.area.redraw = 1; //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));

@@ -346,7 +346,7 @@

// remove from our list systray.list_icons = g_slist_remove(systray.list_icons, traywin); g_free(traywin); - systray.area.resize = 1; + systray.area.resize = 1; systray.area.redraw = 1; //printf("remove_icon id %lx, %d\n", traywin->id);
M src/taskbar/task.csrc/taskbar/task.c

@@ -204,11 +204,11 @@ memcpy (tsk->icon_data, tmp_data, w * h * sizeof (DATA32));

#endif } XFree (data); - } - else { - // get Pixmap icon - XWMHints *hints = XGetWMHints(server.dsp, tsk->win); - if (!hints) return; + } + else { + // get Pixmap icon + XWMHints *hints = XGetWMHints(server.dsp, tsk->win); + if (!hints) return; if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) { // get width, height and depth for the pixmap Window root;

@@ -235,7 +235,7 @@ memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (DATA32));

imlib_free_image(); } XFree(hints); - } + } if (tsk->icon_data) { tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32));
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -36,8 +36,8 @@

void init_taskbar() { - Panel *panel; - int i, j; + Panel *panel; + int i, j; for (i=0 ; i < nb_panel ; i++) { panel = &panel1[i];

@@ -115,9 +115,9 @@

void cleanup_taskbar() { - Panel *panel; + Panel *panel; Taskbar *tskbar; - int i, j; + int i, j; GSList *l0; Task *tsk;

@@ -152,11 +152,11 @@

Task *task_get_task (Window win) { - Task *tsk; - GSList *l0; - int i, j; + Task *tsk; + GSList *l0; + int i, j; - for (i=0 ; i < nb_panel ; i++) { + for (i=0 ; i < nb_panel ; i++) { for (j=0 ; j < panel1[i].nb_desktop ; j++) { for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) { tsk = l0->data;

@@ -164,23 +164,23 @@ if (win == tsk->win)

return tsk; } } - } - return 0; + } + return 0; } void task_refresh_tasklist () { - Window *win, active_win; - int num_results, i, j, k; - GSList *l0; - Task *tsk; + Window *win, active_win; + int num_results, i, j, k; + GSList *l0; + Task *tsk; - win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results); - if (!win) return; + win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results); + if (!win) return; - // Remove any old and set active win - active_win = window_get_active (); + // Remove any old and set active win + active_win = window_get_active (); if (task_active) { task_active->area.is_active = 0; task_active = 0;

@@ -205,28 +205,28 @@ // careful : remove_task change l0->next

if (k == num_results) remove_task (tsk); } } - } + } - // Add any new - for (i = 0; i < num_results; i++) - if (!task_get_task (win[i])) - add_task (win[i]); + // Add any new + for (i = 0; i < num_results; i++) + if (!task_get_task (win[i])) + add_task (win[i]); - XFree (win); + XFree (win); } void resize_taskbar(void *obj) { Taskbar *taskbar = (Taskbar*)obj; - Panel *panel = (Panel*)taskbar->area.panel; - Task *tsk; - GSList *l; + Panel *panel = (Panel*)taskbar->area.panel; + Task *tsk; + GSList *l; int task_count; -//printf("resize_taskbar : posx et width des taches\n"); + //printf("resize_taskbar : posx et width des taches\n"); - taskbar->area.redraw = 1; + taskbar->area.redraw = 1; if (panel_horizontal) { int pixel_width, modulo_width=0;
M src/tint.csrc/tint.c

@@ -48,52 +48,52 @@

void init (int argc, char *argv[]) { - int c; + int c; // read options - c = getopt (argc, argv, "c:"); - if (c != -1) { + c = getopt (argc, argv, "c:"); + if (c != -1) { config_path = strdup (optarg); - c = getopt (argc, argv, "j:"); - if (c != -1) + c = getopt (argc, argv, "j:"); + if (c != -1) thumbnail_path = strdup (optarg); } // Set signal handler - signal(SIGUSR1, signal_handler); + signal(SIGUSR1, signal_handler); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); signal(SIGHUP, signal_handler); signal(SIGCHLD, SIG_IGN); // don't have to wait() after fork() - // set global data - memset(&server, 0, sizeof(Server_global)); - memset(&systray, 0, sizeof(Systraybar)); + // set global data + memset(&server, 0, sizeof(Server_global)); + memset(&systray, 0, sizeof(Systraybar)); - server.dsp = XOpenDisplay (NULL); - if (!server.dsp) { - fprintf(stderr, "tint2 exit : could not open display.\n"); - exit(0); - } - server_init_atoms (); - server.screen = DefaultScreen (server.dsp); + server.dsp = XOpenDisplay (NULL); + if (!server.dsp) { + fprintf(stderr, "tint2 exit : could not open display.\n"); + exit(0); + } + server_init_atoms (); + server.screen = DefaultScreen (server.dsp); server.root_win = RootWindow(server.dsp, server.screen); - server.depth = DefaultDepth (server.dsp, server.screen); - server.visual = DefaultVisual (server.dsp, server.screen); - server.desktop = server_get_current_desktop (); + server.depth = DefaultDepth (server.dsp, server.screen); + server.visual = DefaultVisual (server.dsp, server.screen); + server.desktop = server_get_current_desktop (); XGCValues gcv; server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv) ; - XSetErrorHandler ((XErrorHandler) server_catch_error); + XSetErrorHandler ((XErrorHandler) server_catch_error); - imlib_context_set_display (server.dsp); - imlib_context_set_visual (server.visual); - imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen)); + imlib_context_set_display (server.dsp); + imlib_context_set_visual (server.visual); + imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen)); - /* Catch events */ - XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); + /* Catch events */ + XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); - setlocale (LC_ALL, ""); + setlocale (LC_ALL, ""); }

@@ -101,13 +101,13 @@ void cleanup()

{ cleanup_panel(); - if (time1_font_desc) pango_font_description_free(time1_font_desc); - if (time2_font_desc) pango_font_description_free(time2_font_desc); - if (time1_format) g_free(time1_format); - if (time2_format) g_free(time2_format); + if (time1_font_desc) pango_font_description_free(time1_font_desc); + if (time2_font_desc) pango_font_description_free(time2_font_desc); + if (time1_format) g_free(time1_format); + if (time2_format) g_free(time2_format); #ifdef ENABLE_BATTERY - if (bat1_font_desc) pango_font_description_free(bat1_font_desc); - if (bat2_font_desc) pango_font_description_free(bat2_font_desc); + if (bat1_font_desc) pango_font_description_free(bat1_font_desc); + if (bat2_font_desc) pango_font_description_free(bat2_font_desc); if (battery_low_cmd) g_free(battery_low_cmd); if (path_energy_now) g_free(path_energy_now); if (path_energy_full) g_free(path_energy_full);

@@ -119,9 +119,9 @@ if (clock_rclick_command) g_free(clock_rclick_command);

if (config_path) g_free(config_path); if (thumbnail_path) g_free(thumbnail_path); - if (server.monitor) free(server.monitor); - XFreeGC(server.dsp, server.gc); - XCloseDisplay(server.dsp); + if (server.monitor) free(server.monitor); + XFreeGC(server.dsp, server.gc); + XCloseDisplay(server.dsp); }

@@ -212,7 +212,7 @@

void window_action (Task *tsk, int action) { - if (!tsk) return; + if (!tsk) return; int desk; switch (action) { case CLOSE:

@@ -259,13 +259,13 @@

void event_button_press (XEvent *e) { - Panel *panel = get_panel(e->xany.window); + Panel *panel = get_panel(e->xany.window); if (!panel) return; if (panel_mode == MULTI_DESKTOP) task_drag = click_task(panel, e); - if (wm_menu && !task_drag && !click_clock(panel, e) && (e->xbutton.button != 1) ) { + if (wm_menu && !task_drag && !click_clock(panel, e) && (e->xbutton.button != 1) ) { // forward the click to the desktop window (thanks conky) XUngrabPointer(server.dsp, e->xbutton.time); e->xbutton.window = server.root_win;

@@ -277,15 +277,15 @@ //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);

XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time); XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e); return; - } + } - XLowerWindow (server.dsp, panel->main_win); + XLowerWindow (server.dsp, panel->main_win); } void event_button_release (XEvent *e) { - Panel *panel = get_panel(e->xany.window); + Panel *panel = get_panel(e->xany.window); if (!panel) return; if (wm_menu && click_padding(panel, e)) {

@@ -295,27 +295,27 @@ XSendEvent(server.dsp, e->xbutton.window, False, ButtonReleaseMask, e);

return; } - int action = TOGGLE_ICONIFY; - switch (e->xbutton.button) { - case 2: - action = mouse_middle; - break; - case 3: - action = mouse_right; - break; - case 4: - action = mouse_scroll_up; - break; - case 5: - action = mouse_scroll_down; - break; - case 6: - action = mouse_tilt_left; - break; - case 7: - action = mouse_tilt_right; - break; - } + int action = TOGGLE_ICONIFY; + switch (e->xbutton.button) { + case 2: + action = mouse_middle; + break; + case 3: + action = mouse_right; + break; + case 4: + action = mouse_scroll_up; + break; + case 5: + action = mouse_scroll_down; + break; + case 6: + action = mouse_tilt_left; + break; + case 7: + action = mouse_tilt_right; + break; + } if ( click_clock(panel, e)) { clock_action(e->xbutton.button);

@@ -332,51 +332,51 @@ task_drag = 0;

return; } - // drag and drop task - if (task_drag) { - if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) { - if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) { - windows_set_desktop(task_drag->win, tskbar->desktop); - if (tskbar->desktop == server.desktop) - set_active(task_drag->win); - task_drag = 0; - } - return; - } - else task_drag = 0; - } + // drag and drop task + if (task_drag) { + if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) { + if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) { + windows_set_desktop(task_drag->win, tskbar->desktop); + if (tskbar->desktop == server.desktop) + set_active(task_drag->win); + task_drag = 0; + } + return; + } + else task_drag = 0; + } - // switch desktop - if (panel_mode == MULTI_DESKTOP) { - if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT) - set_desktop (tskbar->desktop); + // switch desktop + if (panel_mode == MULTI_DESKTOP) { + if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT) + set_desktop (tskbar->desktop); } - // action on task - window_action( click_task(panel, e), action); + // action on task + window_action( click_task(panel, e), action); - // to keep window below - XLowerWindow (server.dsp, panel->main_win); + // to keep window below + XLowerWindow (server.dsp, panel->main_win); } void event_property_notify (XEvent *e) { - int i, j; - Task *tsk; - Window win = e->xproperty.window; - Atom at = e->xproperty.atom; + int i, j; + Task *tsk; + Window win = e->xproperty.window; + Atom at = e->xproperty.atom; - if (win == server.root_win) { - if (!server.got_root_win) { - XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); - server.got_root_win = 1; - } + if (win == server.root_win) { + if (!server.got_root_win) { + XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); + server.got_root_win = 1; + } - // Change number of desktops - else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) { - server.nb_desktop = server_get_number_of_desktop (); - cleanup_taskbar(); + // Change number of desktops + else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) { + server.nb_desktop = server_get_number_of_desktop (); + cleanup_taskbar(); init_taskbar(); visible_object(); for (i=0 ; i < nb_panel ; i++) {

@@ -384,12 +384,12 @@ panel1[i].area.resize = 1;

} task_refresh_tasklist(); panel_refresh = 1; - } - // Change desktop - else if (at == server.atom._NET_CURRENT_DESKTOP) { - server.desktop = server_get_current_desktop (); + } + // Change desktop + else if (at == server.atom._NET_CURRENT_DESKTOP) { + server.desktop = server_get_current_desktop (); for (i=0 ; i < nb_panel ; i++) { - Panel *panel = &panel1[i]; + Panel *panel = &panel1[i]; if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) { // redraw taskbar panel_refresh = 1;

@@ -417,72 +417,77 @@ }

} } } - if (panel_mode != MULTI_DESKTOP) { + if (panel_mode != MULTI_DESKTOP) { visible_object(); - } - } - // Window list - else if (at == server.atom._NET_CLIENT_LIST) { - task_refresh_tasklist(); - panel_refresh = 1; - } - // Change active - else if (at == server.atom._NET_ACTIVE_WINDOW) { - GSList *l0; - if (task_active) { + } + } + // Window list + else if (at == server.atom._NET_CLIENT_LIST) { + task_refresh_tasklist(); + panel_refresh = 1; + } + // Change active + else if (at == server.atom._NET_ACTIVE_WINDOW) { + GSList *l0; + if (task_active) { for (i=0 ; i < nb_panel ; i++) { for (j=0 ; j < panel1[i].nb_desktop ; j++) { - for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) { - tsk = l0->data; - tsk->area.is_active = 0; - } + for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) { + tsk = l0->data; + tsk->area.is_active = 0; + } } } - task_active = 0; + task_active = 0; } - Window w1 = window_get_active (); - Task *t = task_get_task(w1); - if (!t) { - Window w2; - if (XGetTransientForHint(server.dsp, w1, &w2) != 0) - if (w2) t = task_get_task(w2); - } + Window w1 = window_get_active (); + Task *t = task_get_task(w1); + if (!t) { + Window w2; + if (XGetTransientForHint(server.dsp, w1, &w2) != 0) + if (w2) t = task_get_task(w2); + } if (task_urgent == t) { init_precision(); task_urgent = 0; } // put active state on all task (multi_desktop) - if (t) { + if (t) { for (i=0 ; i < nb_panel ; i++) { for (j=0 ; j < panel1[i].nb_desktop ; j++) { - for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) { - tsk = l0->data; - if (tsk->win == t->win) { - tsk->area.is_active = 1; - //printf("active monitor %d, task %s\n", panel1[i].monitor, tsk->title); - } - } + for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) { + tsk = l0->data; + if (tsk->win == t->win) { + tsk->area.is_active = 1; + //printf("active monitor %d, task %s\n", panel1[i].monitor, tsk->title); + } + } } } - task_active = t; + task_active = t; } - panel_refresh = 1; - } - else if (at == server.atom._XROOTPMAP_ID) { + panel_refresh = 1; + } + else if (at == server.atom._XROOTPMAP_ID) { // change Wallpaper for (i=0 ; i < nb_panel ; i++) { set_panel_background(&panel1[i]); } - panel_refresh = 1; - } - } - else { - tsk = task_get_task (win); - if (!tsk) return; - //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title); + panel_refresh = 1; + } + } + else { + tsk = task_get_task (win); + if (!tsk) { + if ( at != server.atom._NET_WM_STATE) + return; + else if ( !(tsk = add_task(win)) ) + return; + } + //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title); - // Window title changed - if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) { + // Window title changed + if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) { Task *tsk2; GSList *l0; get_title(tsk);

@@ -498,22 +503,25 @@ }

} } } - panel_refresh = 1; - } + panel_refresh = 1; + } // Demand attention - else if (at == server.atom._NET_WM_STATE) { - if (window_is_urgent (win)) { + else if (at == server.atom._NET_WM_STATE) { + if (window_is_urgent (win)) { task_urgent = tsk; tick_urgent = 0; time_precision = 1; } + if (window_is_skip_taskbar(win)) { + remove_task( tsk ); + } } - else if (at == server.atom.WM_STATE) { - // Iconic state + else if (at == server.atom.WM_STATE) { + // Iconic state // TODO : try to delete following code - if (window_is_iconified (win)) { - if (task_active) { - if (task_active->win == tsk->win) { + if (window_is_iconified (win)) { + if (task_active) { + if (task_active->win == tsk->win) { Task *tsk2; GSList *l0; for (i=0 ; i < nb_panel ; i++) {

@@ -524,14 +532,14 @@ tsk2->area.is_active = 0;

} } } - task_active = 0; - } - } + task_active = 0; + } + } } } - // Window icon changed - else if (at == server.atom._NET_WM_ICON) { - get_icon(tsk); + // Window icon changed + else if (at == server.atom._NET_WM_ICON) { + get_icon(tsk); Task *tsk2; GSList *l0; for (i=0 ; i < nb_panel ; i++) {

@@ -548,10 +556,10 @@ }

} } } - panel_refresh = 1; - } - // Window desktop changed - else if (at == server.atom._NET_WM_DESKTOP) { + panel_refresh = 1; + } + // Window desktop changed + else if (at == server.atom._NET_WM_DESKTOP) { int desktop = window_get_desktop (win); int active = tsk->area.is_active; //printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);

@@ -565,21 +573,21 @@ task_active = tsk;

} panel_refresh = 1; } - } + } - if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen); - } + if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen); + } } void event_expose (XEvent *e) { - Panel *panel; + Panel *panel; panel = get_panel(e->xany.window); if (!panel) return; // TODO : one panel_refresh per panel ? - panel_refresh = 1; + panel_refresh = 1; }

@@ -593,39 +601,39 @@ traywin = (TrayWindow*)l->data;

if (traywin->id == win) { //printf("move tray %d\n", traywin->x); XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height); - panel_refresh = 1; + panel_refresh = 1; return; } } // check 'win' move in another monitor - if (nb_panel == 1) return; - if (server.nb_monitor == 1) return; - Task *tsk = task_get_task (win); - if (!tsk) return; + if (nb_panel == 1) return; + if (server.nb_monitor == 1) return; + Task *tsk = task_get_task (win); + if (!tsk) return; - Panel *p = tsk->area.panel; - if (p->monitor != window_get_monitor (win)) { - remove_task (tsk); - add_task (win); - if (win == window_get_active ()) { - Task *tsk = task_get_task (win); + Panel *p = tsk->area.panel; + if (p->monitor != window_get_monitor (win)) { + remove_task (tsk); + add_task (win); + if (win == window_get_active ()) { + Task *tsk = task_get_task (win); tsk->area.is_active = 1; task_active = tsk; } - panel_refresh = 1; - } + panel_refresh = 1; + } } void event_timer() { - struct timeval stv; + struct timeval stv; int i; - if (gettimeofday(&stv, 0)) return; + if (gettimeofday(&stv, 0)) return; - if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return; + if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return; time_clock.tv_sec = stv.tv_sec; time_clock.tv_sec -= time_clock.tv_sec % time_precision;

@@ -648,9 +656,9 @@ }

#endif // update clock - if (time1_format) { + if (time1_format) { for (i=0 ; i < nb_panel ; i++) - panel1[i].clock.area.resize = 1; + panel1[i].clock.area.resize = 1; } panel_refresh = 1; }

@@ -658,20 +666,20 @@

int main (int argc, char *argv[]) { - XEvent e; - fd_set fd; - int x11_fd, i; - struct timeval tv; - Panel *panel; + XEvent e; + fd_set fd; + int x11_fd, i; + struct timeval tv; + Panel *panel; GSList *it; - init (argc, argv); + init (argc, argv); load_config: - i = 0; + i = 0; init_config(); - if (config_path) - i = config_read_file (config_path); + if (config_path) + i = config_read_file (config_path); else i = config_read (); if (!i) {

@@ -679,7 +687,7 @@ fprintf(stderr, "usage: tint2 [-c] <config_file>\n");

cleanup(); exit(1); } - config_finish(); + config_finish(); if (thumbnail_path) { // usage: tint2 -j <file> for internal use printf("file %s\n", thumbnail_path);

@@ -687,46 +695,46 @@ cleanup();

exit(0); } - x11_fd = ConnectionNumber(server.dsp); - XSync(server.dsp, False); + x11_fd = ConnectionNumber(server.dsp); + XSync(server.dsp, False); - while (1) { - // thanks to AngryLlama for the timer - // Create a File Description Set containing x11_fd - FD_ZERO (&fd); - FD_SET (x11_fd, &fd); + while (1) { + // thanks to AngryLlama for the timer + // Create a File Description Set containing x11_fd + FD_ZERO (&fd); + FD_SET (x11_fd, &fd); - tv.tv_usec = 500000; - tv.tv_sec = 0; + tv.tv_usec = 500000; + tv.tv_sec = 0; - // Wait for X Event or a Timer - if (select(x11_fd+1, &fd, 0, 0, &tv)) { - while (XPending (server.dsp)) { - XNextEvent(server.dsp, &e); + // Wait for X Event or a Timer + if (select(x11_fd+1, &fd, 0, 0, &tv)) { + while (XPending (server.dsp)) { + XNextEvent(server.dsp, &e); - switch (e.type) { - case ButtonPress: - event_button_press (&e); - break; + switch (e.type) { + case ButtonPress: + event_button_press (&e); + break; - case ButtonRelease: - event_button_release(&e); - break; + case ButtonRelease: + event_button_release(&e); + break; - case Expose: - event_expose(&e); - break; + case Expose: + event_expose(&e); + break; - case PropertyNotify: - event_property_notify(&e); - break; + case PropertyNotify: + event_property_notify(&e); + break; - case ConfigureNotify: - if (e.xconfigure.window == server.root_win) - goto load_config; - else - event_configure_notify (e.xconfigure.window); - break; + case ConfigureNotify: + if (e.xconfigure.window == server.root_win) + goto load_config; + else + event_configure_notify (e.xconfigure.window); + break; case ReparentNotify: if (!systray.area.on_screen)

@@ -753,24 +761,24 @@ if (!systray.area.on_screen) break;

if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) { net_message(&e.xclient); } - break; - } - } - } - event_timer(); + break; + } + } + } + event_timer(); switch (signal_pending) { case SIGUSR1: signal_pending = 0; - goto load_config; + goto load_config; case SIGINT: case SIGTERM: case SIGHUP: - cleanup (); - return 0; - } + cleanup (); + return 0; + } - if (panel_refresh) { + if (panel_refresh) { panel_refresh = 0; if (refresh_systray) {

@@ -783,8 +791,8 @@

if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap); panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth); - refresh(&panel->area); - XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); + refresh(&panel->area); + XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); } XFlush (server.dsp);

@@ -797,7 +805,7 @@ // force icon's refresh

refresh_systray_icon(); } } - } + } }
M src/util/area.csrc/util/area.c

@@ -41,23 +41,23 @@

size(a); // don't draw transparent objects (without foreground and without background) - if (a->redraw) { - a->redraw = 0; - //printf("draw area posx %d, width %d\n", a->posx, a->width); - draw(a, 0); - if (a->use_active) - draw(a, 1); + if (a->redraw) { + a->redraw = 0; + //printf("draw area posx %d, width %d\n", a->posx, a->width); + draw(a, 0); + if (a->use_active) + draw(a, 1); } // draw current Area - Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap); + Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap); if (*pmap == 0) printf("empty area posx %d, width %d\n", a->posx, a->width); - XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); + XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); - // and then refresh child object + // and then refresh child object GSList *l; - for (l = a->list; l ; l = l->next) - refresh(l->data); + for (l = a->list; l ; l = l->next) + refresh(l->data); }

@@ -66,13 +66,13 @@ {

GSList *l; if (a->resize) { - a->resize = 0; + a->resize = 0; for (l = a->list; l ; l = l->next) size(l->data); - // resize can generate a redraw - if (a->_resize) { - a->_resize(a); + // resize can generate a redraw + if (a->_resize) { + a->_resize(a); } } }

@@ -80,159 +80,159 @@

void set_redraw (Area *a) { - a->redraw = 1; + a->redraw = 1; - GSList *l; - for (l = a->list ; l ; l = l->next) - set_redraw(l->data); + GSList *l; + for (l = a->list ; l ; l = l->next) + set_redraw(l->data); } void draw (Area *a, int active) { - Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap); + Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap); - if (*pmap) XFreePixmap (server.dsp, *pmap); - *pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth); + if (*pmap) XFreePixmap (server.dsp, *pmap); + *pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth); - // add layer of root pixmap - XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); + // add layer of root pixmap + XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); - cairo_surface_t *cs; - cairo_t *c; + cairo_surface_t *cs; + cairo_t *c; - cs = cairo_xlib_surface_create (server.dsp, *pmap, server.visual, a->width, a->height); - c = cairo_create (cs); + cs = cairo_xlib_surface_create (server.dsp, *pmap, server.visual, a->width, a->height); + c = cairo_create (cs); - draw_background (a, c, active); + draw_background (a, c, active); - if (a->_draw_foreground) - a->_draw_foreground(a, c, active); + if (a->_draw_foreground) + a->_draw_foreground(a, c, active); - cairo_destroy (c); - cairo_surface_destroy (cs); + cairo_destroy (c); + cairo_surface_destroy (cs); } void draw_background (Area *a, cairo_t *c, int active) { - Pmap *pix = (active == 0) ? (&a->pix) : (&a->pix_active); + Pmap *pix = (active == 0) ? (&a->pix) : (&a->pix_active); - if (pix->back.alpha > 0.0) { - //printf(" draw_background (%d %d) RGBA (%lf, %lf, %lf, %lf)\n", a->posx, a->posy, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha); - draw_rect(c, pix->border.width, pix->border.width, a->width-(2.0 * pix->border.width), a->height-(2.0*pix->border.width), pix->border.rounded - pix->border.width/1.571); - cairo_set_source_rgba(c, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha); + if (pix->back.alpha > 0.0) { + //printf(" draw_background (%d %d) RGBA (%lf, %lf, %lf, %lf)\n", a->posx, a->posy, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha); + draw_rect(c, pix->border.width, pix->border.width, a->width-(2.0 * pix->border.width), a->height-(2.0*pix->border.width), pix->border.rounded - pix->border.width/1.571); + cairo_set_source_rgba(c, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha); - cairo_fill(c); - } + cairo_fill(c); + } - if (pix->border.width > 0 && pix->border.alpha > 0.0) { - cairo_set_line_width (c, pix->border.width); + if (pix->border.width > 0 && pix->border.alpha > 0.0) { + cairo_set_line_width (c, pix->border.width); - // draw border inside (x, y, width, height) - draw_rect(c, pix->border.width/2.0, pix->border.width/2.0, a->width - pix->border.width, a->height - pix->border.width, pix->border.rounded); - /* - // convert : radian = degre * M_PI/180 - // définir le dégradé dans un carré de (0,0) (100,100) - // ensuite ce dégradé est extrapolé selon le ratio width/height - // dans repère (0, 0) (100, 100) - double X0, Y0, X1, Y1, degre; - // x = X * (a->width / 100), y = Y * (a->height / 100) - double x0, y0, x1, y1; - X0 = 0; - Y0 = 100; - X1 = 100; - Y1 = 0; - degre = 45; - // et ensuite faire la changement d'unité du repère - // car ce qui doit resté inchangée est les traits et pas la direction + // draw border inside (x, y, width, height) + draw_rect(c, pix->border.width/2.0, pix->border.width/2.0, a->width - pix->border.width, a->height - pix->border.width, pix->border.rounded); + /* + // convert : radian = degre * M_PI/180 + // définir le dégradé dans un carré de (0,0) (100,100) + // ensuite ce dégradé est extrapolé selon le ratio width/height + // dans repère (0, 0) (100, 100) + double X0, Y0, X1, Y1, degre; + // x = X * (a->width / 100), y = Y * (a->height / 100) + double x0, y0, x1, y1; + X0 = 0; + Y0 = 100; + X1 = 100; + Y1 = 0; + degre = 45; + // et ensuite faire la changement d'unité du repère + // car ce qui doit resté inchangée est les traits et pas la direction - // il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°) - // ceci peut être appliqué une fois pour toute au départ - // ensuite calculer l'angle dans le nouveau repère - // puis faire une rotation de 90° - x0 = X0 * ((double)a->width / 100); - x1 = X1 * ((double)a->width / 100); - y0 = Y0 * ((double)a->height / 100); - y1 = Y1 * ((double)a->height / 100); + // il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°) + // ceci peut être appliqué une fois pour toute au départ + // ensuite calculer l'angle dans le nouveau repère + // puis faire une rotation de 90° + x0 = X0 * ((double)a->width / 100); + x1 = X1 * ((double)a->width / 100); + y0 = Y0 * ((double)a->height / 100); + y1 = Y1 * ((double)a->height / 100); - x0 = X0 * ((double)a->height / 100); - x1 = X1 * ((double)a->height / 100); - y0 = Y0 * ((double)a->width / 100); - y1 = Y1 * ((double)a->width / 100); + x0 = X0 * ((double)a->height / 100); + x1 = X1 * ((double)a->height / 100); + y0 = Y0 * ((double)a->width / 100); + y1 = Y1 * ((double)a->width / 100); - cairo_pattern_t *linpat; - linpat = cairo_pattern_create_linear (x0, y0, x1, y1); - cairo_pattern_add_color_stop_rgba (linpat, 0, a->border.color[0], a->border.color[1], a->border.color[2], a->border.alpha); - cairo_pattern_add_color_stop_rgba (linpat, 1, a->border.color[0], a->border.color[1], a->border.color[2], 0); - cairo_set_source (c, linpat); - */ - cairo_set_source_rgba (c, pix->border.color[0], pix->border.color[1], pix->border.color[2], pix->border.alpha); + cairo_pattern_t *linpat; + linpat = cairo_pattern_create_linear (x0, y0, x1, y1); + cairo_pattern_add_color_stop_rgba (linpat, 0, a->border.color[0], a->border.color[1], a->border.color[2], a->border.alpha); + cairo_pattern_add_color_stop_rgba (linpat, 1, a->border.color[0], a->border.color[1], a->border.color[2], 0); + cairo_set_source (c, linpat); + */ + cairo_set_source_rgba (c, pix->border.color[0], pix->border.color[1], pix->border.color[2], pix->border.alpha); - cairo_stroke (c); - //cairo_pattern_destroy (linpat); - } + cairo_stroke (c); + //cairo_pattern_destroy (linpat); + } } void remove_area (Area *a) { - Area *parent = (Area*)a->parent; + Area *parent = (Area*)a->parent; - parent->list = g_slist_remove(parent->list, a); - set_redraw (parent); + parent->list = g_slist_remove(parent->list, a); + set_redraw (parent); } void add_area (Area *a) { - Area *parent = (Area*)a->parent; + Area *parent = (Area*)a->parent; - parent->list = g_slist_remove(parent->list, a); - set_redraw (parent); + parent->list = g_slist_remove(parent->list, a); + set_redraw (parent); } void free_area (Area *a) { - GSList *l0; - for (l0 = a->list; l0 ; l0 = l0->next) - free_area (l0->data); + GSList *l0; + for (l0 = a->list; l0 ; l0 = l0->next) + free_area (l0->data); - if (a->list) { - g_slist_free(a->list); - a->list = 0; - } - if (a->pix.pmap) { - XFreePixmap (server.dsp, a->pix.pmap); - a->pix.pmap = 0; + if (a->list) { + g_slist_free(a->list); + a->list = 0; + } + if (a->pix.pmap) { + XFreePixmap (server.dsp, a->pix.pmap); + a->pix.pmap = 0; } - if (a->pix_active.pmap) { - XFreePixmap (server.dsp, a->pix_active.pmap); - a->pix_active.pmap = 0; + if (a->pix_active.pmap) { + XFreePixmap (server.dsp, a->pix_active.pmap); + a->pix_active.pmap = 0; } } void draw_rect(cairo_t *c, double x, double y, double w, double h, double r) { - if (r > 0.0) { - double c1 = 0.55228475 * r; + if (r > 0.0) { + double c1 = 0.55228475 * r; - cairo_move_to(c, x+r, y); - cairo_rel_line_to(c, w-2*r, 0); - cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r); - cairo_rel_line_to(c, 0, h-2*r); - cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r); - cairo_rel_line_to (c, -w +2*r, 0); - cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r); - cairo_rel_line_to (c, 0, -h + 2 * r); - cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r); - } - else - cairo_rectangle(c, x, y, w, h); + cairo_move_to(c, x+r, y); + cairo_rel_line_to(c, w-2*r, 0); + cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r); + cairo_rel_line_to(c, 0, h-2*r); + cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r); + cairo_rel_line_to (c, -w +2*r, 0); + cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r); + cairo_rel_line_to (c, 0, -h + 2 * r); + cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r); + } + else + cairo_rectangle(c, x, y, w, h); }
M src/util/window.csrc/util/window.c

@@ -38,70 +38,70 @@

void set_active (Window win) { - send_event32 (win, server.atom._NET_ACTIVE_WINDOW, 2, CurrentTime, 0); + send_event32 (win, server.atom._NET_ACTIVE_WINDOW, 2, CurrentTime, 0); } void set_desktop (int desktop) { - send_event32 (server.root_win, server.atom._NET_CURRENT_DESKTOP, desktop, 0, 0); + send_event32 (server.root_win, server.atom._NET_CURRENT_DESKTOP, desktop, 0, 0); } void windows_set_desktop (Window win, int desktop) { - send_event32 (win, server.atom._NET_WM_DESKTOP, desktop, 2, 0); + send_event32 (win, server.atom._NET_WM_DESKTOP, desktop, 2, 0); } void set_close (Window win) { - send_event32 (win, server.atom._NET_CLOSE_WINDOW, 0, 2, 0); + send_event32 (win, server.atom._NET_CLOSE_WINDOW, 0, 2, 0); } void window_toggle_shade (Window win) { - send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_SHADED, 0); + send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_SHADED, 0); } void window_maximize_restore (Window win) { - send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_VERT, 0); - send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_HORZ, 0); + send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_VERT, 0); + send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_HORZ, 0); } int window_is_hidden (Window win) { - Window window; - Atom *at; - int count, i; + Window window; + Atom *at; + int count, i; - if (XGetTransientForHint(server.dsp, win, &window) != 0) { - if (window) { - return 1; - } - } + if (XGetTransientForHint(server.dsp, win, &window) != 0) { + if (window) { + return 1; + } + } - at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count); - for (i = 0; i < count; i++) { - if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) { - XFree(at); - return 1; - } - } - XFree(at); + at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count); + for (i = 0; i < count; i++) { + if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) { + XFree(at); + return 1; + } + } + XFree(at); - at = server_get_property (win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count); - for (i = 0; i < count; i++) { - if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) { - XFree(at); - return 1; - } - } - XFree(at); + at = server_get_property (win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count); + for (i = 0; i < count; i++) { + if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) { + XFree(at); + return 1; + } + } + XFree(at); for (i=0 ; i < nb_panel ; i++) { if (panel1[i].main_win == win) {

@@ -109,172 +109,189 @@ return 1;

} } - // specification - // Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set - // MUST be taken as top-level window. - return 0; + // specification + // Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set + // MUST be taken as top-level window. + return 0; } int window_get_desktop (Window win) { - return get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL); + return get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL); } int window_get_monitor (Window win) { - int i, x, y; - Window src; + int i, x, y; + Window src; - XTranslateCoordinates(server.dsp, win, server.root_win, 0, 0, &x, &y, &src); - x += 2; - y += 2; - for (i = 0; i < server.nb_monitor; i++) { - if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width)) - if (y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height)) - break; - } + XTranslateCoordinates(server.dsp, win, server.root_win, 0, 0, &x, &y, &src); + x += 2; + y += 2; + for (i = 0; i < server.nb_monitor; i++) { + if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width)) + if (y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height)) + break; + } - //printf("window %lx : ecran %d, (%d, %d)\n", win, i, x, y); - if (i == server.nb_monitor) return 0; - else return i; + //printf("window %lx : ecran %d, (%d, %d)\n", win, i, x, y); + if (i == server.nb_monitor) return 0; + else return i; } int window_is_iconified (Window win) { - return (IconicState == get_property32(win, server.atom.WM_STATE, server.atom.WM_STATE)); + return (IconicState == get_property32(win, server.atom.WM_STATE, server.atom.WM_STATE)); } int window_is_urgent (Window win) { - Atom *at; - int count, i; + Atom *at; + int count, i; + + at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count); + for (i = 0; i < count; i++) { + if (at[i] == server.atom._NET_WM_STATE_DEMANDS_ATTENTION) { + XFree(at); + return 1; + } + } + XFree(at); + return 0; +} + + +int window_is_skip_taskbar (Window win) +{ + Atom *at; + int count, i; - at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count); - for (i = 0; i < count; i++) { - if (at[i] == server.atom._NET_WM_STATE_DEMANDS_ATTENTION) { - XFree(at); - return 1; - } - } - XFree(at); + at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count); + for (i=0; i<count; i++) { + if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) { + XFree(at); + return 1; + } + } + XFree(at); return 0; } int server_get_number_of_desktop () { - return get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL); + return get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL); } int server_get_current_desktop () { - return get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL); + return get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL); } Window window_get_active () { - return get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW); + return get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW); } int window_is_active (Window win) { - return (win == get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW)); + return (win == get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW)); } int get_icon_count (long *data, int num) { - int count, pos, w, h; + int count, pos, w, h; - count = 0; - pos = 0; - while (pos < num) { - w = data[pos++]; - h = data[pos++]; - pos += w * h; - if (pos > num || w * h == 0) break; - count++; - } + count = 0; + pos = 0; + while (pos < num) { + w = data[pos++]; + h = data[pos++]; + pos += w * h; + if (pos > num || w * h == 0) break; + count++; + } - return count; + return count; } long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size) { - int width[icon_count], height[icon_count], pos, i, w, h; - long *icon_data[icon_count]; + int width[icon_count], height[icon_count], pos, i, w, h; + long *icon_data[icon_count]; - /* List up icons */ - pos = 0; - i = icon_count; - while (i--) { - w = data[pos++]; - h = data[pos++]; - if (pos + w * h > num) break; + /* List up icons */ + pos = 0; + i = icon_count; + while (i--) { + w = data[pos++]; + h = data[pos++]; + if (pos + w * h > num) break; - width[i] = w; - height[i] = h; - icon_data[i] = &data[pos]; + width[i] = w; + height[i] = h; + icon_data[i] = &data[pos]; - pos += w * h; - } + pos += w * h; + } - /* Try to find exact size */ - int icon_num = -1; - for (i = 0; i < icon_count; i++) { - if (width[i] == best_icon_size) { - icon_num = i; - break; - } - } + /* Try to find exact size */ + int icon_num = -1; + for (i = 0; i < icon_count; i++) { + if (width[i] == best_icon_size) { + icon_num = i; + break; + } + } - /* Take the biggest or whatever */ - if (icon_num < 0) { - int highest = 0; - for (i = 0; i < icon_count; i++) { - if (width[i] > highest) { - icon_num = i; - highest = width[i]; - } - } - } + /* Take the biggest or whatever */ + if (icon_num < 0) { + int highest = 0; + for (i = 0; i < icon_count; i++) { + if (width[i] > highest) { + icon_num = i; + highest = width[i]; + } + } + } - *iw = width[icon_num]; - *ih = height[icon_num]; - return icon_data[icon_num]; + *iw = width[icon_num]; + *ih = height[icon_num]; + return icon_data[icon_num]; } void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len) { - PangoRectangle rect_ink, rect; + PangoRectangle rect_ink, rect; - Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth); + Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth); - cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height); - cairo_t *c = cairo_create (cs); + cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height); + cairo_t *c = cairo_create (cs); - PangoLayout *layout = pango_cairo_create_layout (c); - pango_layout_set_font_description (layout, font); - pango_layout_set_text (layout, text, len); + PangoLayout *layout = pango_cairo_create_layout (c); + pango_layout_set_font_description (layout, font); + pango_layout_set_text (layout, text, len); - pango_layout_get_pixel_extents(layout, &rect_ink, &rect); - *height_ink = rect_ink.height; - *height = rect.height; - //printf("dimension : %d - %d\n", rect_ink.height, rect.height); + pango_layout_get_pixel_extents(layout, &rect_ink, &rect); + *height_ink = rect_ink.height; + *height = rect.height; + //printf("dimension : %d - %d\n", rect_ink.height, rect.height); - g_object_unref (layout); - cairo_destroy (c); - cairo_surface_destroy (cs); - XFreePixmap (server.dsp, pmap); + g_object_unref (layout); + cairo_destroy (c); + cairo_surface_destroy (cs); + XFreePixmap (server.dsp, pmap); }
M src/util/window.hsrc/util/window.h

@@ -21,6 +21,7 @@ int window_is_iconified (Window win);

int window_is_urgent (Window win); int window_is_hidden (Window win); int window_is_active (Window win); +int window_is_skip_taskbar (Window win); int get_icon_count (long *data, int num); long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size); void window_maximize_restore (Window win);