summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/WorkspaceCmd.cc40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc
index 143f90b..c70d8d2 100644
--- a/src/WorkspaceCmd.cc
+++ b/src/WorkspaceCmd.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: WorkspaceCmd.cc,v 1.4 2003/09/06 14:05:32 fluxgen Exp $ 23// $Id: WorkspaceCmd.cc,v 1.5 2003/09/20 10:46:01 grubert Exp $
24 24
25#include "WorkspaceCmd.hh" 25#include "WorkspaceCmd.hh"
26 26
@@ -120,28 +120,19 @@ void ArrangeWindowsCmd::execute() {
120 if (win_count == 0) 120 if (win_count == 0)
121 return; 121 return;
122 122
123 const unsigned int max_weigth = screen->width(); 123 const unsigned int max_width = screen->width();
124 const unsigned int max_heigth = screen->height(); 124 const unsigned int max_heigth = screen->height();
125 125
126 126 // try to get the same number of rows as columns.
127 unsigned int cols = 1; // columns 127 unsigned int rows = int(sqrt(win_count)); // truncate to lower
128 unsigned int rows = 1; // rows 128 unsigned int cols = int(0.99 + float(win_count) / float(rows));
129 129 if (max_width<max_heigth) { // rotate
130 // Calculates the "best" width / heigth ratio ( basically it 130 unsigned int tmp;
131 // chooses the two divisors of win_count which are closest to 131 tmp = rows;
132 // each other) 132 rows = cols;
133 int rt = win_count; // holds last t value 133 cols = tmp;
134 for (unsigned int i = 1; i <= win_count; ++i) { 134 }
135 int t = (win_count / i) - i; 135 const unsigned int cal_width = max_width/cols; // calculated width ratio (width of every window)
136
137 if (t < rt && t >= 0 && (win_count % i) == 0) {
138 rt = t;
139 rows = i;
140 cols = win_count / i;
141 }
142 }
143
144 const unsigned int cal_width = max_weigth/cols; // calculated width ratio (width of every window)
145 const unsigned int cal_heigth = max_heigth/rows; // heigth ratio (heigth of every window) 136 const unsigned int cal_heigth = max_heigth/rows; // heigth ratio (heigth of every window)
146 137
147 // Resizes and sets windows positions in columns and rows. 138 // Resizes and sets windows positions in columns and rows.
@@ -152,7 +143,12 @@ void ArrangeWindowsCmd::execute() {
152 for (unsigned int i = 0; i < rows; ++i) { 143 for (unsigned int i = 0; i < rows; ++i) {
153 x_offs = 0; 144 x_offs = 0;
154 for (unsigned int j = 0; j < cols && window < win_count; ++j, ++window) { 145 for (unsigned int j = 0; j < cols && window < win_count; ++j, ++window) {
155 windowlist[window]->moveResize(x_offs, y_offs, cal_width, cal_heigth); 146 if (window==(win_count-1)) {
147 // the last window gets everything that is left.
148 windowlist[window]->moveResize(x_offs, y_offs, max_width-x_offs, cal_heigth);
149 } else {
150 windowlist[window]->moveResize(x_offs, y_offs, cal_width, cal_heigth);
151 }
156 // next x offset 152 // next x offset
157 x_offs += cal_width; 153 x_offs += cal_width;
158 } 154 }