Skip to content

Conversation

@Cinabutts
Copy link

@Cinabutts Cinabutts commented Jan 7, 2026

Major Changes:

  1. Window Subclassing System Overhaul (Comments 1, 10)

    • Replaced SetWindowLongPtrW with WindhawkUtils::SetWindowSubclassFromAnyThread for all window subclassing
    • Updated subclass callbacks to use the standard DWORD_PTR refData parameter (matches SetWindowSubclass/WindhawkUtils expectations)
    • Removed fallback ListView subclassing (SHELLDLL_DefView handles input properly)
    • Added proper cleanup with RemoveWindowSubclassFromAnyThread in WM_NCDESTROY handlers
    • Updated function signatures to use DefSubclassProc instead of CallWindowProcW
  2. Process Isolation (Comments 4, 6)

    • Added IsWindowInCurrentProcess() helper function
    • Now verifies ListView and ShellView belong to current explorer.exe process
    • Added a process check for SHELLDLL_DefView under Progman; if not current-process, falls back to WorkerW search
    • Prevents the mod from affecting other explorer processes
  3. Settings API Fixes (Comments 2, 3)

    • Fixed Wh_GetIntSetting calls to use single argument (removed incorrect TRUE parameter)
    • Added Wh_FreeStringSetting to properly free string memory
    • Changed settings structure to nested modifierKeys object (matches Windhawk patterns)
  4. Initialization Improvements (Comments 7, 8)

    • Removed Sleep(2000) hack from Wh_ModAfterInit
    • Removed unnecessary bInitialized flag
    • Added EnsureValidListView() helper for dynamic ListView validation
    • ListView now re-discovered on-demand if window becomes invalid
    • After settings changes, re-discovers shell/ListView handles and refreshes visibility state before re-establishing subclasses (hotkeys keep working)
  5. Code Cleanup (Comments 5, 9)

    • Removed redundant RestoreIconsToVisible call from Wh_ModBeforeUninit (already in Wh_ModUninit)
    • Added null checks and proper error handling throughout
    • Added ToUpperCase() helper for case-insensitive key matching
    • WM_CHAR handling now requires Ctrl when configured and respects Alt, preventing false positives from control codes

Additional Improvements:

  • Added <commctrl.h> and <windhawk_utils.h> includes
  • Added --optimize=0 --debug compiler options
  • Enhanced documentation in readme with modifier key details
  • Better logging and error messages throughout

Description:
Toggle desktop icon visibility with a customizable hotkey (default Ctrl+Alt+D). Includes support for configurable modifiers and key. Tested on Windows 11 24h2 (64-bit).
Icons automatically restore when the mod is disabled. Lightweight and user-friendly.

This mod was cobbled together out of multiple hours of work with AI and a moderate level of understanding.
There is also a AHK script I created to coincide meant to link to this mods hotkey which will be up in my Win11 repo soon, This is so that you can call it from the other mod taskbar-empty-space-clicks ie Middle click = calls ahk which triggers the hotkey associated with this mod.
**Major Changes:**

1. **Window Subclassing System Overhaul (Comments ramensoftware#1, ramensoftware#10)**
   - Replaced `SetWindowLongPtrW` with `WindhawkUtils::SetWindowSubclassFromAnyThread` for all window subclassing
   - Removed fallback ListView subclassing (it was unnecessary since SHELLDLL_DefView handles input properly)
   - Added proper cleanup with `RemoveWindowSubclassFromAnyThread` in WM_NCDESTROY handlers
   - Updated function signatures to use `DefSubclassProc` instead of `CallWindowProcW`

2. **Process Isolation (Comments ramensoftware#4, ramensoftware#6)**
   - Added `IsWindowInCurrentProcess()` helper function
   - Now verifies ListView and ShellView belong to current explorer.exe process
   - Prevents mod from affecting other explorer processes

3. **Settings API Fixes (Comments ramensoftware#2, ramensoftware#3)**
   - Fixed `Wh_GetIntSetting` calls to use single argument (removed incorrect TRUE parameter)
   - Added `Wh_FreeStringSetting` to properly free string memory
   - Changed settings structure to nested `modifierKeys` object (matches Windhawk patterns)

4. **Initialization Improvements (Comments ramensoftware#7, ramensoftware#8)**
   - Removed `Sleep(2000)` hack from `Wh_ModAfterInit`
   - Removed unnecessary `bInitialized` flag
   - Added `EnsureValidListView()` helper for dynamic ListView validation
   - ListView now re-discovered on-demand if window becomes invalid

5. **Code Cleanup (Comments ramensoftware#5, ramensoftware#9)**
   - Removed redundant `RestoreIconsToVisible` call from `Wh_ModBeforeUninit` (already in Wh_ModUninit)
   - Added null checks and proper error handling throughout
   - Added `ToUpperCase()` helper for case-insensitive key matching

**Additional Improvements:**
- Added `<commctrl.h>` and `<windhawk_utils.h>` includes
- Added `--optimize=0 --debug` compiler options
- Enhanced documentation in readme with modifier key details
- Better logging and error messages throughout
@Cinabutts Cinabutts marked this pull request as ready for review January 7, 2026 06:25
Copilot AI review requested due to automatic review settings January 7, 2026 06:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Windhawk mod that allows users to toggle desktop icon visibility using a configurable hotkey (default: Ctrl+Alt+D). The mod is a complete rewrite addressing feedback from a previous review, with major improvements to window subclassing, process isolation, settings API usage, and initialization logic.

Key Changes

  • Implements proper window subclassing using WindhawkUtils API with automatic cleanup
  • Adds process isolation to prevent the mod from affecting other explorer.exe instances
  • Implements configurable hotkey support with nested settings structure
  • Includes robust window discovery with dynamic re-validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Cinabutts Cinabutts closed this Jan 7, 2026
@Cinabutts Cinabutts reopened this Jan 7, 2026
**Major Changes:**

1. **Window Subclassing System Overhaul (Comments [1](ramensoftware#2267 (comment)), [10](ramensoftware#2267 (comment)
   - Replaced `SetWindowLongPtrW` with `WindhawkUtils::SetWindowSubclassFromAnyThread` for all window subclassing
   - Updated subclass callbacks to use the standard `DWORD_PTR` refData parameter (matches `SetWindowSubclass`/WindhawkUtils expectations)
   - Removed fallback ListView subclassing (SHELLDLL_DefView handles input properly)
   - Added proper cleanup with `RemoveWindowSubclassFromAnyThread` in WM_NCDESTROY handlers
   - Updated function signatures to use `DefSubclassProc` instead of `CallWindowProcW`

2. **Process Isolation (Comments [4](ramensoftware#2267 (comment)), [6](ramensoftware#2267 (comment)
   - Added `IsWindowInCurrentProcess()` helper function
   - Now verifies ListView and ShellView belong to current explorer.exe process
   - Added a process check for `SHELLDLL_DefView` under Progman; if not current-process, falls back to WorkerW search
   - Prevents the mod from affecting other explorer processes

3. **Settings API Fixes (Comments [2](ramensoftware#2267 (comment)), [3](ramensoftware#2267 (comment)
   - Fixed `Wh_GetIntSetting` calls to use single argument (removed incorrect TRUE parameter)
   - Added `Wh_FreeStringSetting` to properly free string memory
   - Changed settings structure to nested `modifierKeys` object (matches Windhawk patterns)

4. **Initialization Improvements (Comments [7](ramensoftware#2267 (comment)), [8](ramensoftware#2267 (comment)
   - Removed `Sleep(2000)` hack from `Wh_ModAfterInit`
   - Removed unnecessary `bInitialized` flag
   - Added `EnsureValidListView()` helper for dynamic ListView validation
   - ListView now re-discovered on-demand if window becomes invalid
   - After settings changes, re-discovers shell/ListView handles and refreshes visibility state before re-establishing subclasses (hotkeys keep working)

5. **Code Cleanup (Comments [5](ramensoftware#2267 (comment)), [9](ramensoftware#2267 (comment)
   - Removed redundant `RestoreIconsToVisible` call from `Wh_ModBeforeUninit` (already in Wh_ModUninit)
   - Added null checks and proper error handling throughout
   - Added `ToUpperCase()` helper for case-insensitive key matching
   - WM_CHAR handling now requires Ctrl when configured and respects Alt, preventing false positives from control codes

**Additional Improvements:**
- Added `<commctrl.h>` and `<windhawk_utils.h>` includes
- Added `--optimize=0 --debug` compiler options
- Enhanced documentation in readme with modifier key details
- Better logging and error messages throughout
@Cinabutts
Copy link
Author

@m417z Let me know what ya think

@Cinabutts Cinabutts requested a review from m417z January 8, 2026 04:05
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