support skip_taskbar by Andreas.Fink85

git-svn-id: http://tint2.googlecode.com/svn/trunk@169 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2009-09-07 21:41:21 +00:00
parent a17b62f76f
commit babda8e268
13 changed files with 1399 additions and 1369 deletions

View file

@ -1,3 +1,7 @@
2009-09-07
- fixed issue 117 : support skip_taskbar by Andreas.Fink85
- cleanup : switch space to tab
2009-09-01 2009-09-01
- fixed segfault - fixed segfault

View file

@ -94,9 +94,9 @@ void init_battery()
} }
FILE *fp; FILE *fp;
Panel *panel; Panel *panel;
Battery *battery; Battery *battery;
int i, bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink; int i, bat_percentage_height, bat_percentage_height_ink, bat_time_height, bat_time_height_ink;
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i]; panel = &panel1[i];
@ -268,7 +268,7 @@ void draw_battery (void *obj, cairo_t *c, int active)
void resize_battery(void *obj) void resize_battery(void *obj)
{ {
Battery *battery = obj; Battery *battery = obj;
PangoLayout *layout; PangoLayout *layout;
int percentage_width, time_width, new_width; int percentage_width, time_width, new_width;

View file

@ -56,9 +56,9 @@ void init_precision()
void init_clock() void init_clock()
{ {
Panel *panel; Panel *panel;
Clock *clock; Clock *clock;
int i, time_height, time_height_ink, date_height, date_height_ink; int i, time_height, time_height_ink, date_height, date_height_ink;
init_precision(); init_precision();
// update clock to force update (-time_precision) // update clock to force update (-time_precision)
@ -68,8 +68,8 @@ void init_clock()
time_clock.tv_sec -= time_clock.tv_sec % time_precision; time_clock.tv_sec -= time_clock.tv_sec % time_precision;
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i]; panel = &panel1[i];
clock = &panel->clock; clock = &panel->clock;
if (!clock->area.on_screen) continue; if (!clock->area.on_screen) continue;
@ -114,64 +114,64 @@ void init_clock()
void draw_clock (void *obj, cairo_t *c, int active) void draw_clock (void *obj, cairo_t *c, int active)
{ {
Clock *clock = obj; Clock *clock = obj;
PangoLayout *layout; PangoLayout *layout;
layout = pango_cairo_create_layout (c); layout = pango_cairo_create_layout (c);
// draw layout // draw layout
pango_layout_set_font_description (layout, time1_font_desc); pango_layout_set_font_description (layout, time1_font_desc);
pango_layout_set_width (layout, clock->area.width * PANGO_SCALE); pango_layout_set_width (layout, clock->area.width * PANGO_SCALE);
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
pango_layout_set_text (layout, buf_time, strlen(buf_time)); pango_layout_set_text (layout, buf_time, strlen(buf_time));
cairo_set_source_rgba (c, clock->font.color[0], clock->font.color[1], clock->font.color[2], clock->font.alpha); cairo_set_source_rgba (c, clock->font.color[0], clock->font.color[1], clock->font.color[2], clock->font.alpha);
pango_cairo_update_layout (c, layout); pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time1_posy); cairo_move_to (c, 0, clock->time1_posy);
pango_cairo_show_layout (c, layout); pango_cairo_show_layout (c, layout);
if (time2_format) { if (time2_format) {
pango_layout_set_font_description (layout, time2_font_desc); pango_layout_set_font_description (layout, time2_font_desc);
pango_layout_set_indent(layout, 0); pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_date, strlen(buf_date)); pango_layout_set_text (layout, buf_date, strlen(buf_date));
pango_layout_set_width (layout, clock->area.width * PANGO_SCALE); pango_layout_set_width (layout, clock->area.width * PANGO_SCALE);
pango_cairo_update_layout (c, layout); pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time2_posy); cairo_move_to (c, 0, clock->time2_posy);
pango_cairo_show_layout (c, layout); pango_cairo_show_layout (c, layout);
} }
g_object_unref (layout); g_object_unref (layout);
} }
void resize_clock (void *obj) void resize_clock (void *obj)
{ {
Clock *clock = obj; Clock *clock = obj;
PangoLayout *layout; PangoLayout *layout;
int time_width, date_width, new_width; int time_width, date_width, new_width;
clock->area.redraw = 1; clock->area.redraw = 1;
time_width = date_width = 0; time_width = date_width = 0;
strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec)); strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
if (time2_format) if (time2_format)
strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec)); strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
// vertical panel doen't adjust width // vertical panel doen't adjust width
if (!panel_horizontal) return; if (!panel_horizontal) return;
//printf(" resize_clock\n"); //printf(" resize_clock\n");
cairo_surface_t *cs; cairo_surface_t *cs;
cairo_t *c; cairo_t *c;
Pixmap pmap; Pixmap pmap;
pmap = XCreatePixmap (server.dsp, server.root_win, clock->area.width, clock->area.height, server.depth); pmap = XCreatePixmap (server.dsp, server.root_win, clock->area.width, clock->area.height, server.depth);
cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, clock->area.width, clock->area.height); cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, clock->area.width, clock->area.height);
c = cairo_create (cs); c = cairo_create (cs);
layout = pango_cairo_create_layout (c); layout = pango_cairo_create_layout (c);
// check width // check width
pango_layout_set_font_description (layout, time1_font_desc); pango_layout_set_font_description (layout, time1_font_desc);
pango_layout_set_indent(layout, 0); pango_layout_set_indent(layout, 0);
pango_layout_set_text (layout, buf_time, strlen(buf_time)); pango_layout_set_text (layout, buf_time, strlen(buf_time));
@ -187,28 +187,28 @@ void resize_clock (void *obj)
else new_width = date_width; else new_width = date_width;
new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width); new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width);
if (new_width > clock->area.width || new_width < (clock->area.width-6)) { if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
Panel *panel = ((Area*)obj)->panel; Panel *panel = ((Area*)obj)->panel;
// resize clock // resize clock
// we try to limit the number of resize // we try to limit the number of resize
// printf("clock_width %d, new_width %d\n", clock->area.width, new_width); // printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
clock->area.width = new_width + 1; clock->area.width = new_width + 1;
clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width; clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width;
// resize other objects on panel // resize other objects on panel
panel->area.resize = 1; panel->area.resize = 1;
#ifdef ENABLE_BATTERY #ifdef ENABLE_BATTERY
panel->battery.area.resize = 1; panel->battery.area.resize = 1;
#endif #endif
systray.area.resize = 1; systray.area.resize = 1;
panel_refresh = 1; panel_refresh = 1;
} }
g_object_unref (layout); g_object_unref (layout);
cairo_destroy (c); cairo_destroy (c);
cairo_surface_destroy (cs); cairo_surface_destroy (cs);
XFreePixmap (server.dsp, pmap); XFreePixmap (server.dsp, pmap);
} }

File diff suppressed because it is too large Load diff

View file

@ -69,21 +69,21 @@ void init_panel()
p->area.parent = p; p->area.parent = p;
p->area.panel = p; p->area.panel = p;
p->area.on_screen = 1; p->area.on_screen = 1;
p->area.resize = 1; p->area.resize = 1;
p->area._resize = resize_panel; p->area._resize = resize_panel;
p->g_taskbar.parent = p; p->g_taskbar.parent = p;
p->g_taskbar.panel = p; p->g_taskbar.panel = p;
p->g_task.area.panel = p; p->g_task.area.panel = p;
// add childs // add childs
if (p->clock.area.on_screen) if (p->clock.area.on_screen)
p->area.list = g_slist_append(p->area.list, &p->clock); p->area.list = g_slist_append(p->area.list, &p->clock);
#ifdef ENABLE_BATTERY #ifdef ENABLE_BATTERY
if (p->battery.area.on_screen) if (p->battery.area.on_screen)
p->area.list = g_slist_append(p->area.list, &p->battery); p->area.list = g_slist_append(p->area.list, &p->battery);
#endif #endif
// systray only on first panel // systray only on first panel
if (systray.area.on_screen && i == 0) if (systray.area.on_screen && i == 0)
p->area.list = g_slist_append(p->area.list, &systray); p->area.list = g_slist_append(p->area.list, &systray);
// full width mode // full width mode
@ -168,12 +168,12 @@ void cleanup_panel()
task_drag = 0; task_drag = 0;
task_urgent = 0; task_urgent = 0;
cleanup_systray(); cleanup_systray();
cleanup_taskbar(); cleanup_taskbar();
// font allocated once // font allocated once
if (panel1[0].g_task.font_desc) { if (panel1[0].g_task.font_desc) {
pango_font_description_free(panel1[0].g_task.font_desc); pango_font_description_free(panel1[0].g_task.font_desc);
panel1[0].g_task.font_desc = 0; panel1[0].g_task.font_desc = 0;
} }
int i; int i;
@ -182,8 +182,8 @@ void cleanup_panel()
p = &panel1[i]; p = &panel1[i];
free_area(&p->area); free_area(&p->area);
free_area(&p->g_task.area); free_area(&p->g_task.area);
free_area(&p->g_taskbar); free_area(&p->g_taskbar);
if (p->temp_pmap) { if (p->temp_pmap) {
XFreePixmap(server.dsp, p->temp_pmap); XFreePixmap(server.dsp, p->temp_pmap);
@ -195,17 +195,17 @@ void cleanup_panel()
} }
} }
if (panel1) free(panel1); if (panel1) free(panel1);
panel1 = 0; panel1 = 0;
} }
void resize_panel(void *obj) void resize_panel(void *obj)
{ {
Panel *panel = (Panel*)obj; Panel *panel = (Panel*)obj;
if (panel_horizontal) { if (panel_horizontal) {
int taskbar_width, modulo_width = 0; int taskbar_width, modulo_width = 0;
taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
if (panel->clock.area.on_screen && panel->clock.area.width) if (panel->clock.area.on_screen && panel->clock.area.width)
@ -241,7 +241,7 @@ void resize_panel(void *obj)
} }
} }
else { else {
int taskbar_height, modulo_height = 0; int taskbar_height, modulo_height = 0;
int i, posy; int i, posy;
taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); taskbar_height = panel->area.height - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
@ -280,8 +280,8 @@ void resize_panel(void *obj)
void visible_object() void visible_object()
{ {
Panel *panel; Panel *panel;
int i, j; int i, j;
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i]; panel = &panel1[i];
@ -304,22 +304,22 @@ void visible_object()
void set_panel_properties(Panel *p) void set_panel_properties(Panel *p)
{ {
XStoreName (server.dsp, p->main_win, "tint2"); XStoreName (server.dsp, p->main_win, "tint2");
// TODO: check if the name is really needed for a panel/taskbar ? // TODO: check if the name is really needed for a panel/taskbar ?
gsize len; gsize len;
gchar *name = g_locale_to_utf8("tint2", -1, NULL, &len, NULL); gchar *name = g_locale_to_utf8("tint2", -1, NULL, &len, NULL);
if (name != NULL) { if (name != NULL) {
XChangeProperty(server.dsp, p->main_win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 8, PropModeReplace, (unsigned char *) name, (int) len); XChangeProperty(server.dsp, p->main_win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 8, PropModeReplace, (unsigned char *) name, (int) len);
g_free(name); g_free(name);
} }
// Dock // Dock
long val = server.atom._NET_WM_WINDOW_TYPE_DOCK; long val = server.atom._NET_WM_WINDOW_TYPE_DOCK;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1); XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1);
// Reserved space // Reserved space
long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
if (panel_horizontal) { if (panel_horizontal) {
if (panel_position & TOP) { if (panel_position & TOP) {
struts[2] = p->area.height + p->marginy; struts[2] = p->area.height + p->marginy;
@ -348,69 +348,69 @@ void set_panel_properties(Panel *p)
struts[7] = p->posy + p->area.height - 1; struts[7] = p->posy + p->area.height - 1;
} }
} }
// Old specification : fluxbox need _NET_WM_STRUT. // Old specification : fluxbox need _NET_WM_STRUT.
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4); XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4);
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12); XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12);
// Sticky and below other window // Sticky and below other window
val = 0xFFFFFFFF; val = 0xFFFFFFFF;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1); XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1);
Atom state[4]; Atom state[4];
state[0] = server.atom._NET_WM_STATE_SKIP_PAGER; state[0] = server.atom._NET_WM_STATE_SKIP_PAGER;
state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR; state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR;
state[2] = server.atom._NET_WM_STATE_STICKY; state[2] = server.atom._NET_WM_STATE_STICKY;
state[3] = server.atom._NET_WM_STATE_BELOW; state[3] = server.atom._NET_WM_STATE_BELOW;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4); XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4);
// Fixed position // Fixed position
XSizeHints size_hints; XSizeHints size_hints;
size_hints.flags = PPosition; size_hints.flags = PPosition;
XChangeProperty (server.dsp, p->main_win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4); XChangeProperty (server.dsp, p->main_win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4);
// Unfocusable // Unfocusable
XWMHints wmhints; XWMHints wmhints;
wmhints.flags = InputHint; wmhints.flags = InputHint;
wmhints.input = False; wmhints.input = False;
XChangeProperty (server.dsp, p->main_win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4); XChangeProperty (server.dsp, p->main_win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4);
// Undecorated // Undecorated
long prop[5] = { 2, 0, 0, 0, 0 }; long prop[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(server.dsp, p->main_win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5); XChangeProperty(server.dsp, p->main_win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5);
} }
void set_panel_background(Panel *p) void set_panel_background(Panel *p)
{ {
get_root_pixmap(); get_root_pixmap();
if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap); if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap);
p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth); p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth);
// copy background (server.root_pmap) in panel.area.pix.pmap // copy background (server.root_pmap) in panel.area.pix.pmap
Window dummy; Window dummy;
int x, y; int x, y;
XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy);
XSetTSOrigin(server.dsp, server.gc, -x, -y) ; XSetTSOrigin(server.dsp, server.gc, -x, -y) ;
XFillRectangle(server.dsp, p->area.pix.pmap, server.gc, 0, 0, p->area.width, p->area.height); XFillRectangle(server.dsp, p->area.pix.pmap, server.gc, 0, 0, p->area.width, p->area.height);
// draw background panel // draw background panel
cairo_surface_t *cs; cairo_surface_t *cs;
cairo_t *c; cairo_t *c;
cs = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height); cs = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height);
c = cairo_create (cs); c = cairo_create (cs);
draw_background(&p->area, c, 0); draw_background(&p->area, c, 0);
cairo_destroy (c); cairo_destroy (c);
cairo_surface_destroy (cs); cairo_surface_destroy (cs);
// redraw panel's object // redraw panel's object
GSList *l0; GSList *l0;
Area *a; Area *a;
for (l0 = p->area.list; l0 ; l0 = l0->next) { for (l0 = p->area.list; l0 ; l0 = l0->next) {
a = l0->data; a = l0->data;
set_redraw(a); set_redraw(a);
} }
} }

View file

@ -33,46 +33,46 @@ static char *name_trayer = 0;
void server_init_atoms () void server_init_atoms ()
{ {
server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False); server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False);
server.atom._NET_CURRENT_DESKTOP = XInternAtom (server.dsp, "_NET_CURRENT_DESKTOP", False); server.atom._NET_CURRENT_DESKTOP = XInternAtom (server.dsp, "_NET_CURRENT_DESKTOP", False);
server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom (server.dsp, "_NET_NUMBER_OF_DESKTOPS", False); server.atom._NET_NUMBER_OF_DESKTOPS = XInternAtom (server.dsp, "_NET_NUMBER_OF_DESKTOPS", False);
server.atom._NET_DESKTOP_GEOMETRY = XInternAtom (server.dsp, "_NET_DESKTOP_GEOMETRY", False); server.atom._NET_DESKTOP_GEOMETRY = XInternAtom (server.dsp, "_NET_DESKTOP_GEOMETRY", False);
server.atom._NET_DESKTOP_VIEWPORT = XInternAtom (server.dsp, "_NET_DESKTOP_VIEWPORT", False); server.atom._NET_DESKTOP_VIEWPORT = XInternAtom (server.dsp, "_NET_DESKTOP_VIEWPORT", False);
server.atom._NET_ACTIVE_WINDOW = XInternAtom (server.dsp, "_NET_ACTIVE_WINDOW", False); server.atom._NET_ACTIVE_WINDOW = XInternAtom (server.dsp, "_NET_ACTIVE_WINDOW", False);
server.atom._NET_WM_WINDOW_TYPE = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE", False); server.atom._NET_WM_WINDOW_TYPE = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE", False);
server.atom._NET_WM_STATE_SKIP_PAGER = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_PAGER", False); server.atom._NET_WM_STATE_SKIP_PAGER = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_PAGER", False);
server.atom._NET_WM_STATE_SKIP_TASKBAR = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_TASKBAR", False); server.atom._NET_WM_STATE_SKIP_TASKBAR = XInternAtom (server.dsp, "_NET_WM_STATE_SKIP_TASKBAR", False);
server.atom._NET_WM_STATE_STICKY = XInternAtom (server.dsp, "_NET_WM_STATE_STICKY", False); server.atom._NET_WM_STATE_STICKY = XInternAtom (server.dsp, "_NET_WM_STATE_STICKY", False);
server.atom._NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom (server.dsp, "_NET_WM_STATE_DEMANDS_ATTENTION", False); server.atom._NET_WM_STATE_DEMANDS_ATTENTION = XInternAtom (server.dsp, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
server.atom._NET_WM_WINDOW_TYPE_DOCK = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DOCK", False); server.atom._NET_WM_WINDOW_TYPE_DOCK = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DOCK", False);
server.atom._NET_WM_WINDOW_TYPE_DESKTOP = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DESKTOP", False); server.atom._NET_WM_WINDOW_TYPE_DESKTOP = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
server.atom._NET_WM_WINDOW_TYPE_TOOLBAR = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); server.atom._NET_WM_WINDOW_TYPE_TOOLBAR = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_TOOLBAR", False);
server.atom._NET_WM_WINDOW_TYPE_MENU = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_MENU", False); server.atom._NET_WM_WINDOW_TYPE_MENU = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_MENU", False);
server.atom._NET_WM_WINDOW_TYPE_SPLASH = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_SPLASH", False); server.atom._NET_WM_WINDOW_TYPE_SPLASH = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_SPLASH", False);
server.atom._NET_WM_WINDOW_TYPE_DIALOG = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DIALOG", False); server.atom._NET_WM_WINDOW_TYPE_DIALOG = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_DIALOG", False);
server.atom._NET_WM_WINDOW_TYPE_NORMAL = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_NORMAL", False); server.atom._NET_WM_WINDOW_TYPE_NORMAL = XInternAtom (server.dsp, "_NET_WM_WINDOW_TYPE_NORMAL", False);
server.atom._NET_WM_DESKTOP = XInternAtom (server.dsp, "_NET_WM_DESKTOP", False); server.atom._NET_WM_DESKTOP = XInternAtom (server.dsp, "_NET_WM_DESKTOP", False);
server.atom.WM_STATE = XInternAtom (server.dsp, "WM_STATE", False); server.atom.WM_STATE = XInternAtom (server.dsp, "WM_STATE", False);
server.atom._NET_WM_STATE = XInternAtom (server.dsp, "_NET_WM_STATE", False); server.atom._NET_WM_STATE = XInternAtom (server.dsp, "_NET_WM_STATE", False);
server.atom._NET_WM_STATE_MAXIMIZED_VERT = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_VERT", False); server.atom._NET_WM_STATE_MAXIMIZED_VERT = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_VERT", False);
server.atom._NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_HORZ", False); server.atom._NET_WM_STATE_MAXIMIZED_HORZ = XInternAtom (server.dsp, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
server.atom._NET_WM_STATE_SHADED = XInternAtom (server.dsp, "_NET_WM_STATE_SHADED", False); server.atom._NET_WM_STATE_SHADED = XInternAtom (server.dsp, "_NET_WM_STATE_SHADED", False);
server.atom._NET_WM_STATE_BELOW = XInternAtom (server.dsp, "_NET_WM_STATE_BELOW", False); server.atom._NET_WM_STATE_BELOW = XInternAtom (server.dsp, "_NET_WM_STATE_BELOW", False);
server.atom._NET_WM_STATE_MODAL = XInternAtom (server.dsp, "_NET_WM_STATE_MODAL", False); server.atom._NET_WM_STATE_MODAL = XInternAtom (server.dsp, "_NET_WM_STATE_MODAL", False);
server.atom._NET_CLIENT_LIST = XInternAtom (server.dsp, "_NET_CLIENT_LIST", False); server.atom._NET_CLIENT_LIST = XInternAtom (server.dsp, "_NET_CLIENT_LIST", False);
server.atom._NET_WM_VISIBLE_NAME = XInternAtom (server.dsp, "_NET_WM_VISIBLE_NAME", False); server.atom._NET_WM_VISIBLE_NAME = XInternAtom (server.dsp, "_NET_WM_VISIBLE_NAME", False);
server.atom._NET_WM_NAME = XInternAtom (server.dsp, "_NET_WM_NAME", False); server.atom._NET_WM_NAME = XInternAtom (server.dsp, "_NET_WM_NAME", False);
server.atom._NET_WM_STRUT = XInternAtom (server.dsp, "_NET_WM_STRUT", False); server.atom._NET_WM_STRUT = XInternAtom (server.dsp, "_NET_WM_STRUT", False);
server.atom._NET_WM_ICON = XInternAtom (server.dsp, "_NET_WM_ICON", False); server.atom._NET_WM_ICON = XInternAtom (server.dsp, "_NET_WM_ICON", False);
server.atom._NET_CLOSE_WINDOW = XInternAtom (server.dsp, "_NET_CLOSE_WINDOW", False); server.atom._NET_CLOSE_WINDOW = XInternAtom (server.dsp, "_NET_CLOSE_WINDOW", False);
server.atom.UTF8_STRING = XInternAtom (server.dsp, "UTF8_STRING", False); server.atom.UTF8_STRING = XInternAtom (server.dsp, "UTF8_STRING", False);
server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_SUPPORTING_WM_CHECK", False); server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_SUPPORTING_WM_CHECK", False);
server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_WM_NAME", False); server.atom._NET_SUPPORTING_WM_CHECK = XInternAtom (server.dsp, "_NET_WM_NAME", False);
server.atom._WIN_LAYER = XInternAtom (server.dsp, "_WIN_LAYER", False); server.atom._WIN_LAYER = XInternAtom (server.dsp, "_WIN_LAYER", False);
server.atom._NET_WM_STRUT_PARTIAL = XInternAtom (server.dsp, "_NET_WM_STRUT_PARTIAL", False); server.atom._NET_WM_STRUT_PARTIAL = XInternAtom (server.dsp, "_NET_WM_STRUT_PARTIAL", False);
server.atom.WM_NAME = XInternAtom(server.dsp, "WM_NAME", False); server.atom.WM_NAME = XInternAtom(server.dsp, "WM_NAME", False);
server.atom.__SWM_VROOT = XInternAtom(server.dsp, "__SWM_VROOT", False); server.atom.__SWM_VROOT = XInternAtom(server.dsp, "__SWM_VROOT", False);
server.atom._MOTIF_WM_HINTS = XInternAtom(server.dsp, "_MOTIF_WM_HINTS", False); server.atom._MOTIF_WM_HINTS = XInternAtom(server.dsp, "_MOTIF_WM_HINTS", False);
// systray protocol // systray protocol
name_trayer = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.dsp)); name_trayer = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(server.dsp));
@ -94,65 +94,65 @@ void cleanup_server()
void send_event32 (Window win, Atom at, long data1, long data2, long data3) void send_event32 (Window win, Atom at, long data1, long data2, long data3)
{ {
XEvent event; XEvent event;
event.xclient.type = ClientMessage; event.xclient.type = ClientMessage;
event.xclient.serial = 0; event.xclient.serial = 0;
event.xclient.send_event = True; event.xclient.send_event = True;
event.xclient.display = server.dsp; event.xclient.display = server.dsp;
event.xclient.window = win; event.xclient.window = win;
event.xclient.message_type = at; event.xclient.message_type = at;
event.xclient.format = 32; event.xclient.format = 32;
event.xclient.data.l[0] = data1; event.xclient.data.l[0] = data1;
event.xclient.data.l[1] = data2; event.xclient.data.l[1] = data2;
event.xclient.data.l[2] = data3; event.xclient.data.l[2] = data3;
event.xclient.data.l[3] = 0; event.xclient.data.l[3] = 0;
event.xclient.data.l[4] = 0; event.xclient.data.l[4] = 0;
XSendEvent(server.dsp, server.root_win, False, SubstructureRedirectMask|SubstructureNotifyMask, &event); XSendEvent(server.dsp, server.root_win, False, SubstructureRedirectMask|SubstructureNotifyMask, &event);
} }
int get_property32 (Window win, Atom at, Atom type) int get_property32 (Window win, Atom at, Atom type)
{ {
Atom type_ret; Atom type_ret;
int format_ret = 0, data = 0; int format_ret = 0, data = 0;
unsigned long nitems_ret = 0; unsigned long nitems_ret = 0;
unsigned long bafter_ret = 0; unsigned long bafter_ret = 0;
unsigned char *prop_value = 0; unsigned char *prop_value = 0;
int result; int result;
if (!win) return 0; if (!win) return 0;
result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value); result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value);
if (result == Success && prop_value) { if (result == Success && prop_value) {
data = ((gulong*)prop_value)[0]; data = ((gulong*)prop_value)[0];
XFree (prop_value); XFree (prop_value);
} }
return data; return data;
} }
void *server_get_property (Window win, Atom at, Atom type, int *num_results) void *server_get_property (Window win, Atom at, Atom type, int *num_results)
{ {
Atom type_ret; Atom type_ret;
int format_ret = 0; int format_ret = 0;
unsigned long nitems_ret = 0; unsigned long nitems_ret = 0;
unsigned long bafter_ret = 0; unsigned long bafter_ret = 0;
unsigned char *prop_value; unsigned char *prop_value;
int result; int result;
if (!win) return 0; if (!win) return 0;
result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value); result = XGetWindowProperty(server.dsp, win, at, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &nitems_ret, &bafter_ret, &prop_value);
/* Send back resultcount */ /* Send back resultcount */
if (num_results) *num_results = nitems_ret; if (num_results) *num_results = nitems_ret;
if (result == Success && prop_value) return prop_value; if (result == Success && prop_value) return prop_value;
else return 0; else return 0;
} }
@ -160,7 +160,7 @@ void get_root_pixmap()
{ {
Pixmap ret = None; Pixmap ret = None;
unsigned long *res; unsigned long *res;
int c = 2; int c = 2;
do { do {
@ -168,7 +168,7 @@ void get_root_pixmap()
if (res) { if (res) {
ret = *((Pixmap*)res); ret = *((Pixmap*)res);
XFree(res); XFree(res);
break; break;
} }
} while (--c > 0); } while (--c > 0);
server.root_pmap = ret; server.root_pmap = ret;
@ -190,49 +190,49 @@ void get_root_pixmap()
int compareMonitor(const void *monitor1, const void *monitor2) int compareMonitor(const void *monitor1, const void *monitor2)
{ {
Monitor *m1 = (Monitor*)monitor1; Monitor *m1 = (Monitor*)monitor1;
Monitor *m2 = (Monitor*)monitor2; Monitor *m2 = (Monitor*)monitor2;
if (m1->x < m2->x) { if (m1->x < m2->x) {
return -1; return -1;
} }
else else
if (m1->x > m2->x) { if (m1->x > m2->x) {
return 1; return 1;
} }
else else
if (m1->width < m2->width) { if (m1->width < m2->width) {
return 1; return 1;
} }
else else
if (m1->width > m2->width) { if (m1->width > m2->width) {
return -1; return -1;
} }
else { else {
return 0; return 0;
} }
} }
void get_monitors_and_desktops() void get_monitors_and_desktops()
{ {
int i; int i;
if (server.monitor) free(server.monitor); if (server.monitor) free(server.monitor);
server.nb_monitor = 0; server.nb_monitor = 0;
server.monitor = 0; server.monitor = 0;
int nb_monitor; int nb_monitor;
if (XineramaIsActive(server.dsp)) { if (XineramaIsActive(server.dsp)) {
XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor); XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor);
if (info) { if (info) {
int nb=0, j; int nb=0, j;
i = 0; i = 0;
server.monitor = calloc(nb_monitor, sizeof(Monitor)); server.monitor = calloc(nb_monitor, sizeof(Monitor));
while (i < nb_monitor) { while (i < nb_monitor) {
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
if (info[i].x_org >= info[j].x_org && info[i].y_org >= info[j].y_org && (info[i].x_org+info[i].width) <= (info[j].x_org+info[j].width) && (info[i].y_org+info[i].height) <= (info[j].y_org+info[j].height)) { if (info[i].x_org >= info[j].x_org && info[i].y_org >= info[j].y_org && (info[i].x_org+info[i].width) <= (info[j].x_org+info[j].width) && (info[i].y_org+info[i].height) <= (info[j].y_org+info[j].height)) {
if (info[i].x_org == info[j].x_org && info[i].y_org == info[j].y_org && info[i].width == info[j].width && info[i].height == info[j].height && nb == 0) { if (info[i].x_org == info[j].x_org && info[i].y_org == info[j].y_org && info[i].width == info[j].width && info[i].height == info[j].height && nb == 0) {
// add the first monitor // add the first monitor
@ -240,48 +240,48 @@ void get_monitors_and_desktops()
} }
else { else {
// doesn't count monitor 'i' because it's included into another one // doesn't count monitor 'i' because it's included into another one
//fprintf(stderr, "monitor %d included into another one\n", i); //fprintf(stderr, "monitor %d included into another one\n", i);
goto next; goto next;
} }
} }
} }
server.monitor[nb].x = info[i].x_org; server.monitor[nb].x = info[i].x_org;
server.monitor[nb].y = info[i].y_org; server.monitor[nb].y = info[i].y_org;
server.monitor[nb].width = info[i].width; server.monitor[nb].width = info[i].width;
server.monitor[nb].height = info[i].height; server.monitor[nb].height = info[i].height;
nb++; nb++;
next: next:
i++; i++;
} }
XFree(info); XFree(info);
server.nb_monitor = nb; server.nb_monitor = nb;
// ordered monitor according to coordinate // ordered monitor according to coordinate
qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor); qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor);
} }
} }
if (!server.nb_monitor) { if (!server.nb_monitor) {
server.nb_monitor = 1; server.nb_monitor = 1;
server.monitor = calloc(server.nb_monitor, sizeof(Monitor)); server.monitor = calloc(server.nb_monitor, sizeof(Monitor));
server.monitor[0].x = server.monitor[0].y = 0; server.monitor[0].x = server.monitor[0].y = 0;
server.monitor[0].width = DisplayWidth (server.dsp, server.screen); server.monitor[0].width = DisplayWidth (server.dsp, server.screen);
server.monitor[0].height = DisplayHeight (server.dsp, server.screen); server.monitor[0].height = DisplayHeight (server.dsp, server.screen);
} }
// detect number of desktops // detect number of desktops
// wait 15s to leave some time for window manager startup // wait 15s to leave some time for window manager startup
for (i=0 ; i < 15 ; i++) { for (i=0 ; i < 15 ; i++) {
server.nb_desktop = server_get_number_of_desktop (); server.nb_desktop = server_get_number_of_desktop ();
if (server.nb_desktop > 0) break; if (server.nb_desktop > 0) break;
sleep(1); sleep(1);
} }
if (server.nb_desktop == 0) { if (server.nb_desktop == 0) {
server.nb_desktop = 1; server.nb_desktop = 1;
fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n"); fprintf(stderr, "warning : WM doesn't respect NETWM specs. tint2 default to 1 desktop.\n");
} }
fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", server.nb_monitor, server.nb_desktop); fprintf(stderr, "tint2 : nb monitor %d, nb desktop %d\n", server.nb_monitor, server.nb_desktop);
} }

View file

@ -78,14 +78,14 @@ void init_systray()
void cleanup_systray() void cleanup_systray()
{ {
if (systray.list_icons) { if (systray.list_icons) {
// remove_icon change systray.list_icons // remove_icon change systray.list_icons
while(systray.list_icons) while(systray.list_icons)
remove_icon((TrayWindow*)systray.list_icons->data); remove_icon((TrayWindow*)systray.list_icons->data);
g_slist_free(systray.list_icons); g_slist_free(systray.list_icons);
systray.list_icons = 0; systray.list_icons = 0;
} }
free_area(&systray.area); free_area(&systray.area);
cleanup_net(); cleanup_net();
@ -199,7 +199,7 @@ int init_net()
} }
// init systray protocol // init systray protocol
net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0); net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0);
// v0.2 trayer specification. tint2 always orizontal. // v0.2 trayer specification. tint2 always orizontal.
// TODO : vertical panel ?? // TODO : vertical panel ??
@ -210,11 +210,11 @@ int init_net()
if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) { if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) {
fprintf(stderr, "tint2 : can't get systray manager\n"); fprintf(stderr, "tint2 : can't get systray manager\n");
return 0; return 0;
} }
XClientMessageEvent ev; XClientMessageEvent ev;
ev.type = ClientMessage; ev.type = ClientMessage;
ev.window = server.root_win; ev.window = server.root_win;
ev.message_type = server.atom.MANAGER; ev.message_type = server.atom.MANAGER;
ev.format = 32; ev.format = 32;
ev.data.l[0] = CurrentTime; ev.data.l[0] = CurrentTime;
@ -230,8 +230,8 @@ int init_net()
void cleanup_net() void cleanup_net()
{ {
if (net_sel_win != None) { if (net_sel_win != None) {
XDestroyWindow(server.dsp, net_sel_win); XDestroyWindow(server.dsp, net_sel_win);
net_sel_win = None; net_sel_win = None;
} }
} }
@ -319,9 +319,9 @@ gboolean add_icon(Window id)
traywin = g_new0(TrayWindow, 1); traywin = g_new0(TrayWindow, 1);
traywin->id = id; traywin->id = id;
// systray.list_icons = g_slist_prepend(systray.list_icons, traywin); // systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows); systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows);
systray.area.resize = 1; systray.area.resize = 1;
systray.area.redraw = 1; systray.area.redraw = 1;
//printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons)); //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));
@ -346,7 +346,7 @@ void remove_icon(TrayWindow *traywin)
// remove from our list // remove from our list
systray.list_icons = g_slist_remove(systray.list_icons, traywin); systray.list_icons = g_slist_remove(systray.list_icons, traywin);
g_free(traywin); g_free(traywin);
systray.area.resize = 1; systray.area.resize = 1;
systray.area.redraw = 1; systray.area.redraw = 1;
//printf("remove_icon id %lx, %d\n", traywin->id); //printf("remove_icon id %lx, %d\n", traywin->id);

View file

@ -204,11 +204,11 @@ void get_icon (Task *tsk)
#endif #endif
} }
XFree (data); XFree (data);
} }
else { else {
// get Pixmap icon // get Pixmap icon
XWMHints *hints = XGetWMHints(server.dsp, tsk->win); XWMHints *hints = XGetWMHints(server.dsp, tsk->win);
if (!hints) return; if (!hints) return;
if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) { if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) {
// get width, height and depth for the pixmap // get width, height and depth for the pixmap
Window root; Window root;
@ -235,7 +235,7 @@ void get_icon (Task *tsk)
imlib_free_image(); imlib_free_image();
} }
XFree(hints); XFree(hints);
} }
if (tsk->icon_data) { if (tsk->icon_data) {
tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32)); tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32));

View file

@ -36,8 +36,8 @@
void init_taskbar() void init_taskbar()
{ {
Panel *panel; Panel *panel;
int i, j; int i, j;
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i]; panel = &panel1[i];
@ -115,9 +115,9 @@ void init_taskbar()
void cleanup_taskbar() void cleanup_taskbar()
{ {
Panel *panel; Panel *panel;
Taskbar *tskbar; Taskbar *tskbar;
int i, j; int i, j;
GSList *l0; GSList *l0;
Task *tsk; Task *tsk;
@ -152,11 +152,11 @@ void cleanup_taskbar()
Task *task_get_task (Window win) Task *task_get_task (Window win)
{ {
Task *tsk; Task *tsk;
GSList *l0; GSList *l0;
int i, j; int i, j;
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
for (j=0 ; j < panel1[i].nb_desktop ; j++) { for (j=0 ; j < panel1[i].nb_desktop ; j++) {
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) { for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk = l0->data; tsk = l0->data;
@ -164,23 +164,23 @@ Task *task_get_task (Window win)
return tsk; return tsk;
} }
} }
} }
return 0; return 0;
} }
void task_refresh_tasklist () void task_refresh_tasklist ()
{ {
Window *win, active_win; Window *win, active_win;
int num_results, i, j, k; int num_results, i, j, k;
GSList *l0; GSList *l0;
Task *tsk; Task *tsk;
win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results); win = server_get_property (server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results);
if (!win) return; if (!win) return;
// Remove any old and set active win // Remove any old and set active win
active_win = window_get_active (); active_win = window_get_active ();
if (task_active) { if (task_active) {
task_active->area.is_active = 0; task_active->area.is_active = 0;
task_active = 0; task_active = 0;
@ -205,28 +205,28 @@ void task_refresh_tasklist ()
if (k == num_results) remove_task (tsk); if (k == num_results) remove_task (tsk);
} }
} }
} }
// Add any new // Add any new
for (i = 0; i < num_results; i++) for (i = 0; i < num_results; i++)
if (!task_get_task (win[i])) if (!task_get_task (win[i]))
add_task (win[i]); add_task (win[i]);
XFree (win); XFree (win);
} }
void resize_taskbar(void *obj) void resize_taskbar(void *obj)
{ {
Taskbar *taskbar = (Taskbar*)obj; Taskbar *taskbar = (Taskbar*)obj;
Panel *panel = (Panel*)taskbar->area.panel; Panel *panel = (Panel*)taskbar->area.panel;
Task *tsk; Task *tsk;
GSList *l; GSList *l;
int task_count; int task_count;
//printf("resize_taskbar : posx et width des taches\n"); //printf("resize_taskbar : posx et width des taches\n");
taskbar->area.redraw = 1; taskbar->area.redraw = 1;
if (panel_horizontal) { if (panel_horizontal) {
int pixel_width, modulo_width=0; int pixel_width, modulo_width=0;

View file

@ -48,52 +48,52 @@ void signal_handler(int sig)
void init (int argc, char *argv[]) void init (int argc, char *argv[])
{ {
int c; int c;
// read options // read options
c = getopt (argc, argv, "c:"); c = getopt (argc, argv, "c:");
if (c != -1) { if (c != -1) {
config_path = strdup (optarg); config_path = strdup (optarg);
c = getopt (argc, argv, "j:"); c = getopt (argc, argv, "j:");
if (c != -1) if (c != -1)
thumbnail_path = strdup (optarg); thumbnail_path = strdup (optarg);
} }
// Set signal handler // Set signal handler
signal(SIGUSR1, signal_handler); signal(SIGUSR1, signal_handler);
signal(SIGINT, signal_handler); signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler); signal(SIGTERM, signal_handler);
signal(SIGHUP, signal_handler); signal(SIGHUP, signal_handler);
signal(SIGCHLD, SIG_IGN); // don't have to wait() after fork() signal(SIGCHLD, SIG_IGN); // don't have to wait() after fork()
// set global data // set global data
memset(&server, 0, sizeof(Server_global)); memset(&server, 0, sizeof(Server_global));
memset(&systray, 0, sizeof(Systraybar)); memset(&systray, 0, sizeof(Systraybar));
server.dsp = XOpenDisplay (NULL); server.dsp = XOpenDisplay (NULL);
if (!server.dsp) { if (!server.dsp) {
fprintf(stderr, "tint2 exit : could not open display.\n"); fprintf(stderr, "tint2 exit : could not open display.\n");
exit(0); exit(0);
} }
server_init_atoms (); server_init_atoms ();
server.screen = DefaultScreen (server.dsp); server.screen = DefaultScreen (server.dsp);
server.root_win = RootWindow(server.dsp, server.screen); server.root_win = RootWindow(server.dsp, server.screen);
server.depth = DefaultDepth (server.dsp, server.screen); server.depth = DefaultDepth (server.dsp, server.screen);
server.visual = DefaultVisual (server.dsp, server.screen); server.visual = DefaultVisual (server.dsp, server.screen);
server.desktop = server_get_current_desktop (); server.desktop = server_get_current_desktop ();
XGCValues gcv; XGCValues gcv;
server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv) ; server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv) ;
XSetErrorHandler ((XErrorHandler) server_catch_error); XSetErrorHandler ((XErrorHandler) server_catch_error);
imlib_context_set_display (server.dsp); imlib_context_set_display (server.dsp);
imlib_context_set_visual (server.visual); imlib_context_set_visual (server.visual);
imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen)); imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen));
/* Catch events */ /* Catch events */
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
} }
@ -101,13 +101,13 @@ void cleanup()
{ {
cleanup_panel(); cleanup_panel();
if (time1_font_desc) pango_font_description_free(time1_font_desc); if (time1_font_desc) pango_font_description_free(time1_font_desc);
if (time2_font_desc) pango_font_description_free(time2_font_desc); if (time2_font_desc) pango_font_description_free(time2_font_desc);
if (time1_format) g_free(time1_format); if (time1_format) g_free(time1_format);
if (time2_format) g_free(time2_format); if (time2_format) g_free(time2_format);
#ifdef ENABLE_BATTERY #ifdef ENABLE_BATTERY
if (bat1_font_desc) pango_font_description_free(bat1_font_desc); if (bat1_font_desc) pango_font_description_free(bat1_font_desc);
if (bat2_font_desc) pango_font_description_free(bat2_font_desc); if (bat2_font_desc) pango_font_description_free(bat2_font_desc);
if (battery_low_cmd) g_free(battery_low_cmd); if (battery_low_cmd) g_free(battery_low_cmd);
if (path_energy_now) g_free(path_energy_now); if (path_energy_now) g_free(path_energy_now);
if (path_energy_full) g_free(path_energy_full); if (path_energy_full) g_free(path_energy_full);
@ -119,9 +119,9 @@ void cleanup()
if (config_path) g_free(config_path); if (config_path) g_free(config_path);
if (thumbnail_path) g_free(thumbnail_path); if (thumbnail_path) g_free(thumbnail_path);
if (server.monitor) free(server.monitor); if (server.monitor) free(server.monitor);
XFreeGC(server.dsp, server.gc); XFreeGC(server.dsp, server.gc);
XCloseDisplay(server.dsp); XCloseDisplay(server.dsp);
} }
@ -212,7 +212,7 @@ int click_clock(Panel *panel, XEvent *e)
void window_action (Task *tsk, int action) void window_action (Task *tsk, int action)
{ {
if (!tsk) return; if (!tsk) return;
int desk; int desk;
switch (action) { switch (action) {
case CLOSE: case CLOSE:
@ -259,13 +259,13 @@ void window_action (Task *tsk, int action)
void event_button_press (XEvent *e) void event_button_press (XEvent *e)
{ {
Panel *panel = get_panel(e->xany.window); Panel *panel = get_panel(e->xany.window);
if (!panel) return; if (!panel) return;
if (panel_mode == MULTI_DESKTOP) if (panel_mode == MULTI_DESKTOP)
task_drag = click_task(panel, e); task_drag = click_task(panel, e);
if (wm_menu && !task_drag && !click_clock(panel, e) && (e->xbutton.button != 1) ) { if (wm_menu && !task_drag && !click_clock(panel, e) && (e->xbutton.button != 1) ) {
// forward the click to the desktop window (thanks conky) // forward the click to the desktop window (thanks conky)
XUngrabPointer(server.dsp, e->xbutton.time); XUngrabPointer(server.dsp, e->xbutton.time);
e->xbutton.window = server.root_win; e->xbutton.window = server.root_win;
@ -277,15 +277,15 @@ void event_button_press (XEvent *e)
XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time); XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e); XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
return; return;
} }
XLowerWindow (server.dsp, panel->main_win); XLowerWindow (server.dsp, panel->main_win);
} }
void event_button_release (XEvent *e) void event_button_release (XEvent *e)
{ {
Panel *panel = get_panel(e->xany.window); Panel *panel = get_panel(e->xany.window);
if (!panel) return; if (!panel) return;
if (wm_menu && click_padding(panel, e)) { if (wm_menu && click_padding(panel, e)) {
@ -295,27 +295,27 @@ void event_button_release (XEvent *e)
return; return;
} }
int action = TOGGLE_ICONIFY; int action = TOGGLE_ICONIFY;
switch (e->xbutton.button) { switch (e->xbutton.button) {
case 2: case 2:
action = mouse_middle; action = mouse_middle;
break; break;
case 3: case 3:
action = mouse_right; action = mouse_right;
break; break;
case 4: case 4:
action = mouse_scroll_up; action = mouse_scroll_up;
break; break;
case 5: case 5:
action = mouse_scroll_down; action = mouse_scroll_down;
break; break;
case 6: case 6:
action = mouse_tilt_left; action = mouse_tilt_left;
break; break;
case 7: case 7:
action = mouse_tilt_right; action = mouse_tilt_right;
break; break;
} }
if ( click_clock(panel, e)) { if ( click_clock(panel, e)) {
clock_action(e->xbutton.button); clock_action(e->xbutton.button);
@ -332,51 +332,51 @@ void event_button_release (XEvent *e)
return; return;
} }
// drag and drop task // drag and drop task
if (task_drag) { if (task_drag) {
if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) { if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) {
if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) { if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) {
windows_set_desktop(task_drag->win, tskbar->desktop); windows_set_desktop(task_drag->win, tskbar->desktop);
if (tskbar->desktop == server.desktop) if (tskbar->desktop == server.desktop)
set_active(task_drag->win); set_active(task_drag->win);
task_drag = 0; task_drag = 0;
} }
return; return;
} }
else task_drag = 0; else task_drag = 0;
}
// switch desktop
if (panel_mode == MULTI_DESKTOP) {
if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT)
set_desktop (tskbar->desktop);
} }
// action on task // switch desktop
window_action( click_task(panel, e), action); if (panel_mode == MULTI_DESKTOP) {
if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT)
set_desktop (tskbar->desktop);
}
// to keep window below // action on task
XLowerWindow (server.dsp, panel->main_win); window_action( click_task(panel, e), action);
// to keep window below
XLowerWindow (server.dsp, panel->main_win);
} }
void event_property_notify (XEvent *e) void event_property_notify (XEvent *e)
{ {
int i, j; int i, j;
Task *tsk; Task *tsk;
Window win = e->xproperty.window; Window win = e->xproperty.window;
Atom at = e->xproperty.atom; Atom at = e->xproperty.atom;
if (win == server.root_win) { if (win == server.root_win) {
if (!server.got_root_win) { if (!server.got_root_win) {
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
server.got_root_win = 1; server.got_root_win = 1;
} }
// Change number of desktops // Change number of desktops
else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) { else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
server.nb_desktop = server_get_number_of_desktop (); server.nb_desktop = server_get_number_of_desktop ();
cleanup_taskbar(); cleanup_taskbar();
init_taskbar(); init_taskbar();
visible_object(); visible_object();
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
@ -384,12 +384,12 @@ void event_property_notify (XEvent *e)
} }
task_refresh_tasklist(); task_refresh_tasklist();
panel_refresh = 1; panel_refresh = 1;
} }
// Change desktop // Change desktop
else if (at == server.atom._NET_CURRENT_DESKTOP) { else if (at == server.atom._NET_CURRENT_DESKTOP) {
server.desktop = server_get_current_desktop (); server.desktop = server_get_current_desktop ();
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
Panel *panel = &panel1[i]; Panel *panel = &panel1[i];
if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) { if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) {
// redraw taskbar // redraw taskbar
panel_refresh = 1; panel_refresh = 1;
@ -417,72 +417,77 @@ void event_property_notify (XEvent *e)
} }
} }
} }
if (panel_mode != MULTI_DESKTOP) { if (panel_mode != MULTI_DESKTOP) {
visible_object(); visible_object();
} }
} }
// Window list // Window list
else if (at == server.atom._NET_CLIENT_LIST) { else if (at == server.atom._NET_CLIENT_LIST) {
task_refresh_tasklist(); task_refresh_tasklist();
panel_refresh = 1; panel_refresh = 1;
} }
// Change active // Change active
else if (at == server.atom._NET_ACTIVE_WINDOW) { else if (at == server.atom._NET_ACTIVE_WINDOW) {
GSList *l0; GSList *l0;
if (task_active) { if (task_active) {
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
for (j=0 ; j < panel1[i].nb_desktop ; j++) { for (j=0 ; j < panel1[i].nb_desktop ; j++) {
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) { for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk = l0->data; tsk = l0->data;
tsk->area.is_active = 0; tsk->area.is_active = 0;
} }
} }
} }
task_active = 0; task_active = 0;
}
Window w1 = window_get_active ();
Task *t = task_get_task(w1);
if (!t) {
Window w2;
if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
if (w2) t = task_get_task(w2);
} }
Window w1 = window_get_active ();
Task *t = task_get_task(w1);
if (!t) {
Window w2;
if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
if (w2) t = task_get_task(w2);
}
if (task_urgent == t) { if (task_urgent == t) {
init_precision(); init_precision();
task_urgent = 0; task_urgent = 0;
} }
// put active state on all task (multi_desktop) // put active state on all task (multi_desktop)
if (t) { if (t) {
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
for (j=0 ; j < panel1[i].nb_desktop ; j++) { for (j=0 ; j < panel1[i].nb_desktop ; j++) {
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) { for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
tsk = l0->data; tsk = l0->data;
if (tsk->win == t->win) { if (tsk->win == t->win) {
tsk->area.is_active = 1; tsk->area.is_active = 1;
//printf("active monitor %d, task %s\n", panel1[i].monitor, tsk->title); //printf("active monitor %d, task %s\n", panel1[i].monitor, tsk->title);
} }
} }
} }
} }
task_active = t; task_active = t;
} }
panel_refresh = 1; panel_refresh = 1;
} }
else if (at == server.atom._XROOTPMAP_ID) { else if (at == server.atom._XROOTPMAP_ID) {
// change Wallpaper // change Wallpaper
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
set_panel_background(&panel1[i]); set_panel_background(&panel1[i]);
} }
panel_refresh = 1; panel_refresh = 1;
} }
} }
else { else {
tsk = task_get_task (win); tsk = task_get_task (win);
if (!tsk) return; if (!tsk) {
//printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title); if ( at != server.atom._NET_WM_STATE)
return;
else if ( !(tsk = add_task(win)) )
return;
}
//printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
// Window title changed // Window title changed
if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) { if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
Task *tsk2; Task *tsk2;
GSList *l0; GSList *l0;
get_title(tsk); get_title(tsk);
@ -498,22 +503,25 @@ void event_property_notify (XEvent *e)
} }
} }
} }
panel_refresh = 1; panel_refresh = 1;
} }
// Demand attention // Demand attention
else if (at == server.atom._NET_WM_STATE) { else if (at == server.atom._NET_WM_STATE) {
if (window_is_urgent (win)) { if (window_is_urgent (win)) {
task_urgent = tsk; task_urgent = tsk;
tick_urgent = 0; tick_urgent = 0;
time_precision = 1; time_precision = 1;
} }
if (window_is_skip_taskbar(win)) {
remove_task( tsk );
}
} }
else if (at == server.atom.WM_STATE) { else if (at == server.atom.WM_STATE) {
// Iconic state // Iconic state
// TODO : try to delete following code // TODO : try to delete following code
if (window_is_iconified (win)) { if (window_is_iconified (win)) {
if (task_active) { if (task_active) {
if (task_active->win == tsk->win) { if (task_active->win == tsk->win) {
Task *tsk2; Task *tsk2;
GSList *l0; GSList *l0;
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
@ -524,14 +532,14 @@ void event_property_notify (XEvent *e)
} }
} }
} }
task_active = 0; task_active = 0;
} }
} }
} }
} }
// Window icon changed // Window icon changed
else if (at == server.atom._NET_WM_ICON) { else if (at == server.atom._NET_WM_ICON) {
get_icon(tsk); get_icon(tsk);
Task *tsk2; Task *tsk2;
GSList *l0; GSList *l0;
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
@ -548,10 +556,10 @@ void event_property_notify (XEvent *e)
} }
} }
} }
panel_refresh = 1; panel_refresh = 1;
} }
// Window desktop changed // Window desktop changed
else if (at == server.atom._NET_WM_DESKTOP) { else if (at == server.atom._NET_WM_DESKTOP) {
int desktop = window_get_desktop (win); int desktop = window_get_desktop (win);
int active = tsk->area.is_active; int active = tsk->area.is_active;
//printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop); //printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
@ -565,21 +573,21 @@ void event_property_notify (XEvent *e)
} }
panel_refresh = 1; panel_refresh = 1;
} }
} }
if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen); if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen);
} }
} }
void event_expose (XEvent *e) void event_expose (XEvent *e)
{ {
Panel *panel; Panel *panel;
panel = get_panel(e->xany.window); panel = get_panel(e->xany.window);
if (!panel) return; if (!panel) return;
// TODO : one panel_refresh per panel ? // TODO : one panel_refresh per panel ?
panel_refresh = 1; panel_refresh = 1;
} }
@ -593,39 +601,39 @@ void event_configure_notify (Window win)
if (traywin->id == win) { if (traywin->id == win) {
//printf("move tray %d\n", traywin->x); //printf("move tray %d\n", traywin->x);
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height); XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
panel_refresh = 1; panel_refresh = 1;
return; return;
} }
} }
// check 'win' move in another monitor // check 'win' move in another monitor
if (nb_panel == 1) return; if (nb_panel == 1) return;
if (server.nb_monitor == 1) return; if (server.nb_monitor == 1) return;
Task *tsk = task_get_task (win); Task *tsk = task_get_task (win);
if (!tsk) return; if (!tsk) return;
Panel *p = tsk->area.panel; Panel *p = tsk->area.panel;
if (p->monitor != window_get_monitor (win)) { if (p->monitor != window_get_monitor (win)) {
remove_task (tsk); remove_task (tsk);
add_task (win); add_task (win);
if (win == window_get_active ()) { if (win == window_get_active ()) {
Task *tsk = task_get_task (win); Task *tsk = task_get_task (win);
tsk->area.is_active = 1; tsk->area.is_active = 1;
task_active = tsk; task_active = tsk;
} }
panel_refresh = 1; panel_refresh = 1;
} }
} }
void event_timer() void event_timer()
{ {
struct timeval stv; struct timeval stv;
int i; int i;
if (gettimeofday(&stv, 0)) return; if (gettimeofday(&stv, 0)) return;
if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return; if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return;
time_clock.tv_sec = stv.tv_sec; time_clock.tv_sec = stv.tv_sec;
time_clock.tv_sec -= time_clock.tv_sec % time_precision; time_clock.tv_sec -= time_clock.tv_sec % time_precision;
@ -648,9 +656,9 @@ void event_timer()
#endif #endif
// update clock // update clock
if (time1_format) { if (time1_format) {
for (i=0 ; i < nb_panel ; i++) for (i=0 ; i < nb_panel ; i++)
panel1[i].clock.area.resize = 1; panel1[i].clock.area.resize = 1;
} }
panel_refresh = 1; panel_refresh = 1;
} }
@ -658,20 +666,20 @@ void event_timer()
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
XEvent e; XEvent e;
fd_set fd; fd_set fd;
int x11_fd, i; int x11_fd, i;
struct timeval tv; struct timeval tv;
Panel *panel; Panel *panel;
GSList *it; GSList *it;
init (argc, argv); init (argc, argv);
load_config: load_config:
i = 0; i = 0;
init_config(); init_config();
if (config_path) if (config_path)
i = config_read_file (config_path); i = config_read_file (config_path);
else else
i = config_read (); i = config_read ();
if (!i) { if (!i) {
@ -679,7 +687,7 @@ load_config:
cleanup(); cleanup();
exit(1); exit(1);
} }
config_finish(); config_finish();
if (thumbnail_path) { if (thumbnail_path) {
// usage: tint2 -j <file> for internal use // usage: tint2 -j <file> for internal use
printf("file %s\n", thumbnail_path); printf("file %s\n", thumbnail_path);
@ -687,46 +695,46 @@ load_config:
exit(0); exit(0);
} }
x11_fd = ConnectionNumber(server.dsp); x11_fd = ConnectionNumber(server.dsp);
XSync(server.dsp, False); XSync(server.dsp, False);
while (1) { while (1) {
// thanks to AngryLlama for the timer // thanks to AngryLlama for the timer
// Create a File Description Set containing x11_fd // Create a File Description Set containing x11_fd
FD_ZERO (&fd); FD_ZERO (&fd);
FD_SET (x11_fd, &fd); FD_SET (x11_fd, &fd);
tv.tv_usec = 500000; tv.tv_usec = 500000;
tv.tv_sec = 0; tv.tv_sec = 0;
// Wait for X Event or a Timer // Wait for X Event or a Timer
if (select(x11_fd+1, &fd, 0, 0, &tv)) { if (select(x11_fd+1, &fd, 0, 0, &tv)) {
while (XPending (server.dsp)) { while (XPending (server.dsp)) {
XNextEvent(server.dsp, &e); XNextEvent(server.dsp, &e);
switch (e.type) { switch (e.type) {
case ButtonPress: case ButtonPress:
event_button_press (&e); event_button_press (&e);
break; break;
case ButtonRelease: case ButtonRelease:
event_button_release(&e); event_button_release(&e);
break; break;
case Expose: case Expose:
event_expose(&e); event_expose(&e);
break; break;
case PropertyNotify: case PropertyNotify:
event_property_notify(&e); event_property_notify(&e);
break; break;
case ConfigureNotify: case ConfigureNotify:
if (e.xconfigure.window == server.root_win) if (e.xconfigure.window == server.root_win)
goto load_config; goto load_config;
else else
event_configure_notify (e.xconfigure.window); event_configure_notify (e.xconfigure.window);
break; break;
case ReparentNotify: case ReparentNotify:
if (!systray.area.on_screen) if (!systray.area.on_screen)
@ -753,24 +761,24 @@ load_config:
if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) { if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
net_message(&e.xclient); net_message(&e.xclient);
} }
break; break;
} }
} }
} }
event_timer(); event_timer();
switch (signal_pending) { switch (signal_pending) {
case SIGUSR1: case SIGUSR1:
signal_pending = 0; signal_pending = 0;
goto load_config; goto load_config;
case SIGINT: case SIGINT:
case SIGTERM: case SIGTERM:
case SIGHUP: case SIGHUP:
cleanup (); cleanup ();
return 0; return 0;
} }
if (panel_refresh) { if (panel_refresh) {
panel_refresh = 0; panel_refresh = 0;
if (refresh_systray) { if (refresh_systray) {
@ -783,8 +791,8 @@ load_config:
if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap); if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth); panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
refresh(&panel->area); refresh(&panel->area);
XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
} }
XFlush (server.dsp); XFlush (server.dsp);
@ -797,7 +805,7 @@ load_config:
refresh_systray_icon(); refresh_systray_icon();
} }
} }
} }
} }

View file

@ -41,23 +41,23 @@ void refresh (Area *a)
size(a); size(a);
// don't draw transparent objects (without foreground and without background) // don't draw transparent objects (without foreground and without background)
if (a->redraw) { if (a->redraw) {
a->redraw = 0; a->redraw = 0;
//printf("draw area posx %d, width %d\n", a->posx, a->width); //printf("draw area posx %d, width %d\n", a->posx, a->width);
draw(a, 0); draw(a, 0);
if (a->use_active) if (a->use_active)
draw(a, 1); draw(a, 1);
} }
// draw current Area // draw current Area
Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap); Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
if (*pmap == 0) printf("empty area posx %d, width %d\n", a->posx, a->width); 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); XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
// and then refresh child object // and then refresh child object
GSList *l; GSList *l;
for (l = a->list; l ; l = l->next) for (l = a->list; l ; l = l->next)
refresh(l->data); refresh(l->data);
} }
@ -66,13 +66,13 @@ void size (Area *a)
GSList *l; GSList *l;
if (a->resize) { if (a->resize) {
a->resize = 0; a->resize = 0;
for (l = a->list; l ; l = l->next) for (l = a->list; l ; l = l->next)
size(l->data); size(l->data);
// resize can generate a redraw // resize can generate a redraw
if (a->_resize) { if (a->_resize) {
a->_resize(a); a->_resize(a);
} }
} }
} }
@ -80,159 +80,159 @@ void size (Area *a)
void set_redraw (Area *a) void set_redraw (Area *a)
{ {
a->redraw = 1; a->redraw = 1;
GSList *l; GSList *l;
for (l = a->list ; l ; l = l->next) for (l = a->list ; l ; l = l->next)
set_redraw(l->data); set_redraw(l->data);
} }
void draw (Area *a, int active) void draw (Area *a, int active)
{ {
Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap); Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap);
if (*pmap) XFreePixmap (server.dsp, *pmap); if (*pmap) XFreePixmap (server.dsp, *pmap);
*pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth); *pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
// add layer of root pixmap // add layer of root pixmap
XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);
cairo_surface_t *cs; cairo_surface_t *cs;
cairo_t *c; cairo_t *c;
cs = cairo_xlib_surface_create (server.dsp, *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); c = cairo_create (cs);
draw_background (a, c, active); draw_background (a, c, active);
if (a->_draw_foreground) if (a->_draw_foreground)
a->_draw_foreground(a, c, active); a->_draw_foreground(a, c, active);
cairo_destroy (c); cairo_destroy (c);
cairo_surface_destroy (cs); cairo_surface_destroy (cs);
} }
void draw_background (Area *a, cairo_t *c, int active) void draw_background (Area *a, cairo_t *c, int active)
{ {
Pmap *pix = (active == 0) ? (&a->pix) : (&a->pix_active); Pmap *pix = (active == 0) ? (&a->pix) : (&a->pix_active);
if (pix->back.alpha > 0.0) { 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); //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); 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_set_source_rgba(c, pix->back.color[0], pix->back.color[1], pix->back.color[2], pix->back.alpha);
cairo_fill(c); cairo_fill(c);
} }
if (pix->border.width > 0 && pix->border.alpha > 0.0) { if (pix->border.width > 0 && pix->border.alpha > 0.0) {
cairo_set_line_width (c, pix->border.width); cairo_set_line_width (c, pix->border.width);
// draw border inside (x, y, width, height) // draw border inside (x, y, width, height)
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); 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 // convert : radian = degre * M_PI/180
// définir le dégradé dans un carré de (0,0) (100,100) // définir le dégradé dans un carré de (0,0) (100,100)
// ensuite ce dégradé est extrapolé selon le ratio width/height // ensuite ce dégradé est extrapolé selon le ratio width/height
// dans repère (0, 0) (100, 100) // dans repère (0, 0) (100, 100)
double X0, Y0, X1, Y1, degre; double X0, Y0, X1, Y1, degre;
// x = X * (a->width / 100), y = Y * (a->height / 100) // x = X * (a->width / 100), y = Y * (a->height / 100)
double x0, y0, x1, y1; double x0, y0, x1, y1;
X0 = 0; X0 = 0;
Y0 = 100; Y0 = 100;
X1 = 100; X1 = 100;
Y1 = 0; Y1 = 0;
degre = 45; degre = 45;
// et ensuite faire la changement d'unité du repère // et ensuite faire la changement d'unité du repère
// car ce qui doit resté inchangée est les traits et pas la direction // 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°) // 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 // ceci peut être appliqué une fois pour toute au départ
// ensuite calculer l'angle dans le nouveau repère // ensuite calculer l'angle dans le nouveau repère
// puis faire une rotation de 90° // puis faire une rotation de 90°
x0 = X0 * ((double)a->width / 100); x0 = X0 * ((double)a->width / 100);
x1 = X1 * ((double)a->width / 100); x1 = X1 * ((double)a->width / 100);
y0 = Y0 * ((double)a->height / 100); y0 = Y0 * ((double)a->height / 100);
y1 = Y1 * ((double)a->height / 100); y1 = Y1 * ((double)a->height / 100);
x0 = X0 * ((double)a->height / 100); x0 = X0 * ((double)a->height / 100);
x1 = X1 * ((double)a->height / 100); x1 = X1 * ((double)a->height / 100);
y0 = Y0 * ((double)a->width / 100); y0 = Y0 * ((double)a->width / 100);
y1 = Y1 * ((double)a->width / 100); y1 = Y1 * ((double)a->width / 100);
cairo_pattern_t *linpat; cairo_pattern_t *linpat;
linpat = cairo_pattern_create_linear (x0, y0, x1, y1); linpat = cairo_pattern_create_linear (x0, y0, x1, y1);
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, 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_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 (c, linpat);
*/ */
cairo_set_source_rgba (c, pix->border.color[0], pix->border.color[1], pix->border.color[2], pix->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_stroke (c);
//cairo_pattern_destroy (linpat); //cairo_pattern_destroy (linpat);
} }
} }
void remove_area (Area *a) void remove_area (Area *a)
{ {
Area *parent = (Area*)a->parent; Area *parent = (Area*)a->parent;
parent->list = g_slist_remove(parent->list, a); parent->list = g_slist_remove(parent->list, a);
set_redraw (parent); set_redraw (parent);
} }
void add_area (Area *a) void add_area (Area *a)
{ {
Area *parent = (Area*)a->parent; Area *parent = (Area*)a->parent;
parent->list = g_slist_remove(parent->list, a); parent->list = g_slist_remove(parent->list, a);
set_redraw (parent); set_redraw (parent);
} }
void free_area (Area *a) void free_area (Area *a)
{ {
GSList *l0; GSList *l0;
for (l0 = a->list; l0 ; l0 = l0->next) for (l0 = a->list; l0 ; l0 = l0->next)
free_area (l0->data); free_area (l0->data);
if (a->list) { if (a->list) {
g_slist_free(a->list); g_slist_free(a->list);
a->list = 0; a->list = 0;
}
if (a->pix.pmap) {
XFreePixmap (server.dsp, a->pix.pmap);
a->pix.pmap = 0;
} }
if (a->pix_active.pmap) { if (a->pix.pmap) {
XFreePixmap (server.dsp, a->pix_active.pmap); XFreePixmap (server.dsp, a->pix.pmap);
a->pix_active.pmap = 0; a->pix.pmap = 0;
}
if (a->pix_active.pmap) {
XFreePixmap (server.dsp, a->pix_active.pmap);
a->pix_active.pmap = 0;
} }
} }
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r) void draw_rect(cairo_t *c, double x, double y, double w, double h, double r)
{ {
if (r > 0.0) { if (r > 0.0) {
double c1 = 0.55228475 * r; double c1 = 0.55228475 * r;
cairo_move_to(c, x+r, y); cairo_move_to(c, x+r, y);
cairo_rel_line_to(c, w-2*r, 0); cairo_rel_line_to(c, w-2*r, 0);
cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r); cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r);
cairo_rel_line_to(c, 0, h-2*r); cairo_rel_line_to(c, 0, h-2*r);
cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r); cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r);
cairo_rel_line_to (c, -w +2*r, 0); cairo_rel_line_to (c, -w +2*r, 0);
cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r); cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r);
cairo_rel_line_to (c, 0, -h + 2 * r); cairo_rel_line_to (c, 0, -h + 2 * r);
cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r); cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r);
} }
else else
cairo_rectangle(c, x, y, w, h); cairo_rectangle(c, x, y, w, h);
} }

View file

@ -38,70 +38,70 @@
void set_active (Window win) void set_active (Window win)
{ {
send_event32 (win, server.atom._NET_ACTIVE_WINDOW, 2, CurrentTime, 0); send_event32 (win, server.atom._NET_ACTIVE_WINDOW, 2, CurrentTime, 0);
} }
void set_desktop (int desktop) void set_desktop (int desktop)
{ {
send_event32 (server.root_win, server.atom._NET_CURRENT_DESKTOP, desktop, 0, 0); send_event32 (server.root_win, server.atom._NET_CURRENT_DESKTOP, desktop, 0, 0);
} }
void windows_set_desktop (Window win, int desktop) void windows_set_desktop (Window win, int desktop)
{ {
send_event32 (win, server.atom._NET_WM_DESKTOP, desktop, 2, 0); send_event32 (win, server.atom._NET_WM_DESKTOP, desktop, 2, 0);
} }
void set_close (Window win) void set_close (Window win)
{ {
send_event32 (win, server.atom._NET_CLOSE_WINDOW, 0, 2, 0); send_event32 (win, server.atom._NET_CLOSE_WINDOW, 0, 2, 0);
} }
void window_toggle_shade (Window win) void window_toggle_shade (Window win)
{ {
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_SHADED, 0); send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_SHADED, 0);
} }
void window_maximize_restore (Window win) void window_maximize_restore (Window win)
{ {
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_VERT, 0); send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_VERT, 0);
send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_HORZ, 0); send_event32 (win, server.atom._NET_WM_STATE, 2, server.atom._NET_WM_STATE_MAXIMIZED_HORZ, 0);
} }
int window_is_hidden (Window win) int window_is_hidden (Window win)
{ {
Window window; Window window;
Atom *at; Atom *at;
int count, i; int count, i;
if (XGetTransientForHint(server.dsp, win, &window) != 0) { if (XGetTransientForHint(server.dsp, win, &window) != 0) {
if (window) { if (window) {
return 1; return 1;
} }
} }
at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count); at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) { if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) {
XFree(at); XFree(at);
return 1; return 1;
} }
} }
XFree(at); XFree(at);
at = server_get_property (win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count); at = server_get_property (win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) { if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) {
XFree(at); XFree(at);
return 1; return 1;
} }
} }
XFree(at); XFree(at);
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
if (panel1[i].main_win == win) { if (panel1[i].main_win == win) {
@ -109,172 +109,189 @@ int window_is_hidden (Window win)
} }
} }
// specification // specification
// Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set // Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set
// MUST be taken as top-level window. // MUST be taken as top-level window.
return 0; return 0;
} }
int window_get_desktop (Window win) int window_get_desktop (Window win)
{ {
return get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL); return get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL);
} }
int window_get_monitor (Window win) int window_get_monitor (Window win)
{ {
int i, x, y; int i, x, y;
Window src; Window src;
XTranslateCoordinates(server.dsp, win, server.root_win, 0, 0, &x, &y, &src); XTranslateCoordinates(server.dsp, win, server.root_win, 0, 0, &x, &y, &src);
x += 2; x += 2;
y += 2; y += 2;
for (i = 0; i < server.nb_monitor; i++) { for (i = 0; i < server.nb_monitor; i++) {
if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width)) if (x >= server.monitor[i].x && x <= (server.monitor[i].x + server.monitor[i].width))
if (y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height)) if (y >= server.monitor[i].y && y <= (server.monitor[i].y + server.monitor[i].height))
break; break;
} }
//printf("window %lx : ecran %d, (%d, %d)\n", win, i, x, y); //printf("window %lx : ecran %d, (%d, %d)\n", win, i, x, y);
if (i == server.nb_monitor) return 0; if (i == server.nb_monitor) return 0;
else return i; else return i;
} }
int window_is_iconified (Window win) int window_is_iconified (Window win)
{ {
return (IconicState == get_property32(win, server.atom.WM_STATE, server.atom.WM_STATE)); return (IconicState == get_property32(win, server.atom.WM_STATE, server.atom.WM_STATE));
} }
int window_is_urgent (Window win) int window_is_urgent (Window win)
{ {
Atom *at; Atom *at;
int count, i; int count, i;
at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count); at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (at[i] == server.atom._NET_WM_STATE_DEMANDS_ATTENTION) { if (at[i] == server.atom._NET_WM_STATE_DEMANDS_ATTENTION) {
XFree(at); XFree(at);
return 1; return 1;
} }
} }
XFree(at); XFree(at);
return 0;
}
int window_is_skip_taskbar (Window win)
{
Atom *at;
int count, i;
at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (i=0; i<count; i++) {
if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) {
XFree(at);
return 1;
}
}
XFree(at);
return 0; return 0;
} }
int server_get_number_of_desktop () int server_get_number_of_desktop ()
{ {
return get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL); return get_property32(server.root_win, server.atom._NET_NUMBER_OF_DESKTOPS, XA_CARDINAL);
} }
int server_get_current_desktop () int server_get_current_desktop ()
{ {
return get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL); return get_property32(server.root_win, server.atom._NET_CURRENT_DESKTOP, XA_CARDINAL);
} }
Window window_get_active () Window window_get_active ()
{ {
return get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW); return get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW);
} }
int window_is_active (Window win) int window_is_active (Window win)
{ {
return (win == get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW)); return (win == get_property32(server.root_win, server.atom._NET_ACTIVE_WINDOW, XA_WINDOW));
} }
int get_icon_count (long *data, int num) int get_icon_count (long *data, int num)
{ {
int count, pos, w, h; int count, pos, w, h;
count = 0; count = 0;
pos = 0; pos = 0;
while (pos < num) { while (pos < num) {
w = data[pos++]; w = data[pos++];
h = data[pos++]; h = data[pos++];
pos += w * h; pos += w * h;
if (pos > num || w * h == 0) break; if (pos > num || w * h == 0) break;
count++; count++;
} }
return count; return count;
} }
long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size) long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size)
{ {
int width[icon_count], height[icon_count], pos, i, w, h; int width[icon_count], height[icon_count], pos, i, w, h;
long *icon_data[icon_count]; long *icon_data[icon_count];
/* List up icons */ /* List up icons */
pos = 0; pos = 0;
i = icon_count; i = icon_count;
while (i--) { while (i--) {
w = data[pos++]; w = data[pos++];
h = data[pos++]; h = data[pos++];
if (pos + w * h > num) break; if (pos + w * h > num) break;
width[i] = w; width[i] = w;
height[i] = h; height[i] = h;
icon_data[i] = &data[pos]; icon_data[i] = &data[pos];
pos += w * h; pos += w * h;
} }
/* Try to find exact size */ /* Try to find exact size */
int icon_num = -1; int icon_num = -1;
for (i = 0; i < icon_count; i++) { for (i = 0; i < icon_count; i++) {
if (width[i] == best_icon_size) { if (width[i] == best_icon_size) {
icon_num = i; icon_num = i;
break; break;
} }
} }
/* Take the biggest or whatever */ /* Take the biggest or whatever */
if (icon_num < 0) { if (icon_num < 0) {
int highest = 0; int highest = 0;
for (i = 0; i < icon_count; i++) { for (i = 0; i < icon_count; i++) {
if (width[i] > highest) { if (width[i] > highest) {
icon_num = i; icon_num = i;
highest = width[i]; highest = width[i];
} }
} }
} }
*iw = width[icon_num]; *iw = width[icon_num];
*ih = height[icon_num]; *ih = height[icon_num];
return icon_data[icon_num]; return icon_data[icon_num];
} }
void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len) void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len)
{ {
PangoRectangle rect_ink, rect; PangoRectangle rect_ink, rect;
Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth); Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth);
cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height); cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height);
cairo_t *c = cairo_create (cs); cairo_t *c = cairo_create (cs);
PangoLayout *layout = pango_cairo_create_layout (c); PangoLayout *layout = pango_cairo_create_layout (c);
pango_layout_set_font_description (layout, font); pango_layout_set_font_description (layout, font);
pango_layout_set_text (layout, text, len); pango_layout_set_text (layout, text, len);
pango_layout_get_pixel_extents(layout, &rect_ink, &rect); pango_layout_get_pixel_extents(layout, &rect_ink, &rect);
*height_ink = rect_ink.height; *height_ink = rect_ink.height;
*height = rect.height; *height = rect.height;
//printf("dimension : %d - %d\n", rect_ink.height, rect.height); //printf("dimension : %d - %d\n", rect_ink.height, rect.height);
g_object_unref (layout); g_object_unref (layout);
cairo_destroy (c); cairo_destroy (c);
cairo_surface_destroy (cs); cairo_surface_destroy (cs);
XFreePixmap (server.dsp, pmap); XFreePixmap (server.dsp, pmap);
} }

View file

@ -21,6 +21,7 @@ int window_is_iconified (Window win);
int window_is_urgent (Window win); int window_is_urgent (Window win);
int window_is_hidden (Window win); int window_is_hidden (Window win);
int window_is_active (Window win); int window_is_active (Window win);
int window_is_skip_taskbar (Window win);
int get_icon_count (long *data, int num); int get_icon_count (long *data, int num);
long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size); long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int best_icon_size);
void window_maximize_restore (Window win); void window_maximize_restore (Window win);