MCPcopy
hub / github.com/paperwm/PaperWM / switchGlobal

Method switchGlobal

tiling.js:1190–1262  ·  view source on GitHub ↗
(direction)

Source from the content-addressed store, hash-verified

1188 switchGlobalUp() { this.switchGlobal(Meta.MotionDirection.UP); }
1189 switchGlobalDown() { this.switchGlobal(Meta.MotionDirection.DOWN); }
1190 switchGlobal(direction) {
1191 let space = this;
1192 let index = space.selectedIndex();
1193 if (index === -1) {
1194 return;
1195 }
1196 let row = space[index].indexOf(space.selectedWindow);
1197
1198 switch (direction) {
1199 case Meta.MotionDirection.RIGHT:
1200 index++;
1201 break;
1202 case Meta.MotionDirection.LEFT:
1203 index--;
1204 }
1205 if (index < 0 || index >= space.length) {
1206 let monitor = focusMonitor();
1207 let dir = index < 0
1208 ? Meta.DisplayDirection.LEFT : Meta.DisplayDirection.RIGHT;
1209 let i = display.get_monitor_neighbor_index(monitor.index, dir);
1210 if (i === -1)
1211 return;
1212
1213 let newMonitor = Main.layoutManager.monitors[i];
1214 space = spaces.monitors.get(newMonitor);
1215 if (dir === Meta.DisplayDirection.LEFT) {
1216 index = space.length - 1;
1217 } else {
1218 index = 0;
1219 }
1220 if (space[index].length <= row)
1221 row = space[index].length - 1;
1222 space.activate(false, false);
1223 Navigator.finishNavigation();
1224 Navigator.getNavigator().showMinimap(space);
1225 }
1226
1227 let column = space[index];
1228 if (column.length <= row)
1229 row = column.length - 1;
1230
1231 switch (direction) {
1232 case Meta.MotionDirection.UP:
1233 row--;
1234 break;
1235 case Meta.MotionDirection.DOWN:
1236 row++;
1237 }
1238 if (row < 0 || row >= column.length) {
1239 let monitor = focusMonitor();
1240 let dir = row < 0
1241 ? Meta.DisplayDirection.UP : Meta.DisplayDirection.DOWN;
1242 let i = display.get_monitor_neighbor_index(monitor.index, dir);
1243 if (i === -1)
1244 return;
1245
1246 let newMonitor = Main.layoutManager.monitors[i];
1247 space = spaces.monitors.get(newMonitor);

Callers 4

switchGlobalLeftMethod · 0.95
switchGlobalRightMethod · 0.95
switchGlobalUpMethod · 0.95
switchGlobalDownMethod · 0.95

Calls 7

focusMonitorFunction · 0.85
ensureViewportFunction · 0.85
selectedIndexMethod · 0.80
indexOfMethod · 0.80
showMinimapMethod · 0.80
getWindowMethod · 0.80
activateMethod · 0.45

Tested by

no test coverage detected