order of panel items : partial implementation. expect crash/instability
git-svn-id: http://tint2.googlecode.com/svn/trunk@546 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
124
src/panel.c
124
src/panel.c
@@ -123,7 +123,7 @@ void cleanup_panel()
|
|||||||
|
|
||||||
void init_panel()
|
void init_panel()
|
||||||
{
|
{
|
||||||
int i;
|
int i, j;
|
||||||
Panel *p;
|
Panel *p;
|
||||||
|
|
||||||
if (panel_config.monitor > (server.nb_monitor-1)) {
|
if (panel_config.monitor > (server.nb_monitor-1)) {
|
||||||
@@ -170,9 +170,15 @@ void init_panel()
|
|||||||
p->g_task.area.panel = p;
|
p->g_task.area.panel = p;
|
||||||
init_panel_size_and_position(p);
|
init_panel_size_and_position(p);
|
||||||
// add childs
|
// add childs
|
||||||
if (clock_enabled) {
|
// TODO : should respect the order of 'panel_items' config parameter
|
||||||
init_clock_panel(p);
|
if (launcher_enabled) {
|
||||||
p->area.list = g_slist_append(p->area.list, &p->clock);
|
init_launcher_panel(p);
|
||||||
|
p->area.list = g_slist_append(p->area.list, &p->launcher);
|
||||||
|
}
|
||||||
|
p->nb_desktop = server.nb_desktop;
|
||||||
|
p->taskbar = calloc(p->nb_desktop, sizeof(Taskbar));
|
||||||
|
for (j=0 ; j < p->nb_desktop ; j++) {
|
||||||
|
p->area.list = g_slist_append(p->area.list, &p->taskbar[j]);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_BATTERY
|
#ifdef ENABLE_BATTERY
|
||||||
if (battery_enabled) {
|
if (battery_enabled) {
|
||||||
@@ -180,16 +186,16 @@ void init_panel()
|
|||||||
p->area.list = g_slist_append(p->area.list, &p->battery);
|
p->area.list = g_slist_append(p->area.list, &p->battery);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (launcher_enabled) {
|
|
||||||
init_launcher_panel(p);
|
|
||||||
p->area.list = g_slist_append(p->area.list, &p->launcher);
|
|
||||||
}
|
|
||||||
// systray only on first panel
|
// systray only on first panel
|
||||||
if (systray.area.on_screen && i == 0) {
|
if (systray.area.on_screen && i == 0) {
|
||||||
init_systray_panel(p);
|
init_systray_panel(p);
|
||||||
p->area.list = g_slist_append(p->area.list, &systray);
|
p->area.list = g_slist_append(p->area.list, &systray);
|
||||||
refresh_systray = 1;
|
refresh_systray = 1;
|
||||||
}
|
}
|
||||||
|
if (clock_enabled) {
|
||||||
|
init_clock_panel(p);
|
||||||
|
p->area.list = g_slist_append(p->area.list, &p->clock);
|
||||||
|
}
|
||||||
|
|
||||||
// catch some events
|
// catch some events
|
||||||
XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
|
XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
|
||||||
@@ -304,29 +310,33 @@ void init_panel_size_and_position(Panel *panel)
|
|||||||
int resize_panel(void *obj)
|
int resize_panel(void *obj)
|
||||||
{
|
{
|
||||||
Panel *panel = (Panel*)obj;
|
Panel *panel = (Panel*)obj;
|
||||||
//printf("resize_panel : taskbar\n");
|
int size, nb_by_content=0, nb_by_layout=0;
|
||||||
|
Area *a = (Area*)obj;
|
||||||
|
int paddingx = a->paddingx;;
|
||||||
|
|
||||||
if (panel_horizontal) {
|
if (panel_horizontal) {
|
||||||
int taskbar_width, modulo_width = 0;
|
// detect free size for SIZE_BY_LAYOUT's Area
|
||||||
|
size = a->width - (2 * a->paddingxlr) - (2 * a->bg->border.width);
|
||||||
taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width);
|
GSList *l;
|
||||||
if (panel->clock.area.on_screen && panel->clock.area.width)
|
for (l = ((Area*)obj)->list ; l ; l = l->next) {
|
||||||
taskbar_width -= (panel->clock.area.width + panel->area.paddingx);
|
a = (Area*)l->data;
|
||||||
if (panel->launcher.area.on_screen && panel->launcher.area.width)
|
if (a->on_screen && a->width && a->size_mode == SIZE_BY_CONTENT) {
|
||||||
taskbar_width -= (panel->launcher.area.width + panel->area.paddingx);
|
size -= a->width;
|
||||||
#ifdef ENABLE_BATTERY
|
nb_by_content++;
|
||||||
if (panel->battery.area.on_screen && panel->battery.area.width)
|
}
|
||||||
taskbar_width -= (panel->battery.area.width + panel->area.paddingx);
|
if (a->on_screen && a->size_mode == SIZE_BY_LAYOUT)
|
||||||
#endif
|
nb_by_layout++;
|
||||||
// TODO : systray only on first panel. search better implementation !
|
|
||||||
if (systray.area.on_screen && systray.area.width && panel == &panel1[0])
|
|
||||||
taskbar_width -= (systray.area.width + panel->area.paddingx);
|
|
||||||
|
|
||||||
if (panel_mode == MULTI_DESKTOP) {
|
|
||||||
int width = taskbar_width - ((panel->nb_desktop-1) * panel->area.paddingx);
|
|
||||||
taskbar_width = width / panel->nb_desktop;
|
|
||||||
modulo_width = width % panel->nb_desktop;
|
|
||||||
}
|
}
|
||||||
|
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
|
// change posx and width for all taskbar
|
||||||
int i, posx;
|
int i, posx;
|
||||||
@@ -335,57 +345,55 @@ int resize_panel(void *obj)
|
|||||||
posx += (panel->launcher.area.width + panel->area.paddingx);
|
posx += (panel->launcher.area.width + panel->area.paddingx);
|
||||||
for (i=0 ; i < panel->nb_desktop ; i++) {
|
for (i=0 ; i < panel->nb_desktop ; i++) {
|
||||||
panel->taskbar[i].area.posx = posx;
|
panel->taskbar[i].area.posx = posx;
|
||||||
panel->taskbar[i].area.width = taskbar_width;
|
panel->taskbar[i].area.width = width;
|
||||||
panel->taskbar[i].area.resize = 1;
|
panel->taskbar[i].area.resize = 1;
|
||||||
if (modulo_width) {
|
if (modulo) {
|
||||||
panel->taskbar[i].area.width++;
|
panel->taskbar[i].area.width++;
|
||||||
modulo_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);
|
//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)
|
if (panel_mode == MULTI_DESKTOP)
|
||||||
posx += panel->taskbar[i].area.width + panel->area.paddingx;
|
posx += panel->taskbar[i].area.width + panel->area.paddingx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int taskbar_height, modulo_height = 0;
|
// detect free size for SIZE_BY_LAYOUT's Area
|
||||||
int i, posy;
|
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);
|
||||||
|
|
||||||
taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.bg->border.width);
|
int width=0, modulo=0;
|
||||||
if (panel->clock.area.on_screen && panel->clock.area.height)
|
if (nb_by_layout) {
|
||||||
taskbar_height -= (panel->clock.area.height + panel->area.paddingx);
|
width = size / nb_by_layout;
|
||||||
if (panel->launcher.area.on_screen && panel->launcher.area.height)
|
modulo = size % nb_by_layout;
|
||||||
taskbar_height -= (panel->launcher.area.height + panel->area.paddingx);
|
|
||||||
#ifdef ENABLE_BATTERY
|
|
||||||
if (panel->battery.area.on_screen && panel->battery.area.height)
|
|
||||||
taskbar_height -= (panel->battery.area.height + panel->area.paddingx);
|
|
||||||
#endif
|
|
||||||
// TODO : systray only on first panel. search better implementation !
|
|
||||||
if (systray.area.on_screen && systray.area.height && panel == &panel1[0])
|
|
||||||
taskbar_height -= (systray.area.height + panel->area.paddingx);
|
|
||||||
|
|
||||||
posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - taskbar_height;
|
|
||||||
if (panel->launcher.area.on_screen && panel->launcher.area.height)
|
|
||||||
posy -= (panel->launcher.area.height + panel->area.paddingx);
|
|
||||||
if (panel_mode == MULTI_DESKTOP) {
|
|
||||||
int height = taskbar_height - ((panel->nb_desktop-1) * panel->area.paddingx);
|
|
||||||
taskbar_height = height / panel->nb_desktop;
|
|
||||||
modulo_height = height % panel->nb_desktop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// change posy and height for all taskbar
|
// change posy and height for all taskbar
|
||||||
|
int i, posy;
|
||||||
for (i=0 ; i < panel->nb_desktop ; i++) {
|
for (i=0 ; i < panel->nb_desktop ; i++) {
|
||||||
panel->taskbar[i].area.posy = posy;
|
panel->taskbar[i].area.posy = posy;
|
||||||
panel->taskbar[i].area.height = taskbar_height;
|
panel->taskbar[i].area.height = width;
|
||||||
panel->taskbar[i].area.resize = 1;
|
panel->taskbar[i].area.resize = 1;
|
||||||
if (modulo_height) {
|
if (modulo) {
|
||||||
panel->taskbar[i].area.height++;
|
panel->taskbar[i].area.height++;
|
||||||
modulo_height--;
|
modulo--;
|
||||||
}
|
}
|
||||||
if (panel_mode == MULTI_DESKTOP)
|
if (panel_mode == MULTI_DESKTOP)
|
||||||
posy += panel->taskbar[i].area.height + panel->area.paddingx;
|
posy += panel->taskbar[i].area.height + panel->area.paddingx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ gboolean add_icon(Window id)
|
|||||||
XSetWindowAttributes set_attr;
|
XSetWindowAttributes set_attr;
|
||||||
Visual* visual = server.visual;
|
Visual* visual = server.visual;
|
||||||
//printf("icon with depth: %d, width %d, height %d\n", attr.depth, attr.width, attr.height);
|
//printf("icon with depth: %d, width %d, height %d\n", attr.depth, attr.width, attr.height);
|
||||||
printf("icon with depth: %d\n", attr.depth);
|
//printf("icon with depth: %d\n", attr.depth);
|
||||||
if (attr.depth != server.depth || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
if (attr.depth != server.depth || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
||||||
visual = attr.visual;
|
visual = attr.visual;
|
||||||
set_attr.colormap = attr.colormap;
|
set_attr.colormap = attr.colormap;
|
||||||
|
|||||||
@@ -60,11 +60,6 @@ void init_taskbar()
|
|||||||
for (i=0 ; i < nb_panel ; i++) {
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
panel = &panel1[i];
|
panel = &panel1[i];
|
||||||
|
|
||||||
if (panel->taskbar) {
|
|
||||||
free(panel->taskbar);
|
|
||||||
panel->taskbar = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (panel->g_taskbar.bg == 0) {
|
if (panel->g_taskbar.bg == 0) {
|
||||||
panel->g_taskbar.bg = &g_array_index(backgrounds, Background, 0);
|
panel->g_taskbar.bg = &g_array_index(backgrounds, Background, 0);
|
||||||
panel->g_taskbar.area.bg = panel->g_taskbar.bg;
|
panel->g_taskbar.area.bg = panel->g_taskbar.bg;
|
||||||
@@ -159,17 +154,12 @@ void init_taskbar()
|
|||||||
//printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width);
|
//printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width);
|
||||||
|
|
||||||
Taskbar *tskbar;
|
Taskbar *tskbar;
|
||||||
panel->nb_desktop = server.nb_desktop;
|
|
||||||
panel->taskbar = calloc(panel->nb_desktop, sizeof(Taskbar));
|
|
||||||
for (j=0 ; j < panel->nb_desktop ; j++) {
|
for (j=0 ; j < panel->nb_desktop ; j++) {
|
||||||
tskbar = &panel->taskbar[j];
|
tskbar = &panel->taskbar[j];
|
||||||
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
|
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
|
||||||
tskbar->desktop = j;
|
tskbar->desktop = j;
|
||||||
if (j == server.desktop && panel->g_taskbar.use_active)
|
if (j == server.desktop && panel->g_taskbar.use_active)
|
||||||
tskbar->area.bg = panel->g_taskbar.bg_active;
|
tskbar->area.bg = panel->g_taskbar.bg_active;
|
||||||
|
|
||||||
// add taskbar to the panel
|
|
||||||
panel->area.list = g_slist_append(panel->area.list, tskbar);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user