Area: refactor list -> children
This commit is contained in:
parent
f2922d7dbd
commit
57c35549f3
8 changed files with 62 additions and 62 deletions
|
@ -50,7 +50,7 @@ int freespace_get_max_size(Panel *p) {
|
|||
// Get space used by every element except the freespace
|
||||
GList *walk;
|
||||
int size = 0;
|
||||
for (walk = p->area.list; walk; walk = g_list_next(walk)) {
|
||||
for (walk = p->area.children; walk; walk = g_list_next(walk)) {
|
||||
Area *a = (Area *)walk->data;
|
||||
|
||||
if (a->_resize == resize_freespace || !a->on_screen)
|
||||
|
|
38
src/panel.c
38
src/panel.c
|
@ -361,16 +361,16 @@ int resize_panel(void *obj)
|
|||
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
GList *l;
|
||||
for (l = taskbar->area.list; l; l = l->next) {
|
||||
for (l = taskbar->area.children; l; l = l->next) {
|
||||
Area *child = l->data;
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
total_items++;
|
||||
}
|
||||
if (taskbarname_enabled) {
|
||||
if (taskbar->area.list) {
|
||||
if (taskbar->area.children) {
|
||||
total_items--;
|
||||
Area *name = taskbar->area.list->data;
|
||||
Area *name = taskbar->area.children->data;
|
||||
if (panel_horizontal) {
|
||||
total_name_size += name->width;
|
||||
} else {
|
||||
|
@ -395,7 +395,7 @@ int resize_panel(void *obj)
|
|||
|
||||
int requested_size = (2 * taskbar->area.bg->border.width) + (2 * taskbar->area.paddingxlr);
|
||||
int items = 0;
|
||||
GList *l = taskbar->area.list;
|
||||
GList *l = taskbar->area.children;
|
||||
if (taskbarname_enabled)
|
||||
l = l->next;
|
||||
for (; l; l = l->next) {
|
||||
|
@ -489,32 +489,32 @@ void set_panel_items_order(Panel *p)
|
|||
{
|
||||
int k, j;
|
||||
|
||||
if (p->area.list) {
|
||||
g_list_free(p->area.list);
|
||||
p->area.list = 0;
|
||||
if (p->area.children) {
|
||||
g_list_free(p->area.children);
|
||||
p->area.children = 0;
|
||||
}
|
||||
|
||||
for (k=0 ; k < strlen(panel_items_order) ; k++) {
|
||||
if (panel_items_order[k] == 'L') {
|
||||
p->area.list = g_list_append(p->area.list, &p->launcher);
|
||||
p->area.children = g_list_append(p->area.children, &p->launcher);
|
||||
p->launcher.area.resize = 1;
|
||||
}
|
||||
if (panel_items_order[k] == 'T') {
|
||||
for (j=0 ; j < p->nb_desktop ; j++)
|
||||
p->area.list = g_list_append(p->area.list, &p->taskbar[j]);
|
||||
p->area.children = g_list_append(p->area.children, &p->taskbar[j]);
|
||||
}
|
||||
#ifdef ENABLE_BATTERY
|
||||
if (panel_items_order[k] == 'B')
|
||||
p->area.list = g_list_append(p->area.list, &p->battery);
|
||||
p->area.children = g_list_append(p->area.children, &p->battery);
|
||||
#endif
|
||||
int i = p - panel1;
|
||||
if (panel_items_order[k] == 'S' && systray_on_monitor(i, nb_panel)) {
|
||||
p->area.list = g_list_append(p->area.list, &systray);
|
||||
p->area.children = g_list_append(p->area.children, &systray);
|
||||
}
|
||||
if (panel_items_order[k] == 'C')
|
||||
p->area.list = g_list_append(p->area.list, &p->clock);
|
||||
p->area.children = g_list_append(p->area.children, &p->clock);
|
||||
if (panel_items_order[k] == 'F')
|
||||
p->area.list = g_list_append(p->area.list, &p->freespace);
|
||||
p->area.children = g_list_append(p->area.children, &p->freespace);
|
||||
}
|
||||
init_rendering(&p->area, 0);
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ void set_panel_background(Panel *p)
|
|||
// redraw panel's object
|
||||
GList *l0;
|
||||
Area *a;
|
||||
for (l0 = p->area.list; l0 ; l0 = l0->next) {
|
||||
for (l0 = p->area.children; l0 ; l0 = l0->next) {
|
||||
a = l0->data;
|
||||
set_redraw(a);
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ void set_panel_background(Panel *p)
|
|||
}
|
||||
tskbar->area.pix = 0;
|
||||
tskbar->bar_name.area.pix = 0;
|
||||
l0 = tskbar->area.list;
|
||||
l0 = tskbar->area.children;
|
||||
if (taskbarname_enabled) l0 = l0->next;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
set_task_redraw((Task *)l0->data);
|
||||
|
@ -711,7 +711,7 @@ Task *click_task (Panel *panel, int x, int y)
|
|||
if ( (tskbar = click_taskbar(panel, x, y)) ) {
|
||||
if (panel_horizontal) {
|
||||
Task *tsk;
|
||||
l0 = tskbar->area.list;
|
||||
l0 = tskbar->area.children;
|
||||
if (taskbarname_enabled) l0 = l0->next;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
tsk = l0->data;
|
||||
|
@ -722,7 +722,7 @@ Task *click_task (Panel *panel, int x, int y)
|
|||
}
|
||||
else {
|
||||
Task *tsk;
|
||||
l0 = tskbar->area.list;
|
||||
l0 = tskbar->area.children;
|
||||
if (taskbarname_enabled) l0 = l0->next;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
tsk = l0->data;
|
||||
|
@ -823,9 +823,9 @@ Area* click_area(Panel *panel, int x, int y)
|
|||
Area* new_result = result;
|
||||
do {
|
||||
result = new_result;
|
||||
GList* it = result->list;
|
||||
GList* it = result->children;
|
||||
while (it) {
|
||||
Area* a = it->data;
|
||||
Area* a = (Area*)it->data;
|
||||
if (a->on_screen && x >= a->posx && x <= (a->posx + a->width)
|
||||
&& y >= a->posy && y <= (a->posy + a->height)) {
|
||||
new_result = a;
|
||||
|
|
|
@ -113,7 +113,7 @@ Task *add_task (Window win)
|
|||
}
|
||||
new_tsk2->icon_width = new_tsk.icon_width;
|
||||
new_tsk2->icon_height = new_tsk.icon_height;
|
||||
tskbar->area.list = g_list_append(tskbar->area.list, new_tsk2);
|
||||
tskbar->area.children = g_list_append(tskbar->area.children, new_tsk2);
|
||||
tskbar->area.resize = 1;
|
||||
g_ptr_array_add(task_group, new_tsk2);
|
||||
//printf("add_task panel %d, desktop %d, task %s\n", i, j, new_tsk2->title);
|
||||
|
@ -419,7 +419,7 @@ Task *find_active_task(Task *current_task, Task *active_task)
|
|||
|
||||
Taskbar* tskbar = current_task->area.parent;
|
||||
|
||||
GList *l0 = tskbar->area.list;
|
||||
GList *l0 = tskbar->area.children;
|
||||
if (taskbarname_enabled)
|
||||
l0 = l0->next;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
|
@ -438,7 +438,7 @@ Task *next_task(Task *tsk)
|
|||
|
||||
Taskbar* tskbar = tsk->area.parent;
|
||||
|
||||
GList *l0 = tskbar->area.list;
|
||||
GList *l0 = tskbar->area.children;
|
||||
if (taskbarname_enabled) l0 = l0->next;
|
||||
GList *lfirst_tsk = l0;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
|
@ -462,7 +462,7 @@ Task *prev_task(Task *tsk)
|
|||
Taskbar* tskbar = tsk->area.parent;
|
||||
|
||||
tsk2 = 0;
|
||||
GList *l0 = tskbar->area.list;
|
||||
GList *l0 = tskbar->area.children;
|
||||
if (taskbarname_enabled) l0 = l0->next;
|
||||
GList *lfirst_tsk = l0;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
|
|
|
@ -337,7 +337,7 @@ int resize_taskbar(void *obj)
|
|||
resize_by_layout(obj, panel->g_task.maximum_width);
|
||||
|
||||
text_width = panel->g_task.maximum_width;
|
||||
GList *l = taskbar->area.list;
|
||||
GList *l = taskbar->area.children;
|
||||
if (taskbarname_enabled) l = l->next;
|
||||
for (; l != NULL; l = l->next) {
|
||||
if (((Task *)l->data)->area.on_screen) {
|
||||
|
@ -391,7 +391,7 @@ void set_taskbar_state(Taskbar *tskbar, int state)
|
|||
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]) {
|
||||
GList *l = tskbar->area.list;
|
||||
GList *l = tskbar->area.children;
|
||||
if (taskbarname_enabled) l = l->next;
|
||||
for ( ; l ; l = l->next)
|
||||
set_task_redraw(l->data);
|
||||
|
@ -426,9 +426,9 @@ gint compare_tasks_trivial(Task *a, Task *b, Taskbar *taskbar)
|
|||
if (a == b)
|
||||
return 0;
|
||||
if (taskbarname_enabled) {
|
||||
if (a == taskbar->area.list->data)
|
||||
if (a == taskbar->area.children->data)
|
||||
return -1;
|
||||
if (b == taskbar->area.list->data)
|
||||
if (b == taskbar->area.children->data)
|
||||
return 1;
|
||||
}
|
||||
return NONTRIVIAL;
|
||||
|
@ -515,7 +515,7 @@ int taskbar_needs_sort(Taskbar *taskbar)
|
|||
return 0;
|
||||
|
||||
GList *i, *j;
|
||||
for (i = taskbar->area.list, j = i ? i->next : NULL; i && j; i = i->next, j = j->next) {
|
||||
for (i = taskbar->area.children, j = i ? i->next : NULL; i && j; i = i->next, j = j->next) {
|
||||
if (compare_tasks(i->data, j->data, taskbar) > 0) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ void sort_tasks(Taskbar *taskbar)
|
|||
if (!taskbar_needs_sort(taskbar)) {
|
||||
return;
|
||||
}
|
||||
taskbar->area.list = g_list_sort_with_data(taskbar->area.list, (GCompareDataFunc)compare_tasks, taskbar);
|
||||
taskbar->area.children = g_list_sort_with_data(taskbar->area.children, (GCompareDataFunc)compare_tasks, taskbar);
|
||||
taskbar->area.resize = 1;
|
||||
panel_refresh = 1;
|
||||
((Panel*)taskbar->area.panel)->area.resize = 1;
|
||||
|
|
|
@ -77,7 +77,7 @@ void init_taskbarname_panel(void *p)
|
|||
tskbar->bar_name.name = g_strdup_printf("%d", j+1);
|
||||
|
||||
// append the name at the beginning of taskbar
|
||||
tskbar->area.list = g_list_append(tskbar->area.list, &tskbar->bar_name);
|
||||
tskbar->area.children = g_list_append(tskbar->area.children, &tskbar->bar_name);
|
||||
}
|
||||
|
||||
for (l=list ; l ; l = l->next)
|
||||
|
|
12
src/tint.c
12
src/tint.c
|
@ -539,8 +539,8 @@ void event_button_motion_notify (XEvent *e)
|
|||
} else {
|
||||
// Swap the task_drag with the task on the event's location (if they differ)
|
||||
if (event_task && event_task != task_drag) {
|
||||
GList * drag_iter = g_list_find(event_taskbar->area.list, task_drag);
|
||||
GList * task_iter = g_list_find(event_taskbar->area.list, event_task);
|
||||
GList * drag_iter = g_list_find(event_taskbar->area.children, task_drag);
|
||||
GList * task_iter = g_list_find(event_taskbar->area.children, event_task);
|
||||
if (drag_iter && task_iter) {
|
||||
gpointer temp = task_iter->data;
|
||||
task_iter->data = drag_iter->data;
|
||||
|
@ -561,10 +561,10 @@ void event_button_motion_notify (XEvent *e)
|
|||
|
||||
if (event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) {
|
||||
int i = (taskbarname_enabled) ? 1 : 0;
|
||||
event_taskbar->area.list = g_list_insert(event_taskbar->area.list, task_drag, i);
|
||||
event_taskbar->area.children = g_list_insert(event_taskbar->area.children, task_drag, i);
|
||||
}
|
||||
else
|
||||
event_taskbar->area.list = g_list_append(event_taskbar->area.list, task_drag);
|
||||
event_taskbar->area.children = g_list_append(event_taskbar->area.children, task_drag);
|
||||
|
||||
// Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify')
|
||||
task_drag->area.parent = event_taskbar;
|
||||
|
@ -758,7 +758,7 @@ void event_property_notify (XEvent *e)
|
|||
Task *tsk;
|
||||
if (server.nb_desktop > old_desktop) {
|
||||
tskbar = &panel->taskbar[old_desktop];
|
||||
GList *l = tskbar->area.list;
|
||||
GList *l = tskbar->area.children;
|
||||
if (taskbarname_enabled) l = l->next;
|
||||
for (; l ; l = l->next) {
|
||||
tsk = l->data;
|
||||
|
@ -772,7 +772,7 @@ void event_property_notify (XEvent *e)
|
|||
}
|
||||
}
|
||||
tskbar = &panel->taskbar[server.desktop];
|
||||
GList *l = tskbar->area.list;
|
||||
GList *l = tskbar->area.children;
|
||||
if (taskbarname_enabled) l = l->next;
|
||||
for (; l ; l = l->next) {
|
||||
tsk = l->data;
|
||||
|
|
|
@ -79,7 +79,7 @@ void init_rendering(void *obj, int pos)
|
|||
|
||||
// initialize fixed position/size
|
||||
GList *l;
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
for (l = a->children; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (panel_horizontal) {
|
||||
child->posy = pos + a->bg->border.width + a->paddingy;
|
||||
|
@ -118,7 +118,7 @@ void size_by_content (Area *a)
|
|||
|
||||
// children node are resized before its parent
|
||||
GList *l;
|
||||
for (l = a->list; l ; l = l->next)
|
||||
for (l = a->children; l ; l = l->next)
|
||||
size_by_content(l->data);
|
||||
|
||||
// calculate area's size
|
||||
|
@ -152,20 +152,20 @@ void size_by_layout (Area *a, int level)
|
|||
if (a->_resize) {
|
||||
a->_resize(a);
|
||||
// resize childs with SIZE_BY_LAYOUT
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
for (l = a->children; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (child->size_mode == SIZE_BY_LAYOUT && child->list)
|
||||
if (child->size_mode == SIZE_BY_LAYOUT && child->children)
|
||||
child->resize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update position of children
|
||||
if (a->list) {
|
||||
if (a->children) {
|
||||
if (a->alignment == ALIGN_LEFT) {
|
||||
int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr;
|
||||
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
for (l = a->children; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
@ -191,7 +191,7 @@ void size_by_layout (Area *a, int level)
|
|||
} else if (a->alignment == ALIGN_RIGHT) {
|
||||
int pos = (panel_horizontal ? a->posx + a->width : a->posy + a->height) - a->bg->border.width - a->paddingxlr;
|
||||
|
||||
for (l = g_list_last(a->list); l ; l = l->prev) {
|
||||
for (l = g_list_last(a->children); l ; l = l->prev) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
@ -220,19 +220,19 @@ void size_by_layout (Area *a, int level)
|
|||
|
||||
int children_size = 0;
|
||||
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
for (l = a->children; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
||||
children_size += panel_horizontal ? child->width : child->height;
|
||||
children_size += (l == a->list) ? 0 : a->paddingx;
|
||||
children_size += (l == a->children) ? 0 : a->paddingx;
|
||||
}
|
||||
|
||||
int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr;
|
||||
pos += ((panel_horizontal ? a->width : a->height) - children_size) / 2;
|
||||
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
for (l = a->children; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
@ -277,7 +277,7 @@ void refresh (Area *a)
|
|||
a->redraw = 0;
|
||||
// force redraw of child
|
||||
//GList *l;
|
||||
//for (l = a->list ; l ; l = l->next)
|
||||
//for (l = a->children ; l ; l = l->next)
|
||||
//((Area*)l->data)->redraw = 1;
|
||||
|
||||
//printf("draw area posx %d, width %d\n", a->posx, a->width);
|
||||
|
@ -290,8 +290,8 @@ void refresh (Area *a)
|
|||
|
||||
// and then refresh child object
|
||||
GList *l;
|
||||
for (l = a->list; l ; l = l->next)
|
||||
refresh(l->data);
|
||||
for (l = a->children; l ; l = l->next)
|
||||
refresh((Area*)l->data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -304,7 +304,7 @@ int resize_by_layout(void *obj, int maximum_size)
|
|||
// detect free size for SIZE_BY_LAYOUT's Area
|
||||
size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
|
||||
GList *l;
|
||||
for (l = a->list ; l ; l = l->next) {
|
||||
for (l = a->children ; l ; l = l->next) {
|
||||
child = (Area*)l->data;
|
||||
if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
|
||||
size -= child->width;
|
||||
|
@ -328,7 +328,7 @@ int resize_by_layout(void *obj, int maximum_size)
|
|||
}
|
||||
|
||||
// resize SIZE_BY_LAYOUT objects
|
||||
for (l = a->list ; l ; l = l->next) {
|
||||
for (l = a->children ; l ; l = l->next) {
|
||||
child = (Area*)l->data;
|
||||
if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) {
|
||||
old_width = child->width;
|
||||
|
@ -346,7 +346,7 @@ int resize_by_layout(void *obj, int maximum_size)
|
|||
// detect free size for SIZE_BY_LAYOUT's Area
|
||||
size = a->height - (2 * (a->paddingxlr + a->bg->border.width));
|
||||
GList *l;
|
||||
for (l = a->list ; l ; l = l->next) {
|
||||
for (l = a->children ; l ; l = l->next) {
|
||||
child = (Area*)l->data;
|
||||
if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
|
||||
size -= child->height;
|
||||
|
@ -369,7 +369,7 @@ int resize_by_layout(void *obj, int maximum_size)
|
|||
}
|
||||
|
||||
// resize SIZE_BY_LAYOUT objects
|
||||
for (l = a->list ; l ; l = l->next) {
|
||||
for (l = a->children ; l ; l = l->next) {
|
||||
child = (Area*)l->data;
|
||||
if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) {
|
||||
int old_height = child->height;
|
||||
|
@ -392,7 +392,7 @@ void set_redraw (Area *a)
|
|||
a->redraw = 1;
|
||||
|
||||
GList *l;
|
||||
for (l = a->list ; l ; l = l->next)
|
||||
for (l = a->children ; l ; l = l->next)
|
||||
set_redraw(l->data);
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ void remove_area (void *a)
|
|||
Area *area = (Area*)a;
|
||||
Area *parent = (Area*)area->parent;
|
||||
|
||||
parent->list = g_list_remove(parent->list, area);
|
||||
parent->children = g_list_remove(parent->children, area);
|
||||
parent->resize = 1;
|
||||
set_redraw (parent);
|
||||
|
||||
|
@ -501,7 +501,7 @@ void add_area (Area *a)
|
|||
{
|
||||
Area *parent = (Area*)a->parent;
|
||||
|
||||
parent->list = g_list_append(parent->list, a);
|
||||
parent->children = g_list_append(parent->children, a);
|
||||
set_redraw (parent);
|
||||
|
||||
}
|
||||
|
@ -513,12 +513,12 @@ void free_area (Area *a)
|
|||
return;
|
||||
|
||||
GList *l0;
|
||||
for (l0 = a->list; l0 ; l0 = l0->next)
|
||||
for (l0 = a->children; l0 ; l0 = l0->next)
|
||||
free_area (l0->data);
|
||||
|
||||
if (a->list) {
|
||||
g_list_free(a->list);
|
||||
a->list = 0;
|
||||
if (a->children) {
|
||||
g_list_free(a->children);
|
||||
a->children = 0;
|
||||
}
|
||||
if (a->pix) {
|
||||
XFreePixmap (server.dsp, a->pix);
|
||||
|
|
|
@ -70,7 +70,7 @@ typedef struct {
|
|||
Background *bg;
|
||||
|
||||
// list of child : Area object
|
||||
GList *list;
|
||||
GList *children;
|
||||
|
||||
// object visible on screen.
|
||||
// An object (like systray) could be enabled but hidden (because no tray icon).
|
||||
|
|
Loading…
Reference in a new issue