Skip to content

Restore "Show desktop on wallpaper click" as an opt-in setting#210

Merged
AllTerrainDeveloper merged 1 commit into
trunkfrom
bring-back-show-desktop
May 14, 2026
Merged

Restore "Show desktop on wallpaper click" as an opt-in setting#210
AllTerrainDeveloper merged 1 commit into
trunkfrom
bring-back-show-desktop

Conversation

@AllTerrainDeveloper
Copy link
Copy Markdown
Collaborator

@AllTerrainDeveloper AllTerrainDeveloper commented May 14, 2026

Summary

Adds a new per-user toggle in OS Settings → Features:
"Show desktop when clicking the wallpaper" (off by default).

The macOS-style left-click-the-wallpaper gesture used to be the only
way to trigger Show Desktop. It was moved into the wallpaper context
menu (CMO) so left-clicks on the desktop wouldn't surprise users who
weren't expecting that affordance. This brings the gesture back as an
opt-in, with the two surfaces kept mutually exclusive so there's
never a redundant entry on screen:

  • Off (default) — wallpaper left-clicks do nothing; the
    Show desktop entry appears in the wallpaper CMO.
  • On — left-clicking the empty wallpaper toggles Show Desktop;
    the matching CMO entry is suppressed.

Also tidies up the Features tab: each toggle + hint pair now has a
hairline separator above it (matching the existing __row separator
at the bottom of the section), so the wall of checkboxes reads as
grouped settings rather than one continuous list.

Tab placement

The toggle lives in Features, not Appearance: Features is
where per-user behavior flags live (native Posts/Pages/Users/Plugins/
Comments windows, AI comment scoring, reset what's-new dialogs).
Appearance is reserved for look-and-feel (wallpaper, accent, dock
size, layout). This is interaction behavior, so Features is the
right home.

State plumbing

New persisted field showDesktopOnWallpaperClick: boolean
(default false) wired end-to-end:

  • PHPdesktop_mode_default_os_settings() and
    desktop_mode_sanitize_os_settings() in includes/os-settings.php
    add the field with a (bool) coercion matching the surrounding
    native*Enabled flags.
  • TypeScript state — added to OsSettingsState
    (src/settings/types.ts), DEFAULTS (src/settings/constants.ts),
    and the _parseRaw sanitizer in src/settings/state.ts.

The field is intentionally not added to
OsSettingsSnapshot — it's a shell-level preference; no plugin
needs to read it. The shell reads osSettings.state.* directly at
click time.

Wallpaper menu wiring

src/desktop-files/wallpaper-menu.ts gains an optional
includeShowDesktop?: boolean field on WallpaperMenuDeps
(default true). When false, the built-in show-desktop item is
omitted from the menu's items list.

src/desktop.ts passes
includeShowDesktop: ! osSettings.state.showDesktopOnWallpaperClick
into the menu builder.

Left-click handler

src/desktop.ts registers a click listener on desktopArea,
gated on the setting:

desktopArea.addEventListener( 'click', ( e: MouseEvent ) => {
    if ( ! osSettings.state.showDesktopOnWallpaperClick ) return;
    if ( e.target !== desktopArea ) return;
    if ( desktopArea.classList.contains( 'desktop-mode-area--overview' ) ) return;
    if ( isWallpaperMenuOpen() ) return;
    manager.toggleShowDesktop();
} );

Guards in plain English:

  • target !== desktopArea — only the bare wallpaper. Clicks on a
    tile, widget, or any inner surface bubble up but mustn't trigger
    the toggle.
  • Overview check — overview owns its own pointer surface; a
    synthesized trailing click would otherwise minimize every window
    the moment the overview animation starts (this guard mirrors the
    one already in the contextmenu handler above).
  • isWallpaperMenuOpen() — if the CMO is currently open, the click
    should just dismiss it (handled by the menu's own outside-click
    listener) without also triggering Show Desktop.

Features section grouping

Each toggle + hint in src/settings/sections/features.ts is now
wrapped in <div class="desktop-mode-features__item">. A new rule
in assets/css/os-settings.css adds a hairline border + padding
above every item after the first:

.desktop-mode-features__item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.desktop-mode-features__item + .desktop-mode-features__item {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var( --wpd-border, rgba( 0, 0, 0, 0.08 ) );
}

This matches the border-top style already used by
.desktop-mode-features__row at the bottom of the section
("Reset what's-new dialogs").

Files changed

  • includes/os-settings.php — default + sanitize.
  • src/settings/types.tsOsSettingsState.showDesktopOnWallpaperClick.
  • src/settings/constants.tsDEFAULTS.showDesktopOnWallpaperClick.
  • src/settings/state.ts_parseRaw coercion.
  • src/settings/sections/features.ts — new checkbox; each toggle
    wrapped in __item divs.
  • src/desktop-files/wallpaper-menu.tsincludeShowDesktop deps flag.
  • src/desktop.ts — passes flag into menu builder; left-click handler.
  • assets/css/os-settings.css__item separators.
  • tests/vitest/desktop-files-wallpaper-menu.test.ts — new test
    asserting the show-desktop item is omitted when
    includeShowDesktop: false.

Test plan

  • npm run build — green.
  • ./node_modules/.bin/tsc --noEmit — green.
  • npm run lint — green.
  • npm run test:js — 1209 / 1209 passing.
  • npm run test:php — couldn't run locally (wp-env tests-mysql
    service won't start in this environment). PHP change is the same
    default-+-sanitize pattern the surrounding fields use; php -l
    on includes/os-settings.php passes.
  • Manual QA:
    • Default state: wallpaper left-click does nothing; CMO
      shows "Show desktop".
    • Toggle on: wallpaper left-click minimizes all windows;
      second click restores; CMO no longer shows "Show desktop".
    • Toggle persists across reload.
    • Right-click + dismiss-by-left-click still works.
    • Overview is unaffected (clicks on overview thumbnails
      don't trigger Show Desktop).
    • Features tab visually separates each toggle group.
Open WordPress Playground Preview

@AllTerrainDeveloper AllTerrainDeveloper enabled auto-merge (squash) May 14, 2026 09:53
@github-actions
Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@AllTerrainDeveloper AllTerrainDeveloper merged commit d25bfa5 into trunk May 14, 2026
5 checks passed
@AllTerrainDeveloper AllTerrainDeveloper deleted the bring-back-show-desktop branch May 14, 2026 09:56
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.

1 participant