/**************************************************************************
*
* Copyright (C) 2008 Pål Staurland (staura@gmail.com)
-* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
+* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
task_dragged = 0;
panel_horizontal = 1;
panel_position = CENTER;
- panel_items_order = strdup("LTBSC"); // Default order : Launcher, Taskbar, Battery, Systray, Clock
+ panel_items_order = 0;
panel_autohide = 0;
panel_autohide_show_timeout = 0;
panel_autohide_hide_timeout = 0;
void init_panel()
{
- int i;
+ int i, k;
Panel *p;
if (panel_config.monitor > (server.nb_monitor-1)) {
p->g_task.area.panel = p;
init_panel_size_and_position(p);
// add childs according to panel_items
- set_panel_items(p);
+ for (k=0 ; k < strlen(panel_items_order) ; k++) {
+ if (panel_items_order[k] == 'L')
+ init_launcher_panel(p);
+ if (panel_items_order[k] == 'T')
+ init_taskbar_panel(p);
+#ifdef ENABLE_BATTERY
+ if (panel_items_order[k] == 'B')
+ init_battery_panel(p);
+#endif
+ if (panel_items_order[k] == 'S') {
+ // TODO : check systray is only on 1 panel
+ init_systray_panel(p);
+ refresh_systray = 1;
+ }
+ if (panel_items_order[k] == 'C')
+ init_clock_panel(p);
+ }
+ set_panel_items_order(p);
// catch some events
XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
if (panel_autohide)
add_timeout(panel_autohide_hide_timeout, 0, autohide_hide, p);
+
+ visible_taskbar(p);
}
- panel_refresh = 1;
- visible_object();
task_refresh_tasklist();
active_task();
}
int resize_panel(void *obj)
{
- Panel *panel = (Panel*)obj;
- int size, nb_by_content=0, nb_by_layout=0;
- Area *a = (Area*)obj;
- int paddingx = a->paddingx;;
-
- if (panel_horizontal) {
- // detect free size for SIZE_BY_LAYOUT's Area
- size = a->width - (2 * a->paddingxlr) - (2 * a->bg->border.width);
- GSList *l;
- for (l = ((Area*)obj)->list ; l ; l = l->next) {
- a = (Area*)l->data;
- if (a->on_screen && a->width && a->size_mode == SIZE_BY_CONTENT) {
- size -= a->width;
- nb_by_content++;
- }
- if (a->on_screen && a->size_mode == SIZE_BY_LAYOUT)
- nb_by_layout++;
- }
- if (nb_by_content+nb_by_layout)
- size -= ((nb_by_content+nb_by_layout-1) * paddingx);
- //printf("resize_panel : size_panel %d, size_layout %d\n", panel->area.width, size);
-
- int width=0, modulo=0;
- if (nb_by_layout) {
- width = size / nb_by_layout;
- modulo = size % nb_by_layout;
- }
- //printf(" content %d, layout %d, width %d, modulo %d\n", nb_by_content, nb_by_layout, width, modulo);
-
- // change posx and width for all taskbar
- int i, posx;
- posx = panel->area.bg->border.width + panel->area.paddingxlr;
- if (panel->launcher.area.on_screen && panel->launcher.area.width)
- posx += (panel->launcher.area.width + panel->area.paddingx);
+ resize_by_layout(obj, 0);
+
+ //printf("resize_panel\n");
+ if (panel_mode != MULTI_DESKTOP && taskbar_enabled) {
+ // propagate width/height on hidden taskbar
+ int i, width, height;
+ Panel *panel = (Panel*)obj;
+ width = panel->taskbar[server.desktop].area.width;
+ height = panel->taskbar[server.desktop].area.height;
for (i=0 ; i < panel->nb_desktop ; i++) {
- panel->taskbar[i].area.posx = posx;
panel->taskbar[i].area.width = width;
+ panel->taskbar[i].area.height = height;
panel->taskbar[i].area.resize = 1;
- if (modulo) {
- panel->taskbar[i].area.width++;
- modulo--;
- }
- //printf(" width %d\n", panel->taskbar[i].area.width);
- //printf("taskbar %d : posx %d, width, %d, posy %d\n", i, posx, panel->taskbar[i].area.width, posx + panel->taskbar[i].area.width);
- if (panel_mode == MULTI_DESKTOP)
- posx += panel->taskbar[i].area.width + panel->area.paddingx;
- }
- }
- else {
- // detect free size for SIZE_BY_LAYOUT's Area
- size = a->height - (2 * a->paddingxlr) - (2 * a->bg->border.width);
- GSList *l;
- for (l = ((Area*)obj)->list ; l ; l = l->next) {
- a = (Area*)l->data;
- if (a->on_screen && a->height && a->size_mode == SIZE_BY_CONTENT) {
- size -= a->height;
- nb_by_content++;
- }
- if (a->on_screen && a->size_mode == SIZE_BY_LAYOUT)
- nb_by_layout++;
- }
- if (nb_by_content+nb_by_layout)
- size -= ((nb_by_content+nb_by_layout-1) * paddingx);
-
- int width=0, modulo=0;
- if (nb_by_layout) {
- width = size / nb_by_layout;
- modulo = size % nb_by_layout;
- }
-
- // change posy and height for all taskbar
- int i, posy;
- for (i=0 ; i < panel->nb_desktop ; i++) {
- panel->taskbar[i].area.posy = posy;
- panel->taskbar[i].area.height = width;
- panel->taskbar[i].area.resize = 1;
- if (modulo) {
- panel->taskbar[i].area.height++;
- modulo--;
- }
- if (panel_mode == MULTI_DESKTOP)
- posy += panel->taskbar[i].area.height + panel->area.paddingx;
}
}
return 0;
}
-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) {
}
-void set_panel_items(Panel *p)
+void set_panel_items_order(Panel *p)
{
int k, j;
}
for (k=0 ; k < strlen(panel_items_order) ; k++) {
- if (panel_items_order[k] == 'L') {
- init_launcher_panel(p);
+ if (panel_items_order[k] == 'L')
p->area.list = g_slist_append(p->area.list, &p->launcher);
- }
if (panel_items_order[k] == 'T') {
- init_taskbar_panel(p);
for (j=0 ; j < p->nb_desktop ; j++)
p->area.list = g_slist_append(p->area.list, &p->taskbar[j]);
}
#ifdef ENABLE_BATTERY
- if (panel_items_order[k] == 'B') {
- init_battery_panel(p);
+ if (panel_items_order[k] == 'B')
p->area.list = g_slist_append(p->area.list, &p->battery);
- }
#endif
if (panel_items_order[k] == 'S') {
// TODO : check systray is only on 1 panel
- init_systray_panel(p);
- refresh_systray = 1;
p->area.list = g_slist_append(p->area.list, &systray);
}
- if (panel_items_order[k] == 'C') {
- init_clock_panel(p);
+ if (panel_items_order[k] == 'C')
p->area.list = g_slist_append(p->area.list, &p->clock);
- }
}
+ init_rendering(&p->area, 0);
}
}
// redraw panel's object
- //p->area.redraw = 1;
GSList *l0;
Area *a;
for (l0 = p->area.list; l0 ; l0 = l0->next) {
set_redraw(a);
}
- // reset task 'state_pix'
- int i;
+ // reset task/taskbar 'state_pix'
+ int i, k;
Taskbar *tskbar;
for (i=0 ; i < p->nb_desktop ; i++) {
tskbar = &p->taskbar[i];
+ for (k=0; k<TASKBAR_STATE_COUNT; ++k) {
+ if (tskbar->state_pix[k]) XFreePixmap(server.dsp, tskbar->state_pix[k]);
+ tskbar->state_pix[k] = 0;
+ }
+ tskbar->area.pix = 0;
for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
set_task_redraw((Task *)l0->data);
}