memorized taskbar pixmap. So we don t redraw taskbar/task when switching desktop.

git-svn-id: http://tint2.googlecode.com/svn/trunk@577 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
thilor77 2010-10-23 11:16:29 +00:00
parent ad716c907a
commit c01b7f480e
5 changed files with 54 additions and 28 deletions

View file

@ -454,15 +454,15 @@ void add_entry (char *key, char *value)
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);

View file

@ -530,11 +530,16 @@ void set_panel_background(Panel *p)
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);
}

View file

@ -99,18 +99,17 @@ void init_taskbar_panel(void *p)
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) {
@ -158,11 +157,11 @@ void init_taskbar_panel(void *p)
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;
}
@ -200,7 +199,9 @@ void init_taskbar_panel(void *p)
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];
}
}
@ -259,6 +260,15 @@ void task_refresh_tasklist ()
}
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;
@ -286,6 +296,20 @@ int resize_taskbar(void *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;

View file

@ -10,6 +10,7 @@
#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;
@ -21,6 +22,8 @@ typedef struct {
Area area;
int desktop;
int current_state;
Pixmap state_pix[TASKBAR_STATE_COUNT];
// task parameters
int text_width;
@ -30,8 +33,9 @@ typedef struct {
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;
@ -44,12 +48,14 @@ void cleanup_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);

View file

@ -513,17 +513,8 @@ void event_property_notify (XEvent *e)
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;