Skip to content

Win10 IME tray icon fix - #7447

Merged
m417z merged 4 commits into
ramensoftware:mainfrom
yumeyao:win10-mod
Nov 18, 2026
Merged

m417z merged 4 commits into
ramensoftware:mainfrom
yumeyao:win10-mod

Conversation

@yumeyao

@yumeyao yumeyao commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

This fixes the "misclick" issue caused by IME tray icon width bouncing.

In a multilingual input environment on Windows 10 / 11, the Input Indicator in the system tray toggles its width between "1 glyph" and "2 glyphs". Because the notification area is anchored to the right edge, this width change shifts the tray icons that sit to the left of the indicator. When "Let me set a different input method for each app window" is enabled, clicking a tray icon can end up hitting a neighboring icon instead (a misclick).

Before the fix: clicking a tray icon shrinks the indicator and shifts nearby icons, causing a misclick

After the Fix - moving the IME tray icons to the leftmost:

After the fix: the indicator is pinned to the far left, and all icons to its right keep a constant distance from the right edge and no longer shift

Mimicking Docked Language Bar?

Yes. But the docked language bar is broken in win10 (unstable, and won't work in remote desktop - even if you enable this option in both sides, and the latest MSPY doesn't support it unless you turn on "Use the old version of MSPY") and is completely removed in win11.

AI Contribution Statement

The reverse engineering and the source code were completed by an AI agent (deepseek v4.1 flash). The final mod products, however, were guided and audited by the author to make sure no unnecessary extra performance overhead was introduced (the AI had previously introduced a repeating timer or an extra thread). The author verified and confirmed both the tech stack and the concrete implementation.

Changelog

If this pull request updates an existing mod, describe the changes inside the changelog markers:

Mod authorship

If this pull request introduces a new mod, please complete the section below.

This mod was created by:

    • The submitter, without AI assistance
    • The submitter, with AI assistance
    • Claude
    • ChatGPT
    • Gemini
    • Another AI (please specify):
    • Other (please specify):

@windhawk-reviewer windhawk-reviewer Bot added the waiting-for-author The author's turn: request an AI review, or respond to one that was posted. label Nov 14, 2026
@windhawk-reviewer

Copy link
Copy Markdown

Thanks for the pull request! This repository uses a two-stage review: an AI review that you run yourself, followed by a human review.

To get started, comment /ai-review. Once you're happy with the result, comment /ready-for-reviewer to hand it over to a human reviewer.

See the pull request review process for the full details.

@yumeyao

yumeyao commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-ai-review An AI review was requested and is being prepared. and removed waiting-for-author The author's turn: request an AI review, or respond to one that was posted. labels Nov 14, 2026
@windhawk-reviewer

Copy link
Copy Markdown

@yumeyao /ready-for-reviewer can't be applied here: an AI review is being prepared, please wait for it to be posted.

@windhawk-reviewer

Copy link
Copy Markdown

Submission review

Note: This review was done by Claude. Due to the amount of submissions, doing a fully manual review for each pull request is no longer feasible. Thank you for understanding.

Remember: The AI reviewer can be wrong - it may misread code, flag correct code as broken, or suggest changes that make things worse. Treat its findings as suggestions to verify, not instructions to follow blindly. You're responsible for the code you submit, so if a finding doesn't hold up, say so instead of changing working code to satisfy it.

Please address the following issues. The items in the collapsed sections are optional, so it's your call whether to address them.


The approach is targeted: it subclasses only the tray children it moves and overrides only the indicator's size reply. But the mod won't take effect in the most common case, and a few details need fixing:

1. The mod does nothing after a reboot or an Explorer restart. SyncNotify runs only from Wh_ModAfterInit (lines 352–361). When explorer.exe starts with the mod already enabled (every sign-in, every Explorer restart or crash), Windhawk loads the mod before Explorer runs any of its own code (Mod lifetime), so Shell_TrayWnd doesn't exist yet. FindTrayNotify returns null, the mod logs TrayNotifyWnd not found, and it stays inactive for the whole session. Wh_ModSettingsChanged doesn't retry, because g_tray.hNotify is still null. The mod only works when it's enabled or toggled while Explorer is already running, which is probably how it was tested.

Fix: also catch the tray windows when they're created, and keep the current lookup for enabling mid-session. Hook CreateWindowExW. The hook runs on the taskbar thread, so it can subclass directly. Because SyncNotify sorts the children by their rects, run it after the first layout pass has placed them (for example from a TrayNotifyWnd subclass, after its first WM_SIZE):

using CreateWindowExW_t = decltype(&CreateWindowExW);
CreateWindowExW_t CreateWindowExW_Original;
HWND WINAPI CreateWindowExW_Hook(DWORD dwExStyle, LPCWSTR lpClassName,
                                 LPCWSTR lpWindowName, DWORD dwStyle, int X,
                                 int Y, int nWidth, int nHeight,
                                 HWND hWndParent, HMENU hMenu,
                                 HINSTANCE hInstance, LPVOID lpParam) {
    HWND hWnd = CreateWindowExW_Original(dwExStyle, lpClassName, lpWindowName,
                                         dwStyle, X, Y, nWidth, nHeight,
                                         hWndParent, hMenu, hInstance, lpParam);
    if (hWnd && !IS_INTRESOURCE(lpClassName) &&
        _wcsicmp(lpClassName, kTrayNotifyClass) == 0) {
        // Subclass TrayNotifyWnd here and run SyncNotify once its children
        // have been laid out.
    }
    return hWnd;
}

Reference: CreateWindowExW_Hook in taskbar-volume-control. Another option may be simpler, since your comments say the layout already goes through a DeferWindowPos batch: more-space-in-language-indicator hooks DeferWindowPos and recognizes TrayInputIndicatorWClass by its class name. That works from process start and needs no window lookup.

2. The taskbar lookup isn't limited to the current process (lines 247–251). FindWindowW(L"Shell_TrayWnd", nullptr) returns the taskbar of whichever process owns it. The mod is loaded into every explorer.exe, including the separate folder-window process ("Launch folder windows in a separate process") and the extra explorer.exe instances Windows starts for some shell operations. Those instances find the shell's taskbar. Subclassing fails there, because SetWindowSubclassFromAnyThread can't target another process's thread. But the cross-process ShowWindow on the IME mode button (line 168) and the 0x415 post (line 341) still work. So a non-shell Explorer process changes the shell's indicator on its init, on every settings change and on unload. Fix: skip windows of other processes:

HWND FindTrayNotify() {
    HWND hTray = FindWindowW(kTrayWndClass, nullptr);
    DWORD pid = 0;
    if (!hTray || !GetWindowThreadProcessId(hTray, &pid) ||
        pid != GetCurrentProcessId()) {
        return nullptr;
    }
    return FindWindowExW(hTray, nullptr, kTrayNotifyClass, nullptr);
}

(Or enumerate with a PID filter, like FindCurrentProcessTaskbarWindows.)

3. The IME mode button is forced visible even when "Hide secondary IME mode glyph" is off. EnforceImeModeHidden (lines 165–170) calls ShowWindow(hImeMode, SW_SHOW) whenever hideImeMode is off, which is the default. That happens on every WM_WINDOWPOSCHANGING of the indicator (line 205), in Wh_ModAfterInit, in Wh_ModSettingsChanged, and in Wh_ModUninit (lines 370–371), even for users who never turned the option on. Explorer manages this button's visibility itself: with a plain keyboard layout such as ENG there is no mode glyph, and your comment at lines 102–106 refers to "which children happen to be visible". If Explorer hides the button for those layouts, the mod shows it again, as an empty or stale button in the slot. If Explorer only gives it zero width instead, the call is harmless. Please confirm which one happens. Either way, the mod should only change visibility when the option is on, and restore only what it hid:

std::atomic<bool> g_imeModeHiddenByMod{false};

void EnforceImeModeHidden() {
    HWND hImeMode = g_tray.hImeMode.load(std::memory_order_relaxed);
    if (!hImeMode || !IsWindow(hImeMode)) {
        return;
    }
    if (g_hideImeMode) {
        if (IsWindowVisible(hImeMode)) {
            g_imeModeHiddenByMod = true;
            ShowWindow(hImeMode, SW_HIDE);
        }
    } else if (g_imeModeHiddenByMod.exchange(false)) {
        ShowWindow(hImeMode, SW_SHOW);
    }
}

4. The 36 px single-glyph width is hard-coded and ignores display scaling (line 157). With "Hide secondary IME mode glyph" on and fixedWidth left at -1, the slot is pinned to 36 physical pixels. The indicator's glyphs scale with the DPI (Explorer is per-monitor DPI aware). At scaling factors other than the author's, the slot doesn't fit: at 125%/150%, common on laptops, the language glyph is wider than 36 px. MainIconProc then places it at x = 0 (band <= cx), and it's clipped on the right. The numbers in the fixedWidth description and README ("36 = one glyph, 58 = glyph + secondary") are also correct at only one scale factor. Fix: scale the constant by the tray's DPI, e.g. MulDiv(36, GetDpiForWindow(hNotify), 96) when handling kMsgGetMinSize, or use the main glyph's actual width. For the user value, either scale it the same way and describe it as "at 100% scaling", or say in the description that it's in physical pixels and depends on the scaling factor.

Optional improvements

Minor polish — none of this affects users, so it's your call.

  • Settings globals are read without synchronization. g_movePosition, g_fixedWidth and g_hideImeMode (lines 96–107) are plain globals. LoadSettings and Wh_ModUninit write them on the Windhawk engine thread, while the subclass procs read them on the taskbar thread. That's a data race, though only on a settings change or unload. Make them std::atomic, like the Tray fields.
  • -luser32 in @compilerOptions is redundant. user32 is linked by default. -lcomctl32 is still needed for DefSubclassProc.

Functionality notes

Non-critical observations and ideas about the feature behavior itself.

  • The shift isn't idempotent. ShiftRightProc adds bandWidth to every move of the chevron and SysPager that doesn't carry SWP_NOMOVE, not only to the moves from the layout pass. If anything repositions one of them while passing its current (already shifted) position, for example a resize that keeps x, it is shifted a second time and drifts right until the next full layout. Worth testing by adding and removing tray icons and by showing and hiding the chevron. Changing the positions inside the layout batch, as in the DeferWindowPos approach from item 1, would avoid this.
  • A hidden indicator still shifts the icons. When the indicator is hidden (turned off in "Turn system icons on or off", only one input language, or hidden by Windows while a Remote Desktop window is focused), Explorer probably stops asking it for its size. bandWidth then keeps its last value, and SysPager and the chevron are still pushed right by it, toward the clock. Also, if the mod is enabled while the indicator is hidden, the sorting in SyncNotify relies on a meaningless indicator rect. Using a width of 0 in ShiftRightProc when !IsWindowVisible(hIndicator) would cover the first part.
  • Windows 11. The PR body describes the problem on Windows 10 / 11. On Windows 11's default taskbar the indicator is XAML, so this mod doesn't apply there. With the Windows 10 taskbar restored on Windows 11, the private message numbers (0x415, 0x464) and the chevron control ID haven't been verified. Please state in the README which configurations are supported. If you only want to support Windows 10, consider having the mod do nothing on Windows 11 builds.
  • Related mods (no overlap concern). taskbar-language-indicator-layout-control prevents tray jumps when the indicator is hidden during Remote Desktop, and more-space-in-language-indicator changes its height. Neither addresses the width changes this mod fixes.

Code overview

For the maintainer: a map of the mod and what it touches outside its own process. Descriptive only — anything that needs a change is listed above. Line numbers refer to the mod source at commit 637980c. This mod is new, so everything below is new.

Code regions

  • Line 1–11: metadata (@include explorer.exe, no @architecture, -lcomctl32 -luser32)
  • Line 13–68: README — explains the bug and the three modes, with before/after GIFs on raw.githubusercontent.com
  • Line 70–82: settings — moveToLeft (bool), fixedWidth (number, -1 = natural), hideImeMode (bool)
  • Line 84–146: includes and globals — setting values, tray class names, the chevron control ID 0x5DE, private messages 0x464 (band min-size query) and 0x415 (relayout), and the Tray struct of atomic HWNDs, shift list and band width
  • Line 148–160: LoadSettings — reads the three settings and forces width 36 when hideImeMode is on and fixedWidth < 0
  • Line 162–170: EnforceImeModeHidden — ShowWindow SW_HIDE/SW_SHOW on IMEModeButton
  • Line 172–183: Transformable — checks the unload flag, window validity, and that the notification area is horizontal
  • Line 185–212: IndicatorProc subclass — overrides the 0x464 size reply with the fixed width and records it, applies the IME mode visibility, and moves the indicator to x = 0
  • Line 214–226: ShiftRightProc subclass — adds the band width to the x of each window that was left of the indicator
  • Line 228–245: MainIconProc subclass — centers InputIndicatorButton in the slot when the mode glyph is hidden
  • Line 247–251: FindTrayNotify — FindWindowW(Shell_TrayWnd) → TrayNotifyWnd
  • Line 253–331: SyncNotify — picks the windows to shift (by rect, chevron ID, SysPager class), stores the handles, seeds the band width, and installs the three subclasses with SetWindowSubclassFromAnyThread
  • Line 333–343: Refresh — posts 0x415 to TrayNotifyWnd to rerun the layout
  • Line 347–367: Wh_ModInit (loads settings), Wh_ModAfterInit (find, sync, refresh), Wh_ModSettingsChanged (reload, refresh)
  • Line 369–398: Wh_ModUninit — shows the IME mode button, sets the unload flag, removes all subclasses, posts a relayout

Side effects of interest

  • Line 339–343: IPC: PostMessageW(TrayNotifyWnd, 0x415), an undocumented Explorer message, sent from Wh_ModAfterInit, Wh_ModSettingsChanged and Wh_ModUninit. It goes to the shell process's window even when the mod runs in another explorer.exe (item 2).
  • Line 165–170: IPC: ShowWindow on the shell's IMEModeButton in the same callbacks and on each indicator move. Cross-process when the mod runs in a non-shell explorer.exe.
  • Line 247–251: other reach outside the process: FindWindowW(L"Shell_TrayWnd") without a process filter, run in Wh_ModAfterInit.


Next steps:

  • /ai-review - after pushing fixes, to get a review of the updated code. You can repeat this as many times as you need, but each review is thorough and usually there's no need for more than 2-3 iterations.
  • /ready-for-reviewer - once you're satisfied with the state of the pull request, to hand it over to a human reviewer. If some findings above are left unaddressed, add a short note explaining why.

See the review process for details.

Important: Each reply that was generated by AI must be disclosed by including the following text in the reply: "Generated by AI. Model: (ai-model-name)".

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-author The author's turn: request an AI review, or respond to one that was posted. and removed waiting-for-ai-review An AI review was requested and is being prepared. labels Nov 14, 2026
@yumeyao

yumeyao commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review

I updated the commit.

  • mimicking taskbar-volume-control 's injection model to address 1 and 2.
  • high dpi scaling handling to address 4.

For other parts:

  1. The IME mode button is forced visible even when "Hide secondary IME mode glyph" is off.

This is never an issue in reality tests. I asked the Agent to further prove it by reverse engineering, so it's decisive - zero width.

regarding the "show only what you hide", I considered it at the very first stage and left it out:
ShowWindow() is a cheap no-op when the status is already there. So remembering "what you hide" only benefits when two mods both hide the same button, and that case brings ordering problems worse than the one it solves, for example enable A, enable B, disable A, disable B is not LIFO, and the flag would then record a state the mod no longer owns. With a single writer, "restore only what we hid" reduces to "restore when our option is off", which is what the code already does. Users running competing mods are better served by configuring one of them not to touch the glyph together.

The shift isn't idempotent.

ShiftRightProc adds bandWidth to the incoming x, so it is idempotent only if every caller passes the untransformed position. That holds here, and it is verifiable from the binary:

  • CTrayNotify::_SizeWindows is the sole producer of band positions. It builds every rectangle by chaining widths and never reads a child's current geometry. Across the decompiled function set, GetWindowRect appears exactly once, in CTrayNotify::_ResizeChildWindows, and its subject is the indicator itself.
  • The two other position writes do not feed back either. _SizeWindows moves the overflow toolbar with SetWindowPos(hwnd, nullptr, 0, 0, w, cy, 0x114), a constant x of 0. CTray::v_WndProc issues SetWindowPos(..., 0, 0, 0, 0, 0x13), and 0x13 is SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE, which the guard skips on wp->flags & SWP_NOMOVE.
  • CTrayNotify::_PlaceItem only manipulates toolbar button state through TB_* messages, it moves no windows.

So, adding and removing tray icons, and showing and hiding the chevron, all reach _SizeWindows, which recomputes every band from zero. There is nothing to accumulate.

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-ai-review An AI review was requested and is being prepared. and removed waiting-for-author The author's turn: request an AI review, or respond to one that was posted. labels Nov 15, 2026
@windhawk-reviewer

Copy link
Copy Markdown

Submission review

Note: This review was done by Claude. Due to the amount of submissions, doing a fully manual review for each pull request is no longer feasible. Thank you for understanding.

Remember: The AI reviewer can be wrong - it may misread code, flag correct code as broken, or suggest changes that make things worse. Treat its findings as suggestions to verify, not instructions to follow blindly. You're responsible for the code you submit, so if a finding doesn't hold up, say so instead of changing working code to satisfy it.

Please address the following issues. The items in the collapsed sections are optional, so it's your call whether to address them.


Thanks for the update. The process filter, the DPI handling and the atomics look good, and your reverse-engineering notes settle the IME mode button and the shift questions. One problem remains in the new startup path:

The startup path runs SyncNotify before Explorer has laid out the tray. The CreateWindowExW hook now catches TrayNotifyWnd at startup. But HandleCreatedWindow (lines 481–497) runs SyncNotify as soon as CreateWindowExW returns, before any layout pass. SyncNotify relies on that layout in two places:

  • It needs the indicator to exist (lines 360–364). If TrayInputIndicatorWClass is created after CreateWindowExW returns for TrayNotifyWnd, SyncNotify returns early and nothing is subclassed. Nothing retries either, since Wh_ModSettingsChanged (lines 547–551) only posts the relayout again. The mod would then be inactive for the session, as before.
  • It picks the windows to shift by comparing their rects with the indicator's (lines 384–394). Before the first layout, the children are still at their creation positions, so this test can't tell which of them sit left of the indicator. Only the chevron and SysPager are caught, because they're matched directly. Any other band left of the indicator, which is the case this rect test exists for, isn't shifted, and the shifted SysPager ends up on top of it.

Enabling the mod mid-session isn't affected, because the tray is already laid out at that point. The problem only shows up after a sign-in or an Explorer restart. If you've confirmed that the children already exist and are positioned when CreateWindowExW returns, a log line in SyncNotify with shiftCount and the class names would settle it: compare an Explorer restart with a mid-session enable. Otherwise, wait for the first layout. Subclass TrayNotifyWnd in the hook, and wire up after the first WM_SIZE that leaves the indicator with a width (your comment at lines 456–458 says WM_SIZE lays out the children):

LRESULT CALLBACK NotifyProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam,
                            DWORD_PTR /*dwRefData*/) {
    LRESULT result = DefSubclassProc(hWnd, msg, wParam, lParam);
    // Wire up once, after a layout pass has placed the children.
    if (msg == WM_SIZE && !g_unloading.load(std::memory_order_relaxed) &&
        !g_tray.hIndicator.load(std::memory_order_relaxed)) {
        HWND hIndicator =
            FindWindowExW(hWnd, nullptr, kIndicatorClass, nullptr);
        RECT rc;
        if (hIndicator && GetWindowRect(hIndicator, &rc) &&
            rc.right > rc.left) {
            HandleIdentifiedTrayNotify(hWnd);
        }
    }
    return result;
}

// In HandleCreatedWindow, instead of calling HandleIdentifiedTrayNotify(hWnd):
g_tray.hNotify.store(hWnd, std::memory_order_relaxed);
WindhawkUtils::SetWindowSubclassFromAnyThread(hWnd, NotifyProc, 0);

Also remove NotifyProc from g_tray.hNotify in Wh_ModUninit, together with the other subclasses.

Optional improvements

Minor polish — none of this affects users, so it's your call.

  • IsShellProcess is redundant (lines 345–348, 534–536). FindCurrentProcessTaskbarWindow already returns null in a process that doesn't own a taskbar, so the check adds nothing in the folder-window process. It also assumes Shell_TrayWnd is registered with the exe's own HINSTANCE. Where it isn't, for example a restored Windows 10 taskbar that registers the class from a DLL, the mod would silently do nothing when enabled mid-session. Removing the check removes that assumption.

Functionality notes

Non-critical observations and ideas about the feature behavior itself.

  • Explorer may not scale the slot width the way the mod does. The comment at lines 213–216 says Explorer's own value is 2 * SM_CYBORDER + 34: 36 px at 100%, and only a few pixels more at 150%. OverrideBandWidth scales linearly instead (MulDiv(width, dpi, 96)), so the fallback and a fixedWidth of 36 both become 54 px at 150%. If Explorer's slot really grows only with the border, the setting's guidance ("36 = one glyph, 58 = glyph + secondary") leaves an empty gap at high DPI. Worth comparing the natural width with the scaled value at 150%. There's also a lag. The measured glyph width (line 290) is recorded after the size query for that pass has already been answered. So after a DPI change, the slot keeps its old width until the next relayout. Calling Refresh when the measured value changes would make the slot follow right away.
  • Windows 11 (still open from the last round). The README says the mod was tested on Windows 10 21H2, but not what happens on Windows 11. There, the default taskbar's indicator is XAML and the mod does nothing. A restored Windows 10 taskbar hasn't been checked against the private message numbers. One line in the README would set expectations.

Code overview

For the maintainer: a map of the mod and what it touches outside its own process. Descriptive only — anything that needs a change is listed above. Line numbers refer to the mod source at commit 6ee2dc4. This mod is new, so everything below is new.

Code regions

  • Line 1–11: metadata (@include explorer.exe, no @architecture, -lcomctl32)
  • Line 13–68: README — explains the bug and the three modes, with before/after GIFs on raw.githubusercontent.com
  • Line 70–82: settings — moveToLeft (bool), fixedWidth (number, -1 = natural, scaled by DPI), hideImeMode (bool)
  • Line 84–153: includes and globals — atomic setting values and the measured glyph width; tray class names; the chevron control ID 0x5DE; the undocumented Explorer messages 0x464 (band min-size query) and 0x415 (relayout); the Tray struct of atomic HWNDs, the shift list and the band width; the unload flag
  • Line 155–162: LoadSettings — reads the three settings
  • Line 164–183: IsOwnedByCurrentProcess (PID check run before every use of a cached handle) and EnforceImeModeHidden (ShowWindow SW_HIDE/SW_SHOW on IMEModeButton)
  • Line 185–220: Transformable (unload flag, ownership, horizontal-tray check) and OverrideBandWidth (the fixed width scaled by DPI, or the measured glyph width / scaled 36 when the mode glyph is hidden)
  • Line 222–253: IndicatorProc subclass — overrides the nonzero 0x464 size reply and records it, applies the IME mode visibility, moves the indicator to x = 0
  • Line 255–275: ShiftRightProc subclass — adds the band width to the x of each window that was left of the indicator
  • Line 277–301: MainIconProc subclass — records the glyph width, and centers InputIndicatorButton in the slot when the mode glyph is hidden
  • Line 303–348: taskbar lookup — EnumWindows filtered by PID for Shell_TrayWnd, FindWindowExW for TrayNotifyWnd, and IsShellProcess (GetClassInfoW on the exe module)
  • Line 350–451: SyncNotify — picks the windows to shift (by rect, chevron ID, SysPager class), stores the handles, seeds the glyph and band widths, installs the three subclasses with SetWindowSubclassFromAnyThread
  • Line 453–475: Refresh (posts 0x415 to the own process's TrayNotifyWnd) and HandleIdentifiedTrayNotify (sync, apply visibility, refresh)
  • Line 477–513: CreateWindowExW hook — when a TrayNotifyWnd is created, wires it up immediately on the taskbar thread
  • Line 517–551: Wh_ModInit (loads settings, installs the CreateWindowExW hook), Wh_ModAfterInit (finds an already existing tray when the mod is enabled mid-session), Wh_ModSettingsChanged (reload, apply visibility, refresh)
  • Line 553–582: Wh_ModUninit — shows the IME mode button, sets the unload flag, removes all subclasses, posts a relayout

Side effects of interest

  • None found — the mod only hooks CreateWindowExW and subclasses tray windows in its own explorer.exe. Every cached window is checked to belong to the current process before ShowWindow or the 0x415 post, and the EnumWindows lookup is filtered by PID. No files, registry, network or system settings are touched.


Next steps:

  • /ai-review - after pushing fixes, to get a review of the updated code. You can repeat this as many times as you need, but each review is thorough and usually there's no need for more than 2-3 iterations.
  • /ready-for-reviewer - once you're satisfied with the state of the pull request, to hand it over to a human reviewer. If some findings above are left unaddressed, add a short note explaining why.

See the review process for details.

Important: Each reply that was generated by AI must be disclosed by including the following text in the reply: "Generated by AI. Model: (ai-model-name)".

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-author The author's turn: request an AI review, or respond to one that was posted. and removed waiting-for-ai-review An AI review was requested and is being prepared. labels Nov 15, 2026
… as virtual keyboard) creation.

also revise condition guard checks and remove IsShellProcess() check.
@yumeyao

yumeyao commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review

The startup path is actually fine. The indicator does exist when CreateWindowExW returns. The real issue is actually the install-once design, it can't catch new windows, for example, the virtual keyboard KeyboardButton. So in previous versions, if the user turns on this mod without that icon, but later enables it in the OS settings, that icon is not in the shift list so not shifted by the mod, leaving an empty slot before the clock tray.

So the new design just register every child to the subclass, and decide if it requires moving afterwards, it's still cheap - no heavy runtime overhead. With this new design, the issue mentioned above is fixed, and your concern is gone as well.

I also nuked IsShellProcess() and removed other redundant runtime checks.

Explorer may not scale the slot width the way the mod does.

  • the uncontiguous value gap: yes. but this is not the main function of this mod. if a user requires a precise width control under different dpis, the user should disable this function and use another mod.
  • dpi change on-the-fly: tested and working (no lag). should there be any edge case, it's always recoverable on the next refresh (by the user to switch IME or tray icon change).

Windows 11

There is a sibling mod to handle win11. because the mechanism is totally different (win32 vs xaml), no common code is shared. The description mention both win10/win11 just to reflect the facts.

Windows 10 taskbar on Windows11 might be an interest but not covered right now. hope it works (because the explorer.exe used to achieve this goal is a vanilla win10 one).

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-ai-review An AI review was requested and is being prepared. and removed waiting-for-author The author's turn: request an AI review, or respond to one that was posted. labels Nov 15, 2026
@windhawk-reviewer

Copy link
Copy Markdown

Submission review

Note: This review was done by Claude. Due to the amount of submissions, doing a fully manual review for each pull request is no longer feasible. Thank you for understanding.

Remember: The AI reviewer can be wrong - it may misread code, flag correct code as broken, or suggest changes that make things worse. Treat its findings as suggestions to verify, not instructions to follow blindly. You're responsible for the code you submit, so if a finding doesn't hold up, say so instead of changing working code to satisfy it.

Please address the following issues. The items in the collapsed sections are optional, so it's your call whether to address them.


Thanks for the details. Your reasoning about the indicator existing at CreateWindowExW time makes sense. But the commit with the new design hasn't reached the PR yet, so this round still covers 6ee2dc4:

The changes from your last comment aren't in the PR. The head is still 6ee2dc4, the commit the previous round reviewed. IsShellProcess is still there (lines 345–348, 534–536), and SyncNotify still picks a fixed list of windows to shift, once (lines 384–408). Please push the new commit and comment /ai-review again. Until then, the PR still has the bug you described:

  • A band created or shown after wiring isn't in the shift list. For example, if the touch keyboard button is enabled later in Settings, it stays at its stock position and leaves an empty slot before the clock (your repro).
  • At startup, the rect test runs before the first layout, so it only matches the chevron and SysPager.

The new version should also cover these two cases:

  • Children created after wiring. Subclassing every child when the mod wires up doesn't reach a band that Explorer creates later. If the touch keyboard, Windows Ink or Meet Now button can be created after TrayNotifyWnd, subclass it in the existing CreateWindowExW hook when parent is the tracked TrayNotifyWnd. (Children created inside TrayNotifyWnd's own creation are still caught when the mod enumerates the children at wiring time.) If you've confirmed these buttons always exist from the start and are only hidden, this isn't needed.
  • Every subclass removed on unload. Once the set of subclassed windows can change, a fixed 8-slot list in Wh_ModUninit can miss some of them. Enumerate the current children instead. Removing a subclass that isn't installed does nothing.
// In CreateWindowExW_Hook, after the original call:
if (hWnd && parent &&
    parent == g_tray.hNotify.load(std::memory_order_relaxed) &&
    !g_unloading.load(std::memory_order_relaxed)) {
    WindhawkUtils::SetWindowSubclassFromAnyThread(hWnd, ShiftRightProc, 0);
}

// In Wh_ModUninit, instead of walking g_tray.shift:
HWND hNotify = g_tray.hNotify.load(std::memory_order_relaxed);
if (IsOwnedByCurrentProcess(hNotify)) {
    for (HWND child = GetWindow(hNotify, GW_CHILD); child;
         child = GetWindow(child, GW_HWNDNEXT)) {
        WindhawkUtils::RemoveWindowSubclassFromAnyThread(child, ShiftRightProc);
    }
}

On a mirrored (right-to-left) taskbar, the rect test picks the wrong side. Lines 384–394 compare GetWindowRect results, which are screen coordinates. With an Arabic or Hebrew display language, the taskbar is mirrored (WS_EX_LAYOUTRTL), so layout x = 0 is the right edge of TrayNotifyWnd. The bands laid out before the indicator are then to its right on screen. So when the mod is enabled mid-session, rc.left < indicatorRect.left matches the clock, the action center button and the show desktop button. ShiftRightProc then pushes them toward the screen edge, past the end of the tray. The chevron and SysPager are matched by identity, so they're shifted too, and the tray ends up with overlapping bands. The transform itself is fine there, because WINDOWPOS coordinates are in the parent's mirrored client space. Only the selection of windows to shift is wrong. Please check this with an Arabic or Hebrew display language. To fix it, compare positions in TrayNotifyWnd client coordinates: MapWindowPoints(HWND_DESKTOP, hNotify, reinterpret_cast<POINT*>(&rc), 2) corrects for mirroring when it's given a rect (two points). Or, if the new design decides per layout pass, compare the incoming WINDOWPOS::x values, which are already in layout order. If you'd rather not support RTL, skip the transform when GetWindowLongPtrW(hNotify, GWL_EXSTYLE) & WS_EX_LAYOUTRTL is set, and say so in the README.

Functionality notes

Non-critical observations and ideas about the feature behavior itself.

  • How this differs from related mods. taskbar-language-indicator-layout-control also stops the tray from jumping, but for a different cause: the indicator being hidden and shown again while a Remote Desktop window is active. It does this with a ShowWindow hook and doesn't touch the width changes this mod targets. more-space-in-language-indicator only changes how the indicator text is laid out, and tray-utility-customizer works on the Windows 11 XAML tray. None of them is a near-duplicate. One possible README addition: with Mode 1 the indicator's slot is at the left end of the tray, so the Remote Desktop hide/show jump should go away as well.
  • Windows 11. You mentioned the sibling PR for the Windows 11 taskbar. One README line pointing Windows 11 users to it would help, along with a note that the Windows 10 taskbar on Windows 11 is untested. The mod's name says Windows 10, but users find mods by searching.

Code overview

For the maintainer: a map of the mod and what it touches outside its own process. Descriptive only — anything that needs a change is listed above. Line numbers refer to the mod source at commit 6ee2dc4. This mod is new, so everything below is new.

Code regions

  • Line 1–11: metadata (@include explorer.exe, no @architecture, -lcomctl32 for the subclass APIs)
  • Line 13–68: README — explains the width-bounce misclick and the three modes, before/after GIFs on raw.githubusercontent.com, AI credit and tested builds
  • Line 70–82: settings — moveToLeft (bool, on), fixedWidth (number, -1 = natural, scaled by DPI), hideImeMode (bool, off)
  • Line 84–153: includes and globals — atomic copies of the settings and the measured glyph width; tray class names; the chevron control ID 0x5DE; Explorer's private messages 0x464 (band min-size query) and 0x415 (relayout); the Tray struct of atomic HWNDs, an 8-slot shift list and the band width; the unload flag
  • Line 155–162: LoadSettings — reads the three settings
  • Line 164–183: IsOwnedByCurrentProcess (PID check before each use of a cached handle) and EnforceImeModeHidden (ShowWindow SW_HIDE/SW_SHOW on IMEModeButton)
  • Line 185–220: Transformable (unload flag, ownership, horizontal-tray check), DpiOf, OverrideBandWidth (fixed width scaled by DPI, or the measured glyph width / scaled 36 when the mode glyph is hidden)
  • Line 222–253: IndicatorProc subclass — overrides a nonzero 0x464 size reply and records it as the band width, applies the IME mode visibility, moves the indicator to x = 0
  • Line 255–275: ShiftRightProc subclass — adds the band width to the incoming x of each window that was left of the indicator
  • Line 277–301: MainIconProc subclass — records the glyph width, centers InputIndicatorButton in the slot when the mode glyph is hidden
  • Line 303–348: taskbar lookup — PID-filtered EnumWindows for Shell_TrayWnd, FindWindowExW for TrayNotifyWnd, IsShellProcess (GetClassInfoW on the exe module)
  • Line 350–451: SyncNotify — picks the windows to shift (screen-rect test, chevron ID, SysPager class), caches the handles, seeds the glyph and band widths, installs the three subclasses with SetWindowSubclassFromAnyThread
  • Line 453–475: Refresh (posts 0x415 to the own process's TrayNotifyWnd) and HandleIdentifiedTrayNotify (sync, apply visibility, refresh)
  • Line 477–513: CreateWindowExW hook — when a TrayNotifyWnd is created, wires it up right away on the taskbar thread
  • Line 517–551: Wh_ModInit (settings, installs the hook), Wh_ModAfterInit (finds an existing tray when enabled mid-session), Wh_ModSettingsChanged (reload, apply visibility, refresh)
  • Line 553–582: Wh_ModUninit — shows the IME mode button, sets the unload flag, removes the subclasses from the cached windows, posts a relayout

Side effects of interest

  • None found — the mod only hooks CreateWindowExW and subclasses tray windows in its own explorer.exe. The EnumWindows lookup is filtered by PID, and each cached window is checked to belong to the current process before ShowWindow or the 0x415 post. No files, registry, network or system settings are touched.


Next steps:

  • /ai-review - after pushing fixes, to get a review of the updated code. You can repeat this as many times as you need, but each review is thorough and usually there's no need for more than 2-3 iterations.
  • /ready-for-reviewer - once you're satisfied with the state of the pull request, to hand it over to a human reviewer. If some findings above are left unaddressed, add a short note explaining why.

See the review process for details.

Important: Each reply that was generated by AI must be disclosed by including the following text in the reply: "Generated by AI. Model: (ai-model-name)".

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-author The author's turn: request an AI review, or respond to one that was posted. and removed waiting-for-ai-review An AI review was requested and is being prepared. labels Nov 15, 2026
@yumeyao

yumeyao commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review

sorry for the commit gap.

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-ai-review An AI review was requested and is being prepared. and removed waiting-for-author The author's turn: request an AI review, or respond to one that was posted. labels Nov 15, 2026
@windhawk-reviewer

Copy link
Copy Markdown

This pull request has already had 3 AI reviews in the last 24 hours, which is the limit, so no review was posted this time.

Comment /ai-review again after 2026-11-15 22:33 UTC (in 18 hours) to get another one.

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-author The author's turn: request an AI review, or respond to one that was posted. and removed waiting-for-ai-review An AI review was requested and is being prepared. labels Nov 15, 2026
@yumeyao

yumeyao commented Nov 16, 2026 via email

Copy link
Copy Markdown
Contributor Author

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-ai-review An AI review was requested and is being prepared. and removed waiting-for-author The author's turn: request an AI review, or respond to one that was posted. labels Nov 16, 2026
@windhawk-reviewer

Copy link
Copy Markdown

Submission review

Note: This review was done by Claude. Due to the amount of submissions, doing a fully manual review for each pull request is no longer feasible. Thank you for understanding.

Remember: The AI reviewer can be wrong - it may misread code, flag correct code as broken, or suggest changes that make things worse. Treat its findings as suggestions to verify, not instructions to follow blindly. You're responsible for the code you submit, so if a finding doesn't hold up, say so instead of changing working code to satisfy it.

Please address the following issues. The items in the collapsed sections are optional, so it's your call whether to address them.


Both items from the last round are fixed. Bands created later get ShiftRightProc from the CreateWindowExW hook (lines 456–463), and Wh_ModUninit removes it from the current children (lines 527–534). The shift decision now compares the incoming WINDOWPOS::x with the indicator's last layout x (lines 252–259, 274). Those values are in TrayNotifyWnd's client coordinates, which are mirrored on an RTL taskbar, so the RTL problem is gone as well.

No blocking issues. Looks good to merge.

Optional improvements

Minor polish — none of this affects users, so it's your call.

  • The ownership comment no longer matches the code. Lines 164–166 say "Cached handles are re-checked with this before every use". This commit removed those checks from EnforceImeModeHidden (line 178), Refresh (line 419) and Transformable (line 193). The cached handles are now used unchecked from the engine thread in Wh_ModSettingsChanged and Wh_ModUninit. That's fine as long as the tray windows live as long as the process. If any of them can be destroyed earlier, a recycled handle could point the ShowWindow(SW_SHOW) or the 0x415 post at another process's window. Either put IsOwnedByCurrentProcess back on the calls from Wh_ModSettingsChanged and Wh_ModUninit (the subclass procs don't need it), or reword the comment so it only describes the lookup. A related nit: the comment at line 351 says the indicator is a "Direct child of the taskbar", but it's a child of TrayNotifyWnd.
  • The unload loop can stop early (lines 529–533). If Explorer destroys a band while the loop runs, GetWindow(child, GW_HWNDNEXT) on that band returns NULL and the loop ends. Each removal is a SendMessage, so the UI thread keeps processing messages between iterations. The children after that band keep ShiftRightProc, which then points into the unloaded DLL. The timing window is very narrow and only exists on unload. EnumChildWindows collects the window list before it calls the callback, and the docs say a child destroyed before it's reached is just skipped, so it doesn't have this problem. It also visits grandchildren (the SysPager toolbar, the indicator's own children). For those the removal message does nothing.
    BOOL CALLBACK RemoveShiftSubclassProc(HWND hWnd, LPARAM) {
        WindhawkUtils::RemoveWindowSubclassFromAnyThread(hWnd, ShiftRightProc);
        return TRUE;
    }
    
    // In Wh_ModUninit:
    if (hNotify) {
        EnumChildWindows(hNotify, RemoveShiftSubclassProc, 0);
    }

Functionality notes

Non-critical observations and ideas about the feature behavior itself.

  • The indicator and its two glyph windows are cached once. SyncNotify runs only when the mod wires up (lines 350–410). The hook path for later children (lines 460–463) gives any new direct child ShiftRightProc. Suppose TrayInputIndicatorWClass can be created after TrayNotifyWnd, for example when the Input Indicator system icon is turned on or a second input language is added while Explorer runs. Then the new indicator gets ShiftRightProc instead of IndicatorProc, and hImeMode / hMainIcon still point at the old windows. Mode 1 and the mode-glyph hiding then stop working until Explorer restarts. The same applies if IMEModeButton or InputIndicatorButton is created only when an IME is first activated. If you've confirmed these windows are created with TrayNotifyWnd and are only hidden or shown after that, you can ignore this. Otherwise it's a small change in HandleCreatedWindow:
    if ((style & WS_CHILD) && hNotify && GetAncestor(hWnd, GA_PARENT) == hNotify) {
        if (textualClassName && !_wcsicmp(className, kIndicatorClass)) {
            SyncNotify(hNotify);  // re-caches the indicator and its children
            Refresh(hNotify);
            return;
        }
        WindhawkUtils::SetWindowSubclassFromAnyThread(hWnd, ShiftRightProc, 0);
    }
  • One-pass lag when bands change. Your comment at lines 147–152 covers this. One more consequence: in the first pass, the bands are classified against the previous indicator x. If the bands left of the indicator shrink by more than the indicator's width in one step (for example, several tray icons disappear at once), the first band right of the indicator (normally the clock) is also below the old boundary. That pass then shifts it, so it overlaps the next band for one frame, until the posted relayout corrects it. A fresh enable has a similar one-pass glitch: g_indicatorX starts at 0, so the first pass moves the indicator to x = 0 on top of the chevron. It doesn't last, so this is just FYI.
  • Related mods: as the previous round noted, none is a near-duplicate. taskbar-language-indicator-layout-control addresses the jump caused by the indicator being hidden while an RDP window is active. more-space-in-language-indicator only changes the indicator's text layout. Neither keeps the tray icons in place when the indicator's width changes.

Code overview

For the maintainer: a map of the mod and what it touches outside its own process. Descriptive only — anything that needs a change is listed above. Line numbers refer to the mod source at commit a09bedb. This mod is new, so everything below is new.

Code regions

  • Line 1–11: metadata (@include explorer.exe, no @architecture, -lcomctl32 for the subclass APIs)
  • Line 13–68: README: the width-bounce misclick, the three modes, before/after GIFs on raw.githubusercontent.com, AI credit and tested builds
  • Line 70–82: settings: moveToLeft (bool, on), fixedWidth (number, -1 = natural width, DPI-scaled), hideImeMode (bool, off)
  • Line 84–153: includes and globals: atomic copies of the settings and the measured glyph width; tray class names; Explorer's private messages 0x464 (band min-size query) and 0x415 (relayout); the Tray struct of atomic HWNDs and the band width; the unload flag; g_indicatorX, the indicator's last untransformed x, which is the boundary for shifting
  • Line 155–162: LoadSettings: reads the three settings
  • Line 164–183: IsOwnedByCurrentProcess (PID check) and EnforceImeModeHidden (ShowWindow SW_HIDE/SW_SHOW on the cached IMEModeButton)
  • Line 185–219: Transformable (unload flag, horizontal-tray check), DpiOf, OverrideBandWidth (fixed width scaled by DPI, or the measured glyph width / scaled 36 when the mode glyph is hidden)
  • Line 221–263: IndicatorProc subclass: overrides a nonzero 0x464 reply and records it as the band width; on WM_WINDOWPOSCHANGING, applies the IME-mode visibility, stores the incoming x in g_indicatorX (posting 0x415 when it changed), and moves the indicator to x = 0
  • Line 265–279: ShiftRightProc subclass: adds the band width to the incoming x of a band whose x is below g_indicatorX
  • Line 281–305: MainIconProc subclass: records the glyph width and centers InputIndicatorButton in the slot when the mode glyph is hidden
  • Line 307–344: taskbar lookup: PID-filtered EnumWindows for Shell_TrayWnd, then FindWindowExW for TrayNotifyWnd
  • Line 346–410: SyncNotify: caches the indicator, mode-glyph and main-glyph handles, seeds the glyph and band widths, subclasses every TrayNotifyWnd child with ShiftRightProc and the indicator / main glyph with their own procs
  • Line 412–434: Refresh (posts 0x415 to TrayNotifyWnd) and HandleIdentifiedTrayNotify (PID check, stores hNotify, sync, visibility, relayout)
  • Line 436–480: HandleCreatedWindow and the CreateWindowExW hook: wires the mod up when TrayNotifyWnd is created, and subclasses direct children of TrayNotifyWnd that are created later with ShiftRightProc
  • Line 484–512: Wh_ModInit (settings, installs the hook), Wh_ModAfterInit (finds an existing tray when enabled mid-session), Wh_ModSettingsChanged (reload, visibility, relayout)
  • Line 514–548: Wh_ModUninit: shows the IME mode button, sets the unload flag, removes ShiftRightProc from the current children and the two other subclasses from the cached windows, posts a relayout

Side effects of interest

  • None found. The mod only hooks CreateWindowExW and subclasses tray windows in its own explorer.exe. The EnumWindows lookup is filtered by PID. The ShowWindow calls and the 0x415 posts go to cached handles of that process's own tray windows. No files, registry, network or system settings are touched.


Next steps:

  • /ai-review - after pushing fixes, to get a review of the updated code. You can repeat this as many times as you need, but each review is thorough and usually there's no need for more than 2-3 iterations.
  • /ready-for-reviewer - once you're satisfied with the state of the pull request, to hand it over to a human reviewer. If some findings above are left unaddressed, add a short note explaining why.

See the review process for details.

Important: Each reply that was generated by AI must be disclosed by including the following text in the reply: "Generated by AI. Model: (ai-model-name)".

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-author The author's turn: request an AI review, or respond to one that was posted. and removed waiting-for-ai-review An AI review was requested and is being prepared. labels Nov 16, 2026
…tion/[un]init).

Also fix potential race condition in uninit.
@yumeyao

yumeyao commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/ai-review

just a cleanup round:

I reordered the functions to make them logically grouped (settings/hook/injection/mod[un]init). The AI agent broke it badly.

The comment is fixed. and the uninit race condition is fixed.

The startup sequence is also proved by reverse engineering: IME icons are always created, just show/hide difference.

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-ai-review An AI review was requested and is being prepared. and removed waiting-for-author The author's turn: request an AI review, or respond to one that was posted. labels Nov 16, 2026
@windhawk-reviewer

Copy link
Copy Markdown

Submission review

Note: This review was done by Claude. Due to the amount of submissions, doing a fully manual review for each pull request is no longer feasible. Thank you for understanding.

Remember: The AI reviewer can be wrong - it may misread code, flag correct code as broken, or suggest changes that make things worse. Treat its findings as suggestions to verify, not instructions to follow blindly. You're responsible for the code you submit, so if a finding doesn't hold up, say so instead of changing working code to satisfy it.

Please address the following issues. The items in the collapsed sections are optional, so it's your call whether to address them.


This round fixes the two optional items from the last review:

  • The ownership comment now matches the code (lines 376–377): the PID check runs once, on the tray lookup.
  • Wh_ModUninit removes the subclasses with EnumChildWindows (lines 513–516, 533). If a band is destroyed while the removal loop runs, that band is skipped and the loop keeps going.

You also confirmed that the indicator and its glyph windows always exist and are only shown or hidden. That settles the caching question from the functionality notes. The rest of the commit only moves functions around, and the logic is unchanged.

No blocking issues. Looks good to merge.

Optional improvements

Minor polish — none of this affects users, so it's your call.

  • The comment at line 303 still says the indicator is a "Direct child of the taskbar". The FindWindowExW call under it looks the indicator up under TrayNotifyWnd, not under Shell_TrayWnd.

Functionality notes

Non-critical observations and ideas about the feature behavior itself.

  • One-pass lag when bands change (FYI, by design; see the comment at lines 147–152). Each pass decides which bands to shift using the indicator's x from the previous pass. Suppose the bands left of the indicator shrink by more than the indicator's width in one step, for example when several tray icons disappear at once. The first band right of the indicator, normally the clock, then also falls below the old boundary. For one frame it's shifted and overlaps its neighbor, until the posted relayout corrects it. A fresh enable has a similar one-frame glitch: g_indicatorX starts at 0, so the first pass puts the indicator on top of the chevron.
  • Related mods: none is a near-duplicate. taskbar-language-indicator-layout-control addresses the tray jump when the indicator is hidden while an RDP window is active. more-space-in-language-indicator only changes the indicator's text layout. Neither keeps the tray icons in place when the indicator's width changes.

Code overview

For the maintainer: a map of the mod and what it touches outside its own process. Descriptive only — anything that needs a change is listed above. Line numbers refer to the mod source at commit 5534e09. This mod is new, so everything below is new.

Code regions

  • Line 1–11: metadata (@include explorer.exe, no @architecture, -lcomctl32 for the subclass APIs)
  • Line 13–68: README: the width-bounce misclick, the three modes, before/after GIFs on raw.githubusercontent.com, AI credit and tested builds
  • Line 70–82: settings: moveToLeft (bool, on), fixedWidth (number, -1 = natural width, DPI-scaled), hideImeMode (bool, off)
  • Line 84–153: includes and globals: atomic copies of the settings and the measured glyph width; tray class names; Explorer's private messages 0x464 (band min-size query) and 0x415 (relayout); the Tray struct of atomic HWNDs and the band width; the unload flag; g_indicatorX, the indicator's last untransformed x, which is the boundary for shifting
  • Line 155–162: LoadSettings: reads the three settings
  • Line 164–174: EnforceImeModeHidden: ShowWindow SW_HIDE/SW_SHOW on the cached IMEModeButton
  • Line 176–210: Transformable (unload flag, horizontal-tray check), DpiOf, OverrideBandWidth (fixed width scaled by DPI, or the measured glyph width / scaled 36 when the mode glyph is hidden)
  • Line 212–254: IndicatorProc subclass: overrides a nonzero 0x464 reply and records it as the band width. On WM_WINDOWPOSCHANGING it applies the IME-mode visibility, stores the incoming x in g_indicatorX (posting 0x415 when it changed), and moves the indicator to x = 0
  • Line 256–270: ShiftRightProc subclass: adds the band width to the incoming x of a band whose x is below g_indicatorX
  • Line 272–296: MainIconProc subclass: records the glyph width, centers InputIndicatorButton in the slot when the mode glyph is hidden
  • Line 298–362: SyncNotify: caches the indicator, mode-glyph and main-glyph handles, seeds the glyph and band widths. It subclasses every TrayNotifyWnd child with ShiftRightProc, and the indicator and main glyph with their own procs
  • Line 364–374: Refresh: posts 0x415 to TrayNotifyWnd
  • Line 376–421: IsOwnedByCurrentProcess and the taskbar lookup: PID-filtered EnumWindows for Shell_TrayWnd, then FindWindowExW for TrayNotifyWnd
  • Line 423–433: HandleIdentifiedTrayNotify: PID check, stores hNotify, sync, visibility, relayout
  • Line 435–479: HandleCreatedWindow and the CreateWindowExW hook: wires the mod up when TrayNotifyWnd is created, and subclasses direct children of TrayNotifyWnd created later with ShiftRightProc
  • Line 483–511: Wh_ModInit (settings, installs the hook), Wh_ModAfterInit (finds an existing tray when enabled mid-session), Wh_ModSettingsChanged (reload, visibility, relayout)
  • Line 513–548: RemoveShiftSubclassProc and Wh_ModUninit: shows the IME mode button, sets the unload flag, removes ShiftRightProc from all descendants of TrayNotifyWnd via EnumChildWindows, removes the two other subclasses from the cached windows, posts a relayout

Side effects of interest

  • None found. The mod only hooks CreateWindowExW and subclasses tray windows in its own explorer.exe. The EnumWindows lookup is filtered by PID. The ShowWindow calls and the 0x415 posts go to that process's own tray windows. No files, registry, network or system settings are touched.


Next steps:

  • /ai-review - after pushing fixes, to get a review of the updated code. You can repeat this as many times as you need, but each review is thorough and usually there's no need for more than 2-3 iterations.
  • /ready-for-reviewer - once you're satisfied with the state of the pull request, to hand it over to a human reviewer. If some findings above are left unaddressed, add a short note explaining why.

See the review process for details.

Important: Each reply that was generated by AI must be disclosed by including the following text in the reply: "Generated by AI. Model: (ai-model-name)".

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-author The author's turn: request an AI review, or respond to one that was posted. and removed waiting-for-ai-review An AI review was requested and is being prepared. labels Nov 16, 2026
@yumeyao

yumeyao commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/ready-for-reviewer

@windhawk-reviewer windhawk-reviewer Bot added waiting-for-reviewer Ready for a human reviewer, and in the queue for one. and removed waiting-for-author The author's turn: request an AI review, or respond to one that was posted. labels Nov 16, 2026
@m417z
m417z merged commit 2e3f0ac into ramensoftware:main Nov 18, 2026
6 checks passed
@windhawk-reviewer windhawk-reviewer Bot removed the waiting-for-reviewer Ready for a human reviewer, and in the queue for one. label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants