From b4b08fd9263fec907863b90c649c8168202c8295 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 12 Apr 2009 21:08:59 +0200 Subject: [PATCH] Split wibox_position_update() up Floating wiboxes are much easier to handle, so they deserve their own function. This function, wibox_position_update_floating() does exactly the same things wibox_position_update() did before. No behaviour change involved. Signed-off-by: Uli Schlachter --- wibox.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/wibox.c b/wibox.c index 835ad37d..c2f321eb 100644 --- a/wibox.c +++ b/wibox.c @@ -315,12 +315,24 @@ wibox_systray_refresh(wibox_t *wibox) } } -/** Update the wibox position. It deletes every wibox resources and - * create them back. - * \param wibox The wibox. - */ -void -wibox_position_update(wibox_t *wibox) +/* Only called by wibox_position_update() */ +static void +wibox_position_update_floating(wibox_t *wibox) +{ + area_t wingeom = wibox->sw.geometry; + + /* We only make sure the wibox is at least 1x1 pixel big. */ + wingeom.width = MAX(1, wibox->sw.geometry.width); + wingeom.height = MAX(1, wibox->sw.geometry.height); + + if(wingeom.width != wibox->sw.geometry.width + || wingeom.height != wibox->sw.geometry.height) + wibox_resize(wibox, wingeom.width, wingeom.height); +} + +/* Only called by wibox_position_update() */ +static void +wibox_position_update_non_floating(wibox_t *wibox) { area_t area, wingeom = wibox->sw.geometry; bool ignore = false; @@ -486,6 +498,19 @@ wibox_position_update(wibox_t *wibox) wibox_move(wibox, wingeom.x, wingeom.y); } +/** Update the wibox position. It deletes every wibox resources and + * create them back. + * \param wibox The wibox. + */ +void +wibox_position_update(wibox_t *wibox) +{ + if(wibox->position == Floating) + wibox_position_update_floating(wibox); + else + wibox_position_update_non_floating(wibox); +} + /** Get a wibox by its window. * \param w The window id. * \return A wibox if found, NULL otherwise.