-#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
/**************************************************************************
*
* Tint2 : clock
-*
+*
* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
-*
+*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
int time_height, time_height_ink, date_height, date_height_ink;
if (!clock->time1_format) return;
-
+
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;
+ clock->area.redraw = 1;
gettimeofday(&clock->clock, 0);
clock->clock.tv_sec -= clock->clock.tv_sec % clock->time_precision;
-
+
strftime(buf_time, sizeof(buf_time), clock->time1_format, localtime(&clock->clock.tv_sec));
if (clock->time2_format)
strftime(buf_date, sizeof(buf_date), clock->time2_format, localtime(&clock->clock.tv_sec));
-
+
get_text_size(clock->time1_font_desc, &time_height_ink, &time_height, panel_height, buf_time, strlen(buf_time));
clock->time1_posy = (clock->area.height - time_height) / 2;
- if (clock->time2_format) {
+ if (clock->time2_format) {
get_text_size(clock->time2_font_desc, &date_height_ink, &date_height, panel_height, buf_date, strlen(buf_date));
-
+
clock->time1_posy -= ((date_height_ink + 2) / 2);
clock->time2_posy = clock->time1_posy + time_height + 2 - (time_height - time_height_ink)/2 - (date_height - date_height_ink)/2;
}
}
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();
goto redraw;
pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_date, strlen(buf_date));
pango_layout_set_width (layout, clock->area.width * PANGO_SCALE);
-
+
pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time2_posy);
pango_cairo_show_layout (c, layout);
}
-
+
g_object_unref (layout);
}
#include "window.h"
-void cleanup_taskbar()
-{
+void cleanup_taskbar()
+{
GSList *l0;
Task *tsk;
-
+
int i, nb;
nb = panel.nb_desktop * panel.nb_monitor;
for (i=0 ; i < nb ; i++) {
// careful : remove_task change l0->next
remove_task (tsk);
}
-
+
free_area (&panel.taskbar[i].area);
}
free(panel.taskbar);
panel.taskbar = 0;
-
+
free_area(&panel.area);
}
fileSrc = fopen(pathSrc, "rb");
if (fileSrc == NULL) return;
-
+
fileDest = fopen(pathDest, "wb");
if (fileDest == NULL) return;
-
+
while ((nb = fread(line, 1, 100, fileSrc)) > 0) fwrite(line, 1, nb, fileDest);
-
+
fclose (fileDest);
fclose (fileSrc);
}
if (*value1) free (*value1);
if (*value2) free (*value2);
-
+
if ((b = strchr (value, ' '))) {
b[0] = '\0';
b++;
g_strstrip(*value2);
}
else *value2 = 0;
-
+
*value1 = strdup (value);
g_strstrip(*value1);
}
int hex_char_to_int (char c)
{
int r;
-
+
if (c >= '0' && c <= '9') r = c - '0';
else if (c >= 'a' && c <= 'f') r = c - 'a' + 10;
else if (c >= 'A' && c <= 'F') r = c - 'A' + 10;
/* 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 */
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 */
}
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 */
else if (strcmp (key, "taskbar_mode") == 0) {
if (strcmp (value, "multi_desktop") == 0) panel.mode = MULTI_DESKTOP;
}
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 */
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) {
}
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 */
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) ;
-
+
else
fprintf(stderr, "Invalid option: \"%s\", correct your config file\n", key);
{
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++) {
server.nb_desktop = server_get_number_of_desktop ();
if (server.nb_desktop > 0) break;
}
if (panel.taskbar) cleanup_taskbar();
-
+
panel.nb_desktop = server.nb_desktop;
if (panel.mode == MULTI_MONITOR) panel.nb_monitor = server.nb_monitor;
else panel.nb_monitor = 1;
memcpy(&tskbar->area, &g_taskbar, sizeof(Area));
tskbar->desktop = i;
tskbar->monitor = j;
-
+
// 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)
panel.area.list = g_slist_append(panel.area.list, &panel.clock);
-
+
//printf("taskbar (desktop x monitor) : (%d x %d)\n", panel.nb_desktop, panel.nb_monitor);
resize_taskbar();
task_refresh_tasklist ();
void config_finish ()
{
int height_ink, height;
-
+
if (panel.old_config_file) save_config();
// get monitor's configuration
else {
panel.sleep_mode = 0;
//printf("tint2 wake up on monitor %d\n", panel.monitor+1);
- 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");
}
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);
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;
g_task.icon_posy = (g_task.area.height - g_task.icon_size1) / 2;
}
-
+
config_taskbar();
visible_object();
// check tint2rc file according to XDG specification
path1 = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
if (!g_file_test (path1, G_FILE_TEST_EXISTS)) {
-
+
path2 = 0;
system_dirs = g_get_system_config_dirs();
for (i = 0; system_dirs[i]; i++) {
path2 = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL);
-
+
if (g_file_test(path2, G_FILE_TEST_EXISTS)) break;
g_free (path2);
path2 = 0;
}
-
+
if (path2) {
// copy file in user directory (path1)
dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) g_mkdir(dir, 0777);
g_free(dir);
-
+
copy_file(path2, path1);
g_free(path2);
}
{
FILE *fp;
char line[80];
-
+
if ((fp = fopen(path, "r")) == NULL) return 0;
-
+
while (fgets(line, sizeof(line), fp) != NULL)
parse_line (line);
fprintf(stderr, "tint2 warning : convert user's config file\n");
panel.area.paddingx = panel.area.paddingy = panel.marginx;
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;
fp = fopen(path, "w");
g_free(path);
if (fp == NULL) return;
-
+
fputs("#---------------------------------------------\n", fp);
fputs("# TINT CONFIG FILE\n", fp);
fputs("#---------------------------------------------\n\n", fp);
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);
fputs("#---------------------------------------------\n", fp);
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);
else if (panel.mouse_right == ICONIFY) fputs("mouse_right = iconify\n", fp);
else if (panel.mouse_right == SHADE) fputs("mouse_right = shade\n", fp);
else fputs("mouse_right = toggle_iconify\n", fp);
-
+
if (panel.mouse_scroll_up == NONE) fputs("mouse_scroll_up = none\n", fp);
else if (panel.mouse_scroll_up == CLOSE) fputs("mouse_scroll_up = close\n", fp);
else if (panel.mouse_scroll_up == TOGGLE) fputs("mouse_scroll_up = toggle\n", fp);
else if (panel.mouse_scroll_up == ICONIFY) fputs("mouse_scroll_up = iconify\n", fp);
else if (panel.mouse_scroll_up == SHADE) fputs("mouse_scroll_up = shade\n", fp);
else fputs("mouse_scroll_up = toggle_iconify\n", fp);
-
+
if (panel.mouse_scroll_down == NONE) fputs("mouse_scroll_down = none\n", fp);
else if (panel.mouse_scroll_down == CLOSE) fputs("mouse_scroll_down = close\n", fp);
else if (panel.mouse_scroll_down == TOGGLE) fputs("mouse_scroll_down = toggle\n", fp);
void visual_refresh ()
{
- if (!panel.area.pmap)
- set_panel_background();
-
+ 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;
XChangeProperty(server.dsp, win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 8, PropModeReplace, (unsigned char *) name, (int) len);
g_free(name);
}
-
+
// Dock
long val = server.atom._NET_WM_WINDOW_TYPE_DOCK;
XChangeProperty (server.dsp, win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1);
// Old specification : fluxbox need _NET_WM_STRUT.
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
val = 0xFFFFFFFF;
XChangeProperty (server.dsp, win, server.atom._NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1);
state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR;
state[2] = server.atom._NET_WM_STATE_STICKY;
state[3] = server.atom._NET_WM_STATE_BELOW;
- XChangeProperty (server.dsp, win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4);
-
+ XChangeProperty (server.dsp, win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4);
+
// Fixed position
XSizeHints size_hints;
size_hints.flags = PPosition;
XChangeProperty (server.dsp, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4);
-
+
// Unfocusable
XWMHints wmhints;
wmhints.flags = InputHint;
wmhints.input = False;
XChangeProperty (server.dsp, win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4);
-
+
// Undecorated
long prop[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(server.dsp, win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5);
/* Catch some events */
XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 };
-
+
// XCreateWindow(display, parent, x, y, w, h, border, depth, class, visual, mask, attrib)
// main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right.
if (window.main_win) XDestroyWindow(server.dsp, window.main_win);
{
if (panel.area.list) {
g_slist_free(panel.area.list);
- panel.area.list = 0;
+ panel.area.list = 0;
}
// list of visible objects
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);
}
}
{
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);
}
/**************************************************************************
*
* Tint2 panel
-*
+*
* Copyright (C) 2007 Pål Staurland (staura@gmail.com)
* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
-*
+*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
Pixmap ret;
Window root = RootWindow(server.dsp, server.screen);
- ret = None;
+ ret = None;
int act_format, c = 2 ;
u_long nitems ;
u_long bytes_after ;
Pixmap root_pixmap;
unsigned long *res;
- server.root_win = window_get_root();
+ server.root_win = window_get_root();
res = server_get_property (server.root_win, server.atom._XROOTPMAP_ID, XA_PIXMAP, 0);
if (res) {
// try _XSETROOT_ID
}
return 0;
-}
+}
*/
if (server.monitor) free(server.monitor);
server.nb_monitor = 0;
server.monitor = 0;
-
+
if (XineramaIsActive(server.dsp)) {
XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &server.nb_monitor);
if (info) {
int i;
-
+
server.monitor = calloc(server.nb_monitor, sizeof(Monitor));
for (i = 0; i < server.nb_monitor; i++) {
server.monitor[i].x = info[i].x_org;
server.monitor[i].y = info[i].y_org;
server.monitor[i].width = info[i].width;
server.monitor[i].height = info[i].height;
- }
+ }
XFree(info);
}
}
/**************************************************************************
*
* Tint2 : task
-*
+*
* Copyright (C) 2007 Pål Staurland (staura@gmail.com)
* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
-*
+*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
new_tsk->win = win;
new_tsk->title = 0;
new_tsk->icon_data = 0;
-
+
get_icon(new_tsk);
get_title(new_tsk);
memcpy(&new_tsk->area, &g_task.area, sizeof(Area));
- 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);
-
+
//if (panel.mode == MULTI_MONITOR) monitor = window_get_monitor (new_tsk->win);
//else monitor = 0;
//printf("task %s : desktop %d, monitor %d\n", new_tsk->title, desktop, monitor);
-
+
XSelectInput (server.dsp, new_tsk->win, PropertyChangeMask|StructureNotifyMask);
-
+
if (desktop == 0xFFFFFFFF) {
if (new_tsk->title) {
free (new_tsk->title);
fprintf(stderr, "task on all desktop : ignored\n");
return;
}
-
+
//printf("add_task %d %s\n", index(desktop, monitor), new_tsk->title);
Taskbar *tskbar;
- tskbar = &panel.taskbar[index(desktop, monitor)];
+ tskbar = &panel.taskbar[index(desktop, monitor)];
new_tsk->area.parent = tskbar;
tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk);
void remove_task (Task *tsk)
{
if (!tsk) return;
-
+
Taskbar *tskbar;
tskbar = (Taskbar*)tsk->area.parent;
tskbar->area.list = g_slist_remove(tskbar->area.list, 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);
}
}
// add space before title
- title = malloc(strlen(name)+2);
+ title = malloc(strlen(name)+2);
if (g_task.icon) strcpy(title, " ");
else title[0] = 0;
strcat(title, name);
void get_icon (Task *tsk)
{
if (!g_task.icon) return;
-
+
long *data;
int num;
tsk->icon_height = h;
tsk->icon_data = malloc (w * h * sizeof (long));
memcpy (tsk->icon_data, tmp_data, w * h * sizeof (long));
-
+
XFree (data);
}
else {
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;
if (g_task.centered) {
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;
Imlib_Color_Modifier cmod;
data[i] = tsk->icon_data[i];
}
else data = (DATA32 *) tsk->icon_data;
-
+
icon = imlib_create_image_using_data (tsk->icon_width, tsk->icon_height, data);
imlib_context_set_image (icon);
imlib_context_set_drawable (*pmap);
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);
-
+
//imlib_render_image_on_drawable (pos_x, pos_y);
imlib_render_image_on_drawable_at_size (pos_x, g_task.icon_posy, g_task.icon_size1, g_task.icon_size1);
-
+
imlib_free_color_modifier ();
imlib_free_image ();
if (sizeof(long) != 4) free(data);
}
-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;
-
+
if (g_task.text) {
- /* Layout */
- layout = pango_cairo_create_layout (c);
- pango_layout_set_font_description (layout, g_task.font_desc);
- pango_layout_set_text (layout, tsk->title, -1);
+ /* Layout */
+ layout = pango_cairo_create_layout (c);
+ pango_layout_set_font_description (layout, g_task.font_desc);
+ pango_layout_set_text (layout, tsk->title, -1);
- /* Drawing width and Cut text */
- pango_layout_set_width (layout, ((Taskbar*)tsk->area.parent)->text_width * PANGO_SCALE);
- pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+ /* Drawing width and Cut text */
+ pango_layout_set_width (layout, ((Taskbar*)tsk->area.parent)->text_width * PANGO_SCALE);
+ pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
- /* Center text */
- if (g_task.centered) pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
- else pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
+ /* Center text */
+ if (g_task.centered) pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
+ else pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
- pango_layout_get_pixel_size (layout, &width, &height);
+ pango_layout_get_pixel_size (layout, &width, &height);
- if (active) config_text = &g_task.font_active;
- else config_text = &g_task.font;
+ if (active) config_text = &g_task.font_active;
+ else config_text = &g_task.font;
- cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha);
+ cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha);
- pango_cairo_update_layout (c, layout);
- cairo_move_to (c, g_task.text_posx, g_task.text_posy);
- pango_cairo_show_layout (c, layout);
+ pango_cairo_update_layout (c, layout);
+ cairo_move_to (c, g_task.text_posx, g_task.text_posy);
+ pango_cairo_show_layout (c, layout);
- if (g_task.font_shadow) {
- cairo_set_source_rgba (c, 0.0, 0.0, 0.0, 0.5);
- pango_cairo_update_layout (c, layout);
- cairo_move_to (c, g_task.text_posx + 1, g_task.text_posy + 1);
- pango_cairo_show_layout (c, layout);
- }
- g_object_unref (layout);
+ if (g_task.font_shadow) {
+ cairo_set_source_rgba (c, 0.0, 0.0, 0.0, 0.5);
+ pango_cairo_update_layout (c, layout);
+ cairo_move_to (c, g_task.text_posx + 1, g_task.text_posy + 1);
+ pango_cairo_show_layout (c, layout);
+ }
+ g_object_unref (layout);
}
if (g_task.icon) {
}
}
-
-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);
-}
-
/**************************************************************************
-* task :
-* -
+* task :
+* -
*
**************************************************************************/
// global task parameter
typedef struct {
Area area;
- Area area_active;
- Area area_inactive;
-
+
int text;
int icon;
int icon_size1;
typedef struct {
// always start with area
Area area;
- Area area_active;
- Area area_inactive;
// TODO: group task with list of windows here
Window win;
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);
/**************************************************************************
*
* Tint2 : taskbar
-*
+*
* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
-*
+*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
Task *tsk;
GSList *l0;
int i, nb;
-
+
nb = panel.nb_desktop * panel.nb_monitor;
for (i=0 ; i < nb ; i++) {
for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results);
if (!win) return;
-
+
// 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++) {
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;
}
}
// Add any new
- for (i = 0; i < num_results; i++)
- if (!task_get_task (win[i]))
+ for (i = 0; i < num_results; i++)
+ if (!task_get_task (win[i]))
add_task (win[i]);
XFree (win);
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;
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--;
}
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.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;
if (taskbar_on_screen > 1)
modulo_width = (taskbar_width - ((taskbar_on_screen-1) * panel.area.paddingx)) % taskbar_on_screen;
- else
+ 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;
panel.taskbar[i].area.width++;
modulo--;
}
-
+
resize_tasks(&panel.taskbar[i]);
}
}
/**************************************************************************
*
* Tint2 panel
-*
+*
* Copyright (C) 2007 Pål Staurland (staura@gmail.com)
* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
-*
+*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
panel.clock.area.draw_foreground = draw_foreground_clock;
g_task.area.draw_foreground = draw_foreground_task;
window.main_win = 0;
-
+
server.dsp = XOpenDisplay (NULL);
if (!server.dsp) {
fprintf(stderr, "Could not open display.\n");
//kde_init();
//net_init();
//printf("ici 4\n");
-
+
imlib_context_set_display (server.dsp);
imlib_context_set_visual (server.visual);
imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen));
void event_button_press (int x, int y)
-{
+{
if (panel.mode == SINGLE_DESKTOP) {
// drag and drop disabled
XLowerWindow (server.dsp, window.main_win);
return;
}
-
+
Taskbar *tskbar;
GSList *l0;
for (l0 = panel.area.list; l0 ; l0 = l0->next) {
}
}
}
-
+
XLowerWindow (server.dsp, window.main_win);
}
action = panel.mouse_scroll_down;
break;
}
-
+
// search taskbar
Taskbar *tskbar;
GSList *l0;
if (panel.task_drag) {
if (tskbar != panel.task_drag->area.parent && action == TOGGLE_ICONIFY) {
windows_set_desktop(panel.task_drag->win, tskbar->desktop);
- if (tskbar->desktop == server.desktop)
+ if (tskbar->desktop == server.desktop)
set_active(panel.task_drag->win);
panel.task_drag = 0;
return;
}
else panel.task_drag = 0;
}
-
+
// switch desktop
if (panel.mode == MULTI_DESKTOP)
if (tskbar->desktop != server.desktop && action != CLOSE)
break;
}
}
-
+
// to keep window below
XLowerWindow (server.dsp, window.main_win);
}
void event_property_notify (Window win, Atom at)
-{
-
+{
+
if (win == server.root_win) {
if (!server.got_root_win) {
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
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;
}
}
/* 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) {
/* Window desktop changed */
else if (at == server.atom._NET_WM_DESKTOP) {
add_task (tsk->win);
- remove_task (tsk);
+ remove_task (tsk);
panel.refresh = 1;
}
void event_configure_notify (Window win)
-{
+{
Task *tsk;
tsk = task_get_task (win);
if (!tsk) return;
-
+
Taskbar *tskbar = tsk->area.parent;
- if (tskbar->monitor != window_get_monitor (win)) {
+ if (tskbar->monitor != window_get_monitor (win)) {
// task on another monitor
add_task (tsk->win);
remove_task (tsk);
struct timeval stv;
if (!panel.clock.time1_format) return;
-
+
if (gettimeofday(&stv, 0)) return;
-
+
if (abs(stv.tv_sec - panel.clock.clock.tv_sec) < panel.clock.time_precision) return;
-
+
// update clock
panel.clock.clock.tv_sec = stv.tv_sec;
panel.clock.clock.tv_sec -= panel.clock.clock.tv_sec % panel.clock.time_precision;
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)));
exit(1);
}
config_finish ();
-
+
window_draw_panel ();
-
+
// BUG: refresh(clock) is needed here, but 'on the paper' it's not necessary.
refresh(&panel.clock.area);
x11_fd = ConnectionNumber (server.dsp);
XSync (server.dsp, False);
-
+
while (1) {
// thanks to AngryLlama for the timer
// Create a File Description Set containing x11_fd
tv.tv_usec = 500000;
tv.tv_sec = 0;
-
+
// Wait for X Event or a Timer
if (select(x11_fd+1, &fd, 0, 0, &tv)) {
while (XPending (server.dsp)) {
XNextEvent(server.dsp, &e);
-
+
switch (e.type) {
case ButtonPress:
if (e.xbutton.button == 1) event_button_press (e.xbutton.x, e.xbutton.y);
case ButtonRelease:
event_button_release (e.xbutton.button, e.xbutton.x, e.xbutton.y);
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;
if (e.xconfigure.window == server.root_win)
goto load_config;
else
- if (panel.mode == MULTI_MONITOR)
- event_configure_notify (e.xconfigure.window);
+ if (panel.mode == MULTI_MONITOR)
+ event_configure_notify (e.xconfigure.window);
break;
}
}
if (panel.refresh && !panel.sleep_mode) {
visual_refresh ();
//printf(" *** visual_refresh\n");
- }
+ }
}
}
/**************************************************************************
*
* Tint2 : area
-*
+*
* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
-*
+*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
void refresh (Area *a)
{
if (a->redraw) {
- if (a->draw)
- a->draw(a);
- else
- draw(a);
- }
-
- XCopyArea (server.dsp, a->pmap, server.pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
-
+ //printf("draw pix\n");
+ draw(a, 0);
+ if (a->use_active)
+ draw(a, 1);
+ a->redraw = 0;
+ //printf("end draw pix\n");
+ }
+
+ 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");
}
void set_redraw (Area *a)
{
a->redraw = 1;
-
+
GSList *l;
- for (l = a->list ; l ; l = l->next)
+ for (l = a->list ; l ; l = l->next)
set_redraw(l->data);
}
-void draw (Area *a)
+void draw (Area *a, int active)
{
- cairo_surface_t *cs;
- cairo_t *c;
-
+ Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
+
//printf("begin draw area\n");
- if (a->pmap) XFreePixmap (server.dsp, a->pmap);
- a->pmap = server_create_pixmap (a->width, a->height);
+ if (*pmap) XFreePixmap (server.dsp, *pmap);
+ *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);
+ XCopyArea (server.dsp, server.pmap, *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);
+ cairo_surface_t *cs;
+ cairo_t *c;
+
+ 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)
degre = 45;
// et ensuite faire la changement d'unité du repère
// car ce qui doit resté inchangée est les traits et pas la direction
-
+
// il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°)
// ceci peut être appliqué une fois pour toute au départ
// ensuite calculer l'angle dans le nouveau repère
x1 = X1 * ((double)a->width / 100);
y0 = Y0 * ((double)a->height / 100);
y1 = Y1 * ((double)a->height / 100);
-
+
x0 = X0 * ((double)a->height / 100);
x1 = X1 * ((double)a->height / 100);
y0 = Y0 * ((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;
linpat = cairo_pattern_create_linear (x0, y0, x1, y1);
cairo_pattern_add_color_stop_rgba (linpat, 0, a->border.color[0], a->border.color[1], a->border.color[2], a->border.alpha);
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);
}
void remove_area (Area *a)
{
Area *parent;
-
+
parent = (Area*)a->parent;
parent->list = g_slist_remove(parent->list, a);
set_redraw (parent);
void add_area (Area *a)
{
Area *parent;
-
+
parent = (Area*)a->parent;
parent->list = g_slist_remove(parent->list, a);
set_redraw (parent);
void free_area (Area *a)
{
GSList *l0;
- for (l0 = a->list; l0 ; l0 = l0->next)
+ for (l0 = a->list; l0 ; l0 = l0->next)
free_area (l0->data);
if (a->list) {
g_slist_free(a->list);
- a->list = 0;
+ a->list = 0;
}
}
/**************************************************************************
* 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
* - taille clock calculée à partir de l'heure
* - taille d'une tache calculée à partir de la taskbar (ajout, suppression, taille)
* - 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)
*
**************************************************************************/
#include "common.h"
-
typedef struct
{
double color[3];
} 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 paddingx, paddingy;
+ 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);
+ int (*remove_child)(void *obj);
} Area;
// 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);