Skip to content

Add Desktop Peek feature — click empty desktop/taskbar to reveal windows#743

Open
wangjiati wants to merge 5 commits into
RamonUnch:mainfrom
wangjiati:feature/peek-desktop
Open

Add Desktop Peek feature — click empty desktop/taskbar to reveal windows#743
wangjiati wants to merge 5 commits into
RamonUnch:mainfrom
wangjiati:feature/peek-desktop

Conversation

@wangjiati
Copy link
Copy Markdown

Summary

Port PeekDesktop (by Scott Hanselman, MIT License) into AltSnap.

Click on empty desktop wallpaper (or empty taskbar area) to reveal your desktop — just like macOS Sonoma. All visible windows minimize with a single click; click again or switch to any application to restore them.

Changes

New features

  • peek.c (~580 lines) — Low-level mouse hook detects clicks on desktop wallpaper and empty taskbar. Implements minimize/restore with FlyAway animation mode, gaming suppression, restore-on-focus-change, and drag-to-cancel.
  • Peek settings UI — 7 controls added to General tab (enable, double-click mode, taskbar peek, gaming pause, restore-on-app-switch, peek mode selector)
  • Complete localization — All 19 supported languages have Peek translations
  • Documentation — README (EN/ZH/KO) updated with feature description

Bug fixes

  • IsFullscreenApp false-positive with system windows (TextInputHost, etc.)
  • IsTaskbarBlank rewritten with parent-chain traversal + MonitorFromPoint fallback
  • Mouse-up event no longer blocked (returns 0 to let event propagate)
  • Double-click detection state preserved across click pairs
  • About-tab crash fixed (duplicate control IDs in window.rc)
  • Layout: all 6 property-sheet pages unified to 275px height, dialog expanded to 260 DLU

Maintenance

  • .gitignore added (excludes .claude/, build/, tests/, release/)
  • ziprelease.bat: include AltSnap.dni in ZIP package (was missing)

Test plan

  • Desktop click minimizes all visible windows
  • Click again or switch app restores windows
  • Double-click mode works correctly
  • Taskbar blank-area click triggers peek
  • Gaming suppression pauses peek during fullscreen apps
  • All UI controls save/load correctly from INI
  • Translations display correctly in all 19 languages
  • Clean build with 0 warnings (MakefileX64, GCC 15.2)

wangjiati and others added 4 commits May 31, 2026 19:33
Port PeekDesktop (github.com/shanselman/PeekDesktop) into AltSnap:
- new peek.c: low-level mouse hook detects clicks on desktop wallpaper
  and empty taskbar area, minimizes all visible windows on click and
  restores them on next click/app-switch (like macOS Sonoma)
- add Peek controls to General tab: enable/disable, double-click mode,
  taskbar peek, gaming pause, restore-on-app-switch, peek mode selector
- add configuration support (optlst/strlst/combo) in config.c
- add 8 control IDs in resource.h and expand dialog layout to fit
- unify all 6 property-sheet pages to 275px height with consistent
  container margins, expand dialog width to 260 DLU
- add complete Peek translations for all 19 supported languages
- document the feature in README (EN/ZH/KO)
- add .gitignore to exclude .claude/, build/, tests/

Bugs fixed along the way:
- IsFullscreenApp false-positive with system windows (TextInputHost etc.)
- IsTaskbarBlank now walks parent chain + uses MonitorFromPoint fallback
- PeekHandleMouseEvent no longer blocks mouse-up from propagating
- double-click detection state preserved across click pairs
- About-tab crash (duplicate control IDs in window.rc, NULL langinfo)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The ZIP package was missing AltSnap.dni (the default config template).
Without it, new portable users would start with no configuration at all.
The NSIS installer already included it; this aligns the ZIP with the
installer. Also replaced the pre-configured AltSnap.ini with the template
.dni so that the portable package uses the same documented defaults.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@RamonUnch
Copy link
Copy Markdown
Owner

Excuse me to say that, I do reckon you did a lot of work, but I have a lot of problems with your PR.

  1. Is it really needed to integrate this into AltSnap? when there is already another program doing the job perfectly, If there is no benefit other than having a single program, then I will not to add this feature.

  2. in function IsDesktopIcon()
    Why do you need to allocate/read remote process memory, this should never be done, editing another process memory is a huge security risk.

Also why is PEEK_LVM_HITTEST defined to 0x1009? if it is an actual alias for LVM_HITTEST it should be (LVM_FIRST+18) which is 0x1012. Were did you find this information? This is all crazy to me, especially considering it seems you are not using the function anywhere anyway.

Anyway connecting to a remote process and querying a list view which is not guarantee to be there in the future is a no-go.

  1. There are far too much hard-coded strings of random internal windows programs taht have changed in the past and will keep changing in the future.

  2. Why do you need to set an event hook? there is no good reason for that, the LowLevel mouse hook should be enough.

You did a lot of work indeed. However, if you want the feature, why not just use PeekDesktop?
Adding more to AltSnap will not benefit much if PeekDesktop works alongside AltSnap. the first step would be a very strong rational for that.

Match the original release format: use AltSnap.ini (portable config)
instead of AltSnap.dni (template), and include the Themes/ directory.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@eodomo
Copy link
Copy Markdown

eodomo commented May 31, 2026

I'm not sure what this application's policy is on vibe-coded features, but I'd personally be hesitant with how much of this PR (seemingly all of it) appears to be AI generated.

Just looking at the .gitignore changes, it looks like it's totally centered around Claude.

@wangjiati
Copy link
Copy Markdown
Author

A quick note before we start

I want to be upfront: I used Claude (Anthropic's AI coding assistant) to help port the PeekDesktop logic to C, organize commits, and write the PR. I did all the manual testing on real hardware myself. The bugs you spotted — dead code, class name filters, wrong LVM_HITTEST value — those are on me, I should have reviewed the AI output more carefully.

Also, Chinese is my native language and this reply was written with translation help, so please excuse any phrasing that sounds unnatural.


Thanks so much for the thorough review — I really appreciate you taking the time to go through the code carefully.

Rationale for integration

I deploy AltSnap on industrial PCs where operators have minimal computer skills. There are two concrete problems that integration solves:

  1. Training cost. Teaching a production-line worker to press Win+D and then restore windows individually is a real training burden — it seems simple to us, but for non-technical staff it generates support calls. One click on empty desktop wallpaper to hide everything, one click to bring it all back: that's intuitive for anyone.

  2. Process reliability. Running two WH_MOUSE_LL hook-based programs side by side means two processes to keep alive on every device. If either crashes silently, the operator doesn't know which one broke — they just know "it doesn't work anymore." A single process = a single thing to monitor.

I understand this may not be a feature you want to carry in the mainline, and I'll respect your decision either way.

Bugs and code issues — fixed

IsDesktopIcon() — removed

You're absolutely right about the cross-process memory access. This was dead code — I removed the call during testing (the icon check made peek unusable on icon-dense desktops) but forgot to clean up the function. Removed:

  • IsDesktopIcon(), FindDesktopListView()
  • PEEK_LVHITTESTINFO struct
  • PEEK_LVM_HITTEST constant (you're correct: LVM_HITTEST = LVM_FIRST + 18 = 0x1012)
  • All OpenProcess / VirtualAllocEx / WriteProcessMemory / ReadProcessMemory / VirtualFreeEx calls

PEEK_LVM_HITTEST value

Porting error from the C# source — you're correct. Since IsDesktopIcon is removed entirely, this constant goes with it. If it ever needs to come back, I'd use the canonical LVM_FIRST + 18 form.

UWP class name filters — removed

Windows.UI.Core.CoreWindow and ApplicationFrameWindow removed from EnumPeekWindows. The remaining filters are only the truly stable ones (Progman, WorkerW, Shell_TrayWnd — unchanged since NT4/Win95). The enumeration already safely skips unqualified windows via IsVisible / IsIconic / IsCloaked checks. Removing these class-name shortcuts means, at worst, a UWP window gets minimized too — which is harmless.

WinEvent hook — kept with explanation

I've kept the SetWinEventHook(EVENT_SYSTEM_FOREGROUND) but added comments clarifying it is only installed while actively peeking AND only when the user has enabled "Restore on app switch" (PeekFlags bit3). Without the hook, peeking works fine — the user just needs to click the desktop again to restore. The hook simply makes the experience smoother: when you Alt+Tab to another app after peeking, everything restores automatically. It is uninstalled immediately when peek ends.

Summary of changes (latest commit)

Change Lines
Remove IsDesktopIcon + helpers -45
Remove PEEK_LVHITTESTINFO + PEEK_LVM_HITTEST -7
Remove UWP class name filters -2
Add clarifying comments on WinEvent hook +5
Net -50

Let me know if there are other issues you'd like me to address. Thanks again for the careful review.

@RamonUnch
Copy link
Copy Markdown
Owner

I am personally bias against IA, but I would prefer to be more neutral in this regard.
LLMs can be great tools for coding, but I will demand that the generated code be perfectly understood by the person who commits it.
Also I want to stay in control of the code, meaning it has to be understandable and clean enough for me, and this applies to all code. Whether it is made by AI or human is not really the Issue.

It is always difficult to say no to people that are trying their best to have a meaningful contribution. My plan is to maintain a program that people enjoy using.

It seems a lot of lines of code for basically just a "minimize / restore all windows".

Also I want to stay a little humble, I have proven myself clueless recently. #723.
Even though the PR #723 was very straightforward the LLM was clueless about the fact the message result is retried by reference an not by the return value in the SendMessageTimeout() function. So any code should be re-read carefully, double checking all API specifics.

@RamonUnch
Copy link
Copy Markdown
Owner

I did not review deeply yet, I was just quickly looking into the code.

So the rationale for having this inside AltSnap is only to have the feature + AltSnap with a single process.
Of course the feature is desirable for some people, I wont argue on this point.

How often does one of the process crashes and has to be restarted? How hard can it be to install both of them given they are both available on winget?
Is this such a hassle to have two programs running? Each of the eats just a couple of MB or RAM. Even in the early 2000s this would have been fine for typical hardware.
If one of them is so unstable it has to be restarted often, then it would be wiser to just fix the crash rather than porting the whole program into an other.

Also PeekDesktop is written in C# which is a managed Language an has more protections against crashes than a plain C, where a small mistake in the code can lead to catastrophic failure. Of course this may not be very relevant for this specific application where you have to call a lot of raw Win32 API.

I will for now keep this PR opened and I will wait to see if it can be more simply implemented in the future when maybe I will have other uses for a global event hook in the program.
Having an action triggered when clicking the desktop could be generalized, as well. Even If I were to implement this I would prefer to take more time to think about it.

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.

3 participants