@@ -1094,6 +1094,33 @@ export class Space extends Array {
10941094 ensureViewport ( this . selectedWindow , this , { force : true } ) ;
10951095 }
10961096
1097+ moveToStart ( metaWindow ) {
1098+ metaWindow = metaWindow || this . selectedWindow ;
1099+
1100+ let [ index , row ] = this . positionOf ( metaWindow ) ;
1101+ if ( index == 0 ) return ;
1102+
1103+ let [ it ] = this . splice ( index , 1 ) ;
1104+ this . unshift ( it ) ;
1105+ this . layout ( ) ;
1106+ this . emit ( "swapped" , index , 0 , row , row ) ;
1107+ ensureViewport ( this . selectedWindow , this , { force : true } ) ;
1108+ }
1109+
1110+ moveToEnd ( metaWindow ) {
1111+ metaWindow = metaWindow || this . selectedWindow ;
1112+
1113+ let [ index , row ] = this . positionOf ( metaWindow ) ;
1114+ let targetIndex = this . length - 1 ;
1115+ if ( index == targetIndex ) return ;
1116+
1117+ let [ it ] = this . splice ( index , 1 ) ;
1118+ this . push ( it ) ;
1119+ this . layout ( ) ;
1120+ this . emit ( "swapped" , index , 0 , row , row ) ;
1121+ ensureViewport ( this . selectedWindow , this , { force : true } ) ;
1122+ }
1123+
10971124 switchLinear ( dir , loop ) {
10981125 let index = this . selectedIndex ( ) ;
10991126 let column = this [ index ] ;
@@ -1262,6 +1289,65 @@ export class Space extends Array {
12621289 ensureViewport ( metaWindow , space ) ;
12631290 }
12641291
1292+ moveGlobal ( metaWindow , direction ) {
1293+ let space = this ;
1294+ let index = space . selectedIndex ( ) ;
1295+ if ( index === - 1 ) {
1296+ return ;
1297+ }
1298+
1299+ let column = space [ index ] ;
1300+ let row = column . indexOf ( metaWindow ) ;
1301+ if ( row === - 1 ) {
1302+ let selected = sortWindows ( this , column ) [ column . length - 1 ] ;
1303+ row = column . indexOf ( selected ) ;
1304+ }
1305+
1306+ switch ( direction ) {
1307+ case Meta . MotionDirection . LEFT :
1308+ if ( index > 0 ) {
1309+ space . swap ( direction , metaWindow ) ;
1310+ return ;
1311+ } else {
1312+ let new_space = spaces . switchMonitor ( Meta . DisplayDirection . LEFT , true ) ;
1313+ if ( new_space != null ) {
1314+ new_space . moveToEnd ( metaWindow ) ;
1315+ }
1316+ return ;
1317+ }
1318+
1319+ case Meta . MotionDirection . RIGHT :
1320+ if ( index < space . length - 1 ) {
1321+ space . swap ( direction ) ;
1322+ return ;
1323+ } else {
1324+ let new_space = spaces . switchMonitor ( Meta . DisplayDirection . RIGHT , true ) ;
1325+ if ( new_space != null ) {
1326+ new_space . moveToStart ( metaWindow ) ;
1327+ }
1328+ return ;
1329+ }
1330+
1331+ case Meta . MotionDirection . UP :
1332+ if ( row > 0 ) {
1333+ space . swap ( direction ) ;
1334+ return ;
1335+ } else {
1336+ spaces . switchMonitor ( Meta . DisplayDirection . UP , true ) ;
1337+ return ;
1338+ }
1339+
1340+ case Meta . MotionDirection . DOWN :
1341+ if ( row < column . length - 1 ) {
1342+ space . swap ( direction ) ;
1343+ return ;
1344+ } else {
1345+ spaces . switchMonitor ( Meta . DisplayDirection . DOWN , true ) ;
1346+ return ;
1347+ }
1348+ }
1349+ }
1350+
12651351 _drift ( dx ) {
12661352 if ( dx === 0 ) {
12671353 return ;
@@ -2542,7 +2628,7 @@ export const Spaces = class Spaces extends Map {
25422628 let currentSpace = this . monitors . get ( monitor ) ;
25432629 let i = display . get_monitor_neighbor_index ( monitor . index , direction ) ;
25442630 if ( i === - 1 )
2545- return ;
2631+ return null ;
25462632 let newMonitor = Main . layoutManager . monitors [ i ] ;
25472633 if ( warp ) {
25482634 Utils . warpPointerToMonitor ( newMonitor ) ;
@@ -2575,6 +2661,7 @@ export const Spaces = class Spaces extends Map {
25752661 } else {
25762662 space . activate ( false , false ) ;
25772663 }
2664+ return space ;
25782665 }
25792666
25802667 moveToMonitor ( direction , backDirection ) {
0 commit comments