X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fpanel.c;h=0a43d7f833d6f8cbb2acbe7b9002616923e3f028;hb=ee8eefd5400319f8ceafbe00c6ef9ae112306bb4;hp=c3c58032a894f3fe1fc1fd6861123665224ea5c1;hpb=346e19cf9cc32f56221ae0e9dc25070cefedb5be;p=chaz%2Ftint2 diff --git a/src/panel.c b/src/panel.c index c3c5803..0a43d7f 100644 --- a/src/panel.c +++ b/src/panel.c @@ -38,13 +38,20 @@ int mouse_middle; int mouse_right; int mouse_scroll_up; int mouse_scroll_down; +int mouse_tilt_left; +int mouse_tilt_right; int panel_mode; +int wm_menu; int panel_position; +int panel_horizontal; int panel_refresh; -Task *task_active = 0; -Task *task_drag = 0; +Task *task_active; +Task *task_drag; +Task *task_urgent; +int tick_urgent; +int max_tick_urgent; Panel *panel1 = 0; int nb_panel; @@ -61,7 +68,7 @@ void init_panel() p->area.parent = p; p->area.panel = p; - p->area.visible = 1; + p->area.on_screen = 1; p->area.resize = 1; p->area._resize = resize_panel; p->g_taskbar.parent = p; @@ -69,29 +76,47 @@ void init_panel() p->g_task.area.panel = p; // add childs - if (p->clock.area.visible) + if (p->clock.area.on_screen) p->area.list = g_slist_append(p->area.list, &p->clock); - if (systray.area.visible && i == 0) { - // systray only on first panel +#ifdef ENABLE_BATTERY + if (p->battery.area.on_screen) + p->area.list = g_slist_append(p->area.list, &p->battery); +#endif + // systray only on first panel + if (systray.area.on_screen && i == 0) p->area.list = g_slist_append(p->area.list, &systray); - } - - // detect panel size - 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; // full width mode - if (!p->area.width) - p->area.width = server.monitor[p->monitor].width; + if (!p->initial_width) { + p->initial_width = 100; + p->pourcentx = 1; + } - if (p->area.pix.border.rounded > p->area.height/2) - p->area.pix.border.rounded = p->area.height/2; + // 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) { @@ -102,23 +127,28 @@ void init_panel() p->posx = server.monitor[p->monitor].x + server.monitor[p->monitor].width - p->area.width - p->marginx; } else { - p->posx = server.monitor[p->monitor].x + ((server.monitor[p->monitor].width - p->area.width) / 2); + 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 { - p->posy = server.monitor[p->monitor].y + server.monitor[p->monitor].height - p->area.height - p->marginy; + 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); // Catch some events XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 }; - - // XCreateWindow(display, parent, x, y, w, h, border, depth, class, visual, mask, attrib) - // main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right. if (p->main_win) XDestroyWindow(server.dsp, p->main_win); - //win = XCreateWindow (server.dsp, server.root_win, p->posx+p->area.paddingxlr, p->posy, p->area.width-(2*p->area.paddingxlr), p->area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att); p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att); set_panel_properties(p); @@ -134,6 +164,10 @@ void cleanup_panel() { if (!panel1) return; + task_active = 0; + task_drag = 0; + task_urgent = 0; + cleanup_systray(); cleanup_taskbar(); // font allocated once @@ -169,43 +203,78 @@ void cleanup_panel() void resize_panel(void *obj) { Panel *panel = (Panel*)obj; - int taskbar_width, modulo_width, taskbar_on_screen; - -//printf("resize_panel : : posx et width des barres de taches\n"); - - if (panel_mode == MULTI_DESKTOP) taskbar_on_screen = panel->nb_desktop; - else taskbar_on_screen = 1; - - taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); - if (panel->clock.area.visible && panel->clock.area.width) - taskbar_width -= (panel->clock.area.width + panel->area.paddingx); - if (systray.area.visible && systray.area.width) - taskbar_width -= (systray.area.width + panel->area.paddingx); - - taskbar_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) / taskbar_on_screen; - - if (taskbar_on_screen > 1) - modulo_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) % taskbar_on_screen; - else - modulo_width = 0; - - // change posx and width for all taskbar - int i, modulo=0, posx=0; - for (i=0 ; i < panel->nb_desktop ; i++) { - if ((i % taskbar_on_screen) == 0) { - posx = panel->area.pix.border.width + panel->area.paddingxlr; - modulo = modulo_width; - } - else posx += taskbar_width + panel->area.paddingx; - - panel->taskbar[i].area.posx = posx; - panel->taskbar[i].area.width = taskbar_width; - panel->taskbar[i].area.resize = 1; - if (modulo) { - panel->taskbar[i].area.width++; - modulo--; - } - } + + if (panel_horizontal) { + int taskbar_width, modulo_width = 0; + + taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); + if (panel->clock.area.on_screen && panel->clock.area.width) + taskbar_width -= (panel->clock.area.width + panel->area.paddingx); + #ifdef ENABLE_BATTERY + if (panel->battery.area.on_screen && panel->battery.area.width) + taskbar_width -= (panel->battery.area.width + panel->area.paddingx); + #endif + // 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; + } + + // change posx and width for all taskbar + int i, posx; + posx = panel->area.pix.border.width + panel->area.paddingxlr; + for (i=0 ; i < panel->nb_desktop ; i++) { + panel->taskbar[i].area.posx = posx; + panel->taskbar[i].area.width = taskbar_width; + panel->taskbar[i].area.resize = 1; + if (modulo_width) { + panel->taskbar[i].area.width++; + modulo_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 { + int taskbar_height, modulo_height = 0; + int i, posy; + + taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); + if (panel->clock.area.on_screen && panel->clock.area.height) + taskbar_height -= (panel->clock.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.pix.border.width - panel->area.paddingxlr - taskbar_height; + 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 + for (i=0 ; i < panel->nb_desktop ; i++) { + panel->taskbar[i].area.posy = posy; + panel->taskbar[i].area.height = taskbar_height; + panel->taskbar[i].area.resize = 1; + if (modulo_height) { + panel->taskbar[i].area.height++; + modulo_height--; + } + if (panel_mode == MULTI_DESKTOP) + posy += panel->taskbar[i].area.height + panel->area.paddingx; + } + } } @@ -221,11 +290,11 @@ void visible_object() for (j=0 ; j < panel->nb_desktop ; j++) { taskbar = &panel->taskbar[j]; if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) { - // (SINGLE_DESKTOP or SINGLE_MONITOR) and not current desktop - taskbar->area.visible = 0; + // SINGLE_DESKTOP and not current desktop + taskbar->area.on_screen = 0; } else { - taskbar->area.visible = 1; + taskbar->area.on_screen = 1; } } } @@ -251,18 +320,34 @@ void set_panel_properties(Panel *p) // Reserved space long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (panel_position & TOP) { - struts[2] = p->area.height + p->marginy; - struts[8] = p->posx; - // p->area.width - 1 allowed full screen on monitor 2 - struts[9] = p->posx + p->area.width - 1; - } - else { - struts[3] = p->area.height + p->marginy; - struts[10] = p->posx; - // p->area.width - 1 allowed full screen on monitor 2 - struts[11] = p->posx + p->area.width - 1; - } + if (panel_horizontal) { + if (panel_position & TOP) { + struts[2] = p->area.height + p->marginy; + struts[8] = p->posx; + // p->area.width - 1 allowed full screen on monitor 2 + struts[9] = p->posx + p->area.width - 1; + } + else { + struts[3] = p->area.height + p->marginy; + struts[10] = p->posx; + // p->area.width - 1 allowed full screen on monitor 2 + struts[11] = p->posx + p->area.width - 1; + } + } + else { + if (panel_position & LEFT) { + struts[0] = p->area.width + p->marginx; + struts[4] = p->posy; + // p->area.width - 1 allowed full screen on monitor 2 + struts[5] = p->posy + p->area.height - 1; + } + else { + struts[1] = p->area.width + p->marginx; + struts[6] = p->posy; + // p->area.width - 1 allowed full screen on monitor 2 + struts[7] = p->posy + p->area.height - 1; + } + } // Old specification : fluxbox need _NET_WM_STRUT. XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4); XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12);