+2009-06-21
+- play with some code for vertical panel
+
2009-06-20
- remove flickering on systray
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
-AC_INIT([tint2], [0.7_beta2], [http://code.google.com/p/tint2/issues])
+AC_INIT([tint2], [0.7_beta3], [http://code.google.com/p/tint2/issues])
LT_INIT
AM_INIT_AUTOMAKE
battery->area.panel = panel;
battery->area._draw_foreground = draw_battery;
battery->area._resize = resize_battery;
+ battery->area.resize = 1;
+ battery->area.redraw = 1;
if((fp = fopen(path_energy_now, "r")) == NULL) {
fprintf(stderr, "ERROR: battery applet can't open energy_now\n");
}
fclose(fp);
- battery->area.posy = panel->area.pix.border.width + panel->area.paddingy;
- battery->area.height = panel->area.height - (2 * battery->area.posy);
- battery->area.resize = 1;
- battery->area.redraw = 1;
-
update_battery(&battery_state);
snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes);
get_text_size(bat1_font_desc, &bat_percentage_height_ink, &bat_percentage_height, panel->area.height, buf_bat_percentage, strlen(buf_bat_percentage));
- battery->bat1_posy = (battery->area.height - bat_percentage_height) / 2;
-
get_text_size(bat2_font_desc, &bat_time_height_ink, &bat_time_height, panel->area.height, buf_bat_time, strlen(buf_bat_time));
+ if (panel_horizontal) {
+ // panel horizonal => fixed height and posy
+ battery->area.posy = panel->area.pix.border.width + panel->area.paddingy;
+ battery->area.height = panel->area.height - (2 * battery->area.posy);
+ }
+ else {
+ // panel vertical => fixed width, height, posy and posx
+ battery->area.posy = panel->clock.area.posy + panel->clock.area.height + panel->area.paddingx;
+ battery->area.height = (2 * battery->area.paddingxlr) + (bat_time_height + bat_percentage_height);
+ battery->area.posx = panel->area.pix.border.width + panel->area.paddingy;
+ battery->area.width = panel->area.width - (2 * panel->area.pix.border.width) - (2 * panel->area.paddingy);
+ }
+
+ battery->bat1_posy = (battery->area.height - bat_percentage_height) / 2;
battery->bat1_posy -= ((bat_time_height_ink + 2) / 2);
battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2;
}
new_percentage = (energy_now*100)/energy_full;
if(battery_low_status != 0 && battery_low_status == new_percentage && battery_state.percentage > new_percentage) {
- printf("battery low, executing: %s\n", battery_low_cmd);
- if(battery_low_cmd) system(battery_low_cmd);
+ //printf("battery low, executing: %s\n", battery_low_cmd);
+ if (battery_low_cmd) system(battery_low_cmd);
}
battery_state.percentage = new_percentage;
snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes);
+ // vertical panel doen't adjust width
+ if (!panel_horizontal) return;
cairo_surface_t *cs;
cairo_t *c;
panel = &panel1[i];
clock = &panel->clock;
+ if (!clock->area.on_screen) continue;
+
clock->area.parent = panel;
clock->area.panel = panel;
clock->area._draw_foreground = draw_clock;
clock->area._resize = resize_clock;
-
- if (!clock->area.on_screen) continue;
-
- clock->area.posy = panel->area.pix.border.width + panel->area.paddingy;
- clock->area.height = panel->area.height - (2 * clock->area.posy);
clock->area.resize = 1;
clock->area.redraw = 1;
strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
- if (time2_format)
+ get_text_size(time1_font_desc, &time_height_ink, &time_height, panel->area.height, buf_time, strlen(buf_time));
+ if (time2_format) {
strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
+ get_text_size(time2_font_desc, &date_height_ink, &date_height, panel->area.height, buf_date, strlen(buf_date));
+ }
- get_text_size(time1_font_desc, &time_height_ink, &time_height, panel->area.height, buf_time, strlen(buf_time));
- clock->time1_posy = (clock->area.height - time_height) / 2;
+ if (panel_horizontal) {
+ // panel horizonal => fixed height and posy
+ clock->area.posy = panel->area.pix.border.width + panel->area.paddingy;
+ clock->area.height = panel->area.height - (2 * clock->area.posy);
+ }
+ else {
+ // panel vertical => fixed width, height, posy and posx
+ clock->area.posy = panel->area.pix.border.width + panel->area.paddingxlr;
+ clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height);
+ clock->area.posx = panel->area.pix.border.width + panel->area.paddingy;
+ clock->area.width = panel->area.width - (2 * panel->area.pix.border.width) - (2 * panel->area.paddingy);
+ }
+ clock->time1_posy = (clock->area.height - time_height) / 2;
if (time2_format) {
+ strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
get_text_size(time2_font_desc, &date_height_ink, &date_height, panel->area.height, buf_date, strlen(buf_date));
clock->time1_posy -= ((date_height_ink + 2) / 2);
Clock *clock = obj;
PangoLayout *layout;
- //printf(" draw_clock : %s en (%d, %d)\n", buf_time, clock->area.posx, clock->area.width);
layout = pango_cairo_create_layout (c);
// draw layout
PangoLayout *layout;
int time_width, date_width, new_width;
- time_width = date_width = 0;
clock->area.redraw = 1;
-
+ time_width = date_width = 0;
strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec));
if (time2_format)
strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec));
+ // vertical panel doen't adjust width
+ if (!panel_horizontal) return;
+
//printf(" resize_clock\n");
cairo_surface_t *cs;
cairo_t *c;
layout = pango_cairo_create_layout (c);
// check width
- pango_layout_set_font_description (layout, time1_font_desc);
- pango_layout_set_indent(layout, 0);
- pango_layout_set_text (layout, buf_time, strlen(buf_time));
- pango_layout_get_pixel_size (layout, &time_width, NULL);
- if (time2_format) {
- pango_layout_set_font_description (layout, time2_font_desc);
- pango_layout_set_indent(layout, 0);
- pango_layout_set_text (layout, buf_date, strlen(buf_date));
- pango_layout_get_pixel_size (layout, &date_width, NULL);
- }
+ pango_layout_set_font_description (layout, time1_font_desc);
+ pango_layout_set_indent(layout, 0);
+ pango_layout_set_text (layout, buf_time, strlen(buf_time));
+ pango_layout_get_pixel_size (layout, &time_width, NULL);
+ if (time2_format) {
+ pango_layout_set_font_description (layout, time2_font_desc);
+ pango_layout_set_indent(layout, 0);
+ pango_layout_set_text (layout, buf_date, strlen(buf_date));
+ pango_layout_get_pixel_size (layout, &date_width, NULL);
+ }
- if (time_width > date_width) new_width = time_width;
- else new_width = date_width;
- new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width);
+ if (time_width > date_width) new_width = time_width;
+ else new_width = date_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)) {
Panel *panel = ((Area*)obj)->panel;
// resize clock
// we try to limit the number of resize
// printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
- 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.width = new_width + 1;
+ clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width;
// resize other objects on panel
panel->area.resize = 1;
else if (strcmp (key, "panel_position") == 0) {
extract_values(value, &value1, &value2, &value3);
if (strcmp (value1, "top") == 0) panel_position = TOP;
- else panel_position = BOTTOM;
+ else {
+ if (strcmp (value1, "bottom") == 0) panel_position = BOTTOM;
+ else panel_position = CENTER;
+ }
- if (!value2) panel_position = CENTER;
+ if (!value2) panel_position |= CENTER;
else {
if (strcmp (value2, "left") == 0) panel_position |= LEFT;
else {
else panel_position |= CENTER;
}
}
+ if (!value3) panel_horizontal = 1;
+ else {
+ if (strcmp (value3, "vertical") == 0) panel_horizontal = 0;
+ else panel_horizontal = 1;
+ }
}
else if (strcmp (key, "font_shadow") == 0)
panel_config->g_task.font_shadow = atoi (value);
int panel_mode;
int wm_menu;
int panel_position;
+int panel_horizontal;
int panel_refresh;
Task *task_active;
if (systray.area.on_screen && i == 0)
p->area.list = g_slist_append(p->area.list, &systray);
- // detect panel size
- if (p->pourcentx)
- p->area.width = (float)server.monitor[p->monitor].width * p->initial_width / 100;
- else
- p->area.width = p->initial_width;
- if (p->pourcenty)
- p->area.height = (float)server.monitor[p->monitor].height * p->initial_height / 100;
- else
- p->area.height = p->initial_height;
-
// full width mode
- if (!p->area.width)
- p->area.width = server.monitor[p->monitor].width;
+ if (!p->initial_width) {
+ p->initial_width = 100;
+ p->pourcentx = 1;
+ }
- if (p->area.pix.border.rounded > p->area.height/2)
- p->area.pix.border.rounded = p->area.height/2;
+ // detect panel size
+ if (panel_horizontal) {
+ if (p->pourcentx)
+ p->area.width = (float)server.monitor[p->monitor].width * p->initial_width / 100;
+ else
+ p->area.width = p->initial_width;
+ if (p->pourcenty)
+ p->area.height = (float)server.monitor[p->monitor].height * p->initial_height / 100;
+ else
+ p->area.height = p->initial_height;
+ if (p->area.pix.border.rounded > p->area.height/2)
+ p->area.pix.border.rounded = p->area.height/2;
+ }
+ else {
+ if (p->pourcentx)
+ p->area.height = (float)server.monitor[p->monitor].height * p->initial_width / 100;
+ else
+ p->area.height = p->initial_width;
+ if (p->pourcenty)
+ p->area.width = (float)server.monitor[p->monitor].width * p->initial_height / 100;
+ else
+ p->area.width = p->initial_height;
+ if (p->area.pix.border.rounded > p->area.width/2)
+ p->area.pix.border.rounded = p->area.width/2;
+ }
/* panel position determined here */
if (panel_position & LEFT) {
p->posx = server.monitor[p->monitor].x + server.monitor[p->monitor].width - p->area.width - p->marginx;
}
else {
- p->posx = server.monitor[p->monitor].x + ((server.monitor[p->monitor].width - p->area.width) / 2);
+ if (panel_horizontal)
+ p->posx = server.monitor[p->monitor].x + ((server.monitor[p->monitor].width - p->area.width) / 2);
+ else
+ p->posx = server.monitor[p->monitor].x + p->marginx;
}
}
if (panel_position & TOP) {
p->posy = server.monitor[p->monitor].y + p->marginy;
}
else {
- p->posy = server.monitor[p->monitor].y + server.monitor[p->monitor].height - p->area.height - p->marginy;
+ if (panel_position & BOTTOM) {
+ p->posy = server.monitor[p->monitor].y + server.monitor[p->monitor].height - p->area.height - p->marginy;
+ }
+ else {
+ p->posy = server.monitor[p->monitor].y + ((server.monitor[p->monitor].height - p->area.height) / 2);
+ }
}
- //printf("posx %d, posy %d, width %d, height %d\n", p->posx, p->posy, p->area.width, p->area.height);
+ // printf("panel : posx %d, posy %d, width %d, height %d\n", p->posx, p->posy, p->area.width, p->area.height);
// Catch some events
XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 };
// Reserved space
long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- if (panel_position & TOP) {
- struts[2] = p->area.height + p->marginy;
- struts[8] = p->posx;
- // p->area.width - 1 allowed full screen on monitor 2
- struts[9] = p->posx + p->area.width - 1;
- }
- else {
- struts[3] = p->area.height + p->marginy;
- struts[10] = p->posx;
- // p->area.width - 1 allowed full screen on monitor 2
- struts[11] = p->posx + p->area.width - 1;
- }
+ if (panel_horizontal) {
+ if (panel_position & TOP) {
+ struts[2] = p->area.height + p->marginy;
+ struts[8] = p->posx;
+ // p->area.width - 1 allowed full screen on monitor 2
+ struts[9] = p->posx + p->area.width - 1;
+ }
+ else {
+ struts[3] = p->area.height + p->marginy;
+ struts[10] = p->posx;
+ // p->area.width - 1 allowed full screen on monitor 2
+ struts[11] = p->posx + p->area.width - 1;
+ }
+ }
+ else {
+ if (panel_position & LEFT) {
+ struts[0] = p->area.width + p->marginx;
+ struts[4] = p->posy;
+ // p->area.width - 1 allowed full screen on monitor 2
+ struts[5] = p->posy + p->area.height - 1;
+ }
+ else {
+ struts[1] = p->area.width + p->marginx;
+ struts[6] = p->posy;
+ // p->area.width - 1 allowed full screen on monitor 2
+ struts[7] = p->posy + p->area.height - 1;
+ }
+ }
// 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_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12);
//panel position
enum { LEFT=0x01, RIGHT=0x02, CENTER=0X04, TOP=0X08, BOTTOM=0x10 };
extern int panel_position;
+extern int panel_horizontal;
extern int panel_refresh;