big change : panel_monitor = all will draw one panel per monitor, panel_size accept percentage or pixel, update documentation, taskbar_mode = single_monitor show tasks of current monitor
git-svn-id: http://tint2.googlecode.com/svn/trunk@32 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <glib.h>
|
||||
#include <Imlib2.h>
|
||||
|
||||
#include "task.h"
|
||||
#include "taskbar.h"
|
||||
#include "server.h"
|
||||
#include "window.h"
|
||||
@@ -33,19 +34,106 @@
|
||||
|
||||
|
||||
|
||||
void init_taskbar()
|
||||
{
|
||||
Panel *panel;
|
||||
int i, j;
|
||||
|
||||
for (i=0 ; i < nb_panel ; i++) {
|
||||
panel = &panel1[i];
|
||||
|
||||
// taskbar
|
||||
panel->g_taskbar.posy = panel->area.pix.border.width + panel->area.paddingy;
|
||||
panel->g_taskbar.height = panel->area.height - (2 * panel->g_taskbar.posy);
|
||||
panel->g_taskbar.redraw = 1;
|
||||
|
||||
// task
|
||||
panel->g_task.area.draw_foreground = draw_foreground_task;
|
||||
panel->g_task.area.posy = panel->g_taskbar.posy + panel->g_taskbar.pix.border.width + panel->g_taskbar.paddingy;
|
||||
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
|
||||
panel->g_task.area.use_active = 1;
|
||||
panel->g_task.area.redraw = 1;
|
||||
|
||||
if (panel->g_task.area.pix.border.rounded > panel->g_task.area.height/2) {
|
||||
panel->g_task.area.pix.border.rounded = panel->g_task.area.height/2;
|
||||
panel->g_task.area.pix_active.border.rounded = panel->g_task.area.pix.border.rounded;
|
||||
}
|
||||
|
||||
// compute vertical position : text and icon
|
||||
int height_ink, height;
|
||||
get_text_size(panel->g_task.font_desc, &height_ink, &height, panel->area.height, "TAjpg", 5);
|
||||
|
||||
if (!panel->g_task.maximum_width)
|
||||
panel->g_task.maximum_width = server.monitor[panel->monitor].width;
|
||||
|
||||
// add task_icon_size
|
||||
panel->g_task.text_posx = panel->g_task.area.paddingxlr + panel->g_task.area.pix.border.width;
|
||||
panel->g_task.text_posy = (panel->g_task.area.height - height) / 2.0;
|
||||
if (panel->g_task.icon) {
|
||||
panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
|
||||
panel->g_task.text_posx += panel->g_task.icon_size1;
|
||||
panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
|
||||
}
|
||||
//printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width);
|
||||
|
||||
Taskbar *tskbar;
|
||||
panel->nb_desktop = server.nb_desktop;
|
||||
panel->taskbar = calloc(panel->nb_desktop, sizeof(Taskbar));
|
||||
for (j=0 ; j < panel->nb_desktop ; j++) {
|
||||
tskbar = &panel->taskbar[j];
|
||||
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
|
||||
tskbar->desktop = j;
|
||||
}
|
||||
|
||||
resize_taskbar(panel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void cleanup_taskbar()
|
||||
{
|
||||
Panel *panel;
|
||||
int i, j;
|
||||
GSList *l0;
|
||||
Task *tsk;
|
||||
|
||||
for (i=0 ; i < nb_panel ; i++) {
|
||||
panel = &panel1[i];
|
||||
if (!panel->taskbar) continue;
|
||||
|
||||
for (j=0 ; j < panel->nb_desktop ; j++) {
|
||||
l0 = panel->taskbar[j].area.list;
|
||||
while (l0) {
|
||||
tsk = l0->data;
|
||||
l0 = l0->next;
|
||||
// careful : remove_task change l0->next
|
||||
remove_task (tsk);
|
||||
}
|
||||
|
||||
free_area (&panel->taskbar[j].area);
|
||||
}
|
||||
|
||||
free(panel->taskbar);
|
||||
panel->taskbar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Task *task_get_task (Window win)
|
||||
{
|
||||
Task *tsk;
|
||||
GSList *l0;
|
||||
int i, nb;
|
||||
int i, j;
|
||||
|
||||
nb = panel.nb_desktop * panel.nb_monitor;
|
||||
for (i=0 ; i < nb ; i++) {
|
||||
for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
|
||||
tsk = l0->data;
|
||||
if (win == tsk->win)
|
||||
return tsk;
|
||||
}
|
||||
for (i=0 ; i < nb_panel ; i++) {
|
||||
for (j=0 ; j < panel1[i].nb_desktop ; j++) {
|
||||
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
|
||||
tsk = l0->data;
|
||||
if (win == tsk->win)
|
||||
return tsk;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -54,7 +142,7 @@ Task *task_get_task (Window win)
|
||||
void task_refresh_tasklist ()
|
||||
{
|
||||
Window *win, active_win;
|
||||
int num_results, i, j, nb;
|
||||
int num_results, i, j, k;
|
||||
GSList *l0;
|
||||
Task *tsk;
|
||||
|
||||
@@ -64,29 +152,30 @@ void task_refresh_tasklist ()
|
||||
|
||||
// Remove any old and set active win
|
||||
active_win = window_get_active ();
|
||||
if (panel.task_active) {
|
||||
panel.task_active->area.is_active = 0;
|
||||
panel.task_active = 0;
|
||||
if (task_active) {
|
||||
task_active->area.is_active = 0;
|
||||
task_active = 0;
|
||||
}
|
||||
|
||||
nb = panel.nb_desktop * panel.nb_monitor;
|
||||
for (i=0 ; i < nb ; i++) {
|
||||
l0 = panel.taskbar[i].area.list;
|
||||
while (l0) {
|
||||
tsk = l0->data;
|
||||
l0 = l0->next;
|
||||
for (i=0 ; i < nb_panel ; i++) {
|
||||
for (j=0 ; j < panel1[i].nb_desktop ; j++) {
|
||||
l0 = panel1[i].taskbar[j].area.list;
|
||||
while (l0) {
|
||||
tsk = l0->data;
|
||||
l0 = l0->next;
|
||||
|
||||
if (tsk->win == active_win) {
|
||||
tsk->area.is_active = 1;
|
||||
panel.task_active = tsk;
|
||||
if (tsk->win == active_win) {
|
||||
tsk->area.is_active = 1;
|
||||
task_active = tsk;
|
||||
}
|
||||
|
||||
for (k = 0; k < num_results; k++) {
|
||||
if (tsk->win == win[k]) break;
|
||||
}
|
||||
// careful : remove_task change l0->next
|
||||
if (tsk->win != win[k]) remove_task (tsk);
|
||||
}
|
||||
|
||||
for (j = 0; j < num_results; j++) {
|
||||
if (tsk->win == win[j]) break;
|
||||
}
|
||||
// careful : remove_task change l0->next
|
||||
if (tsk->win != win[j]) remove_task (tsk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add any new
|
||||
@@ -103,19 +192,23 @@ int resize_tasks (Taskbar *taskbar)
|
||||
int ret, task_count, pixel_width, modulo_width=0;
|
||||
int x, taskbar_width;
|
||||
Task *tsk;
|
||||
Panel *panel = (Panel*)taskbar->area.panel;
|
||||
GSList *l;
|
||||
|
||||
// new task width for 'desktop'
|
||||
task_count = g_slist_length(taskbar->area.list);
|
||||
if (!task_count) pixel_width = g_task.maximum_width;
|
||||
if (!task_count) pixel_width = panel->g_task.maximum_width;
|
||||
else {
|
||||
taskbar_width = taskbar->area.width - (2 * g_taskbar.pix.border.width) - (2 * g_taskbar.paddingxlr);
|
||||
if (task_count>1) taskbar_width -= ((task_count-1) * g_taskbar.paddingx);
|
||||
taskbar_width = taskbar->area.width - (2 * panel->g_taskbar.pix.border.width) - (2 * panel->g_taskbar.paddingxlr);
|
||||
if (task_count>1) taskbar_width -= ((task_count-1) * panel->g_taskbar.paddingx);
|
||||
|
||||
pixel_width = taskbar_width / task_count;
|
||||
if (pixel_width > g_task.maximum_width) pixel_width = g_task.maximum_width;
|
||||
else modulo_width = taskbar_width % task_count;
|
||||
if (pixel_width > panel->g_task.maximum_width)
|
||||
pixel_width = panel->g_task.maximum_width;
|
||||
else
|
||||
modulo_width = taskbar_width % task_count;
|
||||
}
|
||||
//printf("monitor %d, resize_tasks %d %d\n", panel->monitor, task_count, pixel_width);
|
||||
|
||||
if ((taskbar->task_width == pixel_width) && (taskbar->task_modulo == modulo_width)) {
|
||||
ret = 0;
|
||||
@@ -124,7 +217,7 @@ int resize_tasks (Taskbar *taskbar)
|
||||
ret = 1;
|
||||
taskbar->task_width = pixel_width;
|
||||
taskbar->task_modulo = modulo_width;
|
||||
taskbar->text_width = pixel_width - g_task.text_posx - g_task.area.pix.border.width - g_task.area.paddingx;
|
||||
taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx;
|
||||
}
|
||||
|
||||
// change pos_x and width for all tasks
|
||||
@@ -138,47 +231,47 @@ int resize_tasks (Taskbar *taskbar)
|
||||
modulo_width--;
|
||||
}
|
||||
|
||||
x += tsk->area.width + g_taskbar.paddingx;
|
||||
x += tsk->area.width + panel->g_taskbar.paddingx;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// initialise taskbar posx and width
|
||||
void resize_taskbar()
|
||||
void resize_taskbar(void *p)
|
||||
{
|
||||
Panel *panel = p;
|
||||
int taskbar_width, modulo_width, taskbar_on_screen;
|
||||
|
||||
if (panel.mode == MULTI_DESKTOP) taskbar_on_screen = panel.nb_desktop;
|
||||
else taskbar_on_screen = panel.nb_monitor;
|
||||
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);
|
||||
taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
|
||||
if (time1_format)
|
||||
taskbar_width -= (panel.clock.area.width + panel.area.paddingx);
|
||||
taskbar_width = (taskbar_width - ((taskbar_on_screen-1) * panel.area.paddingx)) / taskbar_on_screen;
|
||||
taskbar_width -= (panel->clock.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;
|
||||
modulo_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) % taskbar_on_screen;
|
||||
else
|
||||
modulo_width = 0;
|
||||
|
||||
int i, nb, modulo=0, posx=0;
|
||||
nb = panel.nb_desktop * panel.nb_monitor;
|
||||
for (i=0 ; i < nb ; i++) {
|
||||
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;
|
||||
posx = panel->area.pix.border.width + panel->area.paddingxlr;
|
||||
modulo = modulo_width;
|
||||
}
|
||||
else posx += taskbar_width + panel.area.paddingx;
|
||||
else posx += taskbar_width + panel->area.paddingx;
|
||||
|
||||
panel.taskbar[i].area.posx = posx;
|
||||
panel.taskbar[i].area.width = taskbar_width;
|
||||
panel->taskbar[i].area.posx = posx;
|
||||
panel->taskbar[i].area.width = taskbar_width;
|
||||
if (modulo) {
|
||||
panel.taskbar[i].area.width++;
|
||||
panel->taskbar[i].area.width++;
|
||||
modulo--;
|
||||
}
|
||||
|
||||
resize_tasks(&panel.taskbar[i]);
|
||||
resize_tasks(&panel->taskbar[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user