fixed bugs with new design (first step)

git-svn-id: http://tint2.googlecode.com/svn/trunk@18 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2008-11-08 20:23:42 +00:00
parent f327e045c6
commit b1c239db22
15 changed files with 215 additions and 220 deletions

View file

@ -1,7 +1,13 @@
2008-11-02
- fixed bugs with new design
- panel.area manage the tree of visible objects
2008-10-28 2008-10-28
- fixed issue : "untitled task", "task button did not update", "window don't shade", - fixed issue : "untitled task", "task button did not update", "window don't shade",
"error if I don't do 'make install", "Makefile error" "error if I don't do 'make install'", "Makefile error"
2008-09-24 2008-09-24
- change tintrc format - change tintrc format

View file

@ -27,6 +27,7 @@
#include "server.h" #include "server.h"
#include "area.h" #include "area.h"
#include "clock.h" #include "clock.h"
#include "panel.h"
void init_clock(Clock *clock, int panel_height) void init_clock(Clock *clock, int panel_height)
@ -40,6 +41,10 @@ void init_clock(Clock *clock, int panel_height)
if (strchr(clock->time1_format, 'S') == NULL) clock->time_precision = 60; if (strchr(clock->time1_format, 'S') == NULL) clock->time_precision = 60;
else clock->time_precision = 1; else clock->time_precision = 1;
clock->area.posy = panel.area.border.width + panel.area.paddingy;
clock->area.height = panel.area.height - (2 * clock->area.posy);
clock->area.redraw = 1;
gettimeofday(&clock->clock, 0); gettimeofday(&clock->clock, 0);
clock->clock.tv_sec -= clock->clock.tv_sec % clock->time_precision; clock->clock.tv_sec -= clock->clock.tv_sec % clock->time_precision;
@ -72,6 +77,8 @@ int draw_foreground_clock (void *obj, cairo_t *c)
if (clock->time2_format) if (clock->time2_format)
strftime(buf_date, sizeof(buf_date), clock->time2_format, localtime(&clock->clock.tv_sec)); strftime(buf_date, sizeof(buf_date), clock->time2_format, localtime(&clock->clock.tv_sec));
//printf(" draw_foreground_clock : %s\n", buf_time);
redraw:
layout = pango_cairo_create_layout (c); layout = pango_cairo_create_layout (c);
// check width // check width
@ -90,11 +97,14 @@ int draw_foreground_clock (void *obj, cairo_t *c)
new_width += (2*clock->area.paddingx) + (2*clock->area.border.width); new_width += (2*clock->area.paddingx) + (2*clock->area.border.width);
if (new_width > clock->area.width || (new_width != clock->area.width && date_width > time_width)) { if (new_width > clock->area.width || (new_width != clock->area.width && date_width > time_width)) {
printf("clock_width %d, new_width %d\n", clock->area.width, new_width); //printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
// resize clock
clock->area.width = new_width; clock->area.width = new_width;
panel.clock.area.posx = panel.area.width - panel.clock.area.width - panel.area.paddingx - panel.area.border.width;
g_object_unref (layout); g_object_unref (layout);
return 1; resize_taskbar();
goto redraw;
} }
// draw layout // draw layout

View file

@ -13,7 +13,6 @@
typedef struct Clock { typedef struct Clock {
// --------------------------------------------------
// always start with area // always start with area
Area area; Area area;

View file

@ -45,21 +45,24 @@
void cleanup_taskbar() void cleanup_taskbar()
{ {
Task *tsk; free_area(&panel.area);
Taskbar *tskbar;
GSList *l0; int i, nb;
for (l0 = panel.area.list; l0 ; l0 = l0->next) { Task *tsk, *next;
tskbar = l0->data;
GSList *l1; nb = panel.nb_desktop * panel.nb_monitor;
for (l1 = tskbar->area.list; l1 ; l1 = l1->next) { for (i=0 ; i < nb ; i++) {
tsk = l1->data; /* TODO: voir ce code !!
for (tsk = panel.taskbar[i].tasklist; tsk ; tsk = next) {
next = tsk->next;
remove_task (tsk); remove_task (tsk);
} }
g_slist_free(tskbar->area.list); */
} }
g_slist_free(panel.area.list);
panel.area.list = 0; free(panel.taskbar);
panel.taskbar = 0;
} }
@ -69,7 +72,7 @@ void cleanup ()
if (g_task.font_desc) pango_font_description_free(g_task.font_desc); if (g_task.font_desc) pango_font_description_free(g_task.font_desc);
if (panel.clock.time1_font_desc) pango_font_description_free(panel.clock.time1_font_desc); if (panel.clock.time1_font_desc) pango_font_description_free(panel.clock.time1_font_desc);
if (panel.clock.time2_font_desc) pango_font_description_free(panel.clock.time2_font_desc); if (panel.clock.time2_font_desc) pango_font_description_free(panel.clock.time2_font_desc);
cleanup_taskbar(); if (panel.taskbar) cleanup_taskbar();
if (panel.clock.time1_format) g_free(panel.clock.time1_format); if (panel.clock.time1_format) g_free(panel.clock.time1_format);
if (panel.clock.time2_format) g_free(panel.clock.time2_format); if (panel.clock.time2_format) g_free(panel.clock.time2_format);
if (server.monitor) free(server.monitor); if (server.monitor) free(server.monitor);
@ -473,37 +476,31 @@ void config_taskbar()
fprintf(stderr, "tint2 warning : cannot found number of desktop.\n"); fprintf(stderr, "tint2 warning : cannot found number of desktop.\n");
} }
cleanup_taskbar(); if (panel.taskbar) cleanup_taskbar();
panel.nb_desktop = server.nb_desktop; panel.nb_desktop = server.nb_desktop;
if (panel.mode == MULTI_MONITOR) panel.nb_monitor = server.nb_monitor; if (panel.mode == MULTI_MONITOR) panel.nb_monitor = server.nb_monitor;
else panel.nb_monitor = 1; else panel.nb_monitor = 1;
panel.taskbar = calloc(panel.nb_desktop * panel.nb_monitor, sizeof(Taskbar));
// TODO: mémoriser le pointeur sur la première g_slist_free(panel.area.list);
// malgré l'apparant désordre, les taskbars sont ordonnées panel.area.list = 0;
Taskbar *new_tskbar;
Taskbar *tskbar;
for (i=0 ; i < panel.nb_desktop ; i++) { for (i=0 ; i < panel.nb_desktop ; i++) {
for (j=0 ; j < panel.nb_monitor ; j++) { for (j=0 ; j < panel.nb_monitor ; j++) {
new_tskbar = calloc(1, sizeof(Taskbar)); tskbar = &panel.taskbar[index(i,j)];
memcpy(&new_tskbar->area, &g_taskbar, sizeof(Area)); memcpy(&tskbar->area, &g_taskbar, sizeof(Area));
new_tskbar->desktop = i; tskbar->desktop = i;
new_tskbar->monitor = j; tskbar->monitor = j;
panel.area.list = g_slist_append(panel.area.list, new_tskbar); // TODO: redefinir panel.area.list en fonction des objets visibles
panel.area.list = g_slist_append(panel.area.list, tskbar);
} }
} }
/* if (panel.clock.time1_format)
comment faire pour parcourir les barres de taches ? on ne peut pas se baser sur l'ordre des éléments !! panel.area.list = g_slist_append(panel.area.list, &panel.clock);
a t'on besoin de parcourir les barres de taches ?? OUI !! bof ??
=> resize_taskbar() dans panel.c =>
=> task_refresh_tasklist () dans taskbar.c
=> Task *task_get_task (Window win) dans taskbar.c
=> event_button_press (int x, int y) dans tint.c => area->event_button_press() est conseillé !!
cela enlève aussi l'organisation des barres de taches en tableau à 2 dimensions
il est possible de mémoriser un pointeur sur la première barre de taches
*/
//printf("tasbar (desktop x monitor) : (%d x %d)\n", panel.nb_desktop, panel.nb_monitor); //printf("taskbar (desktop x monitor) : (%d x %d)\n", panel.nb_desktop, panel.nb_monitor);
resize_taskbar(); resize_taskbar();
task_refresh_tasklist (); task_refresh_tasklist ();
panel.refresh = 1; panel.refresh = 1;
@ -529,7 +526,7 @@ void config_finish ()
if (!server.monitor[panel.monitor].width || !server.monitor[panel.monitor].height) if (!server.monitor[panel.monitor].width || !server.monitor[panel.monitor].height)
fprintf(stderr, "tint2 error : invalid monitor size.\n"); 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;
// taskbar // taskbar
@ -551,9 +548,6 @@ void config_finish ()
panel.area.border.rounded = panel.area.height/2; panel.area.border.rounded = panel.area.height/2;
// clock // clock
panel.clock.area.posy = panel.area.border.width + panel.area.paddingy;
panel.clock.area.height = panel.area.height - (2 * panel.clock.area.posy);
panel.clock.area.redraw = 1;
init_clock(&panel.clock, panel.area.height); init_clock(&panel.clock, panel.area.height);
// compute vertical position : text and icon // compute vertical position : text and icon
@ -569,7 +563,8 @@ void config_finish ()
} }
config_taskbar(); config_taskbar();
visible_object();
// cleanup background list // cleanup background list
GSList *l0; GSList *l0;
for (l0 = list_back; l0 ; l0 = l0->next) { for (l0 = list_back; l0 ; l0 = l0->next) {

View file

@ -31,43 +31,22 @@
void visual_refresh () void visual_refresh ()
{ {
server_refresh_root_pixmap (); if (!server.root_pmap) {
Pixmap wall = get_root_pixmap();
draw (&panel.area);
refresh (&panel.area);
if (panel.clock.time1_format) {
if (panel.clock.area.redraw)
panel.refresh = 1;
if (draw (&panel.clock.area)) {
panel.clock.area.redraw = 1;
draw (&panel.clock.area);
resize_clock();
resize_taskbar();
redraw(&panel.area);
}
refresh (&panel.clock.area);
}
// TODO: ne pas afficher les taskbar invisibles server.root_pmap = server_create_pixmap (panel.area.width, panel.area.height);
//if (panel.mode != MULTI_DESKTOP && desktop != server.desktop) continue;
Task *tsk; XCopyArea (server.dsp, wall, server.root_pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0);
Taskbar *tskbar;
GSList *l0; redraw (&panel.area);
for (l0 = panel.area.list; l0 ; l0 = l0->next) {
tskbar = l0->data;
draw (&tskbar->area);
refresh (&tskbar->area);
GSList *l1;
for (l1 = tskbar->area.list; l1 ; l1 = l1->next) {
tsk = l1->data;
draw(&tsk->area);
if (tsk == panel.task_active) refresh (&tsk->area_active);
else refresh (&tsk->area);
}
} }
if (server.pmap) XFreePixmap (server.dsp, server.pmap);
server.pmap = server_create_pixmap (panel.area.width, panel.area.height);
XCopyArea (server.dsp, server.root_pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
draw (&panel.area);
XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0); XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
XFlush(server.dsp); XFlush(server.dsp);
@ -103,9 +82,9 @@ void set_panel_properties (Window win)
struts[10] = server.posx; struts[10] = server.posx;
struts[11] = server.posx + panel.area.width; struts[11] = server.posx + panel.area.width;
} }
XChangeProperty (server.dsp, win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12); // Old specification : fluxbox need _NET_WM_STRUT.
// Old specification
XChangeProperty (server.dsp, win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4); XChangeProperty (server.dsp, win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4);
XChangeProperty (server.dsp, win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12);
// Sticky and below other window // Sticky and below other window
val = 0xFFFFFFFF; val = 0xFFFFFFFF;
@ -163,50 +142,29 @@ void window_draw_panel ()
} }
void resize_clock() void visible_object()
{ {
panel.clock.area.posx = panel.area.width - panel.clock.area.width - panel.area.paddingx - panel.area.border.width; if (panel.area.list) {
} g_slist_free(panel.area.list);
panel.area.list = 0;
// initialise taskbar posx and width
void resize_taskbar()
{
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;
taskbar_width = panel.area.width - (2 * panel.area.paddingx) - (2 * panel.area.border.width);
if (panel.clock.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;
if (taskbar_on_screen > 1)
modulo_width = (taskbar_width - ((taskbar_on_screen-1) * panel.area.paddingx)) % taskbar_on_screen;
else
modulo_width = 0;
int posx, modulo, i;
Taskbar *tskbar;
GSList *l0;
for (i = 0, l0 = panel.area.list; l0 ; i++, l0 = l0->next) {
if ((i % taskbar_on_screen) == 0) {
posx = panel.area.border.width + panel.area.paddingx;
modulo = modulo_width;
}
else posx += taskbar_width + panel.area.paddingx;
tskbar = l0->data;
tskbar->area.posx = posx;
tskbar->area.width = taskbar_width;
if (modulo) {
tskbar->area.width++;
modulo--;
}
resize_tasks(tskbar);
} }
// list of visible objects
// start with clock because draw(clock) can resize others object
if (panel.clock.time1_format)
panel.area.list = g_slist_append(panel.area.list, &panel.clock);
int i, j;
Taskbar *taskbar;
for (i=0 ; i < panel.nb_desktop ; i++) {
for (j=0 ; j < panel.nb_monitor ; j++) {
taskbar = &panel.taskbar[index(i,j)];
if (panel.mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) continue;
panel.area.list = g_slist_append(panel.area.list, taskbar);
}
}
panel.refresh = 1;
} }

View file

@ -26,7 +26,6 @@ enum { LEFT=0x01, RIGHT=0x02, CENTER=0X04, TOP=0X08, BOTTOM=0x10 };
typedef struct { typedef struct {
// --------------------------------------------------
// always start with area // always start with area
Area area; Area area;
@ -49,7 +48,7 @@ typedef struct {
// -------------------------------------------------- // --------------------------------------------------
// taskbar point to the first taskbar in panel.area.list. number of tasbar == nb_desktop x nb_monitor. // taskbar point to the first taskbar in panel.area.list. number of tasbar == nb_desktop x nb_monitor.
//Taskbar *taskbar; Taskbar *taskbar;
int mode; int mode;
int nb_desktop; int nb_desktop;
int nb_monitor; int nb_monitor;
@ -78,8 +77,7 @@ Panel panel;
void visual_refresh (); void visual_refresh ();
void set_panel_properties (Window win); void set_panel_properties (Window win);
void window_draw_panel (); void window_draw_panel ();
void resize_clock(); void visible_object();
void resize_taskbar();
#endif #endif

View file

@ -191,24 +191,6 @@ Pixmap get_root_pixmap ()
} }
*/ */
void server_refresh_root_pixmap ()
{
if (!server.root_pmap) {
Pixmap wall = get_root_pixmap();
server.root_pmap = server_create_pixmap (panel.area.width, panel.area.height);
XCopyArea (server.dsp, wall, server.root_pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0);
panel.area.redraw = 1;
}
if (server.pmap) XFreePixmap (server.dsp, server.pmap);
server.pmap = server_create_pixmap (panel.area.width, panel.area.height);
XCopyArea (server.dsp, server.root_pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
}
void get_monitors() void get_monitors()
{ {

View file

@ -68,11 +68,11 @@ void add_task (Window win)
} }
Taskbar *tskbar; Taskbar *tskbar;
tskbar = g_slist_nth_data(panel.area.list, index(desktop, monitor)); tskbar = &panel.taskbar[index(desktop, monitor)];
new_tsk->area.parent = tskbar; new_tsk->area.parent = tskbar;
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk); tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk);
if (resize_tasks (tskbar)) if (resize_tasks (tskbar))
redraw (&tskbar->area); redraw (&tskbar->area);
} }
@ -263,7 +263,8 @@ int draw_foreground_task (void *obj, cairo_t *c)
Task *tsk = obj; Task *tsk = obj;
cairo_surface_t *cs; cairo_surface_t *cs;
cairo_t *ca; cairo_t *ca;
//printf(" draw_foreground_task\n");
draw_task_title (c, tsk, 0); draw_task_title (c, tsk, 0);
// draw active pmap // draw active pmap

View file

@ -17,6 +17,7 @@
typedef struct { typedef struct {
Area area; Area area;
Area area_active; Area area_active;
Area area_inactive;
int text; int text;
int icon; int icon;
@ -38,10 +39,10 @@ typedef struct {
// -------------------------------------------------- // --------------------------------------------------
// task parameter // task parameter
typedef struct { typedef struct {
// --------------------------------------------------
// always start with area // always start with area
Area area; Area area;
Area area_active; Area area_active;
Area area_inactive;
// TODO: group task with list of windows here // TODO: group task with list of windows here
Window win; Window win;

View file

@ -35,21 +35,17 @@
Task *task_get_task (Window win) Task *task_get_task (Window win)
{ {
Taskbar *tskbar;
Task *tsk; Task *tsk;
GSList *l0; GSList *l0;
int i, nb;
for (l0 = panel.area.list; l0 ; l0 = l0->next) { nb = panel.nb_desktop * panel.nb_monitor;
tskbar = l0->data; for (i=0 ; i < nb ; i++) {
GSList *l1; for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
for (l1 = tskbar->area.list; l1 ; l1 = l1->next) { tsk = l0->data;
tsk = l1->data;
if (win == tsk->win) return tsk; if (win == tsk->win) return tsk;
} }
} }
// nb = panel.nb_desktop * panel.nb_monitor;
//printf("task_get_task return 0\n");
return 0; return 0;
} }
@ -57,24 +53,22 @@ Task *task_get_task (Window win)
void task_refresh_tasklist () void task_refresh_tasklist ()
{ {
Window *win, active_win; Window *win, active_win;
int num_results, i, j; int num_results, i, j, nb;
GSList *l0;
Task *tsk;
win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results); win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results);
if (!win) return; if (!win) return;
/* Remove any old and set active win */ // Remove any old and set active win
active_win = window_get_active (); active_win = window_get_active ();
Task *tsk; nb = panel.nb_desktop * panel.nb_monitor;
Taskbar *tskbar; for (i=0 ; i < nb ; i++) {
GSList *l0; for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
for (l0 = panel.area.list; l0 ; l0 = l0->next) { tsk = l0->data;
tskbar = l0->data;
GSList *l1;
for (l1 = tskbar->area.list; l1 ; l1 = l1->next) {
tsk = l1->data;
if (tsk->win == active_win) panel.task_active = tsk; if (tsk->win == active_win) panel.task_active = tsk;
for (j = 0; j < num_results; j++) { for (j = 0; j < num_results; j++) {
@ -83,11 +77,11 @@ void task_refresh_tasklist ()
if (tsk->win != win[j]) remove_task (tsk); if (tsk->win != win[j]) remove_task (tsk);
} }
} }
/* Add any new */ // Add any new
for (i = 0; i < num_results; i++) { for (i = 0; i < num_results; i++)
if (!task_get_task (win[i])) add_task (win[i]); if (!task_get_task (win[i]))
} add_task (win[i]);
XFree (win); XFree (win);
} }
@ -141,3 +135,42 @@ int resize_tasks (Taskbar *taskbar)
} }
// initialise taskbar posx and width
void resize_taskbar()
{
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;
taskbar_width = panel.area.width - (2 * panel.area.paddingx) - (2 * panel.area.border.width);
if (panel.clock.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;
if (taskbar_on_screen > 1)
modulo_width = (taskbar_width - ((taskbar_on_screen-1) * panel.area.paddingx)) % taskbar_on_screen;
else
modulo_width = 0;
int posx, modulo, i, nb;
nb = panel.nb_desktop * panel.nb_monitor;
for (i=0 ; i < nb ; i++) {
if ((i % taskbar_on_screen) == 0) {
posx = panel.area.border.width + panel.area.paddingx;
modulo = modulo_width;
}
else posx += taskbar_width + panel.area.paddingx;
panel.taskbar[i].area.posx = posx;
panel.taskbar[i].area.width = taskbar_width;
if (modulo) {
panel.taskbar[i].area.width++;
modulo--;
}
resize_tasks(&panel.taskbar[i]);
}
}

View file

@ -8,7 +8,6 @@
// -------------------------------------------------- // --------------------------------------------------
// taskbar parameter // taskbar parameter
typedef struct { typedef struct {
// --------------------------------------------------
// always start with area // always start with area
Area area; Area area;
@ -33,6 +32,8 @@ void task_refresh_tasklist ();
// return 1 if task_width changed // return 1 if task_width changed
int resize_tasks (Taskbar *tskbar); int resize_tasks (Taskbar *tskbar);
void resize_taskbar();
//void add_taskbar(Area *a); //void add_taskbar(Area *a);
#endif #endif

View file

@ -158,6 +158,8 @@ void event_button_press (int x, int y)
void event_button_release (int button, int x, int y) void event_button_release (int button, int x, int y)
{ {
int action = TOGGLE_ICONIFY; int action = TOGGLE_ICONIFY;
// TODO: convert event_button_press(int x, int y) to area->event_button_press()
// if systray is ok
switch (button) { switch (button) {
case 2: case 2:
@ -173,9 +175,6 @@ void event_button_release (int button, int x, int y)
action = panel.mouse_scroll_down; action = panel.mouse_scroll_down;
break; break;
} }
// TODO: ne pas afficher les taskbar invisibles
//if (panel.mode != MULTI_DESKTOP && desktop != server.desktop) continue;
// search taskbar // search taskbar
Taskbar *tskbar; Taskbar *tskbar;
@ -237,13 +236,15 @@ void event_property_notify (Window win, Atom at)
/* Change number of desktops */ /* Change number of desktops */
else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) { else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
config_taskbar(); config_taskbar();
visible_object();
redraw(&panel.area); redraw(&panel.area);
panel.refresh = 1;
} }
/* Change desktop */ /* Change desktop */
else if (at == server.atom._NET_CURRENT_DESKTOP) { else if (at == server.atom._NET_CURRENT_DESKTOP) {
server.desktop = server_get_current_desktop (); server.desktop = server_get_current_desktop ();
if (panel.mode != MULTI_DESKTOP) panel.refresh = 1; if (panel.mode != MULTI_DESKTOP) {
visible_object();
}
} }
/* Window list */ /* Window list */
else if (at == server.atom._NET_CLIENT_LIST) { else if (at == server.atom._NET_CLIENT_LIST) {
@ -313,20 +314,14 @@ void event_configure_notify (Window win)
tsk = task_get_task (win); tsk = task_get_task (win);
if (!tsk) return; if (!tsk) return;
/* TODO ??? voir ancien code !!
Taskbar *tskbar;
tskbar = tsk->area.parent;
int new_monitor = window_get_monitor (win);
int desktop = tskbar->desktop;
// task on the same monitor Taskbar *tskbar = tsk->area.parent;
if (tsk->id_taskbar == index(desktop, new_monitor)) return; if (tskbar->monitor != window_get_monitor (win)) {
// task on another monitor
add_task (tsk->win); add_task (tsk->win);
remove_task (tsk); remove_task (tsk);
panel.refresh = 1; panel.refresh = 1;
*/ }
} }
@ -375,6 +370,9 @@ load_config:
config_finish (); config_finish ();
window_draw_panel (); window_draw_panel ();
// BUG: draw(clock) is needed here, but 'on the paper' it's not necessary.
draw(&panel.clock.area);
x11_fd = ConnectionNumber (server.dsp); x11_fd = ConnectionNumber (server.dsp);
XSync (server.dsp, False); XSync (server.dsp, False);

BIN
src/tint2

Binary file not shown.

View file

@ -30,7 +30,6 @@
#include "area.h" #include "area.h"
void redraw (Area *a) void redraw (Area *a)
{ {
a->redraw = 1; a->redraw = 1;
@ -43,34 +42,41 @@ void redraw (Area *a)
int draw (Area *a) int draw (Area *a)
{ {
if (!a->redraw) return 0;
cairo_surface_t *cs; cairo_surface_t *cs;
cairo_t *c; cairo_t *c;
int ret = 0; int ret = 0;
if (a->pmap) XFreePixmap (server.dsp, a->pmap); if (a->redraw) {
a->pmap = server_create_pixmap (a->width, a->height); //printf("begin draw area\n");
if (a->pmap) XFreePixmap (server.dsp, a->pmap);
a->pmap = server_create_pixmap (a->width, a->height);
// add layer of root pixmap // add layer of root pixmap
XCopyArea (server.dsp, server.pmap, a->pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); XCopyArea (server.dsp, server.pmap, a->pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
cs = cairo_xlib_surface_create (server.dsp, a->pmap, server.visual, a->width, a->height); cs = cairo_xlib_surface_create (server.dsp, a->pmap, server.visual, a->width, a->height);
c = cairo_create (cs); c = cairo_create (cs);
draw_background (a, c); draw_background (a, c);
if (a->draw_foreground) { if (a->draw_foreground)
ret = a->draw_foreground(a, c); ret = a->draw_foreground(a, c);
cairo_destroy (c);
cairo_surface_destroy (cs);
a->redraw = 0;
} }
else {
// parcours de la liste des sous objets XCopyArea (server.dsp, a->pmap, server.pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
GSList *l = a->list;
if (l) {
// draw child object
for (; l ; l = l->next)
draw(l->data);
} }
cairo_destroy (c); //printf("end draw area\n");
cairo_surface_destroy (cs);
a->redraw = 0;
return ret; return ret;
} }
@ -153,12 +159,6 @@ void draw_background (Area *a, cairo_t *c)
} }
void refresh (Area *a)
{
XCopyArea (server.dsp, a->pmap, server.pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
}
void remove_area (Area *a) void remove_area (Area *a)
{ {
Area *parent; Area *parent;
@ -180,3 +180,16 @@ void add_area (Area *a)
} }
void free_area (Area *a)
{
GSList *l0;
for (l0 = a->list; l0 ; l0 = l0->next)
free_area (l0->data);
if (a->list) {
g_slist_free(a->list);
a->list = 0;
}
}

View file

@ -7,8 +7,8 @@
* Area manage the background and border drawing, size and padding. * Area manage the background and border drawing, size and padding.
* Area manage also the tree of visible objects * Area manage also the tree of visible objects
* panel -> taskbars -> tasks * panel -> taskbars -> tasks
* -> clock
* -> systray -> icons * -> systray -> icons
* -> clock
* *
* un objet comprend les actions: * un objet comprend les actions:
* 1) redraw(obj) * 1) redraw(obj)
@ -110,7 +110,7 @@ typedef struct {
void (*add_child)(void *obj); void (*add_child)(void *obj);
int (*remove_child)(void *obj); int (*remove_child)(void *obj);
// list of child // list of child : Area object
GSList *list; GSList *list;
} Area; } Area;
@ -123,9 +123,9 @@ void redraw (Area *a);
int draw (Area *a); int draw (Area *a);
void draw_background (Area *a, cairo_t *c); void draw_background (Area *a, cairo_t *c);
void refresh (Area *a);
void remove_area (Area *a); void remove_area (Area *a);
void add_area (Area *a); void add_area (Area *a);
void free_area (Area *a);
#endif #endif