X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fpanel.c;h=9faa33a2ede8054c1a4edbf7c833ae68d0b0df2f;hb=bf2a3e4f8b4160e4cc719b2bfbf2e6551812dbd9;hp=adc6520199cf7f306017d97b497fa52dc77aee4f;hpb=c3e588a8426c1257c127e0aca79aab53bb9961b1;p=chaz%2Ftint2 diff --git a/src/panel.c b/src/panel.c index adc6520..9faa33a 100644 --- a/src/panel.c +++ b/src/panel.c @@ -55,6 +55,9 @@ Task *task_urgent; int tick_urgent; int max_tick_urgent; +// panel's initial config +Panel panel_config; +// panels (one panel per monitor) Panel *panel1 = 0; int nb_panel; @@ -77,9 +80,20 @@ void init_panel() g_free(path); } + //if (panel1) + // free(panel1); + // alloc panels (one monitor or all monitors) + if (panel_config.monitor >= 0) + nb_panel = 1; + else + nb_panel = server.nb_monitor; + panel1 = malloc(nb_panel * sizeof(Panel)); + for (i=0 ; i < nb_panel ; i++) { p = &panel1[i]; + memcpy(p, &panel_config, sizeof(Panel)); + p->monitor = i; p->area.parent = p; p->area.panel = p; p->area.on_screen = 1; @@ -106,59 +120,7 @@ void init_panel() p->pourcentx = 1; } - // detect panel size - if (panel_horizontal) { - if (p->pourcentx) - p->area.width = (float)server.monitor[p->monitor].width * p->initial_width / 100; - else - p->area.width = p->initial_width; - if (p->pourcenty) - p->area.height = (float)server.monitor[p->monitor].height * p->initial_height / 100; - else - p->area.height = p->initial_height; - if (p->area.pix.border.rounded > p->area.height/2) - p->area.pix.border.rounded = p->area.height/2; - } - else { - if (p->pourcentx) - p->area.height = (float)server.monitor[p->monitor].height * p->initial_width / 100; - else - p->area.height = p->initial_width; - if (p->pourcenty) - p->area.width = (float)server.monitor[p->monitor].width * p->initial_height / 100; - else - p->area.width = p->initial_height; - if (p->area.pix.border.rounded > p->area.width/2) - p->area.pix.border.rounded = p->area.width/2; - } - - /* panel position determined here */ - if (panel_position & LEFT) { - p->posx = server.monitor[p->monitor].x + p->marginx; - } - else { - if (panel_position & RIGHT) { - p->posx = server.monitor[p->monitor].x + server.monitor[p->monitor].width - p->area.width - p->marginx; - } - else { - if (panel_horizontal) - p->posx = server.monitor[p->monitor].x + ((server.monitor[p->monitor].width - p->area.width) / 2); - else - p->posx = server.monitor[p->monitor].x + p->marginx; - } - } - if (panel_position & TOP) { - p->posy = server.monitor[p->monitor].y + p->marginy; - } - else { - if (panel_position & BOTTOM) { - p->posy = server.monitor[p->monitor].y + server.monitor[p->monitor].height - p->area.height - p->marginy; - } - else { - p->posy = server.monitor[p->monitor].y + ((server.monitor[p->monitor].height - p->area.height) / 2); - } - } - // printf("panel : posx %d, posy %d, width %d, height %d\n", p->posx, p->posy, p->area.width, p->area.height); + init_panel_size_and_position(p); // Catch some events long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask; @@ -177,6 +139,64 @@ void init_panel() } +void init_panel_size_and_position(Panel *panel) +{ + // detect panel size + if (panel_horizontal) { + if (panel->pourcentx) + panel->area.width = (float)server.monitor[panel->monitor].width * panel->initial_width / 100; + else + panel->area.width = panel->initial_width; + if (panel->pourcenty) + panel->area.height = (float)server.monitor[panel->monitor].height * panel->initial_height / 100; + else + panel->area.height = panel->initial_height; + if (panel->area.pix.border.rounded > panel->area.height/2) + panel->area.pix.border.rounded = panel->area.height/2; + } + else { + if (panel->pourcentx) + panel->area.height = (float)server.monitor[panel->monitor].height * panel->initial_width / 100; + else + panel->area.height = panel->initial_width; + if (panel->pourcenty) + panel->area.width = (float)server.monitor[panel->monitor].width * panel->initial_height / 100; + else + panel->area.width = panel->initial_height; + if (panel->area.pix.border.rounded > panel->area.width/2) + panel->area.pix.border.rounded = panel->area.width/2; + } + + // panel position determined here + if (panel_position & LEFT) { + panel->posx = server.monitor[panel->monitor].x + panel->marginx; + } + else { + if (panel_position & RIGHT) { + panel->posx = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width - panel->area.width - panel->marginx; + } + else { + if (panel_horizontal) + panel->posx = server.monitor[panel->monitor].x + ((server.monitor[panel->monitor].width - panel->area.width) / 2); + else + panel->posx = server.monitor[panel->monitor].x + panel->marginx; + } + } + if (panel_position & TOP) { + panel->posy = server.monitor[panel->monitor].y + panel->marginy; + } + else { + if (panel_position & BOTTOM) { + panel->posy = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height - panel->area.height - panel->marginy; + } + else { + panel->posy = server.monitor[panel->monitor].y + ((server.monitor[panel->monitor].height - panel->area.height) / 2); + } + } + // printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, panel->area.height); +} + + void cleanup_panel() { if (!panel1) return;