patch from Robert Escriva and fixed MULTI_MONITOR mode with task_on_all_desktop

git-svn-id: http://tint2.googlecode.com/svn/trunk@27 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2009-01-20 00:19:05 +00:00
parent d818e66097
commit 024e8fb1f3
6 changed files with 69 additions and 79 deletions

View file

@ -1,4 +1,8 @@
2009-01-19
- patch from Robert Escriva, fixed tint2 on multi-monitor
- fixed bug between MULTI_MONITOR mode and 'task on all desktop'
2009-01-18
- update documentation for new config format
- fixed memory corruption

View file

@ -529,7 +529,7 @@ void config_finish ()
fprintf(stderr, "tint2 error : invalid monitor size.\n");
}
if (!panel.area.width) panel.area.width = server.monitor[panel.monitor].width;
if (!panel.area.width) panel.area.width = server.monitor[panel.monitor].width - 1;
// taskbar
g_taskbar.posy = panel.area.pix.border.width + panel.area.paddingy;

View file

@ -37,64 +37,47 @@
void add_task (Window win)
{
Task *new_tsk;
int desktop, monitor;
int desktop, monitor, all_desktop;
if (!win) return;
if (window_is_hidden (win) || win == window.main_win) return;
desktop = window_get_desktop (win);
if (desktop == 0xFFFFFFFF) {
desktop = 0;
all_desktop = 1;
}
else
all_desktop = 0;
if (panel.mode == MULTI_MONITOR) monitor = window_get_monitor (win);
else monitor = 0;
deb:
new_tsk = malloc(sizeof(Task));
new_tsk->win = win;
new_tsk->all_desktop = all_desktop;
new_tsk->title = 0;
new_tsk->icon_data = 0;
get_icon(new_tsk);
get_title(new_tsk);
memcpy(&new_tsk->area, &g_task.area, sizeof(Area));
desktop = window_get_desktop (new_tsk->win);
monitor = window_get_monitor (new_tsk->win);
//if (panel.mode == MULTI_MONITOR) monitor = window_get_monitor (new_tsk->win);
//else monitor = 0;
//printf("task %s : desktop %d, monitor %d\n", new_tsk->title, desktop, monitor);
XSelectInput (server.dsp, new_tsk->win, PropertyChangeMask|StructureNotifyMask);
Taskbar *tskbar;
if (desktop == 0xFFFFFFFF) {
tskbar = &panel.taskbar[index(0, monitor)];
new_tsk->all_desktop = 1;
}
else {
tskbar = &panel.taskbar[index(desktop, monitor)];
new_tsk->all_desktop = 0;
}
//printf("add_task %d %s\n", index(desktop, monitor), new_tsk->title);
Taskbar *tskbar = &panel.taskbar[index(desktop, monitor)];
new_tsk->area.parent = tskbar;
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk);
if (resize_tasks (tskbar))
set_redraw (&tskbar->area);
if (desktop == 0xFFFFFFFF) {
// task on all desktop
int i;
Task *new_tsk2;
for (i = 1 ; i < server.nb_desktop ; i++) {
new_tsk2 = malloc(sizeof(Task));
memcpy(new_tsk2, new_tsk, sizeof(Task));
new_tsk2->title = 0;
new_tsk2->icon_data = 0;
get_icon(new_tsk2);
get_title(new_tsk2);
tskbar = &panel.taskbar[index(i, monitor)];
new_tsk2->area.parent = tskbar;
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2);
if (resize_tasks (tskbar))
set_redraw (&tskbar->area);
}
if (all_desktop) {
desktop++;
if (desktop < server.nb_desktop)
goto deb;
}
}
@ -103,30 +86,50 @@ void remove_task (Task *tsk)
{
if (!tsk) return;
Task *tsk2 = tsk;
Taskbar *tskbar;
tskbar = (Taskbar*)tsk->area.parent;
tskbar->area.list = g_slist_remove(tskbar->area.list, tsk);
Window win = tsk->win;
int desktop = 0, all_desktop = tsk->all_desktop;
int monitor = ((Taskbar*)tsk->area.parent)->monitor;
deb:
if (all_desktop) {
tskbar = &panel.taskbar[index(desktop, monitor)];
GSList *l0;
for (l0 = tskbar->area.list; l0 ; ) {
tsk2 = l0->data;
l0 = l0->next;
if (win == tsk2->win)
break;
}
}
else
tskbar = (Taskbar*)tsk->area.parent;
tskbar->area.list = g_slist_remove(tskbar->area.list, tsk2);
resize_tasks (tskbar);
set_redraw (&tskbar->area);
//printf("remove_task %d %s\n", index(tskbar->desktop, tskbar->monitor), tsk->title);
if (tsk == panel.task_active)
if (tsk2 == panel.task_active)
panel.task_active = 0;
if (tsk == panel.task_drag)
if (tsk2 == panel.task_drag)
panel.task_drag = 0;
if (tsk->title) {
free (tsk->title);
tsk->title = 0;
}
if (tsk->icon_data) {
free (tsk->icon_data);
tsk->icon_data = 0;
}
if (tsk2->title)
free (tsk2->title);
if (tsk2->icon_data)
free (tsk2->icon_data);
XFreePixmap (server.dsp, tsk->area.pix.pmap);
XFreePixmap (server.dsp, tsk->area.pix_active.pmap);
free(tsk);
XFreePixmap (server.dsp, tsk2->area.pix.pmap);
XFreePixmap (server.dsp, tsk2->area.pix_active.pmap);
free(tsk2);
if (all_desktop) {
desktop++;
if (desktop < server.nb_desktop)
goto deb;
}
}

View file

@ -364,23 +364,7 @@ void event_property_notify (Window win, Atom at)
}
/* Window desktop changed */
else if (at == server.atom._NET_WM_DESKTOP) {
Window win2 = tsk->win;
if (tsk->all_desktop) {
Task *tsk2;
GSList *l0;
int i, nb;
nb = server.nb_desktop * server.nb_monitor;
for (i=0 ; i < nb ; i++) {
for (l0 = panel.taskbar[i].area.list; l0 ; ) {
tsk2 = l0->data;
l0 = l0->next;
if (win2 == tsk2->win)
remove_task (tsk2);
}
}
}
else
remove_task (tsk);
remove_task (tsk);
add_task (win);
panel.refresh = 1;
}
@ -392,16 +376,16 @@ void event_property_notify (Window win, Atom at)
void event_configure_notify (Window win)
{
Task *tsk;
if (panel.mode != MULTI_MONITOR) return;
tsk = task_get_task (win);
Task *tsk = task_get_task (win);
if (!tsk) return;
Taskbar *tskbar = tsk->area.parent;
if (tskbar->monitor != window_get_monitor (win)) {
// task on another monitor
add_task (tsk->win);
remove_task (tsk);
add_task (win);
panel.refresh = 1;
}
}
@ -499,8 +483,7 @@ load_config:
if (e.xconfigure.window == server.root_win)
goto load_config;
else
if (panel.mode == MULTI_MONITOR)
event_configure_notify (e.xconfigure.window);
event_configure_notify (e.xconfigure.window);
break;
}
}

BIN
src/tint2

Binary file not shown.

View file

@ -19,8 +19,8 @@ border_color = #cccccc 40
# PANEL
#---------------------------------------------
panel_monitor = 1
panel_position = top right
panel_size = 600 27
panel_position = bottom left
panel_size = 0 27
panel_margin = 0 0
panel_padding = 4 0
font_shadow = 0
@ -29,7 +29,7 @@ panel_background_id = 1
#---------------------------------------------
# TASKBAR
#---------------------------------------------
taskbar_mode = multi_desktop
taskbar_mode = multi_monitor
taskbar_padding = 4 0
taskbar_background_id = 0