Cinnamon: Option for Alt-Tab switcher to list windows on current monitor only

Created on 18 Jun 2015  路  18Comments  路  Source: linuxmint/cinnamon

In a multi-monitor setup, it should be possible to configure the Alt-Tab switcher to switch between the windows on the "current" monitor only, where the "current" one is the one that contains the focussed window.

FEATURE REQUEST

Most helpful comment

I solved this issue easily:

Edit file: /usr/share/cinnamon/js/ui/appSwitcher/appSwitcher.js

Go to line 66, after the line
windows = windows.filter( Main.isInteresting );

We want to add the following line of code:
windows = windows.filter(w => w.get_monitor() === global.screen.get_current_monitor())

I.E. we have to change getWindowsForBinding function, the result is the following:

function getWindowsForBinding(binding) {
    // Construct a list with all windows
    let windows = [];
    let windowActors = global.get_window_actors();
    //let windowActors = getWindowList();

    for (let i in windowActors)
        windows.push(windowActors[i].get_meta_window());

    windows = windows.filter( Main.isInteresting );
    windows = windows.filter(w => w.get_monitor() === global.screen.get_current_monitor()) ##   NEW LINE !!!!!!!!

    switch(binding.get_name()) {
        case 'switch-panels':
            // Switch between windows of all workspaces
            windows = windows.filter( matchSkipTaskbar );
            break;
        case 'switch-group':
            // Switch between windows of the same application
            let focused = global.display.focus_window ? global.display.focus_window : windows[0];
            windows = windows.filter( matchWmClass, focused.get_wm_class() );
            this._showAllWorkspaces = global.settings.get_boolean("alttab-switcher-show-all-workspaces");
            if (!this._showAllWorkspaces) {
                windows = windows.filter( matchWorkspace, global.screen.get_active_workspace() );
            }
            break;
        default:
            // Switch between windows of current workspace
            this._showAllWorkspaces = global.settings.get_boolean("alttab-switcher-show-all-workspaces");
            if (!this._showAllWorkspaces) {
                windows = windows.filter( matchWorkspace, global.screen.get_active_workspace() );
            }
            break;
    }

    // Sort by user time
    windows.sort(sortWindowsByUserTime);

    return windows;
}

All 18 comments

Great suggestion, something I also often have in mind.

I guess preferable would be a configuration option under Windows > Alt-Tab settings, but additionally there could be a new opt-in shortcut key (which could be used in conjunction with the normal Alt+Tab).

+1

+1

+1

I believe Windows 10 has an option that allows you to use Ctrl+Alt+Tab to view all windows in all monitors and Alt+Tab for just windows on the current monitor.

+1

Can you elaborate on the thumbs-down comment?

Probably: since there is the thumbup/down feature, posting just "+1" is a bit spammy.

Dang. Did any of you guys figure out a usable workaround for this issue?

Many thanks for contributing to Cinnamon. Your suggestion was reviewed. Your job is done and we'll take it from here :)

For more information on our workflow and feature requests, read https://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/faq.html

Is this implemented? I can't find any option to set this.

Is this implemented? I can't find any option to set this.

No, but the issue was closed because https://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/faq.html#why-are-ideas-and-feature-requests-closed

I would find this really useful, as I`m mostly using 2 or 3 monitors and having this limitations forces me for some tasks to use other OS so I can be more productive.

I solved this issue easily:

Edit file: /usr/share/cinnamon/js/ui/appSwitcher/appSwitcher.js

Go to line 66, after the line
windows = windows.filter( Main.isInteresting );

We want to add the following line of code:
windows = windows.filter(w => w.get_monitor() === global.screen.get_current_monitor())

I.E. we have to change getWindowsForBinding function, the result is the following:

function getWindowsForBinding(binding) {
    // Construct a list with all windows
    let windows = [];
    let windowActors = global.get_window_actors();
    //let windowActors = getWindowList();

    for (let i in windowActors)
        windows.push(windowActors[i].get_meta_window());

    windows = windows.filter( Main.isInteresting );
    windows = windows.filter(w => w.get_monitor() === global.screen.get_current_monitor()) ##   NEW LINE !!!!!!!!

    switch(binding.get_name()) {
        case 'switch-panels':
            // Switch between windows of all workspaces
            windows = windows.filter( matchSkipTaskbar );
            break;
        case 'switch-group':
            // Switch between windows of the same application
            let focused = global.display.focus_window ? global.display.focus_window : windows[0];
            windows = windows.filter( matchWmClass, focused.get_wm_class() );
            this._showAllWorkspaces = global.settings.get_boolean("alttab-switcher-show-all-workspaces");
            if (!this._showAllWorkspaces) {
                windows = windows.filter( matchWorkspace, global.screen.get_active_workspace() );
            }
            break;
        default:
            // Switch between windows of current workspace
            this._showAllWorkspaces = global.settings.get_boolean("alttab-switcher-show-all-workspaces");
            if (!this._showAllWorkspaces) {
                windows = windows.filter( matchWorkspace, global.screen.get_active_workspace() );
            }
            break;
    }

    // Sort by user time
    windows.sort(sortWindowsByUserTime);

    return windows;
}

Thank you @delchiaro for this. This still works. Cinnamon 4.4.8 on Arch Linux 20200327.

Hi @delchiaro, I can confirm this works in Linux Mint 19.3

The folder location is /usr/share/cinnamon/js/ui/appSwitcher/

The file is actually named:
appSwitcher.js

And don`t forget to restart Cinnamon after doing the change.

Most simple way is by pressing ALT+F2, type r and press Enter

Hi @delchiaro, I can confirm this works in Linux Mint 19.3

The folder location is /usr/share/cinnamon/js/ui/appSwitcher/

The file is actually named:
appSwitcher.js

Corrected the path in my comment, thanks

Most simple way is by pressing ALT+F2, type r and press Enter

Another way (which I have to do from time to time) is to do execute cinnamon --replace & from a command prompt.

@delchiaro Thanks a lot for your change, greatly appreciated. :+1: Please try to get a PR created with this feature so we can get it into Cinnamon upstream, it's really useful. (I guess it will have to be configurable in some way to get it merged, but the Cinnamon developers can probably assist you with useful suggestions about that part.)

Was this page helpful?
0 / 5 - 0 ratings