void init_panel() { if (panel_config.monitor > (server.num_monitors - 1)) { // server.num_monitors minimum value is 1 (see get_monitors()) fprintf(stderr, "warning : monitor not found. tint2 default to all monitors.\n"); panel_config.monitor = 0; } fprintf(stderr, "panel items: %s\n", panel_items_order); init_tooltip(); init_systray(); init_launcher(); init_clock(); #ifdef ENABLE_BATTERY init_battery(); #endif init_taskbar(); init_separator(); init_execp(); // number of panels (one monitor or 'all' monitors) if (panel_config.monitor >= 0) num_panels = 1; else num_panels = server.num_monitors; panels = calloc(num_panels, sizeof(Panel)); for (int i = 0; i < num_panels; i++) { memcpy(&panels[i], &panel_config, sizeof(Panel)); panels[i].area.gradients = g_list_copy(panel_config.area.gradients); } fprintf(stderr, "tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n", server.num_monitors, num_panels, server.num_desktops); for (int i = 0; i < num_panels; i++) { Panel *p = &panels[i]; if (panel_config.monitor < 0) p->monitor = i; if (!p->area.bg) p->area.bg = &g_array_index(backgrounds, Background, 0); p->area.parent = p; p->area.panel = p; snprintf(p->area.name, sizeof(p->area.name), "Panel %d", i); p->area.on_screen = TRUE; p->area.resize_needed = 1; p->area.size_mode = LAYOUT_DYNAMIC; p->area._resize = resize_panel; p->area._clear = panel_clear_background; p->separator_list = NULL; init_panel_size_and_position(p); instantiate_area_gradients(&p->area); // add children according to panel_items for (int 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' && systray_on_monitor(i, num_panels)) { init_systray_panel(p); refresh_systray = 1; } if (panel_items_order[k] == 'C') init_clock_panel(p); if (panel_items_order[k] == 'F' && !strstr(panel_items_order, "T")) init_freespace_panel(p); if (panel_items_order[k] == ':') init_separator_panel(p); if (panel_items_order[k] == 'E') init_execp_panel(p); } set_panel_items_order(p); // catch some events XSetWindowAttributes att = {.colormap = server.colormap, .background_pixel = 0, .border_pixel = 0}; unsigned long mask = CWEventMask | CWColormap | CWBackPixel | CWBorderPixel; p->main_win = XCreateWindow(server.display, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, server.visual, mask, &att); long event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PropertyChangeMask; if (p->mouse_effects || p->g_task.tooltip_enabled || p->clock.area._get_tooltip_text || (launcher_enabled && launcher_tooltip_enabled)) event_mask |= PointerMotionMask | LeaveWindowMask; if (panel_autohide) event_mask |= LeaveWindowMask | EnterWindowMask; XChangeWindowAttributes(server.display, p->main_win, CWEventMask, &(XSetWindowAttributes){.event_mask = event_mask}); if (!server.gc) { XGCValues gcv; server.gc = XCreateGC(server.display, p->main_win, 0, &gcv); } // printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height); set_panel_properties(p); set_panel_background(p); if (!snapshot_path) { // if we are not in 'snapshot' mode then map new panel XMapWindow(server.display, p->main_win); } if (panel_autohide) autohide_trigger_hide(p); } taskbar_refresh_tasklist(); reset_active_task(); update_all_taskbars_visibility(); }
void init_panel() { int i, k; Panel *p; if (panel_config.monitor > (server.nb_monitor-1)) { // server.nb_monitor minimum value is 1 (see get_monitors()) fprintf(stderr, "warning : monitor not found. tint2 default to all monitors.\n"); panel_config.monitor = 0; } init_tooltip(); init_systray(); init_launcher(); init_clock(); #ifdef ENABLE_BATTERY init_battery(); #endif init_taskbar(); // number of panels (one monitor or 'all' monitors) if (panel_config.monitor >= 0) nb_panel = 1; else nb_panel = server.nb_monitor; panel1 = calloc(nb_panel, sizeof(Panel)); for (i=0 ; i < nb_panel ; i++) { memcpy(&panel1[i], &panel_config, sizeof(Panel)); } fprintf(stderr, "tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n", server.nb_monitor, nb_panel, server.nb_desktop); for (i=0 ; i < nb_panel ; i++) { p = &panel1[i]; if (panel_config.monitor < 0) p->monitor = i; if (!p->area.bg) p->area.bg = &g_array_index(backgrounds, Background, 0); p->area.parent = p; p->area.panel = p; p->area.on_screen = 1; p->area.resize = 1; p->area.size_mode = SIZE_BY_LAYOUT; p->area._resize = resize_panel; init_panel_size_and_position(p); // add childs according to panel_items 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' && systray_on_monitor(i, nb_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 }; unsigned long mask = CWEventMask|CWColormap|CWBackPixel|CWBorderPixel; p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, server.visual, mask, &att); long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask; if (p->g_task.tooltip_enabled || p->clock.area._get_tooltip_text || (launcher_enabled && launcher_tooltip_enabled)) event_mask |= PointerMotionMask|LeaveWindowMask; if (panel_autohide) event_mask |= LeaveWindowMask|EnterWindowMask; XChangeWindowAttributes(server.dsp, p->main_win, CWEventMask, &(XSetWindowAttributes){.event_mask=event_mask}); if (!server.gc) { XGCValues gcv; server.gc = XCreateGC(server.dsp, p->main_win, 0, &gcv); } //printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height); set_panel_properties(p); set_panel_background(p); if (snapshot_path == 0) { // if we are not in 'snapshot' mode then map new panel XMapWindow (server.dsp, p->main_win); } if (panel_autohide) autohide_trigger_hide(p); visible_taskbar(p); } task_refresh_tasklist(); active_task(); }