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

Method switch

tiling.js:1129–1184  ·  view source on GitHub ↗
(direction, loop)

Source from the content-addressed store, hash-verified

1127 switchUp(loop) { return this.switch(Meta.MotionDirection.UP, loop); }
1128 switchDown(loop) { return this.switch(Meta.MotionDirection.DOWN, loop); }
1129 switch(direction, loop) {
1130 let space = this;
1131 let index = space.selectedIndex();
1132 if (index === -1) {
1133 return false;
1134 }
1135 let row = space[index].indexOf(space.selectedWindow);
1136 switch (direction) {
1137 case Meta.MotionDirection.RIGHT:
1138 index++;
1139 row = -1;
1140 break;
1141 case Meta.MotionDirection.LEFT:
1142 index--;
1143 row = -1;
1144 }
1145 if (loop) {
1146 if (index < 0) {
1147 index = space.length - 1;
1148 } else if (index >= space.length) {
1149 index = 0;
1150 }
1151 } else if (index < 0 || index >= space.length) {
1152 return false;
1153 }
1154
1155 let column = space[index];
1156
1157 if (row === -1) {
1158 let selected =
1159 sortWindows(this, column)[column.length - 1];
1160 row = column.indexOf(selected);
1161 }
1162
1163 switch (direction) {
1164 case Meta.MotionDirection.UP:
1165 row--;
1166 break;
1167 case Meta.MotionDirection.DOWN:
1168 row++;
1169 }
1170 if (loop) {
1171 if (row < 0) {
1172 row = column.length - 1;
1173 } else if (row >= column.length) {
1174 row = 0;
1175 }
1176 } else if (row < 0 || row >= column.length) {
1177 return false;
1178 }
1179
1180 let metaWindow = space.getWindow(index, row);
1181 ensureViewport(metaWindow, space);
1182
1183 return true;
1184 }
1185
1186 switchGlobalLeft() { this.switchGlobal(Meta.MotionDirection.LEFT); }

Callers 4

switchLeftMethod · 0.95
switchRightMethod · 0.95
switchUpMethod · 0.95
switchDownMethod · 0.95

Calls 5

ensureViewportFunction · 0.85
selectedIndexMethod · 0.80
indexOfMethod · 0.80
getWindowMethod · 0.80
sortWindowsFunction · 0.70

Tested by

no test coverage detected