Compare commits
2 Commits
spacer
...
area-align
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92fa96b8c7 | ||
|
|
ca862025d6 |
22
src/panel.c
22
src/panel.c
@@ -354,7 +354,7 @@ int resize_panel(void *obj)
|
||||
}
|
||||
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
GSList *l;
|
||||
GList *l;
|
||||
for (l = taskbar->area.list; l; l = l->next) {
|
||||
Area *child = l->data;
|
||||
if (!child->on_screen)
|
||||
@@ -389,7 +389,7 @@ int resize_panel(void *obj)
|
||||
|
||||
int requested_size = (2 * taskbar->area.bg->border.width) + (2 * taskbar->area.paddingxlr);
|
||||
int items = 0;
|
||||
GSList *l = taskbar->area.list;
|
||||
GList *l = taskbar->area.list;
|
||||
if (taskbarname_enabled)
|
||||
l = l->next;
|
||||
for (; l; l = l->next) {
|
||||
@@ -482,29 +482,29 @@ void set_panel_items_order(Panel *p)
|
||||
int k, j;
|
||||
|
||||
if (p->area.list) {
|
||||
g_slist_free(p->area.list);
|
||||
g_list_free(p->area.list);
|
||||
p->area.list = 0;
|
||||
}
|
||||
|
||||
for (k=0 ; k < strlen(panel_items_order) ; k++) {
|
||||
if (panel_items_order[k] == 'L') {
|
||||
p->area.list = g_slist_append(p->area.list, &p->launcher);
|
||||
p->area.list = g_list_append(p->area.list, &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_slist_append(p->area.list, &p->taskbar[j]);
|
||||
p->area.list = g_list_append(p->area.list, &p->taskbar[j]);
|
||||
}
|
||||
#ifdef ENABLE_BATTERY
|
||||
if (panel_items_order[k] == 'B')
|
||||
p->area.list = g_slist_append(p->area.list, &p->battery);
|
||||
p->area.list = g_list_append(p->area.list, &p->battery);
|
||||
#endif
|
||||
int i = p - panel1;
|
||||
if (panel_items_order[k] == 'S' && systray_on_monitor(i, nb_panel)) {
|
||||
p->area.list = g_slist_append(p->area.list, &systray);
|
||||
p->area.list = g_list_append(p->area.list, &systray);
|
||||
}
|
||||
if (panel_items_order[k] == 'C')
|
||||
p->area.list = g_slist_append(p->area.list, &p->clock);
|
||||
p->area.list = g_list_append(p->area.list, &p->clock);
|
||||
}
|
||||
init_rendering(&p->area, 0);
|
||||
}
|
||||
@@ -629,7 +629,7 @@ void set_panel_background(Panel *p)
|
||||
}
|
||||
|
||||
// redraw panel's object
|
||||
GSList *l0;
|
||||
GList *l0;
|
||||
Area *a;
|
||||
for (l0 = p->area.list; l0 ; l0 = l0->next) {
|
||||
a = l0->data;
|
||||
@@ -695,7 +695,7 @@ Taskbar *click_taskbar (Panel *panel, int x, int y)
|
||||
|
||||
Task *click_task (Panel *panel, int x, int y)
|
||||
{
|
||||
GSList *l0;
|
||||
GList *l0;
|
||||
Taskbar *tskbar;
|
||||
|
||||
if ( (tskbar = click_taskbar(panel, x, y)) ) {
|
||||
@@ -797,7 +797,7 @@ Area* click_area(Panel *panel, int x, int y)
|
||||
Area* new_result = result;
|
||||
do {
|
||||
result = new_result;
|
||||
GSList* it = result->list;
|
||||
GList* it = result->list;
|
||||
while (it) {
|
||||
Area* a = it->data;
|
||||
if (a->on_screen && x >= a->posx && x <= (a->posx + a->width)
|
||||
|
||||
@@ -109,7 +109,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_slist_append(tskbar->area.list, new_tsk2);
|
||||
tskbar->area.list = g_list_append(tskbar->area.list, 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);
|
||||
@@ -167,7 +167,7 @@ void remove_task (Task *tsk)
|
||||
for (i=0; i<task_group->len; ++i) {
|
||||
tsk2 = g_ptr_array_index(task_group, i);
|
||||
tskbar = tsk2->area.parent;
|
||||
tskbar->area.list = g_slist_remove(tskbar->area.list, tsk2);
|
||||
tskbar->area.list = g_list_remove(tskbar->area.list, tsk2);
|
||||
tskbar->area.resize = 1;
|
||||
if (tsk2 == task_active) task_active = 0;
|
||||
if (tsk2 == task_drag) task_drag = 0;
|
||||
@@ -422,15 +422,13 @@ Task *find_active_task(Task *current_task, Task *active_task)
|
||||
if (active_task == NULL)
|
||||
return current_task;
|
||||
|
||||
GSList *l0;
|
||||
Task *tsk;
|
||||
Taskbar* tskbar = current_task->area.parent;
|
||||
|
||||
l0 = tskbar->area.list;
|
||||
GList *l0 = tskbar->area.list;
|
||||
if (taskbarname_enabled)
|
||||
l0 = l0->next;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
tsk = l0->data;
|
||||
Task *tsk = l0->data;
|
||||
if (tsk->win == active_task->win)
|
||||
return tsk;
|
||||
}
|
||||
@@ -443,15 +441,13 @@ Task *next_task(Task *tsk)
|
||||
if (tsk == 0)
|
||||
return 0;
|
||||
|
||||
GSList *l0, *lfirst_tsk;
|
||||
Task *tsk1;
|
||||
Taskbar* tskbar = tsk->area.parent;
|
||||
|
||||
l0 = tskbar->area.list;
|
||||
GList *l0 = tskbar->area.list;
|
||||
if (taskbarname_enabled) l0 = l0->next;
|
||||
lfirst_tsk = l0;
|
||||
GList *lfirst_tsk = l0;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
tsk1 = l0->data;
|
||||
Task *tsk1 = l0->data;
|
||||
if (tsk1 == tsk) {
|
||||
if (l0->next == 0) l0 = lfirst_tsk;
|
||||
else l0 = l0->next;
|
||||
@@ -467,19 +463,18 @@ Task *prev_task(Task *tsk)
|
||||
if (tsk == 0)
|
||||
return 0;
|
||||
|
||||
GSList *l0, *lfirst_tsk;
|
||||
Task *tsk1, *tsk2;
|
||||
Taskbar* tskbar = tsk->area.parent;
|
||||
|
||||
tsk2 = 0;
|
||||
l0 = tskbar->area.list;
|
||||
GList *l0 = tskbar->area.list;
|
||||
if (taskbarname_enabled) l0 = l0->next;
|
||||
lfirst_tsk = l0;
|
||||
GList *lfirst_tsk = l0;
|
||||
for (; l0 ; l0 = l0->next) {
|
||||
tsk1 = l0->data;
|
||||
if (tsk1 == tsk) {
|
||||
if (l0 == lfirst_tsk) {
|
||||
l0 = g_slist_last ( l0 );
|
||||
l0 = g_list_last ( l0 );
|
||||
tsk2 = l0->data;
|
||||
}
|
||||
return tsk2;
|
||||
|
||||
@@ -97,7 +97,7 @@ void cleanup_taskbar()
|
||||
}
|
||||
free_area(&tskbar->area);
|
||||
// remove taskbar from the panel
|
||||
panel->area.list = g_slist_remove(panel->area.list, tskbar);
|
||||
panel->area.list = g_list_remove(panel->area.list, tskbar);
|
||||
}
|
||||
if (panel->taskbar) {
|
||||
free(panel->taskbar);
|
||||
@@ -153,6 +153,7 @@ void init_taskbar_panel(void *p)
|
||||
panel->g_taskbar.area.parent = panel;
|
||||
panel->g_taskbar.area.panel = panel;
|
||||
panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT;
|
||||
panel->g_taskbar.area.alignment = ALIGN_CENTER;
|
||||
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;
|
||||
@@ -334,7 +335,7 @@ int resize_taskbar(void *obj)
|
||||
resize_by_layout(obj, panel->g_task.maximum_width);
|
||||
|
||||
text_width = panel->g_task.maximum_width;
|
||||
GSList *l = taskbar->area.list;
|
||||
GList *l = taskbar->area.list;
|
||||
if (taskbarname_enabled) l = l->next;
|
||||
for (; l != NULL; l = l->next) {
|
||||
if (((Task *)l->data)->area.on_screen) {
|
||||
@@ -388,7 +389,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]) {
|
||||
GSList *l = tskbar->area.list;
|
||||
GList *l = tskbar->area.list;
|
||||
if (taskbarname_enabled) l = l->next;
|
||||
for ( ; l ; l = l->next)
|
||||
set_task_redraw(l->data);
|
||||
@@ -511,7 +512,7 @@ int taskbar_needs_sort(Taskbar *taskbar)
|
||||
if (taskbar_sort_method == TASKBAR_NOSORT)
|
||||
return 0;
|
||||
|
||||
GSList *i, *j;
|
||||
GList *i, *j;
|
||||
for (i = taskbar->area.list, j = i ? i->next : NULL; i && j; i = i->next, j = j->next) {
|
||||
if (compare_tasks(i->data, j->data, taskbar) > 0) {
|
||||
return 1;
|
||||
@@ -528,7 +529,7 @@ void sort_tasks(Taskbar *taskbar)
|
||||
if (!taskbar_needs_sort(taskbar)) {
|
||||
return;
|
||||
}
|
||||
taskbar->area.list = g_slist_sort_with_data(taskbar->area.list, (GCompareDataFunc)compare_tasks, taskbar);
|
||||
taskbar->area.list = g_list_sort_with_data(taskbar->area.list, (GCompareDataFunc)compare_tasks, taskbar);
|
||||
taskbar->area.resize = 1;
|
||||
panel_refresh = 1;
|
||||
((Panel*)taskbar->area.panel)->area.resize = 1;
|
||||
|
||||
@@ -76,7 +76,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_slist_append(tskbar->area.list, &tskbar->bar_name);
|
||||
tskbar->area.list = g_list_append(tskbar->area.list, &tskbar->bar_name);
|
||||
}
|
||||
|
||||
for (l=list ; l ; l = l->next)
|
||||
@@ -103,7 +103,7 @@ void cleanup_taskbarname()
|
||||
XFreePixmap(server.dsp, tskbar->bar_name.state_pix[k]);
|
||||
tskbar->bar_name.state_pix[k] = 0;
|
||||
}
|
||||
tskbar->area.list = g_slist_remove(tskbar->area.list, &tskbar->bar_name);
|
||||
tskbar->area.list = g_list_remove(tskbar->area.list, &tskbar->bar_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
src/tint.c
18
src/tint.c
@@ -470,8 +470,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) {
|
||||
GSList * drag_iter = g_slist_find(event_taskbar->area.list, task_drag);
|
||||
GSList * task_iter = g_slist_find(event_taskbar->area.list, event_task);
|
||||
GList * drag_iter = g_list_find(event_taskbar->area.list, task_drag);
|
||||
GList * task_iter = g_list_find(event_taskbar->area.list, event_task);
|
||||
if(drag_iter && task_iter) {
|
||||
gpointer temp = task_iter->data;
|
||||
task_iter->data = drag_iter->data;
|
||||
@@ -488,14 +488,14 @@ void event_button_motion_notify (XEvent *e)
|
||||
return;
|
||||
|
||||
Taskbar * drag_taskbar = (Taskbar*)task_drag->area.parent;
|
||||
drag_taskbar->area.list = g_slist_remove(drag_taskbar->area.list, task_drag);
|
||||
drag_taskbar->area.list = g_list_remove(drag_taskbar->area.list, task_drag);
|
||||
|
||||
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_slist_insert(event_taskbar->area.list, task_drag, i);
|
||||
event_taskbar->area.list = g_list_insert(event_taskbar->area.list, task_drag, i);
|
||||
}
|
||||
else
|
||||
event_taskbar->area.list = g_slist_append(event_taskbar->area.list, task_drag);
|
||||
event_taskbar->area.list = g_list_append(event_taskbar->area.list, task_drag);
|
||||
|
||||
// Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify')
|
||||
task_drag->area.parent = event_taskbar;
|
||||
@@ -619,7 +619,8 @@ void event_property_notify (XEvent *e)
|
||||
// Change name of desktops
|
||||
else if (at == server.atom._NET_DESKTOP_NAMES) {
|
||||
if (!taskbarname_enabled) return;
|
||||
GSList *l, *list = server_get_name_of_desktop();
|
||||
GSList *list = server_get_name_of_desktop();
|
||||
GSList *l;
|
||||
int j;
|
||||
gchar *name;
|
||||
Taskbar *tskbar;
|
||||
@@ -677,10 +678,9 @@ void event_property_notify (XEvent *e)
|
||||
// check ALLDESKTOP task => resize taskbar
|
||||
Taskbar *tskbar;
|
||||
Task *tsk;
|
||||
GSList *l;
|
||||
if (server.nb_desktop > old_desktop) {
|
||||
tskbar = &panel->taskbar[old_desktop];
|
||||
l = tskbar->area.list;
|
||||
GList *l = tskbar->area.list;
|
||||
if (taskbarname_enabled) l = l->next;
|
||||
for (; l ; l = l->next) {
|
||||
tsk = l->data;
|
||||
@@ -694,7 +694,7 @@ void event_property_notify (XEvent *e)
|
||||
}
|
||||
}
|
||||
tskbar = &panel->taskbar[server.desktop];
|
||||
l = tskbar->area.list;
|
||||
GList *l = tskbar->area.list;
|
||||
if (taskbarname_enabled) l = l->next;
|
||||
for (; l ; l = l->next) {
|
||||
tsk = l->data;
|
||||
|
||||
174
src/util/area.c
174
src/util/area.c
@@ -76,7 +76,7 @@ void init_rendering(void *obj, int pos)
|
||||
Area *a = (Area*)obj;
|
||||
|
||||
// initialize fixed position/size
|
||||
GSList *l;
|
||||
GList *l;
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (panel_horizontal) {
|
||||
@@ -102,7 +102,7 @@ void rendering(void *obj)
|
||||
Panel *panel = (Panel*)obj;
|
||||
|
||||
size_by_content(&panel->area);
|
||||
size_by_layout(&panel->area, 0, 1);
|
||||
size_by_layout(&panel->area, 1);
|
||||
|
||||
refresh(&panel->area);
|
||||
}
|
||||
@@ -111,10 +111,11 @@ void rendering(void *obj)
|
||||
void size_by_content (Area *a)
|
||||
{
|
||||
// don't resize hiden objects
|
||||
if (!a->on_screen) return;
|
||||
if (!a->on_screen)
|
||||
return;
|
||||
|
||||
// children node are resized before its parent
|
||||
GSList *l;
|
||||
GList *l;
|
||||
for (l = a->list; l ; l = l->next)
|
||||
size_by_content(l->data);
|
||||
|
||||
@@ -134,14 +135,21 @@ void size_by_content (Area *a)
|
||||
}
|
||||
|
||||
|
||||
void size_by_layout (Area *a, int pos, int level)
|
||||
void size_by_layout (Area *a, int level)
|
||||
{
|
||||
// don't resize hiden objects
|
||||
if (!a->on_screen) return;
|
||||
if (!a->on_screen)
|
||||
return;
|
||||
|
||||
if (a == &panel1->taskbar[0]) {
|
||||
printf("%s %d: Taskbar 0: y=%d, h=%d, b=%d\n", __FUNCTION__, __LINE__, a->posy, a->height, a->posy + a->height);
|
||||
} else if (a == &panel1->taskbar[1]) {
|
||||
printf("%s %d: Taskbar 1: y=%d, h=%d, b=%d\n", __FUNCTION__, __LINE__, a->posy, a->height, a->posy + a->height);
|
||||
}
|
||||
|
||||
// parent node is resized before its children
|
||||
// calculate area's size
|
||||
GSList *l;
|
||||
GList *l;
|
||||
if (a->resize && a->size_mode == SIZE_BY_LAYOUT) {
|
||||
a->resize = 0;
|
||||
|
||||
@@ -156,40 +164,103 @@ void size_by_layout (Area *a, int pos, int level)
|
||||
}
|
||||
}
|
||||
|
||||
// update position of childs
|
||||
pos += a->paddingxlr + a->bg->border.width;
|
||||
int i=0;
|
||||
for (l = a->list; l ; l = l->next) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen) continue;
|
||||
i++;
|
||||
|
||||
if (panel_horizontal) {
|
||||
if (pos != child->posx) {
|
||||
// pos changed => redraw
|
||||
child->posx = pos;
|
||||
child->on_changed = 1;
|
||||
// update position of children
|
||||
if (a->list) {
|
||||
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) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
||||
if (panel_horizontal) {
|
||||
if (pos != child->posx) {
|
||||
// pos changed => redraw
|
||||
child->posx = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
} else {
|
||||
if (pos != child->posy) {
|
||||
// pos changed => redraw
|
||||
child->posy = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
size_by_layout(child, level+1);
|
||||
|
||||
pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx;
|
||||
}
|
||||
} 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) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
||||
pos -= panel_horizontal ? child->width : child->height;
|
||||
|
||||
if (panel_horizontal) {
|
||||
if (pos != child->posx) {
|
||||
// pos changed => redraw
|
||||
child->posx = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
} else {
|
||||
if (pos != child->posy) {
|
||||
// pos changed => redraw
|
||||
child->posy = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
size_by_layout(child, level+1);
|
||||
|
||||
pos -= a->paddingx;
|
||||
}
|
||||
} else if (a->alignment == ALIGN_CENTER) {
|
||||
|
||||
int children_size = 0;
|
||||
|
||||
for (l = a->list; 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;
|
||||
}
|
||||
|
||||
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) {
|
||||
Area *child = ((Area*)l->data);
|
||||
if (!child->on_screen)
|
||||
continue;
|
||||
|
||||
if (panel_horizontal) {
|
||||
if (pos != child->posx) {
|
||||
// pos changed => redraw
|
||||
child->posx = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
} else {
|
||||
if (pos != child->posy) {
|
||||
// pos changed => redraw
|
||||
child->posy = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
size_by_layout(child, level+1);
|
||||
|
||||
pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pos != child->posy) {
|
||||
// pos changed => redraw
|
||||
child->posy = pos;
|
||||
child->on_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*// position of each visible object
|
||||
int k;
|
||||
for (k=0 ; k < level ; k++) printf(" ");
|
||||
printf("tree level %d, object %d, pos %d, %s\n", level, i, pos, (child->size_mode == SIZE_BY_LAYOUT) ? "SIZE_BY_LAYOUT" : "SIZE_BY_CONTENT");*/
|
||||
size_by_layout(child, pos, level+1);
|
||||
|
||||
if (panel_horizontal)
|
||||
pos += child->width + a->paddingx;
|
||||
else
|
||||
pos += child->height + a->paddingx;
|
||||
}
|
||||
}
|
||||
|
||||
if (a->on_changed) {
|
||||
// pos/size changed
|
||||
@@ -222,7 +293,7 @@ void refresh (Area *a)
|
||||
XCopyArea (server.dsp, a->pix, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
|
||||
|
||||
// and then refresh child object
|
||||
GSList *l;
|
||||
GList *l;
|
||||
for (l = a->list; l ; l = l->next)
|
||||
refresh(l->data);
|
||||
}
|
||||
@@ -236,7 +307,7 @@ int resize_by_layout(void *obj, int maximum_size)
|
||||
if (panel_horizontal) {
|
||||
// detect free size for SIZE_BY_LAYOUT's Area
|
||||
size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
|
||||
GSList *l;
|
||||
GList *l;
|
||||
for (l = a->list ; l ; l = l->next) {
|
||||
child = (Area*)l->data;
|
||||
if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
|
||||
@@ -278,7 +349,7 @@ int resize_by_layout(void *obj, int maximum_size)
|
||||
else {
|
||||
// detect free size for SIZE_BY_LAYOUT's Area
|
||||
size = a->height - (2 * (a->paddingxlr + a->bg->border.width));
|
||||
GSList *l;
|
||||
GList *l;
|
||||
for (l = a->list ; l ; l = l->next) {
|
||||
child = (Area*)l->data;
|
||||
if (child->on_screen && child->size_mode == SIZE_BY_CONTENT) {
|
||||
@@ -291,7 +362,7 @@ int resize_by_layout(void *obj, int maximum_size)
|
||||
if (nb_by_content+nb_by_layout)
|
||||
size -= ((nb_by_content+nb_by_layout-1) * a->paddingx);
|
||||
|
||||
int height=0, modulo=0, old_height;
|
||||
int height=0, modulo=0;
|
||||
if (nb_by_layout) {
|
||||
height = size / nb_by_layout;
|
||||
modulo = size % nb_by_layout;
|
||||
@@ -305,8 +376,13 @@ int resize_by_layout(void *obj, int maximum_size)
|
||||
for (l = a->list ; l ; l = l->next) {
|
||||
child = (Area*)l->data;
|
||||
if (child->on_screen && child->size_mode == SIZE_BY_LAYOUT) {
|
||||
old_height = child->height;
|
||||
int old_height = child->height;
|
||||
child->height = height;
|
||||
if (child == &panel1->taskbar[0]) {
|
||||
printf("Taskbar 0: y=%d, h=%d, b=%d\n", child->posy, child->height, child->posy + child->height);
|
||||
} else if (child == &panel1->taskbar[1]) {
|
||||
printf("Taskbar 1: y=%d, h=%d, b=%d\n", child->posy, child->height, child->posy + child->height);
|
||||
}
|
||||
if (modulo) {
|
||||
child->height++;
|
||||
modulo--;
|
||||
@@ -324,7 +400,7 @@ void set_redraw (Area *a)
|
||||
{
|
||||
a->redraw = 1;
|
||||
|
||||
GSList *l;
|
||||
GList *l;
|
||||
for (l = a->list ; l ; l = l->next)
|
||||
set_redraw(l->data);
|
||||
}
|
||||
@@ -438,7 +514,7 @@ void remove_area (Area *a)
|
||||
{
|
||||
Area *parent = (Area*)a->parent;
|
||||
|
||||
parent->list = g_slist_remove(parent->list, a);
|
||||
parent->list = g_list_remove(parent->list, a);
|
||||
set_redraw (parent);
|
||||
|
||||
}
|
||||
@@ -448,7 +524,7 @@ void add_area (Area *a)
|
||||
{
|
||||
Area *parent = (Area*)a->parent;
|
||||
|
||||
parent->list = g_slist_append(parent->list, a);
|
||||
parent->list = g_list_append(parent->list, a);
|
||||
set_redraw (parent);
|
||||
|
||||
}
|
||||
@@ -459,12 +535,12 @@ void free_area (Area *a)
|
||||
if (!a)
|
||||
return;
|
||||
|
||||
GSList *l0;
|
||||
GList *l0;
|
||||
for (l0 = a->list; l0 ; l0 = l0->next)
|
||||
free_area (l0->data);
|
||||
|
||||
if (a->list) {
|
||||
g_slist_free(a->list);
|
||||
g_list_free(a->list);
|
||||
a->list = 0;
|
||||
}
|
||||
if (a->pix) {
|
||||
|
||||
@@ -52,6 +52,8 @@ typedef struct
|
||||
// SIZE_BY_CONTENT objects : clock, battery, launcher, systray
|
||||
enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT };
|
||||
|
||||
enum { ALIGN_LEFT = 0, ALIGN_CENTER = 1, ALIGN_RIGHT = 2 };
|
||||
|
||||
typedef struct {
|
||||
// coordinate relative to panel window
|
||||
int posx, posy;
|
||||
@@ -61,13 +63,15 @@ typedef struct {
|
||||
Background *bg;
|
||||
|
||||
// list of child : Area object
|
||||
GSList *list;
|
||||
GList *list;
|
||||
|
||||
// object visible on screen.
|
||||
// An object (like systray) could be enabled but hidden (because no tray icon).
|
||||
int on_screen;
|
||||
// way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT)
|
||||
int size_mode;
|
||||
|
||||
int alignment;
|
||||
// need to calculate position and width
|
||||
int resize;
|
||||
// need redraw Pixmap
|
||||
@@ -96,7 +100,7 @@ void init_rendering(void *obj, int pos);
|
||||
|
||||
void rendering(void *obj);
|
||||
void size_by_content (Area *a);
|
||||
void size_by_layout (Area *a, int pos, int level);
|
||||
void size_by_layout (Area *a, int level);
|
||||
// draw background and foreground
|
||||
void refresh (Area *a);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user