Skip to content

Add click-outside hide preference - #22

Closed
alvst wants to merge 1 commit into
momenbasel:mainfrom
alvst:pr-22-click-outside
Closed

Add click-outside hide preference#22
alvst wants to merge 1 commit into
momenbasel:mainfrom
alvst:pr-22-click-outside

Conversation

@alvst

@alvst alvst commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Add a setting to choose whether Pesty hides when focus moves outside its bar.
  • Honor that preference in the bar panel's focus-loss handling.

Why

Users can keep the bar open while working elsewhere when that better suits their workflow.

Validation

  • swift build
  • swift build -Xswiftc -DMAS
  • Tested on Apple Silicon. Intel Mac testing was not available.

Screenshots

To be added.

@alvst
alvst marked this pull request as ready for review July 26, 2026 22:06
@momenbasel

Copy link
Copy Markdown
Owner

Defaults preserve current behaviour, which is right, and the three-line mechanism is correct in isolation. What it does not account for is what the app does once the bar is allowed to outlive an app switch.

previousApp is captured only inside showBar(). With the preference off, the bar survives app switches but the paste target does not update - so pasting targets whatever app was frontmost when the bar was first opened. Focus Safari, open the bar, click into Notes, click a clip: on the direct-download build PasteService activates Safari and synthesizes Cmd-V into it, so the clip lands in a window you are not looking at.

lastActiveApp is already maintained on every workspace activation and currently only feeds source attribution. Falling back to it, or re-capturing previousApp while the bar is visible, fixes this.

There is also no escape hatch once the bar is pinned. The panel is .modalPanel level with hidesOnDeactivate = false and joins all spaces, so a 430pt bar sits over every app including full-screen ones, and Escape does nothing because the key handler is a local monitor that receives nothing while another app is frontmost. The only ways out are the global hotkey and the menu bar item - and the menu bar item is now hideable, since #23 merged. Worth keeping the hide on applicationWillResignActive regardless of the setting, or dropping the panel to .floating when the preference is off.

Minor: the label says click-outside but the guard sits on windowDidResignKey, which also fires for Cmd-Tab and for Pesty own Settings window taking key - so with the preference off the bar floats above your own Settings window.

@momenbasel

Copy link
Copy Markdown
Owner

Maintainer pass — landed reworked via #74, closing as superseded.

Assessment: the three-line mechanism and the preserve-current-behaviour default were right. The review's concerns about what happens once the bar outlives an app switch are addressed as follows in #74 (with Co-authored-by credit):

  • Stale paste target: fixed independently by the pasteTarget work extracted from Add full clip context menu actions #42 — pastes now resolve through lastActiveApp (updated on every workspace activation), so clicking into Notes with the bar pinned and then choosing a clip pastes into Notes, not the app that was frontmost when the bar first opened.
  • No escape hatch over full-screen apps: when the preference is off, the panel now shows at .floating instead of .modalPanel (the review's suggested option), so a pinned bar no longer sits above everything at modal level. The global hotkey and menu bar item remain the dismissal paths, and Escape still works whenever the bar is key.
  • One gap the diff missed: the show() settle handler has its own "bar is unfocused, hide it" backstop (from the Don`t open clipboard #64 presentation rework) that the PR's guard didn't cover — with the preference off, that backstop would have dismissed the pinned bar the moment it finished animating without focus. It now respects the setting too.

The windowDidResignKey-also-fires-on-⌘Tab wording nit stands, but with .floating level the practical impact is small and the label matches the common case. Verified with swift build and swift build -Xswiftc -DMAS. Thanks @alvst!

— automated maintainer pass on behalf of @momenbasel

@momenbasel momenbasel closed this Aug 12, 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