cleanup code
git-svn-id: http://tint2.googlecode.com/svn/trunk@562 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
e68c361951
commit
98c3cbe874
10 changed files with 41 additions and 40 deletions
|
@ -237,6 +237,8 @@ void init_battery_panel(void *p)
|
|||
battery->area._draw_foreground = draw_battery;
|
||||
battery->area.size_mode = SIZE_BY_CONTENT;
|
||||
battery->area._resize = resize_battery;
|
||||
battery->area.on_screen = 1;
|
||||
battery->area.resize = 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -451,13 +451,14 @@ void add_entry (char *key, char *value)
|
|||
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;
|
||||
}
|
||||
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.use_active = 1;
|
||||
}
|
||||
|
||||
/* Task */
|
||||
|
|
26
src/panel.c
26
src/panel.c
|
@ -219,9 +219,10 @@ void init_panel()
|
|||
|
||||
if (panel_autohide)
|
||||
add_timeout(panel_autohide_hide_timeout, 0, autohide_hide, p);
|
||||
|
||||
visible_taskbar(p);
|
||||
}
|
||||
|
||||
visible_object();
|
||||
task_refresh_tasklist();
|
||||
active_task();
|
||||
}
|
||||
|
@ -301,29 +302,6 @@ void init_panel_size_and_position(Panel *panel)
|
|||
}
|
||||
|
||||
|
||||
void visible_object()
|
||||
{
|
||||
Panel *panel;
|
||||
int i, j;
|
||||
|
||||
for (i=0 ; i < nb_panel ; i++) {
|
||||
panel = &panel1[i];
|
||||
|
||||
Taskbar *taskbar;
|
||||
for (j=0 ; j < panel->nb_desktop ; j++) {
|
||||
taskbar = &panel->taskbar[j];
|
||||
if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) {
|
||||
// SINGLE_DESKTOP and not current desktop
|
||||
taskbar->area.on_screen = 0;
|
||||
}
|
||||
else {
|
||||
taskbar->area.on_screen = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
panel_refresh = 1;
|
||||
}
|
||||
|
||||
void update_strut(Panel* p)
|
||||
{
|
||||
if (panel_strut_policy == STRUT_NONE) {
|
||||
|
|
|
@ -138,7 +138,6 @@ void init_panel_size_and_position(Panel *panel);
|
|||
|
||||
void set_panel_items_order(Panel *p);
|
||||
void set_panel_properties(Panel *p);
|
||||
void visible_object();
|
||||
|
||||
// draw background panel
|
||||
void set_panel_background(Panel *p);
|
||||
|
|
|
@ -342,6 +342,7 @@ void draw_task (void *obj, cairo_t *c)
|
|||
Color *config_text;
|
||||
int width=0, height;
|
||||
Panel *panel = (Panel*)tsk->area.panel;
|
||||
//printf("draw_task %d %d\n", tsk->area.posx, tsk->area.posy);
|
||||
|
||||
if (panel->g_task.text) {
|
||||
/* Layout */
|
||||
|
|
|
@ -198,7 +198,7 @@ void init_taskbar_panel(void *p)
|
|||
tskbar = &panel->taskbar[j];
|
||||
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
|
||||
tskbar->desktop = j;
|
||||
if (j == server.desktop && panel->g_taskbar.use_active)
|
||||
if (j == server.desktop)
|
||||
tskbar->area.bg = panel->g_taskbar.bg_active;
|
||||
}
|
||||
}
|
||||
|
@ -266,9 +266,7 @@ int resize_taskbar(void *obj)
|
|||
GSList *l;
|
||||
int task_count, border_width;
|
||||
|
||||
//printf("resize_taskbar : posx et width des taches\n");
|
||||
taskbar->area.redraw = 1;
|
||||
|
||||
// taskbar->area.redraw = 1;
|
||||
border_width = taskbar->area.bg->border.width;
|
||||
|
||||
if (panel_horizontal) {
|
||||
|
@ -297,7 +295,7 @@ int resize_taskbar(void *obj)
|
|||
for (l = taskbar->area.list; l ; l = l->next) {
|
||||
tsk = l->data;
|
||||
if (!tsk->area.on_screen) continue;
|
||||
set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id)
|
||||
//set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id)
|
||||
tsk->area.width = pixel_width;
|
||||
// TODO : move later (when posx is known)
|
||||
// long value[] = { panel->posx+x, panel->posy, pixel_width, panel->area.height };
|
||||
|
@ -335,7 +333,7 @@ int resize_taskbar(void *obj)
|
|||
for (l = taskbar->area.list; l ; l = l->next) {
|
||||
tsk = l->data;
|
||||
if (!tsk->area.on_screen) continue;
|
||||
set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id)
|
||||
//set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id)
|
||||
tsk->area.height = pixel_height;
|
||||
// TODO : move later (when posy is known)
|
||||
// long value[] = { panel->posx, panel->posy+y, panel->area.width, pixel_height };
|
||||
|
@ -347,6 +345,27 @@ int resize_taskbar(void *obj)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void visible_taskbar(void *p)
|
||||
{
|
||||
Panel *panel =(Panel*)p;
|
||||
int j;
|
||||
|
||||
Taskbar *taskbar;
|
||||
for (j=0 ; j < panel->nb_desktop ; j++) {
|
||||
taskbar = &panel->taskbar[j];
|
||||
if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) {
|
||||
// SINGLE_DESKTOP and not current desktop
|
||||
taskbar->area.on_screen = 0;
|
||||
}
|
||||
else {
|
||||
taskbar->area.on_screen = 1;
|
||||
}
|
||||
}
|
||||
panel_refresh = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ typedef struct {
|
|||
Area area;
|
||||
Background* bg;
|
||||
Background* bg_active;
|
||||
int use_active;
|
||||
} Global_taskbar;
|
||||
|
||||
|
||||
|
@ -54,6 +53,9 @@ void task_refresh_tasklist ();
|
|||
|
||||
int resize_taskbar(void *obj);
|
||||
|
||||
// show/hide taskbar according to current desktop
|
||||
void visible_taskbar(void *p);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -494,9 +494,9 @@ void event_property_notify (XEvent *e)
|
|||
for (i=0 ; i < nb_panel ; i++) {
|
||||
init_taskbar_panel(&panel1[i]);
|
||||
set_panel_items_order(&panel1[i]);
|
||||
visible_taskbar(&panel1[i]);
|
||||
panel1[i].area.resize = 1;
|
||||
}
|
||||
visible_object();
|
||||
task_refresh_tasklist();
|
||||
active_task();
|
||||
panel_refresh = 1;
|
||||
|
@ -508,7 +508,7 @@ 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.use_active) {
|
||||
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
|
||||
|
@ -542,9 +542,8 @@ void event_property_notify (XEvent *e)
|
|||
tskbar->area.resize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (panel_mode != MULTI_DESKTOP) {
|
||||
visible_object();
|
||||
if (panel_mode != MULTI_DESKTOP)
|
||||
visible_taskbar(panel);
|
||||
}
|
||||
}
|
||||
// Window list
|
||||
|
|
|
@ -220,7 +220,6 @@ int resize_by_layout(void *obj)
|
|||
Area *child, *a = (Area*)obj;
|
||||
int size, nb_by_content=0, nb_by_layout=0;
|
||||
|
||||
printf("resize_by_layout\n");
|
||||
if (panel_horizontal) {
|
||||
// detect free size for SIZE_BY_LAYOUT's Area
|
||||
size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
|
||||
|
|
|
@ -82,7 +82,8 @@ typedef struct {
|
|||
|
||||
// each object can overwrite following function
|
||||
void (*_draw_foreground)(void *obj, cairo_t *c);
|
||||
// calculate size. return '1' if size changed, '0' otherwise.
|
||||
// update area's content and update size (width/heith).
|
||||
// return '1' if size changed, '0' otherwise.
|
||||
int (*_resize)(void *obj);
|
||||
void (*_add_child)(void *obj);
|
||||
int (*_remove_child)(void *obj);
|
||||
|
|
Loading…
Reference in a new issue