All field notesEngineering

The drawer is not a window

It is an NSPanel that never takes focus, which is the only reason ⌘V can land in the app you were already in. What that costs, and the three AppKit behaviors we had to give up to get it.
By the Pastry team at Monospace®8 min read
01

The one thing it must not steal

A clipboard manager has a peculiar job. It has to appear instantly, accept a decision, and disappear without making the application underneath it feel interrupted. The obvious implementation is a normal window. The obvious implementation also takes focus.

That tiny change breaks the whole interaction. If Pastry becomes the active application, the Return key belongs to Pastry, but the paste that follows no longer knows where you were working. A tool meant to remove a detour has created a larger one.

The drawer can be visible and interactive without becoming the frontmost application.
02

A panel, with conditions

The drawer is an NSPanel configured to sit above ordinary windows and opt out of the usual activation dance. AppKit still draws it, moves it, and gives it a place on every Space. It simply does not announce itself as a new destination for your work.

That gives us the essential sequence: press Command-Shift-V, move through history, press Return, and land back in the field that was active before the drawer arrived. There is no focus restoration animation because there was no focus transfer to undo.

03

What the drawer gives up

Once a window stops behaving like a normal window, many free AppKit behaviors stop being free. Key events need a deliberate route. Clicking while secure input is active needs special care. Showing and hiding must be coordinated with the application that still owns the keyboard.

The window also cannot be allowed to wander. Pastry measures the active screen, pins the panel to its lower edge, and treats that position as part of the interaction rather than a remembered window preference. A drawer in the middle of the display is just a palette with the wrong name.

04

Why it is still worth it

The panel is harder to build than a window and easier to use than one. That is a trade we will keep making. The most important part of a utility is often the behavior a screenshot cannot show: what stays selected, which application remains active, and whether your hands have to change their plan.

Pastry is not trying to become the place where the work happens. It is trying to return one useful thing to that place, then get out of the way.

Read next

What a clipboard should refuse to remember

Every clipboard manager is a keylogger you installed on purpose. The interesting engineering is not in what it keeps - it is in the classifier deciding, locally and in a millisecond, what never gets written down.

Continue reading