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

Method _showWorkspaceSwitcher

js/ui/windowManager.js:1749–1848  ·  view source on GitHub ↗
(display, window, event, binding)

Source from the content-addressed store, hash-verified

1747 }
1748
1749 _showWorkspaceSwitcher(display, window, event, binding) {
1750 const workspaceManager = display.get_workspace_manager();
1751
1752 if (!Main.sessionMode.hasWorkspaces)
1753 return;
1754
1755 if (workspaceManager.n_workspaces === 1)
1756 return;
1757
1758 let [action,,, target] = binding.get_name().split('-');
1759 let newWs;
1760 let direction;
1761 const vertical = workspaceManager.layout_rows === -1;
1762 const rtl = Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
1763
1764 if (action === 'move') {
1765 // "Moving" a window to another workspace doesn't make sense when
1766 // it cannot be unstuck, and is potentially confusing if a new
1767 // workspaces is added at the start/end
1768 if (window.is_always_on_all_workspaces() ||
1769 (Meta.prefs_get_workspaces_only_on_primary() &&
1770 window.get_monitor() !== Main.layoutManager.primaryIndex))
1771 return;
1772 }
1773
1774 if (target === 'last') {
1775 if (vertical)
1776 direction = Meta.MotionDirection.DOWN;
1777 else if (rtl)
1778 direction = Meta.MotionDirection.LEFT;
1779 else
1780 direction = Meta.MotionDirection.RIGHT;
1781 newWs = workspaceManager.get_workspace_by_index(workspaceManager.n_workspaces - 1);
1782 } else if (isNaN(target)) {
1783 // Prepend a new workspace dynamically
1784 let prependTarget;
1785 if (vertical)
1786 prependTarget = 'up';
1787 else if (rtl)
1788 prependTarget = 'right';
1789 else
1790 prependTarget = 'left';
1791 if (workspaceManager.get_active_workspace_index() === 0 &&
1792 action === 'move' && target === prependTarget &&
1793 this._isWorkspacePrepended === false) {
1794 this.insertWorkspace(0);
1795 this._isWorkspacePrepended = true;
1796 }
1797
1798 direction = Meta.MotionDirection[target.toUpperCase()];
1799 newWs = workspaceManager.get_active_workspace().get_neighbor(direction);
1800 } else if ((target > 0) && (target <= workspaceManager.n_workspaces)) {
1801 target--;
1802 newWs = workspaceManager.get_workspace_by_index(target);
1803
1804 if (workspaceManager.get_active_workspace_index() > target) {
1805 if (vertical)
1806 direction = Meta.MotionDirection.UP;

Callers

nothing calls this directly

Calls 7

insertWorkspaceMethod · 0.95
actionMoveWorkspaceMethod · 0.95
actionMoveWindowMethod · 0.95
blockWorkspaceUpdatesMethod · 0.95
displayMethod · 0.80
indexMethod · 0.45

Tested by

no test coverage detected