From bd230aca5f0289c9464aa98b29f672c28fc58243 Mon Sep 17 00:00:00 2001 From: Thierry Lorthiois Date: Mon, 15 Nov 2010 15:36:12 +0000 Subject: [PATCH] desktop name second step --- src/config.c | 14 ++++++++++++-- src/panel.c | 3 +++ src/taskbar/taskbar.c | 6 ++++++ src/taskbar/taskbarname.c | 15 ++++++++++----- src/taskbar/taskbarname.h | 1 + 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/config.c b/src/config.c index b0b06d7..73732af 100644 --- a/src/config.c +++ b/src/config.c @@ -461,15 +461,21 @@ void add_entry (char *key, char *value) else if (strcmp (key, "taskbar_active_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); + panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); } else if (strcmp (key, "taskbar_name") == 0) { taskbarname_enabled = atoi (value); } + else if (strcmp (key, "taskbar_name_padding") == 0) { + extract_values(value, &value1, &value2, &value3); + panel_config.g_taskbar.area_name.paddingxlr = panel_config.g_taskbar.area_name.paddingx = atoi (value1); + } else if (strcmp (key, "taskbar_name_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; - panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); + panel_config.g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); + if (panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] == 0) + panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = panel_config.g_taskbar.background_name[TASKBAR_NORMAL]; } else if (strcmp (key, "taskbar_name_active_background_id") == 0) { int id = atoi (value); @@ -486,6 +492,10 @@ void add_entry (char *key, char *value) else taskbarname_font.alpha = 0.5; } else if (strcmp (key, "taskbar_name_active_font_color") == 0) { + extract_values(value, &value1, &value2, &value3); + get_color (value1, taskbarname_active_font.color); + if (value2) taskbarname_active_font.alpha = (atoi (value2) / 100.0); + else taskbarname_active_font.alpha = 0.5; } /* Task */ diff --git a/src/panel.c b/src/panel.c index 96f20cc..85efec9 100644 --- a/src/panel.c +++ b/src/panel.c @@ -537,8 +537,11 @@ void set_panel_background(Panel *p) for (k=0; kstate_pix[k]) XFreePixmap(server.dsp, tskbar->state_pix[k]); tskbar->state_pix[k] = 0; + if (tskbar->bar_name.state_pix[k]) XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]); + tskbar->bar_name.state_pix[k] = 0; } tskbar->area.pix = 0; + tskbar->bar_name.area.pix = 0; l0 = tskbar->area.list; if (taskbarname_enabled) l0 = l0->next; for (; l0 ; l0 = l0->next) { diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index f05f067..640bda8 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -342,6 +342,10 @@ void set_taskbar_state(Taskbar *tskbar, int state) { tskbar->area.bg = panel1[0].g_taskbar.background[state]; tskbar->area.pix = tskbar->state_pix[state]; + if (taskbarname_enabled) { + tskbar->bar_name.area.bg = panel1[0].g_taskbar.background_name[state]; + tskbar->bar_name.area.pix = tskbar->bar_name.state_pix[state]; + } if (panel_mode != MULTI_DESKTOP) { if (state == TASKBAR_NORMAL) tskbar->area.on_screen = 0; @@ -351,6 +355,8 @@ void set_taskbar_state(Taskbar *tskbar, int state) if (tskbar->area.on_screen == 1) { if (tskbar->state_pix[state] == 0) tskbar->area.redraw = 1; + if (taskbarname_enabled && tskbar->bar_name.state_pix[state] == 0) + tskbar->bar_name.area.redraw = 1; if (panel_mode == MULTI_DESKTOP && panel1[0].g_taskbar.background[TASKBAR_NORMAL] != panel1[0].g_taskbar.background[TASKBAR_ACTIVE]) { GSList *l = tskbar->area.list; if (taskbarname_enabled) l = l->next; diff --git a/src/taskbar/taskbarname.c b/src/taskbar/taskbarname.c index d1eb34e..ce4d294 100644 --- a/src/taskbar/taskbarname.c +++ b/src/taskbar/taskbarname.c @@ -35,6 +35,7 @@ int taskbarname_enabled; PangoFontDescription *taskbarname_font_desc; Color taskbarname_font; +Color taskbarname_active_font; void default_taskbarname() @@ -92,30 +93,34 @@ 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; + taskbar_name->state_pix[state] = taskbar_name->area.pix; + + // draw content layout = pango_cairo_create_layout (c); - - // draw layout pango_layout_set_font_description (layout, 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_text (layout, taskbar_name->name, strlen(taskbar_name->name)); - cairo_set_source_rgba (c, taskbarname_font.color[0], taskbarname_font.color[1], taskbarname_font.color[2], taskbarname_font.alpha); + cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha); pango_cairo_update_layout (c, layout); cairo_move_to (c, 0, taskbar_name->posy); pango_cairo_show_layout (c, layout); g_object_unref (layout); - printf("draw_taskbarname %s ******************************\n", taskbar_name->name); + //printf("draw_taskbarname %s ******************************\n", taskbar_name->name); } int resize_taskbarname(void *obj) { - Taskbarname *taskbar_name = (Taskbar*)obj; + Taskbarname *taskbar_name = obj; Panel *panel = taskbar_name->area.panel; int name_height, name_width, name_height_ink; int ret = 0; diff --git a/src/taskbar/taskbarname.h b/src/taskbar/taskbarname.h index 5fbbcbb..12f85f2 100644 --- a/src/taskbar/taskbarname.h +++ b/src/taskbar/taskbarname.h @@ -11,6 +11,7 @@ extern int taskbarname_enabled; extern PangoFontDescription *taskbarname_font_desc; extern Color taskbarname_font; +extern Color taskbarname_active_font; void default_taskbarname(); void cleanup_taskbarname(); -- 2.45.2