diff --git a/src/battery/battery.c b/src/battery/battery.c index f759aa9..b4317ef 100644 --- a/src/battery/battery.c +++ b/src/battery/battery.c @@ -57,6 +57,146 @@ char *battery_dwheel_command; gboolean battery_found; void battery_init_fonts(); +char *battery_get_tooltip(void *obj); + +void default_battery() +{ + battery_enabled = FALSE; + battery_tooltip_enabled = TRUE; + battery_found = FALSE; + percentage_hide = 101; + battery_low_cmd_sent = FALSE; + battery_timeout = NULL; + bat1_has_font = FALSE; + bat1_font_desc = NULL; + bat2_has_font = FALSE; + bat2_font_desc = NULL; + ac_connected_cmd = NULL; + ac_disconnected_cmd = NULL; + battery_low_cmd = NULL; + battery_lclick_command = NULL; + battery_mclick_command = NULL; + battery_rclick_command = NULL; + battery_uwheel_command = NULL; + battery_dwheel_command = NULL; + battery_state.percentage = 0; + battery_state.time.hours = 0; + battery_state.time.minutes = 0; + battery_state.time.seconds = 0; + battery_state.state = BATTERY_UNKNOWN; +} + +void cleanup_battery() +{ + pango_font_description_free(bat1_font_desc); + bat1_font_desc = NULL; + pango_font_description_free(bat2_font_desc); + bat2_font_desc = NULL; + free(battery_low_cmd); + battery_low_cmd = NULL; + free(battery_lclick_command); + battery_lclick_command = NULL; + free(battery_mclick_command); + battery_mclick_command = NULL; + free(battery_rclick_command); + battery_rclick_command = NULL; + free(battery_uwheel_command); + battery_uwheel_command = NULL; + free(battery_dwheel_command); + battery_dwheel_command = NULL; + free(ac_connected_cmd); + ac_connected_cmd = NULL; + free(ac_disconnected_cmd); + ac_disconnected_cmd = NULL; + stop_timeout(battery_timeout); + battery_timeout = NULL; + battery_found = FALSE; + + battery_os_free(); +} + +void init_battery() +{ + if (!battery_enabled) + return; + + battery_found = battery_os_init(); + + if (!battery_timeout) + battery_timeout = add_timeout(10, 30000, update_battery_tick, 0, &battery_timeout); + + update_battery(); +} + +void reinit_battery() +{ + battery_os_free(); + battery_found = battery_os_init(); + update_battery(); +} + +void init_battery_panel(void *p) +{ + Panel *panel = (Panel *)p; + Battery *battery = &panel->battery; + + if (!battery_enabled) + return; + + battery_init_fonts(); + + if (!battery->area.bg) + battery->area.bg = &g_array_index(backgrounds, Background, 0); + + battery->area.parent = p; + battery->area.panel = p; + battery->area._draw_foreground = draw_battery; + battery->area.size_mode = LAYOUT_FIXED; + battery->area._resize = resize_battery; + battery->area.on_screen = TRUE; + battery->area.resize_needed = 1; + battery->area.has_mouse_over_effect = battery_lclick_command || battery_mclick_command || battery_rclick_command || + battery_uwheel_command || battery_dwheel_command; + battery->area.has_mouse_press_effect = battery->area.has_mouse_over_effect; + if (battery_tooltip_enabled) + battery->area._get_tooltip_text = battery_get_tooltip; +} + +void battery_init_fonts() +{ + if (!bat1_font_desc) { + bat1_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(bat1_font_desc, + pango_font_description_get_size(bat1_font_desc) - PANGO_SCALE); + } + if (!bat2_font_desc) { + bat2_font_desc = pango_font_description_from_string(get_default_font()); + pango_font_description_set_size(bat2_font_desc, + pango_font_description_get_size(bat2_font_desc) - PANGO_SCALE); + } +} + +void battery_default_font_changed() +{ + if (!battery_enabled) + return; + if (bat1_has_font && bat2_has_font) + return; + if (!bat1_has_font) { + pango_font_description_free(bat1_font_desc); + bat1_font_desc = NULL; + } + if (!bat2_has_font) { + pango_font_description_free(bat2_font_desc); + bat2_font_desc = NULL; + } + battery_init_fonts(); + for (int i = 0; i < num_panels; i++) { + panels[i].battery.area.resize_needed = TRUE; + panels[i].battery.area.redraw_needed = TRUE; + } + panel_refresh = TRUE; +} void update_battery_tick(void *arg) { @@ -126,162 +266,17 @@ void update_battery_tick(void *arg) } } -void default_battery() -{ - battery_enabled = FALSE; - battery_tooltip_enabled = TRUE; - battery_found = FALSE; - percentage_hide = 101; - battery_low_cmd_sent = FALSE; - battery_timeout = NULL; - bat1_has_font = FALSE; - bat1_font_desc = NULL; - bat2_has_font = FALSE; - bat2_font_desc = NULL; - ac_connected_cmd = NULL; - ac_disconnected_cmd = NULL; - battery_low_cmd = NULL; - battery_lclick_command = NULL; - battery_mclick_command = NULL; - battery_rclick_command = NULL; - battery_uwheel_command = NULL; - battery_dwheel_command = NULL; - battery_state.percentage = 0; - battery_state.time.hours = 0; - battery_state.time.minutes = 0; - battery_state.time.seconds = 0; - battery_state.state = BATTERY_UNKNOWN; -} - -void cleanup_battery() -{ - pango_font_description_free(bat1_font_desc); - bat1_font_desc = NULL; - pango_font_description_free(bat2_font_desc); - bat2_font_desc = NULL; - free(battery_low_cmd); - battery_low_cmd = NULL; - free(battery_lclick_command); - battery_lclick_command = NULL; - free(battery_mclick_command); - battery_mclick_command = NULL; - free(battery_rclick_command); - battery_rclick_command = NULL; - free(battery_uwheel_command); - battery_uwheel_command = NULL; - free(battery_dwheel_command); - battery_dwheel_command = NULL; - free(ac_connected_cmd); - ac_connected_cmd = NULL; - free(ac_disconnected_cmd); - ac_disconnected_cmd = NULL; - stop_timeout(battery_timeout); - battery_timeout = NULL; - battery_found = FALSE; - - battery_os_free(); -} - -void reinit_battery() -{ - battery_os_free(); - battery_found = battery_os_init(); - update_battery(); -} -void init_battery() -{ - if (!battery_enabled) - return; - - battery_found = battery_os_init(); - - if (!battery_timeout) - battery_timeout = add_timeout(10, 30000, update_battery_tick, 0, &battery_timeout); - - update_battery(); -} - -char *battery_get_tooltip(void *obj) -{ - return battery_os_tooltip(); -} - -void init_battery_panel(void *p) -{ - Panel *panel = (Panel *)p; - Battery *battery = &panel->battery; - - if (!battery_enabled) - return; - - battery_init_fonts(); - - if (!battery->area.bg) - battery->area.bg = &g_array_index(backgrounds, Background, 0); - - battery->area.parent = p; - battery->area.panel = p; - battery->area._draw_foreground = draw_battery; - battery->area.size_mode = LAYOUT_FIXED; - battery->area._resize = resize_battery; - battery->area.on_screen = TRUE; - battery->area.resize_needed = 1; - battery->area.has_mouse_over_effect = battery_lclick_command || battery_mclick_command || battery_rclick_command || - battery_uwheel_command || battery_dwheel_command; - battery->area.has_mouse_press_effect = battery->area.has_mouse_over_effect; - if (battery_tooltip_enabled) - battery->area._get_tooltip_text = battery_get_tooltip; -} - -void battery_init_fonts() -{ - if (!bat1_font_desc) { - bat1_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(bat1_font_desc, - pango_font_description_get_size(bat1_font_desc) - PANGO_SCALE); - } - if (!bat2_font_desc) { - bat2_font_desc = pango_font_description_from_string(get_default_font()); - pango_font_description_set_size(bat2_font_desc, - pango_font_description_get_size(bat2_font_desc) - PANGO_SCALE); - } -} - -void battery_default_font_changed() -{ - if (!battery_enabled) - return; - if (bat1_has_font && bat2_has_font) - return; - if (!bat1_has_font) { - pango_font_description_free(bat1_font_desc); - bat1_font_desc = NULL; - } - if (!bat2_has_font) { - pango_font_description_free(bat2_font_desc); - bat2_font_desc = NULL; - } - battery_init_fonts(); - for (int i = 0; i < num_panels; i++) { - panels[i].battery.area.resize_needed = TRUE; - panels[i].battery.area.redraw_needed = TRUE; - } - panel_refresh = TRUE; -} - int update_battery() { - int err; - - /* reset */ + // Reset battery_state.state = BATTERY_UNKNOWN; battery_state.percentage = 0; battery_state.ac_connected = FALSE; battery_state_set_time(&battery_state, 0); - err = battery_os_update(&battery_state); + int err = battery_os_update(&battery_state); - // clamp percentage to 100 in case battery is misreporting that its current charge is more than its max + // Clamp percentage to 100 in case battery is misreporting that its current charge is more than its max if (battery_state.percentage > 100) { battery_state.percentage = 100; } @@ -289,40 +284,6 @@ int update_battery() return err; } -void draw_battery(void *obj, cairo_t *c) -{ - Battery *battery = obj; - PangoLayout *layout; - - layout = pango_cairo_create_layout(c); - - // draw layout - pango_layout_set_font_description(layout, bat1_font_desc); - pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); - pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, buf_bat_percentage, strlen(buf_bat_percentage)); - - cairo_set_source_rgba(c, battery->font.rgb[0], battery->font.rgb[1], battery->font.rgb[2], battery->font.alpha); - - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, battery->bat1_posy, &battery->font, ((Panel *)battery->area.panel)->font_shadow); - - pango_layout_set_font_description(layout, bat2_font_desc); - pango_layout_set_indent(layout, 0); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, buf_bat_time, strlen(buf_bat_time)); - pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); - - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, battery->bat2_posy, &battery->font, ((Panel *)battery->area.panel)->font_shadow); - pango_cairo_show_layout(c, layout); - - g_object_unref(layout); -} - gboolean resize_battery(void *obj) { Battery *battery = obj; @@ -374,7 +335,7 @@ gboolean resize_battery(void *obj) } } else { int new_size = - bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width)); + bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width)); if (new_size > battery->area.height || new_size < battery->area.height - 2) { battery->area.height = new_size; battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2) / 2; @@ -385,9 +346,49 @@ gboolean resize_battery(void *obj) return ret; } +void draw_battery(void *obj, cairo_t *c) +{ + Battery *battery = obj; + + PangoLayout *layout = pango_cairo_create_layout(c); + pango_layout_set_font_description(layout, bat1_font_desc); + pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, buf_bat_percentage, strlen(buf_bat_percentage)); + + cairo_set_source_rgba(c, + battery->font_color.rgb[0], + battery->font_color.rgb[1], + battery->font_color.rgb[2], + battery->font_color.alpha); + + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, battery->bat1_posy, &battery->font_color, ((Panel *)battery->area.panel)->font_shadow); + + pango_layout_set_font_description(layout, bat2_font_desc); + pango_layout_set_indent(layout, 0); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, buf_bat_time, strlen(buf_bat_time)); + pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); + + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, battery->bat2_posy, &battery->font_color, ((Panel *)battery->area.panel)->font_shadow); + pango_cairo_show_layout(c, layout); + + g_object_unref(layout); +} + +char *battery_get_tooltip(void *obj) +{ + return battery_os_tooltip(); +} + void battery_action(int button) { - char *command = 0; + char *command = NULL; switch (button) { case 1: command = battery_lclick_command; diff --git a/src/battery/battery.h b/src/battery/battery.h index 14eb9fc..c515d37 100644 --- a/src/battery/battery.h +++ b/src/battery/battery.h @@ -16,12 +16,9 @@ #include "common.h" #include "area.h" -// battery drawing parameter (per panel) typedef struct Battery { - // always start with area Area area; - - Color font; + Color font_color; int bat1_posy; int bat2_posy; } Battery; diff --git a/src/clock/clock.c b/src/clock/clock.c index 8abc81c..6064d39 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -54,6 +54,7 @@ int clock_enabled; static timeout *clock_timeout; void clock_init_fonts(); +char *clock_get_tooltip(void *obj); void default_clock() { @@ -111,9 +112,8 @@ void cleanup_clock() void update_clocks_sec(void *arg) { gettimeofday(&time_clock, 0); - int i; if (time1_format) { - for (i = 0; i < num_panels; i++) + for (int i = 0; i < num_panels; i++) panels[i].clock.area.resize_needed = 1; } panel_refresh = TRUE; @@ -126,9 +126,8 @@ void update_clocks_min(void *arg) time_t old_sec = time_clock.tv_sec; gettimeofday(&time_clock, 0); if (time_clock.tv_sec % 60 == 0 || time_clock.tv_sec - old_sec > 60) { - int i; if (time1_format) { - for (i = 0; i < num_panels; i++) + for (int i = 0; i < num_panels; i++) panels[i].clock.area.resize_needed = 1; } panel_refresh = TRUE; @@ -146,23 +145,18 @@ struct tm *clock_gettime_for_tz(const char *timezone) else unsetenv("TZ"); return result; - } else + } else { return localtime(&time_clock.tv_sec); + } } -char *clock_get_tooltip(void *obj) -{ - strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); - return strdup(buf_tooltip); -} - -int time_format_needs_sec_ticks(char *time_format) +gboolean time_format_needs_sec_ticks(char *time_format) { if (!time_format) - return 0; + return FALSE; if (strchr(time_format, 'S') || strchr(time_format, 'T') || strchr(time_format, 'r')) - return 1; - return 0; + return TRUE; + return FALSE; } void init_clock() @@ -242,44 +236,12 @@ void clock_default_font_changed() panel_refresh = TRUE; } -void draw_clock(void *obj, cairo_t *c) -{ - Clock *clock = obj; - PangoLayout *layout; - - 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_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, buf_time, strlen(buf_time)); - - cairo_set_source_rgba(c, clock->font.rgb[0], clock->font.rgb[1], clock->font.rgb[2], clock->font.alpha); - - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, clock->time1_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow); - - 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); - draw_text(layout, c, 0, clock->time2_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow); - } - - g_object_unref(layout); -} - gboolean resize_clock(void *obj) { Clock *clock = obj; Panel *panel = clock->area.panel; - int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width, ret = 0; + int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width; + gboolean result = FALSE; clock->area.redraw_needed = TRUE; @@ -322,7 +284,7 @@ gboolean resize_clock(void *obj) clock->time1_posy -= (date_height) / 2; clock->time2_posy = clock->time1_posy + time_height; } - ret = 1; + result = TRUE; } } else { int new_size = time_height + date_height + (2 * (clock->area.paddingxlr + clock->area.bg->border.width)); @@ -334,16 +296,52 @@ gboolean resize_clock(void *obj) clock->time1_posy -= (date_height) / 2; clock->time2_posy = clock->time1_posy + time_height; } - ret = 1; + result = TRUE; } } - return ret; + return result; +} + +void draw_clock(void *obj, cairo_t *c) +{ + Clock *clock = obj; + PangoLayout *layout = pango_cairo_create_layout(c); + + 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_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, buf_time, strlen(buf_time)); + + cairo_set_source_rgba(c, clock->font.rgb[0], clock->font.rgb[1], clock->font.rgb[2], clock->font.alpha); + + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, clock->time1_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow); + + 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); + draw_text(layout, c, 0, clock->time2_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow); + } + + g_object_unref(layout); +} + +char *clock_get_tooltip(void *obj) +{ + strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); + return strdup(buf_tooltip); } void clock_action(int button) { - char *command = 0; + char *command = NULL; switch (button) { case 1: command = clock_lclick_command; @@ -363,4 +361,3 @@ void clock_action(int button) } tint_exec(command); } - diff --git a/src/config.c b/src/config.c index 03c49ec..783e914 100644 --- a/src/config.c +++ b/src/config.c @@ -318,7 +318,6 @@ void add_entry(char *key, char *value) } else if (strcmp(key, "panel_items") == 0) { new_config_file = 1; panel_items_order = strdup(value); - int j; systray_enabled = 0; launcher_enabled = 0; #ifdef ENABLE_BATTERY @@ -326,7 +325,7 @@ void add_entry(char *key, char *value) #endif clock_enabled = 0; taskbar_enabled = 0; - for (j = 0; j < strlen(panel_items_order); j++) { + for (int j = 0; j < strlen(panel_items_order); j++) { if (panel_items_order[j] == 'L') launcher_enabled = 1; if (panel_items_order[j] == 'T') @@ -477,11 +476,11 @@ void add_entry(char *key, char *value) } else if (strcmp(key, "battery_font_color") == 0) { #ifdef ENABLE_BATTERY extract_values(value, &value1, &value2, &value3); - get_color(value1, panel_config.battery.font.rgb); + get_color(value1, panel_config.battery.font_color.rgb); if (value2) - panel_config.battery.font.alpha = (atoi(value2) / 100.0); + panel_config.battery.font_color.alpha = (atoi(value2) / 100.0); else - panel_config.battery.font.alpha = 0.5; + panel_config.battery.font_color.alpha = 0.5; #endif } else if (strcmp(key, "battery_padding") == 0) { #ifdef ENABLE_BATTERY diff --git a/src/execplugin/execplugin.c b/src/execplugin/execplugin.c index ccc3e7f..7f5e140 100644 --- a/src/execplugin/execplugin.c +++ b/src/execplugin/execplugin.c @@ -273,39 +273,6 @@ gboolean reload_icon(Execp *execp) return FALSE; } -void draw_execp(void *obj, cairo_t *c) -{ - Execp *execp = obj; - PangoLayout *layout = pango_cairo_create_layout(c); - - if (execp->backend->has_icon && execp->backend->icon) { - imlib_context_set_image(execp->backend->icon); - // Render icon - render_image(execp->area.pix, execp->frontend->iconx, execp->frontend->icony); - } - - // draw layout - pango_layout_set_font_description(layout, execp->backend->font_desc); - pango_layout_set_width(layout, execp->frontend->textw * PANGO_SCALE); - pango_layout_set_alignment(layout, execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - if (!execp->backend->has_markup) - pango_layout_set_text(layout, execp->backend->text, strlen(execp->backend->text)); - else - pango_layout_set_markup(layout, execp->backend->text, strlen(execp->backend->text)); - - pango_cairo_update_layout(c, layout); - draw_text(layout, - c, - execp->frontend->textx, - execp->frontend->texty, - &execp->backend->font_color, - panel_config.font_shadow); - - g_object_unref(layout); -} - gboolean resize_execp(void *obj) { Execp *execp = obj; @@ -428,6 +395,39 @@ gboolean resize_execp(void *obj) return result; } +void draw_execp(void *obj, cairo_t *c) +{ + Execp *execp = obj; + PangoLayout *layout = pango_cairo_create_layout(c); + + if (execp->backend->has_icon && execp->backend->icon) { + imlib_context_set_image(execp->backend->icon); + // Render icon + render_image(execp->area.pix, execp->frontend->iconx, execp->frontend->icony); + } + + // draw layout + pango_layout_set_font_description(layout, execp->backend->font_desc); + pango_layout_set_width(layout, execp->frontend->textw * PANGO_SCALE); + pango_layout_set_alignment(layout, execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + if (!execp->backend->has_markup) + pango_layout_set_text(layout, execp->backend->text, strlen(execp->backend->text)); + else + pango_layout_set_markup(layout, execp->backend->text, strlen(execp->backend->text)); + + pango_cairo_update_layout(c, layout); + draw_text(layout, + c, + execp->frontend->textx, + execp->frontend->texty, + &execp->backend->font_color, + panel_config.font_shadow); + + g_object_unref(layout); +} + void execp_action(void *obj, int button) { Execp *execp = obj; diff --git a/src/freespace/freespace.c b/src/freespace/freespace.c index 9b8ca37..676880f 100644 --- a/src/freespace/freespace.c +++ b/src/freespace/freespace.c @@ -48,9 +48,8 @@ void init_freespace_panel(void *p) int freespace_get_max_size(Panel *p) { // Get space used by every element except the freespace - GList *walk; int size = 0; - for (walk = p->area.children; walk; walk = g_list_next(walk)) { + for (GList *walk = p->area.children; walk; walk = g_list_next(walk)) { Area *a = (Area *)walk->data; if (a->_resize == resize_freespace || !a->on_screen) @@ -75,12 +74,12 @@ gboolean resize_freespace(void *obj) FreeSpace *freespace = (FreeSpace *)obj; Panel *panel = (Panel *)freespace->area.panel; if (!freespace->area.on_screen) - return 0; + return FALSE; int old_size = panel_horizontal ? freespace->area.width : freespace->area.height; int size = freespace_get_max_size(panel); if (old_size == size) - return 0; + return FALSE; if (panel_horizontal) { freespace->area.width = size; @@ -90,5 +89,5 @@ gboolean resize_freespace(void *obj) freespace->area.redraw_needed = TRUE; panel_refresh = TRUE; - return 1; + return TRUE; } diff --git a/src/launcher/launcher.c b/src/launcher/launcher.c index 6bcc9a9..c56d63d 100644 --- a/src/launcher/launcher.c +++ b/src/launcher/launcher.c @@ -107,16 +107,13 @@ void init_launcher_panel(void *p) void cleanup_launcher() { - int i; - GSList *l; - - for (i = 0; i < num_panels; i++) { + for (int i = 0; i < num_panels; i++) { Panel *panel = &panels[i]; Launcher *launcher = &panel->launcher; cleanup_launcher_theme(launcher); } - for (l = panel_config.launcher.list_apps; l; l = l->next) { + for (GSList *l = panel_config.launcher.list_apps; l; l = l->next) { free(l->data); } g_slist_free(panel_config.launcher.list_apps); @@ -128,14 +125,13 @@ void cleanup_launcher() free(icon_theme_name_xsettings); icon_theme_name_xsettings = NULL; - launcher_enabled = 0; + launcher_enabled = FALSE; } void cleanup_launcher_theme(Launcher *launcher) { free_area(&launcher->area); - GSList *l; - for (l = launcher->list_icons; l; l = l->next) { + for (GSList *l = launcher->list_icons; l; l = l->next) { LauncherIcon *launcherIcon = (LauncherIcon *)l->data; if (launcherIcon) { free_icon(launcherIcon->image); @@ -158,10 +154,9 @@ void cleanup_launcher_theme(Launcher *launcher) gboolean resize_launcher(void *obj) { Launcher *launcher = obj; - GSList *l; - int count, icon_size; int icons_per_column = 1, icons_per_row = 1, margin = 0; + int icon_size; if (panel_horizontal) { icon_size = launcher->area.height; } else { @@ -172,7 +167,7 @@ gboolean resize_launcher(void *obj) icon_size = launcher_max_icon_size; // Resize icons if necessary - for (l = launcher->list_icons; l; l = l->next) { + for (GSList *l = launcher->list_icons; l; l = l->next) { LauncherIcon *launcherIcon = (LauncherIcon *)l->data; if (launcherIcon->icon_size != icon_size || !launcherIcon->image) { launcherIcon->icon_size = icon_size; @@ -231,7 +226,7 @@ gboolean resize_launcher(void *obj) } } - count = g_slist_length(launcher->list_icons); + int count = g_slist_length(launcher->list_icons); if (panel_horizontal) { if (!count) { @@ -259,7 +254,7 @@ gboolean resize_launcher(void *obj) } } - int i, posx, posy; + int posx, posy; int start = launcher->area.bg->border.width + launcher->area.paddingy + margin / 2; if (panel_horizontal) { posy = start; @@ -269,6 +264,8 @@ gboolean resize_launcher(void *obj) posy = launcher->area.bg->border.width + launcher->area.paddingxlr; } + int i; + GSList *l; for (i = 1, l = launcher->list_icons; l; i++, l = l->next) { LauncherIcon *launcherIcon = (LauncherIcon *)l->data; @@ -296,7 +293,7 @@ gboolean resize_launcher(void *obj) } } - return 1; + return TRUE; } // Here we override the default layout of the icons; normally Area layouts its children @@ -472,11 +469,11 @@ void launcher_load_icons(Launcher *launcher) void launcher_load_themes(Launcher *launcher) { launcher->list_themes = - load_themes(launcher_icon_theme_override - ? (icon_theme_name_config ? icon_theme_name_config - : icon_theme_name_xsettings ? icon_theme_name_xsettings : "hicolor") - : (icon_theme_name_xsettings ? icon_theme_name_xsettings - : icon_theme_name_config ? icon_theme_name_config : "hicolor")); + load_themes(launcher_icon_theme_override + ? (icon_theme_name_config ? icon_theme_name_config + : icon_theme_name_xsettings ? icon_theme_name_xsettings : "hicolor") + : (icon_theme_name_xsettings ? icon_theme_name_xsettings + : icon_theme_name_config ? icon_theme_name_config : "hicolor")); } void launcher_default_icon_theme_changed() diff --git a/src/launcher/launcher.h b/src/launcher/launcher.h index 44d4a27..ce7ad4b 100644 --- a/src/launcher/launcher.h +++ b/src/launcher/launcher.h @@ -35,7 +35,7 @@ typedef struct LauncherIcon { int x, y; } LauncherIcon; -extern int launcher_enabled; +extern gboolean launcher_enabled; extern int launcher_max_icon_size; extern int launcher_tooltip_enabled; extern int launcher_alpha; diff --git a/src/server.c b/src/server.c index a0bb220..530685d 100644 --- a/src/server.c +++ b/src/server.c @@ -137,7 +137,7 @@ void cleanup_server() if (server.gc) XFreeGC(server.dsp, server.gc); server.gc = NULL; - server.disable_transparency = 0; + server.disable_transparency = FALSE; } void send_event32(Window win, Atom at, long data1, long data2, long data3) @@ -565,14 +565,14 @@ void server_init_visual() attrs.event_mask = StructureNotifyMask; XChangeWindowAttributes(server.dsp, server.composite_manager, CWEventMask, &attrs); - server.real_transparency = 1; + server.real_transparency = TRUE; server.depth = 32; printf("real transparency on... depth: %d\n", server.depth); server.colormap = XCreateColormap(server.dsp, server.root_win, visual, AllocNone); server.visual = visual; } else { // no composite manager or snapshot mode => fake transparency - server.real_transparency = 0; + server.real_transparency = FALSE; server.depth = DefaultDepth(server.dsp, server.screen); printf("real transparency off.... depth: %d\n", server.depth); server.colormap = DefaultColormap(server.dsp, server.screen); diff --git a/src/server.h b/src/server.h index e0f05c8..fb44ebc 100644 --- a/src/server.h +++ b/src/server.h @@ -110,8 +110,8 @@ typedef struct Server { Display *dsp; Window root_win; Window composite_manager; - int real_transparency; - int disable_transparency; + gboolean real_transparency; + gboolean disable_transparency; // current desktop int desktop; int screen; @@ -123,7 +123,7 @@ typedef struct Server { // In that case there are num_desktops viewports. Viewport *viewports; Monitor *monitor; - int got_root_win; + gboolean got_root_win; Visual *visual; Visual *visual32; // root background diff --git a/src/systray/systraybar.c b/src/systray/systraybar.c index c9af9a0..8c7845b 100644 --- a/src/systray/systraybar.c +++ b/src/systray/systraybar.c @@ -122,37 +122,11 @@ void init_systray_panel(void *p) refresh_systray = 1; } -void draw_systray(void *obj, cairo_t *c) -{ - if (systray_profile) - fprintf(stderr, BLUE "[%f] %s:%d\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__); - if (systray_composited) { - if (render_background) - XFreePixmap(server.dsp, render_background); - render_background = - XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth); - XCopyArea(server.dsp, - systray.area.pix, - render_background, - server.gc, - 0, - 0, - systray.area.width, - systray.area.height, - 0, - 0); - } - - refresh_systray = 1; -} - gboolean resize_systray(void *obj) { if (systray_profile) fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); Systraybar *sysbar = obj; - GSList *l; - int count; if (panel_horizontal) sysbar->icon_size = sysbar->area.height; @@ -165,17 +139,17 @@ gboolean resize_systray(void *obj) if (systray.icon_size > 0) { long icon_size = systray.icon_size; XChangeProperty(server.dsp, - net_sel_win, - server.atom._NET_SYSTEM_TRAY_ICON_SIZE, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&icon_size, - 1); + net_sel_win, + server.atom._NET_SYSTEM_TRAY_ICON_SIZE, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&icon_size, + 1); } - count = 0; - for (l = systray.list_icons; l; l = l->next) { + int count = 0; + for (GSList *l = systray.list_icons; l; l = l->next) { if (((TrayWindow *)l->data)->hide) continue; count++; @@ -188,28 +162,52 @@ gboolean resize_systray(void *obj) // here icons_per_column always higher than 0 sysbar->icons_per_column = (height + sysbar->area.paddingx) / (sysbar->icon_size + sysbar->area.paddingx); sysbar->margin = - height - (sysbar->icons_per_column - 1) * (sysbar->icon_size + sysbar->area.paddingx) - sysbar->icon_size; + height - (sysbar->icons_per_column - 1) * (sysbar->icon_size + sysbar->area.paddingx) - sysbar->icon_size; sysbar->icons_per_row = count / sysbar->icons_per_column + (count % sysbar->icons_per_column != 0); systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + - (sysbar->icon_size * sysbar->icons_per_row) + - ((sysbar->icons_per_row - 1) * systray.area.paddingx); + (sysbar->icon_size * sysbar->icons_per_row) + + ((sysbar->icons_per_row - 1) * systray.area.paddingx); } else { int width = sysbar->area.width - 2 * sysbar->area.bg->border.width - 2 * sysbar->area.paddingy; // here icons_per_row always higher than 0 sysbar->icons_per_row = (width + sysbar->area.paddingx) / (sysbar->icon_size + sysbar->area.paddingx); sysbar->margin = - width - (sysbar->icons_per_row - 1) * (sysbar->icon_size + sysbar->area.paddingx) - sysbar->icon_size; + width - (sysbar->icons_per_row - 1) * (sysbar->icon_size + sysbar->area.paddingx) - sysbar->icon_size; sysbar->icons_per_column = count / sysbar->icons_per_row + (count % sysbar->icons_per_row != 0); systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + - (sysbar->icon_size * sysbar->icons_per_column) + - ((sysbar->icons_per_column - 1) * systray.area.paddingx); + (sysbar->icon_size * sysbar->icons_per_column) + + ((sysbar->icons_per_column - 1) * systray.area.paddingx); } if (net_sel_win == None) { start_net(); } - return 1; + return TRUE; +} + +void draw_systray(void *obj, cairo_t *c) +{ + if (systray_profile) + fprintf(stderr, BLUE "[%f] %s:%d\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__); + if (systray_composited) { + if (render_background) + XFreePixmap(server.dsp, render_background); + render_background = + XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth); + XCopyArea(server.dsp, + systray.area.pix, + render_background, + server.gc, + 0, + 0, + systray.area.width, + systray.area.height, + 0, + 0); + } + + refresh_systray = TRUE; } void on_change_systray(void *obj) @@ -222,9 +220,9 @@ void on_change_systray(void *obj) return; Panel *panel = sysbar->area.panel; - int i, posx, posy; + int posx, posy; int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + - systray.area.paddingy + sysbar->margin / 2; + systray.area.paddingy + sysbar->margin / 2; if (panel_horizontal) { posy = start; posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr; @@ -235,6 +233,7 @@ void on_change_systray(void *obj) TrayWindow *traywin; GSList *l; + int i; for (i = 1, l = systray.list_icons; l; i++, l = l->next) { traywin = (TrayWindow *)l->data; if (traywin->hide) @@ -244,14 +243,14 @@ void on_change_systray(void *obj) traywin->x = posx; if (systray_profile) fprintf(stderr, - "%s:%d win = %lu (%s), parent = %lu, x = %d, y = %d\n", - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name, - traywin->parent, - posx, - posy); + "%s:%d win = %lu (%s), parent = %lu, x = %d, y = %d\n", + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name, + traywin->parent, + posx, + posy); traywin->width = sysbar->icon_size; traywin->height = sysbar->icon_size; if (panel_horizontal) { @@ -281,19 +280,19 @@ void on_change_systray(void *obj) if (width != traywin->width || height != traywin->height || xpos != traywin->x || ypos != traywin->y) { if (systray_profile) fprintf(stderr, - "XMoveResizeWindow(server.dsp, traywin->parent = %ld, traywin->x = %d, traywin->y = %d, " - "traywin->width = %d, traywin->height = %d)\n", - traywin->parent, - traywin->x, - traywin->y, - traywin->width, - traywin->height); + "XMoveResizeWindow(server.dsp, traywin->parent = %ld, traywin->x = %d, traywin->y = %d, " + "traywin->width = %d, traywin->height = %d)\n", + traywin->parent, + traywin->x, + traywin->y, + traywin->width, + traywin->height); XMoveResizeWindow(server.dsp, traywin->parent, traywin->x, traywin->y, traywin->width, traywin->height); } if (!traywin->reparented) reparent_icon(traywin); } - refresh_systray = 1; + refresh_systray = TRUE; } // *********************************************** @@ -327,17 +326,17 @@ void start_net() _NET_WM_PID = XInternAtom(server.dsp, "_NET_WM_PID", True); int ret = XGetWindowProperty(server.dsp, - win, - _NET_WM_PID, - 0, - 1024, - False, - AnyPropertyType, - &actual_type, - &actual_format, - &nitems, - &bytes_after, - &prop); + win, + _NET_WM_PID, + 0, + 1024, + False, + AnyPropertyType, + &actual_type, + &actual_format, + &nitems, + &bytes_after, + &prop); fprintf(stderr, RED "tint2 : another systray is running" RESET); if (ret == Success && prop) { @@ -357,33 +356,33 @@ void start_net() // Vertical panel will draw the systray horizontal. long orientation = 0; XChangeProperty(server.dsp, - net_sel_win, - server.atom._NET_SYSTEM_TRAY_ORIENTATION, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&orientation, - 1); + net_sel_win, + server.atom._NET_SYSTEM_TRAY_ORIENTATION, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&orientation, + 1); if (systray.icon_size > 0) { long icon_size = systray.icon_size; XChangeProperty(server.dsp, - net_sel_win, - server.atom._NET_SYSTEM_TRAY_ICON_SIZE, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&icon_size, - 1); + net_sel_win, + server.atom._NET_SYSTEM_TRAY_ICON_SIZE, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&icon_size, + 1); } long padding = 0; XChangeProperty(server.dsp, - net_sel_win, - server.atom._NET_SYSTEM_TRAY_PADDING, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)&padding, - 1); + net_sel_win, + server.atom._NET_SYSTEM_TRAY_PADDING, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&padding, + 1); VisualID vid; if (systray_composited) @@ -391,13 +390,13 @@ void start_net() else vid = XVisualIDFromVisual(server.visual); XChangeProperty(server.dsp, - net_sel_win, - XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_VISUAL", False), - XA_VISUALID, - 32, - PropModeReplace, - (unsigned char *)&vid, - 1); + net_sel_win, + XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_VISUAL", False), + XA_VISUALID, + 32, + PropModeReplace, + (unsigned char *)&vid, + 1); 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) { @@ -426,10 +425,9 @@ void net_message(XClientMessageEvent *e) { if (systray_profile) fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); - unsigned long opcode; - Window win; - opcode = e->data.l[1]; + Window win; + unsigned long opcode = e->data.l[1]; switch (opcode) { case SYSTEM_TRAY_REQUEST_DOCK: win = e->data.l[2]; @@ -497,7 +495,7 @@ static gint compare_traywindows(gconstpointer a, gconstpointer b) if (systray.sort == SYSTRAY_SORT_ASCENDING || systray.sort == SYSTRAY_SORT_DESCENDING) { return g_ascii_strncasecmp(traywin_a->name, traywin_b->name, -1) * - (systray.sort == SYSTRAY_SORT_ASCENDING ? 1 : -1); + (systray.sort == SYSTRAY_SORT_ASCENDING ? 1 : -1); } if (systray.sort == SYSTRAY_SORT_LEFT2RIGHT || systray.sort == SYSTRAY_SORT_RIGHT2LEFT) { @@ -532,17 +530,17 @@ gboolean add_icon(Window win) unsigned long bytes_after; unsigned char *prop = 0; int ret = XGetWindowProperty(server.dsp, - win, - server.atom._NET_WM_PID, - 0, - 1024, - False, - AnyPropertyType, - &actual_type, - &actual_format, - &nitems, - &bytes_after, - &prop); + win, + server.atom._NET_WM_PID, + 0, + 1024, + False, + AnyPropertyType, + &actual_type, + &actual_format, + &nitems, + &bytes_after, + &prop); if (ret == Success && prop) { pid = prop[1] * 256; pid += prop[0]; @@ -550,9 +548,8 @@ gboolean add_icon(Window win) } // Check if the application leaves behind empty icons - GSList *l; int num_empty_same_pid = 0; - for (l = systray.list_icons; l; l = l->next) { + for (GSList *l = systray.list_icons; l; l = l->next) { TrayWindow *other = (TrayWindow *)l->data; if (other->win == win) { free(name); @@ -568,14 +565,14 @@ gboolean add_icon(Window win) if (image) { imlib_context_set_drawable(panel->temp_pmap); Imlib_Image bg = - imlib_create_image_from_drawable(0, other->x, other->y, other->width, other->height, 1); + imlib_create_image_from_drawable(0, other->x, other->y, other->width, other->height, 1); imlib_context_set_image(bg); DATA32 *data_bg = imlib_image_get_data_for_reading_only(); imlib_context_set_image(image); imlib_image_set_has_alpha(other->depth > 24); DATA32 *data = imlib_image_get_data_for_reading_only(); int x, y; - int empty = 1; + gboolean empty = TRUE; for (x = 0; x < other->width && empty; x++) { for (y = 0; y < other->height && empty; y++) { DATA32 pixel = data[y * other->width + x]; @@ -589,7 +586,7 @@ gboolean add_icon(Window win) if (rgb != rgb_bg) { if (systray_profile) fprintf(stderr, "Pixel: %x different from bg %x at pos %d %d\n", pixel, pixel_bg, x, y); - empty = 0; + empty = FALSE; } } } @@ -599,13 +596,13 @@ gboolean add_icon(Window win) imlib_free_image_and_decache(); if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s) empty = %d\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - other->win, - other->name, - other->empty); + "[%f] %s:%d win = %lu (%s) empty = %d\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + other->win, + other->name, + other->empty); } } if (pid && other->pid == pid) { @@ -617,15 +614,15 @@ gboolean add_icon(Window win) // Remove empty icons if the application leaves behind more than 1 const int max_num_empty_same_pid = 0; if (num_empty_same_pid > max_num_empty_same_pid) { - for (l = systray.list_icons; l; l = l->next) { + for (GSList *l = systray.list_icons; l; l = l->next) { if (pid && ((TrayWindow *)l->data)->pid == pid && ((TrayWindow *)l->data)->empty) { num_empty_same_pid++; fprintf(stderr, - RED - "Removing tray icon %lu (%s) from misbehaving application with pid=%d (too many icons)\n" RESET, - ((TrayWindow *)l->data)->win, - ((TrayWindow *)l->data)->name, - pid); + RED + "Removing tray icon %lu (%s) from misbehaving application with pid=%d (too many icons)\n" RESET, + ((TrayWindow *)l->data)->win, + ((TrayWindow *)l->data)->name, + pid); remove_icon((TrayWindow *)l->data); break; } @@ -644,16 +641,16 @@ gboolean add_icon(Window win) XSetWindowAttributes set_attr; Visual *visual = server.visual; fprintf(stderr, - GREEN "add_icon: %lu (%s), pid %d, %d, visual %p, colormap %lu, depth %d, width %d, height %d\n" RESET, - win, - name, - pid, - num_empty_same_pid, - attr.visual, - attr.colormap, - attr.depth, - attr.width, - attr.height); + GREEN "add_icon: %lu (%s), pid %d, %d, visual %p, colormap %lu, depth %d, width %d, height %d\n" RESET, + win, + name, + pid, + num_empty_same_pid, + attr.visual, + attr.colormap, + attr.depth, + attr.width, + attr.height); if (server.disable_transparency) { set_attr.background_pixmap = ParentRelative; mask = CWBackPixmap; @@ -677,17 +674,17 @@ gboolean add_icon(Window win) if (systray_profile) fprintf(stderr, "XCreateWindow(...)\n"); Window parent = XCreateWindow(server.dsp, - panel->main_win, - 0, - 0, - systray.icon_size, - systray.icon_size, - 0, - attr.depth, - InputOutput, - visual, - mask, - &set_attr); + panel->main_win, + 0, + 0, + systray.icon_size, + systray.icon_size, + 0, + attr.depth, + InputOutput, + visual, + mask, + &set_attr); // Add the icon to the list TrayWindow *traywin = g_new0(TrayWindow, 1); @@ -723,11 +720,11 @@ gboolean add_icon(Window win) // Resize and redraw the systray if (systray_profile) fprintf(stderr, BLUE "[%f] %s:%d trigger resize & redraw\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__); - systray.area.resize_needed = 1; + systray.area.resize_needed = TRUE; systray.area.redraw_needed = TRUE; - panel->area.resize_needed = 1; + panel->area.resize_needed = TRUE; panel_refresh = TRUE; - refresh_systray = 1; + refresh_systray = TRUE; return TRUE; } @@ -735,12 +732,12 @@ gboolean reparent_icon(TrayWindow *traywin) { if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); if (traywin->reparented) return TRUE; @@ -756,10 +753,10 @@ gboolean reparent_icon(TrayWindow *traywin) if (systray_profile) fprintf(stderr, - "XMoveResizeWindow(server.dsp, traywin->win = %ld, 0, 0, traywin->width = %d, traywin->height = %d)\n", - traywin->win, - traywin->width, - traywin->height); + "XMoveResizeWindow(server.dsp, traywin->win = %ld, 0, 0, traywin->width = %d, traywin->height = %d)\n", + traywin->win, + traywin->width, + traywin->height); XMoveResizeWindow(server.dsp, traywin->win, 0, 0, traywin->width, traywin->height); // Embed into parent @@ -785,26 +782,26 @@ gboolean reparent_icon(TrayWindow *traywin) XSetErrorHandler(old); if (error != FALSE) { fprintf(stderr, - RED "systray %d: cannot embed icon for window %lu (%s) parent %lu pid %d\n" RESET, - __LINE__, - traywin->win, - traywin->name, - traywin->parent, - traywin->pid); + RED "systray %d: cannot embed icon for window %lu (%s) parent %lu pid %d\n" RESET, + __LINE__, + traywin->win, + traywin->name, + traywin->parent, + traywin->pid); remove_icon(traywin); return FALSE; } - traywin->reparented = 1; + traywin->reparented = TRUE; if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); return TRUE; } @@ -813,12 +810,12 @@ gboolean embed_icon(TrayWindow *traywin) { if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); if (traywin->embedded) return TRUE; @@ -836,20 +833,21 @@ gboolean embed_icon(TrayWindow *traywin) int ret; if (systray_profile) - fprintf(stderr, "XGetWindowProperty(server.dsp, traywin->win, server.atom._XEMBED_INFO, 0, 2, False, " - "server.atom._XEMBED_INFO, &acttype, &actfmt, &nbitem, &bytes, &data)\n"); + fprintf(stderr, + "XGetWindowProperty(server.dsp, traywin->win, server.atom._XEMBED_INFO, 0, 2, False, " + "server.atom._XEMBED_INFO, &acttype, &actfmt, &nbitem, &bytes, &data)\n"); ret = XGetWindowProperty(server.dsp, - traywin->win, - server.atom._XEMBED_INFO, - 0, - 2, - False, - server.atom._XEMBED_INFO, - &acttype, - &actfmt, - &nbitem, - &bytes, - (unsigned char **)&data); + traywin->win, + server.atom._XEMBED_INFO, + 0, + 2, + False, + server.atom._XEMBED_INFO, + &acttype, + &actfmt, + &nbitem, + &bytes, + (unsigned char **)&data); if (ret == Success) { if (data) { if (nbitem >= 2) { @@ -908,26 +906,26 @@ gboolean embed_icon(TrayWindow *traywin) XSetErrorHandler(old); if (error != FALSE) { fprintf(stderr, - RED "systray %d: cannot embed icon for window %lu (%s) parent %lu pid %d\n" RESET, - __LINE__, - traywin->win, - traywin->name, - traywin->parent, - traywin->pid); + RED "systray %d: cannot embed icon for window %lu (%s) parent %lu pid %d\n" RESET, + __LINE__, + traywin->win, + traywin->name, + traywin->parent, + traywin->pid); remove_icon(traywin); return FALSE; } - traywin->embedded = 1; + traywin->embedded = TRUE; if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); return TRUE; } @@ -936,12 +934,12 @@ void remove_icon(TrayWindow *traywin) { if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); Panel *panel = systray.area.panel; // remove from our list @@ -985,11 +983,11 @@ void remove_icon(TrayWindow *traywin) // Resize and redraw the systray if (systray_profile) fprintf(stderr, BLUE "[%f] %s:%d trigger resize & redraw\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__); - systray.area.resize_needed = 1; + systray.area.resize_needed = TRUE; systray.area.redraw_needed = TRUE; - panel->area.resize_needed = 1; + panel->area.resize_needed = TRUE; panel_refresh = TRUE; - refresh_systray = 1; + refresh_systray = TRUE; } void systray_resize_icon(void *t) @@ -1008,11 +1006,11 @@ void systray_resize_icon(void *t) if (1 || xpos != 0 || ypos != 0 || width != traywin->width || height != traywin->height) { if (systray_profile) fprintf(stderr, - "XMoveResizeWindow(server.dsp, traywin->win = %ld, 0, 0, traywin->width = %d, traywin->height " - "= %d)\n", - traywin->win, - traywin->width, - traywin->height); + "XMoveResizeWindow(server.dsp, traywin->win = %ld, 0, 0, traywin->width = %d, traywin->height " + "= %d)\n", + traywin->win, + traywin->width, + traywin->height); if (0) { XMoveResizeWindow(server.dsp, traywin->win, 0, 0, traywin->width, traywin->height); } @@ -1048,19 +1046,19 @@ void systray_reconfigure_event(TrayWindow *traywin, XEvent *e) { if (systray_profile) fprintf(stderr, - "XConfigure event: win = %lu (%s), x = %d, y = %d, w = %d, h = %d\n", - traywin->win, - traywin->name, - e->xconfigure.x, - e->xconfigure.y, - e->xconfigure.width, - e->xconfigure.height); + "XConfigure event: win = %lu (%s), x = %d, y = %d, w = %d, h = %d\n", + traywin->win, + traywin->name, + e->xconfigure.x, + e->xconfigure.y, + e->xconfigure.width, + e->xconfigure.height); if (!traywin->reparented) return; if (e->xconfigure.width != traywin->width || e->xconfigure.height != traywin->height || e->xconfigure.x != 0 || - e->xconfigure.y != 0) { + e->xconfigure.y != 0) { if (traywin->bad_size_counter < max_bad_resize_events) { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); @@ -1079,15 +1077,15 @@ void systray_reconfigure_event(TrayWindow *traywin, XEvent *e) } else { if (!traywin->resize_timeout) traywin->resize_timeout = - add_timeout(fast_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); + add_timeout(fast_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); } } else { if (traywin->bad_size_counter == max_bad_resize_events) { traywin->bad_size_counter++; fprintf(stderr, - RED "Detected resize loop for tray icon %lu (%s), throttling resize events\n" RESET, - traywin->win, - traywin->name); + RED "Detected resize loop for tray icon %lu (%s), throttling resize events\n" RESET, + traywin->win, + traywin->name); } // Delayed resize // FIXME Normally we should force the icon to resize fill_color to the size we resized it to when we @@ -1095,7 +1093,7 @@ void systray_reconfigure_event(TrayWindow *traywin, XEvent *e) // However this triggers a resize loop in new versions of GTK, which we must avoid. if (!traywin->resize_timeout) traywin->resize_timeout = - add_timeout(slow_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); + add_timeout(slow_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); return; } } else { @@ -1114,11 +1112,11 @@ void systray_resize_request_event(TrayWindow *traywin, XEvent *e) { if (systray_profile) fprintf(stderr, - "XResizeRequest event: win = %lu (%s), w = %d, h = %d\n", - traywin->win, - traywin->name, - e->xresizerequest.width, - e->xresizerequest.height); + "XResizeRequest event: win = %lu (%s), w = %d, h = %d\n", + traywin->win, + traywin->name, + e->xresizerequest.width, + e->xresizerequest.height); if (!traywin->reparented) return; @@ -1142,15 +1140,15 @@ void systray_resize_request_event(TrayWindow *traywin, XEvent *e) } else { if (!traywin->resize_timeout) traywin->resize_timeout = - add_timeout(fast_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); + add_timeout(fast_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); } } else { if (traywin->bad_size_counter == max_bad_resize_events) { traywin->bad_size_counter++; fprintf(stderr, - RED "Detected resize loop for tray icon %lu (%s), throttling resize events\n" RESET, - traywin->win, - traywin->name); + RED "Detected resize loop for tray icon %lu (%s), throttling resize events\n" RESET, + traywin->win, + traywin->name); } // Delayed resize // FIXME Normally we should force the icon to resize fill_color to the size we resized it to when we @@ -1158,7 +1156,7 @@ void systray_resize_request_event(TrayWindow *traywin, XEvent *e) // However this triggers a resize loop in new versions of GTK, which we must avoid. if (!traywin->resize_timeout) traywin->resize_timeout = - add_timeout(slow_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); + add_timeout(slow_resize_period, 0, systray_resize_icon, traywin, &traywin->resize_timeout); return; } } else { @@ -1177,12 +1175,12 @@ void systray_destroy_event(TrayWindow *traywin) { if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); remove_icon(traywin); } @@ -1193,26 +1191,26 @@ void systray_render_icon_from_image(TrayWindow *traywin) return; imlib_context_set_image(traywin->image); XCopyArea(server.dsp, - render_background, - systray.area.pix, - server.gc, - traywin->x - systray.area.posx, - traywin->y - systray.area.posy, - traywin->width, - traywin->height, - traywin->x - systray.area.posx, - traywin->y - systray.area.posy); + render_background, + systray.area.pix, + server.gc, + traywin->x - systray.area.posx, + traywin->y - systray.area.posy, + traywin->width, + traywin->height, + traywin->x - systray.area.posx, + traywin->y - systray.area.posy); render_image(systray.area.pix, traywin->x - systray.area.posx, traywin->y - systray.area.posy); XCopyArea(server.dsp, - systray.area.pix, - panel->temp_pmap, - server.gc, - traywin->x - systray.area.posx, - traywin->y - systray.area.posy, - traywin->width, - traywin->height, - traywin->x, - traywin->y); + systray.area.pix, + panel->temp_pmap, + server.gc, + traywin->x - systray.area.posx, + traywin->y - systray.area.posy, + traywin->width, + traywin->height, + traywin->x, + traywin->y); } void systray_render_icon_composited(void *t) @@ -1223,12 +1221,12 @@ void systray_render_icon_composited(void *t) if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); // wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms struct timespec now; @@ -1238,15 +1236,15 @@ void systray_render_icon_composited(void *t) traywin->num_fast_renders++; if (traywin->num_fast_renders > max_fast_refreshes) { traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout); + add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout); if (systray_profile) fprintf(stderr, - YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering\n" RESET, - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering\n" RESET, + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); return; } } else { @@ -1258,15 +1256,15 @@ void systray_render_icon_composited(void *t) if (traywin->width == 0 || traywin->height == 0) { // reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu) traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout); + add_timeout(min_refresh_period, 0, systray_render_icon_composited, traywin, &traywin->render_timeout); if (systray_profile) fprintf(stderr, - YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering\n" RESET, - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering\n" RESET, + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); return; } @@ -1317,7 +1315,7 @@ void systray_render_icon_composited(void *t) goto on_error; } Picture pict_drawable = - XRenderCreatePicture(server.dsp, tmp_pmap, XRenderFindVisualFormat(server.dsp, server.visual32), 0, 0); + XRenderCreatePicture(server.dsp, tmp_pmap, XRenderFindVisualFormat(server.dsp, server.visual32), 0, 0); if (!pict_drawable) { XRenderFreePicture(server.dsp, pict_image); XFreePixmap(server.dsp, tmp_pmap); @@ -1325,18 +1323,18 @@ void systray_render_icon_composited(void *t) goto on_error; } XRenderComposite(server.dsp, - PictOpSrc, - pict_image, - None, - pict_drawable, - 0, - 0, - 0, - 0, - 0, - 0, - traywin->width, - traywin->height); + PictOpSrc, + pict_image, + None, + pict_drawable, + 0, + 0, + 0, + 0, + 0, + 0, + traywin->width, + traywin->height); XRenderFreePicture(server.dsp, pict_image); XRenderFreePicture(server.dsp, pict_drawable); // end of the ugly hack and we can continue as before @@ -1373,11 +1371,11 @@ void systray_render_icon_composited(void *t) int empty = image_empty(data, traywin->width, traywin->height); if (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) adjust_asb(data, - traywin->width, - traywin->height, - systray.alpha, - (float)systray.saturation / 100, - (float)systray.brightness / 100); + traywin->width, + traywin->height, + systray.alpha, + (float)systray.saturation / 100, + (float)systray.brightness / 100); imlib_image_put_back_data(data); systray_render_icon_from_image(traywin); @@ -1396,10 +1394,10 @@ void systray_render_icon_composited(void *t) // Resize and redraw the systray if (systray_profile) fprintf(stderr, - BLUE "[%f] %s:%d trigger resize & redraw\n" RESET, - profiling_get_time(), - __FUNCTION__, - __LINE__); + BLUE "[%f] %s:%d trigger resize & redraw\n" RESET, + profiling_get_time(), + __FUNCTION__, + __LINE__); systray.area.resize_needed = 1; systray.area.redraw_needed = TRUE; panel->area.resize_needed = 1; @@ -1410,32 +1408,32 @@ void systray_render_icon_composited(void *t) if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); return; on_error: fprintf(stderr, - RED "systray %d: rendering error for icon %lu (%s) pid %d\n" RESET, - __LINE__, - traywin->win, - traywin->name, - traywin->pid); + RED "systray %d: rendering error for icon %lu (%s) pid %d\n" RESET, + __LINE__, + traywin->win, + traywin->name, + traywin->pid); return; on_systray_error: fprintf(stderr, - RED "systray %d: rendering error for icon %lu (%s) pid %d. " - "Disabling compositing and restarting systray...\n" RESET, - __LINE__, - traywin->win, - traywin->name, - traywin->pid); + RED "systray %d: rendering error for icon %lu (%s) pid %d. " + "Disabling compositing and restarting systray...\n" RESET, + __LINE__, + traywin->win, + traywin->name, + traywin->pid); systray_composited = 0; stop_net(); start_net(); @@ -1447,24 +1445,24 @@ void systray_render_icon(void *t) TrayWindow *traywin = t; if (systray_profile) fprintf(stderr, - "[%f] %s:%d win = %lu (%s)\n", - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + "[%f] %s:%d win = %lu (%s)\n", + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); if (!traywin->reparented || !traywin->embedded) { if (systray_profile) fprintf(stderr, - YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering\n" RESET, - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering\n" RESET, + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); stop_timeout(traywin->render_timeout); traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); + add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); return; } @@ -1481,7 +1479,7 @@ void systray_render_icon(void *t) stop_timeout(traywin->render_timeout); if (!traywin->resize_timeout) traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); + add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); systray_render_icon_from_image(traywin); XSetErrorHandler(old); return; @@ -1490,16 +1488,16 @@ void systray_render_icon(void *t) stop_timeout(traywin->render_timeout); if (!traywin->resize_timeout) traywin->render_timeout = - add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); + add_timeout(min_refresh_period, 0, systray_render_icon, traywin, &traywin->render_timeout); systray_render_icon_from_image(traywin); if (systray_profile) fprintf(stderr, - YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering\n" RESET, - profiling_get_time(), - __FUNCTION__, - __LINE__, - traywin->win, - traywin->name); + YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering\n" RESET, + profiling_get_time(), + __FUNCTION__, + __LINE__, + traywin->win, + traywin->name); XSetErrorHandler(old); return; } @@ -1516,13 +1514,13 @@ void systray_render_icon(void *t) // Trigger window repaint if (systray_profile) fprintf(stderr, - "XClearArea(server.dsp, traywin->parent = %ld, 0, 0, traywin->width, traywin->height, True)\n", - traywin->parent); + "XClearArea(server.dsp, traywin->parent = %ld, 0, 0, traywin->width, traywin->height, True)\n", + traywin->parent); XClearArea(server.dsp, traywin->parent, 0, 0, 0, 0, True); if (systray_profile) fprintf(stderr, - "XClearArea(server.dsp, traywin->win = %ld, 0, 0, traywin->width, traywin->height, True)\n", - traywin->win); + "XClearArea(server.dsp, traywin->win = %ld, 0, 0, traywin->width, traywin->height, True)\n", + traywin->win); XClearArea(server.dsp, traywin->win, 0, 0, 0, 0, True); } } @@ -1543,5 +1541,6 @@ void refresh_systray_icons() gboolean systray_on_monitor(int i_monitor, int num_panelss) { - return (i_monitor == systray_monitor) || (i_monitor == 0 && (systray_monitor >= num_panelss || systray_monitor < 0)); + return (i_monitor == systray_monitor) || + (i_monitor == 0 && (systray_monitor >= num_panelss || systray_monitor < 0)); } diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index a8ace3a..f12e946 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -70,10 +70,10 @@ void default_taskbar() win_to_task = NULL; urgent_timeout = NULL; urgent_list = NULL; - taskbar_enabled = 0; - taskbar_distribute_size = 0; - hide_inactive_tasks = 0; - hide_task_diff_monitor = 0; + taskbar_enabled = FALSE; + taskbar_distribute_size = FALSE; + hide_inactive_tasks = FALSE; + hide_task_diff_monitor = FALSE; taskbar_sort_method = TASKBAR_NOSORT; taskbar_alignment = ALIGN_LEFT; default_taskbarname(); diff --git a/src/taskbar/taskbarname.c b/src/taskbar/taskbarname.c index 18a4c34..2352523 100644 --- a/src/taskbar/taskbarname.c +++ b/src/taskbar/taskbarname.c @@ -135,35 +135,6 @@ void cleanup_taskbarname() } } -void draw_taskbarname(void *obj, cairo_t *c) -{ - Taskbarname *taskbar_name = obj; - Taskbar *taskbar = taskbar_name->area.parent; - PangoLayout *layout; - Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font; - - int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL; - if (!panel_config.mouse_effects) - taskbar_name->state_pix[state] = taskbar_name->area.pix; - - // draw content - layout = pango_cairo_create_layout(c); - pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc); - pango_layout_set_width(layout, taskbar_name->area.width * PANGO_SCALE); - pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); - pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); - pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); - pango_layout_set_text(layout, taskbar_name->name, strlen(taskbar_name->name)); - - cairo_set_source_rgba(c, config_text->rgb[0], config_text->rgb[1], config_text->rgb[2], config_text->alpha); - - pango_cairo_update_layout(c, layout); - draw_text(layout, c, 0, taskbar_name->posy, config_text, ((Panel *)taskbar_name->area.panel)->font_shadow); - - g_object_unref(layout); - // printf("draw_taskbarname %s ******************************\n", taskbar_name->name); -} - gboolean resize_taskbarname(void *obj) { Taskbarname *taskbar_name = obj; @@ -201,3 +172,32 @@ gboolean resize_taskbarname(void *obj) } return ret; } + +void draw_taskbarname(void *obj, cairo_t *c) +{ + Taskbarname *taskbar_name = obj; + Taskbar *taskbar = taskbar_name->area.parent; + PangoLayout *layout; + Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font; + + int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL; + if (!panel_config.mouse_effects) + taskbar_name->state_pix[state] = taskbar_name->area.pix; + + // draw content + layout = pango_cairo_create_layout(c); + pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc); + pango_layout_set_width(layout, taskbar_name->area.width * PANGO_SCALE); + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); + pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE); + pango_layout_set_text(layout, taskbar_name->name, strlen(taskbar_name->name)); + + cairo_set_source_rgba(c, config_text->rgb[0], config_text->rgb[1], config_text->rgb[2], config_text->alpha); + + pango_cairo_update_layout(c, layout); + draw_text(layout, c, 0, taskbar_name->posy, config_text, ((Panel *)taskbar_name->area.panel)->font_shadow); + + g_object_unref(layout); + // printf("draw_taskbarname %s ******************************\n", taskbar_name->name); +} diff --git a/src/tint.c b/src/tint.c index 08443b1..d747f37 100644 --- a/src/tint.c +++ b/src/tint.c @@ -369,12 +369,13 @@ void get_snapshot(const char *path) imlib_free_image(); } -void window_action(Task *task, int action) +void window_action(Task *task, MouseAction action) { if (!task) return; - int desk; switch (action) { + case NONE: + break; case CLOSE: close_window(task->win); break; @@ -402,30 +403,30 @@ void window_action(Task *task, int action) case RESTORE: toggle_window_maximized(task->win); break; - case DESKTOP_LEFT: + case DESKTOP_LEFT: { if (task->desktop == 0) break; - desk = task->desktop - 1; - change_window_desktop(task->win, desk); - if (desk == server.desktop) + int desktop = task->desktop - 1; + change_window_desktop(task->win, desktop); + if (desktop == server.desktop) activate_window(task->win); break; - case DESKTOP_RIGHT: + } + case DESKTOP_RIGHT: { if (task->desktop == server.num_desktops) break; - desk = task->desktop + 1; - change_window_desktop(task->win, desk); - if (desk == server.desktop) + int desktop = task->desktop + 1; + change_window_desktop(task->win, desktop); + if (desktop == server.desktop) activate_window(task->win); break; + } case NEXT_TASK: { - Task *task1; - task1 = next_task(find_active_task(task)); + Task *task1 = next_task(find_active_task(task)); activate_window(task1->win); } break; case PREV_TASK: { - Task *task1; - task1 = prev_task(find_active_task(task)); + Task *task1 = prev_task(find_active_task(task)); activate_window(task1->win); } } @@ -737,7 +738,6 @@ void event_property_notify(XEvent *e) { gboolean debug = FALSE; - int i; Window win = e->xproperty.window; Atom at = e->xproperty.atom; @@ -746,7 +746,7 @@ void event_property_notify(XEvent *e) if (win == server.root_win) { if (!server.got_root_win) { XSelectInput(server.dsp, server.root_win, PropertyChangeMask | StructureNotifyMask); - server.got_root_win = 1; + server.got_root_win = TRUE; } // Change name of desktops @@ -775,7 +775,7 @@ void event_property_notify(XEvent *e) } cleanup_taskbar(); init_taskbar(); - for (i = 0; i < num_panels; i++) { + for (int i = 0; i < num_panels; i++) { init_taskbar_panel(&panels[i]); set_panel_items_order(&panels[i]); visible_taskbar(&panels[i]); @@ -785,7 +785,7 @@ void event_property_notify(XEvent *e) reset_active_task(); panel_refresh = TRUE; } else if (old_desktop != server.desktop) { - for (i = 0; i < num_panels; i++) { + for (int i = 0; i < num_panels; i++) { Panel *panel = &panels[i]; set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL); set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE); @@ -863,7 +863,7 @@ void event_property_notify(XEvent *e) if (debug) fprintf(stderr, "%s %d: win = root, atom = _XROOTPMAP_ID\n", __FUNCTION__, __LINE__); // change Wallpaper - for (i = 0; i < num_panels; i++) { + for (int i = 0; i < num_panels; i++) { set_panel_background(&panels[i]); } panel_refresh = TRUE;