Repository navigation
Conversation
xevrion
force-pushed
the
feat/gui-drag-out
branch
from
November 27, 2026 19:28
90092d0 to
36c6da3
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rows of the contents tree can be dragged into Explorer (Windows) or the Finder (macOS), which extracts just those entries. The archive is always kept, as with "Extract selected…".
Design
Gesture (Slint, all systems). The row's
TouchAreacallsdrag(index)once a press moves more than 5 px. The press is then marked as a drag, so its release is not a click and does not change the selection or open/close a folder. Rust (App::drag_out) decides what goes: the whole selection if the row is part of it (or inside a chosen folder), the row alone otherwise, which is what file managers do. The dragged rows are dimmed (opacity 0.5) until the drop. That is the only visual change; nothing moves. The gesture only works where "Extract selected…" does: a fresh archive, nothing running.Extraction (
src/drag.rs, shared). This goes through the engine, the same way "Extract selected…" does:session::openwithonly, thensession::beginwithkeep_archive, thenRun::execute. The archive is opened read-only. Path safety and selection checks are the engine's own, and there is no new extractor. The difference is the journal:Pathspoint into the drag's own work folder, never next to the archive. So a drag can't leave a journal that looks like a run to resume, and the main window's read handle stays valid on Windows. A drag is refused if a real journal exists next to the archive. The space plan is checked first, using the reserve from settings. The password is the one the window already holds.Windows (
platform/windows.rs). OLEDoDragDrop, using the shell's own data object (SHCreateDataObject, so the formats Explorer sets during a drag are handled) with a CF_HDROP of paths under%TEMP%\hatchzip-drag-<pid>\<n>\out\. OnlyDROPEFFECT_COPYis offered. The files are extracted inIDropSource::QueryContinueDragwhen the button is released over a target whose last feedback was notDROPEFFECT_NONE. This happens before OLE tells the target about the drop, which is 7-Zip's old approach. Nothing is extracted while hovering, on Esc, or over a target that refuses.OleInitializeon the UI thread for its drop target. Before the drag the code callsOleInitializeagain, which only counts up, and matches it withOleUninitialize.DoDragDropruns its own message loop. If it ran inside a Slint callback (which runs inside winit's event handler), winit would panic on the firstWM_PAINT("event handler is re-entrant"), because it does not bufferRedrawRequested. So the drag starts from a one-shot threadSetTimercallback. The message loop dispatches that between events, so the window keeps drawing during the drag.PointerReleasedat (-1, -1) gives Slint back the button-up that OLE swallowed.drag::is_ours) instead of opening them as an archive.macOS (
platform/macos.rs).NSView beginDraggingSessionWithItems:event:source:, called synchronously from the Slint callback. At that pointNSApp.currentEventis theLeftMouseDraggedbeing handled; for any other event type the drag doesn't start. The view comes from winit's raw window handle.NSFilePromiseProviderper row. Its delegate (HatchZipFilePromise,define_class!) gives the file name and serveswritePromiseToURL:on a backgroundNSOperationQueue..hatchzip-drag-<pid>-<n>folder next to the destination (same disk), renames it into place, and removes the folder. It refuses to overwrite an existing path.HatchZipDragSource) offers Copy only and reports the end of the session. Delegates are kept for the life of the process, since a promise holds its delegate weakly.NSWorkspace iconForFileType:. It is deprecated, but the replacement needs UTType bindings the app doesn't otherwise use.Linux. winit has no drag source, so
DRAG_OUTis false and the gesture does nothing. "Extract selected…" is the way there.Cleanup. The Windows temp folder of this process is removed when the app exits.
hatchzip-drag-*folders older than a day (left after a crash) are removed at startup. Temp files can't be removed right after the drop, because Explorer may still be copying from them.Concurrency. While entries are being extracted for a drop (on macOS that happens after the drag ended, on a background thread), Extract and "Extract selected…" are refused with a notice. The drop reads the archive without a lock, so an in-place run must not shrink it underneath.
Trade-offs
DRAG_LIMIT, uncompressed size from the tree). Above that a notice points to "Extract selected…". Virtual files (CFSTR_FILEDESCRIPTOR/CFSTR_FILECONTENTS, what newer 7-Zip does) would avoid the double write and the cap, but need a full customIDataObjectwithIStreams and much more unsafe code. That is left for later.session::beginalso records the temp output in the "chosen outputs" record for the archive, and the finished run forgets it. That is harmless, because drags are refused while a real journal exists. It does mean a second HatchZip process with a run in progress on the same archive would lose its record. That is an edge case and is not handled.New messages
All four catalogs (es, hi, tr, zh_CN) are updated. Native speakers, please check:
Up to {} can be dragged out at once. Use Extract selected… for more.Entries dragged out of the archive are still being extracted. Try again when they are done."Insufficient disk space" (already translated) is reused for a drag that doesn't fit.
Verified
Only
cargo fmtran locally. Builds, clippy and tests run on CI only.drag.rs):../outsideand missing entries are refused.hatchzip-drag-*folders.entries.rs): dragging a selected row takes the selection; any other row goes alone; a row inside a chosen folder takes the selection.tests/ui.rs, Slint testing backend): press plus a 30 px move on a chosen row hands the selection to the app; on another row, that row alone. The release after a drag chooses nothing and doesn't toggle the folder. A 3 px move is still a click.Not verified (needs a real machine)
The OS drags can't run on CI: there is no display, and no Explorer or Finder. Nobody has run the Windows OLE path or the macOS AppKit path yet, beyond compiling on CI. In particular:
DoDragDropwhen started from the timer.Manual test plan
Use an archive with a top folder, several files and a subfolder, plus a password-protected ZIP. Check the archive's hash before and after every step.
Windows (Explorer)
%TEMP%\hatchzip-drag-<pid>has no newoutcontent for that drag.%TEMP%\hatchzip-drag-<pid>is gone.macOS (Finder)
.hatchzip-drag-*folder is left next to it afterwards.Linux: dragging a row does nothing; click, Ctrl+click and Shift+click still work.