X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Ffocus_cycle_popup.c;h=92f0c0c99fd2070dc79a4f1a889c435ce95eb419;hb=2ed4552f8ba79d4f2ca78e61b1c74af8478be988;hp=4d6ccdcad1fbb6490dbfd3f7394b2b63c729d049;hpb=50ba7e2d4c1f8df9b18739bac384f64e7717da24;p=chaz%2Fopenbox diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 4d6ccdca..92f0c0c9 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -71,9 +71,13 @@ struct _ObFocusCyclePopup static ObFocusCyclePopup popup; static gchar *popup_get_name (ObClient *c); -static void popup_setup (ObFocusCyclePopup *p,gboolean all_desktops, - gboolean dock_windows, gboolean desktop_windows); -static void popup_render (ObFocusCyclePopup *p, const ObClient *c); +static void popup_setup (ObFocusCyclePopup *p, + gboolean iconic_windows, + gboolean all_desktops, + gboolean dock_windows, + gboolean desktop_windows); +static void popup_render (ObFocusCyclePopup *p, + const ObClient *c); static Window create_window(Window parent, guint bwidth, gulong mask, XSetWindowAttributes *attr) @@ -142,7 +146,8 @@ void focus_cycle_popup_shutdown(gboolean reconfig) RrAppearanceFree(popup.a_bg); } -static void popup_setup(ObFocusCyclePopup *p,gboolean all_desktops, +static void popup_setup(ObFocusCyclePopup *p, + gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows) { gint maxwidth, n; @@ -161,6 +166,7 @@ static void popup_setup(ObFocusCyclePopup *p,gboolean all_desktops, ObClient *ft = it->data; if (focus_cycle_target_valid(ft, + iconic_windows, all_desktops, dock_windows, desktop_windows)) @@ -228,6 +234,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) gint icon_rows; gint textx, texty, textw, texth; gint rgbax, rgbay, rgbaw, rgbah; + gint icons_center_x; gint innerw, innerh; gint i; GList *it; @@ -257,7 +264,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* how many icons will fit in that row? make the width fit that */ w -= l + r; - icons_per_row = w / ICON_SIZE; + icons_per_row = (w + ICON_SIZE - 1) / ICON_SIZE; w = icons_per_row * ICON_SIZE + l + r; /* how many rows do we need? */ @@ -286,6 +293,12 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) rgbaw = w - ml - mr; rgbah = h - mt - mb; + /* center the icons if there is less than one row */ + if (icon_rows == 1) + icons_center_x = (w - p->n_targets * ICON_SIZE) / 2; + else + icons_center_x; + if (!p->mapped) { /* position the background but don't draw it*/ XMoveResizeWindow(ob_display, p->bg, x, y, w, h); @@ -311,7 +324,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) if (target->client == c) { /* save the target */ newtarget = target; - newtargetx = l + (col * ICON_SIZE); + newtargetx = icons_center_x + l + (col * ICON_SIZE); newtargety = t + (row * ICON_SIZE); if (!p->mapped) @@ -379,7 +392,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) gint innerx, innery; /* find the dimensions of the icon inside it */ - innerx = l + (col * ICON_SIZE); + innerx = icons_center_x + l + (col * ICON_SIZE); innerx += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN; innery = t + (row * ICON_SIZE); innery += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN; @@ -410,7 +423,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) p->last_target = newtarget; } -void focus_cycle_popup_show(ObClient *c, +void focus_cycle_popup_show(ObClient *c, gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows) { @@ -418,7 +431,8 @@ void focus_cycle_popup_show(ObClient *c, /* do this stuff only when the dialog is first showing */ if (!popup.mapped) - popup_setup(&popup, all_desktops, dock_windows, desktop_windows); + popup_setup(&popup, iconic_windows, all_desktops, + dock_windows, desktop_windows); g_assert(popup.targets != NULL); popup_render(&popup, c);