+2009-03-01
+- cleanup code
+- basic systray with some bugs
+- update documentation and tintrc sample for systray
+
2009-02-27
-- fixed issue 49 : better Makefile
+- fixed issue 49 : patch from Daniel Moerner
- some systray code (doesn't work)
- cleanup code
- fixed issue 48 : tint2 does't create config file on first start
2009-02-14
-- fxed issue 45 : segfault without clock
+- fixed issue 45 : segfault without clock
2009-02-13
- improved object oriented layout
clock->area.parent = panel;
clock->area.panel = panel;
- if (!clock->area.visible) return;
-
- clock->area._draw_foreground = draw_foreground_clock;
+ clock->area._draw_foreground = draw_clock;
clock->area._resize = resize_clock;
+ if (!clock->area.on_screen) continue;
+
if (strchr(time1_format, 'S') == NULL) time_precision = 60;
else time_precision = 1;
}
-void draw_foreground_clock (void *obj, cairo_t *c, int active)
+void draw_clock (void *obj, cairo_t *c, int active)
{
Clock *clock = obj;
PangoLayout *layout;
- //printf(" draw_foreground_clock : %s en (%d, %d)\n", buf_time, clock->area.posx, clock->area.width);
+ //printf(" draw_clock : %s en (%d, %d)\n", buf_time, clock->area.posx, clock->area.width);
layout = pango_cairo_create_layout (c);
// draw layout
// initialize clock : y position, precision, ...
void init_clock();
-void draw_foreground_clock (void *obj, cairo_t *c, int active);
+void draw_clock (void *obj, cairo_t *c, int active);
void resize_clock (void *obj);
if (time1_format) g_free(time1_format);
if (strlen(value) > 0) time1_format = strdup (value);
else time1_format = 0;
- panel_config->clock.area.visible = 1;
+ panel_config->clock.area.on_screen = 1;
}
else if (strcmp (key, "time2_format") == 0) {
if (time2_format) g_free(time2_format);
systray.area.paddingxlr = systray.area.paddingx = atoi (value1);
if (value2) systray.area.paddingy = atoi (value2);
if (value3) systray.area.paddingx = atoi (value3);
- systray.area.visible = 1;
+ systray.area.on_screen = 1;
}
else if (strcmp (key, "systray_background_id") == 0) {
int id = atoi (value);
p->area.parent = p;
p->area.panel = p;
- p->area.visible = 1;
+ p->area.on_screen = 1;
p->area.resize = 1;
p->area._resize = resize_panel;
p->g_taskbar.parent = p;
p->g_task.area.panel = p;
// add childs
- if (p->clock.area.visible)
+ if (p->clock.area.on_screen)
p->area.list = g_slist_append(p->area.list, &p->clock);
- if (systray.area.visible && i == 0) {
+ if (systray.area.on_screen && i == 0) {
// systray only on first panel
p->area.list = g_slist_append(p->area.list, &systray);
}
else taskbar_on_screen = 1;
taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
- if (panel->clock.area.visible && panel->clock.area.width)
+ if (panel->clock.area.on_screen && panel->clock.area.width)
taskbar_width -= (panel->clock.area.width + panel->area.paddingx);
- if (systray.area.visible && systray.area.width)
+ // TODO : systray only on first panel. search better implementation !
+ if (systray.area.on_screen && systray.area.width && panel == &panel1[0])
taskbar_width -= (systray.area.width + panel->area.paddingx);
taskbar_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) / taskbar_on_screen;
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;
+ taskbar->area.on_screen = 0;
}
else {
- taskbar->area.visible = 1;
+ taskbar->area.on_screen = 1;
}
}
}
Panel *panel = &panel1[0];
systray.area.parent = panel;
systray.area.panel = panel;
+ systray.area._draw_foreground = draw_systray;
systray.area._resize = resize_systray;
- if (systray.area.visible) {
+ if (systray.area.on_screen) {
if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != None) {
fprintf(stderr, "tint2 : another systray is running\n");
- systray.area.visible = 0;
+ systray.area.on_screen = 0;
}
}
- if (systray.area.visible)
- systray.area.visible = net_init();
+ if (systray.area.on_screen)
+ systray.area.on_screen = net_init();
- if (!systray.area.visible)
+ if (!systray.area.on_screen)
return;
// configure systray
systray.area.width = 0;
systray.area.posx = panel->area.width - panel->area.paddingxlr - panel->area.pix.border.width - systray.area.width;
- if (panel->clock.area.visible)
+ if (panel->clock.area.on_screen)
systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
systray.area.redraw = 1;
}
+void draw_systray(void *obj, cairo_t *c, int active)
+{
+ Systraybar *sysbar = obj;
+ Panel *panel = sysbar->area.panel;
+ TrayWindow *traywin;
+ GSList *l;
+ int icon_size;
+
+ icon_size = sysbar->area.height - (2 * sysbar->area.pix.border.width) - (2 * sysbar->area.paddingy);
+ for (l = systray.list_icons; l ; l = l->next) {
+ traywin = (TrayWindow*)l->data;
+
+ printf("draw_systray %d %d\n", systray.area.posx, systray.area.width);
+ // watch for the icon trying to resize itself!
+ XSelectInput(server.dsp, traywin->id, StructureNotifyMask);
+
+ // position and size the icon window
+ XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
+
+ // resize our window so that the new window can fit in it
+ //fix_geometry();
+
+ // flush before clearing, otherwise the clear isn't effective.
+ XFlush(server.dsp);
+ // make sure the new child will get the right stuff in its background
+ // for ParentRelative.
+ XClearWindow(server.dsp, panel->main_win);
+
+ // show the window
+ XMapRaised(server.dsp, traywin->id);
+ }
+}
+
+
+void resize_systray(void *obj)
+{
+ Systraybar *sysbar = obj;
+ Panel *panel = sysbar->area.panel;
+ TrayWindow *traywin;
+ GSList *l;
+ int count, posx, posy;
+ int icon_size;
+
+ icon_size = sysbar->area.height - (2 * sysbar->area.pix.border.width) - (2 * sysbar->area.paddingy);
+ count = g_slist_length(systray.list_icons);
+
+ if (!count) systray.area.width = 0;
+ else systray.area.width = (2 * systray.area.pix.border.width) + (2 * systray.area.paddingxlr) + (icon_size * count) + ((count-1) * systray.area.paddingx);
+
+ systray.area.posx = panel->area.width - panel->area.pix.border.width - panel->area.paddingxlr - systray.area.width;
+ if (panel->clock.area.on_screen)
+ systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
+
+ systray.area.redraw = 1;
+
+ posy = panel->area.pix.border.width + panel->area.paddingy + systray.area.pix.border.width + systray.area.paddingy;
+ posx = systray.area.posx + systray.area.pix.border.width + systray.area.paddingxlr;
+ for (l = systray.list_icons; l ; l = l->next) {
+ traywin = (TrayWindow*)l->data;
+
+ traywin->y = posy;
+ traywin->x = posx;
+ posx += (icon_size + systray.area.paddingx);
+ }
+
+ // resize other objects on panel
+ printf("resize_systray %d %d\n", systray.area.posx, systray.area.width);
+}
+
+
int net_init()
{
// init systray protocol
}
-void resize_systray (void *obj)
-{
- Systraybar *sysbar = obj;
- Panel *panel = sysbar->area.panel;
- int count = g_slist_length(systray.list_icons);
-
- if (!count) systray.area.width = 0;
- else systray.area.width = 30 * count;
-
- systray.area.posx = panel->area.width - panel->area.paddingxlr - panel->area.pix.border.width - systray.area.width;
- if (panel->clock.area.visible)
- systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
-
- systray.area.redraw = 1;
-
- // resize other objects on panel
- printf("resize_systray %d %d\n", systray.area.posx, systray.area.width);
-}
-
-
-
-Window win, root;
+//Window win, root;
int width, height;
int border;
int icon_size;
void fix_geometry()
{
GSList *it;
+ Panel *panel = systray.area.panel;
// find the proper width and height
width = 0;
width += icon_size;
}
- XResizeWindow(server.dsp, win, width + border * 2, height + border * 2);
+ XResizeWindow(server.dsp, panel->main_win, width + border * 2, height + border * 2);
}
gboolean icon_swallow(TrayWindow *traywin)
{
XErrorHandler old;
+ Panel *panel = systray.area.panel;
error = FALSE;
old = XSetErrorHandler(window_error_handler);
- XReparentWindow(server.dsp, traywin->id, win, 0, 0);
+ XReparentWindow(server.dsp, traywin->id, panel->main_win, 0, 0);
XSync(server.dsp, False);
XSetErrorHandler(old);
traywin = g_new0(TrayWindow, 1);
traywin->id = id;
- systray.list_icons = g_slist_append(systray.list_icons, traywin);
+ systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
printf("ajout d'un icone %d (%lx)\n", g_slist_length(systray.list_icons), id);
systray.area.resize = 1;
+ systray.area.redraw = 1;
// changed in systray force resize on panel
Panel *panel = systray.area.panel;
panel->area.resize = 1;
panel_refresh = 1;
- return TRUE;
if (!icon_swallow(traywin)) {
printf("not icon_swallow\n");
g_free(traywin);
return FALSE;
}
+ else
+ printf("icon_swallow\n");
+ //return TRUE;
+// => calcul x, y, width, height dans resize
+/*
// find the positon for the systray app window
int count = g_slist_length(icons);
traywin->x = border + ((width % icon_size) / 2) +
// add the new icon to the list
icons = g_slist_append(icons, traywin);
-
- // watch for the icon trying to resize itself!
- //XSelectInput(server.dsp, traywin->id, StructureNotifyMask);
-
- // position and size the icon window
- XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
-
- // resize our window so that the new window can fit in it
- fix_geometry();
-
- // flush before clearing, otherwise the clear isn't effective.
- XFlush(server.dsp);
- // make sure the new child will get the right stuff in its background
- // for ParentRelative.
- XClearWindow(server.dsp, win);
-
- // show the window
- XMapRaised(server.dsp, traywin->id);
+*/
return TRUE;
}
opcode = e->data.l[1];
switch (opcode) {
- case SYSTEM_TRAY_REQUEST_DOCK:
- panel_refresh = 1;
- id = e->data.l[2];
- if (id && icon_add(id)) {
- XSelectInput(server.dsp, id, StructureNotifyMask);
- }
- break;
-
- case SYSTEM_TRAY_BEGIN_MESSAGE:
- //g_printerr("Message From Dockapp\n");
- id = e->window;
- break;
+ case SYSTEM_TRAY_REQUEST_DOCK:
+ id = e->data.l[2];
+ if (id) icon_add(id);
+ break;
- case SYSTEM_TRAY_CANCEL_MESSAGE:
- //g_printerr("Message Cancelled\n");
- id = e->window;
- break;
+ case SYSTEM_TRAY_BEGIN_MESSAGE:
+ printf("message from dockapp\n");
+ id = e->window;
+ break;
- default:
- if (opcode == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA) {
- printf("message from dockapp:\n %s\n", e->data.b);
+ case SYSTEM_TRAY_CANCEL_MESSAGE:
+ printf("message cancelled\n");
id = e->window;
- }
- // unknown message type. not in the spec
- break;
+ break;
+
+ default:
+ if (opcode == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA) {
+ printf("message from dockapp:\n %s\n", e->data.b);
+ id = e->window;
+ }
+ // unknown message type. not in the spec
+ break;
}
}
#ifndef SYSTRAYBAR_H
#define SYSTRAYBAR_H
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
+#include "common.h"
#include "area.h"
void net_message(XClientMessageEvent *e);
void icon_remove(TrayWindow *traywin);
-void resize_systray (void *obj);
+void draw_systray(void *obj, cairo_t *c, int active);
+
+void resize_systray(void *obj);
#endif
}
-void draw_foreground_task (void *obj, cairo_t *c, int active)
+void draw_task (void *obj, cairo_t *c, int active)
{
Task *tsk = obj;
PangoLayout *layout;
void add_task (Window win);
void remove_task (Task *tsk);
-void draw_foreground_task (void *obj, cairo_t *c, int active);
+void draw_task (void *obj, cairo_t *c, int active);
void get_icon (Task *tsk);
void get_title(Task *tsk);
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.redraw = 1;
- panel->g_taskbar.visible = 1;
+ panel->g_taskbar.on_screen = 1;
// task
- panel->g_task.area._draw_foreground = draw_foreground_task;
+ panel->g_task.area._draw_foreground = draw_task;
panel->g_task.area.posy = panel->g_taskbar.posy + panel->g_taskbar.pix.border.width + panel->g_taskbar.paddingy;
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.redraw = 1;
- panel->g_task.area.visible = 1;
+ panel->g_task.area.on_screen = 1;
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;
int y = e->xbutton.y;
for (l0 = panel->area.list; l0 ; l0 = l0->next) {
tskbar = l0->data;
- if (!tskbar->area.visible) continue;
+ if (!tskbar->area.on_screen) continue;
if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
break;
}
GSList *l0;
for (l0 = panel->area.list; l0 ; l0 = l0->next) {
tskbar = l0->data;
- if (!tskbar->area.visible) continue;
+ if (!tskbar->area.on_screen) continue;
if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
goto suite;
}
}
+void event_expose (XEvent *e)
+{
+ Panel *panel;
+
+ panel = get_panel(e->xany.window);
+ if (!panel) return;
+/*
+ if (systray.area.on_screen) {
+ // force trayer refresh
+ //XClearWindow(tray_data.dpy, ti->mid_parent);
+ //x11_send_visibility(tray_data.dpy, dst, VisibilityFullyObscured);
+ //x11_send_visibility(tray_data.dpy, dst, VisibilityUnobscured);
+
+ GSList *l;
+ TrayWindow *traywin;
+ for (l = systray.list_icons; l ; l = l->next) {
+ traywin = (TrayWindow*)l->data;
+ // send Expose event
+ XClearArea(server.dsp, traywin->id, 0, 0, systray.area.width, systray.area.height, True);
+ //printf("expose %lx\n", traywin->id);
+ }
+
+ //x11_refresh_window(tray_data.dpy, ti->wid, ti->l.wnd_sz.x, ti->l.wnd_sz.y, True);
+ }
+*/
+ panel_refresh = 1;
+ //XCopyArea (server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
+
+}
+
+
void event_configure_notify (Window win)
{
if (panel_mode != SINGLE_MONITOR) return;
break;
case ButtonRelease:
- event_button_release (&e);
+ event_button_release(&e);
break;
case Expose:
- panel = get_panel(e.xany.window);
- if (!panel) break;
- XCopyArea (server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
+ event_expose(&e);
break;
case PropertyNotify:
- event_property_notify (&e);
+ event_property_notify(&e);
break;
case ConfigureNotify:
// 4) redraw child
void refresh (Area *a)
{
- if (!a->visible) return;
+ // don't draw and resize hide objects
+ if (!a->on_screen) return;
size(a);
+ // don't draw transparent objects (without foreground and without background)
+
if (a->redraw) {
a->redraw = 0;
//printf("draw area posx %d, width %d\n", a->posx, a->width);
// draw current Area
Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
+ if (*pmap == 0) printf("empty area posx %d, width %d\n", a->posx, a->width);
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
// list of child : Area object
GSList *list;
- int visible;
+ int on_screen;
// need compute position and width
int resize;
// need redraw Pixmap
task_background_id = 3
task_active_background_id = 2
+#---------------------------------------------
+# SYSTRAYBAR
+#---------------------------------------------
+systray_padding = 0 3 3
+systray_background_id = 0
#---------------------------------------------
# CLOCK
time2_format = %A %d %B
time2_font = sans 6
clock_font_color = #ffffff 76
-clock_padding = 4 0
+clock_padding = 1 0
clock_background_id = 0
#---------------------------------------------
#---------------------------------------------
# SYSTRAYBAR
#---------------------------------------------
-systray_padding = 4 2 2
-systray_background_id = 2
+systray_padding = 0 2 2
+systray_background_id = 0
#---------------------------------------------
# CLOCK
time2_format = %A %d %B
time2_font = sans 7
clock_font_color = #ffffff 100
-clock_padding = 2 0
+clock_padding = 1 0
clock_background_id = 0
#---------------------------------------------
task_background_id = 0
task_active_background_id = 2
+#---------------------------------------------
+# SYSTRAYBAR
+#---------------------------------------------
+#systray_padding = 0 2 2
+systray_background_id = 0
+
#---------------------------------------------
# CLOCK
#---------------------------------------------
# PANEL
#---------------------------------------------
panel_monitor = all
-panel_position = bottom left
-panel_size = 99% 27
+panel_position = bottom center
+panel_size = 97% 26
panel_margin = 0 0
-panel_padding = 5 3 5
+panel_padding = 0 2 5
font_shadow = 0
panel_background_id = 0
task_background_id = 1
task_active_background_id = 2
+#---------------------------------------------
+# SYSTRAYBAR
+#---------------------------------------------
+systray_padding = 5 3 5
+systray_background_id = 1
+
#---------------------------------------------
# CLOCK
#---------------------------------------------
-time1_format = %a %d %H:%M
+#time1_format = %a %d %H:%M
time1_font = sans bold 7.5
#time2_format = %A %d %B
time2_font = sans bold 7.5
--- /dev/null
+#---------------------------------------------
+# TINT2 CONFIG FILE
+#---------------------------------------------
+
+#---------------------------------------------
+# BACKGROUND AND BORDER
+#---------------------------------------------
+rounded = 1
+border_width = 0
+background_color = #282828 100
+border_color = #000000 0
+
+rounded = 1
+border_width = 0
+background_color = #cccccc 20
+border_color = #cccccc 40
+
+#---------------------------------------------
+# PANEL
+#---------------------------------------------
+panel_monitor = all
+panel_position = bottom center
+panel_size = 95% 22
+panel_margin = 0 0
+panel_padding = 7 0
+font_shadow = 0
+panel_background_id = 1
+
+#---------------------------------------------
+# TASKBAR
+#---------------------------------------------
+taskbar_mode = single_desktop
+taskbar_padding = 0 0 0
+taskbar_background_id = 0
+
+#---------------------------------------------
+# TASKS
+#---------------------------------------------
+task_icon = 0
+task_text = 1
+task_width = 160
+task_centered = 1
+task_padding = 5 0
+task_font = sans 9
+task_font_color = #ffffff 60
+task_active_font_color = #ffffff 100
+task_background_id = 0
+task_active_background_id = 2
+
+#---------------------------------------------
+# SYSTRAYBAR
+#---------------------------------------------
+systray_padding = 0 3 4
+systray_background_id = 0
+
+#---------------------------------------------
+# CLOCK
+#---------------------------------------------
+time1_format = %H:%M
+time1_font = sans 13
+#time2_format = %A %d %B
+time2_font = sans 7
+clock_font_color = #ffffff 90
+clock_padding = 1 0
+clock_background_id = 0
+
+#---------------------------------------------
+# MOUSE ACTION ON TASK
+#---------------------------------------------
+mouse_middle = none
+mouse_right = close
+mouse_scroll_up = toggle
+mouse_scroll_down = iconify
+
task_background_id = 0
task_active_background_id = 2
+#---------------------------------------------
+# SYSTRAYBAR
+#---------------------------------------------
+systray_padding = 9 3 5
+systray_background_id = 1
+
#---------------------------------------------
# CLOCK
#---------------------------------------------
-time1_format = %H:%M
+#time1_format = %H:%M
time1_font = sans bold 8
-time2_format = %A %d %B
+#time2_format = %A %d %B
time2_font = sans 7
clock_font_color = #ffffff 65
clock_padding = 6 0
--- /dev/null
+#---------------------------------------------
+# TINT2 CONFIG FILE
+#---------------------------------------------
+
+#---------------------------------------------
+# BACKGROUND AND BORDER
+#---------------------------------------------
+rounded = 4
+border_width = 1
+background_color = #000000 40
+border_color = #d1d1d1 34
+
+rounded = 3
+border_width = 0
+background_color = #000000 40
+border_color = #d1d1d1 40
+
+#---------------------------------------------
+# PANEL
+#---------------------------------------------
+panel_monitor = all
+panel_position = bottom center
+panel_size = 97% 30
+panel_margin = 0 0
+panel_padding = 0 2 7
+font_shadow = 0
+panel_background_id = 0
+
+#---------------------------------------------
+# TASKBAR
+#---------------------------------------------
+taskbar_mode = multi_desktop
+taskbar_padding = 0 0 0
+taskbar_background_id = 1
+
+#---------------------------------------------
+# TASKS
+#---------------------------------------------
+task_icon = 0
+task_text = 1
+task_width = 160
+task_centered = 1
+task_padding = 4 3
+task_font = sans bold 7.5
+task_font_color = #ffffff 60
+task_active_font_color = #ffffff 90
+task_background_id = 0
+task_active_background_id = 2
+
+#---------------------------------------------
+# SYSTRAYBAR
+#---------------------------------------------
+systray_padding = 6 3 4
+systray_background_id = 1
+
+#---------------------------------------------
+# CLOCK
+#---------------------------------------------
+time1_format = %H:%M
+time1_font = sans bold 7
+time2_format = %A %d %B
+time2_font = sans 7
+clock_font_color = #ffffff 60
+clock_padding = 2 0
+clock_background_id = 1
+
+#---------------------------------------------
+# MOUSE ACTION ON TASK
+#---------------------------------------------
+mouse_middle = none
+mouse_right = close
+mouse_scroll_up = toggle
+mouse_scroll_down = iconify
+