[Xfce4-commits] <xfwm4:ochosi/tabwin> Shrink the app icon when out of space

Simon Steinbeiss noreply at xfce.org
Sun Dec 15 10:54:01 CET 2013


Updating branch refs/heads/ochosi/tabwin
         to fa67b6a7247884cf9b0f53c65ac23b55c20260f0 (commit)
       from edf7ad46c0686b483ebeb5bc206c83778580747e (commit)

commit fa67b6a7247884cf9b0f53c65ac23b55c20260f0
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Dec 15 11:46:25 2013 +0300

    Shrink the app icon when out of space
    
    In the standard icon grid and there's a lot of windows to display,
    shrink the icon size until all the windows will fit. This does it
    by halving the current icon size. If the icon size goes below 8,
    it will stop there so the icons are still present.
    
    Signed-off-by: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>

 src/tabwin.c |   30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/tabwin.c b/src/tabwin.c
index c5d8846..0c6e5f1 100644
--- a/src/tabwin.c
+++ b/src/tabwin.c
@@ -453,10 +453,32 @@ createWindowlist (ScreenInfo *screen_info, TabwinWidget *tbw)
     gtk_widget_style_get (GTK_WIDGET (tbw), "icon-size", &icon_size, NULL);
     tbw->widgets = NULL;
 
+    /* We need to account for changes to the font size in the user's
+     * appearance theme and gtkrc settings */
+    layout = gtk_widget_create_pango_layout (GTK_WIDGET (tbw), "");
+    pango_layout_get_pixel_size (layout, NULL, &app_label_height);
+    g_object_unref (layout);
+
     if (screen_info->params->cycle_tabwin_mode == STANDARD_ICON_GRID)
     {
-        tbw->grid_cols = (monitor_width / (icon_size + 2 * WIN_ICON_BORDER)) * 0.75;
+        tbw->grid_cols = (monitor_width / (icon_size+app_label_height+10)) * 0.75;
         tbw->grid_rows = screen_info->client_count / tbw->grid_cols + 1;
+
+        /* If we run out of space, halve the icon size to make more room. */
+        while ((icon_size + app_label_height + 10) * tbw->grid_rows > monitor_height - app_label_height)
+        {
+            icon_size = icon_size / 2;
+            /* recalculate with new icon size */
+            tbw->grid_cols = (monitor_width / (icon_size+app_label_height+10)) * 0.75;
+            tbw->grid_rows = screen_info->client_count / tbw->grid_cols + 1;
+
+            /* Shrinking the icon too much makes it hard to see */
+            if (icon_size < 8)
+            {
+                icon_size = 8;
+                break;
+            }
+        }
     }
     else
     {
@@ -481,12 +503,6 @@ createWindowlist (ScreenInfo *screen_info, TabwinWidget *tbw)
         g_signal_connect (window_button, "leave-notify-event", G_CALLBACK (cb_window_button_leave), tbw);
         gtk_widget_add_events (window_button, GDK_ENTER_NOTIFY_MASK);
 
-        /* We need to account for changes to the font size in the user's
-         * appearance theme and gtkrc settings */
-        layout = gtk_widget_create_pango_layout (GTK_WIDGET (tbw), "");
-        pango_layout_get_pixel_size (layout, NULL, &app_label_height);
-        g_object_unref (layout);
-
         if (screen_info->params->cycle_tabwin_mode == STANDARD_ICON_GRID)
         {
             gtk_widget_set_size_request (GTK_WIDGET (window_button), icon_size+app_label_height+10, icon_size+app_label_height+10);


More information about the Xfce4-commits mailing list