Skip to content

Commit 0922a38

Browse files
committed
/ ‘desktop_shell/window_spread.js’
1 parent af8e1e4 commit 0922a38

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

desktop_shell/window_spread.js

+23-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,30 @@ function spread_windows() {
33
}
44

55
function number_of_rows() {
6-
// Calculate the total width
7-
var base_width = 0
8-
var base_height = 1
6+
var rows = 1
7+
while (!try_fit_windows(rows))
8+
rows++;
9+
10+
return rows
11+
}
12+
13+
function try_fit_windows(max_rows) {
14+
int row = 0
15+
int row_width = 0
16+
int row_height = available_height/rows
917

1018
for (window in windows) {
11-
var width = window.width * base_height/window.height
19+
var width = window.width * row_height/window.height
20+
if (row_width + width > available_width) {
21+
row++
22+
row_width = width
23+
} else {
24+
row_width += width
25+
}
26+
27+
if (row >= max_rows)
28+
return false
1229
}
30+
31+
return true
1332
}

0 commit comments

Comments
 (0)