Remove double pixmap caching, it is crazy (see issue #542)
This commit is contained in:
parent
dbf065ab12
commit
5450f89612
6 changed files with 6 additions and 80 deletions
12
src/panel.c
12
src/panel.c
|
@ -749,16 +749,8 @@ void set_panel_background(Panel *p)
|
||||||
Taskbar *taskbar;
|
Taskbar *taskbar;
|
||||||
for (int i = 0; i < p->num_desktops; i++) {
|
for (int i = 0; i < p->num_desktops; i++) {
|
||||||
taskbar = &p->taskbar[i];
|
taskbar = &p->taskbar[i];
|
||||||
for (int k = 0; k < TASKBAR_STATE_COUNT; ++k) {
|
schedule_redraw(&taskbar->area);
|
||||||
if (taskbar->state_pix[k])
|
schedule_redraw(&taskbar->bar_name.area);
|
||||||
XFreePixmap(server.display, taskbar->state_pix[k]);
|
|
||||||
taskbar->state_pix[k] = 0;
|
|
||||||
if (taskbar->bar_name.state_pix[k])
|
|
||||||
XFreePixmap(server.display, taskbar->bar_name.state_pix[k]);
|
|
||||||
taskbar->bar_name.state_pix[k] = 0;
|
|
||||||
}
|
|
||||||
taskbar->area.pix = 0;
|
|
||||||
taskbar->bar_name.area.pix = 0;
|
|
||||||
GList *l = taskbar->area.children;
|
GList *l = taskbar->area.children;
|
||||||
if (taskbarname_enabled)
|
if (taskbarname_enabled)
|
||||||
l = l->next;
|
l = l->next;
|
||||||
|
|
|
@ -80,7 +80,6 @@ Task *add_task(Window win)
|
||||||
task_template.title = NULL;
|
task_template.title = NULL;
|
||||||
for (int k = 0; k < TASK_STATE_COUNT; ++k) {
|
for (int k = 0; k < TASK_STATE_COUNT; ++k) {
|
||||||
task_template.icon[k] = NULL;
|
task_template.icon[k] = NULL;
|
||||||
task_template.state_pix[k] = 0;
|
|
||||||
}
|
}
|
||||||
get_title(&task_template);
|
get_title(&task_template);
|
||||||
get_icon(&task_template);
|
get_icon(&task_template);
|
||||||
|
@ -116,7 +115,6 @@ Task *add_task(Window win)
|
||||||
task_instance->icon[k] = task_template.icon[k];
|
task_instance->icon[k] = task_template.icon[k];
|
||||||
task_instance->icon_hover[k] = task_template.icon_hover[k];
|
task_instance->icon_hover[k] = task_template.icon_hover[k];
|
||||||
task_instance->icon_press[k] = task_template.icon_press[k];
|
task_instance->icon_press[k] = task_template.icon_press[k];
|
||||||
task_instance->state_pix[k] = 0;
|
|
||||||
}
|
}
|
||||||
task_instance->icon_width = task_template.icon_width;
|
task_instance->icon_width = task_template.icon_width;
|
||||||
task_instance->icon_height = task_template.icon_height;
|
task_instance->icon_height = task_template.icon_height;
|
||||||
|
@ -179,8 +177,6 @@ void remove_task(Task *task)
|
||||||
imlib_free_image();
|
imlib_free_image();
|
||||||
task->icon_press[k] = 0;
|
task->icon_press[k] = 0;
|
||||||
}
|
}
|
||||||
if (task->state_pix[k])
|
|
||||||
XFreePixmap(server.display, task->state_pix[k]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GPtrArray *task_group = g_hash_table_lookup(win_to_task, &win);
|
GPtrArray *task_group = g_hash_table_lookup(win_to_task, &win);
|
||||||
|
@ -406,9 +402,6 @@ void draw_task(void *obj, cairo_t *c)
|
||||||
Task *task = (Task *)obj;
|
Task *task = (Task *)obj;
|
||||||
Panel *panel = (Panel *)task->area.panel;
|
Panel *panel = (Panel *)task->area.panel;
|
||||||
|
|
||||||
if (!panel_config.mouse_effects)
|
|
||||||
task->state_pix[task->current_state] = task->area.pix;
|
|
||||||
|
|
||||||
int text_width = 0;
|
int text_width = 0;
|
||||||
if (panel->g_task.text) {
|
if (panel->g_task.text) {
|
||||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||||
|
@ -573,14 +566,7 @@ void set_task_state(Task *task, TaskState state)
|
||||||
Task *task1 = g_ptr_array_index(task_group, i);
|
Task *task1 = g_ptr_array_index(task_group, i);
|
||||||
task1->current_state = state;
|
task1->current_state = state;
|
||||||
task1->area.bg = panels[0].g_task.background[state];
|
task1->area.bg = panels[0].g_task.background[state];
|
||||||
if (!panel_config.mouse_effects) {
|
|
||||||
task1->area.pix = task1->state_pix[state];
|
|
||||||
if (!task1->area.pix)
|
|
||||||
schedule_redraw(&task1->area);
|
schedule_redraw(&task1->area);
|
||||||
panel_refresh = TRUE;
|
|
||||||
} else {
|
|
||||||
schedule_redraw(&task1->area);
|
|
||||||
}
|
|
||||||
if (state == TASK_ACTIVE && g_slist_find(urgent_list, task1))
|
if (state == TASK_ACTIVE && g_slist_find(urgent_list, task1))
|
||||||
del_urgent(task1);
|
del_urgent(task1);
|
||||||
gboolean hide = FALSE;
|
gboolean hide = FALSE;
|
||||||
|
@ -615,12 +601,6 @@ void set_task_state(Task *task, TaskState state)
|
||||||
|
|
||||||
void set_task_redraw(Task *task)
|
void set_task_redraw(Task *task)
|
||||||
{
|
{
|
||||||
for (int k = 0; k < TASK_STATE_COUNT; ++k) {
|
|
||||||
if (task->state_pix[k])
|
|
||||||
XFreePixmap(server.display, task->state_pix[k]);
|
|
||||||
task->state_pix[k] = 0;
|
|
||||||
}
|
|
||||||
task->area.pix = 0;
|
|
||||||
schedule_redraw(&task->area);
|
schedule_redraw(&task->area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ typedef struct Task {
|
||||||
Imlib_Image icon[TASK_STATE_COUNT];
|
Imlib_Image icon[TASK_STATE_COUNT];
|
||||||
Imlib_Image icon_hover[TASK_STATE_COUNT];
|
Imlib_Image icon_hover[TASK_STATE_COUNT];
|
||||||
Imlib_Image icon_press[TASK_STATE_COUNT];
|
Imlib_Image icon_press[TASK_STATE_COUNT];
|
||||||
Pixmap state_pix[TASK_STATE_COUNT];
|
|
||||||
unsigned int icon_width;
|
unsigned int icon_width;
|
||||||
unsigned int icon_height;
|
unsigned int icon_height;
|
||||||
char *title;
|
char *title;
|
||||||
|
|
|
@ -99,11 +99,6 @@ void cleanup_taskbar()
|
||||||
Panel *panel = &panels[i];
|
Panel *panel = &panels[i];
|
||||||
for (int j = 0; j < panel->num_desktops; j++) {
|
for (int j = 0; j < panel->num_desktops; j++) {
|
||||||
Taskbar *taskbar = &panel->taskbar[j];
|
Taskbar *taskbar = &panel->taskbar[j];
|
||||||
for (int k = 0; k < TASKBAR_STATE_COUNT; ++k) {
|
|
||||||
if (taskbar->state_pix[k])
|
|
||||||
XFreePixmap(server.display, taskbar->state_pix[k]);
|
|
||||||
taskbar->state_pix[k] = 0;
|
|
||||||
}
|
|
||||||
free_area(&taskbar->area);
|
free_area(&taskbar->area);
|
||||||
// remove taskbar from the panel
|
// remove taskbar from the panel
|
||||||
remove_area((Area *)taskbar);
|
remove_area((Area *)taskbar);
|
||||||
|
@ -164,7 +159,6 @@ void init_taskbar_panel(void *p)
|
||||||
panel->g_taskbar.area.size_mode = LAYOUT_DYNAMIC;
|
panel->g_taskbar.area.size_mode = LAYOUT_DYNAMIC;
|
||||||
panel->g_taskbar.area.alignment = taskbar_alignment;
|
panel->g_taskbar.area.alignment = taskbar_alignment;
|
||||||
panel->g_taskbar.area._resize = resize_taskbar;
|
panel->g_taskbar.area._resize = resize_taskbar;
|
||||||
panel->g_taskbar.area._draw_foreground = draw_taskbar;
|
|
||||||
panel->g_taskbar.area._on_change_layout = on_change_taskbar;
|
panel->g_taskbar.area._on_change_layout = on_change_taskbar;
|
||||||
panel->g_taskbar.area.resize_needed = 1;
|
panel->g_taskbar.area.resize_needed = 1;
|
||||||
panel->g_taskbar.area.on_screen = TRUE;
|
panel->g_taskbar.area.on_screen = TRUE;
|
||||||
|
@ -380,14 +374,6 @@ void task_refresh_tasklist()
|
||||||
XFree(win);
|
XFree(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_taskbar(void *obj, cairo_t *c)
|
|
||||||
{
|
|
||||||
Taskbar *taskbar = (Taskbar *)obj;
|
|
||||||
int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL;
|
|
||||||
|
|
||||||
taskbar->state_pix[state] = taskbar->area.pix;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean resize_taskbar(void *obj)
|
gboolean resize_taskbar(void *obj)
|
||||||
{
|
{
|
||||||
Taskbar *taskbar = (Taskbar *)obj;
|
Taskbar *taskbar = (Taskbar *)obj;
|
||||||
|
@ -421,26 +407,14 @@ gboolean resize_taskbar(void *obj)
|
||||||
void on_change_taskbar(void *obj)
|
void on_change_taskbar(void *obj)
|
||||||
{
|
{
|
||||||
Taskbar *taskbar = (Taskbar *)obj;
|
Taskbar *taskbar = (Taskbar *)obj;
|
||||||
|
|
||||||
// reset Pixmap when position/size changed
|
|
||||||
for (int k = 0; k < TASKBAR_STATE_COUNT; ++k) {
|
|
||||||
if (taskbar->state_pix[k])
|
|
||||||
XFreePixmap(server.display, taskbar->state_pix[k]);
|
|
||||||
taskbar->state_pix[k] = 0;
|
|
||||||
}
|
|
||||||
taskbar->area.pix = 0;
|
|
||||||
schedule_redraw(&taskbar->area);
|
schedule_redraw(&taskbar->area);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
|
void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
|
||||||
{
|
{
|
||||||
taskbar->area.bg = panels[0].g_taskbar.background[state];
|
taskbar->area.bg = panels[0].g_taskbar.background[state];
|
||||||
taskbar->area.pix = taskbar->state_pix[state];
|
|
||||||
if (taskbarname_enabled) {
|
if (taskbarname_enabled) {
|
||||||
taskbar->bar_name.area.bg = panels[0].g_taskbar.background_name[state];
|
taskbar->bar_name.area.bg = panels[0].g_taskbar.background_name[state];
|
||||||
if (!panel_config.mouse_effects) {
|
|
||||||
taskbar->bar_name.area.pix = taskbar->bar_name.state_pix[state];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (taskbar_mode != MULTI_DESKTOP) {
|
if (taskbar_mode != MULTI_DESKTOP) {
|
||||||
if (state == TASKBAR_NORMAL)
|
if (state == TASKBAR_NORMAL)
|
||||||
|
@ -449,15 +423,9 @@ void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
|
||||||
taskbar->area.on_screen = TRUE;
|
taskbar->area.on_screen = TRUE;
|
||||||
}
|
}
|
||||||
if (taskbar->area.on_screen) {
|
if (taskbar->area.on_screen) {
|
||||||
if (!taskbar->state_pix[state])
|
|
||||||
schedule_redraw(&taskbar->area);
|
schedule_redraw(&taskbar->area);
|
||||||
if (taskbarname_enabled) {
|
if (taskbarname_enabled) {
|
||||||
if (!panel_config.mouse_effects) {
|
|
||||||
if (!taskbar->bar_name.state_pix[state])
|
|
||||||
schedule_redraw(&taskbar->bar_name.area);
|
schedule_redraw(&taskbar->bar_name.area);
|
||||||
} else {
|
|
||||||
schedule_redraw(&taskbar->bar_name.area);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (taskbar_mode == MULTI_DESKTOP &&
|
if (taskbar_mode == MULTI_DESKTOP &&
|
||||||
panels[0].g_taskbar.background[TASKBAR_NORMAL] != panels[0].g_taskbar.background[TASKBAR_ACTIVE]) {
|
panels[0].g_taskbar.background[TASKBAR_NORMAL] != panels[0].g_taskbar.background[TASKBAR_ACTIVE]) {
|
||||||
|
|
|
@ -37,15 +37,12 @@ extern Alignment taskbar_alignment;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Area area;
|
Area area;
|
||||||
Pixmap state_pix[TASKBAR_STATE_COUNT];
|
|
||||||
|
|
||||||
gchar *name;
|
gchar *name;
|
||||||
int posy;
|
int posy;
|
||||||
} Taskbarname;
|
} Taskbarname;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Area area;
|
Area area;
|
||||||
Pixmap state_pix[TASKBAR_STATE_COUNT];
|
|
||||||
int desktop;
|
int desktop;
|
||||||
Taskbarname bar_name;
|
Taskbarname bar_name;
|
||||||
int text_width;
|
int text_width;
|
||||||
|
@ -68,7 +65,6 @@ void cleanup_taskbar();
|
||||||
void init_taskbar();
|
void init_taskbar();
|
||||||
void init_taskbar_panel(void *p);
|
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);
|
void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data);
|
||||||
Task *task_get_task(Window win);
|
Task *task_get_task(Window win);
|
||||||
GPtrArray *task_get_tasks(Window win);
|
GPtrArray *task_get_tasks(Window win);
|
||||||
|
|
|
@ -114,7 +114,7 @@ void taskbarname_default_font_changed()
|
||||||
|
|
||||||
void cleanup_taskbarname()
|
void cleanup_taskbarname()
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j;
|
||||||
Panel *panel;
|
Panel *panel;
|
||||||
Taskbar *taskbar;
|
Taskbar *taskbar;
|
||||||
|
|
||||||
|
@ -125,11 +125,6 @@ void cleanup_taskbarname()
|
||||||
g_free(taskbar->bar_name.name);
|
g_free(taskbar->bar_name.name);
|
||||||
taskbar->bar_name.name = NULL;
|
taskbar->bar_name.name = NULL;
|
||||||
free_area(&taskbar->bar_name.area);
|
free_area(&taskbar->bar_name.area);
|
||||||
for (k = 0; k < TASKBAR_STATE_COUNT; ++k) {
|
|
||||||
if (taskbar->bar_name.state_pix[k])
|
|
||||||
XFreePixmap(server.display, taskbar->bar_name.state_pix[k]);
|
|
||||||
taskbar->bar_name.state_pix[k] = 0;
|
|
||||||
}
|
|
||||||
remove_area((Area *)&taskbar->bar_name);
|
remove_area((Area *)&taskbar->bar_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,10 +175,6 @@ void draw_taskbarname(void *obj, cairo_t *c)
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font;
|
Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font;
|
||||||
|
|
||||||
int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL;
|
|
||||||
if (!panel_config.mouse_effects)
|
|
||||||
taskbar_name->state_pix[state] = taskbar_name->area.pix;
|
|
||||||
|
|
||||||
// draw content
|
// draw content
|
||||||
layout = pango_cairo_create_layout(c);
|
layout = pango_cairo_create_layout(c);
|
||||||
pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc);
|
pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc);
|
||||||
|
|
Loading…
Reference in a new issue