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

Function cycleWorkspaceSettings

tiling.js:5578–5612  ·  view source on GitHub ↗
(dir = 1)

Source from the content-addressed store, hash-verified

5576}
5577
5578export function cycleWorkspaceSettings(dir = 1) {
5579 let n = workspaceManager.get_n_workspaces();
5580 let N = workspaceSettings.getWorkspaceList().get_strv('list').length;
5581 let space = spaces.selectedSpace;
5582 let wsI = space.index;
5583
5584 // 2 6 7 8 <-- indices
5585 // x a b c <-- settings
5586 // a b c x <-- rotated settings
5587
5588 let uuids = workspaceSettings.getWorkspaceList().get_strv('list');
5589 // Work on tuples of [uuid, settings] since we need to uuid association
5590 // in the last step
5591 let settings = uuids.map(
5592 uuid => [uuid, workspaceSettings.getWorkspaceSettingsByUUID(uuid)]
5593 );
5594 settings.sort((a, b) => a[1].get_int('index') - b[1].get_int('index'));
5595
5596 let unbound = settings.slice(n);
5597 let strip = [settings[wsI]].concat(unbound);
5598
5599 strip = rotated(strip, dir);
5600
5601 let nextSettings = strip[0];
5602 unbound = strip.slice(1);
5603
5604 nextSettings[1].set_int('index', wsI);
5605 space.setSettings(nextSettings); // ASSUMPTION: ok that two settings have same index here
5606
5607 // Re-assign unbound indices:
5608 for (let i = n; i < N; i++) {
5609 unbound[i - n][1].set_int('index', i);
5610 }
5611 return space;
5612}
5613
5614// Backward compatibility
5615export function defwinprop(...args) {

Callers

nothing calls this directly

Calls 4

rotatedFunction · 0.85
getWorkspaceListMethod · 0.80
setSettingsMethod · 0.80

Tested by

no test coverage detected