jorsh.xyz wiki

WinXP-style Alt-Tab

problem

Windows 7 and above ship an alt-tab menu that shows thumbnails of open applications.

The problem with this is

Thus, when switching between applications frequently (e.g. with two windows tiled side-by-side), the alt-tab UI menu is constantly flickering in and out of existence. This causes headaches for some people (myself included)

side note: yes, this is a real intentional feature that gnome 3 has and windows 10 does not have

Here’s the relavent snippet of code

// We delay showing the popup so that fast Alt+Tab users aren't
// disturbed by the popup briefly flashing.
this._initialDelayTimeoutId = GLib.timeout_add(
    GLib.PRIORITY_DEFAULT,
    POPUP_DELAY_TIMEOUT,
    () => {
        this._showImmediately();
        return GLib.SOURCE_REMOVE;
    });
GLib.Source.set_name_by_id(this._initialDelayTimeoutId, '[gnome-shell] Main.osdWindow.cancel');

this excerpt is from gnome-shell source file js/ui/switcherPopup.js, gitlab source permalink here

potential solution: WinXP-style Alt-Tab

There is a secret keyboard shortcut that activates a much smaller and simpler alt-tab menu:

To trigger the old XP style one, you’ll need to do the following:

And Voila! The ugly old XP-style one will show up.

reference: Stupid Geek Tricks: Windows 7 Easter Egg Shows the XP Alt-Tab Prompt

problem: too hard to type

This keyboard shortcut is a huge pain to type. Two hands just to alt-tab!?! No thank you!!!

solution: use a QMK keyboard macro to tap the other alt key:

enum custom_keycodes {
    TABALT = SAFE_RANGE,
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    switch (keycode) {
    case TABALT:
        if (record->event.pressed) {
            if ((get_mods() == MOD_BIT(KC_LALT))) {
                tap_code(KC_RALT);
            }
            register_code(KC_TAB);
        } else {
            unregister_code(KC_TAB);
        }
        break;
    }
    return true;
};

// and then replace KC_TAB with TABALT in layout definition

See my full keyboard layout file for full implementation, including a function key to toggle it on and off, and using part of my keyboard’s RGB underglow as an indicator.

another problem: the switched-away-from app receives an alt tap

In many apps (chrome, firefox, vscode, etc), pressing and releasing the alt key moves the keyboard focus to some kind of menu. Thus, with the above keyboard-macro-based mitigation, switching between windows could cause menus to focus undesirably.

I don’t have a solution for this yet.

alternative solution: regedit

reference: Stupid Geek Tricks: How to Switch Windows 7 to the XP Style Alt-Tab Switcher

pros:

cons:

better solution: delay alt-tab

This is based much more directly on the way that gnome-shell does it (see above).

The idea is relatively simple: buffer the tab part of the alt-tab for a timeout interval, instead of sending a tab keycode immediately. Then:

The state machine kind of logic necessary to implement this turned out to be much more complicated than I expected! I think I’ve got it totally working now (but technically it doesn’t do the “any key” part above, just tab). The code is here, and includes a pseudocode-ish summary of the intent.