summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2013-12-15 11:46:25 +0300
committerSimon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>2013-12-15 10:53:31 +0100
commitfa67b6a7247884cf9b0f53c65ac23b55c20260f0 (patch)
treee744bc756ae01bb96f969676ec5644b8e3771b8f
parentedf7ad46c0686b483ebeb5bc206c83778580747e (diff)
downloadxfwm4-ochosi/tabwin.tar.gz
Shrink the app icon when out of spaceochosi/tabwin
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);