From: Thierry Lorthiois Date: Tue, 20 Jan 2009 00:19:05 +0000 (+0000) Subject: patch from Robert Escriva and fixed MULTI_MONITOR mode with task_on_all_desktop X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=087b91a75cfdc6203f397cd8dddd9c02df65455f;p=chaz%2Ftint2 patch from Robert Escriva and fixed MULTI_MONITOR mode with task_on_all_desktop --- diff --git a/ChangeLog b/ChangeLog index e48dba3..7e5d991 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/config.c b/src/config.c index 741e12e..acb49e8 100644 --- a/src/config.c +++ b/src/config.c @@ -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; diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 9bfc703..aaebcbf 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -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; } } @@ -102,31 +85,51 @@ void add_task (Window win) 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 (tsk2->title) + free (tsk2->title); + if (tsk2->icon_data) + free (tsk2->icon_data); + + 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; } - if (tsk->icon_data) { - free (tsk->icon_data); - tsk->icon_data = 0; - } - - XFreePixmap (server.dsp, tsk->area.pix.pmap); - XFreePixmap (server.dsp, tsk->area.pix_active.pmap); - free(tsk); } diff --git a/src/tint.c b/src/tint.c index a85771d..e64f8d9 100644 --- a/src/tint.c +++ b/src/tint.c @@ -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; } } diff --git a/src/tint2 b/src/tint2 index 7714670..e441bf4 100755 Binary files a/src/tint2 and b/src/tint2 differ diff --git a/tintrc02 b/tintrc02 index 2cfb910..bd826ac 100644 --- a/tintrc02 +++ b/tintrc02 @@ -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