]> Dogcows Code - chaz/openbox/blobdiff - openbox/focus_cycle_popup.c
round up rather than down for figuring out the width of the popup, so it will fit...
[chaz/openbox] / openbox / focus_cycle_popup.c
index b171e9420538572ad260ecf7383d89f35492a1fd..92f0c0c99fd2070dc79a4f1a889c435ce95eb419 100644 (file)
@@ -234,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;
@@ -263,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? */
@@ -292,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);
@@ -317,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)
@@ -385,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;
This page took 0.021355 seconds and 4 git commands to generate.