Invalidate cached pixmaps on resize/move (issue #576)

This commit is contained in:
o9000 2016-04-22 23:47:28 +02:00
parent a6879ea2a5
commit 9d8350dabc

View file

@ -70,17 +70,15 @@ void relayout_fixed(Area *a)
relayout_fixed(l->data); relayout_fixed(l->data);
// Recalculate size // Recalculate size
a->_changed = 0; a->_changed = FALSE;
if (a->resize_needed && a->size_mode == LAYOUT_FIXED) { if (a->resize_needed && a->size_mode == LAYOUT_FIXED) {
a->resize_needed = 0; a->resize_needed = FALSE;
if (a->_resize) { if (a->_resize && a->_resize(a)) {
if (a->_resize(a)) { // The size has changed => resize needed for the parent
// The size hash changed => resize needed for the parent if (a->parent)
if (a->parent) ((Area *)a->parent)->resize_needed = TRUE;
((Area *)a->parent)->resize_needed = 1; a->_changed = TRUE;
a->_changed = 1;
}
} }
} }
} }
@ -92,10 +90,11 @@ void relayout_dynamic(Area *a, int level)
// Area is resized before its children // Area is resized before its children
if (a->resize_needed && a->size_mode == LAYOUT_DYNAMIC) { if (a->resize_needed && a->size_mode == LAYOUT_DYNAMIC) {
a->resize_needed = 0; a->resize_needed = FALSE;
if (a->_resize) { if (a->_resize) {
a->_resize(a); if (a->_resize(a))
a->_changed = TRUE;
// resize children with LAYOUT_DYNAMIC // resize children with LAYOUT_DYNAMIC
for (GList *l = a->children; l; l = l->next) { for (GList *l = a->children; l; l = l->next) {
Area *child = ((Area *)l->data); Area *child = ((Area *)l->data);
@ -119,13 +118,13 @@ void relayout_dynamic(Area *a, int level)
if (pos != child->posx) { if (pos != child->posx) {
// pos changed => redraw // pos changed => redraw
child->posx = pos; child->posx = pos;
child->_changed = 1; child->_changed = TRUE;
} }
} else { } else {
if (pos != child->posy) { if (pos != child->posy) {
// pos changed => redraw // pos changed => redraw
child->posy = pos; child->posy = pos;
child->_changed = 1; child->_changed = TRUE;
} }
} }
@ -148,13 +147,13 @@ void relayout_dynamic(Area *a, int level)
if (pos != child->posx) { if (pos != child->posx) {
// pos changed => redraw // pos changed => redraw
child->posx = pos; child->posx = pos;
child->_changed = 1; child->_changed = TRUE;
} }
} else { } else {
if (pos != child->posy) { if (pos != child->posy) {
// pos changed => redraw // pos changed => redraw
child->posy = pos; child->posy = pos;
child->_changed = 1; child->_changed = TRUE;
} }
} }
@ -187,13 +186,13 @@ void relayout_dynamic(Area *a, int level)
if (pos != child->posx) { if (pos != child->posx) {
// pos changed => redraw // pos changed => redraw
child->posx = pos; child->posx = pos;
child->_changed = 1; child->_changed = TRUE;
} }
} else { } else {
if (pos != child->posy) { if (pos != child->posy) {
// pos changed => redraw // pos changed => redraw
child->posy = pos; child->posy = pos;
child->_changed = 1; child->_changed = TRUE;
} }
} }
@ -224,7 +223,7 @@ void draw_tree(Area *a)
return; return;
if (a->_redraw_needed) { if (a->_redraw_needed) {
a->_redraw_needed = 0; a->_redraw_needed = FALSE;
draw(a); draw(a);
} }
@ -286,7 +285,7 @@ int relayout_with_constraint(Area *a, int maximum_size)
modulo--; modulo--;
} }
if (child->width != old_width) if (child->width != old_width)
child->_changed = 1; child->_changed = TRUE;
} }
} }
} else { } else {
@ -326,7 +325,7 @@ int relayout_with_constraint(Area *a, int maximum_size)
modulo--; modulo--;
} }
if (child->height != old_height) if (child->height != old_height)
child->_changed = 1; child->_changed = TRUE;
} }
} }
} }
@ -361,7 +360,7 @@ void hide(Area *a)
a->on_screen = FALSE; a->on_screen = FALSE;
if (parent) if (parent)
parent->resize_needed = 1; parent->resize_needed = TRUE;
if (panel_horizontal) if (panel_horizontal)
a->width = 0; a->width = 0;
else else
@ -374,12 +373,27 @@ void show(Area *a)
a->on_screen = TRUE; a->on_screen = TRUE;
if (parent) if (parent)
parent->resize_needed = 1; parent->resize_needed = TRUE;
a->resize_needed = 1; a->resize_needed = TRUE;
} }
void draw(Area *a) void draw(Area *a)
{ {
if (a->_changed) {
// On resize/move, invalidate cached pixmaps
for (int i = 0; i < MOUSE_STATE_COUNT; i++) {
XFreePixmap(server.display, a->pix_by_state[i]);
if (a->pix == a->pix_by_state[i]) {
a->pix = None;
}
a->pix_by_state[i] = None;
}
if (a->pix) {
XFreePixmap(server.display, a->pix);
a->pix = None;
}
}
if (a->pix) { if (a->pix) {
XFreePixmap(server.display, a->pix); XFreePixmap(server.display, a->pix);
if (a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0] != a->pix) if (a->pix_by_state[a->has_mouse_over_effect ? a->mouse_state : 0] != a->pix)