MCPcopy Create free account
hub / github.com/GNOME/gnome-shell / insertWorkspace

Method insertWorkspace

js/ui/windowManager.js:1020–1061  ·  view source on GitHub ↗
(pos)

Source from the content-addressed store, hash-verified

1018 }
1019
1020 insertWorkspace(pos) {
1021 const workspaceManager = global.workspace_manager;
1022
1023 if (!Meta.prefs_get_dynamic_workspaces())
1024 return;
1025
1026 workspaceManager.append_new_workspace(false, global.get_current_time());
1027
1028 const windows = global.get_window_actors().map(a => a.meta_window);
1029
1030 // To create a new workspace, we slide all the windows on workspaces
1031 // below us to the next workspace, leaving a blank workspace for us
1032 // to recycle.
1033 windows.forEach(window => {
1034 // If the window is attached to an ancestor, we don't need/want
1035 // to move it
1036 if (window.get_transient_for() != null)
1037 return;
1038 // Same for OR windows
1039 if (window.is_override_redirect())
1040 return;
1041 // Sticky windows don't need moving, in fact moving would
1042 // unstick them
1043 if (window.on_all_workspaces)
1044 return;
1045 // Windows on workspaces below pos don't need moving
1046 const index = window.get_workspace().index();
1047 if (index < pos)
1048 return;
1049 window.change_workspace_by_index(index + 1, true);
1050 });
1051
1052 // If the new workspace was inserted before the active workspace,
1053 // activate the workspace to which its windows went
1054 const activeIndex = workspaceManager.get_active_workspace_index();
1055 if (activeIndex >= pos) {
1056 const newWs = workspaceManager.get_workspace_by_index(activeIndex + 1);
1057 this._blockAnimations = true;
1058 newWs.activate(global.get_current_time());
1059 this._blockAnimations = false;
1060 }
1061 }
1062
1063 keepWorkspaceAlive(workspace, duration) {
1064 if (!this._workspaceTracker)

Callers 2

acceptDropMethod · 0.80

Calls 3

forEachMethod · 0.80
indexMethod · 0.45
activateMethod · 0.45

Tested by

no test coverage detected