-
Notifications
You must be signed in to change notification settings - Fork 179
Add: Desktop-icons-toggle #2968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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
There was a problem hiding this 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.
**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
|
@m417z Let me know what ya think |
Removed `--optimize=0 --debug`
Major Changes:
Window Subclassing System Overhaul (Comments 1, 10)
SetWindowLongPtrWwithWindhawkUtils::SetWindowSubclassFromAnyThreadfor all window subclassingDWORD_PTRrefData parameter (matchesSetWindowSubclass/WindhawkUtils expectations)RemoveWindowSubclassFromAnyThreadin WM_NCDESTROY handlersDefSubclassProcinstead ofCallWindowProcWProcess Isolation (Comments 4, 6)
IsWindowInCurrentProcess()helper functionSHELLDLL_DefViewunder Progman; if not current-process, falls back to WorkerW searchSettings API Fixes (Comments 2, 3)
Wh_GetIntSettingcalls to use single argument (removed incorrect TRUE parameter)Wh_FreeStringSettingto properly free string memorymodifierKeysobject (matches Windhawk patterns)Initialization Improvements (Comments 7, 8)
Sleep(2000)hack fromWh_ModAfterInitbInitializedflagEnsureValidListView()helper for dynamic ListView validationCode Cleanup (Comments 5, 9)
RestoreIconsToVisiblecall fromWh_ModBeforeUninit(already in Wh_ModUninit)ToUpperCase()helper for case-insensitive key matchingAdditional Improvements:
<commctrl.h>and<windhawk_utils.h>includes--optimize=0 --debugcompiler options