else if (strcmp (key, "taskbar_background_id") == 0) {
int id = atoi (value);
id = (id < backgrounds->len && id >= 0) ? id : 0;
- panel_config.g_taskbar.bg = &g_array_index(backgrounds, Background, id);
- if (panel_config.g_taskbar.bg_active == 0)
- panel_config.g_taskbar.bg_active = panel_config.g_taskbar.bg;
- panel_config.g_taskbar.area.bg = panel_config.g_taskbar.bg;
+ panel_config.g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id);
+ if (panel_config.g_taskbar.background[TASKBAR_ACTIVE] == 0)
+ panel_config.g_taskbar.background[TASKBAR_ACTIVE] = panel_config.g_taskbar.background[TASKBAR_NORMAL];
+ //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 < backgrounds->len && id >= 0) ? id : 0;
- panel_config.g_taskbar.bg_active = &g_array_index(backgrounds, Background, id);
+ panel_config.g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id);
}
else if (strcmp (key, "taskbar_name") == 0) {
taskbarname_enabled = atoi (value);
set_redraw(a);
}
- // reset task 'state_pix'
- int i;
+ // reset task/taskbar 'state_pix'
+ int i, k;
Taskbar *tskbar;
for (i=0 ; i < p->nb_desktop ; i++) {
tskbar = &p->taskbar[i];
+ for (k=0; k<TASKBAR_STATE_COUNT; ++k) {
+ if (tskbar->state_pix[k]) XFreePixmap(server.dsp, tskbar->state_pix[k]);
+ tskbar->state_pix[k] = 0;
+ }
+ tskbar->area.pix = 0;
for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
set_task_redraw((Task *)l0->data);
}
Panel *panel =(Panel*)p;
int j;
- if (panel->g_taskbar.bg == 0) {
- panel->g_taskbar.bg = &g_array_index(backgrounds, Background, 0);
- panel->g_taskbar.area.bg = panel->g_taskbar.bg;
+ if (panel->g_taskbar.background[TASKBAR_NORMAL] == 0) {
+ panel->g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0);
+ panel->g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0);
}
- if (panel->g_taskbar.bg_active == 0)
- panel->g_taskbar.bg_active = panel->g_taskbar.bg;
if (panel->g_task.area.bg == 0)
panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0);
// taskbar
panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT;
panel->g_taskbar.area._resize = resize_taskbar;
+ panel->g_taskbar.area._draw_foreground = draw_taskbar;
panel->g_taskbar.area.redraw = 1;
panel->g_taskbar.area.on_screen = 1;
if (panel_horizontal) {
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.area.posy + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
+ panel->g_task.area.posy = panel->g_taskbar.area.posy + panel->g_taskbar.background[TASKBAR_NORMAL]->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.area.posx + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
+ panel->g_task.area.posx = panel->g_taskbar.area.posx + panel->g_taskbar.background[TASKBAR_NORMAL]->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;
}
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
tskbar->desktop = j;
if (j == server.desktop)
- tskbar->area.bg = panel->g_taskbar.bg_active;
+ tskbar->area.bg = panel->g_taskbar.background[TASKBAR_ACTIVE];
+ else
+ tskbar->area.bg = panel->g_taskbar.background[TASKBAR_NORMAL];
}
}
}
+void draw_taskbar (void *obj, cairo_t *c)
+{
+ Taskbar *taskbar = obj;
+ int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL;
+
+ taskbar->state_pix[state] = taskbar->area.pix;
+}
+
+
int resize_taskbar(void *obj)
{
Taskbar *taskbar = (Taskbar*)obj;
}
+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 (tskbar->state_pix[state] == 0) {
+ tskbar->area.redraw = 1;
+ GSList *l;
+ for (l = tskbar->area.list ; l ; l = l->next)
+ ((Area*)l->data)->redraw = 1;
+ }
+ panel_refresh = 1;
+}
+
+
void visible_taskbar(void *p)
{
Panel *panel =(Panel*)p;
#include "task.h"
+enum { TASKBAR_NORMAL, TASKBAR_ACTIVE, TASKBAR_STATE_COUNT };
extern GHashTable* win_to_task_table;
extern Task *task_active;
extern Task *task_drag;
Area area;
int desktop;
+ int current_state;
+ Pixmap state_pix[TASKBAR_STATE_COUNT];
// task parameters
int text_width;
typedef struct {
//always start with area
Area area;
- Background* bg;
- Background* bg_active;
+ Background* background[TASKBAR_STATE_COUNT];
+ //Background* bg;
+ //Background* bg_active;
} Global_taskbar;
void init_taskbar();
void init_taskbar_panel(void *p);
+void draw_taskbar (void *obj, cairo_t *c);
void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data);
Task *task_get_task (Window win);
GPtrArray* task_get_tasks(Window win);
void task_refresh_tasklist ();
int resize_taskbar(void *obj);
+void set_taskbar_state(Taskbar *tskbar, int state);
// show/hide taskbar according to current desktop
void visible_taskbar(void *p);
server.desktop = server_get_current_desktop ();
for (i=0 ; i < nb_panel ; i++) {
Panel *panel = &panel1[i];
- if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.bg != panel->g_taskbar.bg_active) {
- // 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.bg = panel->g_taskbar.bg;
- panel->taskbar[old_desktop].area.resize = 1;
- }
- panel->taskbar[server.desktop].area.bg = panel->g_taskbar.bg_active;
- panel->taskbar[server.desktop].area.resize = 1;
- panel_refresh = 1;
- }
+ set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL);
+ set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE);
// check ALLDESKTOP task => resize taskbar
Taskbar *tskbar;
Task *tsk;