statusbar: support systray kick out

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-08-05 17:23:37 +02:00
parent 189157843a
commit e7871ff8f8
2 changed files with 142 additions and 128 deletions

View File

@ -33,39 +33,41 @@ DO_LUA_NEW(extern, statusbar_t, statusbar, "statusbar", statusbar_ref)
DO_LUA_GC(statusbar_t, statusbar, "statusbar", statusbar_unref) DO_LUA_GC(statusbar_t, statusbar, "statusbar", statusbar_unref)
DO_LUA_EQ(statusbar_t, statusbar, "statusbar") DO_LUA_EQ(statusbar_t, statusbar, "statusbar")
/** Draw a statusbar. /** Kick out systray windows.
* \param statusbar The statusbar to draw. * \param phys_screen Physical screen number.
*/ */
static void static void
statusbar_draw(statusbar_t *statusbar) statusbar_systray_kickout(int phys_screen)
{
xembed_window_t *em;
uint32_t config_win_vals_off[2] = { -512, -512 };
for(em = globalconf.embedded; em; em = em->next)
if(em->phys_screen == phys_screen)
xcb_configure_window(globalconf.connection, em->win,
XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y,
config_win_vals_off);
}
static void
statusbar_systray_refresh(statusbar_t *statusbar)
{ {
widget_node_t *systray; widget_node_t *systray;
statusbar->need_update = false; if(statusbar->screen == SCREEN_UNDEF)
return;
/* found the systray if any */
for(systray = statusbar->widgets; systray; systray = systray->next) for(systray = statusbar->widgets; systray; systray = systray->next)
if(systray->widget->type == systray_new) if(systray->widget->type == systray_new)
break;
if(statusbar->position)
{
widget_render(statusbar->widgets, statusbar->ctx, statusbar->sw->gc,
statusbar->sw->pixmap,
statusbar->screen, statusbar->position,
statusbar->sw->geometry.x, statusbar->sw->geometry.y,
statusbar, AWESOME_TYPE_STATUSBAR);
simplewindow_refresh_pixmap(statusbar->sw);
}
if(systray)
{ {
uint32_t config_win_vals[4]; uint32_t config_win_vals[4];
uint32_t config_win_vals_off[4] = { -1, -1, 1, 1 }; uint32_t config_win_vals_off[2] = { -512, -512 };
xembed_window_t *em; xembed_window_t *em;
position_t pos; position_t pos;
if(statusbar->position && systray->widget->isvisible) if(statusbar->position
&& systray->widget->isvisible)
{ {
pos = statusbar->position; pos = statusbar->position;
/* width */ /* width */
@ -101,9 +103,7 @@ statusbar_draw(statusbar_t *statusbar)
else else
xcb_configure_window(globalconf.connection, em->win, xcb_configure_window(globalconf.connection, em->win,
XCB_CONFIG_WINDOW_X XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_Y,
| XCB_CONFIG_WINDOW_WIDTH
| XCB_CONFIG_WINDOW_HEIGHT,
config_win_vals_off); config_win_vals_off);
} }
client_stack(); client_stack();
@ -129,9 +129,7 @@ statusbar_draw(statusbar_t *statusbar)
else else
xcb_configure_window(globalconf.connection, em->win, xcb_configure_window(globalconf.connection, em->win,
XCB_CONFIG_WINDOW_X XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_Y,
| XCB_CONFIG_WINDOW_WIDTH
| XCB_CONFIG_WINDOW_HEIGHT,
config_win_vals_off); config_win_vals_off);
} }
client_stack(); client_stack();
@ -159,27 +157,40 @@ statusbar_draw(statusbar_t *statusbar)
else else
xcb_configure_window(globalconf.connection, em->win, xcb_configure_window(globalconf.connection, em->win,
XCB_CONFIG_WINDOW_X XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_Y,
| XCB_CONFIG_WINDOW_WIDTH
| XCB_CONFIG_WINDOW_HEIGHT,
config_win_vals_off); config_win_vals_off);
} }
client_stack(); client_stack();
break; break;
default: default:
for(em = globalconf.embedded; em; em = em->next) statusbar_systray_kickout(statusbar->phys_screen);
if(em->phys_screen == statusbar->phys_screen)
xcb_configure_window(globalconf.connection, em->win,
XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y
| XCB_CONFIG_WINDOW_WIDTH
| XCB_CONFIG_WINDOW_HEIGHT,
config_win_vals_off);
break; break;
} }
break;
} }
} }
/** Draw a statusbar.
* \param statusbar The statusbar to draw.
*/
static void
statusbar_draw(statusbar_t *statusbar)
{
statusbar->need_update = false;
if(statusbar->position)
{
widget_render(statusbar->widgets, statusbar->ctx, statusbar->sw->gc,
statusbar->sw->pixmap,
statusbar->screen, statusbar->position,
statusbar->sw->geometry.x, statusbar->sw->geometry.y,
statusbar, AWESOME_TYPE_STATUSBAR);
simplewindow_refresh_pixmap(statusbar->sw);
}
statusbar_systray_refresh(statusbar);
}
/** Statusbar refresh function. /** Statusbar refresh function.
*/ */
void void
@ -609,6 +620,8 @@ statusbar_remove(statusbar_t *statusbar)
{ {
position_t p; position_t p;
statusbar_systray_kickout(statusbar->phys_screen);
/* save position */ /* save position */
p = statusbar->position; p = statusbar->position;
statusbar->position = Off; statusbar->position = Off;

View File

@ -56,6 +56,7 @@ systray_draw(draw_context_t *ctx,
for(em = globalconf.embedded; em; em = em->next) for(em = globalconf.embedded; em; em = em->next)
if(em->phys_screen == sb->phys_screen) if(em->phys_screen == sb->phys_screen)
i++; i++;
/** \todo use clas hints */
w->area.width = MIN(i * ctx->height, ctx->width - used); w->area.width = MIN(i * ctx->height, ctx->width - used);
} }
else else