PangoFontDescription *bat2_font_desc=0;
struct batstate battery_state;
int battery_enabled;
-static const struct timeout* battery_timeout=0;
+static timeout* battery_timeout=0;
static char buf_bat_percentage[10];
static char buf_bat_time[20];
if (panel_horizontal) {
// panel horizonal => fixed height and posy
- battery->area.posy = panel->area.pix.border.width + panel->area.paddingy;
+ battery->area.posy = panel->area.bg->border.width + panel->area.paddingy;
battery->area.height = panel->area.height - (2 * battery->area.posy);
}
else {
// panel vertical => fixed width, height, posy and posx
battery->area.posy = panel->clock.area.posy + panel->clock.area.height + panel->area.paddingx;
battery->area.height = (2 * battery->area.paddingxlr) + (bat_time_height + bat_percentage_height);
- battery->area.posx = panel->area.pix.border.width + panel->area.paddingy;
- battery->area.width = panel->area.width - (2 * panel->area.pix.border.width) - (2 * panel->area.paddingy);
+ battery->area.posx = panel->area.bg->border.width + panel->area.paddingy;
+ battery->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
}
battery->bat1_posy = (battery->area.height - bat_percentage_height) / 2;
}
-void draw_battery (void *obj, cairo_t *c, int active)
+void draw_battery (void *obj, cairo_t *c)
{
Battery *battery = obj;
PangoLayout *layout;
if(percentage_width > time_width) new_width = percentage_width;
else new_width = time_width;
- new_width += (2*battery->area.paddingxlr) + (2*battery->area.pix.border.width);
+ new_width += (2*battery->area.paddingxlr) + (2*battery->area.bg->border.width);
int old_width = battery->area.width;
Panel *panel = ((Area*)obj)->panel;
battery->area.width = new_width + 1;
- battery->area.posx = panel->area.width - battery->area.width - panel->area.paddingxlr - panel->area.pix.border.width;
+ battery->area.posx = panel->area.width - battery->area.width - panel->area.paddingxlr - panel->area.bg->border.width;
if (panel->clock.area.on_screen)
battery->area.posx -= (panel->clock.area.width + panel->area.paddingx);
// always start with area
Area area;
- config_color font;
+ Color font;
int bat1_posy;
int bat2_posy;
} Battery;
void init_battery_panel(void *panel);
void cleanup_battery();
-void draw_battery(void *obj, cairo_t *c, int active);
+void draw_battery(void *obj, cairo_t *c);
void resize_battery(void *obj);
static char buf_date[40];
static char buf_tooltip[40];
int clock_enabled;
-static const struct timeout* clock_timeout=0;
+static timeout* clock_timeout=0;
void update_clocks(void* arg)
if (panel_horizontal) {
// panel horizonal => fixed height and posy
- clock->area.posy = panel->area.pix.border.width + panel->area.paddingy;
+ clock->area.posy = panel->area.bg->border.width + panel->area.paddingy;
clock->area.height = panel->area.height - (2 * clock->area.posy);
}
else {
// panel vertical => fixed width, height, posy and posx
- clock->area.posy = panel->area.pix.border.width + panel->area.paddingxlr;
+ clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height);
- clock->area.posx = panel->area.pix.border.width + panel->area.paddingy;
- clock->area.width = panel->area.width - (2 * panel->area.pix.border.width) - (2 * panel->area.paddingy);
+ clock->area.posx = panel->area.bg->border.width + panel->area.paddingy;
+ clock->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
}
clock->time1_posy = (clock->area.height - time_height) / 2;
}
-void draw_clock (void *obj, cairo_t *c, int active)
+void draw_clock (void *obj, cairo_t *c)
{
Clock *clock = obj;
PangoLayout *layout;
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);
+ new_width += (2*clock->area.paddingxlr) + (2*clock->area.bg->border.width);
Panel *panel = ((Area*)obj)->panel;
- clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width;
+ clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.bg->border.width;
if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
// resize clock
// always start with area
Area area;
- config_color font;
+ Color font;
int time1_posy;
int time2_posy;
} Clock;
void init_clock_panel(void *panel);
void cleanup_clock();
-void draw_clock (void *obj, cairo_t *c, int active);
+void draw_clock (void *obj, cairo_t *c);
void resize_clock (void *obj);
// --------------------------------------------------
// backward compatibility
static int old_task_icon_size;
-static Area *area_task;
-static Area *area_task_active;
+static int bg_task;
+static int bg_task_active;
// detect if it's an old config file
// ==1
static int old_config_file;
-// temporary list of background
-static GSList *list_back;
-static int back_count;
-
-
void init_config()
{
+ if (backgrounds)
+ g_array_free(backgrounds, 1);
+ backgrounds = g_array_new(0, 0, sizeof(Background));
+
// append full transparency background
- list_back = g_slist_append(0, calloc(1, sizeof(Area)));
- back_count = 1;
+ Background transparent_bg;
+ memset(&transparent_bg, 0, sizeof(Background));
+ g_array_append_val(backgrounds, transparent_bg);
// tint2 could reload config, so we cleanup objects
cleanup_systray();
pango_font_description_free(panel_config.g_task.font_desc);
}
memset(&panel_config, 0, sizeof(Panel));
- panel_config.g_task.alpha = 100;
- panel_config.g_task.alpha_active = 100;
+ int i;
+ for (i=0; i<TASK_STATE_COUNT; ++i)
+ panel_config.g_task.alpha[i] = 100;
systray.alpha = 100;
systray.sort = 3;
old_config_file = 1;
void cleanup_config()
{
- // cleanup background list
- GSList *l0;
- for (l0 = list_back; l0 ; l0 = l0->next) {
- free(l0->data);
- }
- g_slist_free(list_back);
- list_back = NULL;
}
}
+int get_task_status(char* status)
+{
+ if (strcmp(status, "active") == 0)
+ return TASK_ACTIVE;
+ if (strcmp(status, "iconified") == 0)
+ return TASK_ICONIFIED;
+ if (strcmp(status, "urgent") == 0)
+ return TASK_URGENT;
+ return TASK_NORMAL;
+}
+
+
void add_entry (char *key, char *value)
{
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);
- back_count++;
+ Background bg;
+ bg.border.rounded = atoi(value);
+ g_array_append_val(backgrounds, bg);
}
else if (strcmp (key, "border_width") == 0) {
- Area *a = g_slist_last(list_back)->data;
- a->pix.border.width = atoi (value);
+ g_array_index(backgrounds, Background, backgrounds->len-1).border.width = atoi(value);
}
else if (strcmp (key, "background_color") == 0) {
- Area *a = g_slist_last(list_back)->data;
+ Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1);
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;
+ get_color (value1, bg->back.color);
+ if (value2) bg->back.alpha = (atoi (value2) / 100.0);
+ else bg->back.alpha = 0.5;
}
else if (strcmp (key, "border_color") == 0) {
- Area *a = g_slist_last(list_back)->data;
+ Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1);
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;
+ get_color (value1, bg->border.color);
+ if (value2) bg->border.alpha = (atoi (value2) / 100.0);
+ else bg->border.alpha = 0.5;
}
/* Panel */
panel_config.g_task.font_shadow = atoi (value);
else if (strcmp (key, "panel_background_id") == 0) {
int id = atoi (value);
- id = (id < back_count && id >= 0) ? id : 0;
- 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));
+ id = (id < backgrounds->len && id >= 0) ? id : 0;
+ panel_config.area.bg = &g_array_index(backgrounds, Background, id);
}
else if (strcmp (key, "wm_menu") == 0)
wm_menu = atoi (value);
else if (strcmp (key, "battery_background_id") == 0) {
#ifdef ENABLE_BATTERY
int id = atoi (value);
- id = (id < back_count && id >= 0) ? id : 0;
- 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));
+ id = (id < backgrounds->len && id >= 0) ? id : 0;
+ panel_config.battery.area.bg = &g_array_index(backgrounds, Background, id);
#endif
}
}
else if (strcmp (key, "clock_background_id") == 0) {
int id = atoi (value);
- id = (id < back_count && id >= 0) ? id : 0;
- 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));
+ id = (id < backgrounds->len && id >= 0) ? id : 0;
+ panel_config.clock.area.bg = &g_array_index(backgrounds, Background, id);
}
else if (strcmp(key, "clock_tooltip") == 0) {
if (strlen(value) > 0)
}
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);
+ panel_config.g_taskbar.area.paddingxlr = panel_config.g_taskbar.area.paddingx = atoi (value1);
+ if (value2) panel_config.g_taskbar.area.paddingy = atoi (value2);
+ if (value3) panel_config.g_taskbar.area.paddingx = atoi (value3);
}
else if (strcmp (key, "taskbar_background_id") == 0) {
int id = atoi (value);
- id = (id < back_count && id >= 0) ? id : 0;
- 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));
+ id = (id < backgrounds->len && id >= 0) ? id : 0;
+ panel_config.g_taskbar.bg = &g_array_index(backgrounds, Background, id);
+ panel_config.g_taskbar.area.bg = panel_config.g_taskbar.bg;
}
else if (strcmp (key, "taskbar_active_background_id") == 0) {
int id = atoi (value);
- id = (id < back_count && id >= 0) ? id : 0;
- 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));
+ id = (id < backgrounds->len && id >= 0) ? id : 0;
+ panel_config.g_taskbar.bg_active = &g_array_index(backgrounds, Background, id);
panel_config.g_taskbar.use_active = 1;
}
else if (strcmp (key, "task_font") == 0) {
panel_config.g_task.font_desc = pango_font_description_from_string (value);
}
- else if (strcmp (key, "task_font_color") == 0) {
+ else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) {
+ gchar** split = g_regex_split_simple("_", key, 0, 0);
+ int status = get_task_status(split[1]);
+ g_strfreev(split);
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) {
+ float alpha = 1;
+ if (value2) alpha = (atoi (value2) / 100.0);
+ get_color (value1, panel_config.g_task.font[status].color);
+ panel_config.g_task.font[status].alpha = alpha;
+ panel_config.g_task.config_font_mask |= (1<<status);
+ }
+ else if (g_regex_match_simple("task.*_icon_asb", key, 0, 0)) {
+ gchar** split = g_regex_split_simple("_", key, 0, 0);
+ int status = get_task_status(split[1]);
+ g_strfreev(split);
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_asb") == 0) {
- extract_values(value, &value1, &value2, &value3);
- panel_config.g_task.alpha = atoi(value1);
- panel_config.g_task.saturation = atoi(value2);
- panel_config.g_task.brightness = atoi(value3);
- }
- else if (strcmp (key, "task_active_icon_asb") == 0) {
- extract_values(value, &value1, &value2, &value3);
- panel_config.g_task.alpha_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);
- id = (id < back_count && id >= 0) ? id : 0;
- 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) {
+ panel_config.g_task.alpha[status] = atoi(value1);
+ panel_config.g_task.saturation[status] = atoi(value2);
+ panel_config.g_task.brightness[status] = atoi(value3);
+ panel_config.g_task.config_asb_mask |= (1<<status);
+ }
+ else if (g_regex_match_simple("task.*_background_id", key, 0, 0)) {
+ gchar** split = g_regex_split_simple("_", key, 0, 0);
+ int status = get_task_status(split[1]);
+ g_strfreev(split);
int id = atoi (value);
- id = (id < back_count && id >= 0) ? id : 0;
- 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));
+ id = (id < backgrounds->len && id >= 0) ? id : 0;
+ panel_config.g_task.background[status] = &g_array_index(backgrounds, Background, id);
+ panel_config.g_task.config_background_mask |= (1<<status);
+ if (status == TASK_NORMAL) panel_config.g_task.area.bg = panel_config.g_task.background[TASK_NORMAL];
}
/* Systray */
}
else if (strcmp (key, "systray_background_id") == 0) {
int id = atoi (value);
- id = (id < back_count && id >= 0) ? id : 0;
- 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));
+ id = (id < backgrounds->len && id >= 0) ? id : 0;
+ systray.area.bg = &g_array_index(backgrounds, Background, id);
}
else if (strcmp(key, "systray_sort") == 0) {
if (strcmp(value, "descending") == 0)
}
else if (strcmp (key, "tooltip_background_id") == 0) {
int id = atoi (value);
- id = (id < back_count && id >= 0) ? id : 0;
- Area *a = g_slist_nth_data(list_back, id);
- memcpy(&g_tooltip.background_color, &a->pix.back, sizeof(Color));
- memcpy(&g_tooltip.border, &a->pix.border, sizeof(Border));
+ id = (id < backgrounds->len && id >= 0) ? id : 0;
+ g_tooltip.bg = &g_array_index(backgrounds, Background, id);
}
else if (strcmp (key, "tooltip_font_color") == 0) {
extract_values(value, &value1, &value2, &value3);
panel_autohide_height = atoi(value);
+ // QUESTION: Do we still need backwards compatibility???
/* Read tint-0.6 config for backward compatibility */
else if (strcmp (key, "panel_mode") == 0) {
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);
+ Background bg;
+ bg.border.rounded = atoi(value);
+ g_array_append_val(backgrounds, bg);
}
else if (strcmp (key, "panel_border_width") == 0) {
- Area *a = g_slist_last(list_back)->data;
- a->pix.border.width = atoi (value);
+ g_array_index(backgrounds, Background, backgrounds->len-1).border.width = atoi(value);
}
else if (strcmp (key, "panel_background_color") == 0) {
- Area *a = g_slist_last(list_back)->data;
+ Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1);
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;
+ get_color (value1, bg->back.color);
+ if (value2) bg->back.alpha = (atoi (value2) / 100.0);
+ else bg->back.alpha = 0.5;
}
else if (strcmp (key, "panel_border_color") == 0) {
- Area *a = g_slist_last(list_back)->data;
+ Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1);
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;
+ get_color (value1, bg->border.color);
+ if (value2) bg->border.alpha = (atoi (value2) / 100.0);
+ else bg->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);
+ panel_config.g_taskbar.area.paddingxlr = 0;
+ panel_config.g_taskbar.area.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);
+ Background bg;
+ bg.border.rounded = atoi(value);
+ g_array_append_val(backgrounds, bg);
+ g_array_append_val(backgrounds, bg);
+ bg_task = backgrounds->len-2;
+ bg_task_active = backgrounds->len-1;
}
else if (strcmp (key, "task_background_color") == 0) {
+ Background* bg = &g_array_index(backgrounds, Background, bg_task);
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;
+ get_color (value1, bg->back.color);
+ if (value2) bg->back.alpha = (atoi (value2) / 100.0);
+ else bg->back.alpha = 0.5;
}
else if (strcmp (key, "task_active_background_color") == 0) {
+ Background* bg = &g_array_index(backgrounds, Background, bg_task_active);
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;
+ get_color (value1, bg->back.color);
+ if (value2) bg->back.alpha = (atoi (value2) / 100.0);
+ else bg->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);
+ Background* bg = &g_array_index(backgrounds, Background, bg_task);
+ bg->border.width = atoi (value);
+ bg = &g_array_index(backgrounds, Background, bg_task_active);
+ bg->border.width = atoi (value);
}
else if (strcmp (key, "task_border_color") == 0) {
+ Background* bg = &g_array_index(backgrounds, Background, bg_task);
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;
+ get_color (value1, bg->border.color);
+ if (value2) bg->border.alpha = (atoi (value2) / 100.0);
+ else bg->border.alpha = 0.5;
}
else if (strcmp (key, "task_active_border_color") == 0) {
+ Background* bg = &g_array_index(backgrounds, Background, bg_task_active);
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;
+ get_color (value1, bg->border.color);
+ if (value2) bg->border.alpha = (atoi (value2) / 100.0);
+ else bg->border.alpha = 0.5;
}
else
Panel *panel1 = 0;
int nb_panel = 0;
+GArray* backgrounds = 0;
+
Imlib_Image default_icon = NULL;
p->area.on_screen = 1;
p->area.resize = 1;
p->area._resize = resize_panel;
- p->g_taskbar.parent = p;
- p->g_taskbar.panel = p;
+ p->g_taskbar.area.parent = p;
+ p->g_taskbar.area.panel = p;
p->g_task.area.panel = p;
init_panel_size_and_position(p);
-
// add childs
if (clock_enabled) {
init_clock_panel(p);
panel->area.width = (float)server.monitor[panel->monitor].width * panel->area.width / 100;
if (panel->pourcenty)
panel->area.height = (float)server.monitor[panel->monitor].height * panel->area.height / 100;
- if (panel->area.pix.border.rounded > panel->area.height/2)
- panel->area.pix.border.rounded = panel->area.height/2;
+ if (panel->area.bg->border.rounded > panel->area.height/2) {
+ printf("panel_background_id rounded is too big... please fix your tint2rc\n");
+ g_array_append_val(backgrounds, *panel->area.bg);
+ panel->area.bg = &g_array_index(backgrounds, Background, backgrounds->len-1);
+ panel->area.bg->border.rounded = panel->area.height/2;
+ }
}
else {
int old_panel_height = panel->area.height;
panel->area.width = (float)server.monitor[panel->monitor].width * old_panel_height / 100;
else
panel->area.width = old_panel_height;
- if (panel->area.pix.border.rounded > panel->area.width/2)
- panel->area.pix.border.rounded = panel->area.width/2;
+ if (panel->area.bg->border.rounded > panel->area.width/2) {
+ printf("panel_background_id rounded is too big... please fix your tint2rc\n");
+ g_array_append_val(backgrounds, *panel->area.bg);
+ panel->area.bg = &g_array_index(backgrounds, Background, backgrounds->len-1);
+ panel->area.bg->border.rounded = panel->area.width/2;
+ }
}
// panel position determined here
if (panel_horizontal) {
int taskbar_width, modulo_width = 0;
- taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
+ taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width);
if (panel->clock.area.on_screen && panel->clock.area.width)
taskbar_width -= (panel->clock.area.width + panel->area.paddingx);
#ifdef ENABLE_BATTERY
// change posx and width for all taskbar
int i, posx;
- posx = panel->area.pix.border.width + panel->area.paddingxlr;
+ posx = panel->area.bg->border.width + panel->area.paddingxlr;
for (i=0 ; i < panel->nb_desktop ; i++) {
panel->taskbar[i].area.posx = posx;
panel->taskbar[i].area.width = taskbar_width;
int taskbar_height, modulo_height = 0;
int i, posy;
- taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
+ taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width);
if (panel->clock.area.on_screen && panel->clock.area.height)
taskbar_height -= (panel->clock.area.height + panel->area.paddingx);
#ifdef ENABLE_BATTERY
if (systray.area.on_screen && systray.area.height && panel == &panel1[0])
taskbar_height -= (systray.area.height + panel->area.paddingx);
- posy = panel->area.height - panel->area.pix.border.width - panel->area.paddingxlr - taskbar_height;
+ posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - taskbar_height;
if (panel_mode == MULTI_DESKTOP) {
int height = taskbar_height - ((panel->nb_desktop-1) * panel->area.paddingx);
taskbar_height = height / panel->nb_desktop;
void set_panel_background(Panel *p)
{
- 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) XFreePixmap (server.dsp, p->area.pix);
+ p->area.pix = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth);
if (real_transparency) {
- clear_pixmap(p->area.pix.pmap, 0, 0, p->area.width, p->area.height);
+ clear_pixmap(p->area.pix, 0, 0, p->area.width, p->area.height);
}
else {
get_root_pixmap();
- // copy background (server.root_pmap) in panel.area.pix.pmap
+ // copy background (server.root_pmap) in panel.area.pix
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);
+ XFillRectangle(server.dsp, p->area.pix, 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);
+ cs = cairo_xlib_surface_create (server.dsp, p->area.pix, server.visual, p->area.width, p->area.height);
c = cairo_create (cs);
- draw_background(&p->area, c, 0);
+ draw_background(&p->area, c);
cairo_destroy (c);
cairo_surface_destroy (cs);
yoff = p->area.height-p->hidden_height;
else if (!panel_horizontal && panel_position & RIGHT)
xoff = p->area.width-p->hidden_width;
- XCopyArea(server.dsp, p->area.pix.pmap, p->hidden_pixmap, server.gc, xoff, yoff, p->hidden_width, p->hidden_height, 0, 0);
+ XCopyArea(server.dsp, p->area.pix, p->hidden_pixmap, server.gc, xoff, yoff, p->hidden_width, p->hidden_height, 0, 0);
}
// redraw panel's object
extern Task *task_drag;
extern int max_tick_urgent;
+extern GArray* backgrounds;
+
extern Imlib_Image default_icon;
// --------------------------------------------------
// task and taskbar parameter per panel
- Area g_taskbar;
+ Global_taskbar g_taskbar;
Global_task g_task;
// --------------------------------------------------
#ifdef ENABLE_BATTERY
Battery battery;
#endif
+
+ // autohide
int is_hidden;
int hidden_width, hidden_height;
Pixmap hidden_pixmap;
- const struct timeout* autohide_timeout;
+ timeout* autohide_timeout;
} Panel;
void server_catch_error (Display *d, XErrorEvent *ev){}
-static char *name_trayer = 0;
-
int real_transparency = 0;
void server_init_atoms ()
server.atom.WM_HINTS = XInternAtom(server.dsp, "WM_HINTS", False);
// systray protocol
- name_trayer = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.dsp));
+ char *name_trayer = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.dsp));
server.atom._NET_SYSTEM_TRAY_SCREEN = XInternAtom(server.dsp, name_trayer, False);
server.atom._NET_SYSTEM_TRAY_OPCODE = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_OPCODE", False);
server.atom.MANAGER = XInternAtom(server.dsp, "MANAGER", False);
void cleanup_server()
{
- if (name_trayer) free(name_trayer);
XFreeColormap(server.dsp, server.colormap);
free(server.monitor);
XFreeGC(server.dsp, server.gc);
int get_property32 (Window win, Atom at, Atom type);
void *server_get_property (Window win, Atom at, Atom type, int *num_results);
Atom server_get_atom (char *atom_name);
-void server_refresh_root_pixmap ();
-void server_refresh_main_pixmap ();
void server_catch_error (Display *d, XErrorEvent *ev);
void server_init_atoms ();
void server_init_visual();
Panel *panel =(Panel*)p;
if (panel_horizontal) {
- systray.area.posy = panel->area.pix.border.width + panel->area.paddingy;
+ systray.area.posy = panel->area.bg->border.width + panel->area.paddingy;
systray.area.height = panel->area.height - (2 * systray.area.posy);
}
else {
- systray.area.posx = panel->area.pix.border.width + panel->area.paddingy;
- systray.area.width = panel->area.width - (2 * panel->area.pix.border.width) - (2 * panel->area.paddingy);
+ systray.area.posx = panel->area.bg->border.width + panel->area.paddingy;
+ systray.area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
}
systray.area.parent = p;
systray.area.panel = p;
}
-void draw_systray(void *obj, cairo_t *c, int active)
+void draw_systray(void *obj, cairo_t *c)
{
if (real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
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.pmap, render_background, server.gc, 0, 0, systray.area.width, systray.area.height, 0, 0);
+ XCopyArea(server.dsp, systray.area.pix, render_background, server.gc, 0, 0, systray.area.width, systray.area.height, 0, 0);
}
// tint2 don't draw systray icons. just the background.
icon_size = sysbar->area.height;
else
icon_size = sysbar->area.width;
- icon_size = icon_size - (2 * sysbar->area.pix.border.width) - (2 * sysbar->area.paddingy);
+ icon_size = icon_size - (2 * sysbar->area.bg->border.width) - (2 * sysbar->area.paddingy);
if (systray_max_icon_size > 0 && icon_size > systray_max_icon_size)
icon_size = systray_max_icon_size;
count = 0;
if (panel_horizontal) {
if (!count) systray.area.width = 0;
else {
- int icons_per_column = (sysbar->area.height - 2*sysbar->area.pix.border.width - 2*sysbar->area.paddingy + sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
+ int icons_per_column = (sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy + sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
int row_count = count / icons_per_column + (count%icons_per_column != 0);
- systray.area.width = (2 * systray.area.pix.border.width) + (2 * systray.area.paddingxlr) + (icon_size * row_count) + ((row_count-1) * systray.area.paddingx);
+ systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * row_count) + ((row_count-1) * systray.area.paddingx);
}
- systray.area.posx = panel->area.width - panel->area.pix.border.width - panel->area.paddingxlr - systray.area.width;
+ systray.area.posx = panel->area.width - panel->area.bg->border.width - panel->area.paddingxlr - systray.area.width;
if (panel->clock.area.on_screen)
systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
#ifdef ENABLE_BATTERY
else {
if (!count) systray.area.height = 0;
else {
- int icons_per_row = (sysbar->area.width - 2*sysbar->area.pix.border.width - 2*sysbar->area.paddingy + sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
+ int icons_per_row = (sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy + sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
int column_count = count / icons_per_row+ (count%icons_per_row != 0);
- systray.area.height = (2 * systray.area.pix.border.width) + (2 * systray.area.paddingxlr) + (icon_size * column_count) + ((column_count-1) * systray.area.paddingx);
+ systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * column_count) + ((column_count-1) * systray.area.paddingx);
}
- systray.area.posy = panel->area.pix.border.width + panel->area.paddingxlr;
+ systray.area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
if (panel->clock.area.on_screen)
systray.area.posy += (panel->clock.area.height + panel->area.paddingx);
#ifdef ENABLE_BATTERY
int max_line_pos;
if (panel_horizontal) {
- max_line_pos = sysbar->area.posy+sysbar->area.height - sysbar->area.pix.border.width - sysbar->area.paddingy - icon_size;
- posy = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
- posx = systray.area.posx + systray.area.pix.border.width + systray.area.paddingxlr;
+ max_line_pos = sysbar->area.posy+sysbar->area.height - sysbar->area.bg->border.width - sysbar->area.paddingy - icon_size;
+ posy = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy;
+ posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
}
else {
- max_line_pos = sysbar->area.posx+sysbar->area.width - sysbar->area.pix.border.width - sysbar->area.paddingy - icon_size;
- posx = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
- posy = systray.area.posy + systray.area.pix.border.width + systray.area.paddingxlr;
+ max_line_pos = sysbar->area.posx+sysbar->area.width - sysbar->area.bg->border.width - sysbar->area.paddingy - icon_size;
+ posx = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy;
+ posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
}
for (l = systray.list_icons; l ; l = l->next) {
posy += icon_size + sysbar->area.paddingx;
else {
posx += (icon_size + systray.area.paddingx);
- posy = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
+ posy = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy;
}
}
else {
posx += icon_size + systray.area.paddingx;
else {
posy += (icon_size + systray.area.paddingx);
- posx = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
+ posx = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy;
}
}
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);
imlib_image_put_back_data(data);
- XCopyArea(server.dsp, render_background, systray.area.pix.pmap, 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);
+ 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);
if ( !real_transparency ) {
- imlib_context_set_drawable(systray.area.pix.pmap);
+ imlib_context_set_drawable(systray.area.pix);
imlib_render_image_on_drawable(traywin->x-systray.area.posx, traywin->y-systray.area.posy);
}
else {
- render_image(systray.area.pix.pmap, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height);
+ render_image(systray.area.pix, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height);
}
- XCopyArea(server.dsp, systray.area.pix.pmap, panel->main_win, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x, traywin->y);
+ XCopyArea(server.dsp, systray.area.pix, panel->main_win, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x, traywin->y);
imlib_free_image_and_decache();
XDamageSubtract(server.dsp, traywin->damage, None, None);
int hide;
int depth;
Damage damage;
- const struct timeout* render_timeout;
+ timeout* render_timeout;
} TrayWindow;
void init_systray();
void init_systray_panel(void *p);
void cleanup_systray();
-void draw_systray(void *obj, cairo_t *c, int active);
+void draw_systray(void *obj, cairo_t *c);
void resize_systray(void *obj);
#include "tooltip.h"
#include "timer.h"
-static const struct timeout* urgent_timeout = 0;
+static timeout* urgent_timeout = 0;
static GSList* urgent_list = 0;
const char* task_get_tooltip(void* obj)
}
else monitor = 0;
new_tsk.area.panel = &panel1[monitor];
+ new_tsk.current_state = window_is_iconified(win) ? TASK_ICONIFIED : TASK_NORMAL;
// allocate only one title and one icon
// even with task_on_all_desktop and with task_on_all_panel
new_tsk.title = 0;
- new_tsk.icon = new_tsk.icon_active = NULL;
+ int k;
+ for (k=0; k<TASK_STATE_COUNT; ++k)
+ new_tsk.icon[k] = 0;
get_title(&new_tsk);
get_icon(&new_tsk);
new_tsk2->area.parent = tskbar;
new_tsk2->win = new_tsk.win;
new_tsk2->desktop = new_tsk.desktop;
+ set_task_state(new_tsk2, new_tsk.current_state);
if (new_tsk2->desktop == ALLDESKTOP && server.desktop != j) {
// hide ALLDESKTOP task on non-current desktop
new_tsk2->area.on_screen = 0;
}
new_tsk2->title = new_tsk.title;
new_tsk2->area._get_tooltip_text = task_get_tooltip;
- new_tsk2->icon = new_tsk.icon;
- new_tsk2->icon_active = new_tsk.icon_active;
+ for (k=0; k<TASK_STATE_COUNT; ++k)
+ new_tsk2->icon[k] = new_tsk.icon[k];
new_tsk2->icon_width = new_tsk.icon_width;
new_tsk2->icon_height = new_tsk.icon_height;
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2);
//printf("remove_task %s %d\n", tsk->title, tsk->desktop);
if (tsk->title)
free (tsk->title);
- if (tsk->icon) {
- imlib_context_set_image(tsk->icon);
- imlib_free_image();
- imlib_context_set_image(tsk->icon_active);
- imlib_free_image();
- tsk->icon = tsk->icon_active = NULL;
+ int k;
+ for (k=0; k<TASK_STATE_COUNT; ++k) {
+ if (tsk->icon[k]) {
+ imlib_context_set_image(tsk->icon[k]);
+ imlib_free_image();
+ tsk->icon[k] = 0;
+ }
}
int i, j;
if (g_slist_find(urgent_list, tsk2))
del_urgent(tsk2);
- XFreePixmap (server.dsp, tsk2->area.pix.pmap);
- XFreePixmap (server.dsp, tsk2->area.pix_active.pmap);
+ XFreePixmap (server.dsp, tsk2->area.pix);
free(tsk2);
}
}
XWMHints *hints = 0;
long *data = 0;
- if (tsk->icon) {
- imlib_context_set_image(tsk->icon);
- imlib_free_image();
- imlib_context_set_image(tsk->icon_active);
- imlib_free_image();
- tsk->icon = tsk->icon_active = NULL;
+ int k;
+ for (k=0; k<TASK_STATE_COUNT; ++k) {
+ if (tsk->icon[k]) {
+ imlib_context_set_image(tsk->icon[k]);
+ imlib_free_image();
+ tsk->icon[k] = 0;
+ }
}
tsk->area.redraw = 1;
int w, h;
w = imlib_image_get_width();
h = imlib_image_get_height();
- tsk->icon = imlib_create_cropped_scaled_image(0, 0, w, h, panel->g_task.icon_size1, panel->g_task.icon_size1);
+ Imlib_Image orig_image = imlib_create_cropped_scaled_image(0, 0, w, h, panel->g_task.icon_size1, panel->g_task.icon_size1);
imlib_free_image();
- imlib_context_set_image(tsk->icon);
+ imlib_context_set_image(orig_image);
tsk->icon_width = imlib_image_get_width();
tsk->icon_height = imlib_image_get_height();
- tsk->icon_active = imlib_clone_image();
-
- DATA32 *data32;
- if (panel->g_task.alpha != 100 || panel->g_task.saturation != 0 || panel->g_task.brightness != 0) {
- data32 = imlib_image_get_data();
- adjust_asb(data32, tsk->icon_width, tsk->icon_height, panel->g_task.alpha, (float)panel->g_task.saturation/100, (float)panel->g_task.brightness/100);
- imlib_image_put_back_data(data32);
- }
-
- if (panel->g_task.alpha_active != 100 || panel->g_task.saturation_active != 0 || panel->g_task.brightness_active != 0) {
- imlib_context_set_image(tsk->icon_active);
- data32 = imlib_image_get_data();
- adjust_asb(data32, tsk->icon_width, tsk->icon_height, panel->g_task.alpha_active, (float)panel->g_task.saturation_active/100, (float)panel->g_task.brightness_active/100);
- imlib_image_put_back_data(data32);
+ for (k=0; k<TASK_STATE_COUNT; ++k) {
+ imlib_context_set_image(orig_image);
+ tsk->icon[k] = imlib_clone_image();
+ imlib_context_set_image(tsk->icon[k]);
+ DATA32 *data32;
+ if (panel->g_task.alpha[k] != 100 || panel->g_task.saturation[k] != 0 || panel->g_task.brightness[k] != 0) {
+ data32 = imlib_image_get_data();
+ adjust_asb(data32, tsk->icon_width, tsk->icon_height, panel->g_task.alpha[k], (float)panel->g_task.saturation[k]/100, (float)panel->g_task.brightness[k]/100);
+ imlib_image_put_back_data(data32);
+ }
}
+ imlib_context_set_image(orig_image);
+ imlib_free_image();
if (hints)
XFree(hints);
}
-void draw_task_icon (Task *tsk, int text_width, int active)
+void draw_task_icon (Task *tsk, int text_width)
{
- if (tsk->icon == NULL || tsk->icon_active == NULL) return;
+ if (tsk->icon[tsk->current_state] == 0) return;
// Find pos
int pos_x;
else
pos_x = (tsk->area.width - panel->g_task.icon_size1) / 2;
}
- else pos_x = panel->g_task.area.paddingxlr + panel->g_task.area.pix.border.width;
+ else pos_x = panel->g_task.area.paddingxlr + tsk->area.bg->border.width;
// Render
- Pixmap *pmap;
- if (active == 0) {
- imlib_context_set_image (tsk->icon);
- pmap = &tsk->area.pix.pmap;
- }
- else {
- imlib_context_set_image (tsk->icon_active);
- pmap = &tsk->area.pix_active.pmap;
- }
+ imlib_context_set_image (tsk->icon[tsk->current_state]);
if (real_transparency) {
- render_image(*pmap, pos_x, panel->g_task.icon_posy, imlib_image_get_width(), imlib_image_get_height() );
+ render_image(tsk->area.pix, pos_x, panel->g_task.icon_posy, imlib_image_get_width(), imlib_image_get_height() );
}
else {
- imlib_context_set_drawable (*pmap);
+ imlib_context_set_drawable(tsk->area.pix);
imlib_render_image_on_drawable (pos_x, panel->g_task.icon_posy);
}
}
-void draw_task (void *obj, cairo_t *c, int active)
+void draw_task (void *obj, cairo_t *c)
{
Task *tsk = obj;
PangoLayout *layout;
- config_color *config_text;
+ Color *config_text;
int width=0, height;
Panel *panel = (Panel*)tsk->area.panel;
pango_layout_get_pixel_size (layout, &width, &height);
- if (active) config_text = &panel->g_task.font_active;
- else config_text = &panel->g_task.font;
+ config_text = &panel->g_task.font[tsk->current_state];
cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha);
if (panel->g_task.icon) {
// icon use same opacity as text
- draw_task_icon (tsk, width, active);
+ draw_task_icon (tsk, width);
}
}
for (j=0 ; j < panel1[i].nb_desktop ; j++) {
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk1 = l0->data;
- tsk1->area.is_active = 0;
+ if (tsk1->win == task_active->win)
+ set_task_state(tsk1, window_is_iconified(tsk1->win) ? TASK_ICONIFIED : TASK_NORMAL);
}
}
}
if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
if (w2) tsk2 = task_get_task(w2);
}
- if ( g_slist_find(urgent_list, tsk2) ) {
+
+ if ( g_slist_find(urgent_list, tsk2) )
del_urgent(tsk2);
- }
+
// put active state on all task (multi_desktop)
if (tsk2) {
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) {
tsk1 = l0->data;
- if (tsk1->win == tsk2->win) {
- tsk1->area.is_active = 1;
- }
+ if (tsk1->win == tsk2->win)
+ set_task_state(tsk1, TASK_ACTIVE);
}
}
}
}
+void set_task_state(Task *tsk, int state)
+{
+ tsk->current_state = state;
+ tsk->area.bg = panel1[0].g_task.background[state];
+ tsk->area.redraw = 1;
+}
+
+
void blink_urgent(void* arg)
{
GSList* urgent_task = urgent_list;
while (urgent_task) {
Task* t = urgent_task->data;
if ( t->urgent_tick < max_tick_urgent) {
- t->area.is_active = !t->area.is_active;
- t->area.redraw = 1;
- t->urgent_tick++;
+ if (t->urgent_tick++ % 2)
+ set_task_state(t, TASK_URGENT);
+ else
+ set_task_state(t, window_is_iconified(t->win) ? TASK_ICONIFIED : TASK_NORMAL);
}
urgent_task = urgent_task->next;
}
urgent_list = g_slist_remove(urgent_list, it->data);
it = it->next;
}
+ g_slist_free(urgent_del);
if (!urgent_list) {
stop_timeout(urgent_timeout);
urgent_timeout = 0;
#include "common.h"
+enum { TASK_NORMAL, TASK_ACTIVE, TASK_ICONIFIED, TASK_URGENT, TASK_STATE_COUNT };
+
// --------------------------------------------------
// global task parameter
typedef struct {
int icon_size1;
int maximum_width;
int maximum_height;
- int alpha, saturation, brightness;
- int alpha_active, saturation_active, brightness_active;
+ int alpha[TASK_STATE_COUNT];
+ int saturation[TASK_STATE_COUNT];
+ int brightness[TASK_STATE_COUNT];
+ int config_asb_mask;
+ Background* background[TASK_STATE_COUNT];
+ int config_background_mask;
// starting position for text ~ task_padding + task_border + icon_size
double text_posx, text_posy;
int font_shadow;
PangoFontDescription *font_desc;
- config_color font;
- config_color font_active;
+ Color font[TASK_STATE_COUNT];
+ int config_font_mask;
} Global_task;
// TODO: group task with list of windows here
Window win;
int desktop;
- Imlib_Image icon;
- Imlib_Image icon_active;
+ int current_state;
+ Imlib_Image icon[TASK_STATE_COUNT];
unsigned int icon_width;
unsigned int icon_height;
char *title;
Task *add_task (Window win);
void remove_task (Task *tsk);
-void draw_task (void *obj, cairo_t *c, int active);
+void draw_task (void *obj, cairo_t *c);
void get_icon (Task *tsk);
void get_title(Task *tsk);
void active_task();
+void set_task_state(Task* tsk, int state);
Task *next_task (Task *tsk);
Task *prev_task (Task *tsk);
}
// taskbar
- panel->g_taskbar._resize = resize_taskbar;
- panel->g_taskbar.redraw = 1;
- panel->g_taskbar.on_screen = 1;
+ panel->g_taskbar.area._resize = resize_taskbar;
+ panel->g_taskbar.area.redraw = 1;
+ panel->g_taskbar.area.on_screen = 1;
if (panel_horizontal) {
- panel->g_taskbar.posy = panel->area.pix.border.width + panel->area.paddingy;
- panel->g_taskbar.height = panel->area.height - (2 * panel->g_taskbar.posy);
+ panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy;
+ panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy);
}
else {
- panel->g_taskbar.posx = panel->area.pix.border.width + panel->area.paddingy;
- panel->g_taskbar.width = panel->area.width - (2 * panel->g_taskbar.posx);
+ panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy;
+ panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx);
}
// task
panel->g_task.area._draw_foreground = draw_task;
- panel->g_task.area.use_active = 1;
panel->g_task.area.redraw = 1;
panel->g_task.area.on_screen = 1;
+ if ((panel->g_task.config_asb_mask & (1<<TASK_ACTIVE)) == 0) {
+ panel->g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL];
+ panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL];
+ panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL];
+ }
+ if ((panel->g_task.config_asb_mask & (1<<TASK_ICONIFIED)) == 0) {
+ panel->g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL];
+ panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL];
+ panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL];
+ }
+ if ((panel->g_task.config_asb_mask & (1<<TASK_URGENT)) == 0) {
+ panel->g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE];
+ panel->g_task.saturation[TASK_URGENT] = panel->g_task.saturation[TASK_ACTIVE];
+ panel->g_task.brightness[TASK_URGENT] = panel->g_task.brightness[TASK_ACTIVE];
+ }
+ if ((panel->g_task.config_font_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.font[TASK_ACTIVE] = panel->g_task.font[TASK_NORMAL];
+ if ((panel->g_task.config_font_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL];
+ if ((panel->g_task.config_font_mask & (1<<TASK_URGENT)) == 0) panel->g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE];
+ if ((panel->g_task.config_background_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL];
+ if ((panel->g_task.config_background_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL];
+ if ((panel->g_task.config_background_mask & (1<<TASK_URGENT)) == 0) panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE];
+
if (panel_horizontal) {
- panel->g_task.area.posy = panel->g_taskbar.posy + panel->g_taskbar.pix.border.width + panel->g_taskbar.paddingy;
+ panel->g_task.area.posy = panel->g_taskbar.area.posy + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
}
else {
- panel->g_task.area.posx = panel->g_taskbar.posx + panel->g_taskbar.pix.border.width + panel->g_taskbar.paddingy;
+ panel->g_task.area.posx = panel->g_taskbar.area.posx + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx);
panel->g_task.area.height = panel->g_task.maximum_height;
}
- if (panel->g_task.area.pix.border.rounded > panel->g_task.area.height/2) {
- panel->g_task.area.pix.border.rounded = panel->g_task.area.height/2;
- panel->g_task.area.pix_active.border.rounded = panel->g_task.area.pix.border.rounded;
+ int k;
+ for (k=0; k<TASK_STATE_COUNT; ++k) {
+ if (panel->g_task.background[k]->border.rounded > panel->g_task.area.height/2) {
+ printf("task%sbackground_id is too big. Please fix your tint2rc\n", k==0 ? "_" : k==1 ? "_active_" : k==2 ? "_iconified_" : "_urgent_");
+ g_array_append_val(backgrounds, *panel->g_task.background[k]);
+ panel->g_task.background[k] = &g_array_index(backgrounds, Background, backgrounds->len-1);
+ panel->g_task.background[k]->border.rounded = panel->g_task.area.height/2;
+ }
}
// compute vertical position : text and icon
if (!panel->g_task.maximum_width && panel_horizontal)
panel->g_task.maximum_width = server.monitor[panel->monitor].width;
- panel->g_task.text_posx = panel->g_task.area.pix.border.width + panel->g_task.area.paddingxlr;
+ panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
panel->g_task.text_posy = (panel->g_task.area.height - height) / 2.0;
if (panel->g_task.icon) {
panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
tskbar = &panel->taskbar[j];
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
tskbar->desktop = j;
- if (j == server.desktop && tskbar->area.use_active)
- tskbar->area.is_active = 1;
+ if (j == server.desktop && panel->g_taskbar.use_active)
+ tskbar->area.bg = panel->g_taskbar.bg_active;
// add taskbar to the panel
panel->area.list = g_slist_append(panel->area.list, tskbar);
//printf("resize_taskbar : posx et width des taches\n");
taskbar->area.redraw = 1;
- if (taskbar->area.is_active && taskbar->area.use_active)
- border_width = taskbar->area.pix_active.border.width;
- else
- border_width = taskbar->area.pix.border.width;
+ border_width = taskbar->area.bg->border.width;
if (panel_horizontal) {
int pixel_width, modulo_width=0;
task_count = g_slist_length(taskbar->area.list);
if (!task_count) pixel_width = panel->g_task.maximum_width;
else {
- taskbar_width = taskbar->area.width - (2 * border_width) - (2 * panel->g_taskbar.paddingxlr);
- if (task_count>1) taskbar_width -= ((task_count-1) * panel->g_taskbar.paddingx);
+ taskbar_width = taskbar->area.width - (2 * border_width) - (2 * panel->g_taskbar.area.paddingxlr);
+ if (task_count>1) taskbar_width -= ((task_count-1) * panel->g_taskbar.area.paddingx);
pixel_width = taskbar_width / task_count;
if (pixel_width > panel->g_task.maximum_width)
taskbar->task_width = pixel_width;
taskbar->task_modulo = modulo_width;
- taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx;
+ taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx;
// change pos_x and width for all tasks
x = taskbar->area.posx + border_width + taskbar->area.paddingxlr;
modulo_width--;
}
- x += tsk->area.width + panel->g_taskbar.paddingx;
+ x += tsk->area.width + panel->g_taskbar.area.paddingx;
}
}
else {
task_count = g_slist_length(taskbar->area.list);
if (!task_count) pixel_height = panel->g_task.maximum_height;
else {
- taskbar_height = taskbar->area.height - (2 * border_width) - (2 * panel->g_taskbar.paddingxlr);
- if (task_count>1) taskbar_height -= ((task_count-1) * panel->g_taskbar.paddingx);
+ taskbar_height = taskbar->area.height - (2 * border_width) - (2 * panel->g_taskbar.area.paddingxlr);
+ if (task_count>1) taskbar_height -= ((task_count-1) * panel->g_taskbar.area.paddingx);
pixel_height = taskbar_height / task_count;
if (pixel_height > panel->g_task.maximum_height)
taskbar->task_width = pixel_height;
taskbar->task_modulo = modulo_height;
- taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.paddingy) - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx;
+ taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx;
// change pos_y and height for all tasks
y = taskbar->area.posy + border_width + taskbar->area.paddingxlr;
modulo_height--;
}
- y += tsk->area.height + panel->g_taskbar.paddingx;
+ y += tsk->area.height + panel->g_taskbar.area.paddingx;
}
}
}
} Taskbar;
+typedef struct {
+ //always start with area
+ Area area;
+ Background* bg;
+ Background* bg_active;
+ int use_active;
+} Global_taskbar;
void init_taskbar();
void cleanup_taskbar();
// redraw both taskbar
if (server.nb_desktop > old_desktop) {
// can happen if last desktop is deleted and we've been on the last desktop
- panel->taskbar[old_desktop].area.is_active = 0;
+ panel->taskbar[old_desktop].area.bg = panel->g_taskbar.bg;
panel->taskbar[old_desktop].area.resize = 1;
}
- panel->taskbar[server.desktop].area.is_active = 1;
+ panel->taskbar[server.desktop].area.bg = panel->g_taskbar.bg_active;
panel->taskbar[server.desktop].area.resize = 1;
panel_refresh = 1;
}
panel_refresh = 1;
}
}
-// We do not check for the iconified state, since it only unsets our active window
-// but in openbox a shaded window is considered iconified. So we would loose the active window
-// property on unshading it again (commented 01.10.2009)
-// 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) {
-// Task *tsk2;
-// GSList *l0;
-// 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) {
-// tsk2 = l0->data;
-// tsk2->area.is_active = 0;
-// }
-// }
-// }
-// task_active = 0;
-// }
-// }
-// }
-// }
+ else if (at == server.atom.WM_STATE) {
+ // Iconic state
+ int state = task_active == tsk ? TASK_ACTIVE : TASK_NORMAL;
+ if (window_is_iconified(win))
+ state = TASK_ICONIFIED;
+ GSList* task_list = task_get_tasks(win);
+ GSList* it = task_list;
+ while (it) {
+ Task* t = it->data;
+ set_task_state(t, state);
+ it = it->next;
+ }
+ g_slist_free(task_list);
+ panel_refresh = 1;
+ }
// 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++) {
- for (j=0 ; j < panel1[i].nb_desktop ; j++) {
- for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
- tsk2 = l0->data;
- if (tsk->win == tsk2->win && tsk != tsk2) {
- tsk2->icon_width = tsk->icon_width;
- tsk2->icon_height = tsk->icon_height;
- tsk2->icon = tsk->icon;
- tsk2->icon_active = tsk->icon_active;
- tsk2->area.redraw = 1;
- }
- }
+ GSList* task_list = task_get_tasks(tsk->win);
+ GSList *l0 = task_list;
+ while (l0) {
+ tsk2 = l0->data;
+ if (tsk2 != tsk) {
+ tsk2->icon_width = tsk->icon_width;
+ tsk2->icon_height = tsk->icon_height;
+ int k=0;
+ for ( ; k<TASK_STATE_COUNT; ++k)
+ tsk2->icon[k] = tsk->icon[k];
+ tsk2->area.redraw = 1;
}
+ l0 = l0->next;
}
+ g_slist_free(task_list);
panel_refresh = 1;
}
// Window desktop changed
add_task (win);
if (win == window_get_active ()) {
GSList* task_list = task_get_tasks(win);
- while (task_list) {
- Task *tsk = task_list->data;
- tsk->area.is_active = 1;
+ GSList* it = task_list;
+ while (it) {
+ Task *tsk = it->data;
+ tsk->current_state = TASK_ACTIVE;
task_active = tsk;
- task_list = task_list->next;
+ it = task_list->next;
}
+ g_slist_free(task_list);
}
panel_refresh = 1;
}
.paddingx = 0,
.paddingy = 0,
.font_color = { .color={1, 1, 1}, .alpha=1 },
- .background_color = { .color={0.5, 0.4, 0.5}, .alpha=1 },
- .border = { .color={0, 0, 0}, .alpha=1, .width=1, .rounded=0 },
+ .bg = 0,
.font_desc = 0,
.timeout = 0
};
pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
PangoRectangle r1, r2;
pango_layout_get_pixel_extents(layout, &r1, &r2);
- width = 2*g_tooltip.border.width + 2*g_tooltip.paddingx + r2.width;
- height = 2*g_tooltip.border.width + 2*g_tooltip.paddingy + r2.height;
+ width = 2*g_tooltip.bg->border.width + 2*g_tooltip.paddingx + r2.width;
+ height = 2*g_tooltip.bg->border.width + 2*g_tooltip.paddingy + r2.height;
Panel* panel = g_tooltip.panel;
if (panel_horizontal && panel_position & BOTTOM)
PangoLayout* layout;
cs = cairo_xlib_surface_create(server.dsp, g_tooltip.window, server.visual, width, height);
c = cairo_create(cs);
- Color bc = g_tooltip.background_color;
- Border b = g_tooltip.border;
+ Color bc = g_tooltip.bg->back;
+ Border b = g_tooltip.bg->border;
if (real_transparency) {
clear_pixmap(g_tooltip.window, 0, 0, width, height);
draw_rect(c, b.width, b.width, width-2*b.width, height-2*b.width, b.rounded-b.width/1.571);
cairo_set_source_rgba(c, b.color[0], b.color[1], b.color[2], b.alpha);
cairo_stroke(c);
- config_color fc = g_tooltip.font_color;
+ Color fc = g_tooltip.font_color;
cairo_set_source_rgba(c, fc.color[0], fc.color[1], fc.color[2], fc.alpha);
layout = pango_cairo_create_layout(c);
pango_layout_set_font_description(layout, g_tooltip.font_desc);
pango_layout_set_height(layout, height*PANGO_SCALE);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
// I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and vert.)
- cairo_move_to(c, -r1.x/2+g_tooltip.border.width+g_tooltip.paddingx, -r1.y/2+g_tooltip.border.width+g_tooltip.paddingy);
+ cairo_move_to(c, -r1.x/2+g_tooltip.bg->border.width+g_tooltip.paddingx, -r1.y/2+g_tooltip.bg->border.width+g_tooltip.paddingy);
pango_cairo_show_layout (c, layout);
g_object_unref (layout);
int paddingx;
int paddingy;
PangoFontDescription* font_desc;
- config_color font_color;
- Color background_color;
- Border border;
- const struct timeout* timeout;
+ Color font_color;
+ Background* bg;
+ timeout* timeout;
} Tooltip;
extern Tooltip g_tooltip;
#include "server.h"
#include "panel.h"
-// QUESTION: Why do we need Pixmaps for drawing? Can't we draw directly in the Window???
-// Parent could pass a cairo_surface_t to the children, and children use it, for drawing...
-
// 1) resize child
// 2) resize parent
set_redraw(l->data);
//printf("draw area posx %d, width %d\n", a->posx, a->width);
- draw(a, 0);
- if (a->use_active)
- draw(a, 1);
+ draw(a);
}
// draw current Area
- 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);
+ if (a->pix == 0) printf("empty area posx %d, width %d\n", a->posx, a->width);
+ XCopyArea (server.dsp, a->pix, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
// and then refresh child object
GSList *l;
}
-void draw (Area *a, int active)
+void draw (Area *a)
{
- 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 (a->pix) XFreePixmap (server.dsp, a->pix);
+ a->pix = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
// add layer of root pixmap (or clear pixmap if real_transparency==true)
if (real_transparency)
- clear_pixmap(*pmap, 0 ,0, a->width, a->height);
- XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
+ clear_pixmap(a->pix, 0 ,0, a->width, a->height);
+ XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, a->pix, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
cairo_surface_t *cs;
cairo_t *c;
- cs = cairo_xlib_surface_create (server.dsp, *pmap, server.visual, a->width, a->height);
+ cs = cairo_xlib_surface_create (server.dsp, a->pix, server.visual, a->width, a->height);
c = cairo_create (cs);
- draw_background (a, c, active);
+ draw_background (a, c);
if (a->_draw_foreground)
- a->_draw_foreground(a, c, active);
+ a->_draw_foreground(a, c);
cairo_destroy (c);
cairo_surface_destroy (cs);
}
-void draw_background (Area *a, cairo_t *c, int active)
+void draw_background (Area *a, cairo_t *c)
{
- Pmap *pix = (active == 0) ? (&a->pix) : (&a->pix_active);
-
- if (pix->back.alpha > 0.0) {
+ if (a->bg->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);
-
+ draw_rect(c, a->bg->border.width, a->bg->border.width, a->width-(2.0 * a->bg->border.width), a->height-(2.0*a->bg->border.width), a->bg->border.rounded - a->bg->border.width/1.571);
+ cairo_set_source_rgba(c, a->bg->back.color[0], a->bg->back.color[1], a->bg->back.color[2], a->bg->back.alpha);
cairo_fill(c);
}
- if (pix->border.width > 0 && pix->border.alpha > 0.0) {
- cairo_set_line_width (c, pix->border.width);
+ if (a->bg->border.width > 0 && a->bg->border.alpha > 0.0) {
+ cairo_set_line_width (c, a->bg->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);
+ draw_rect(c, a->bg->border.width/2.0, a->bg->border.width/2.0, a->width - a->bg->border.width, a->height - a->bg->border.width, a->bg->border.rounded);
/*
// convert : radian = degre * M_PI/180
// définir le dégradé dans un carré de (0,0) (100,100)
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_set_source_rgba (c, a->bg->border.color[0], a->bg->border.color[1], a->bg->border.color[2], a->bg->border.alpha);
cairo_stroke (c);
//cairo_pattern_destroy (linpat);
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) {
+ XFreePixmap (server.dsp, a->pix);
+ a->pix = 0;
}
}
* Area is at the begining of each object (&object == &area).
*
* Area manage the background and border drawing, size and padding.
-* Each Area have 2 Pixmap (pix and pix_active).
+* Each Area has one Pixmap (pix).
*
* Area manage the tree of all objects. Parent object drawn before child object.
* panel -> taskbars -> tasks
double alpha;
} Color;
-
typedef struct
{
- Pixmap pmap;
Color back;
Border border;
-} Pmap;
+} Background;
+
typedef struct {
int posx, posy;
// width and height including border
int width, height;
- Pmap pix;
- Pmap pix_active;
+ Pixmap pix;
+ Background *bg;
// list of child : Area object
GSList *list;
int resize;
// need redraw Pixmap
int redraw;
- int use_active, is_active;
// paddingxlr = horizontal padding left/right
// paddingx = horizontal padding between childs
int paddingxlr, paddingx, paddingy;
void *panel;
// each object can overwrite following function
- void (*_draw_foreground)(void *obj, cairo_t *c, int active);
+ void (*_draw_foreground)(void *obj, cairo_t *c);
void (*_resize)(void *obj);
void (*_add_child)(void *obj);
int (*_remove_child)(void *obj);
// set 'redraw' on an area and childs
void set_redraw (Area *a);
-// draw pixmap and pixmap_active
-void draw (Area *a, int active);
-void draw_background (Area *a, cairo_t *c, int active);
+// draw pixmap
+void draw (Area *a);
+void draw_background (Area *a, cairo_t *c);
void remove_area (Area *a);
void add_area (Area *a);
#define ALLDESKTOP 0xFFFFFFFF
-typedef struct config_border
-{
- double color[3];
- double alpha;
- int width;
- int rounded;
-} config_border;
-
-
-typedef struct config_color
-{
- double color[3];
- double alpha;
-} config_color;
-
-
// copy file source to file dest
void copy_file(const char *pathSrc, const char *pathDest);
GSList* timeout_list = 0;
struct timeval next_timeout;
-void add_timeout_intern(int value_msec, int interval_msec, void(*_callback)(void*), void* arg, struct timeout* t);
-gint compare_timeouts(gconstpointer t1, gconstpointer t2);
-gint compare_timespecs(const struct timespec* t1, const struct timespec* t2);
-int timespec_subtract(struct timespec* result, struct timespec* x, struct timespec* y);
-struct timespec add_msec_to_timespec(struct timespec ts, int msec);
// functions and structs for multi timeouts
-struct multi_timeout {
+typedef struct {
int current_count;
int count_to_expiration;
-};
+} multi_timeout;
-struct multi_timeout_handler {
+typedef struct {
GSList* timeout_list;
- struct timeout* parent_timeout;
+ timeout* parent_timeout;
+} multi_timeout_handler;
+
+struct _timeout {
+ int interval_msec;
+ struct timespec timeout_expires;
+ void (*_callback)(void*);
+ void* arg;
+ multi_timeout* multi_timeout;
};
-int align_with_existing_timeouts(struct timeout* t);
-void create_multi_timeout(struct timeout* t1, struct timeout* t2);
-void append_multi_timeout(struct timeout* t1, struct timeout* t2);
-int calc_multi_timeout_interval(struct multi_timeout_handler* mth);
-void update_multi_timeout_values(struct multi_timeout_handler* mth);
+void add_timeout_intern(int value_msec, int interval_msec, void(*_callback)(void*), void* arg, timeout* t);
+gint compare_timeouts(gconstpointer t1, gconstpointer t2);
+gint compare_timespecs(const struct timespec* t1, const struct timespec* t2);
+int timespec_subtract(struct timespec* result, struct timespec* x, struct timespec* y);
+struct timespec add_msec_to_timespec(struct timespec ts, int msec);
+
+
+int align_with_existing_timeouts(timeout* t);
+void create_multi_timeout(timeout* t1, timeout* t2);
+void append_multi_timeout(timeout* t1, timeout* t2);
+int calc_multi_timeout_interval(multi_timeout_handler* mth);
+void update_multi_timeout_values(multi_timeout_handler* mth);
void callback_multi_timeout(void* mth);
-void remove_from_multi_timeout(struct timeout* t);
-void stop_multi_timeout(struct timeout* t);
+void remove_from_multi_timeout(timeout* t);
+void stop_multi_timeout(timeout* t);
GHashTable* multi_timeouts = 0;
* however it's save to call it.
**/
-const struct timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)(void*), void* arg)
+timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)(void*), void* arg)
{
- struct timeout* t = malloc(sizeof(struct timeout));
+ timeout* t = malloc(sizeof(timeout));
t->multi_timeout = 0;
add_timeout_intern(value_msec, interval_msec, _callback, arg, t);
return t;
}
-void change_timeout(const struct timeout *t, int value_msec, int interval_msec, void(*_callback)(), void* arg)
+void change_timeout(timeout *t, int value_msec, int interval_msec, void(*_callback)(), void* arg)
{
if ( g_slist_find(timeout_list, t) == 0 && g_hash_table_lookup(multi_timeouts, t) == 0)
printf("programming error: timeout already deleted...");
else {
if (t->multi_timeout)
- remove_from_multi_timeout((struct timeout*)t);
+ remove_from_multi_timeout((timeout*)t);
else
timeout_list = g_slist_remove(timeout_list, t);
- add_timeout_intern(value_msec, interval_msec, _callback, arg, (struct timeout*)t);
+ add_timeout_intern(value_msec, interval_msec, _callback, arg, (timeout*)t);
}
}
void update_next_timeout()
{
if (timeout_list) {
- struct timeout* t = timeout_list->data;
+ timeout* t = timeout_list->data;
struct timespec cur_time;
struct timespec next_timeout2 = { .tv_sec=next_timeout.tv_sec, .tv_nsec=next_timeout.tv_usec*1000 };
clock_gettime(CLOCK_MONOTONIC, &cur_time);
void callback_timeout_expired()
{
struct timespec cur_time;
- struct timeout* t;
+ timeout* t;
while (timeout_list) {
clock_gettime(CLOCK_MONOTONIC, &cur_time);
t = timeout_list->data;
}
-void stop_timeout(const struct timeout* t)
+void stop_timeout(timeout* t)
{
// if not in the list, it was deleted in callback_timeout_expired
if (g_slist_find(timeout_list, t) || g_hash_table_lookup(multi_timeouts, t)) {
if (t->multi_timeout)
- remove_from_multi_timeout((struct timeout*)t);
+ remove_from_multi_timeout((timeout*)t);
timeout_list = g_slist_remove(timeout_list, t);
free((void*)t);
}
void stop_all_timeouts()
{
while (timeout_list) {
- struct timeout* t = timeout_list->data;
+ timeout* t = timeout_list->data;
if (t->multi_timeout)
stop_multi_timeout(t);
free(t);
}
-void add_timeout_intern(int value_msec, int interval_msec, void(*_callback)(), void* arg, struct timeout *t)
+void add_timeout_intern(int value_msec, int interval_msec, void(*_callback)(), void* arg, timeout *t)
{
t->interval_msec = interval_msec;
t->_callback = _callback;
gint compare_timeouts(gconstpointer t1, gconstpointer t2)
{
- return compare_timespecs(&((const struct timeout*)t1)->timeout_expires,
- &((const struct timeout*)t2)->timeout_expires);
+ return compare_timespecs(&((timeout*)t1)->timeout_expires,
+ &((timeout*)t2)->timeout_expires);
}
}
-int align_with_existing_timeouts(struct timeout *t)
+int align_with_existing_timeouts(timeout *t)
{
GSList* it = timeout_list;
while (it) {
- struct timeout* t2 = it->data;
+ timeout* t2 = it->data;
if (t2->interval_msec > 0) {
if (t->interval_msec % t2->interval_msec == 0 || t2->interval_msec % t->interval_msec == 0) {
if (multi_timeouts == 0)
}
-int calc_multi_timeout_interval(struct multi_timeout_handler* mth)
+int calc_multi_timeout_interval(multi_timeout_handler* mth)
{
GSList* it = mth->timeout_list;
- struct timeout* t = it->data;
+ timeout* t = it->data;
int min_interval = t->interval_msec;
it = it->next;
while (it) {
}
-void create_multi_timeout(struct timeout* t1, struct timeout* t2)
+void create_multi_timeout(timeout* t1, timeout* t2)
{
- struct multi_timeout* mt1 = malloc(sizeof(struct multi_timeout));
- struct multi_timeout* mt2 = malloc(sizeof(struct multi_timeout));
- struct multi_timeout_handler* mth = malloc(sizeof(struct multi_timeout_handler));
- struct timeout* real_timeout = malloc(sizeof(struct timeout));
+ multi_timeout* mt1 = malloc(sizeof(multi_timeout));
+ multi_timeout* mt2 = malloc(sizeof(multi_timeout));
+ multi_timeout_handler* mth = malloc(sizeof(multi_timeout_handler));
+ timeout* real_timeout = malloc(sizeof(timeout));
mth->timeout_list = 0;
mth->timeout_list = g_slist_prepend(mth->timeout_list, t1);
}
-void append_multi_timeout(struct timeout* t1, struct timeout* t2)
+void append_multi_timeout(timeout* t1, timeout* t2)
{
if (t2->multi_timeout) {
// swap t1 and t2 such that t1 is the multi timeout
- struct timeout* tmp = t2;
+ timeout* tmp = t2;
t2 = t1;
t1 = tmp;
}
- struct multi_timeout* mt = malloc(sizeof(struct multi_timeout));
- struct multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t1);
+ multi_timeout* mt = malloc(sizeof(multi_timeout));
+ multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t1);
mth->timeout_list = g_slist_prepend(mth->timeout_list, t2);
g_hash_table_insert(multi_timeouts, t2, mth);
}
-void update_multi_timeout_values(struct multi_timeout_handler* mth)
+void update_multi_timeout_values(multi_timeout_handler* mth)
{
int interval = calc_multi_timeout_interval(mth);
int next_timeout_msec = interval;
GSList* it = mth->timeout_list;
struct timespec diff_time;
while (it) {
- struct timeout* t = it->data;
- struct multi_timeout* mt = t->multi_timeout;
- mt->count_to_expiration = t->interval_msec / interval;
+ timeout* t = it->data;
+ t->multi_timeout->count_to_expiration = t->interval_msec / interval;
timespec_subtract(&diff_time, &t->timeout_expires, &cur_time);
int msec_to_expiration = diff_time.tv_sec*1000 + diff_time.tv_nsec/1000000;
int count_left = msec_to_expiration / interval + (msec_to_expiration%interval != 0);
- mt->current_count = mt->count_to_expiration - count_left;
+ t->multi_timeout->current_count = t->multi_timeout->count_to_expiration - count_left;
if (msec_to_expiration < next_timeout_msec)
next_timeout_msec = msec_to_expiration;
it = it->next;
void callback_multi_timeout(void* arg)
{
- struct multi_timeout_handler* mth = arg;
+ multi_timeout_handler* mth = arg;
struct timespec cur_time;
clock_gettime(CLOCK_MONOTONIC, &cur_time);
GSList* it = mth->timeout_list;
while (it) {
- struct timeout* t = it->data;
- struct multi_timeout* mt = t->multi_timeout;
- if (++mt->current_count >= mt->count_to_expiration) {
+ timeout* t = it->data;
+ if (++t->multi_timeout->current_count >= t->multi_timeout->count_to_expiration) {
t->_callback(t->arg);
- mt->current_count = 0;
+ t->multi_timeout->current_count = 0;
t->timeout_expires = add_msec_to_timespec(cur_time, t->interval_msec);
}
it = it->next;
}
-void remove_from_multi_timeout(struct timeout* t)
+void remove_from_multi_timeout(timeout* t)
{
- struct multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t);
+ multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t);
g_hash_table_remove(multi_timeouts, t);
mth->timeout_list = g_slist_remove(mth->timeout_list, t);
t->multi_timeout = 0;
if (g_slist_length(mth->timeout_list) == 1) {
- struct timeout* last_timeout = mth->timeout_list->data;
+ timeout* last_timeout = mth->timeout_list->data;
free(last_timeout->multi_timeout);
last_timeout->multi_timeout = 0;
g_hash_table_remove(multi_timeouts, last_timeout);
}
-void stop_multi_timeout(struct timeout* t)
+void stop_multi_timeout(timeout* t)
{
- struct multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t);
+ multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t);
g_hash_table_remove(multi_timeouts, mth->parent_timeout);
while (mth->timeout_list) {
- struct timeout* t = mth->timeout_list->data;
+ timeout* t = mth->timeout_list->data;
mth->timeout_list = g_slist_remove(mth->timeout_list, t);
g_hash_table_remove(multi_timeouts, t);
free(t);
extern struct timeval next_timeout;
-struct timeout {
- int interval_msec;
- struct timespec timeout_expires;
- void (*_callback)(void*);
- void* arg;
- void* multi_timeout;
-};
+typedef struct _timeout timeout;
// timer functions
+/**
+ * Single shot timer (i.e. timer with interval_msec == 0) are deleted automatically as soon as they expire
+ * i.e. you do not need to stop them, however it is safe to call stop_timeout for these timers.
+ * Periodic timeouts are aligned to each other whenever possible, i.e. one interval_msec is an
+ * integral multiple of the other.
+**/
+
/** installs a timeout with the first timeout of 'value_msec' and then a periodic timeout with
- * 'interval_msec'. '_callback' is the callback function when the timer reaches the timeout.
- * returns a pointer to the timeout, which is needed for stopping it again **/
-const struct timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)(void*), void* arg);
+ * 'interval_msec'. '_callback' is the callback function when the timer reaches the timeout.
+ * returns a pointer to the timeout, which is needed for stopping it again
+**/
+timeout* add_timeout(int value_msec, int interval_msec, void (*_callback)(void*), void* arg);
-void change_timeout(const struct timeout* t, int value_msec, int interval_msec, void (*_callback)(void*), void* arg);
+/** changes timeout 't'. If timeout 't' does not exist, nothing happens **/
+void change_timeout(timeout* t, int value_msec, int interval_msec, void (*_callback)(void*), void* arg);
/** stops the timeout 't' **/
-void stop_timeout(const struct timeout* t);
+void stop_timeout(timeout* t);
/** stops all timeouts **/
void stop_all_timeouts();
+/** update_next_timeout updates next_timeout to the value, when the next installed timeout will expire **/
void update_next_timeout();
+
+/** Callback of all expired timeouts **/
void callback_timeout_expired();
#endif // TIMER_H
int window_is_iconified (Window win)
{
- return (IconicState == get_property32(win, server.atom.WM_STATE, server.atom.WM_STATE));
+ if (IconicState == get_property32(win, server.atom.WM_STATE, server.atom.WM_STATE)) {
+ // openbox sets on shaded windows the IconicState, however we do not consider these windows iconified
+ 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_SHADED) {
+ XFree(at);
+ return 0;
+ }
+ }
+ XFree(at);
+ return 1;
+ }
+ return 0;
}