Add existing windows on workspace to the space. Restore the layout of prevSpace if present.
(prevSpace)
| 2048 | layout of prevSpace if present. |
| 2049 | */ |
| 2050 | addAll(prevSpace) { |
| 2051 | // On gnome-shell-restarts the windows are moved into the viewport, but |
| 2052 | // they're moved minimally and the stacking is not changed, so the tiling |
| 2053 | // order is preserved (sans full-width windows..) |
| 2054 | let xz_comparator = windows => { |
| 2055 | // Seems to be the only documented way to get stacking order? |
| 2056 | // Could also rely on the MetaWindowActor's index in it's parent |
| 2057 | // children array: That seem to correspond to clutters z-index (note: |
| 2058 | // z_position is something else) |
| 2059 | let z_sorted = display.sort_windows_by_stacking(windows); |
| 2060 | let xkey = mw => { |
| 2061 | let frame = mw.get_frame_rect(); |
| 2062 | if (frame.x <= 0) |
| 2063 | return 0; |
| 2064 | if (frame.x + frame.width === this.width) { |
| 2065 | return this.width; |
| 2066 | } |
| 2067 | return frame.x; |
| 2068 | }; |
| 2069 | // xorder: a|b c|d |
| 2070 | // zorder: a d b c |
| 2071 | return (a, b) => { |
| 2072 | let ax = xkey(a); |
| 2073 | let bx = xkey(b); |
| 2074 | // Yes, this is not efficient |
| 2075 | let az = z_sorted.indexOf(a); |
| 2076 | let bz = z_sorted.indexOf(b); |
| 2077 | let xcmp = ax - bx; |
| 2078 | if (xcmp !== 0) |
| 2079 | return xcmp; |
| 2080 | |
| 2081 | if (ax === 0) { |
| 2082 | // Left side: lower stacking first |
| 2083 | return az - bz; |
| 2084 | } else { |
| 2085 | // Right side: higher stacking first |
| 2086 | return bz - az; |
| 2087 | } |
| 2088 | }; |
| 2089 | }; |
| 2090 | |
| 2091 | if (prevSpace) { |
| 2092 | for (let i = 0; i < prevSpace.length; i++) { |
| 2093 | let column = prevSpace[i]; |
| 2094 | for (let j = 0; j < column.length; j++) { |
| 2095 | let metaWindow = column[j]; |
| 2096 | // Prune removed windows |
| 2097 | if (metaWindow.get_compositor_private()) { |
| 2098 | this.addWindow(metaWindow, i, j); |
| 2099 | } else { |
| 2100 | // eslint-disable-next-line max-statements-per-line |
| 2101 | column.splice(j, 1); j--; |
| 2102 | } |
| 2103 | } |
| 2104 | if (column.length === 0) { |
| 2105 | // eslint-disable-next-line max-statements-per-line |
| 2106 | prevSpace.splice(i, 1); i--; |
| 2107 | } |
no test coverage detected