tint2 looks good for me. if you see bugs, report it.
git-svn-id: http://tint2.googlecode.com/svn/trunk@54 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
077590ffce
commit
283a7fe289
13 changed files with 207 additions and 172 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2009-02-13
|
||||||
|
- improved object oriented layout
|
||||||
|
- tint2 looks good for me. if you see bugs, report it.
|
||||||
|
|
||||||
2009-02-12
|
2009-02-12
|
||||||
- fixed issue 14 : no icons
|
- fixed issue 14 : no icons
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@ void init_clock(Clock *clock, Area *parent)
|
||||||
clock->area._resize = resize_clock;
|
clock->area._resize = resize_clock;
|
||||||
if (!time1_format) return;
|
if (!time1_format) return;
|
||||||
|
|
||||||
|
// add clock to the panel
|
||||||
|
panel->area.list = g_slist_append(panel->area.list, clock);
|
||||||
|
|
||||||
if (strchr(time1_format, 'S') == NULL) time_precision = 60;
|
if (strchr(time1_format, 'S') == NULL) time_precision = 60;
|
||||||
else time_precision = 1;
|
else time_precision = 1;
|
||||||
|
|
||||||
|
@ -119,12 +122,13 @@ void draw_foreground_clock (void *obj, cairo_t *c, int active)
|
||||||
|
|
||||||
void resize_clock (void *obj)
|
void resize_clock (void *obj)
|
||||||
{
|
{
|
||||||
Area *parent = ((Area*)obj)->parent;
|
|
||||||
Clock *clock = obj;
|
Clock *clock = obj;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
int time_width, date_width, new_width;
|
int time_width, date_width, new_width;
|
||||||
|
|
||||||
time_width = date_width = 0;
|
time_width = date_width = 0;
|
||||||
|
clock->area.redraw = 1;
|
||||||
|
|
||||||
strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
|
strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
|
||||||
if (time2_format)
|
if (time2_format)
|
||||||
strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
|
strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
|
||||||
|
@ -156,11 +160,19 @@ void resize_clock (void *obj)
|
||||||
new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width);
|
new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width);
|
||||||
|
|
||||||
if (new_width > clock->area.width || new_width < (clock->area.width-3)) {
|
if (new_width > clock->area.width || new_width < (clock->area.width-3)) {
|
||||||
// resize clock
|
int i;
|
||||||
|
Panel *panel = ((Area*)obj)->panel;
|
||||||
|
|
||||||
//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;
|
||||||
clock->area.posx = parent->width - clock->area.width - parent->paddingxlr - parent->pix.border.width;
|
clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width;
|
||||||
set_resize(parent);
|
|
||||||
|
// resize other objects on panel
|
||||||
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
|
panel1[i].area.resize = 1;
|
||||||
|
}
|
||||||
|
panel_refresh = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
|
|
11
src/config.c
11
src/config.c
|
@ -570,16 +570,17 @@ void config_finish ()
|
||||||
}
|
}
|
||||||
|
|
||||||
init_panel();
|
init_panel();
|
||||||
|
// force the resize
|
||||||
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
|
panel1[i].area.resize = 1;
|
||||||
|
resize_clock(&panel1[i].clock);
|
||||||
|
}
|
||||||
|
|
||||||
init_taskbar();
|
init_taskbar();
|
||||||
visible_object();
|
visible_object();
|
||||||
|
|
||||||
cleanup_config();
|
cleanup_config();
|
||||||
|
|
||||||
// force the resize (using visible_object() order)
|
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
|
||||||
//init_systray(&panel1[i].trayer, &panel1[i].area);
|
|
||||||
set_resize(&panel1[i]);
|
|
||||||
}
|
|
||||||
task_refresh_tasklist();
|
task_refresh_tasklist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
164
src/panel.c
164
src/panel.c
|
@ -58,8 +58,10 @@ void init_panel()
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
p = &panel1[i];
|
p = &panel1[i];
|
||||||
|
|
||||||
p->area.parent = 0;
|
p->area.parent = p;
|
||||||
p->area.panel = p;
|
p->area.panel = p;
|
||||||
|
p->area.visible = 1;
|
||||||
|
p->area._resize = resize_panel;
|
||||||
p->g_taskbar.parent = p;
|
p->g_taskbar.parent = p;
|
||||||
p->g_taskbar.panel = p;
|
p->g_taskbar.panel = p;
|
||||||
p->g_task.area.panel = p;
|
p->g_task.area.panel = p;
|
||||||
|
@ -73,6 +75,7 @@ void init_panel()
|
||||||
else
|
else
|
||||||
p->area.height = p->initial_height;
|
p->area.height = p->initial_height;
|
||||||
|
|
||||||
|
|
||||||
// full width mode
|
// full width mode
|
||||||
if (!p->area.width)
|
if (!p->area.width)
|
||||||
p->area.width = server.monitor[p->monitor].width;
|
p->area.width = server.monitor[p->monitor].width;
|
||||||
|
@ -125,52 +128,113 @@ void cleanup_panel()
|
||||||
|
|
||||||
cleanup_taskbar();
|
cleanup_taskbar();
|
||||||
|
|
||||||
|
// font allocated once
|
||||||
|
if (panel1[0].g_task.font_desc) {
|
||||||
|
pango_font_description_free(panel1[0].g_task.font_desc);
|
||||||
|
panel1[0].g_task.font_desc = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
Panel *p;
|
Panel *p;
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
p = &panel1[i];
|
p = &panel1[i];
|
||||||
|
|
||||||
// no free_area(&p->area) because it's the list of visible objects
|
// freed list of visible objects
|
||||||
if (p->area.list) {
|
if (p->list_visible) {
|
||||||
g_slist_free(p->area.list);
|
g_slist_free(p->list_visible);
|
||||||
p->area.list = 0;
|
p->list_visible = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_area(&p->area);
|
||||||
free_area(&p->g_task.area);
|
free_area(&p->g_task.area);
|
||||||
free_area(&p->g_taskbar);
|
free_area(&p->g_taskbar);
|
||||||
free_area(&p->clock.area);
|
|
||||||
if (p->area.pix.pmap) XFreePixmap(server.dsp, p->area.pix.pmap);
|
|
||||||
if (p->area.pix_active.pmap) XFreePixmap(server.dsp, p->area.pix_active.pmap);
|
|
||||||
if (p->root_pmap) XFreePixmap(server.dsp, p->root_pmap);
|
|
||||||
if (p->main_win) XDestroyWindow(server.dsp, p->main_win);
|
|
||||||
}
|
|
||||||
|
|
||||||
// font allocated once
|
if (p->temp_pmap) {
|
||||||
if (panel1[0].g_task.font_desc) pango_font_description_free(panel1[0].g_task.font_desc);
|
XFreePixmap(server.dsp, p->temp_pmap);
|
||||||
|
p->temp_pmap = 0;
|
||||||
|
}
|
||||||
|
if (p->main_win) {
|
||||||
|
XDestroyWindow(server.dsp, p->main_win);
|
||||||
|
p->main_win = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (panel1) free(panel1);
|
if (panel1) free(panel1);
|
||||||
panel1 = 0;
|
panel1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void visual_refresh (Panel *p)
|
void resize_panel(void *obj)
|
||||||
{
|
{
|
||||||
if (p->root_pmap) XFreePixmap(server.dsp, p->root_pmap);
|
Panel *panel = (Panel*)obj;
|
||||||
p->root_pmap = XCreatePixmap(server.dsp, server.root_win, p->area.width, p->area.height, server.depth);
|
int taskbar_width, modulo_width, taskbar_on_screen;
|
||||||
|
|
||||||
XCopyArea (server.dsp, p->area.pix.pmap, p->root_pmap, server.gc, 0, 0, p->area.width, p->area.height, 0, 0);
|
//printf("resize_panel : : posx et width des barres de taches\n");
|
||||||
|
|
||||||
// draw child object
|
if (panel_mode == MULTI_DESKTOP) taskbar_on_screen = panel->nb_desktop;
|
||||||
GSList *l = p->area.list;
|
else taskbar_on_screen = 1;
|
||||||
for (; l ; l = l->next) {
|
|
||||||
refresh (l->data);
|
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 -= (panel->trayer.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;
|
||||||
|
|
||||||
|
// change posx and width for all taskbar
|
||||||
|
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;
|
||||||
|
modulo = modulo_width;
|
||||||
}
|
}
|
||||||
|
else posx += taskbar_width + panel->area.paddingx;
|
||||||
|
|
||||||
XCopyArea(server.dsp, p->root_pmap, p->main_win, server.gc, 0, 0, p->area.width, p->area.height, 0, 0);
|
panel->taskbar[i].area.posx = posx;
|
||||||
|
panel->taskbar[i].area.width = taskbar_width;
|
||||||
|
panel->taskbar[i].area.resize = 1;
|
||||||
|
if (modulo) {
|
||||||
|
panel->taskbar[i].area.width++;
|
||||||
|
modulo--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right.
|
|
||||||
// this feature is disabled !
|
void visible_object()
|
||||||
//XCopyArea (server.dsp, server.pmap, p->main_win, server.gc, p->area.paddingxlr, 0, p->area.width-(2*p->area.paddingxlr), p->area.height, 0, 0);
|
{
|
||||||
|
Panel *panel;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
|
panel = &panel1[i];
|
||||||
|
|
||||||
|
// clock before taskbar because resize(clock) can resize others object
|
||||||
|
if (time1_format)
|
||||||
|
panel->clock.area.visible = 1;
|
||||||
|
else
|
||||||
|
panel->clock.area.visible = 0;
|
||||||
|
|
||||||
|
//panel->area.list = g_slist_append(panel->area.list, &panel->trayer);
|
||||||
|
|
||||||
|
Taskbar *taskbar;
|
||||||
|
for (j=0 ; j < panel->nb_desktop ; j++) {
|
||||||
|
taskbar = &panel->taskbar[j];
|
||||||
|
if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) {
|
||||||
|
// (SINGLE_DESKTOP or SINGLE_MONITOR) and not current desktop
|
||||||
|
taskbar->area.visible = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
taskbar->area.visible = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
panel_refresh = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -235,42 +299,6 @@ void set_panel_properties(Panel *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void visible_object()
|
|
||||||
{
|
|
||||||
Panel *panel;
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
|
||||||
panel = &panel1[i];
|
|
||||||
|
|
||||||
if (panel->area.list) {
|
|
||||||
g_slist_free(panel->area.list);
|
|
||||||
panel->area.list = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// list of visible objects
|
|
||||||
// start with clock because draw(clock) can resize others object
|
|
||||||
if (time1_format)
|
|
||||||
panel->area.list = g_slist_append(panel->area.list, &panel->clock);
|
|
||||||
|
|
||||||
//panel->area.list = g_slist_append(panel->area.list, &panel->trayer);
|
|
||||||
|
|
||||||
Taskbar *taskbar;
|
|
||||||
for (j=0 ; j < panel->nb_desktop ; j++) {
|
|
||||||
taskbar = &panel->taskbar[j];
|
|
||||||
if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) {
|
|
||||||
// (SINGLE_DESKTOP or SINGLE_MONITOR) and not current desktop
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
panel->area.list = g_slist_append(panel->area.list, taskbar);
|
|
||||||
}
|
|
||||||
set_redraw(&panel->area);
|
|
||||||
}
|
|
||||||
panel_refresh = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void set_panel_background(Panel *p)
|
void set_panel_background(Panel *p)
|
||||||
{
|
{
|
||||||
get_root_pixmap();
|
get_root_pixmap();
|
||||||
|
@ -278,7 +306,7 @@ void set_panel_background(Panel *p)
|
||||||
if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap);
|
if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap);
|
||||||
p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth);
|
p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth);
|
||||||
|
|
||||||
// copy background (server.root_pmap) in panel
|
// copy background (server.root_pmap) in panel.area.pix.pmap
|
||||||
Window dummy;
|
Window dummy;
|
||||||
int x, y;
|
int x, y;
|
||||||
XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy);
|
XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy);
|
||||||
|
@ -296,11 +324,13 @@ void set_panel_background(Panel *p)
|
||||||
cairo_destroy (c);
|
cairo_destroy (c);
|
||||||
cairo_surface_destroy (cs);
|
cairo_surface_destroy (cs);
|
||||||
|
|
||||||
// redraw panel
|
// redraw panel's object
|
||||||
set_redraw (&p->area);
|
GSList *l0;
|
||||||
|
Area *a;
|
||||||
// copy background panel on desktop window
|
for (l0 = p->area.list; l0 ; l0 = l0->next) {
|
||||||
//XCopyArea (server.dsp, p->area.pix.pmap, server.root_win, server.gc_root, 0, 0, p->area.width, p->area.height, p->posx, p->posy);
|
a = l0->data;
|
||||||
|
set_redraw(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
11
src/panel.h
11
src/panel.h
|
@ -46,12 +46,17 @@ extern Task *task_drag;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// always start with area
|
// always start with area
|
||||||
|
// area.list own all objects of the panel according to config file
|
||||||
Area area;
|
Area area;
|
||||||
|
|
||||||
|
// list of visible objects
|
||||||
|
GSList *list_visible;
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// panel
|
// panel
|
||||||
Window main_win;
|
Window main_win;
|
||||||
Pixmap root_pmap;
|
Pixmap temp_pmap;
|
||||||
|
|
||||||
// position relative to root window
|
// position relative to root window
|
||||||
int posx, posy;
|
int posx, posy;
|
||||||
int marginx, marginy;
|
int marginx, marginy;
|
||||||
|
@ -90,13 +95,15 @@ extern int nb_panel;
|
||||||
|
|
||||||
void init_panel();
|
void init_panel();
|
||||||
void cleanup_panel();
|
void cleanup_panel();
|
||||||
void visual_refresh(Panel *p);
|
void resize_panel(void *obj);
|
||||||
|
|
||||||
void set_panel_properties(Panel *p);
|
void set_panel_properties(Panel *p);
|
||||||
void visible_object();
|
void visible_object();
|
||||||
|
|
||||||
// draw background panel
|
// draw background panel
|
||||||
void set_panel_background(Panel *p);
|
void set_panel_background(Panel *p);
|
||||||
|
|
||||||
|
// detect witch panel
|
||||||
Panel *get_panel(Window win);
|
Panel *get_panel(Window win);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,7 +54,7 @@ void init_systray(Systraybar *sysbar, Area *parent)
|
||||||
|
|
||||||
sysbar->area.redraw = 1;
|
sysbar->area.redraw = 1;
|
||||||
|
|
||||||
printf("init_systray");
|
//printf("init_systray");
|
||||||
|
|
||||||
net_init();
|
net_init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,11 +77,8 @@ void add_task (Window win)
|
||||||
new_tsk2->icon_width = new_tsk.icon_width;
|
new_tsk2->icon_width = new_tsk.icon_width;
|
||||||
new_tsk2->icon_height = new_tsk.icon_height;
|
new_tsk2->icon_height = new_tsk.icon_height;
|
||||||
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2);
|
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2);
|
||||||
|
tskbar->area.resize = 1;
|
||||||
//printf("add_task panel %d, desktop %d, task %s\n", i, j, new_tsk2->title);
|
//printf("add_task panel %d, desktop %d, task %s\n", i, j, new_tsk2->title);
|
||||||
// set_resize (&tskbar->area);
|
|
||||||
if (resize_tasks (tskbar))
|
|
||||||
set_redraw (&tskbar->area);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +94,6 @@ void remove_task (Task *tsk)
|
||||||
// free title and icon just for the first task
|
// free title and icon just for the first task
|
||||||
// even with task_on_all_desktop and with task_on_all_panel
|
// even with task_on_all_desktop and with task_on_all_panel
|
||||||
//printf("remove_task %s %d\n", tsk->title, tsk->desktop);
|
//printf("remove_task %s %d\n", tsk->title, tsk->desktop);
|
||||||
//printf("remove_task %s \n", tsk->title);
|
|
||||||
if (tsk->title)
|
if (tsk->title)
|
||||||
free (tsk->title);
|
free (tsk->title);
|
||||||
if (tsk->icon_data)
|
if (tsk->icon_data)
|
||||||
|
@ -117,8 +113,7 @@ void remove_task (Task *tsk)
|
||||||
l0 = l0->next;
|
l0 = l0->next;
|
||||||
if (win == tsk2->win) {
|
if (win == tsk2->win) {
|
||||||
tskbar->area.list = g_slist_remove(tskbar->area.list, tsk2);
|
tskbar->area.list = g_slist_remove(tskbar->area.list, tsk2);
|
||||||
set_resize (&tskbar->area);
|
tskbar->area.resize = 1;
|
||||||
set_redraw (&tskbar->area);
|
|
||||||
|
|
||||||
if (tsk2 == task_active)
|
if (tsk2 == task_active)
|
||||||
task_active = 0;
|
task_active = 0;
|
||||||
|
|
|
@ -42,11 +42,17 @@ void init_taskbar()
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
panel = &panel1[i];
|
panel = &panel1[i];
|
||||||
|
|
||||||
|
if (panel->taskbar) {
|
||||||
|
free(panel->taskbar);
|
||||||
|
panel->taskbar = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// taskbar
|
// taskbar
|
||||||
panel->g_taskbar._resize = resize_taskbar;
|
panel->g_taskbar._resize = resize_taskbar;
|
||||||
panel->g_taskbar.posy = panel->area.pix.border.width + panel->area.paddingy;
|
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.height = panel->area.height - (2 * panel->g_taskbar.posy);
|
||||||
panel->g_taskbar.redraw = 1;
|
panel->g_taskbar.redraw = 1;
|
||||||
|
panel->g_taskbar.visible = 1;
|
||||||
|
|
||||||
// task
|
// task
|
||||||
panel->g_task.area._draw_foreground = draw_foreground_task;
|
panel->g_task.area._draw_foreground = draw_foreground_task;
|
||||||
|
@ -54,6 +60,7 @@ void init_taskbar()
|
||||||
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
|
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.use_active = 1;
|
||||||
panel->g_task.area.redraw = 1;
|
panel->g_task.area.redraw = 1;
|
||||||
|
panel->g_task.area.visible = 1;
|
||||||
|
|
||||||
if (panel->g_task.area.pix.border.rounded > panel->g_task.area.height/2) {
|
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.border.rounded = panel->g_task.area.height/2;
|
||||||
|
@ -84,6 +91,9 @@ void init_taskbar()
|
||||||
tskbar = &panel->taskbar[j];
|
tskbar = &panel->taskbar[j];
|
||||||
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
|
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
|
||||||
tskbar->desktop = j;
|
tskbar->desktop = j;
|
||||||
|
|
||||||
|
// add taskbar to the panel
|
||||||
|
panel->area.list = g_slist_append(panel->area.list, tskbar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +102,7 @@ void init_taskbar()
|
||||||
void cleanup_taskbar()
|
void cleanup_taskbar()
|
||||||
{
|
{
|
||||||
Panel *panel;
|
Panel *panel;
|
||||||
|
Taskbar *tskbar;
|
||||||
int i, j;
|
int i, j;
|
||||||
GSList *l0;
|
GSList *l0;
|
||||||
Task *tsk;
|
Task *tsk;
|
||||||
|
@ -100,14 +111,18 @@ void cleanup_taskbar()
|
||||||
panel = &panel1[i];
|
panel = &panel1[i];
|
||||||
|
|
||||||
for (j=0 ; j < panel->nb_desktop ; j++) {
|
for (j=0 ; j < panel->nb_desktop ; j++) {
|
||||||
l0 = panel->taskbar[j].area.list;
|
tskbar = &panel->taskbar[j];
|
||||||
|
l0 = tskbar->area.list;
|
||||||
while (l0) {
|
while (l0) {
|
||||||
tsk = l0->data;
|
tsk = l0->data;
|
||||||
l0 = l0->next;
|
l0 = l0->next;
|
||||||
// careful : remove_task change l0->next
|
// careful : remove_task change l0->next
|
||||||
remove_task (tsk);
|
remove_task (tsk);
|
||||||
}
|
}
|
||||||
free_area (&panel->taskbar[j].area);
|
free_area (&tskbar->area);
|
||||||
|
|
||||||
|
// remove taskbar from the panel
|
||||||
|
panel->area.list = g_slist_remove(panel->area.list, tskbar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,17 +203,21 @@ void task_refresh_tasklist ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int resize_tasks (Taskbar *taskbar)
|
void resize_taskbar(void *obj)
|
||||||
{
|
{
|
||||||
int ret, task_count, pixel_width, modulo_width=0;
|
Taskbar *taskbar = (Taskbar*)obj;
|
||||||
|
Panel *panel = (Panel*)taskbar->area.panel;
|
||||||
|
int task_count, pixel_width, modulo_width=0;
|
||||||
int x, taskbar_width;
|
int x, taskbar_width;
|
||||||
Task *tsk;
|
Task *tsk;
|
||||||
Panel *panel = (Panel*)taskbar->area.panel;
|
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
|
//printf("resize_taskbar : posx et width des taches\n");
|
||||||
|
|
||||||
|
taskbar->area.redraw = 1;
|
||||||
|
|
||||||
// new task width for 'desktop'
|
// new task width for 'desktop'
|
||||||
task_count = g_slist_length(taskbar->area.list);
|
task_count = g_slist_length(taskbar->area.list);
|
||||||
|
|
||||||
if (!task_count) pixel_width = panel->g_task.maximum_width;
|
if (!task_count) pixel_width = panel->g_task.maximum_width;
|
||||||
else {
|
else {
|
||||||
taskbar_width = taskbar->area.width - (2 * panel->g_taskbar.pix.border.width) - (2 * panel->g_taskbar.paddingxlr);
|
taskbar_width = taskbar->area.width - (2 * panel->g_taskbar.pix.border.width) - (2 * panel->g_taskbar.paddingxlr);
|
||||||
|
@ -210,13 +229,10 @@ int resize_tasks (Taskbar *taskbar)
|
||||||
else
|
else
|
||||||
modulo_width = taskbar_width % task_count;
|
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)) {
|
if ((taskbar->task_width == pixel_width) && (taskbar->task_modulo == modulo_width)) {
|
||||||
ret = 0;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = 1;
|
|
||||||
taskbar->task_width = pixel_width;
|
taskbar->task_width = pixel_width;
|
||||||
taskbar->task_modulo = modulo_width;
|
taskbar->task_modulo = modulo_width;
|
||||||
taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->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;
|
||||||
|
@ -228,6 +244,7 @@ int resize_tasks (Taskbar *taskbar)
|
||||||
tsk = l->data;
|
tsk = l->data;
|
||||||
tsk->area.posx = x;
|
tsk->area.posx = x;
|
||||||
tsk->area.width = pixel_width;
|
tsk->area.width = pixel_width;
|
||||||
|
tsk->area.redraw = 1;
|
||||||
if (modulo_width) {
|
if (modulo_width) {
|
||||||
tsk->area.width++;
|
tsk->area.width++;
|
||||||
modulo_width--;
|
modulo_width--;
|
||||||
|
@ -235,49 +252,7 @@ int resize_tasks (Taskbar *taskbar)
|
||||||
|
|
||||||
x += tsk->area.width + panel->g_taskbar.paddingx;
|
x += tsk->area.width + panel->g_taskbar.paddingx;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// initialise taskbar posx and width
|
|
||||||
void resize_taskbar(void *obj)
|
|
||||||
{
|
|
||||||
Panel *panel = ((Area*)obj)->panel;
|
|
||||||
int taskbar_width, modulo_width, taskbar_on_screen;
|
|
||||||
|
|
||||||
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);
|
|
||||||
if (time1_format)
|
|
||||||
taskbar_width -= (panel->clock.area.width + panel->area.paddingx);
|
|
||||||
//taskbar_width -= (panel->trayer.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 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;
|
|
||||||
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--;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_redraw (&panel->taskbar[i].area);
|
|
||||||
resize_tasks(&panel->taskbar[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,6 @@ void cleanup_taskbar();
|
||||||
Task *task_get_task (Window win);
|
Task *task_get_task (Window win);
|
||||||
void task_refresh_tasklist ();
|
void task_refresh_tasklist ();
|
||||||
|
|
||||||
// return 1 if task_width changed
|
|
||||||
int resize_tasks (Taskbar *tskbar);
|
|
||||||
|
|
||||||
void resize_taskbar(void *obj);
|
void resize_taskbar(void *obj);
|
||||||
|
|
||||||
|
|
||||||
|
|
36
src/tint.c
36
src/tint.c
|
@ -138,6 +138,7 @@ void event_button_press (XEvent *e)
|
||||||
int y = e->xbutton.y;
|
int y = e->xbutton.y;
|
||||||
for (l0 = panel->area.list; l0 ; l0 = l0->next) {
|
for (l0 = panel->area.list; l0 ; l0 = l0->next) {
|
||||||
tskbar = l0->data;
|
tskbar = l0->data;
|
||||||
|
if (!tskbar->area.visible) continue;
|
||||||
if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
|
if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -187,6 +188,7 @@ void event_button_release (XEvent *e)
|
||||||
GSList *l0;
|
GSList *l0;
|
||||||
for (l0 = panel->area.list; l0 ; l0 = l0->next) {
|
for (l0 = panel->area.list; l0 ; l0 = l0->next) {
|
||||||
tskbar = l0->data;
|
tskbar = l0->data;
|
||||||
|
if (!tskbar->area.visible) continue;
|
||||||
if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
|
if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
|
||||||
goto suite;
|
goto suite;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +252,7 @@ void event_property_notify (Window win, Atom at)
|
||||||
init_taskbar();
|
init_taskbar();
|
||||||
visible_object();
|
visible_object();
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
set_resize(&panel1[i]);
|
panel1[i].area.resize = 1;
|
||||||
}
|
}
|
||||||
task_refresh_tasklist();
|
task_refresh_tasklist();
|
||||||
panel_refresh = 1;
|
panel_refresh = 1;
|
||||||
|
@ -400,6 +402,11 @@ void event_configure_notify (Window win)
|
||||||
// task on another monitor
|
// task on another monitor
|
||||||
remove_task (tsk);
|
remove_task (tsk);
|
||||||
add_task (win);
|
add_task (win);
|
||||||
|
if (win == window_get_active ()) {
|
||||||
|
Task *tsk = task_get_task (win);
|
||||||
|
tsk->area.is_active = 1;
|
||||||
|
task_active = tsk;
|
||||||
|
}
|
||||||
panel_refresh = 1;
|
panel_refresh = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,7 +428,6 @@ void event_timer()
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
panel1[i].clock.area.redraw = 1;
|
|
||||||
panel1[i].clock.area.resize = 1;
|
panel1[i].clock.area.resize = 1;
|
||||||
}
|
}
|
||||||
panel_refresh = 1;
|
panel_refresh = 1;
|
||||||
|
@ -483,9 +489,7 @@ load_config:
|
||||||
case Expose:
|
case Expose:
|
||||||
panel = get_panel(e.xany.window);
|
panel = get_panel(e.xany.window);
|
||||||
if (!panel) break;
|
if (!panel) break;
|
||||||
//XCopyArea (server.dsp, panel.area.pix.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy);
|
XCopyArea (server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
|
||||||
//XCopyArea (server.dsp, server.pmap, panel.main_win, server.gc, panel.area.paddingxlr, 0, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, 0);
|
|
||||||
XCopyArea (server.dsp, panel->root_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PropertyNotify:
|
case PropertyNotify:
|
||||||
|
@ -532,14 +536,26 @@ load_config:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel_refresh) {
|
if (panel_refresh) {
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
|
||||||
visual_refresh(&panel1[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
XFlush (server.dsp);
|
|
||||||
panel_refresh = 0;
|
panel_refresh = 0;
|
||||||
|
|
||||||
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
|
panel = &panel1[i];
|
||||||
|
|
||||||
|
if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
|
||||||
|
panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
|
||||||
|
|
||||||
|
refresh(panel);
|
||||||
|
XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
|
||||||
|
}
|
||||||
|
XFlush (server.dsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ****************************************************
|
||||||
|
// main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right.
|
||||||
|
// this feature is disabled !
|
||||||
|
//XCopyArea (server.dsp, server.pmap, p->main_win, server.gc, p->area.paddingxlr, 0, p->area.width-(2*p->area.paddingxlr), p->area.height, 0, 0);
|
||||||
|
//XCopyArea (server.dsp, panel.area.pix.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy);
|
||||||
|
//XCopyArea (server.dsp, server.pmap, panel.main_win, server.gc, panel.area.paddingxlr, 0, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, 0);
|
||||||
|
|
||||||
|
|
BIN
src/tint2
BIN
src/tint2
Binary file not shown.
|
@ -32,15 +32,18 @@
|
||||||
|
|
||||||
void refresh (Area *a)
|
void refresh (Area *a)
|
||||||
{
|
{
|
||||||
|
if (!a->visible) return;
|
||||||
if (a->resize) {
|
if (a->resize) {
|
||||||
// resize can generate a redraw
|
// resize can generate a redraw
|
||||||
if (a->_resize)
|
if (a->_resize) {
|
||||||
|
//printf("resize area posx %d, width %d\n", a->posx, a->width);
|
||||||
a->_resize(a);
|
a->_resize(a);
|
||||||
|
}
|
||||||
a->resize = 0;
|
a->resize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a->redraw) {
|
if (a->redraw) {
|
||||||
//printf("draw pix\n");
|
//printf("draw area posx %d, width %d\n", a->posx, a->width);
|
||||||
draw(a, 0);
|
draw(a, 0);
|
||||||
if (a->use_active)
|
if (a->use_active)
|
||||||
draw(a, 1);
|
draw(a, 1);
|
||||||
|
@ -49,7 +52,7 @@ void refresh (Area *a)
|
||||||
|
|
||||||
// draw current Area
|
// draw current Area
|
||||||
Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
|
Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
|
||||||
XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->root_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
|
XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
|
||||||
|
|
||||||
// and then refresh child object
|
// and then refresh child object
|
||||||
GSList *l = a->list;
|
GSList *l = a->list;
|
||||||
|
@ -68,26 +71,15 @@ void set_redraw (Area *a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void set_resize (Area *a)
|
|
||||||
{
|
|
||||||
a->resize = 1;
|
|
||||||
|
|
||||||
GSList *l;
|
|
||||||
for (l = a->list ; l ; l = l->next)
|
|
||||||
set_resize(l->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void draw (Area *a, int active)
|
void draw (Area *a, int active)
|
||||||
{
|
{
|
||||||
Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
|
Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
|
||||||
|
|
||||||
//printf("begin draw area\n");
|
|
||||||
if (*pmap) XFreePixmap (server.dsp, *pmap);
|
if (*pmap) XFreePixmap (server.dsp, *pmap);
|
||||||
*pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
|
*pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
|
||||||
|
|
||||||
// add layer of root pixmap
|
// add layer of root pixmap
|
||||||
XCopyArea (server.dsp, ((Panel *)a->panel)->root_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
|
XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
|
||||||
|
|
||||||
cairo_surface_t *cs;
|
cairo_surface_t *cs;
|
||||||
cairo_t *c;
|
cairo_t *c;
|
||||||
|
@ -151,7 +143,6 @@ void draw_background (Area *a, cairo_t *c, int active)
|
||||||
x1 = X1 * ((double)a->height / 100);
|
x1 = X1 * ((double)a->height / 100);
|
||||||
y0 = Y0 * ((double)a->width / 100);
|
y0 = Y0 * ((double)a->width / 100);
|
||||||
y1 = Y1 * ((double)a->width / 100);
|
y1 = Y1 * ((double)a->width / 100);
|
||||||
printf("repère (%d, %d) points (%lf, %lf) (%lf, %lf)\n", a->width, a->height, x0, y0, x1, y1);
|
|
||||||
|
|
||||||
cairo_pattern_t *linpat;
|
cairo_pattern_t *linpat;
|
||||||
linpat = cairo_pattern_create_linear (x0, y0, x1, y1);
|
linpat = cairo_pattern_create_linear (x0, y0, x1, y1);
|
||||||
|
@ -197,8 +188,14 @@ void free_area (Area *a)
|
||||||
g_slist_free(a->list);
|
g_slist_free(a->list);
|
||||||
a->list = 0;
|
a->list = 0;
|
||||||
}
|
}
|
||||||
if (a->pix.pmap) XFreePixmap (server.dsp, a->pix.pmap);
|
if (a->pix.pmap) {
|
||||||
if (a->pix_active.pmap) XFreePixmap (server.dsp, a->pix_active.pmap);
|
XFreePixmap (server.dsp, a->pix.pmap);
|
||||||
|
a->pix.pmap = 0;
|
||||||
|
}
|
||||||
|
if (a->pix_active.pmap) {
|
||||||
|
XFreePixmap (server.dsp, a->pix_active.pmap);
|
||||||
|
a->pix_active.pmap = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* Area manage the background and border drawing, size and padding.
|
* Area manage the background and border drawing, size and padding.
|
||||||
* Each Area have 2 Pixmap (pix and pix_active).
|
* Each Area have 2 Pixmap (pix and pix_active).
|
||||||
*
|
*
|
||||||
* Area also manage the tree of visible objects. Parent object drawn before child object.
|
* Area manage the tree of all objects. Parent object drawn before child object.
|
||||||
* panel -> taskbars -> tasks
|
* panel -> taskbars -> tasks
|
||||||
* -> systray -> icons
|
* -> systray -> icons
|
||||||
* -> clock
|
* -> clock
|
||||||
|
@ -59,6 +59,7 @@ typedef struct {
|
||||||
// list of child : Area object
|
// list of child : Area object
|
||||||
GSList *list;
|
GSList *list;
|
||||||
|
|
||||||
|
int visible;
|
||||||
// need compute position and width
|
// need compute position and width
|
||||||
int resize;
|
int resize;
|
||||||
// need redraw Pixmap
|
// need redraw Pixmap
|
||||||
|
|
Loading…
Reference in a new issue