#include "window.h"
#include "server.h"
-#include "area.h"
#include "panel.h"
-#include "taskbar.h"
#include "battery.h"
-#include "clock.h"
#include "timer.h"
#include "common.h"
if (battery_state.percentage >= percentage_hide) {
if (panel1[i].battery.area.on_screen == 1) {
panel1[i].battery.area.on_screen = 0;
- // force resize on panel
- panel1[i].area.resize = 1;
panel_refresh = 1;
}
continue;
else {
if (panel1[i].battery.area.on_screen == 0) {
panel1[i].battery.area.on_screen = 1;
- // force resize on panel
- panel1[i].area.resize = 1;
panel_refresh = 1;
}
}
}
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.bg->border.width + panel->area.paddingy;
battery->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
}
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 ret;
+ if (!panel_horizontal) {
+// 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);
+ return ret;
+ }
cairo_surface_t *cs;
cairo_t *c;
if(percentage_width > time_width) new_width = percentage_width;
else new_width = time_width;
- new_width += (2*battery->area.paddingxlr) + (2*battery->area.bg->border.width);
-
int old_width = battery->area.width;
-
- Panel *panel = ((Area*)obj)->panel;
+
+ new_width += (2*battery->area.paddingxlr) + (2*battery->area.bg->border.width);
battery->area.width = new_width + 1;
- battery->area.posx = panel->area.width - battery->area.width - panel->area.paddingxlr - panel->area.bg->border.width;
- if (panel->clock.area.on_screen)
- battery->area.posx -= (panel->clock.area.width + panel->area.paddingx);
-
+
if (new_width > old_width || new_width < (old_width-6)) {
// refresh and resize other objects on panel
// we try to limit the number of refresh
#include "window.h"
#include "server.h"
-#include "area.h"
#include "panel.h"
-#include "taskbar.h"
#include "clock.h"
#include "timer.h"
#include "common.h"
}
else {
// panel vertical => fixed width, height, posy and posx
- clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
- clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height);
+// clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
+// clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height);
clock->area.posx = panel->area.bg->border.width + panel->area.paddingy;
clock->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
}
else new_width = date_width;
new_width += (2*clock->area.paddingxlr) + (2*clock->area.bg->border.width);
- Panel *panel = ((Area*)obj)->panel;
if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
// resize clock
// we try to limit the number of resize
ret = 1;
panel_refresh = 1;
}
- clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.bg->border.width;
-
g_object_unref (layout);
cairo_destroy (c);
launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * launcher->area.paddingx);
}
- launcher->area.posx = panel->area.bg->border.width + panel->area.paddingxlr;
+// launcher->area.posx = panel->area.bg->border.width + panel->area.paddingxlr;
launcher->area.posy = panel->area.bg->border.width;
}
else {
}
launcher->area.posx = panel->area.bg->border.width;
- launcher->area.posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - launcher->area.height;
+// launcher->area.posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - launcher->area.height;
}
int i, posx, posy;
posy += panel->taskbar[i].area.height + panel->area.paddingx;
}
}
- return 1;
+ return 0;
}
void draw_systray(void *obj, cairo_t *c)
{
+ // TODO : position and size the icon window when position of systray is known
+ Systraybar *sysbar = obj;
+ Panel *panel = sysbar->area.panel;
+ int i, posx, posy, marging=3, icons_per_column=1, icons_per_row=1;
+ int icon_size = 24;
+ int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +marging/2;
+ if (panel_horizontal) {
+ posy = start;
+ posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
+ }
+ else {
+ posx = start;
+ posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
+ }
+
+ TrayWindow *traywin;
+ GSList *l;
+ for (i=1, l = systray.list_icons; l ; i++, l = l->next) {
+ traywin = (TrayWindow*)l->data;
+ if (traywin->hide) continue;
+
+ traywin->y = posy;
+ traywin->x = posx;
+ traywin->width = icon_size;
+ traywin->height = icon_size;
+ if (panel_horizontal) {
+ if (i % icons_per_column)
+ posy += icon_size + sysbar->area.paddingx;
+ else {
+ posy = start;
+ posx += (icon_size + systray.area.paddingx);
+ }
+ }
+ else {
+ if (i % icons_per_row)
+ posx += icon_size + systray.area.paddingx;
+ else {
+ posx = start;
+ posy += (icon_size + systray.area.paddingx);
+ }
+ }
+
+ // position and size the icon window
+ XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
+ XResizeWindow(server.dsp, traywin->tray_id, icon_size, icon_size);
+ }
+
if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
if (render_background) XFreePixmap(server.dsp, render_background);
render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
int resize_systray(void *obj)
{
Systraybar *sysbar = obj;
- Panel *panel = sysbar->area.panel;
- TrayWindow *traywin;
GSList *l;
int count, icon_size;
int icons_per_column=1, icons_per_row=1, marging=0;
icons_per_row = count / icons_per_column + (count%icons_per_column != 0);
systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * systray.area.paddingx);
}
-
- systray.area.posx = panel->area.width - panel->area.bg->border.width - panel->area.paddingxlr - systray.area.width;
- if (panel->clock.area.on_screen)
- systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
-#ifdef ENABLE_BATTERY
- if (panel->battery.area.on_screen)
- systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
-#endif
}
else {
if (!count) systray.area.height = 0;
icons_per_column = count / icons_per_row+ (count%icons_per_row != 0);
systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * systray.area.paddingx);
}
-
- systray.area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
- if (panel->clock.area.on_screen)
- systray.area.posy += (panel->clock.area.height + panel->area.paddingx);
-#ifdef ENABLE_BATTERY
- if (panel->battery.area.on_screen)
- systray.area.posy += (panel->battery.area.height + panel->area.paddingx);
-#endif
- }
-
- int i, posx, posy;
- int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +marging/2;
- if (panel_horizontal) {
- posy = start;
- posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
- }
- else {
- posx = start;
- posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
- }
-
- for (i=1, l = systray.list_icons; l ; i++, l = l->next) {
- traywin = (TrayWindow*)l->data;
- if (traywin->hide) continue;
-
- traywin->y = posy;
- traywin->x = posx;
- traywin->width = icon_size;
- traywin->height = icon_size;
- if (panel_horizontal) {
- if (i % icons_per_column)
- posy += icon_size + sysbar->area.paddingx;
- else {
- posy = start;
- posx += (icon_size + systray.area.paddingx);
- }
- }
- else {
- if (i % icons_per_row)
- posx += icon_size + systray.area.paddingx;
- else {
- posx = start;
- posy += (icon_size + systray.area.paddingx);
- }
- }
-
- // position and size the icon window
- XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
- XResizeWindow(server.dsp, traywin->tray_id, icon_size, icon_size);
}
return 1;
}
if (panel_horizontal) {
int pixel_width, modulo_width=0;
- int x, taskbar_width;
+ int taskbar_width;
// new task width for 'desktop'
task_count = g_slist_length(taskbar->area.list);
taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx;
// change pos_x and width for all tasks
- x = taskbar->area.posx + border_width + taskbar->area.paddingxlr;
for (l = taskbar->area.list; l ; l = l->next) {
tsk = l->data;
if (!tsk->area.on_screen) continue;
- tsk->area.posx = x;
set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id)
tsk->area.width = pixel_width;
- long value[] = { panel->posx+x, panel->posy, pixel_width, panel->area.height };
- XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4);
+// TODO : move later (when posx is known)
+// long value[] = { panel->posx+x, panel->posy, pixel_width, panel->area.height };
+// XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4);
if (modulo_width) {
tsk->area.width++;
modulo_width--;
}
-
- x += tsk->area.width + panel->g_taskbar.area.paddingx;
}
}
else {
int pixel_height, modulo_height=0;
- int y, taskbar_height;
+ int taskbar_height;
// new task width for 'desktop'
task_count = g_slist_length(taskbar->area.list);
taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx;
// change pos_y and height for all tasks
- y = taskbar->area.posy + border_width + taskbar->area.paddingxlr;
for (l = taskbar->area.list; l ; l = l->next) {
tsk = l->data;
if (!tsk->area.on_screen) continue;
- tsk->area.posy = y;
set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id)
tsk->area.height = pixel_height;
- long value[] = { panel->posx, panel->posy+y, panel->area.width, pixel_height };
- XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4);
+// TODO : move later (when posy is known)
+// long value[] = { panel->posx, panel->posy+y, panel->area.width, pixel_height };
+// XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4);
if (modulo_height) {
tsk->area.height++;
modulo_height--;
}
-
- y += tsk->area.height + panel->g_taskbar.area.paddingx;
}
}
return 0;
}
+
panel->area.width = server.monitor[0].width;
panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
- size_by_content(&panel->area);
- size_by_layout(&panel->area);
- refresh(&panel->area);
+ rendering(panel);
Imlib_Image img = NULL;
imlib_context_set_drawable(panel->temp_pmap);
else {
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);
- size_by_content(&panel->area);
- size_by_layout(&panel->area);
- refresh(&panel->area);
+ rendering(panel);
XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
}
}
*
************************************************************/
+void rendering(void *obj)
+{
+ Panel *panel = (Panel*)obj;
+
+ size_by_content(&panel->area);
+ size_by_layout(&panel->area, 0, 0);
+
+ refresh(&panel->area);
+}
+
void size_by_content (Area *a)
{
if (a->_resize) {
if (a->_resize(a)) {
- // 'size' changed then 'resize = 1' on the parent
+ // 'size' changed => 'resize = 1' on the parent and redraw object
((Area*)a->parent)->resize = 1;
+ a->redraw = 1;
}
- a->redraw = 1;
}
}
}
-void size_by_layout (Area *a)
+void size_by_layout (Area *a, int pos, int level)
{
// don't resize hiden objects
if (!a->on_screen) return;
}
}
- for (l = a->list; l ; l = l->next)
- size_by_layout(l->data);
+ // update position of childs
+ pos += a->paddingxlr + a->bg->border.width;
+ int i=0;
+ for (l = a->list; l ; l = l->next) {
+ Area *child = ((Area*)l->data);
+ i++;
+
+ if (pos != child->posx) {
+ // pos changed => redraw
+ child->posx = pos;
+ child->redraw = 1;
+ }
+ //printf("level %d, object %d, pos %d\n", level, i, pos);
+
+ size_by_layout(child, pos, level+1);
+
+ pos += child->width + a->paddingx;
+ }
}
} Area;
-
+void rendering(void *panel);
void size_by_content (Area *a);
-void size_by_layout (Area *a);
+void size_by_layout (Area *a, int pos, int level);
// draw background and foreground
void refresh (Area *a);