summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2013-12-15 11:46:25 +0300
committerNick Schermer <nick@xfce.org>2014-02-23 21:07:08 +0100
commit3658e525ac0952a1f98ac7bad59d6a5c4aa8e22c (patch)
tree8118dc4bd885248f683c3e40ccff24078f1c7aef
parent3cd369280609cc0e1b3d4ea0be164897a323595d (diff)
downloadxfwm4-3658e525ac0952a1f98ac7bad59d6a5c4aa8e22c.tar.gz
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@elfenbeinturm.at>
-rw-r--r--src/tabwin.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/tabwin.c b/src/tabwin.c
index c5d8846dc..0c6e5f1d9 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);