fixed bug with active task
git-svn-id: http://tint2.googlecode.com/svn/trunk@24 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
e2e134b302
commit
0ecea24ee6
12 changed files with 356 additions and 373 deletions
|
@ -1,5 +1,6 @@
|
|||
#CFLAGS="-O2"
|
||||
FLAGS=-Wall -g `pkg-config --cflags --libs cairo pangocairo x11 xinerama imlib2 glib-2.0`
|
||||
CFLAGS= -O2
|
||||
CC = gcc
|
||||
FLAGS=-W -Wall -g `pkg-config --cflags --libs cairo pangocairo x11 xinerama imlib2 glib-2.0`
|
||||
PROGNAME=tint2
|
||||
FILES=tint.c server.c panel.c config.c taskbar/task.c taskbar/taskbar.c clock/clock.c systray/docker.c systray/icons.c systray/kde.c systray/net.c systray/xproperty.c util/window.c util/area.c
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ void init_clock(Clock *clock, int panel_height)
|
|||
if (strchr(clock->time1_format, 'S') == NULL) clock->time_precision = 60;
|
||||
else clock->time_precision = 1;
|
||||
|
||||
clock->area.posy = panel.area.border.width + panel.area.paddingy;
|
||||
clock->area.posy = panel.area.pix.border.width + panel.area.paddingy;
|
||||
clock->area.height = panel.area.height - (2 * clock->area.posy);
|
||||
clock->area.redraw = 1;
|
||||
|
||||
|
@ -94,13 +94,13 @@ redraw:
|
|||
}
|
||||
if (time_width > date_width) new_width = time_width;
|
||||
else new_width = date_width;
|
||||
new_width += (2*clock->area.paddingx) + (2*clock->area.border.width);
|
||||
new_width += (2*clock->area.paddingx) + (2*clock->area.pix.border.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);
|
||||
// resize clock
|
||||
clock->area.width = new_width;
|
||||
panel.clock.area.posx = panel.area.width - panel.clock.area.width - panel.area.paddingx - panel.area.border.width;
|
||||
panel.clock.area.posx = panel.area.width - panel.clock.area.width - panel.area.paddingx - panel.area.pix.border.width;
|
||||
|
||||
g_object_unref (layout);
|
||||
resize_taskbar();
|
||||
|
|
121
src/config.c
121
src/config.c
|
@ -199,27 +199,27 @@ void add_entry (char *key, char *value)
|
|||
/* Background and border */
|
||||
if (strcmp (key, "rounded") == 0) {
|
||||
// 'rounded' is the first parameter => alloc a new background
|
||||
Area *back = calloc(1, sizeof(Area));
|
||||
back->border.rounded = atoi (value);
|
||||
list_back = g_slist_append(list_back, back);
|
||||
Area *a = calloc(1, sizeof(Area));
|
||||
a->pix.border.rounded = atoi (value);
|
||||
list_back = g_slist_append(list_back, a);
|
||||
}
|
||||
else if (strcmp (key, "border_width") == 0) {
|
||||
Area *back = g_slist_last(list_back)->data;
|
||||
back->border.width = atoi (value);
|
||||
Area *a = g_slist_last(list_back)->data;
|
||||
a->pix.border.width = atoi (value);
|
||||
}
|
||||
else if (strcmp (key, "background_color") == 0) {
|
||||
Area *back = g_slist_last(list_back)->data;
|
||||
Area *a = g_slist_last(list_back)->data;
|
||||
extract_values(value, &value1, &value2);
|
||||
get_color (value1, back->back.color);
|
||||
if (value2) back->back.alpha = (atoi (value2) / 100.0);
|
||||
else back->back.alpha = 0.5;
|
||||
get_color (value1, a->pix.back.color);
|
||||
if (value2) a->pix.back.alpha = (atoi (value2) / 100.0);
|
||||
else a->pix.back.alpha = 0.5;
|
||||
}
|
||||
else if (strcmp (key, "border_color") == 0) {
|
||||
Area *back = g_slist_last(list_back)->data;
|
||||
Area *a = g_slist_last(list_back)->data;
|
||||
extract_values(value, &value1, &value2);
|
||||
get_color (value1, back->border.color);
|
||||
if (value2) back->border.alpha = (atoi (value2) / 100.0);
|
||||
else back->border.alpha = 0.5;
|
||||
get_color (value1, a->pix.border.color);
|
||||
if (value2) a->pix.border.alpha = (atoi (value2) / 100.0);
|
||||
else a->pix.border.alpha = 0.5;
|
||||
}
|
||||
|
||||
/* Panel */
|
||||
|
@ -260,9 +260,9 @@ void add_entry (char *key, char *value)
|
|||
g_task.font_shadow = atoi (value);
|
||||
else if (strcmp (key, "panel_background_id") == 0) {
|
||||
int id = atoi (value);
|
||||
Area *back = g_slist_nth_data(list_back, id);
|
||||
memcpy(&panel.area.back, &back->back, sizeof(Color));
|
||||
memcpy(&panel.area.border, &back->border, sizeof(Border));
|
||||
Area *a = g_slist_nth_data(list_back, id);
|
||||
memcpy(&panel.area.pix.back, &a->pix.back, sizeof(Color));
|
||||
memcpy(&panel.area.pix.border, &a->pix.border, sizeof(Border));
|
||||
}
|
||||
|
||||
/* Clock */
|
||||
|
@ -297,9 +297,9 @@ void add_entry (char *key, char *value)
|
|||
}
|
||||
else if (strcmp (key, "clock_background_id") == 0) {
|
||||
int id = atoi (value);
|
||||
Area *back = g_slist_nth_data(list_back, id);
|
||||
memcpy(&panel.clock.area.back, &back->back, sizeof(Color));
|
||||
memcpy(&panel.clock.area.border, &back->border, sizeof(Border));
|
||||
Area *a = g_slist_nth_data(list_back, id);
|
||||
memcpy(&panel.clock.area.pix.back, &a->pix.back, sizeof(Color));
|
||||
memcpy(&panel.clock.area.pix.border, &a->pix.border, sizeof(Border));
|
||||
}
|
||||
|
||||
/* Taskbar */
|
||||
|
@ -315,9 +315,9 @@ void add_entry (char *key, char *value)
|
|||
}
|
||||
else if (strcmp (key, "taskbar_background_id") == 0) {
|
||||
int id = atoi (value);
|
||||
Area *back = g_slist_nth_data(list_back, id);
|
||||
memcpy(&g_taskbar.back, &back->back, sizeof(Color));
|
||||
memcpy(&g_taskbar.border, &back->border, sizeof(Border));
|
||||
Area *a = g_slist_nth_data(list_back, id);
|
||||
memcpy(&g_taskbar.pix.back, &a->pix.back, sizeof(Color));
|
||||
memcpy(&g_taskbar.pix.border, &a->pix.border, sizeof(Border));
|
||||
}
|
||||
|
||||
/* Task */
|
||||
|
@ -332,10 +332,8 @@ void add_entry (char *key, char *value)
|
|||
else if (strcmp (key, "task_padding") == 0) {
|
||||
extract_values(value, &value1, &value2);
|
||||
g_task.area.paddingx = atoi (value1);
|
||||
g_task.area_active.paddingx = atoi (value1);
|
||||
if (value2) {
|
||||
g_task.area.paddingy = atoi (value2);
|
||||
g_task.area_active.paddingy = atoi (value2);
|
||||
}
|
||||
}
|
||||
else if (strcmp (key, "task_font") == 0) {
|
||||
|
@ -356,15 +354,15 @@ void add_entry (char *key, char *value)
|
|||
}
|
||||
else if (strcmp (key, "task_background_id") == 0) {
|
||||
int id = atoi (value);
|
||||
Area *back = g_slist_nth_data(list_back, id);
|
||||
memcpy(&g_task.area.back, &back->back, sizeof(Color));
|
||||
memcpy(&g_task.area.border, &back->border, sizeof(Border));
|
||||
Area *a = g_slist_nth_data(list_back, id);
|
||||
memcpy(&g_task.area.pix.back, &a->pix.back, sizeof(Color));
|
||||
memcpy(&g_task.area.pix.border, &a->pix.border, sizeof(Border));
|
||||
}
|
||||
else if (strcmp (key, "task_active_background_id") == 0) {
|
||||
int id = atoi (value);
|
||||
Area *back = g_slist_nth_data(list_back, id);
|
||||
memcpy(&g_task.area_active.back, &back->back, sizeof(Color));
|
||||
memcpy(&g_task.area_active.border, &back->border, sizeof(Border));
|
||||
Area *a = g_slist_nth_data(list_back, id);
|
||||
memcpy(&g_task.area.pix_active.back, &a->pix.back, sizeof(Color));
|
||||
memcpy(&g_task.area.pix_active.border, &a->pix.border, sizeof(Border));
|
||||
}
|
||||
|
||||
/* Mouse actions */
|
||||
|
@ -405,21 +403,21 @@ void add_entry (char *key, char *value)
|
|||
else if (strcmp (key, "panel_background") == 0)
|
||||
panel.old_panel_background = atoi (value);
|
||||
else if (strcmp (key, "panel_background_alpha") == 0)
|
||||
panel.area.back.alpha = (atoi (value) / 100.0);
|
||||
panel.area.pix.back.alpha = (atoi (value) / 100.0);
|
||||
else if (strcmp (key, "panel_border_alpha") == 0)
|
||||
panel.area.border.alpha = (atoi (value) / 100.0);
|
||||
panel.area.pix.border.alpha = (atoi (value) / 100.0);
|
||||
else if (strcmp (key, "task_icon") == 0)
|
||||
panel.old_task_icon = atoi (value);
|
||||
else if (strcmp (key, "task_background") == 0)
|
||||
panel.old_task_background = atoi (value);
|
||||
else if (strcmp (key, "task_background_alpha") == 0)
|
||||
g_task.area.back.alpha = (atoi (value) / 100.0);
|
||||
g_task.area.pix.back.alpha = (atoi (value) / 100.0);
|
||||
else if (strcmp (key, "task_active_background_alpha") == 0)
|
||||
g_task.area_active.back.alpha = (atoi (value) / 100.0);
|
||||
g_task.area.pix_active.back.alpha = (atoi (value) / 100.0);
|
||||
else if (strcmp (key, "task_border_alpha") == 0)
|
||||
g_task.area.border.alpha = (atoi (value) / 100.0);
|
||||
g_task.area.pix.border.alpha = (atoi (value) / 100.0);
|
||||
else if (strcmp (key, "task_active_border_alpha") == 0)
|
||||
g_task.area_active.border.alpha = (atoi (value) / 100.0);
|
||||
g_task.area.pix_active.border.alpha = (atoi (value) / 100.0);
|
||||
// disabled parameters
|
||||
else if (strcmp (key, "task_active_border_width") == 0) ;
|
||||
else if (strcmp (key, "task_active_rounded") == 0) ;
|
||||
|
@ -465,9 +463,9 @@ void config_taskbar()
|
|||
{
|
||||
int i, j;
|
||||
|
||||
if (g_task.area.border.rounded > g_task.area.height/2) {
|
||||
g_task.area.border.rounded = g_task.area.height/2;
|
||||
g_task.area_active.border.rounded = g_task.area.border.rounded;
|
||||
if (g_task.area.pix.border.rounded > g_task.area.height/2) {
|
||||
g_task.area.pix.border.rounded = g_task.area.height/2;
|
||||
g_task.area.pix_active.border.rounded = g_task.area.pix.border.rounded;
|
||||
}
|
||||
|
||||
for (i=0 ; i < 15 ; i++) {
|
||||
|
@ -534,22 +532,21 @@ void config_finish ()
|
|||
if (!panel.area.width) panel.area.width = server.monitor[panel.monitor].width;
|
||||
|
||||
// taskbar
|
||||
g_taskbar.posy = panel.area.border.width + panel.area.paddingy;
|
||||
g_taskbar.posy = panel.area.pix.border.width + panel.area.paddingy;
|
||||
g_taskbar.height = panel.area.height - (2 * g_taskbar.posy);
|
||||
g_taskbar.redraw = 1;
|
||||
|
||||
// task
|
||||
g_task.area.posy = g_taskbar.posy + g_taskbar.border.width + g_taskbar.paddingy;
|
||||
g_task.area_active.posy = g_task.area.posy;
|
||||
g_task.area.posy = g_taskbar.posy + g_taskbar.pix.border.width + g_taskbar.paddingy;
|
||||
g_task.area.height = panel.area.height - (2 * g_task.area.posy);
|
||||
g_task.area_active.height = g_task.area.height;
|
||||
g_task.area.use_active = 1;
|
||||
g_task.area.redraw = 1;
|
||||
|
||||
if (!g_task.maximum_width)
|
||||
g_task.maximum_width = server.monitor[panel.monitor].width;
|
||||
|
||||
if (panel.area.border.rounded > panel.area.height/2)
|
||||
panel.area.border.rounded = panel.area.height/2;
|
||||
if (panel.area.pix.border.rounded > panel.area.height/2)
|
||||
panel.area.pix.border.rounded = panel.area.height/2;
|
||||
|
||||
// clock
|
||||
init_clock(&panel.clock, panel.area.height);
|
||||
|
@ -559,7 +556,7 @@ void config_finish ()
|
|||
g_task.text_posy = (g_task.area.height - height) / 2.0;
|
||||
|
||||
// add task_icon_size
|
||||
g_task.text_posx = g_task.area.paddingx + g_task.area.border.width;
|
||||
g_task.text_posx = g_task.area.paddingx + g_task.area.pix.border.width;
|
||||
if (g_task.icon) {
|
||||
g_task.icon_size1 = g_task.area.height - (2 * g_task.area.paddingy);
|
||||
g_task.text_posx += g_task.icon_size1;
|
||||
|
@ -638,14 +635,14 @@ void save_config ()
|
|||
panel.marginx = panel.marginy = 0;
|
||||
|
||||
if (panel.old_task_icon == 0) g_task.icon_size1 = 0;
|
||||
if (panel.old_panel_background == 0) panel.area.back.alpha = 0;
|
||||
if (panel.old_panel_background == 0) panel.area.pix.back.alpha = 0;
|
||||
if (panel.old_task_background == 0) {
|
||||
g_task.area.back.alpha = 0;
|
||||
g_task.area_active.back.alpha = 0;
|
||||
g_task.area.pix.back.alpha = 0;
|
||||
g_task.area.pix_active.back.alpha = 0;
|
||||
}
|
||||
g_task.area.border.rounded = g_task.area.border.rounded / 2;
|
||||
g_task.area_active.border.rounded = g_task.area.border.rounded;
|
||||
panel.area.border.rounded = panel.area.border.rounded / 2;
|
||||
g_task.area.pix.border.rounded = g_task.area.pix.border.rounded / 2;
|
||||
g_task.area.pix_active.border.rounded = g_task.area.pix.border.rounded;
|
||||
panel.area.pix.border.rounded = panel.area.pix.border.rounded / 2;
|
||||
|
||||
char *path;
|
||||
FILE *fp;
|
||||
|
@ -677,10 +674,10 @@ void save_config ()
|
|||
fputs("\n#---------------------------------------------\n", fp);
|
||||
fputs("# PANEL BACKGROUND AND BORDER\n", fp);
|
||||
fputs("#---------------------------------------------\n", fp);
|
||||
fprintf(fp, "panel_rounded = %d\n", panel.area.border.rounded);
|
||||
fprintf(fp, "panel_border_width = %d\n", panel.area.border.width);
|
||||
fprintf(fp, "panel_background_color = #%02x%02x%02x %d\n", (int)(panel.area.back.color[0]*255), (int)(panel.area.back.color[1]*255), (int)(panel.area.back.color[2]*255), (int)(panel.area.back.alpha*100));
|
||||
fprintf(fp, "panel_border_color = #%02x%02x%02x %d\n", (int)(panel.area.border.color[0]*255), (int)(panel.area.border.color[1]*255), (int)(panel.area.border.color[2]*255), (int)(panel.area.border.alpha*100));
|
||||
fprintf(fp, "panel_rounded = %d\n", panel.area.pix.border.rounded);
|
||||
fprintf(fp, "panel_border_width = %d\n", panel.area.pix.border.width);
|
||||
fprintf(fp, "panel_background_color = #%02x%02x%02x %d\n", (int)(panel.area.pix.back.color[0]*255), (int)(panel.area.pix.back.color[1]*255), (int)(panel.area.pix.back.color[2]*255), (int)(panel.area.pix.back.alpha*100));
|
||||
fprintf(fp, "panel_border_color = #%02x%02x%02x %d\n", (int)(panel.area.pix.border.color[0]*255), (int)(panel.area.pix.border.color[1]*255), (int)(panel.area.pix.border.color[2]*255), (int)(panel.area.pix.border.alpha*100));
|
||||
|
||||
fputs("\n#---------------------------------------------\n", fp);
|
||||
fputs("# TASKS\n", fp);
|
||||
|
@ -696,12 +693,12 @@ void save_config ()
|
|||
fputs("\n#---------------------------------------------\n", fp);
|
||||
fputs("# TASK BACKGROUND AND BORDER\n", fp);
|
||||
fputs("#---------------------------------------------\n", fp);
|
||||
fprintf(fp, "task_rounded = %d\n", g_task.area.border.rounded);
|
||||
fprintf(fp, "task_background_color = #%02x%02x%02x %d\n", (int)(g_task.area.back.color[0]*255), (int)(g_task.area.back.color[1]*255), (int)(g_task.area.back.color[2]*255), (int)(g_task.area.back.alpha*100));
|
||||
fprintf(fp, "task_active_background_color = #%02x%02x%02x %d\n", (int)(g_task.area_active.back.color[0]*255), (int)(g_task.area_active.back.color[1]*255), (int)(g_task.area_active.back.color[2]*255), (int)(g_task.area_active.back.alpha*100));
|
||||
fprintf(fp, "task_border_width = %d\n", g_task.area.border.width);
|
||||
fprintf(fp, "task_border_color = #%02x%02x%02x %d\n", (int)(g_task.area.border.color[0]*255), (int)(g_task.area.border.color[1]*255), (int)(g_task.area.border.color[2]*255), (int)(g_task.area.border.alpha*100));
|
||||
fprintf(fp, "task_active_border_color = #%02x%02x%02x %d\n", (int)(g_task.area_active.border.color[0]*255), (int)(g_task.area_active.border.color[1]*255), (int)(g_task.area_active.border.color[2]*255), (int)(g_task.area_active.border.alpha*100));
|
||||
fprintf(fp, "task_rounded = %d\n", g_task.area.pix.border.rounded);
|
||||
fprintf(fp, "task_background_color = #%02x%02x%02x %d\n", (int)(g_task.area.pix.back.color[0]*255), (int)(g_task.area.pix.back.color[1]*255), (int)(g_task.area.pix.back.color[2]*255), (int)(g_task.area.pix.back.alpha*100));
|
||||
fprintf(fp, "task_active_background_color = #%02x%02x%02x %d\n", (int)(g_task.area.pix_active.back.color[0]*255), (int)(g_task.area.pix_active.back.color[1]*255), (int)(g_task.area.pix_active.back.color[2]*255), (int)(g_task.area.pix_active.back.alpha*100));
|
||||
fprintf(fp, "task_border_width = %d\n", g_task.area.pix.border.width);
|
||||
fprintf(fp, "task_border_color = #%02x%02x%02x %d\n", (int)(g_task.area.pix.border.color[0]*255), (int)(g_task.area.pix.border.color[1]*255), (int)(g_task.area.pix.border.color[2]*255), (int)(g_task.area.pix.border.alpha*100));
|
||||
fprintf(fp, "task_active_border_color = #%02x%02x%02x %d\n", (int)(g_task.area.pix_active.border.color[0]*255), (int)(g_task.area.pix_active.border.color[1]*255), (int)(g_task.area.pix_active.border.color[2]*255), (int)(g_task.area.pix_active.border.alpha*100));
|
||||
|
||||
fputs("\n#---------------------------------------------\n", fp);
|
||||
fputs("# CLOCK\n", fp);
|
||||
|
|
14
src/panel.c
14
src/panel.c
|
@ -31,12 +31,12 @@
|
|||
|
||||
void visual_refresh ()
|
||||
{
|
||||
if (!panel.area.pmap)
|
||||
if (!panel.area.pix.pmap)
|
||||
set_panel_background();
|
||||
|
||||
if (server.pmap) XFreePixmap (server.dsp, server.pmap);
|
||||
server.pmap = server_create_pixmap (panel.area.width, panel.area.height);
|
||||
XCopyArea (server.dsp, panel.area.pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
|
||||
XCopyArea (server.dsp, panel.area.pix.pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0);
|
||||
|
||||
// draw child object
|
||||
GSList *l = panel.area.list;
|
||||
|
@ -176,24 +176,24 @@ void set_panel_background()
|
|||
{
|
||||
Pixmap wall = get_root_pixmap();
|
||||
|
||||
panel.area.pmap = server_create_pixmap (panel.area.width, panel.area.height);
|
||||
panel.area.pix.pmap = server_create_pixmap (panel.area.width, panel.area.height);
|
||||
|
||||
// add layer of root pixmap
|
||||
XCopyArea (server.dsp, wall, panel.area.pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0);
|
||||
XCopyArea (server.dsp, wall, panel.area.pix.pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0);
|
||||
|
||||
// draw background panel
|
||||
cairo_surface_t *cs;
|
||||
cairo_t *c;
|
||||
cs = cairo_xlib_surface_create (server.dsp, panel.area.pmap, server.visual, panel.area.width, panel.area.height);
|
||||
cs = cairo_xlib_surface_create (server.dsp, panel.area.pix.pmap, server.visual, panel.area.width, panel.area.height);
|
||||
c = cairo_create (cs);
|
||||
|
||||
draw_background (&panel.area, c);
|
||||
draw_background (&panel.area, c, 0);
|
||||
|
||||
cairo_destroy (c);
|
||||
cairo_surface_destroy (cs);
|
||||
|
||||
// copy background panel on desktop window
|
||||
XCopyArea (server.dsp, panel.area.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy);
|
||||
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);
|
||||
|
||||
set_redraw (&panel.area);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ void add_task (Window win)
|
|||
get_icon(new_tsk);
|
||||
get_title(new_tsk);
|
||||
memcpy(&new_tsk->area, &g_task.area, sizeof(Area));
|
||||
memcpy(&new_tsk->area_active, &g_task.area_active, sizeof(Area));
|
||||
desktop = window_get_desktop (new_tsk->win);
|
||||
monitor = window_get_monitor (new_tsk->win);
|
||||
|
||||
|
@ -103,8 +102,8 @@ void remove_task (Task *tsk)
|
|||
free (tsk->icon_data);
|
||||
tsk->icon_data = 0;
|
||||
}
|
||||
XFreePixmap (server.dsp, tsk->area.pmap);
|
||||
XFreePixmap (server.dsp, tsk->area_active.pmap);
|
||||
XFreePixmap (server.dsp, tsk->area.pix.pmap);
|
||||
XFreePixmap (server.dsp, tsk->area.pix_active.pmap);
|
||||
free(tsk);
|
||||
}
|
||||
|
||||
|
@ -180,10 +179,7 @@ void draw_task_icon (Task *tsk, int text_width, int active)
|
|||
if (tsk->icon_data == 0) get_icon (tsk);
|
||||
if (tsk->icon_data == 0) return;
|
||||
|
||||
Pixmap *pmap;
|
||||
|
||||
if (active) pmap = &tsk->area_active.pmap;
|
||||
else pmap = &tsk->area.pmap;
|
||||
Pixmap *pmap = (active == 0) ? (&tsk->area.pix.pmap) : (&tsk->area.pix_active.pmap);
|
||||
|
||||
/* Find pos */
|
||||
int pos_x;
|
||||
|
@ -193,7 +189,7 @@ void draw_task_icon (Task *tsk, int text_width, int active)
|
|||
else
|
||||
pos_x = (tsk->area.width - g_task.icon_size1) / 2;
|
||||
}
|
||||
else pos_x = g_task.area.paddingx + g_task.area.border.width;
|
||||
else pos_x = g_task.area.paddingx + g_task.area.pix.border.width;
|
||||
|
||||
/* Render */
|
||||
Imlib_Image icon;
|
||||
|
@ -222,9 +218,8 @@ void draw_task_icon (Task *tsk, int text_width, int active)
|
|||
imlib_get_color_modifier_tables (red, green, blue, alpha);
|
||||
|
||||
int i, opacity;
|
||||
if (active) opacity = 255*g_task.font_active.alpha;
|
||||
else opacity = 255*g_task.font.alpha;
|
||||
for(i = 127; i < 256; i++) alpha[i] = opacity;
|
||||
opacity = (active == 0) ? (255*g_task.font.alpha) : (255*g_task.font_active.alpha);
|
||||
for (i = 127; i < 256; i++) alpha[i] = opacity;
|
||||
|
||||
imlib_set_color_modifier_tables (red, green, blue, alpha);
|
||||
|
||||
|
@ -237,8 +232,9 @@ void draw_task_icon (Task *tsk, int text_width, int active)
|
|||
}
|
||||
|
||||
|
||||
void draw_task_title (cairo_t *c, Task *tsk, int active)
|
||||
void draw_foreground_task (void *obj, cairo_t *c, int active)
|
||||
{
|
||||
Task *tsk = obj;
|
||||
PangoLayout *layout;
|
||||
config_color *config_text;
|
||||
int width, height;
|
||||
|
@ -283,39 +279,3 @@ void draw_task_title (cairo_t *c, Task *tsk, int active)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void draw_background_task (void *obj, cairo_t *c)
|
||||
{
|
||||
Task *tsk = obj;
|
||||
|
||||
draw_background (&tsk->area_active, c);
|
||||
draw_background (&tsk->area_inactive, c);
|
||||
}
|
||||
|
||||
|
||||
void draw_foreground_task (void *obj, cairo_t *c)
|
||||
{
|
||||
Task *tsk = obj;
|
||||
cairo_surface_t *cs;
|
||||
cairo_t *ca;
|
||||
//printf(" draw_foreground_task\n");
|
||||
|
||||
draw_task_title (c, tsk, 0);
|
||||
|
||||
// draw active pmap
|
||||
if (tsk->area_active.pmap) XFreePixmap (server.dsp, tsk->area_active.pmap);
|
||||
tsk->area_active.pmap = server_create_pixmap (tsk->area.width, tsk->area.height);
|
||||
|
||||
// add layer of root pixmap
|
||||
XCopyArea (server.dsp, server.pmap, tsk->area_active.pmap, server.gc, tsk->area.posx, tsk->area.posy, tsk->area.width, tsk->area.height, 0, 0);
|
||||
|
||||
cs = cairo_xlib_surface_create (server.dsp, tsk->area_active.pmap, server.visual, tsk->area.width, tsk->area.height);
|
||||
ca = cairo_create (cs);
|
||||
|
||||
// redraw task
|
||||
draw_task_title (ca, tsk, 1);
|
||||
|
||||
cairo_destroy (ca);
|
||||
cairo_surface_destroy (cs);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
// global task parameter
|
||||
typedef struct {
|
||||
Area area;
|
||||
Area area_active;
|
||||
Area area_inactive;
|
||||
|
||||
int text;
|
||||
int icon;
|
||||
|
@ -41,8 +39,6 @@ typedef struct {
|
|||
typedef struct {
|
||||
// always start with area
|
||||
Area area;
|
||||
Area area_active;
|
||||
Area area_inactive;
|
||||
|
||||
// TODO: group task with list of windows here
|
||||
Window win;
|
||||
|
@ -59,7 +55,7 @@ Global_task g_task;
|
|||
void add_task (Window win);
|
||||
void remove_task (Task *tsk);
|
||||
|
||||
void draw_foreground_task (void *obj, cairo_t *c);
|
||||
void draw_foreground_task (void *obj, cairo_t *c, int active);
|
||||
|
||||
void get_icon (Task *tsk);
|
||||
void get_title(Task *tsk);
|
||||
|
|
|
@ -63,6 +63,10 @@ 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;
|
||||
}
|
||||
|
||||
nb = panel.nb_desktop * panel.nb_monitor;
|
||||
for (i=0 ; i < nb ; i++) {
|
||||
|
@ -71,7 +75,10 @@ void task_refresh_tasklist ()
|
|||
tsk = l0->data;
|
||||
l0 = l0->next;
|
||||
|
||||
if (tsk->win == active_win) panel.task_active = tsk;
|
||||
if (tsk->win == active_win) {
|
||||
tsk->area.is_active = 1;
|
||||
panel.task_active = tsk;
|
||||
}
|
||||
|
||||
for (j = 0; j < num_results; j++) {
|
||||
if (tsk->win == win[j]) break;
|
||||
|
@ -101,7 +108,7 @@ int resize_tasks (Taskbar *taskbar)
|
|||
task_count = g_slist_length(taskbar->area.list);
|
||||
if (!task_count) pixel_width = g_task.maximum_width;
|
||||
else {
|
||||
taskbar_width = taskbar->area.width - (2 * g_taskbar.border.width) - ((task_count+1) * g_taskbar.paddingx);
|
||||
taskbar_width = taskbar->area.width - (2 * g_taskbar.pix.border.width) - ((task_count+1) * g_taskbar.paddingx);
|
||||
|
||||
pixel_width = taskbar_width / task_count;
|
||||
if (pixel_width > g_task.maximum_width) pixel_width = g_task.maximum_width;
|
||||
|
@ -115,20 +122,17 @@ 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.border.width - g_task.area.paddingx;
|
||||
taskbar->text_width = pixel_width - g_task.text_posx - g_task.area.pix.border.width - g_task.area.paddingx;
|
||||
}
|
||||
|
||||
// change pos_x and width for all tasks
|
||||
x = taskbar->area.posx + taskbar->area.border.width + taskbar->area.paddingx;
|
||||
x = taskbar->area.posx + taskbar->area.pix.border.width + taskbar->area.paddingx;
|
||||
for (l = taskbar->area.list; l ; l = l->next) {
|
||||
tsk = l->data;
|
||||
tsk->area.posx = x;
|
||||
tsk->area_active.posx = x;
|
||||
tsk->area.width = pixel_width;
|
||||
tsk->area_active.width = pixel_width;
|
||||
if (modulo_width) {
|
||||
tsk->area.width++;
|
||||
tsk->area_active.width++;
|
||||
modulo_width--;
|
||||
}
|
||||
|
||||
|
@ -146,7 +150,7 @@ void resize_taskbar()
|
|||
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);
|
||||
taskbar_width = panel.area.width - (2 * panel.area.paddingx) - (2 * panel.area.pix.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;
|
||||
|
@ -156,11 +160,11 @@ void resize_taskbar()
|
|||
else
|
||||
modulo_width = 0;
|
||||
|
||||
int posx, modulo, i, nb;
|
||||
int i, nb, modulo=0, posx=0;
|
||||
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;
|
||||
posx = panel.area.pix.border.width + panel.area.paddingx;
|
||||
modulo = modulo_width;
|
||||
}
|
||||
else posx += taskbar_width + panel.area.paddingx;
|
||||
|
|
30
src/tint.c
30
src/tint.c
|
@ -246,22 +246,29 @@ void event_property_notify (Window win, Atom at)
|
|||
task_refresh_tasklist ();
|
||||
panel.refresh = 1;
|
||||
}
|
||||
/* Active */
|
||||
/* Change active */
|
||||
else if (at == server.atom._NET_ACTIVE_WINDOW) {
|
||||
if (panel.task_active) {
|
||||
panel.task_active->area.is_active = 0;
|
||||
panel.task_active = 0;
|
||||
}
|
||||
Window w1 = window_get_active ();
|
||||
Task *t = task_get_task(w1);
|
||||
if (t) panel.task_active = t;
|
||||
else {
|
||||
if (!t) {
|
||||
Window w2;
|
||||
if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
|
||||
if (w2) panel.task_active = task_get_task(w2);
|
||||
if (w2) t = task_get_task(w2);
|
||||
}
|
||||
if (t) {
|
||||
t->area.is_active = 1;
|
||||
panel.task_active = t;
|
||||
}
|
||||
panel.refresh = 1;
|
||||
}
|
||||
/* Wallpaper changed */
|
||||
else if (at == server.atom._XROOTPMAP_ID) {
|
||||
XFreePixmap (server.dsp, panel.area.pmap);
|
||||
panel.area.pmap = 0;
|
||||
XFreePixmap (server.dsp, panel.area.pix.pmap);
|
||||
panel.area.pix.pmap = 0;
|
||||
panel.refresh = 1;
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +287,10 @@ void event_property_notify (Window win, Atom at)
|
|||
/* Iconic state */
|
||||
else if (at == server.atom.WM_STATE) {
|
||||
if (window_is_iconified (win))
|
||||
if (panel.task_active == tsk) panel.task_active = 0;
|
||||
if (panel.task_active == tsk) {
|
||||
tsk->area.is_active = 0;
|
||||
panel.task_active = 0;
|
||||
}
|
||||
}
|
||||
/* Window icon changed */
|
||||
else if (at == server.atom._NET_WM_ICON) {
|
||||
|
@ -349,8 +359,8 @@ int main (int argc, char *argv[])
|
|||
init ();
|
||||
|
||||
load_config:
|
||||
if (panel.area.pmap) XFreePixmap (server.dsp, panel.area.pmap);
|
||||
panel.area.pmap = 0;
|
||||
if (panel.area.pix.pmap) XFreePixmap (server.dsp, panel.area.pix.pmap);
|
||||
panel.area.pix.pmap = 0;
|
||||
// append full transparency background
|
||||
list_back = g_slist_append(0, calloc(1, sizeof(Area)));
|
||||
|
||||
|
@ -399,7 +409,7 @@ load_config:
|
|||
break;
|
||||
|
||||
case Expose:
|
||||
XCopyArea (server.dsp, panel.area.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy);
|
||||
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, window.main_win, server.gc, panel.area.paddingx, 0, panel.area.width-(2*panel.area.paddingx), panel.area.height, 0, 0);
|
||||
break;
|
||||
|
||||
|
|
BIN
src/tint2
BIN
src/tint2
Binary file not shown.
|
@ -33,20 +33,23 @@
|
|||
void refresh (Area *a)
|
||||
{
|
||||
if (a->redraw) {
|
||||
if (a->draw)
|
||||
a->draw(a);
|
||||
else
|
||||
draw(a);
|
||||
//printf("draw pix\n");
|
||||
draw(a, 0);
|
||||
if (a->use_active)
|
||||
draw(a, 1);
|
||||
a->redraw = 0;
|
||||
//printf("end draw pix\n");
|
||||
}
|
||||
|
||||
XCopyArea (server.dsp, a->pmap, server.pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
|
||||
Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
|
||||
|
||||
// draw current Area
|
||||
XCopyArea (server.dsp, *pmap, server.pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
|
||||
|
||||
// and then refresh child object
|
||||
GSList *l = a->list;
|
||||
// refresh child object (after refreshing parent)
|
||||
for (; l ; l = l->next)
|
||||
refresh(l->data);
|
||||
|
||||
//printf("end refresh area\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,47 +63,50 @@ void set_redraw (Area *a)
|
|||
}
|
||||
|
||||
|
||||
void draw (Area *a)
|
||||
void draw (Area *a, int active)
|
||||
{
|
||||
Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
|
||||
|
||||
//printf("begin draw area\n");
|
||||
if (*pmap) XFreePixmap (server.dsp, *pmap);
|
||||
*pmap = server_create_pixmap (a->width, a->height);
|
||||
|
||||
// add layer of root pixmap
|
||||
XCopyArea (server.dsp, server.pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
|
||||
|
||||
cairo_surface_t *cs;
|
||||
cairo_t *c;
|
||||
|
||||
//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
|
||||
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, *pmap, server.visual, a->width, a->height);
|
||||
c = cairo_create (cs);
|
||||
|
||||
draw_background (a, c);
|
||||
draw_background (a, c, active);
|
||||
|
||||
if (a->draw_foreground)
|
||||
a->draw_foreground(a, c);
|
||||
a->draw_foreground(a, c, active);
|
||||
|
||||
cairo_destroy (c);
|
||||
cairo_surface_destroy (cs);
|
||||
a->redraw = 0;
|
||||
}
|
||||
|
||||
|
||||
void draw_background (Area *a, cairo_t *c)
|
||||
void draw_background (Area *a, cairo_t *c, int active)
|
||||
{
|
||||
if (a->back.alpha > 0.0) {
|
||||
//printf(" draw_background %d %d\n", a->width, a->height);
|
||||
draw_rect(c, a->border.width, a->border.width, a->width-(2.0 * a->border.width), a->height-(2.0*a->border.width), a->border.rounded - a->border.width/1.571);
|
||||
cairo_set_source_rgba(c, a->back.color[0], a->back.color[1], a->back.color[2], a->back.alpha);
|
||||
Pmap *pix = (active == 0) ? (&a->pix) : (&a->pix_active);
|
||||
|
||||
if (pix->back.alpha > 0.0) {
|
||||
//printf(" draw_background (%d %d) RGBA (%lf, %lf, %lf, %lf)\n", a->posx, a->posy, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha);
|
||||
draw_rect(c, pix->border.width, pix->border.width, a->width-(2.0 * pix->border.width), a->height-(2.0*pix->border.width), pix->border.rounded - pix->border.width/1.571);
|
||||
cairo_set_source_rgba(c, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha);
|
||||
|
||||
cairo_fill(c);
|
||||
}
|
||||
|
||||
if (a->border.width > 0 && a->border.alpha > 0.0) {
|
||||
cairo_set_line_width (c, a->border.width);
|
||||
if (pix->border.width > 0 && pix->border.alpha > 0.0) {
|
||||
cairo_set_line_width (c, pix->border.width);
|
||||
|
||||
// draw border inside (x, y, width, height)
|
||||
draw_rect(c, a->border.width/2.0, a->border.width/2.0, a->width - a->border.width, a->height - a->border.width, a->border.rounded);
|
||||
draw_rect(c, pix->border.width/2.0, pix->border.width/2.0, a->width - pix->border.width, a->height - pix->border.width, pix->border.rounded);
|
||||
/*
|
||||
// convert : radian = degre * M_PI/180
|
||||
// définir le dégradé dans un carré de (0,0) (100,100)
|
||||
|
@ -138,7 +144,7 @@ void draw_background (Area *a, cairo_t *c)
|
|||
cairo_pattern_add_color_stop_rgba (linpat, 1, a->border.color[0], a->border.color[1], a->border.color[2], 0);
|
||||
cairo_set_source (c, linpat);
|
||||
*/
|
||||
cairo_set_source_rgba (c, a->border.color[0], a->border.color[1], a->border.color[2], a->border.alpha);
|
||||
cairo_set_source_rgba (c, pix->border.color[0], pix->border.color[1], pix->border.color[2], pix->border.alpha);
|
||||
|
||||
cairo_stroke (c);
|
||||
//cairo_pattern_destroy (linpat);
|
||||
|
|
|
@ -2,16 +2,19 @@
|
|||
* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
|
||||
*
|
||||
* base class for all graphical objects (panel, taskbar, task, systray, clock, ...).
|
||||
* Area is at the begining of each graphical object so &object == &area.
|
||||
* Area is at the begining of each object (&object == &area).
|
||||
*
|
||||
* Area manage the background and border drawing, size and padding.
|
||||
* Area also manage the tree of visible objects
|
||||
* Each Area have 2 Pixmap (pix and pix_active).
|
||||
*
|
||||
* Area also manage the tree of visible objects. Parent object drawn before child object.
|
||||
* panel -> taskbars -> tasks
|
||||
* -> systray -> icons
|
||||
* -> clock
|
||||
*
|
||||
* draw_foreground(obj) and draw(obj) are virtual function.
|
||||
* draw_foreground(obj) is virtual function.
|
||||
*
|
||||
* TODO :
|
||||
* resize_width(obj, width) = 0 : fonction virtuelle à redéfinir
|
||||
* recalcule la largeur de l'objet (car la hauteur est fixe)
|
||||
* - taille systray calculée à partir de la liste des icones
|
||||
|
@ -20,7 +23,6 @@
|
|||
* - taille d'une taskbar calculée à partir de la taille du panel et des autres objets
|
||||
*
|
||||
* voir resize_taskbar(), resize_clock() et resize_tasks()
|
||||
* variable widthChanged ou bien emission d'un signal ???
|
||||
* voir config(obj) configure un objet (définie les positions verticales)
|
||||
*
|
||||
**************************************************************************/
|
||||
|
@ -34,7 +36,6 @@
|
|||
#include "common.h"
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double color[3];
|
||||
|
@ -51,29 +52,35 @@ typedef struct
|
|||
} Color;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Pixmap pmap;
|
||||
Color back;
|
||||
Border border;
|
||||
} Pmap;
|
||||
|
||||
|
||||
// TODO: isoler 'draw' de 'refresh'
|
||||
// TODO: isoler les données locales des données communes aux freres
|
||||
typedef struct {
|
||||
// TODO: isoler 'draw' de 'refresh'
|
||||
// TODO: isoler les données locales des données communes aux freres
|
||||
// absolute coordinate in panel
|
||||
int posx, posy;
|
||||
int width, height;
|
||||
Pixmap pmap;
|
||||
Pmap pix;
|
||||
Pmap pix_active;
|
||||
|
||||
// list of child : Area object
|
||||
GSList *list;
|
||||
|
||||
// need redraw Pixmap
|
||||
int redraw;
|
||||
int use_active, is_active;
|
||||
int paddingx, paddingy;
|
||||
// parent Area
|
||||
void *parent;
|
||||
|
||||
Color back;
|
||||
Border border;
|
||||
|
||||
// each object can overwrite following function
|
||||
void (*draw)(void *obj);
|
||||
void (*draw_foreground)(void *obj, cairo_t *c);
|
||||
void (*draw_foreground)(void *obj, cairo_t *c, int active);
|
||||
void (*add_child)(void *obj);
|
||||
int (*remove_child)(void *obj);
|
||||
} Area;
|
||||
|
@ -85,8 +92,10 @@ void refresh (Area *a);
|
|||
|
||||
// set 'redraw' on an area and childs
|
||||
void set_redraw (Area *a);
|
||||
void draw (Area *a);
|
||||
void draw_background (Area *a, cairo_t *c);
|
||||
|
||||
// draw pixmap and pixmap_active
|
||||
void draw (Area *a, int active);
|
||||
void draw_background (Area *a, cairo_t *c, int active);
|
||||
|
||||
void remove_area (Area *a);
|
||||
void add_area (Area *a);
|
||||
|
|
Loading…
Reference in a new issue