[Xfce4-commits] [xfce/xfwm4] 01/02: Fix tabwin cols/rows computation
noreply at xfce.org
noreply at xfce.org
Mon Jan 26 21:51:54 CET 2015
This is an automated email from the git hooks/post-receive script.
olivier pushed a commit to branch master
in repository xfce/xfwm4.
commit 120c4746a24df5d74c9ecfaa76b44e3ace5ed47b
Author: Olivier Fourdan <fourdan at xfce.org>
Date: Mon Jan 26 20:52:29 2015 +0100
Fix tabwin cols/rows computation
Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
configure.ac.in | 10 ++++++----
src/tabwin.c | 20 +++++++++++++++-----
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/configure.ac.in b/configure.ac.in
index aaf122a..6223afa 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -67,6 +67,11 @@ AC_CHECK_HEADERS([stropts.h])
AC_CHECK_FUNCS([daemon setsid])
AC_CHECK_FUNCS(opendir)
+dnl Math lib is required (if available)
+MATH_LIBS=""
+AC_CHECK_LIB(m, ceil, MATH_LIBS="-lm")
+AC_SUBST([MATH_LIBS])
+
dnl Check for i18n support
XDT_I18N([@LINGUAS@])
@@ -184,7 +189,7 @@ dnl Xcomposite and related extensions
dnl
compositor="no"
ENABLE_COMPOSITOR=""
-MATH_LIBS=""
+
AC_ARG_ENABLE([compositor],
AC_HELP_STRING([--enable-compositor], [enable compositor in xfwm4 (default)])
AC_HELP_STRING([--disable-compositor], [disable compositor in xfwm4]),
@@ -198,12 +203,9 @@ if test x"$enable_compositor" = x"yes"; then
ENABLE_COMPOSITOR="--enable-compositor"
AC_DEFINE([HAVE_COMPOSITOR], [1], [Define to enable compositor])
compositor="yes"
- dnl Math lib is required for compositor internals
- MATH_LIBS=" -lm"
fi
fi
fi
-AC_SUBST([MATH_LIBS])
AC_SUBST(ENABLE_COMPOSITOR)
dnl
diff --git a/src/tabwin.c b/src/tabwin.c
index 9d9fb1d..d3beaca 100644
--- a/src/tabwin.c
+++ b/src/tabwin.c
@@ -44,6 +44,10 @@
#define WIN_BORDER_WIDTH 1
#endif
+#ifndef WIN_MAX_RATIO
+#define WIN_MAX_RATIO 0.80
+#endif
+
#ifndef WIN_ALPHA
#define WIN_ALPHA 0.85
#endif
@@ -56,6 +60,7 @@
#define WIN_BORDER_RADIUS 10
#endif
+#include <math.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
@@ -727,11 +732,14 @@ computeTabwinData (ScreenInfo *screen_info, TabwinWidget *tabwin_widget)
"icon-size", &tabwin->icon_size, NULL);
}
size_request = tabwin->icon_size + tabwin->label_height + 2 * WIN_ICON_BORDER;
- tabwin->grid_cols = (tabwin->monitor_width / (size_request)) * 0.75;
- tabwin->grid_rows = tabwin->client_count / tabwin->grid_cols;
+ tabwin->grid_cols = (int) (floor ((double) tabwin->monitor_width * WIN_MAX_RATIO /
+ (double) size_request));
+ tabwin->grid_rows = (int) (ceil ((double) tabwin->client_count /
+ (double) tabwin->grid_cols));
/* If we run out of space, halve the icon size to make more room. */
- while ((size_request) * tabwin->grid_rows > tabwin->monitor_height - tabwin->label_height)
+ while ((size_request) * tabwin->grid_rows + tabwin->label_height >
+ ((double) tabwin->monitor_height) * WIN_MAX_RATIO)
{
/* Disable preview otherwise it'd be too slow */
if (preview)
@@ -749,8 +757,10 @@ computeTabwinData (ScreenInfo *screen_info, TabwinWidget *tabwin_widget)
size_request = tabwin->icon_size + tabwin->label_height + 2 * WIN_ICON_BORDER;
/* Recalculate with new icon size */
- tabwin->grid_cols = (tabwin->monitor_width / (size_request)) * 0.75;
- tabwin->grid_rows = tabwin->client_count / tabwin->grid_cols + 1;
+ tabwin->grid_cols = (int) (floor ((double) tabwin->monitor_width * WIN_MAX_RATIO /
+ (double) size_request));
+ tabwin->grid_rows = (int) (ceil ((double) tabwin->client_count /
+ (double) tabwin->grid_cols));
/* Shrinking the icon too much makes it hard to see */
if (tabwin->icon_size < 8)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list