From 8fdb2c819e758ff60a8b6b35ea9a46135c42e632 Mon Sep 17 00:00:00 2001 From: dsz Date: Tue, 24 Nov 2026 10:48:07 +0545 Subject: [PATCH 1/4] Add a rendering of the switcher for the Windhawk mod readme --- assets/hud.png | Bin 0 -> 37042 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/hud.png diff --git a/assets/hud.png b/assets/hud.png new file mode 100644 index 0000000000000000000000000000000000000000..ff062d18e2a84cd61be9046ab50a0539f633860f GIT binary patch literal 37042 zcmdSA2UJt<*Di=%Q9wjQKtMr3K|p#5MWspay+i@&MY`0eNbe%O2^f%GLV!>Or9-Gm z=n?5H^pZf5IsE?rJ9EFg?wYx4);IIbu#&uolyly*&wlsb&wid0p{1cjMae`-K|w*K z{7PPjg5p981;zO^|z}KjGE~5SfA!U0xr~6nocea&hL0w zu52W~v%LI?`PZ0>pg*}Dl6l0S95=Qmb{wPv@nmDk+RI#SS}9yU&0aRcpu7@+nNrv- zfRDM(Hm=I8+yI8h4?Hge!`GXV7l1+KYSuYmc=QJncDzey@6l}ekT04}RHnrpUrlu9Y~-}CA55-A{iXMT?9jBH4jHyK zxrC5;f8;Zrqe!*7GqV$Bid)&%Oo~N;PuEh|1T7%-epTd6$F8SgNVZn#fa6wD8PRX= zg4OO~PV17IR6u}%iSW9~J>o*UV$7mlxWh$?*VL;<#Eyzk=!MeylU)8l!Y-CPK+{4N zlRYN&y~XbbdgU$C`^fI28XJka6-=;uXKwKtt$+?Z=%Wc-9c`;LwjO4wgXkbzd`|=C zv2j>5B*=HJ&=6B^)%1SnfTV1gWQ_DWj3_->%My#|1}3s!SICFw?5!Zpom6O!rD1yl zhl6&NWs# z!(M*YApen5TQ?$F>KU&5$U|DiFKRwA++=Uxm+RG7nqR9-Ss# zOJeEi(v>KeC|q$+NM(38T7)}33pki0+~G!fgEyZ3 zs9tC0JjFYzHNZ~%fxE#BG_Aa7w!;*wt~LIk)zK6($+dI{@gjEj?{V^pjK`y!u#n=q zOm9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ser-only hotkeys - Find the tab strip with a search that skips web page content, so tab widgets inside pages are no longer listed - Run the keyboard hook on its own thread, and only take over Alt+Q and Alt+` while an enabled browser is focused, leaving AltGr alone - Label tabs with the site name from the end of their title, and make "Group tabs by site" work - Add scrolling, Page Up/Down, mouse wheel, DPI scaling, multi-word filtering and a current tab marker - Fix the click hit test, Alt+F4 breaking the hotkeys, Alt+F2 opening the switcher, and COM objects outliving CoUninitialize --- CHANGELOG.md | 23 + ChromiumAltTabInjector.wh.cpp | 1833 +++++++++++++++++++++------------ README.md | 87 +- 3 files changed, 1241 insertions(+), 702 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dbd05a..8b442d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,29 @@ All notable changes to the **AltTabs** project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.2.0] - 2026-11-24 + +### Changed +- **Native Tab Strip Only**: Tabs are read from the browser's tab strip with a search that skips web page content. Previously, tab widgets inside web pages could show up as extra entries (e.g. 14 entries for a 5-tab window). +- **Browser-Only Hotkeys**: `Alt + Q` and ``Alt + ` `` are only taken over while an enabled browser is focused. `AltGr` (Ctrl+Alt) combinations are left alone, so e.g. `AltGr + Q` still types `@` on German layouts. +- **Site Labels**: The label next to a tab is the site name from the end of its title (e.g. `YouTube`), instead of a guessed `.com` domain. +- **Mod Settings**: "Group tabs by site" now works. Removed the Vivaldi setting, since its tab bar is a web page. + +### Added +- Scrolling with the selection, `Page Up` / `Page Down`, the mouse wheel, and a scroll bar. +- `Shift + Alt + Q` cycles backwards, `Ctrl + Backspace` clears the filter. +- Multi-word filtering, a match count, and a marker for the current tab. +- DPI scaling, and keeping the switcher inside the browser's monitor. + +### Fixed +- The keyboard hook runs on its own thread, so UI Automation calls can no longer delay keyboard input system-wide. +- `Alt + F2` no longer opens the switcher, and `Alt + \` isn't taken over anymore. +- Clicking a row in the lower part of the list selected the wrong tab. +- Clicking another app while the switcher was open tried to pull the focus back to the browser. +- `Alt + F4` destroyed the switcher window, after which the hotkeys stopped working. +- Titles containing `&` were drawn with an underlined letter. +- UI Automation objects were released after COM was uninitialized on exit. + ## [1.1.1] - 2026-11-04 ### Added diff --git a/ChromiumAltTabInjector.wh.cpp b/ChromiumAltTabInjector.wh.cpp index cd3f877..ead9b22 100644 --- a/ChromiumAltTabInjector.wh.cpp +++ b/ChromiumAltTabInjector.wh.cpp @@ -1,824 +1,1343 @@ // ==WindhawkMod== // @id chromium-alttab-tabs // @name AltTabs - Browser Tab Switcher HUD -// @description A fast, beautiful Windows 11 Alt+Tab HUD for browser tabs with domain grouping and instant search. -// @version 1.1.1 +// @description Press Alt+Q in Chrome, Edge or Brave to search the open tabs of the window and switch to one with the keyboard +// @version 1.2.0 // @author Dszae // @github https://github.com/Dszae // @homepage https://github.com/Dszae/AltTabs // @include windhawk.exe -// @compilerOptions -lole32 -loleaut32 -luiautomationcore -luuid -lshell32 -lgdi32 -ldwmapi -lshlwapi +// @compilerOptions -lole32 -loleaut32 -lshell32 -lgdi32 -ldwmapi // ==/WindhawkMod== // ==WindhawkModReadme== /* # AltTabs - Browser Tab Switcher HUD -Press **Alt + `** (Tilde / Backtick) or **Alt + Q** while in any Chromium browser (Google Chrome, -Brave, Microsoft Edge, Opera, Vivaldi) to summon a sleek, native Windows 11 floating Tab Switcher HUD. - -![AltTabs Demo](https://raw.githubusercontent.com/Dszae/AltTabs/main/brag-output/brag.jpg) - -### Highlights: -- **Instant Keyboard Navigation**: Press `Alt + ` ` or `Alt + Q` to summon. Use `Tab` / `Arrow Keys` to navigate, and `Enter` to switch. -- **Domain Clustering**: Stacks tabs by root domain (`github.com`, `youtube.com`) so 50 open tabs become clean, readable groups. -- **Real-Time Fuzzy Search**: Just start typing any keyword to filter tabs instantly across your open browser window. -- **Native Windows 11 Styling**: Smooth rounded corners, dark mode, favicons, and zero background clutter. -- **100% Isolated & Stable**: Runs in a dedicated Windhawk tool process without injecting into File Explorer. +Press **Alt+Q** while a Chrome, Edge or Brave window is focused to open a +searchable list of the tabs in that window. Type to filter, pick a tab with +the arrow keys, and press **Enter** to switch to it. + +![AltTabs](https://raw.githubusercontent.com/Dszae/AltTabs/8fdb2c819e758ff60a8b6b35ea9a46135c42e632/assets/hud.png) + +## Keys + +| Key | Action | +|-----|--------| +| **Alt+Q** or **Alt+\`** | Open the list. While it's open, press again to move down, or with Shift to move up. | +| Typing | Filter the tabs. Several words match tabs that contain all of them. | +| **↑** **↓**, **Tab**, **Shift+Tab** | Move the selection | +| **Page Up**, **Page Down** | Move the selection by a page | +| **Enter** or click | Switch to the selected tab | +| **Backspace**, **Ctrl+Backspace** | Delete a character, clear the filter | +| **Esc** | Close the list | + +**Alt+\`** is the key above Tab on US keyboard layouts. The hotkeys are only +taken over while a window of an enabled browser is focused. In other apps +they work as usual. + +## Notes + +- Only the tabs of the focused browser window are listed. The current tab is + marked with a blue bar. +- Tab titles are read with Windows UI Automation. Browsers don't expose tab + addresses this way, so the site name next to a tab is taken from the end of + its title, for example "YouTube" in "Some video - YouTube". Tabs whose title + doesn't end with a site name have no label. +- Vivaldi isn't supported, its tab bar is part of a web page. +- The mod runs in its own Windhawk process. It doesn't inject code into the + browser or into Explorer. */ // ==/WindhawkModReadme== // ==WindhawkModSettings== /* -- GroupByDomain: true - $name: Group tabs by domain - $description: Categorizes multiple tabs from the same website together in the switcher. +- GroupBySite: true + $name: Group tabs by site + $description: List the tabs of each site together, in the order the sites first appear in the tab strip - EnableChrome: true - $name: Support Google Chrome -- EnableBrave: true - $name: Support Brave Browser + $name: Google Chrome - EnableEdge: true - $name: Support Microsoft Edge + $name: Microsoft Edge +- EnableBrave: true + $name: Brave - EnableOpera: true - $name: Support Opera Browser -- EnableVivaldi: true - $name: Support Vivaldi Browser + $name: Opera */ // ==/WindhawkModSettings== -#include #include -#include + #include -#include -#include -#include +#include // Defines the UI Automation GUIDs. +#include +#include + +#include +#include +#include #include -#include #include -#include -#include -#include +#include +#include #include +using Microsoft::WRL::ComPtr; + EXTERN_C IMAGE_DOS_HEADER __ImageBase; -#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase) +#define HINST_THISCOMPONENT ((HINSTANCE) & __ImageBase) + +namespace { + +constexpr UINT_PTR kDeactivateTimerId = 1; + +// A focus change right after the window is shown, e.g. when Alt is released, +// doesn't close it. +constexpr ULONGLONG kActivationGraceMs = 400; + +// UI Automation calls to a hung browser fail after this time. +constexpr DWORD kUiaTimeoutMs = 2000; + +// Limits for the search for the tab strip in the browser's UI. +constexpr int kTabStripMaxDepth = 16; +constexpr int kTabStripMaxNodes = 400; + +constexpr PCWSTR kWindowClass = L"AltTabs_TabSwitcher"; + +// DWMWA_USE_IMMERSIVE_DARK_MODE, DWMWA_WINDOW_CORNER_PREFERENCE and +// DWMWCP_ROUND, which older SDKs don't define. +constexpr DWORD kDwmwaUseImmersiveDarkMode = 20; +constexpr DWORD kDwmwaWindowCornerPreference = 33; +constexpr DWORD kDwmwcpRound = 2; + +// Layout, in pixels at 96 DPI. +constexpr int kWindowWidth = 640; +constexpr int kWindowHeight = 440; +constexpr int kSearchTop = 14; +constexpr int kSearchBottom = 52; +constexpr int kListTop = 66; +constexpr int kRowHeight = 44; +constexpr int kRowStride = 46; +constexpr int kFooterHeight = 34; +constexpr int kSiteWidth = 140; + +constexpr COLORREF kBackgroundColor = RGB(24, 24, 28); +constexpr COLORREF kSearchColor = RGB(36, 36, 42); +constexpr COLORREF kSelectionColor = RGB(48, 68, 120); +constexpr COLORREF kAccentColor = RGB(96, 165, 250); +constexpr COLORREF kTextColor = RGB(230, 230, 235); +constexpr COLORREF kSelectedTextColor = RGB(255, 255, 255); +constexpr COLORREF kSiteColor = RGB(140, 145, 160); +constexpr COLORREF kSelectedSiteColor = RGB(190, 215, 255); +constexpr COLORREF kDimTextColor = RGB(120, 125, 135); +constexpr COLORREF kScrollColor = RGB(70, 72, 82); + +struct Settings { + std::atomic groupBySite{true}; + std::atomic chrome{true}; + std::atomic edge{true}; + std::atomic brave{true}; + std::atomic opera{true}; +}; -namespace AltTabsMod { +Settings g_settings; -struct ModSettings { - bool groupByDomain = true; - bool enableChrome = true; - bool enableBrave = true; - bool enableEdge = true; - bool enableOpera = true; - bool enableVivaldi = true; -} g_settings; +// Registered messages, since the switcher is a top-level window and can get +// WM_APP messages that other programs broadcast. +// Posted by the keyboard hook. wParam is TRUE if Shift is down. +UINT g_hotkeyMessage; +// Posted to stop the switcher thread. +UINT g_quitMessage; -std::mutex g_settingsMutex; +HANDLE g_switcherThread; +HANDLE g_hookThread; +DWORD g_hookThreadId; +std::atomic g_switcherWindow; +bool g_threadStartOk; void LoadSettings() { - std::lock_guard lock(g_settingsMutex); - g_settings.groupByDomain = Wh_GetIntSetting(L"GroupByDomain") != 0; - g_settings.enableChrome = Wh_GetIntSetting(L"EnableChrome") != 0; - g_settings.enableBrave = Wh_GetIntSetting(L"EnableBrave") != 0; - g_settings.enableEdge = Wh_GetIntSetting(L"EnableEdge") != 0; - g_settings.enableOpera = Wh_GetIntSetting(L"EnableOpera") != 0; - g_settings.enableVivaldi = Wh_GetIntSetting(L"EnableVivaldi") != 0; -} - -template -class SafeComPtr { - T* m_ptr = nullptr; -public: - SafeComPtr() = default; - SafeComPtr(T* ptr) : m_ptr(ptr) { if (m_ptr) m_ptr->AddRef(); } - ~SafeComPtr() { Release(); } - SafeComPtr(const SafeComPtr& o) : m_ptr(o.m_ptr) { if (m_ptr) m_ptr->AddRef(); } - SafeComPtr& operator=(const SafeComPtr& o) { - if (this != std::addressof(o)) { - Release(); - m_ptr = o.m_ptr; - if (m_ptr) m_ptr->AddRef(); - } - return *this; + g_settings.groupBySite = Wh_GetIntSetting(L"GroupBySite") != 0; + g_settings.chrome = Wh_GetIntSetting(L"EnableChrome") != 0; + g_settings.edge = Wh_GetIntSetting(L"EnableEdge") != 0; + g_settings.brave = Wh_GetIntSetting(L"EnableBrave") != 0; + g_settings.opera = Wh_GetIntSetting(L"EnableOpera") != 0; +} + +// Returns whether the window is a main window of an enabled browser. +bool IsEnabledBrowserWindow(HWND hwnd) { + if (!hwnd || !IsWindowVisible(hwnd)) { + return false; } - T* operator->() const { return m_ptr; } - T** operator&() { Release(); return &m_ptr; } - operator T*() const { return m_ptr; } - bool operator!() const { return m_ptr == nullptr; } - void Release() { if (m_ptr) { T* tmp = m_ptr; m_ptr = nullptr; tmp->Release(); } } -}; -struct TabInfo { - std::wstring title; - std::wstring domain; - HWND browserHwnd = nullptr; - RECT boundingRect = { 0 }; - bool isSelected = false; - SafeComPtr uiaElement; - HICON hFavicon = nullptr; - - TabInfo() = default; - ~TabInfo() { if (hFavicon) DestroyIcon(hFavicon); } - TabInfo(const TabInfo&) = delete; - TabInfo& operator=(const TabInfo&) = delete; -}; + WCHAR className[32]; + if (!GetClassNameW(hwnd, className, ARRAYSIZE(className)) || + wcscmp(className, L"Chrome_WidgetWin_1") != 0) { + return false; + } -static std::wstring ExtractDomainFromTitle(const std::wstring& title) { - std::wstring s = title; - std::transform(s.begin(), s.end(), s.begin(), ::towlower); - if (s.find(L"github") != std::wstring::npos) return L"github.com"; - if (s.find(L"google") != std::wstring::npos) return L"google.com"; - if (s.find(L"youtube") != std::wstring::npos) return L"youtube.com"; - if (s.find(L"stackoverflow") != std::wstring::npos) return L"stackoverflow.com"; - if (s.find(L"reddit") != std::wstring::npos) return L"reddit.com"; - if (s.find(L"facebook") != std::wstring::npos) return L"facebook.com"; - if (s.find(L"twitter") != std::wstring::npos || s.find(L" x ") != std::wstring::npos) return L"x.com"; - if (s.find(L"chatgpt") != std::wstring::npos || s.find(L"openai") != std::wstring::npos) return L"openai.com"; - if (s.find(L"claude") != std::wstring::npos) return L"claude.ai"; - if (s.find(L"tcioe") != std::wstring::npos) return L"tcioe.edu.np"; - - // Clean up title separators (" - ", " | ") - size_t lastSep = s.find_last_of(L"-|"); - if (lastSep != std::wstring::npos && lastSep + 1 < s.length()) { - std::wstring part = s.substr(lastSep + 1); - while (!part.empty() && part.front() == L' ') part.erase(0, 1); - while (!part.empty() && part.back() == L' ') part.pop_back(); - if (part.length() > 3 && part.find(L' ') == std::wstring::npos) { - return part + L".com"; - } + DWORD processId = 0; + GetWindowThreadProcessId(hwnd, &processId); + HANDLE process = + OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId); + if (!process) { + return false; } - return L"Other Websites"; -} - -static bool IsSupportedBrowserWindow(HWND hwnd, std::wstring* outBrowserName = nullptr) { - if (!IsWindow(hwnd) || !IsWindowVisible(hwnd)) return false; - wchar_t cls[64] = { 0 }; - GetClassNameW(hwnd, cls, 64); - if (wcscmp(cls, L"Chrome_WidgetWin_1") != 0) return false; - - DWORD pid = 0; - GetWindowThreadProcessId(hwnd, &pid); - HANDLE hProc = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid); - if (hProc) { - wchar_t path[MAX_PATH] = { 0 }; - DWORD sz = MAX_PATH; - if (QueryFullProcessImageNameW(hProc, 0, path, &sz)) { - std::wstring sPath(path); - std::transform(sPath.begin(), sPath.end(), sPath.begin(), ::towlower); - - std::lock_guard lock(g_settingsMutex); - if (g_settings.enableBrave && sPath.find(L"brave.exe") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Brave"; - CloseHandle(hProc); - return true; - } - if (g_settings.enableChrome && sPath.find(L"chrome.exe") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Google Chrome"; - CloseHandle(hProc); - return true; - } - if (g_settings.enableEdge && sPath.find(L"msedge.exe") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Microsoft Edge"; - CloseHandle(hProc); - return true; - } - if (g_settings.enableOpera && sPath.find(L"opera.exe") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Opera"; - CloseHandle(hProc); - return true; - } - if (g_settings.enableVivaldi && sPath.find(L"vivaldi.exe") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Vivaldi"; - CloseHandle(hProc); - return true; - } + + WCHAR path[MAX_PATH]; + DWORD pathSize = ARRAYSIZE(path); + BOOL gotPath = QueryFullProcessImageNameW(process, 0, path, &pathSize); + CloseHandle(process); + if (!gotPath) { + return false; + } + + PCWSTR fileName = wcsrchr(path, L'\\'); + fileName = fileName ? fileName + 1 : path; + + const struct { + PCWSTR fileName; + const std::atomic& enabled; + } browsers[] = { + {L"chrome.exe", g_settings.chrome}, + {L"msedge.exe", g_settings.edge}, + {L"brave.exe", g_settings.brave}, + {L"opera.exe", g_settings.opera}, + }; + + for (const auto& browser : browsers) { + if (_wcsicmp(fileName, browser.fileName) == 0) { + return browser.enabled; } - CloseHandle(hProc); } - // Title fallback - wchar_t title[256] = { 0 }; - GetWindowTextW(hwnd, title, 256); - std::wstring sTitle(title); - std::transform(sTitle.begin(), sTitle.end(), sTitle.begin(), ::towlower); + return false; +} - std::lock_guard lock(g_settingsMutex); - if (g_settings.enableBrave && sTitle.find(L"brave") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Brave"; - return true; +std::wstring ToLower(std::wstring text) { + if (!text.empty()) { + CharLowerBuffW(text.data(), static_cast(text.size())); } - if (g_settings.enableChrome && sTitle.find(L"chrome") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Google Chrome"; - return true; + return text; +} + +std::vector SplitWords(const std::wstring& text) { + std::vector words; + size_t pos = 0; + while (true) { + size_t start = text.find_first_not_of(L' ', pos); + if (start == std::wstring::npos) { + break; + } + size_t end = text.find(L' ', start); + if (end == std::wstring::npos) { + end = text.size(); + } + words.push_back(text.substr(start, end - start)); + pos = end; } - if (g_settings.enableEdge && sTitle.find(L"edge") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Microsoft Edge"; - return true; + return words; +} + +// Returns the site name at the end of a page title, e.g. "YouTube" for +// "Some video - YouTube", or an empty string if the title doesn't seem to end +// with one. +std::wstring GetSiteName(const std::wstring& title) { + static constexpr PCWSTR kSeparators[] = { + L" - ", L" | ", L" – ", L" — ", L" · ", + }; + + size_t siteStart = std::wstring::npos; + for (PCWSTR separator : kSeparators) { + size_t pos = title.rfind(separator); + if (pos == std::wstring::npos || pos == 0) { + continue; + } + size_t end = pos + wcslen(separator); + if (siteStart == std::wstring::npos || end > siteStart) { + siteStart = end; + } + } + + if (siteStart == std::wstring::npos) { + return {}; } - if (g_settings.enableOpera && sTitle.find(L"opera") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Opera"; - return true; + + std::wstring site = title.substr(siteStart); + size_t first = site.find_first_not_of(L' '); + size_t last = site.find_last_not_of(L' '); + if (first == std::wstring::npos) { + return {}; } - if (g_settings.enableVivaldi && sTitle.find(L"vivaldi") != std::wstring::npos) { - if (outBrowserName) *outBrowserName = L"Vivaldi"; - return true; + site = site.substr(first, last - first + 1); + + // Site names are short, and don't look like paths or contain many words. + constexpr size_t kMaxSiteLength = 30; + constexpr std::ptrdiff_t kMaxSpaces = 2; + if (site.size() > kMaxSiteLength || + site.find_first_of(L"/\\:") != std::wstring::npos || + std::count(site.begin(), site.end(), L' ') > kMaxSpaces) { + return {}; } - if (outBrowserName) *outBrowserName = L"Browser"; - return true; + return site; } -static HWND FindTargetBrowserWindow(std::wstring* outBrowserName = nullptr) { - HWND fgHwnd = GetForegroundWindow(); - if (IsSupportedBrowserWindow(fgHwnd, outBrowserName)) { - return fgHwnd; +bool IsLeafControlType(CONTROLTYPEID type) { + switch (type) { + case UIA_ButtonControlTypeId: + case UIA_CheckBoxControlTypeId: + case UIA_EditControlTypeId: + case UIA_HyperlinkControlTypeId: + case UIA_ImageControlTypeId: + case UIA_MenuItemControlTypeId: + case UIA_ProgressBarControlTypeId: + case UIA_RadioButtonControlTypeId: + case UIA_SeparatorControlTypeId: + case UIA_SliderControlTypeId: + case UIA_SplitButtonControlTypeId: + case UIA_TabItemControlTypeId: + case UIA_TextControlTypeId: + return true; } + return false; +} - HWND target = nullptr; - HWND hWalk = GetTopWindow(nullptr); - while (hWalk) { - if (IsWindowVisible(hWalk) && !IsIconic(hWalk)) { - if (IsSupportedBrowserWindow(hWalk, outBrowserName)) { - target = hWalk; - break; - } - } - hWalk = GetWindow(hWalk, GW_HWNDNEXT); - } - return target; +void FillSolidRect(HDC dc, const RECT& rect, COLORREF color) { + SetDCBrushColor(dc, color); + FillRect(dc, &rect, static_cast(GetStockObject(DC_BRUSH))); } -// --- TAB SWITCHER HUD WINDOW --- -class TabSwitcherHUD { -public: - static TabSwitcherHUD& Instance() { - static TabSwitcherHUD s_hud; - return s_hud; - } +struct TabEntry { + std::wstring title; + std::wstring site; + std::wstring searchText; + size_t groupOrder = 0; + bool active = false; + ComPtr element; +}; - HWND GetHwnd() const { return m_hwnd; } +class TabSwitcher { + public: + TabSwitcher() = default; + TabSwitcher(const TabSwitcher&) = delete; + TabSwitcher& operator=(const TabSwitcher&) = delete; + + // Both run on the switcher thread, which must have initialized COM. + bool Init(); + void Uninit(); + + HWND Window() const { return m_window; } + + private: + static LRESULT CALLBACK WndProc(HWND hwnd, + UINT message, + WPARAM wParam, + LPARAM lParam); + LRESULT HandleMessage(UINT message, WPARAM wParam, LPARAM lParam); + bool HandleKey(WPARAM key); + + void OnHotkey(bool backwards); + void Show(HWND browser); + void Hide(bool focusBrowser); + void ActivateSelectedTab(); + + void LoadTabs(HWND browser); + std::vector> FindTabStrips( + IUIAutomationElement* window); + void ApplyFilter(); + + void MoveSelection(int delta, bool wrap); + void ScrollBy(int rows); + void EnsureSelectionVisible(); + int GetVisibleRowCount() const; + int GetRowFromPoint(int y) const; + + int Scale(int value) const { return MulDiv(value, m_dpi, 96); } + void UpdateDpi(UINT dpi); + void DeleteFonts(); + void Paint(HDC hdc); + + HWND m_window = nullptr; + HWND m_browser = nullptr; + ULONGLONG m_shownTime = 0; + UINT m_dpi = 96; + HFONT m_titleFont = nullptr; + HFONT m_smallFont = nullptr; + + ComPtr m_uia; + ComPtr m_trueCondition; + ComPtr m_tabItemCondition; + ComPtr m_controlTypeCache; + ComPtr m_tabCache; + + std::vector m_tabs; + // Indices into m_tabs of the tabs that match the filter, in display order. + std::vector m_visible; + std::wstring m_filter; + size_t m_selected = 0; + size_t m_scroll = 0; +}; - void CreateHUDWindow() { - if (m_hwnd && IsWindow(m_hwnd)) return; +bool TabSwitcher::Init() { + HRESULT hr = CoCreateInstance( + CLSID_CUIAutomation8, nullptr, CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(m_uia.ReleaseAndGetAddressOf())); + if (FAILED(hr)) { + hr = CoCreateInstance(CLSID_CUIAutomation, nullptr, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(m_uia.ReleaseAndGetAddressOf())); + } + if (FAILED(hr)) { + Wh_Log(L"Creating CUIAutomation failed: 0x%08X", hr); + return false; + } - WNDCLASSEXW wc = { 0 }; - wc.cbSize = sizeof(WNDCLASSEXW); - wc.lpfnWndProc = WndProc; - wc.hInstance = HINST_THISCOMPONENT; - wc.hCursor = LoadCursor(nullptr, IDC_ARROW); - wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszClassName = L"AltTabs_FloatingHUDWindow"; - RegisterClassExW(&wc); + ComPtr uia2; + if (SUCCEEDED(m_uia.As(&uia2))) { + uia2->put_ConnectionTimeout(kUiaTimeoutMs); + uia2->put_TransactionTimeout(kUiaTimeoutMs); + } - m_hwnd = CreateWindowExW( - WS_EX_TOPMOST | WS_EX_TOOLWINDOW, - L"AltTabs_FloatingHUDWindow", - L"AltTabs Quick Switcher", - WS_POPUP | WS_BORDER, - 100, 100, 640, 440, - nullptr, nullptr, HINST_THISCOMPONENT, this - ); + VARIANT tabItemType; + tabItemType.vt = VT_I4; + tabItemType.lVal = UIA_TabItemControlTypeId; + + if (FAILED(m_uia->CreateTrueCondition(&m_trueCondition)) || + FAILED(m_uia->CreatePropertyCondition( + UIA_ControlTypePropertyId, tabItemType, &m_tabItemCondition)) || + FAILED(m_uia->CreateCacheRequest(&m_controlTypeCache)) || + FAILED(m_controlTypeCache->AddProperty(UIA_ControlTypePropertyId)) || + FAILED(m_uia->CreateCacheRequest(&m_tabCache)) || + FAILED(m_tabCache->AddProperty(UIA_NamePropertyId)) || + FAILED(m_tabCache->AddProperty( + UIA_SelectionItemIsSelectedPropertyId))) { + Wh_Log(L"Creating UI Automation conditions failed"); + return false; + } - // Windows 11 Rounded Corners & Dark Mode - BOOL darkMode = TRUE; - DwmSetWindowAttribute(m_hwnd, 20 /* DWMWA_USE_IMMERSIVE_DARK_MODE */, &darkMode, sizeof(BOOL)); - DWORD corner = 2 /* DWMWCP_ROUND */; - DwmSetWindowAttribute(m_hwnd, 33 /* DWMWA_WINDOW_CORNER_PREFERENCE */, &corner, sizeof(DWORD)); + WNDCLASSEXW windowClass{}; + windowClass.cbSize = sizeof(windowClass); + windowClass.lpfnWndProc = WndProc; + windowClass.hInstance = HINST_THISCOMPONENT; + windowClass.hCursor = LoadCursorW(nullptr, IDC_ARROW); + windowClass.lpszClassName = kWindowClass; + if (!RegisterClassExW(&windowClass)) { + Wh_Log(L"RegisterClassExW failed: %u", GetLastError()); + return false; } - void DestroyHUDWindow() { - if (m_hwnd && IsWindow(m_hwnd)) { - DestroyWindow(m_hwnd); - m_hwnd = nullptr; - } + CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW, kWindowClass, L"AltTabs", + WS_POPUP | WS_BORDER, 0, 0, 0, 0, nullptr, nullptr, + HINST_THISCOMPONENT, this); + if (!m_window) { + Wh_Log(L"CreateWindowExW failed: %u", GetLastError()); + UnregisterClassW(kWindowClass, HINST_THISCOMPONENT); + return false; } - void ShowOrCycle() { - if (m_hwnd && IsWindowVisible(m_hwnd)) { - if (!m_filteredTabs.empty()) { - m_selectedIndex = (m_selectedIndex + 1) % m_filteredTabs.size(); - InvalidateRect(m_hwnd, nullptr, FALSE); - } - return; - } - Show(); + // Dark mode and rounded corners. Older Windows versions ignore these. + BOOL darkMode = TRUE; + DwmSetWindowAttribute(m_window, kDwmwaUseImmersiveDarkMode, &darkMode, + sizeof(darkMode)); + DWORD corners = kDwmwcpRound; + DwmSetWindowAttribute(m_window, kDwmwaWindowCornerPreference, &corners, + sizeof(corners)); + + UpdateDpi(GetDpiForWindow(m_window)); + return true; +} + +void TabSwitcher::Uninit() { + if (m_window) { + DestroyWindow(m_window); + UnregisterClassW(kWindowClass, HINST_THISCOMPONENT); } - void Show() { - std::wstring browserName = L"Browser"; - HWND fgHwnd = FindTargetBrowserWindow(&browserName); - if (!fgHwnd) { - Wh_Log(L"AltTabs: No target browser window found."); - return; - } + DeleteFonts(); + + // Release the UI Automation objects before COM is uninitialized. + m_tabs.clear(); + m_visible.clear(); + m_tabCache.Reset(); + m_controlTypeCache.Reset(); + m_tabItemCondition.Reset(); + m_trueCondition.Reset(); + m_uia.Reset(); +} - m_targetBrowserHwnd = fgHwnd; - m_browserTitle = browserName; - FetchTabsForBrowser(fgHwnd); +LRESULT CALLBACK TabSwitcher::WndProc(HWND hwnd, + UINT message, + WPARAM wParam, + LPARAM lParam) { + TabSwitcher* self; + if (message == WM_NCCREATE) { + auto* createStruct = reinterpret_cast(lParam); + self = static_cast(createStruct->lpCreateParams); + self->m_window = hwnd; + SetWindowLongPtrW(hwnd, GWLP_USERDATA, + reinterpret_cast(self)); + } else { + self = reinterpret_cast( + GetWindowLongPtrW(hwnd, GWLP_USERDATA)); + } - m_filterText.clear(); - m_selectedIndex = 0; - ApplyFilter(); + if (!self) { + return DefWindowProcW(hwnd, message, wParam, lParam); + } - if (!m_hwnd || !IsWindow(m_hwnd)) { - CreateHUDWindow(); - } + LRESULT result = self->HandleMessage(message, wParam, lParam); - // Center HUD on browser window - RECT rcBrowser = { 0 }; - GetWindowRect(fgHwnd, &rcBrowser); - int w = 640; - int h = 440; - int x = rcBrowser.left + (rcBrowser.right - rcBrowser.left - w) / 2; - int y = rcBrowser.top + (rcBrowser.bottom - rcBrowser.top - h) / 2; - if (x < 50) x = 50; - if (y < 50) y = 50; - - m_openTime = GetTickCount64(); - SetWindowPos(m_hwnd, HWND_TOPMOST, x, y, w, h, SWP_SHOWWINDOW); - SetForegroundWindow(m_hwnd); - SetFocus(m_hwnd); - InvalidateRect(m_hwnd, nullptr, TRUE); - Wh_Log(L"AltTabs: HUD displayed for browser hwnd=0x%p (%ls) with %d tabs", fgHwnd, browserName.c_str(), (int)m_allTabs.size()); - } - - void Hide() { - if (m_hwnd && IsWindow(m_hwnd)) { - ShowWindow(m_hwnd, SW_HIDE); - } - m_openTime = 0; - if (m_targetBrowserHwnd && IsWindow(m_targetBrowserHwnd)) { - SetForegroundWindow(m_targetBrowserHwnd); - } + if (message == WM_NCDESTROY) { + SetWindowLongPtrW(hwnd, GWLP_USERDATA, 0); + self->m_window = nullptr; } - void ActivateSelectedTab() { - if (m_filteredTabs.empty() || m_selectedIndex >= m_filteredTabs.size()) { - Hide(); - return; - } + return result; +} - auto tab = m_filteredTabs[m_selectedIndex]; - HWND bHwnd = tab->browserHwnd; - Hide(); +LRESULT TabSwitcher::HandleMessage(UINT message, WPARAM wParam, LPARAM lParam) { + if (message == g_hotkeyMessage) { + OnHotkey(wParam != 0); + return 0; + } - if (bHwnd && IsWindow(bHwnd)) { - if (IsIconic(bHwnd)) ShowWindow(bHwnd, SW_RESTORE); - SetForegroundWindow(bHwnd); + if (message == g_quitMessage) { + PostQuitMessage(0); + return 0; + } - if (tab->uiaElement) { - SafeComPtr pSel; - if (SUCCEEDED(tab->uiaElement->GetCurrentPatternAs(UIA_SelectionItemPatternId, IID_IUIAutomationSelectionItemPattern, (void**)&pSel)) && pSel) { - pSel->Select(); - Wh_Log(L"AltTabs: Tab activated via SelectionItemPattern"); - return; - } + switch (message) { + case WM_CLOSE: + // Alt+F4 hides the window, it's reused next time. + Hide(true); + return 0; - SafeComPtr pLegacy; - if (SUCCEEDED(tab->uiaElement->GetCurrentPatternAs(UIA_LegacyIAccessiblePatternId, IID_IUIAutomationLegacyIAccessiblePattern, (void**)&pLegacy)) && pLegacy) { - pLegacy->DoDefaultAction(); - Wh_Log(L"AltTabs: Tab activated via LegacyIAccessiblePattern"); - return; + case WM_ACTIVATE: + if (LOWORD(wParam) == WA_INACTIVE && m_shownTime) { + ULONGLONG elapsed = GetTickCount64() - m_shownTime; + if (elapsed >= kActivationGraceMs) { + Hide(false); + } else { + SetTimer(m_window, kDeactivateTimerId, + static_cast(kActivationGraceMs - elapsed), + nullptr); } + } + return 0; - SafeComPtr pInv; - if (SUCCEEDED(tab->uiaElement->GetCurrentPatternAs(UIA_InvokePatternId, IID_IUIAutomationInvokePattern, (void**)&pInv)) && pInv) { - pInv->Invoke(); - Wh_Log(L"AltTabs: Tab activated via InvokePattern"); - return; + case WM_TIMER: + if (wParam == kDeactivateTimerId) { + KillTimer(m_window, kDeactivateTimerId); + if (m_shownTime && GetForegroundWindow() != m_window) { + Hide(false); } + return 0; } + break; - // Coordinate click fallback - if (tab->boundingRect.right > tab->boundingRect.left) { - POINT pt = { - tab->boundingRect.left + (tab->boundingRect.right - tab->boundingRect.left) / 2, - tab->boundingRect.top + (tab->boundingRect.bottom - tab->boundingRect.top) / 2 - }; - if (ScreenToClient(bHwnd, &pt)) { - LPARAM lParam = MAKELPARAM(pt.x, pt.y); - PostMessageW(bHwnd, WM_LBUTTONDOWN, MK_LBUTTON, lParam); - PostMessageW(bHwnd, WM_LBUTTONUP, 0, lParam); - Wh_Log(L"AltTabs: Tab activated via coordinate click (%d, %d)", pt.x, pt.y); - } + case WM_KEYDOWN: + if (HandleKey(wParam)) { + return 0; } - } - } + break; + + case WM_SYSKEYDOWN: + // Arrow keys and Enter while Alt is still held after Alt+Q. + if (wParam != VK_F4 && HandleKey(wParam)) { + return 0; + } + if (wParam == VK_MENU) { + return 0; + } + break; -private: - TabSwitcherHUD() = default; + case WM_SYSKEYUP: + // Releasing Alt mustn't enter menu mode. + if (wParam == VK_MENU || wParam == VK_F10) { + return 0; + } + break; - void FetchTabsForBrowser(HWND bHwnd) { - m_allTabs.clear(); + case WM_SYSCHAR: + // Alt+letter has no meaning here, don't beep. + return 0; - // 1. Wake up Chromium accessibility tree - DWORD_PTR dwRes = 0; - SendMessageTimeoutW(bHwnd, WM_GETOBJECT, 0, (LPARAM)(LONG)-4 /* OBJID_CLIENT */, SMTO_ABORTIFHUNG, 100, &dwRes); + case WM_CHAR: + if (wParam >= L' ' && wParam != 0x7F) { + m_filter.push_back(static_cast(wParam)); + ApplyFilter(); + InvalidateRect(m_window, nullptr, FALSE); + } + return 0; - SafeComPtr pUIA; - HRESULT hrUIA = CoCreateInstance(CLSID_CUIAutomation8, nullptr, CLSCTX_INPROC_SERVER, IID_IUIAutomation, (void**)&pUIA); - if (FAILED(hrUIA) || !pUIA) { - hrUIA = CoCreateInstance(CLSID_CUIAutomation, nullptr, CLSCTX_INPROC_SERVER, IID_IUIAutomation, (void**)&pUIA); + case WM_LBUTTONDOWN: { + int row = GetRowFromPoint(static_cast(HIWORD(lParam))); + if (row >= 0) { + m_selected = static_cast(row); + ActivateSelectedTab(); + } + return 0; } - if (FAILED(hrUIA) || !pUIA) { - Wh_Log(L"AltTabs: CoCreateInstance(IUIAutomation) failed hr=0x%08X", (DWORD)hrUIA); - } else { - SafeComPtr pWinElem; - HRESULT hrElem = pUIA->ElementFromHandle(bHwnd, &pWinElem); - if (SUCCEEDED(hrElem) && pWinElem) { - VARIANT varTabItem; - varTabItem.vt = VT_I4; - varTabItem.lVal = UIA_TabItemControlTypeId; - SafeComPtr pTabCond; - pUIA->CreatePropertyCondition(UIA_ControlTypePropertyId, varTabItem, &pTabCond); - - SafeComPtr pArray; - pWinElem->FindAll(TreeScope_Descendants, pTabCond, &pArray); - int count = 0; - if (pArray) pArray->get_Length(&count); - - // Brief pause if Chromium tree is being generated - if (count == 0) { - Sleep(50); - pArray.Release(); - pWinElem->FindAll(TreeScope_Descendants, pTabCond, &pArray); - if (pArray) pArray->get_Length(&count); - } - Wh_Log(L"AltTabs: Found %d UIA tab items in browser hwnd=0x%p", count, bHwnd); + case WM_MOUSEWHEEL: { + int notches = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; + ScrollBy(-notches * 3); + return 0; + } - for (int i = 0; i < count; ++i) { - SafeComPtr pElem; - if (FAILED(pArray->GetElement(i, &pElem)) || !pElem) continue; + case WM_DPICHANGED: + // The window is sized for the browser's monitor before it's moved + // there, so only the fonts need to change. + UpdateDpi(HIWORD(wParam)); + InvalidateRect(m_window, nullptr, FALSE); + return 0; - auto tab = std::make_shared(); - tab->browserHwnd = bHwnd; - tab->uiaElement = pElem; + case WM_ERASEBKGND: + return 1; - BSTR bstrName = nullptr; - if (SUCCEEDED(pElem->get_CurrentName(&bstrName)) && bstrName) { - tab->title = bstrName; - SysFreeString(bstrName); - } - if (tab->title.empty()) tab->title = L"Untitled Tab"; + case WM_PAINT: { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(m_window, &ps); + Paint(hdc); + EndPaint(m_window, &ps); + return 0; + } + } - tab->domain = ExtractDomainFromTitle(tab->title); - pElem->get_CurrentBoundingRectangle(&tab->boundingRect); + return DefWindowProcW(m_window, message, wParam, lParam); +} - m_allTabs.push_back(tab); +bool TabSwitcher::HandleKey(WPARAM key) { + switch (key) { + case VK_ESCAPE: + Hide(true); + return true; + + case VK_RETURN: + ActivateSelectedTab(); + return true; + + case VK_TAB: + MoveSelection(GetKeyState(VK_SHIFT) < 0 ? -1 : 1, true); + return true; + + case VK_DOWN: + MoveSelection(1, true); + return true; + + case VK_UP: + MoveSelection(-1, true); + return true; + + case VK_NEXT: + MoveSelection(GetVisibleRowCount(), false); + return true; + + case VK_PRIOR: + MoveSelection(-GetVisibleRowCount(), false); + return true; + + case VK_BACK: + if (!m_filter.empty()) { + if (GetKeyState(VK_CONTROL) < 0) { + m_filter.clear(); + } else { + m_filter.pop_back(); } - } else { - Wh_Log(L"AltTabs: ElementFromHandle failed hr=0x%08X", (DWORD)hrElem); + ApplyFilter(); + InvalidateRect(m_window, nullptr, FALSE); } - } + return true; + } + + return false; +} - // Guaranteed fallback: If no UIA tabs could be enumerated, use active window title - if (m_allTabs.empty()) { - wchar_t wTitle[512] = { 0 }; - GetWindowTextW(bHwnd, wTitle, 512); - auto tab = std::make_shared(); - tab->browserHwnd = bHwnd; - tab->title = (wTitle[0] != L'\0') ? wTitle : L"Active Browser Tab"; - tab->domain = ExtractDomainFromTitle(tab->title); - m_allTabs.push_back(tab); - Wh_Log(L"AltTabs: Fallback tab added: %ls", tab->title.c_str()); +void TabSwitcher::OnHotkey(bool backwards) { + if (m_shownTime) { + if (GetForegroundWindow() != m_window) { + // Focus was lost during the grace period, take it back. + SetForegroundWindow(m_window); + } else { + MoveSelection(backwards ? -1 : 1, true); } + return; } - void ApplyFilter() { - m_filteredTabs.clear(); - std::wstring query = m_filterText; - std::transform(query.begin(), query.end(), query.begin(), ::towlower); + HWND foreground = GetForegroundWindow(); + HWND browser = foreground ? GetAncestor(foreground, GA_ROOTOWNER) : nullptr; + if (!IsEnabledBrowserWindow(browser)) { + return; + } - for (auto& tab : m_allTabs) { - if (query.empty()) { - m_filteredTabs.push_back(tab); - } else { - std::wstring sTitle = tab->title; - std::transform(sTitle.begin(), sTitle.end(), sTitle.begin(), ::towlower); - std::wstring sDomain = tab->domain; - std::transform(sDomain.begin(), sDomain.end(), sDomain.begin(), ::towlower); + Show(browser); +} - if (sTitle.find(query) != std::wstring::npos || sDomain.find(query) != std::wstring::npos) { - m_filteredTabs.push_back(tab); - } - } - } +void TabSwitcher::Show(HWND browser) { + m_browser = browser; + LoadTabs(browser); + m_filter.clear(); + ApplyFilter(); - if (m_selectedIndex >= m_filteredTabs.size()) { - m_selectedIndex = m_filteredTabs.empty() ? 0 : m_filteredTabs.size() - 1; - } + // Center on the browser window, inside the work area of its monitor. + UINT dpi = GetDpiForWindow(browser); + if (!dpi) { + dpi = 96; } + int width = MulDiv(kWindowWidth, dpi, 96); + int height = MulDiv(kWindowHeight, dpi, 96); + + RECT browserRect{}; + GetWindowRect(browser, &browserRect); + MONITORINFO monitorInfo{}; + monitorInfo.cbSize = sizeof(monitorInfo); + GetMonitorInfoW(MonitorFromWindow(browser, MONITOR_DEFAULTTONEAREST), + &monitorInfo); + const RECT& workArea = monitorInfo.rcWork; + + LONG x = (browserRect.left + browserRect.right - width) / 2; + LONG y = (browserRect.top + browserRect.bottom - height) / 2; + x = std::clamp(x, workArea.left, + std::max(workArea.left, workArea.right - width)); + y = std::clamp(y, workArea.top, + std::max(workArea.top, workArea.bottom - height)); + + m_shownTime = GetTickCount64(); + SetWindowPos(m_window, HWND_TOPMOST, x, y, width, height, + SWP_SHOWWINDOW); + UpdateDpi(GetDpiForWindow(m_window)); + SetForegroundWindow(m_window); + InvalidateRect(m_window, nullptr, FALSE); +} - static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - TabSwitcherHUD* pThis = (TabSwitcherHUD*)GetWindowLongPtrW(hwnd, GWLP_USERDATA); - if (uMsg == WM_CREATE) { - auto* cs = (CREATESTRUCTW*)lParam; - pThis = (TabSwitcherHUD*)cs->lpCreateParams; - SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)pThis); - return 0; - } +void TabSwitcher::Hide(bool focusBrowser) { + if (!m_shownTime) { + return; + } - if (uMsg == WM_APP + 10) { - if (pThis) pThis->ShowOrCycle(); - return 0; + // Cleared first, since hiding the window deactivates it. + m_shownTime = 0; + KillTimer(m_window, kDeactivateTimerId); + ShowWindow(m_window, SW_HIDE); + + if (focusBrowser && IsWindow(m_browser)) { + SetForegroundWindow(m_browser); + } + + // Don't hold on to the browser's UI Automation elements while hidden. + m_tabs.clear(); + m_visible.clear(); + m_filter.clear(); +} + +void TabSwitcher::ActivateSelectedTab() { + if (m_selected >= m_visible.size()) { + Hide(true); + return; + } + + ComPtr element = m_tabs[m_visible[m_selected]].element; + HWND browser = m_browser; + Hide(false); + + if (!IsWindow(browser)) { + return; + } + + if (IsIconic(browser)) { + ShowWindow(browser, SW_RESTORE); + } + SetForegroundWindow(browser); + + ComPtr selectionItem; + if (SUCCEEDED(element->GetCurrentPatternAs( + UIA_SelectionItemPatternId, + IID_PPV_ARGS(selectionItem.GetAddressOf()))) && + selectionItem && SUCCEEDED(selectionItem->Select())) { + return; + } + + ComPtr legacy; + if (SUCCEEDED(element->GetCurrentPatternAs( + UIA_LegacyIAccessiblePatternId, + IID_PPV_ARGS(legacy.GetAddressOf()))) && + legacy && SUCCEEDED(legacy->DoDefaultAction())) { + return; + } + + Wh_Log(L"Switching to the tab failed"); +} + +void TabSwitcher::LoadTabs(HWND browser) { + m_tabs.clear(); + + // Chromium creates its accessibility tree on the first request, so right + // after the browser starts, the tab strip might not be there yet. + constexpr int kAttempts = 3; + for (int attempt = 0; attempt < kAttempts && m_tabs.empty(); attempt++) { + if (attempt > 0) { + Sleep(50 * attempt); } - if (!pThis) return DefWindowProcW(hwnd, uMsg, wParam, lParam); + ComPtr window; + HRESULT hr = m_uia->ElementFromHandle(browser, &window); + if (FAILED(hr) || !window) { + Wh_Log(L"ElementFromHandle failed: 0x%08X", hr); + continue; + } - switch (uMsg) { - case WM_ACTIVATE: - if (LOWORD(wParam) == WA_INACTIVE) { - ULONGLONG now = GetTickCount64(); - if (pThis->m_openTime > 0 && (now - pThis->m_openTime) > 400) { - pThis->Hide(); - } + for (const auto& tabStrip : FindTabStrips(window.Get())) { + ComPtr items; + if (FAILED(tabStrip->FindAllBuildCache( + TreeScope_Descendants, m_tabItemCondition.Get(), + m_tabCache.Get(), &items)) || + !items) { + continue; } - return 0; - case WM_KEYDOWN: - if (wParam == VK_ESCAPE) { - pThis->Hide(); - return 0; - } - if (wParam == VK_RETURN) { - pThis->ActivateSelectedTab(); - return 0; - } - if (wParam == VK_TAB) { - bool shiftDown = (GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0; - if (!pThis->m_filteredTabs.empty()) { - if (shiftDown) { - if (pThis->m_selectedIndex == 0) pThis->m_selectedIndex = pThis->m_filteredTabs.size() - 1; - else pThis->m_selectedIndex--; - } else { - pThis->m_selectedIndex = (pThis->m_selectedIndex + 1) % pThis->m_filteredTabs.size(); - } - InvalidateRect(hwnd, nullptr, FALSE); + int count = 0; + items->get_Length(&count); + for (int i = 0; i < count; i++) { + ComPtr item; + if (FAILED(items->GetElement(i, &item)) || !item) { + continue; } - return 0; - } - if (wParam == VK_DOWN) { - if (!pThis->m_filteredTabs.empty()) { - pThis->m_selectedIndex = (pThis->m_selectedIndex + 1) % pThis->m_filteredTabs.size(); - InvalidateRect(hwnd, nullptr, FALSE); + + TabEntry tab; + + BSTR name = nullptr; + if (SUCCEEDED(item->get_CachedName(&name)) && name) { + tab.title.assign(name, SysStringLen(name)); + SysFreeString(name); } - return 0; - } - if (wParam == VK_UP) { - if (!pThis->m_filteredTabs.empty()) { - if (pThis->m_selectedIndex == 0) pThis->m_selectedIndex = pThis->m_filteredTabs.size() - 1; - else pThis->m_selectedIndex--; - InvalidateRect(hwnd, nullptr, FALSE); + if (tab.title.empty()) { + tab.title = L"(untitled)"; } - return 0; - } - if (wParam == VK_BACK) { - if (!pThis->m_filterText.empty()) { - pThis->m_filterText.pop_back(); - pThis->ApplyFilter(); - InvalidateRect(hwnd, nullptr, FALSE); + + VARIANT selected; + VariantInit(&selected); + if (SUCCEEDED(item->GetCachedPropertyValue( + UIA_SelectionItemIsSelectedPropertyId, &selected)) && + selected.vt == VT_BOOL) { + tab.active = selected.boolVal != VARIANT_FALSE; } - return 0; + VariantClear(&selected); + + tab.site = GetSiteName(tab.title); + tab.searchText = ToLower(tab.title); + tab.element = std::move(item); + m_tabs.push_back(std::move(tab)); } - break; + } + } - case WM_CHAR: - if (wParam >= 32 && wParam != 127) { - pThis->m_filterText.push_back((wchar_t)wParam); - pThis->ApplyFilter(); - InvalidateRect(hwnd, nullptr, FALSE); - return 0; + // Tabs of the same site share the position of the first one of them. + std::unordered_map firstTabOfSite; + for (size_t i = 0; i < m_tabs.size(); i++) { + TabEntry& tab = m_tabs[i]; + tab.groupOrder = i; + if (!tab.site.empty()) { + auto [it, inserted] = firstTabOfSite.try_emplace(ToLower(tab.site), i); + tab.groupOrder = it->second; + } + } + + Wh_Log(L"Found %d tabs", static_cast(m_tabs.size())); +} + +// Returns the tab strips of a browser window, found with a breadth-first +// search which skips web page content. +std::vector> TabSwitcher::FindTabStrips( + IUIAutomationElement* window) { + std::vector> tabStrips; + + std::deque, int>> queue; + queue.emplace_back(window, 0); + int visitedNodes = 0; + + while (!queue.empty() && visitedNodes < kTabStripMaxNodes) { + auto [element, depth] = std::move(queue.front()); + queue.pop_front(); + visitedNodes++; + + ComPtr children; + if (FAILED(element->FindAllBuildCache( + TreeScope_Children, m_trueCondition.Get(), + m_controlTypeCache.Get(), &children)) || + !children) { + continue; + } + + int count = 0; + children->get_Length(&count); + for (int i = 0; i < count; i++) { + ComPtr child; + if (FAILED(children->GetElement(i, &child)) || !child) { + continue; } - break; - case WM_LBUTTONDOWN: { - int y = HIWORD(lParam); - int rowStart = 70; - int rowHeight = 44; - if (y >= rowStart) { - size_t clickedIndex = (y - rowStart) / rowHeight; - if (clickedIndex < pThis->m_filteredTabs.size()) { - pThis->m_selectedIndex = clickedIndex; - pThis->ActivateSelectedTab(); - } + CONTROLTYPEID type = 0; + child->get_CachedControlType(&type); + if (type == UIA_TabControlTypeId) { + tabStrips.push_back(std::move(child)); + } else if (type != UIA_DocumentControlTypeId && + !IsLeafControlType(type) && + depth + 1 < kTabStripMaxDepth) { + queue.emplace_back(std::move(child), depth + 1); } - return 0; } + } - case WM_PAINT: { - PAINTSTRUCT ps; - HDC hdc = BeginPaint(hwnd, &ps); - pThis->Render(hdc); - EndPaint(hwnd, &ps); - return 0; - } + return tabStrips; +} + +void TabSwitcher::ApplyFilter() { + std::vector words = SplitWords(ToLower(m_filter)); + + m_visible.clear(); + for (size_t i = 0; i < m_tabs.size(); i++) { + const std::wstring& text = m_tabs[i].searchText; + bool matches = std::all_of( + words.begin(), words.end(), [&text](const std::wstring& word) { + return text.find(word) != std::wstring::npos; + }); + if (matches) { + m_visible.push_back(i); } + } - return DefWindowProcW(hwnd, uMsg, wParam, lParam); - } - - void Render(HDC hdc) { - RECT rc; - GetClientRect(m_hwnd, &rc); - int w = rc.right - rc.left; - int h = rc.bottom - rc.top; - - HDC memDC = CreateCompatibleDC(hdc); - HBITMAP memBmp = CreateCompatibleBitmap(hdc, w, h); - HBITMAP oldBmp = (HBITMAP)SelectObject(memDC, memBmp); - - // Dark background - HBRUSH bgBrush = CreateSolidBrush(RGB(24, 24, 28)); - FillRect(memDC, &rc, bgBrush); - DeleteObject(bgBrush); - - SetBkMode(memDC, TRANSPARENT); - HFONT hFontMain = CreateFontW(17, 0, 0, 0, FW_SEMIBOLD, FALSE, FALSE, FALSE, - DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH, L"Segoe UI"); - HFONT hFontSub = CreateFontW(13, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, - DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH, L"Segoe UI"); - HFONT hFontHeader = CreateFontW(18, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, - DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH, L"Segoe UI"); - - // Header / Search Bar - RECT rcSearch = { 16, 14, w - 16, 52 }; - HBRUSH searchBg = CreateSolidBrush(RGB(36, 36, 42)); - FillRect(memDC, &rcSearch, searchBg); - DeleteObject(searchBg); - - SelectObject(memDC, hFontMain); - SetTextColor(memDC, RGB(220, 225, 235)); - std::wstring prompt = m_filterText.empty() ? L"Type to search tabs... (Alt+` or Alt+Q to cycle)" : (L"Search: " + m_filterText); - if (m_filterText.empty()) SetTextColor(memDC, RGB(130, 135, 145)); - RECT rcSearchText = { rcSearch.left + 12, rcSearch.top + 8, rcSearch.right - 12, rcSearch.bottom }; - DrawTextW(memDC, prompt.c_str(), -1, &rcSearchText, DT_LEFT | DT_VCENTER | DT_SINGLELINE); - - // Tab list - int y = 66; - int rowHeight = 44; - for (size_t i = 0; i < m_filteredTabs.size() && y < h - 40; ++i) { - RECT rowRc = { 12, y, w - 12, y + rowHeight }; - bool isSelected = (i == m_selectedIndex); - - if (isSelected) { - HBRUSH selBrush = CreateSolidBrush(RGB(48, 68, 120)); - FillRect(memDC, &rowRc, selBrush); - DeleteObject(selBrush); - } + if (g_settings.groupBySite) { + std::stable_sort(m_visible.begin(), m_visible.end(), + [this](size_t a, size_t b) { + return m_tabs[a].groupOrder < m_tabs[b].groupOrder; + }); + } + + m_selected = 0; + m_scroll = 0; +} + +void TabSwitcher::MoveSelection(int delta, bool wrap) { + int count = static_cast(m_visible.size()); + if (count == 0) { + return; + } + + int selected = static_cast(m_selected) + delta; + if (wrap) { + selected = ((selected % count) + count) % count; + } else { + selected = std::clamp(selected, 0, count - 1); + } + + m_selected = static_cast(selected); + EnsureSelectionVisible(); + InvalidateRect(m_window, nullptr, FALSE); +} + +void TabSwitcher::ScrollBy(int rows) { + int maxScroll = std::max( + 0, static_cast(m_visible.size()) - GetVisibleRowCount()); + int scroll = + std::clamp(static_cast(m_scroll) + rows, 0, maxScroll); + m_scroll = static_cast(scroll); + InvalidateRect(m_window, nullptr, FALSE); +} + +void TabSwitcher::EnsureSelectionVisible() { + size_t rows = static_cast(GetVisibleRowCount()); + if (m_selected < m_scroll) { + m_scroll = m_selected; + } else if (m_selected >= m_scroll + rows) { + m_scroll = m_selected - rows + 1; + } +} + +int TabSwitcher::GetVisibleRowCount() const { + RECT client{}; + GetClientRect(m_window, &client); + int listHeight = client.bottom - Scale(kFooterHeight) - Scale(kListTop); + int rowGap = Scale(kRowStride) - Scale(kRowHeight); + return std::max(1, (listHeight + rowGap) / Scale(kRowStride)); +} + +// Returns the index into m_visible of the row at the given client coordinate, +// or -1. +int TabSwitcher::GetRowFromPoint(int y) const { + int offset = y - Scale(kListTop); + if (offset < 0 || offset % Scale(kRowStride) >= Scale(kRowHeight)) { + return -1; + } + + int row = offset / Scale(kRowStride); + if (row >= GetVisibleRowCount()) { + return -1; + } + + size_t index = m_scroll + static_cast(row); + if (index >= m_visible.size()) { + return -1; + } + + return static_cast(index); +} + +void TabSwitcher::UpdateDpi(UINT dpi) { + if (!dpi) { + dpi = 96; + } + if (dpi == m_dpi && m_titleFont) { + return; + } + + m_dpi = dpi; + DeleteFonts(); + m_titleFont = CreateFontW(-Scale(15), 0, 0, 0, FW_SEMIBOLD, FALSE, FALSE, + FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, + DEFAULT_PITCH, L"Segoe UI"); + m_smallFont = CreateFontW(-Scale(12), 0, 0, 0, FW_NORMAL, FALSE, FALSE, + FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, + DEFAULT_PITCH, L"Segoe UI"); +} + +void TabSwitcher::DeleteFonts() { + if (m_titleFont) { + DeleteObject(m_titleFont); + m_titleFont = nullptr; + } + if (m_smallFont) { + DeleteObject(m_smallFont); + m_smallFont = nullptr; + } +} + +void TabSwitcher::Paint(HDC hdc) { + RECT client{}; + GetClientRect(m_window, &client); + int width = client.right; + int height = client.bottom; + + HDC dc = CreateCompatibleDC(hdc); + HBITMAP bitmap = CreateCompatibleBitmap(hdc, width, height); + HGDIOBJ oldBitmap = SelectObject(dc, bitmap); + HGDIOBJ oldFont = SelectObject(dc, m_titleFont); + SetBkMode(dc, TRANSPARENT); + + FillSolidRect(dc, client, kBackgroundColor); + + constexpr UINT kTextFlags = + DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS; + + // Search box, with the number of matching tabs on the right. + RECT search{Scale(16), Scale(kSearchTop), width - Scale(16), + Scale(kSearchBottom)}; + FillSolidRect(dc, search, kSearchColor); - // Domain Badge / Title - SelectObject(memDC, hFontMain); - SetTextColor(memDC, isSelected ? RGB(255, 255, 255) : RGB(230, 230, 235)); - RECT titleRc = { rowRc.left + 14, rowRc.top + 4, rowRc.right - 130, rowRc.top + 24 }; - DrawTextW(memDC, m_filteredTabs[i]->title.c_str(), -1, &titleRc, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS); + RECT searchText = search; + InflateRect(&searchText, -Scale(12), 0); - // Domain chip - SelectObject(memDC, hFontSub); - SetTextColor(memDC, isSelected ? RGB(190, 215, 255) : RGB(140, 145, 160)); - RECT domRc = { rowRc.right - 120, rowRc.top + 12, rowRc.right - 14, rowRc.bottom - 12 }; - DrawTextW(memDC, m_filteredTabs[i]->domain.c_str(), -1, &domRc, DT_RIGHT | DT_VCENTER | DT_SINGLELINE); + WCHAR countText[64]; + if (m_filter.empty()) { + swprintf_s(countText, m_tabs.size() == 1 ? L"%d tab" : L"%d tabs", + static_cast(m_tabs.size())); + } else { + swprintf_s(countText, L"%d of %d", static_cast(m_visible.size()), + static_cast(m_tabs.size())); + } + SelectObject(dc, m_smallFont); + SetTextColor(dc, kDimTextColor); + DrawTextW(dc, countText, -1, &searchText, kTextFlags | DT_RIGHT); + searchText.right -= Scale(90); + + SelectObject(dc, m_titleFont); + if (m_filter.empty()) { + SetTextColor(dc, kDimTextColor); + DrawTextW(dc, L"Type to search tabs", -1, &searchText, kTextFlags); + } else { + SetTextColor(dc, kTextColor); + DrawTextW(dc, m_filter.c_str(), static_cast(m_filter.size()), + &searchText, kTextFlags); + + SIZE textSize{}; + GetTextExtentPoint32W(dc, m_filter.c_str(), + static_cast(m_filter.size()), &textSize); + LONG caretX = + std::min(searchText.left + textSize.cx + Scale(2), searchText.right); + RECT caret{caretX, search.top + Scale(10), + caretX + std::max(1, Scale(1)), search.bottom - Scale(10)}; + FillSolidRect(dc, caret, kAccentColor); + } - y += rowHeight + 2; + // Tab list. + int listBottom = height - Scale(kFooterHeight); + int rows = GetVisibleRowCount(); + int y = Scale(kListTop); + for (size_t i = m_scroll; + i < m_visible.size() && i < m_scroll + static_cast(rows); + i++, y += Scale(kRowStride)) { + const TabEntry& tab = m_tabs[m_visible[i]]; + bool selected = i == m_selected; + + RECT row{Scale(12), y, width - Scale(12), y + Scale(kRowHeight)}; + if (selected) { + FillSolidRect(dc, row, kSelectionColor); } - // Footer hint - SelectObject(memDC, hFontSub); - SetTextColor(memDC, RGB(120, 125, 135)); - RECT ftRc = { 16, h - 28, w - 16, h - 6 }; - DrawTextW(memDC, L"[Tab / \u2191\u2193] Navigate [Enter] Switch Tab [Esc] Close", -1, &ftRc, DT_CENTER | DT_VCENTER | DT_SINGLELINE); - - DeleteObject(hFontMain); - DeleteObject(hFontSub); - DeleteObject(hFontHeader); - - BitBlt(hdc, 0, 0, w, h, memDC, 0, 0, SRCCOPY); - SelectObject(memDC, oldBmp); - DeleteObject(memBmp); - DeleteDC(memDC); - } - - HWND m_hwnd = nullptr; - HWND m_targetBrowserHwnd = nullptr; - ULONGLONG m_openTime = 0; - std::wstring m_browserTitle; - std::wstring m_filterText; - size_t m_selectedIndex = 0; - std::vector> m_allTabs; - std::vector> m_filteredTabs; -}; + if (tab.active) { + RECT marker{row.left, row.top + Scale(12), row.left + Scale(3), + row.bottom - Scale(12)}; + FillSolidRect(dc, marker, kAccentColor); + } -// --- KEYBOARD HOOK & THREAD --- -static HANDLE g_hThread = nullptr; -static DWORD g_dwThreadId = 0; -static HHOOK g_hKbdHook = nullptr; - -static LRESULT CALLBACK LowLevelKbdHookProc(int nCode, WPARAM wParam, LPARAM lParam) { - if (nCode == HC_ACTION && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN)) { - auto* kbd = (KBDLLHOOKSTRUCT*)lParam; - bool altDown = ((kbd->flags & LLKHF_ALTDOWN) != 0) || ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0); - if (altDown) { - // VK_OEM_3: ` ~ (above Tab on standard US keyboard) - // 'Q' / 'q': Q (adjacent to Tab, universal on all physical layouts) - // VK_OEM_5: \ | (above Tab on European/ISO layouts) - if (kbd->vkCode == VK_OEM_3 || kbd->vkCode == 'Q' || kbd->vkCode == 'q' || kbd->vkCode == VK_OEM_5) { - HWND hHUD = TabSwitcherHUD::Instance().GetHwnd(); - if (hHUD && IsWindow(hHUD)) { - PostMessageW(hHUD, WM_APP + 10, 0, 0); - return 1; // Consume key - } - } + RECT titleRect{row.left + Scale(14), row.top, row.right - Scale(14), + row.bottom}; + if (!tab.site.empty()) { + RECT siteRect{row.right - Scale(kSiteWidth), row.top, + row.right - Scale(14), row.bottom}; + SelectObject(dc, m_smallFont); + SetTextColor(dc, selected ? kSelectedSiteColor : kSiteColor); + DrawTextW(dc, tab.site.c_str(), static_cast(tab.site.size()), + &siteRect, kTextFlags | DT_RIGHT); + titleRect.right = siteRect.left - Scale(10); } + + SelectObject(dc, m_titleFont); + SetTextColor(dc, selected ? kSelectedTextColor : kTextColor); + DrawTextW(dc, tab.title.c_str(), static_cast(tab.title.size()), + &titleRect, kTextFlags); + } + + if (m_visible.empty()) { + RECT message{Scale(16), Scale(kListTop), width - Scale(16), listBottom}; + SelectObject(dc, m_titleFont); + SetTextColor(dc, kDimTextColor); + DrawTextW(dc, + m_tabs.empty() ? L"No tabs found in this window" + : L"No matching tabs", + -1, &message, kTextFlags | DT_CENTER); + } + + // Scroll bar. + size_t visibleCount = m_visible.size(); + if (visibleCount > static_cast(rows)) { + int trackTop = Scale(kListTop); + int trackHeight = rows * Scale(kRowStride) - (Scale(kRowStride) - + Scale(kRowHeight)); + int thumbHeight = std::max( + Scale(20), MulDiv(trackHeight, rows, static_cast(visibleCount))); + int maxScroll = static_cast(visibleCount) - rows; + int thumbTop = trackTop + MulDiv(trackHeight - thumbHeight, + static_cast(m_scroll), maxScroll); + RECT thumb{width - Scale(8), thumbTop, width - Scale(5), + thumbTop + thumbHeight}; + FillSolidRect(dc, thumb, kScrollColor); } - return CallNextHookEx(nullptr, nCode, wParam, lParam); + + // Footer. + RECT footer{Scale(16), listBottom, width - Scale(16), height - Scale(6)}; + SelectObject(dc, m_smallFont); + SetTextColor(dc, kDimTextColor); + DrawTextW(dc, + L"↑↓ Navigate Enter Switch Esc Close", + -1, &footer, kTextFlags | DT_CENTER); + + BitBlt(hdc, 0, 0, width, height, dc, 0, 0, SRCCOPY); + + SelectObject(dc, oldFont); + SelectObject(dc, oldBitmap); + DeleteObject(bitmap); + DeleteDC(dc); } -DWORD WINAPI HUDThreadProc(LPVOID lpParam) { - HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); - Wh_Log(L"AltTabs: Worker thread started, CoInitializeEx hr=0x%08X", (DWORD)hr); +bool IsHotkey(const KBDLLHOOKSTRUCT* key) { + // Q, and the key above Tab on US layouts. + if (key->vkCode != 'Q' && key->vkCode != VK_OEM_3) { + return false; + } + + if (!(key->flags & LLKHF_ALTDOWN)) { + return false; + } - TabSwitcherHUD::Instance().CreateHUDWindow(); + // Ctrl+Alt is also AltGr, which types characters on many layouts, e.g. + // AltGr+Q is @ on German keyboards. + if (GetAsyncKeyState(VK_CONTROL) < 0 || GetAsyncKeyState(VK_LWIN) < 0 || + GetAsyncKeyState(VK_RWIN) < 0) { + return false; + } - HINSTANCE hInst = HINST_THISCOMPONENT; - if (!hInst) { - GetModuleHandleExW( - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (LPCWSTR)LowLevelKbdHookProc, - &hInst - ); + return true; +} + +LRESULT CALLBACK LowLevelKeyboardProc(int code, WPARAM wParam, LPARAM lParam) { + if (code == HC_ACTION && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN)) { + const auto* key = reinterpret_cast(lParam); + HWND switcherWindow = g_switcherWindow; + if (switcherWindow && IsHotkey(key)) { + HWND foreground = GetForegroundWindow(); + HWND root = + foreground ? GetAncestor(foreground, GA_ROOTOWNER) : nullptr; + if (foreground == switcherWindow || IsEnabledBrowserWindow(root)) { + BOOL backwards = GetAsyncKeyState(VK_SHIFT) < 0; + PostMessageW(switcherWindow, g_hotkeyMessage, backwards, 0); + return 1; + } + } } - g_hKbdHook = SetWindowsHookExW( - WH_KEYBOARD_LL, - LowLevelKbdHookProc, - hInst, - 0 - ); + return CallNextHookEx(nullptr, code, wParam, lParam); +} - if (g_hKbdHook) { - Wh_Log(L"AltTabs: Low-level keyboard hook installed successfully (hInst=0x%p)", hInst); - } else { - DWORD err = GetLastError(); - Wh_Log(L"AltTabs: FAILED to install keyboard hook, err=%lu. Retrying with NULL module...", err); - g_hKbdHook = SetWindowsHookExW(WH_KEYBOARD_LL, LowLevelKbdHookProc, nullptr, 0); - if (g_hKbdHook) { - Wh_Log(L"AltTabs: Keyboard hook installed with NULL module."); - } else { - Wh_Log(L"AltTabs: Critical failure installing keyboard hook err=%lu", GetLastError()); +// Owns the switcher window and does the UI Automation work. +DWORD WINAPI SwitcherThreadProc(LPVOID param) { + HANDLE readyEvent = param; + + HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + if (FAILED(hr)) { + Wh_Log(L"CoInitializeEx failed: 0x%08X", hr); + SetEvent(readyEvent); + return 0; + } + + { + TabSwitcher switcher; + // g_threadStartOk is reused for the next thread once the event is set, + // so the result is also kept in a local variable. + bool startOk = switcher.Init(); + if (startOk) { + g_switcherWindow = switcher.Window(); + } + g_threadStartOk = startOk; + SetEvent(readyEvent); + + if (startOk) { + MSG msg; + while (GetMessageW(&msg, nullptr, 0, 0) > 0) { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } } + + g_switcherWindow = nullptr; + switcher.Uninit(); } + CoUninitialize(); + return 0; +} + +// Only runs the keyboard hook, so that it's never blocked by the UI +// Automation calls of the switcher thread. +DWORD WINAPI HookThreadProc(LPVOID param) { + HANDLE readyEvent = param; + + // Create the message queue before WhTool_ModUninit can post WM_QUIT. MSG msg; - while (GetMessageW(&msg, nullptr, 0, 0)) { + PeekMessageW(&msg, nullptr, WM_USER, WM_USER, PM_NOREMOVE); + + HHOOK hook = SetWindowsHookExW(WH_KEYBOARD_LL, LowLevelKeyboardProc, + HINST_THISCOMPONENT, 0); + if (!hook) { + Wh_Log(L"SetWindowsHookExW failed: %u", GetLastError()); + } + + g_threadStartOk = hook != nullptr; + SetEvent(readyEvent); + if (!hook) { + return 0; + } + + while (GetMessageW(&msg, nullptr, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessageW(&msg); } - if (g_hKbdHook) { - UnhookWindowsHookEx(g_hKbdHook); - g_hKbdHook = nullptr; + UnhookWindowsHookEx(hook); + return 0; +} + +// Starts a thread and waits until it signals whether it started successfully. +HANDLE StartThread(LPTHREAD_START_ROUTINE threadProc, DWORD* threadId) { + HANDLE readyEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr); + if (!readyEvent) { + return nullptr; } - TabSwitcherHUD::Instance().DestroyHUDWindow(); - CoUninitialize(); - Wh_Log(L"AltTabs: Worker thread exiting."); - return 0; + g_threadStartOk = false; + HANDLE thread = + CreateThread(nullptr, 0, threadProc, readyEvent, 0, threadId); + if (thread) { + // The thread sets the event on every path. + WaitForSingleObject(readyEvent, INFINITE); + if (!g_threadStartOk) { + WaitForSingleObject(thread, INFINITE); + CloseHandle(thread); + thread = nullptr; + } + } + + CloseHandle(readyEvent); + return thread; +} + +void StopSwitcherThread() { + if (!g_switcherThread) { + return; + } + + HWND switcherWindow = g_switcherWindow; + if (switcherWindow) { + PostMessageW(switcherWindow, g_quitMessage, 0, 0); + } + WaitForSingleObject(g_switcherThread, INFINITE); + CloseHandle(g_switcherThread); + g_switcherThread = nullptr; } -} // namespace AltTabsMod +} // namespace -// --- WINDHAWK TOOL MOD ENTRY POINTS --- BOOL WhTool_ModInit() { - Wh_Log(L"Initializing AltTabs Browser HUD Mod..."); - AltTabsMod::LoadSettings(); - AltTabsMod::g_hThread = CreateThread(nullptr, 0, AltTabsMod::HUDThreadProc, nullptr, 0, &AltTabsMod::g_dwThreadId); - if (!AltTabsMod::g_hThread) { - Wh_Log(L"AltTabs: Failed to create worker thread, err=%lu", GetLastError()); + LoadSettings(); + + g_hotkeyMessage = RegisterWindowMessageW(L"AltTabs_Hotkey_" WH_MOD_ID); + g_quitMessage = RegisterWindowMessageW(L"AltTabs_Quit_" WH_MOD_ID); + if (!g_hotkeyMessage || !g_quitMessage) { + Wh_Log(L"RegisterWindowMessageW failed: %u", GetLastError()); + return FALSE; + } + + g_switcherThread = StartThread(SwitcherThreadProc, nullptr); + if (!g_switcherThread) { + Wh_Log(L"Starting the switcher thread failed"); + return FALSE; + } + + g_hookThread = StartThread(HookThreadProc, &g_hookThreadId); + if (!g_hookThread) { + Wh_Log(L"Starting the keyboard hook thread failed"); + StopSwitcherThread(); return FALSE; } - Wh_Log(L"AltTabs Browser HUD Mod loaded successfully."); + return TRUE; } void WhTool_ModUninit() { - Wh_Log(L"Unloading AltTabs Browser HUD Mod..."); - if (AltTabsMod::g_dwThreadId != 0) { - PostThreadMessageW(AltTabsMod::g_dwThreadId, WM_QUIT, 0, 0); + if (g_hookThread) { + PostThreadMessageW(g_hookThreadId, WM_QUIT, 0, 0); + WaitForSingleObject(g_hookThread, INFINITE); + CloseHandle(g_hookThread); + g_hookThread = nullptr; } - if (AltTabsMod::g_hThread) { - WaitForSingleObject(AltTabsMod::g_hThread, 3000); - CloseHandle(AltTabsMod::g_hThread); - AltTabsMod::g_hThread = nullptr; - } - Wh_Log(L"AltTabs Browser HUD Mod unloaded."); + + StopSwitcherThread(); } void WhTool_ModSettingsChanged() { - Wh_Log(L"Settings updated for AltTabs Browser HUD Mod."); - AltTabsMod::LoadSettings(); + LoadSettings(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/README.md b/README.md index 4b57e9d..f595cd8 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Summon instantly with **`Alt + Q`** or **`Alt + ` `**, search in real time, and

- AltTabs Interface Preview
+ The AltTabs switcher listing browser tabs, with GitHub tabs grouped together
🎬 Watch 1080p Video Demonstration (assets/demo.mp4) • 🎮 Interactive Browser Demo (demo.html)

@@ -29,7 +29,7 @@ Summon instantly with **`Alt + Q`** or **`Alt + ` `**, search in real time, and --- > [!NOTE] -> **AltTabs is an in-browser tab switcher HUD**, not a replacement for the Windows application Alt+Tab window switcher. It is designed specifically to solve tab overload inside Chromium browsers (**Brave**, **Google Chrome**, **Microsoft Edge**, **Opera**, and **Vivaldi**) without injecting into Explorer or altering web pages. +> **AltTabs is an in-browser tab switcher HUD**, not a replacement for the Windows application Alt+Tab window switcher. It is designed specifically to solve tab overload inside Chromium browsers (**Brave**, **Google Chrome**, **Microsoft Edge**, and **Opera**) without injecting into Explorer or altering web pages. --- @@ -44,7 +44,7 @@ Power users and developers frequently keep dozens of tabs open across research, ### The Solution: AltTabs **AltTabs** runs as an isolated, native Win32 tool mod via [Windhawk](https://windhawk.net/). When you press **`Alt + Q`** or **`Alt + ` `**: 1. A sleek, centered dark HUD immediately floats over your active browser window. -2. It displays all open tabs with their titles and root domain tags (`github.com`, `youtube.com`). +2. It displays all open tabs of that window with their titles and the site name from the end of each title (`GitHub`, `YouTube`). 3. You can instantly filter the list by typing keywords or navigate with **`Tab`** / **`Arrow Keys`**. 4. Pressing **`Enter`** brings the target tab into view immediately. @@ -54,9 +54,9 @@ Power users and developers frequently keep dozens of tabs open across research, ├────────────────────────────────────────────────────────────────────────┤ │ 🔍 Search: git │ ├────────────────────────────────────────────────────────────────────────┤ -│ > Dszae/AltTabs: Browser Tab Switcher HUD github.com │ -│ Issue #12: Support vertical tab strips github.com │ -│ Pull Request #6964: Add AltTabs Mod github.com │ +│ > Issues · Dszae/AltTabs · GitHub GitHub │ +│ Actions · Dszae/AltTabs · GitHub GitHub │ +│ Pull requests · ramensoftware/windhawk-mods · GitHub GitHub │ ├────────────────────────────────────────────────────────────────────────┤ │ [Tab / ↑↓] Navigate [Enter] Switch Tab [Esc] Close │ └────────────────────────────────────────────────────────────────────────┘ @@ -66,10 +66,10 @@ Power users and developers frequently keep dozens of tabs open across research, ## ✨ Features -- **⚡ Instant Keyboard Activation**: Summon the switcher with **`Alt + Q`** (universal across all physical keyboard layouts) or **`Alt + ` `** (key directly above Tab). -- **🔍 Real-Time Fuzzy Filter**: Simply start typing any keyword to narrow down dozens of open tabs in milliseconds. -- **🏷️ Root Domain Tagging**: Automatically detects and groups titles by website domain (`github.com`, `stackoverflow.com`, `reddit.com`) for rapid visual scanning. -- **🎨 Windows 11 Fluent Aesthetics**: Uses DWM dark mode, rounded corners (`DWMWCP_ROUND`), ClearType Segoe UI typography, and double-buffered GDI rendering. +- **⚡ Instant Keyboard Activation**: Summon the switcher with **`Alt + Q`** or **`Alt + ` `** (the key above Tab on US layouts). The hotkeys are only taken over while a supported browser is focused, so other apps keep them. +- **🔍 Real-Time Filter**: Start typing to narrow down dozens of open tabs. Several words match tabs that contain all of them, in any order. +- **🏷️ Site Labels & Grouping**: Shows the site name from the end of each tab title (`GitHub`, `Stack Overflow`, `YouTube`) and can list the tabs of each site together. Browsers don't expose tab addresses to other apps, so the label comes from the title. +- **🎨 Windows 11 Fluent Aesthetics**: Uses DWM dark mode, rounded corners (`DWMWCP_ROUND`), ClearType Segoe UI typography, double-buffered GDI rendering, and scales with the display's DPI. - **🔒 100% Offline & Private**: Zero telemetry, zero analytics, zero external network traffic. Everything executes strictly in local memory. - **🪶 Zero Background Impact**: Uses a non-polling event model. Consumes **0% CPU** and **< 8 MB RAM** when idle. - **🛡️ Clean Separation**: Runs inside an isolated Windhawk tool process. Does not inject hooks into `explorer.exe` or modify webpage DOM content. @@ -121,14 +121,15 @@ All controls are active whenever the AltTabs HUD is open: | Shortcut | Action | Description | | :--- | :--- | :--- | -| **`Alt + Q`** | **Summon / Cycle** | Summons the HUD over your browser. Tap repeatedly to cycle tabs. | -| **`Alt + ` ` / `Alt + ~`** | **Alternative Summon** | Secondary trigger using the backtick key directly above Tab. | +| **`Alt + Q`** | **Summon / Cycle** | Summons the HUD over your browser. Tap repeatedly to cycle tabs, add `Shift` to cycle backwards. | +| **`Alt + ` ` / `Alt + ~`** | **Alternative Summon** | Same as `Alt + Q`, using the key above Tab on US layouts. | | **`Tab`** or **`↓ Down Arrow`** | **Next Tab** | Moves selection down by one row. | | **`Shift + Tab`** or **`↑ Up Arrow`** | **Previous Tab** | Moves selection up by one row. | +| **`Page Down`** / **`Page Up`** | **Next / Previous Page** | Moves selection by one page of rows. | | **Any Character Key (`a-z`, `0-9`)** | **Filter / Search** | Types directly into the search bar, filtering visible tabs instantly. | -| **`Backspace`** | **Delete Character** | Removes the last typed filter character. | +| **`Backspace`** / **`Ctrl + Backspace`** | **Delete / Clear** | Removes the last typed character, or clears the filter. | | **`Enter`** | **Activate Tab** | Switches to the selected tab and dismisses the HUD. | -| **Left Click** | **Mouse Selection** | Direct click on any row activates that tab immediately. | +| **Left Click** / **Mouse Wheel** | **Mouse Selection** | Click a row to switch to that tab, scroll the wheel to scroll the list. | | **`Esc`** | **Dismiss** | Closes the HUD without changing the active tab. | --- @@ -140,10 +141,10 @@ AltTabs targets the standard Chromium Views accessibility tree (`Chrome_WidgetWi | Browser | Status | Verification Details | | :--- | :---: | :--- | | **Brave Browser** | ✅ **Verified** | Fully tested and verified on Windows 11. Tab strip enumeration and selection verified. | -| **Google Chrome** | ✅ **Supported** | Standard Chromium Views architecture (`Chrome_WidgetWin_1`). | -| **Microsoft Edge** | ✅ **Supported** | Standard Chromium Views architecture (`Chrome_WidgetWin_1`). | -| **Opera** | 🟡 **Expected** | Uses Chromium Views; community testing in progress. | -| **Vivaldi** | 🟡 **Expected** | Uses Chromium Views; community testing in progress. | +| **Google Chrome** | ✅ **Verified** | Tab strip enumeration verified (`TabContainer`). | +| **Microsoft Edge** | ✅ **Verified** | Tab strip enumeration verified (`EdgeTabStripRegionView`). | +| **Opera** | 🟡 **Untested** | Uses Chromium Views; community testing welcome. | +| **Vivaldi** | ❌ **Unsupported** | Vivaldi's tab bar is part of a web page, not a native tab strip. | | **Mozilla Firefox** | ❌ **Unsupported** | Uses Gecko XUL rendering engine (`MozillaWindowClass`), not Chromium Views. | --- @@ -161,12 +162,12 @@ sequenceDiagram participant UIA as Windows UI Automation (CUIAutomation) participant Browser as Browser Window (Chrome_WidgetWin_1) - User->>Hook: Presses Alt+Q or Alt+` - Hook->>HUD: PostMessage(WM_APP + 10) [Non-blocking <0.1ms] - HUD->>Browser: SendMessageTimeout(WM_GETOBJECT) [Ensures accessibility tree is awake] - HUD->>UIA: ElementFromHandle + FindAll(TreeScope_Descendants, UIA_TabItemControlTypeId) - Browser-->>UIA: Returns tab elements (names, bounds) - HUD->>HUD: Parse root domains + apply filter + User->>Hook: Presses Alt+Q or Alt+` in a browser + Hook->>HUD: PostMessage(registered hotkey message) [Non-blocking] + HUD->>UIA: ElementFromHandle + breadth-first search for the tab strip, skipping web content + UIA->>Browser: FindAllBuildCache(TabItem) inside the tab strip + Browser-->>UIA: Returns tab elements (names, selection state) + HUD->>HUD: Read site names + group + apply filter HUD-->>User: Displays Centered Double-Buffered HUD User->>HUD: Types filter query / presses Tab / Enter HUD->>Browser: IUIAutomationSelectionItemPattern::Select() @@ -178,16 +179,14 @@ sequenceDiagram Runs as a standalone tool process rather than injecting DLL code into `explorer.exe` or third-party web browsers. This eliminates Explorer stability risks. 2. **DLL Module Binding for Hooks**: The `WH_KEYBOARD_LL` hook is installed using `HINST_THISCOMPONENT` (`&__ImageBase`), ensuring the Windows hook manager accepts the hook procedure without rejecting `windhawk.exe` as an invalid module. -3. **Dedicated COM Worker Thread**: - Runs its own Win32 message loop with `CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)`. Heavy UIA calls never block the low-level keyboard hook callback. -4. **Resilient Window Activation**: - Tab activation uses a 4-tier fallback: - - `IUIAutomationSelectionItemPattern::Select()` - - `IUIAutomationLegacyIAccessiblePattern::DoDefaultAction()` - - `IUIAutomationInvokePattern::Invoke()` - - Client coordinate mouse click fallback (`WM_LBUTTONDOWN`/`WM_LBUTTONUP`). -5. **Guaranteed Display Fallback**: - If Chromium accessibility takes more than 50ms to populate on first launch, AltTabs captures the active browser window title as a fallback item so the HUD is guaranteed to open visibly on every keystroke. +3. **Separate Hook and UI Automation Threads**: + The `WH_KEYBOARD_LL` hook runs on its own thread that does nothing else, so typing anywhere in Windows is never delayed by UI Automation calls. The HUD and all UIA work live on a second thread with `CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)`, and UIA calls time out after 2 seconds if a browser hangs. +4. **Native Tab Strip Only**: + Tabs are read from the browser's own tab strip, found with a breadth-first search that never descends into web page content. Tab-like widgets inside web pages (ARIA `role="tab"`) aren't listed, and pages aren't crawled. +5. **Window Activation**: + Tab activation uses `IUIAutomationSelectionItemPattern::Select()`, with `IUIAutomationLegacyIAccessiblePattern::DoDefaultAction()` as a fallback. +6. **Accessibility Warm-Up**: + Chromium builds its accessibility tree on the first request, so right after a browser starts, AltTabs retries the tab strip lookup a couple of times before showing "No tabs found". --- @@ -206,16 +205,13 @@ We believe system utilities should be completely transparent: AltTabs is built for zero perceptible latency: - **Idle Resource Usage**: 0.0% CPU, < 8 MB private working set. -- **Activation Latency**: < 15ms from keypress to HUD paint on modern systems. +- **Activation Latency**: Reading the tab strip takes about 30-100 ms in Brave, Chrome and Edge. ### How to Verify Locally: 1. Open **Windhawk** and navigate to the **AltTabs** mod page. -2. Click the **Log** tab to view real-time timing and enumeration logs generated via `Wh_Log`: +2. Click the **Log** tab to view the enumeration logs generated via `Wh_Log`: ```text - AltTabs: Worker thread started, CoInitializeEx hr=0x00000000 - AltTabs: Low-level keyboard hook installed successfully - AltTabs: Found 24 UIA tab items in browser hwnd=0x000508B2 - AltTabs: HUD displayed for browser hwnd=0x000508B2 (Brave) with 24 tabs + Found 24 tabs ``` 3. Open **Windows Task Manager** $\rightarrow$ **Details**, locate the `windhawk.exe` process with command-line `-tool-mod "chromium-alttab-tabs"`, and observe memory and CPU remain at 0% when idle. @@ -225,9 +221,10 @@ AltTabs is built for zero perceptible latency: - [x] **v1.1.0**: Standalone floating HUD with Win32 rounded corners & dark mode. - [x] **v1.1.1**: Dual universal hotkeys (`Alt + Q` and `Alt + ` `), COM apartment fixes, and guaranteed fallback display. -- [ ] **v1.2.0**: User-configurable hotkey selector in Windhawk mod settings UI. -- [ ] **v1.3.0**: Favicon rendering extracted directly from Chromium cache. -- [ ] **v1.4.0**: Multi-window tab switching (switch across all open browser windows simultaneously). +- [x] **v1.2.0**: Native tab strip only, separate hook thread, site grouping, scrolling, DPI scaling, and browser-only hotkeys. +- [ ] **v1.3.0**: User-configurable hotkey selector in Windhawk mod settings UI. +- [ ] **v1.4.0**: Favicon rendering. +- [ ] **v1.5.0**: Multi-window tab switching (switch across all open browser windows simultaneously). --- @@ -263,12 +260,12 @@ Windows 11's Alt-Tab switcher is controlled by XamlExplorerHost.exe
Can I change the keyboard shortcut? -Yes. In ChromiumAltTabInjector.wh.cpp, locate LowLevelKbdHookProc and adjust the virtual key code (e.g., replace 'Q' with your preferred key). A GUI setting for hotkey configuration is planned in an upcoming release. +Yes. In ChromiumAltTabInjector.wh.cpp, locate IsHotkey and adjust the virtual key code (e.g., replace 'Q' with your preferred key). A GUI setting for hotkey configuration is planned in an upcoming release.
Does this work with vertical tabs in Brave or Edge? -Yes! Chromium's UI Automation tree represents tabs as UIA_TabItemControlTypeId regardless of whether tab strips are positioned horizontally or vertically. +It should, since the tabs are found by their UI Automation control type rather than their position, but vertical tabs haven't been tested yet. Reports are welcome.
--- From f360534029e7a257e04f4750d8cf03a644b916c3 Mon Sep 17 00:00:00 2001 From: dsz Date: Tue, 24 Nov 2026 10:51:08 +0545 Subject: [PATCH 3/4] Parenthesize std::min and std::max for MSVC's min/max macros --- ChromiumAltTabInjector.wh.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ChromiumAltTabInjector.wh.cpp b/ChromiumAltTabInjector.wh.cpp index ead9b22..38e4c43 100644 --- a/ChromiumAltTabInjector.wh.cpp +++ b/ChromiumAltTabInjector.wh.cpp @@ -699,9 +699,9 @@ void TabSwitcher::Show(HWND browser) { LONG x = (browserRect.left + browserRect.right - width) / 2; LONG y = (browserRect.top + browserRect.bottom - height) / 2; x = std::clamp(x, workArea.left, - std::max(workArea.left, workArea.right - width)); + (std::max)(workArea.left, workArea.right - width)); y = std::clamp(y, workArea.top, - std::max(workArea.top, workArea.bottom - height)); + (std::max)(workArea.top, workArea.bottom - height)); m_shownTime = GetTickCount64(); SetWindowPos(m_window, HWND_TOPMOST, x, y, width, height, @@ -937,7 +937,7 @@ void TabSwitcher::MoveSelection(int delta, bool wrap) { } void TabSwitcher::ScrollBy(int rows) { - int maxScroll = std::max( + int maxScroll = (std::max)( 0, static_cast(m_visible.size()) - GetVisibleRowCount()); int scroll = std::clamp(static_cast(m_scroll) + rows, 0, maxScroll); @@ -959,7 +959,7 @@ int TabSwitcher::GetVisibleRowCount() const { GetClientRect(m_window, &client); int listHeight = client.bottom - Scale(kFooterHeight) - Scale(kListTop); int rowGap = Scale(kRowStride) - Scale(kRowHeight); - return std::max(1, (listHeight + rowGap) / Scale(kRowStride)); + return (std::max)(1, (listHeight + rowGap) / Scale(kRowStride)); } // Returns the index into m_visible of the row at the given client coordinate, @@ -1065,9 +1065,9 @@ void TabSwitcher::Paint(HDC hdc) { GetTextExtentPoint32W(dc, m_filter.c_str(), static_cast(m_filter.size()), &textSize); LONG caretX = - std::min(searchText.left + textSize.cx + Scale(2), searchText.right); + (std::min)(searchText.left + textSize.cx + Scale(2), searchText.right); RECT caret{caretX, search.top + Scale(10), - caretX + std::max(1, Scale(1)), search.bottom - Scale(10)}; + caretX + (std::max)(1, Scale(1)), search.bottom - Scale(10)}; FillSolidRect(dc, caret, kAccentColor); } @@ -1126,7 +1126,7 @@ void TabSwitcher::Paint(HDC hdc) { int trackTop = Scale(kListTop); int trackHeight = rows * Scale(kRowStride) - (Scale(kRowStride) - Scale(kRowHeight)); - int thumbHeight = std::max( + int thumbHeight = (std::max)( Scale(20), MulDiv(trackHeight, rows, static_cast(visibleCount))); int maxScroll = static_cast(visibleCount) - rows; int thumbTop = trackTop + MulDiv(trackHeight - thumbHeight, From d9da3bdc4b937fb114fd0c75e9e347758717eb47 Mon Sep 17 00:00:00 2001 From: dsz Date: Tue, 24 Nov 2026 11:09:12 +0545 Subject: [PATCH 4/4] Address the Windhawk AI review, rename the mod ID to alttabs - Rename the mod ID to alttabs, since the mod no longer touches Alt+Tab - Make taking the focus reliable with an empty SendInput, and close the switcher if Windows still refuses the focus - Retry the tab strip search only while the accessibility tree is empty, so windows without a tab strip open right away, and stop on the first UI Automation timeout - Open with the tab after the current one selected - Accumulate small wheel deltas, so touchpad scrolling works - Mention Opera and the browser's accessibility cost in the readme --- CHANGELOG.md | 5 ++ ChromiumAltTabInjector.wh.cpp | 121 +++++++++++++++++++++++++++------- README.md | 4 +- include/windhawk_api.h | 2 +- 4 files changed, 107 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b442d5..5e0df35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.2.0] - 2026-11-24 ### Changed +- **Mod ID**: The Windhawk mod ID is now `alttabs`, since the mod no longer adds tabs to Alt+Tab. If you installed an earlier version as a local mod, remove it after installing this one, so that both don't run. - **Native Tab Strip Only**: Tabs are read from the browser's tab strip with a search that skips web page content. Previously, tab widgets inside web pages could show up as extra entries (e.g. 14 entries for a 5-tab window). - **Browser-Only Hotkeys**: `Alt + Q` and ``Alt + ` `` are only taken over while an enabled browser is focused. `AltGr` (Ctrl+Alt) combinations are left alone, so e.g. `AltGr + Q` still types `@` on German layouts. - **Site Labels**: The label next to a tab is the site name from the end of its title (e.g. `YouTube`), instead of a guessed `.com` domain. @@ -17,10 +18,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Scrolling with the selection, `Page Up` / `Page Down`, the mouse wheel, and a scroll bar. - `Shift + Alt + Q` cycles backwards, `Ctrl + Backspace` clears the filter. - Multi-word filtering, a match count, and a marker for the current tab. +- The switcher opens with the tab after the current one selected, so `Alt + Q`, `Enter` switches to another tab. - DPI scaling, and keeping the switcher inside the browser's monitor. +- Touchpad scrolling. ### Fixed - The keyboard hook runs on its own thread, so UI Automation calls can no longer delay keyboard input system-wide. +- The switcher takes the focus reliably. If Windows still refuses, it closes instead of staying on top without focus. +- Windows without a tab strip, such as app windows, open right away instead of after retries, and a browser that stops responding is given up on after 2 seconds. - `Alt + F2` no longer opens the switcher, and `Alt + \` isn't taken over anymore. - Clicking a row in the lower part of the list selected the wrong tab. - Clicking another app while the switcher was open tried to pull the focus back to the browser. diff --git a/ChromiumAltTabInjector.wh.cpp b/ChromiumAltTabInjector.wh.cpp index 38e4c43..cbe538c 100644 --- a/ChromiumAltTabInjector.wh.cpp +++ b/ChromiumAltTabInjector.wh.cpp @@ -1,5 +1,5 @@ // ==WindhawkMod== -// @id chromium-alttab-tabs +// @id alttabs // @name AltTabs - Browser Tab Switcher HUD // @description Press Alt+Q in Chrome, Edge or Brave to search the open tabs of the window and switch to one with the keyboard // @version 1.2.0 @@ -24,7 +24,7 @@ the arrow keys, and press **Enter** to switch to it. | Key | Action | |-----|--------| -| **Alt+Q** or **Alt+\`** | Open the list. While it's open, press again to move down, or with Shift to move up. | +| **Alt+Q** or **Alt+\`** | Open the list, with the tab after the current one selected. While it's open, press again to move down, or with Shift to move up. | | Typing | Filter the tabs. Several words match tabs that contain all of them. | | **↑** **↓**, **Tab**, **Shift+Tab** | Move the selection | | **Page Up**, **Page Down** | Move the selection by a page | @@ -44,7 +44,11 @@ they work as usual. addresses this way, so the site name next to a tab is taken from the end of its title, for example "YouTube" in "Some video - YouTube". Tabs whose title doesn't end with a site name have no label. -- Vivaldi isn't supported, its tab bar is part of a web page. +- Opera should work too, but hasn't been tested. Vivaldi isn't supported, its + tab bar is part of a web page. +- The first time the list is opened, the browser turns on its accessibility + support, as it does for screen readers. This uses some extra CPU and memory + in the browser while it's on. - The mod runs in its own Windhawk process. It doesn't inject code into the browser or into Explorer. */ @@ -308,6 +312,19 @@ void FillSolidRect(HDC dc, const RECT& rect, COLORREF color) { FillRect(dc, &rect, static_cast(GetStockObject(DC_BRUSH))); } +// The keyboard hook takes the hotkey press, so the tool process didn't get the +// last input, and the foreground lock can make SetForegroundWindow fail. An +// empty input makes it reliable. +bool BringToForeground(HWND hwnd) { + INPUT input{}; + SendInput(1, &input, sizeof(input)); + return SetForegroundWindow(hwnd) != FALSE; +} + +bool IsTimeout(HRESULT hr) { + return hr == static_cast(UIA_E_TIMEOUT); +} + struct TabEntry { std::wstring title; std::wstring site; @@ -344,7 +361,9 @@ class TabSwitcher { void LoadTabs(HWND browser); std::vector> FindTabStrips( - IUIAutomationElement* window); + IUIAutomationElement* window, + bool* treeEmpty, + bool* timedOut); void ApplyFilter(); void MoveSelection(int delta, bool wrap); @@ -377,6 +396,9 @@ class TabSwitcher { std::wstring m_filter; size_t m_selected = 0; size_t m_scroll = 0; + // Wheel movement that hasn't added up to a whole row yet, e.g. from a + // touchpad. + int m_wheelRemainder = 0; }; bool TabSwitcher::Init() { @@ -581,8 +603,13 @@ LRESULT TabSwitcher::HandleMessage(UINT message, WPARAM wParam, LPARAM lParam) { } case WM_MOUSEWHEEL: { - int notches = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; - ScrollBy(-notches * 3); + constexpr int kRowsPerNotch = 3; + m_wheelRemainder += GET_WHEEL_DELTA_WPARAM(wParam) * kRowsPerNotch; + int rows = m_wheelRemainder / WHEEL_DELTA; + m_wheelRemainder -= rows * WHEEL_DELTA; + if (rows) { + ScrollBy(-rows); + } return 0; } @@ -658,7 +685,7 @@ void TabSwitcher::OnHotkey(bool backwards) { if (m_shownTime) { if (GetForegroundWindow() != m_window) { // Focus was lost during the grace period, take it back. - SetForegroundWindow(m_window); + BringToForeground(m_window); } else { MoveSelection(backwards ? -1 : 1, true); } @@ -704,10 +731,29 @@ void TabSwitcher::Show(HWND browser) { (std::max)(workArea.top, workArea.bottom - height)); m_shownTime = GetTickCount64(); + m_wheelRemainder = 0; SetWindowPos(m_window, HWND_TOPMOST, x, y, width, height, SWP_SHOWWINDOW); UpdateDpi(GetDpiForWindow(m_window)); - SetForegroundWindow(m_window); + + // Select the tab after the current one, so that Alt+Q followed by Enter + // doesn't just select the current tab again. + auto activeTab = + std::find_if(m_visible.begin(), m_visible.end(), + [this](size_t index) { return m_tabs[index].active; }); + if (activeTab != m_visible.end() && m_visible.size() > 1) { + size_t activeRow = static_cast(activeTab - m_visible.begin()); + m_selected = (activeRow + 1) % m_visible.size(); + EnsureSelectionVisible(); + } + + if (!BringToForeground(m_window)) { + // Without focus, the keys would still go to the browser. + Wh_Log(L"SetForegroundWindow failed"); + Hide(false); + return; + } + InvalidateRect(m_window, nullptr, FALSE); } @@ -772,10 +818,11 @@ void TabSwitcher::ActivateSelectedTab() { void TabSwitcher::LoadTabs(HWND browser) { m_tabs.clear(); - // Chromium creates its accessibility tree on the first request, so right - // after the browser starts, the tab strip might not be there yet. + // Chromium creates its accessibility tree on the first request, so it + // might still be empty. Windows without a tab strip, such as app windows, + // aren't retried, and neither is a browser that doesn't respond. constexpr int kAttempts = 3; - for (int attempt = 0; attempt < kAttempts && m_tabs.empty(); attempt++) { + for (int attempt = 0; attempt < kAttempts; attempt++) { if (attempt > 0) { Sleep(50 * attempt); } @@ -784,15 +831,25 @@ void TabSwitcher::LoadTabs(HWND browser) { HRESULT hr = m_uia->ElementFromHandle(browser, &window); if (FAILED(hr) || !window) { Wh_Log(L"ElementFromHandle failed: 0x%08X", hr); + if (IsTimeout(hr)) { + break; + } continue; } - for (const auto& tabStrip : FindTabStrips(window.Get())) { + bool treeEmpty = false; + bool timedOut = false; + for (const auto& tabStrip : + FindTabStrips(window.Get(), &treeEmpty, &timedOut)) { ComPtr items; - if (FAILED(tabStrip->FindAllBuildCache( - TreeScope_Descendants, m_tabItemCondition.Get(), - m_tabCache.Get(), &items)) || - !items) { + hr = tabStrip->FindAllBuildCache(TreeScope_Descendants, + m_tabItemCondition.Get(), + m_tabCache.Get(), &items); + if (IsTimeout(hr)) { + timedOut = true; + break; + } + if (FAILED(hr) || !items) { continue; } @@ -830,6 +887,14 @@ void TabSwitcher::LoadTabs(HWND browser) { m_tabs.push_back(std::move(tab)); } } + + if (timedOut) { + Wh_Log(L"The browser didn't respond in time"); + } + + if (!m_tabs.empty() || timedOut || !treeEmpty) { + break; + } } // Tabs of the same site share the position of the first one of them. @@ -847,9 +912,13 @@ void TabSwitcher::LoadTabs(HWND browser) { } // Returns the tab strips of a browser window, found with a breadth-first -// search which skips web page content. +// search which skips web page content. Sets *treeEmpty if the window has no +// accessible children yet, and *timedOut if the browser didn't respond, in +// which case the search stops. std::vector> TabSwitcher::FindTabStrips( - IUIAutomationElement* window) { + IUIAutomationElement* window, + bool* treeEmpty, + bool* timedOut) { std::vector> tabStrips; std::deque, int>> queue; @@ -862,15 +931,23 @@ std::vector> TabSwitcher::FindTabStrips( visitedNodes++; ComPtr children; - if (FAILED(element->FindAllBuildCache( - TreeScope_Children, m_trueCondition.Get(), - m_controlTypeCache.Get(), &children)) || - !children) { + HRESULT hr = element->FindAllBuildCache( + TreeScope_Children, m_trueCondition.Get(), + m_controlTypeCache.Get(), &children); + if (IsTimeout(hr)) { + *timedOut = true; + break; + } + if (FAILED(hr) || !children) { continue; } int count = 0; children->get_Length(&count); + if (depth == 0 && count == 0) { + *treeEmpty = true; + } + for (int i = 0; i < count; i++) { ComPtr child; if (FAILED(children->GetElement(i, &child)) || !child) { diff --git a/README.md b/README.md index f595cd8..89796c4 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ All controls are active whenever the AltTabs HUD is open: | Shortcut | Action | Description | | :--- | :--- | :--- | -| **`Alt + Q`** | **Summon / Cycle** | Summons the HUD over your browser. Tap repeatedly to cycle tabs, add `Shift` to cycle backwards. | +| **`Alt + Q`** | **Summon / Cycle** | Summons the HUD over your browser, with the tab after the current one selected. Tap repeatedly to cycle tabs, add `Shift` to cycle backwards. | | **`Alt + ` ` / `Alt + ~`** | **Alternative Summon** | Same as `Alt + Q`, using the key above Tab on US layouts. | | **`Tab`** or **`↓ Down Arrow`** | **Next Tab** | Moves selection down by one row. | | **`Shift + Tab`** or **`↑ Up Arrow`** | **Previous Tab** | Moves selection up by one row. | @@ -213,7 +213,7 @@ AltTabs is built for zero perceptible latency: ```text Found 24 tabs ``` -3. Open **Windows Task Manager** $\rightarrow$ **Details**, locate the `windhawk.exe` process with command-line `-tool-mod "chromium-alttab-tabs"`, and observe memory and CPU remain at 0% when idle. +3. Open **Windows Task Manager** $\rightarrow$ **Details**, locate the `windhawk.exe` process with command-line `-tool-mod "alttabs"`, and observe memory and CPU remain at 0% when idle. --- diff --git a/include/windhawk_api.h b/include/windhawk_api.h index da83bd1..11d849d 100644 --- a/include/windhawk_api.h +++ b/include/windhawk_api.h @@ -6,7 +6,7 @@ typedef BOOL WINBOOL; #endif #ifndef WH_MOD_ID -#define WH_MOD_ID L"chromium-alttab-tabs" +#define WH_MOD_ID L"alttabs" #endif inline int Wh_GetIntSetting(const wchar_t*) { return 0; }