Clean interface of statusbar_update_position.

This commit is contained in:
Aldo Cortesi 2007-12-19 15:40:03 +11:00 committed by Julien Danjou
parent 10200477c8
commit 51379e065b
3 changed files with 28 additions and 18 deletions

View File

@ -208,7 +208,7 @@ handle_event_configurenotify(XEvent * e)
globalconf.screens[screen].statusbar->width,
globalconf.screens[screen].statusbar->height);
statusbar_update_position(e->xany.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
statusbar_update_position(screen);
arrange(screen);
}
}

View File

@ -172,37 +172,49 @@ statusbar_init(int screen)
widget_calculate_alignments(statusbar->widgets);
statusbar_update_position(globalconf.display,
statusbar,
&globalconf.screens[screen].padding);
statusbar_update_position(screen);
XMapRaised(globalconf.display, statusbar->window);
}
void
statusbar_update_position(Display *disp, Statusbar *statusbar, Padding *padding)
statusbar_update_position(int screen)
{
XEvent ev;
ScreenInfo *si = get_screen_info(statusbar->screen, NULL, padding);
Statusbar *statusbar = globalconf.screens[screen].statusbar;
ScreenInfo *si = get_screen_info(statusbar->screen,
NULL,
&globalconf.screens[screen].padding);
XMapRaised(disp, statusbar->window);
XMapRaised(globalconf.display, statusbar->window);
switch (statusbar->position)
{
default:
XMoveWindow(disp, statusbar->window, si[statusbar->screen].x_org, si[statusbar->screen].y_org);
XMoveWindow(globalconf.display,
statusbar->window,
si[statusbar->screen].x_org,
si[statusbar->screen].y_org);
break;
case BarRight:
XMoveWindow(disp, statusbar->window, si[statusbar->screen].x_org + (si[statusbar->screen].width - statusbar->height), si[statusbar->screen].y_org);
XMoveWindow(globalconf.display,
statusbar->window,
si[statusbar->screen].x_org +
(si[statusbar->screen].width -
statusbar->height),
si[statusbar->screen].y_org);
break;
case BarBot:
XMoveWindow(disp, statusbar->window, si[statusbar->screen].x_org, si[statusbar->screen].height - statusbar->height);
XMoveWindow(globalconf.display,
statusbar->window,
si[statusbar->screen].x_org,
si[statusbar->screen].height - statusbar->height);
break;
case BarOff:
XUnmapWindow(disp, statusbar->window);
XUnmapWindow(globalconf.display, statusbar->window);
break;
}
p_delete(&si);
XSync(disp, False);
while(XCheckMaskEvent(disp, EnterWindowMask, &ev));
XSync(globalconf.display, False);
while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &ev));
}
int
@ -231,7 +243,7 @@ uicb_statusbar_toggle(int screen, char *arg __attribute__ ((unused)))
globalconf.screens[screen].statusbar->position = (globalconf.screens[screen].statusbar->dposition == BarOff) ? BarTop : globalconf.screens[screen].statusbar->dposition;
else
globalconf.screens[screen].statusbar->position = BarOff;
statusbar_update_position(globalconf.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
statusbar_update_position(screen);
arrange(screen);
}
@ -246,9 +258,7 @@ uicb_statusbar_set_position(int screen, char *arg)
globalconf.screens[screen].statusbar->dposition =
globalconf.screens[screen].statusbar->position =
statusbar_get_position_from_str(arg);
statusbar_update_position(globalconf.display,
globalconf.screens[screen].statusbar,
&globalconf.screens[screen].padding);
statusbar_update_position(screen);
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -27,7 +27,7 @@
void statusbar_init(int);
void statusbar_draw(int);
int statusbar_get_position_from_str(const char *);
void statusbar_update_position(Display *, Statusbar*, Padding *);
void statusbar_update_position(int);
UICB_PROTO(uicb_statusbar_toggle);
UICB_PROTO(uicb_statusbar_set_position);