rendering engine : _on_change_layout() called when pos/size changed
git-svn-id: http://tint2.googlecode.com/svn/trunk@565 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
4d2def5633
commit
60590bf1ac
7 changed files with 79 additions and 54 deletions
|
@ -61,6 +61,7 @@ void default_systray()
|
||||||
systray.alpha = 100;
|
systray.alpha = 100;
|
||||||
systray.sort = 3;
|
systray.sort = 3;
|
||||||
systray.area._draw_foreground = draw_systray;
|
systray.area._draw_foreground = draw_systray;
|
||||||
|
systray.area._on_change_layout = on_change_systray;
|
||||||
systray.area.size_mode = SIZE_BY_CONTENT;
|
systray.area.size_mode = SIZE_BY_CONTENT;
|
||||||
systray.area._resize = resize_systray;
|
systray.area._resize = resize_systray;
|
||||||
}
|
}
|
||||||
|
@ -114,52 +115,6 @@ void init_systray_panel(void *p)
|
||||||
|
|
||||||
void draw_systray(void *obj, cairo_t *c)
|
void draw_systray(void *obj, cairo_t *c)
|
||||||
{
|
{
|
||||||
// here, sysbar's position is defined. so we can calculate position of tray icon.
|
|
||||||
Systraybar *sysbar = obj;
|
|
||||||
Panel *panel = sysbar->area.panel;
|
|
||||||
int i, posx, posy;
|
|
||||||
int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +sysbar->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 = sysbar->icon_size;
|
|
||||||
traywin->height = sysbar->icon_size;
|
|
||||||
if (panel_horizontal) {
|
|
||||||
if (i % sysbar->icons_per_column)
|
|
||||||
posy += sysbar->icon_size + sysbar->area.paddingx;
|
|
||||||
else {
|
|
||||||
posy = start;
|
|
||||||
posx += (sysbar->icon_size + systray.area.paddingx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (i % sysbar->icons_per_row)
|
|
||||||
posx += sysbar->icon_size + systray.area.paddingx;
|
|
||||||
else {
|
|
||||||
posx = start;
|
|
||||||
posy += (sysbar->icon_size + systray.area.paddingx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// position and size the icon window
|
|
||||||
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size);
|
|
||||||
XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
||||||
if (render_background) XFreePixmap(server.dsp, render_background);
|
if (render_background) XFreePixmap(server.dsp, render_background);
|
||||||
render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
|
render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
|
||||||
|
@ -210,6 +165,56 @@ int resize_systray(void *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void on_change_systray (void *obj)
|
||||||
|
{
|
||||||
|
// here, sysbar's position is defined. so we can calculate position of tray icon.
|
||||||
|
Systraybar *sysbar = obj;
|
||||||
|
Panel *panel = sysbar->area.panel;
|
||||||
|
int i, posx, posy;
|
||||||
|
int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +sysbar->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 = sysbar->icon_size;
|
||||||
|
traywin->height = sysbar->icon_size;
|
||||||
|
if (panel_horizontal) {
|
||||||
|
if (i % sysbar->icons_per_column)
|
||||||
|
posy += sysbar->icon_size + sysbar->area.paddingx;
|
||||||
|
else {
|
||||||
|
posy = start;
|
||||||
|
posx += (sysbar->icon_size + systray.area.paddingx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (i % sysbar->icons_per_row)
|
||||||
|
posx += sysbar->icon_size + systray.area.paddingx;
|
||||||
|
else {
|
||||||
|
posx = start;
|
||||||
|
posy += (sysbar->icon_size + systray.area.paddingx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// position and size the icon window
|
||||||
|
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size);
|
||||||
|
XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ***********************************************
|
// ***********************************************
|
||||||
// systray protocol
|
// systray protocol
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ void init_systray_panel(void *p);
|
||||||
|
|
||||||
void draw_systray(void *obj, cairo_t *c);
|
void draw_systray(void *obj, cairo_t *c);
|
||||||
int resize_systray(void *obj);
|
int resize_systray(void *obj);
|
||||||
|
void on_change_systray(void *obj);
|
||||||
|
|
||||||
|
|
||||||
// systray protocol
|
// systray protocol
|
||||||
|
|
|
@ -344,9 +344,6 @@ void draw_task (void *obj, cairo_t *c)
|
||||||
Panel *panel = (Panel*)tsk->area.panel;
|
Panel *panel = (Panel*)tsk->area.panel;
|
||||||
//printf("draw_task %d %d\n", tsk->area.posx, tsk->area.posy);
|
//printf("draw_task %d %d\n", tsk->area.posx, tsk->area.posy);
|
||||||
|
|
||||||
long value[] = { panel->posx+tsk->area.posx, panel->posy+tsk->area.posy, tsk->area.width, tsk->area.height };
|
|
||||||
XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4);
|
|
||||||
|
|
||||||
if (panel->g_task.text) {
|
if (panel->g_task.text) {
|
||||||
/* Layout */
|
/* Layout */
|
||||||
layout = pango_cairo_create_layout (c);
|
layout = pango_cairo_create_layout (c);
|
||||||
|
@ -389,6 +386,19 @@ void draw_task (void *obj, cairo_t *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void on_change_task (void *obj)
|
||||||
|
{
|
||||||
|
Task *tsk = obj;
|
||||||
|
Panel *panel = (Panel*)tsk->area.panel;
|
||||||
|
|
||||||
|
long value[] = { panel->posx+tsk->area.posx, panel->posy+tsk->area.posy, tsk->area.width, tsk->area.height };
|
||||||
|
XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4);
|
||||||
|
|
||||||
|
// reset Pixmap when position/size changed
|
||||||
|
set_task_redraw(tsk);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Task *next_task(Task *tsk)
|
Task *next_task(Task *tsk)
|
||||||
{
|
{
|
||||||
if (tsk == 0)
|
if (tsk == 0)
|
||||||
|
|
|
@ -69,6 +69,7 @@ Task *add_task (Window win);
|
||||||
void remove_task (Task *tsk);
|
void remove_task (Task *tsk);
|
||||||
|
|
||||||
void draw_task (void *obj, cairo_t *c);
|
void draw_task (void *obj, cairo_t *c);
|
||||||
|
void on_change_task (void *obj);
|
||||||
|
|
||||||
void get_icon (Task *tsk);
|
void get_icon (Task *tsk);
|
||||||
void get_title(Task *tsk);
|
void get_title(Task *tsk);
|
||||||
|
|
|
@ -125,6 +125,7 @@ void init_taskbar_panel(void *p)
|
||||||
// task
|
// task
|
||||||
panel->g_task.area.size_mode = SIZE_BY_LAYOUT;
|
panel->g_task.area.size_mode = SIZE_BY_LAYOUT;
|
||||||
panel->g_task.area._draw_foreground = draw_task;
|
panel->g_task.area._draw_foreground = draw_task;
|
||||||
|
panel->g_task.area._on_change_layout = on_change_task;
|
||||||
panel->g_task.area.redraw = 1;
|
panel->g_task.area.redraw = 1;
|
||||||
panel->g_task.area.on_screen = 1;
|
panel->g_task.area.on_screen = 1;
|
||||||
if ((panel->g_task.config_asb_mask & (1<<TASK_NORMAL)) == 0) {
|
if ((panel->g_task.config_asb_mask & (1<<TASK_NORMAL)) == 0) {
|
||||||
|
@ -296,7 +297,6 @@ int resize_taskbar(void *obj)
|
||||||
for (l = taskbar->area.list; l ; l = l->next) {
|
for (l = taskbar->area.list; l ; l = l->next) {
|
||||||
tsk = l->data;
|
tsk = l->data;
|
||||||
if (!tsk->area.on_screen) continue;
|
if (!tsk->area.on_screen) continue;
|
||||||
//set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id)
|
|
||||||
tsk->area.width = pixel_width;
|
tsk->area.width = pixel_width;
|
||||||
|
|
||||||
if (modulo_width) {
|
if (modulo_width) {
|
||||||
|
@ -331,7 +331,6 @@ int resize_taskbar(void *obj)
|
||||||
for (l = taskbar->area.list; l ; l = l->next) {
|
for (l = taskbar->area.list; l ; l = l->next) {
|
||||||
tsk = l->data;
|
tsk = l->data;
|
||||||
if (!tsk->area.on_screen) continue;
|
if (!tsk->area.on_screen) continue;
|
||||||
//set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id)
|
|
||||||
tsk->area.height = pixel_height;
|
tsk->area.height = pixel_height;
|
||||||
|
|
||||||
if (modulo_height) {
|
if (modulo_height) {
|
||||||
|
|
|
@ -116,6 +116,7 @@ void size_by_content (Area *a)
|
||||||
size_by_content(l->data);
|
size_by_content(l->data);
|
||||||
|
|
||||||
// calculate area's size
|
// calculate area's size
|
||||||
|
a->on_changed = 0;
|
||||||
if (a->resize && a->size_mode == SIZE_BY_CONTENT) {
|
if (a->resize && a->size_mode == SIZE_BY_CONTENT) {
|
||||||
a->resize = 0;
|
a->resize = 0;
|
||||||
|
|
||||||
|
@ -123,8 +124,9 @@ void size_by_content (Area *a)
|
||||||
if (a->_resize(a)) {
|
if (a->_resize(a)) {
|
||||||
// 'size' changed => 'resize = 1' on the parent and redraw object
|
// 'size' changed => 'resize = 1' on the parent and redraw object
|
||||||
((Area*)a->parent)->resize = 1;
|
((Area*)a->parent)->resize = 1;
|
||||||
|
a->on_changed = 1;
|
||||||
|
a->redraw = 1;
|
||||||
}
|
}
|
||||||
a->redraw = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,6 +146,7 @@ void size_by_layout (Area *a, int pos, int level)
|
||||||
if (a->_resize) {
|
if (a->_resize) {
|
||||||
if (a->_resize(a)) {
|
if (a->_resize(a)) {
|
||||||
// if 'size' changed then 'resize = 1' on childs with SIZE_BY_LAYOUT
|
// if 'size' changed then 'resize = 1' on childs with SIZE_BY_LAYOUT
|
||||||
|
a->on_changed = 1;
|
||||||
for (l = a->list; l ; l = l->next) {
|
for (l = a->list; l ; l = l->next) {
|
||||||
if (((Area*)l->data)->size_mode == SIZE_BY_LAYOUT)
|
if (((Area*)l->data)->size_mode == SIZE_BY_LAYOUT)
|
||||||
((Area*)l->data)->resize = 1;
|
((Area*)l->data)->resize = 1;
|
||||||
|
@ -164,6 +167,7 @@ void size_by_layout (Area *a, int pos, int level)
|
||||||
if (pos != child->posx) {
|
if (pos != child->posx) {
|
||||||
// pos changed => redraw
|
// pos changed => redraw
|
||||||
child->posx = pos;
|
child->posx = pos;
|
||||||
|
child->on_changed = 1;
|
||||||
child->redraw = 1;
|
child->redraw = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,6 +175,7 @@ void size_by_layout (Area *a, int pos, int level)
|
||||||
if (pos != child->posy) {
|
if (pos != child->posy) {
|
||||||
// pos changed => redraw
|
// pos changed => redraw
|
||||||
child->posy = pos;
|
child->posy = pos;
|
||||||
|
child->on_changed = 1;
|
||||||
child->redraw = 1;
|
child->redraw = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,6 +188,9 @@ void size_by_layout (Area *a, int pos, int level)
|
||||||
else
|
else
|
||||||
pos += child->height + a->paddingx;
|
pos += child->height + a->paddingx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a->on_changed && a->_on_change_layout)
|
||||||
|
a->_on_change_layout (a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,9 @@ typedef struct {
|
||||||
// update area's content and update size (width/heith).
|
// update area's content and update size (width/heith).
|
||||||
// return '1' if size changed, '0' otherwise.
|
// return '1' if size changed, '0' otherwise.
|
||||||
int (*_resize)(void *obj);
|
int (*_resize)(void *obj);
|
||||||
void (*_add_child)(void *obj);
|
// after pos/size changed, the rendering engine will call _on_change_layout(Area*)
|
||||||
int (*_remove_child)(void *obj);
|
int on_changed;
|
||||||
|
void (*_on_change_layout)(void *obj);
|
||||||
const char* (*_get_tooltip_text)(void *obj);
|
const char* (*_get_tooltip_text)(void *obj);
|
||||||
} Area;
|
} Area;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue