aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathias <mathias>2005-04-30 13:10:15 (GMT)
committermathias <mathias>2005-04-30 13:10:15 (GMT)
commit55f62bc5cc64f0b8c41f7db343ecd871c250ae8f (patch)
treeaf1c69b23d3634f31eb5cf73b7a79042f6feab34
parent815e0cb09a4b4a704a30f72ab305f94515592f60 (diff)
downloadfluxbox-55f62bc5cc64f0b8c41f7db343ecd871c250ae8f.zip
fluxbox-55f62bc5cc64f0b8c41f7db343ecd871c250ae8f.tar.bz2
Fix #1086673 ArrangeWindows on shaded aterms causes inconsistency (Mathias)
we now place shaded Windows above the normal windows. ArrangeWindows touches only windows on the current (xinerama)-head. there are still some open issues with this, look at my notes at the function itself.
-rw-r--r--ChangeLog5
-rw-r--r--src/WorkspaceCmd.cc84
2 files changed, 70 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 1187fac..7a3a19c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.13 2Changes for 0.9.13
3*05/04/30:
4 * Fix #1086673 ArrangeWindows on shaded aterms causes inconsistency (Mathias)
5 we now place shaded Windows above the normal windows. ArrangeWindows
6 touches only windows on the current (xinerama)-head.
7 src/WorkspaceCmd.cc
3*05/04/29: 8*05/04/29:
4 * Added new IconbarModes: (Mathias) 9 * Added new IconbarModes: (Mathias)
5 NoIcons - all but iconified windows 10 NoIcons - all but iconified windows
diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc
index 4cfcbb8..3e6d128 100644
--- a/src/WorkspaceCmd.cc
+++ b/src/WorkspaceCmd.cc
@@ -131,52 +131,98 @@ void JumpToWorkspaceCmd::execute() {
131} 131}
132 132
133 133
134/**
135 try to arrange the windows on the current workspace in a 'clever' way.
136 we take the shaded-windows and put them ontop of the workspace and put the
137 normal windows underneath it.
138 */
134void ArrangeWindowsCmd::execute() { 139void ArrangeWindowsCmd::execute() {
135 BScreen *screen = Fluxbox::instance()->mouseScreen(); 140 BScreen *screen = Fluxbox::instance()->mouseScreen();
136 if (screen == 0) 141 if (screen == 0)
137 return; 142 return;
138 143
139 Workspace *space = screen->currentWorkspace(); 144 Workspace *space = screen->currentWorkspace();
140 const unsigned int win_count = space->windowList().size(); 145 unsigned int win_count = space->windowList().size();
141 146
142 if (win_count == 0) 147 if (win_count == 0)
143 return; 148 return;
144 149
150 // TODO: choice between
151 // - arrange using all windows on all heads
152 // - arrange for each head
153 // - only on current head
145 const int head = screen->getCurrHead(); 154 const int head = screen->getCurrHead();
155 Workspace::Windows::iterator win;
156
157 Workspace::Windows normal_windows;
158 Workspace::Windows shaded_windows;
159 for(win = space->windowList().begin(); win != space->windowList().end(); win++) {
160 int winhead = screen->getHead((*win)->fbWindow());
161 if (winhead == head || winhead == 0) {
162 if (!(*win)->isShaded())
163 normal_windows.push_back(*win);
164 else
165 shaded_windows.push_back(*win);
166 }
167 }
168
169 // to arrange only shaded windows is a bit pointless imho (mathias)
170 if (normal_windows.size() == 0)
171 return;
172
173 win_count = normal_windows.size();
174
146 const unsigned int max_width = screen->maxRight(head) - screen->maxLeft(head); 175 const unsigned int max_width = screen->maxRight(head) - screen->maxLeft(head);
147 const unsigned int max_heigth = screen->maxBottom(head) - screen->maxTop(head); 176 unsigned int max_height = screen->maxBottom(head) - screen->maxTop(head);
148 177
149 // try to get the same number of rows as columns. 178 // try to get the same number of rows as columns.
150 unsigned int rows = int(sqrt((float)win_count)); // truncate to lower 179 unsigned int rows = int(sqrt((float)win_count)); // truncate to lower
151 unsigned int cols = int(0.99 + float(win_count) / float(rows)); 180 unsigned int cols = int(0.99 + float(win_count) / float(rows));
152 if (max_width<max_heigth) { // rotate 181 if (max_width<max_height) { // rotate
153 unsigned int tmp; 182 std::swap(cols, rows);
154 tmp = rows;
155 rows = cols;
156 cols = tmp;
157 } 183 }
158 const unsigned int cal_width = max_width/cols; // calculated width ratio (width of every window)
159 const unsigned int cal_heigth = max_heigth/rows; // heigth ratio (heigth of every window)
160 184
161 // Resizes and sets windows positions in columns and rows.
162 unsigned int x_offs = screen->maxLeft(head); // window position offset in x 185 unsigned int x_offs = screen->maxLeft(head); // window position offset in x
163 unsigned int y_offs = screen->maxTop(head); // window position offset in y 186 unsigned int y_offs = screen->maxTop(head); // window position offset in y
164 unsigned int window = 0; // current window 187 unsigned int window = 0; // current window
165 Workspace::Windows &windowlist = space->windowList(); 188 const unsigned int cal_width = max_width/cols; // calculated width ratio (width of every window)
166 for (unsigned int i = 0; i < rows; ++i) { 189 unsigned int i;
190 unsigned int j;
191
192 // place the shaded windows
193 // TODO: until i resolve the shadedwindow->moveResize() issue to place
194 // them in the same columns as the normal windows i just place the shaded
195 // windows unchanged ontop of the current head
196 for (i = 0, win = shaded_windows.begin(); win != shaded_windows.end(); win++, i++) {
197 if (i & 1)
198 (*win)->move(x_offs, y_offs);
199 else
200 (*win)->move(screen->maxRight(head) - (*win)->frame().width(), y_offs);
201
202 y_offs += (*win)->frame().height();
203 }
204
205 // TODO: what if the number of shaded windows is really big and we end up
206 // with really little space left for the normal windows? how to handle
207 // this?
208 if (!shaded_windows.empty())
209 max_height -= i * (*shaded_windows.begin())->frame().height();
210
211 const unsigned int cal_height = max_height/rows; // height ratio (height of every window)
212 // Resizes and sets windows positions in columns and rows.
213 for (i = 0; i < rows; ++i) {
167 x_offs = screen->maxLeft(head); 214 x_offs = screen->maxLeft(head);
168 for (unsigned int j = 0; j < cols && window < win_count; ++j, ++window) { 215 for (j = 0; j < cols && window < win_count; ++j, ++window) {
169 if (window==(win_count-1)) { 216 if (window!=(win_count-1)) {
170 // the last window gets everything that is left. 217 normal_windows[window]->moveResize(x_offs, y_offs, cal_width, cal_height);
171 windowlist[window]->moveResize(x_offs, y_offs, max_width-x_offs, cal_heigth); 218 } else { // the last window gets everything that is left.
172 } else { 219 normal_windows[window]->moveResize(x_offs, y_offs, screen->maxRight(head)-x_offs, cal_height);
173 windowlist[window]->moveResize(x_offs, y_offs, cal_width, cal_heigth);
174 } 220 }
175 // next x offset 221 // next x offset
176 x_offs += cal_width; 222 x_offs += cal_width;
177 } 223 }
178 // next y offset 224 // next y offset
179 y_offs += cal_heigth; 225 y_offs += cal_height;
180 } 226 }
181} 227}
182 228