Skip to content

win32: add support for starting drags#3

Merged
eira-fransham merged 18 commits into
drag-n-dropfrom
simon/win32-drag
Jun 4, 2026
Merged

win32: add support for starting drags#3
eira-fransham merged 18 commits into
drag-n-dropfrom
simon/win32-drag

Conversation

@tronical
Copy link
Copy Markdown
Member

@tronical tronical commented Jun 2, 2026

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

@tronical tronical force-pushed the simon/win32-drag branch 5 times, most recently from 6a79103 to 028230d Compare June 3, 2026 19:25
@tronical tronical marked this pull request as ready for review June 3, 2026 19:34
@tronical tronical force-pushed the simon/win32-drag branch from 028230d to b38bcab Compare June 3, 2026 21:01
Copy link
Copy Markdown

@eira-fransham eira-fransham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Great job here. Thanks for figuring this out. Some small nitpicks but overall this is good to merge.

Comment thread winit-win32/src/definitions.rs Outdated
Comment thread winit-win32/src/dnd.rs Outdated
Comment thread winit-win32/src/dnd.rs Outdated
Comment thread winit-win32/src/dnd.rs
Comment thread winit-win32/src/dnd.rs
Comment thread winit-win32/src/dnd.rs Outdated
Comment thread winit-win32/src/dnd.rs Outdated
Comment thread winit-win32/src/dnd.rs Outdated
Comment thread winit-win32/src/event_loop.rs Outdated
Comment thread winit-win32/src/event_loop/runner.rs Outdated
tronical added 4 commits June 4, 2026 11:33
Drop emitted DragDropped before computing the effect, so a target
rejection via set_valid_actions(none()) left the source seeing
DROPEFFECT_NONE while the target app had already seen DragDropped.
Compute the effect first and route DROPEFFECT_NONE to DragLeft.

Also trace effect_out on the source - cross-process drops have no
in-process target callback to observe it through.
Standard Arc pattern: Release on decrement publishes, but the dropping
thread needs an Acquire fence on the zero transition to see writes
another thread made through the object. AddRef drops to Relaxed - a
bump on a count you already reference doesn't synchronize anything.
Latent today since our COM objects stay in the STA.
Plumb the icon through IDragSourceHelper::InitializeFromBitmap. The
shell composites in premultiplied alpha, so convert RGBA to
premultiplied BGRA in a top-down DIB or translucent edges get a halo.
Helper failures are non-fatal.
@tronical tronical force-pushed the simon/win32-drag branch from b38bcab to dfd05ae Compare June 4, 2026 09:40
tronical added 6 commits June 4, 2026 11:50
The TYMED branch values in `duplicate_stgmedium` were each off by one
bit shift: TYMED_FILE was 1 (= HGLOBAL) instead of 2, GDI was 32
instead of 16, MFPICT 64 instead of 32, ENHMF 128 instead of 64. Latent
because the shell drag helper only uses HGLOBAL, but a HANDLE-bearing
SetData of any other tymed would have either fallen through or aliased
the wrong union arm. Use the named TYMED_* constants from windows-sys
so we can't drift again.
@tronical tronical force-pushed the simon/win32-drag branch from 26cb8a6 to e35894d Compare June 4, 2026 11:52
aurindam added a commit to slint-ui/zeiterfassung that referenced this pull request Jun 4, 2026
When a developer rebases or force-pushes, the commit author date stays
frozen at the original time, making the day of actual work invisible in
the activity view. The committer date reflects when the rebase happened
and is the correct timestamp to use for time-tracking purposes.

For example, PR slint-ui/winit#3 had commits authored on Jun 2 that were
rebased and force-pushed on Jun 3 (committer date 2026-06-03T19:25Z) —
without this fix Jun 3 showed no activity despite real work being done.

Also re-timestamps already-stored entities when a sync detects the
committer date changed, so historical data self-corrects on the next
Refresh without requiring a manual DB cleanup.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Comment thread winit-win32/src/dnd.rs Outdated
} else if tymed == TYMED_ENHMF {
out.u.hEnhMetaFile = dup as _;
} else {
unreachable!();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panicking is probably unsound here, just return None. Even if this is never called from a system callback, none of this unsafe code is particularly well-tested.

Comment thread winit-win32/src/dnd.rs Outdated
Some(out)
}

unsafe fn alloc_hglobal_from(src: *const u8, len: usize) -> Option<HGLOBAL> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're taking a pointer and length, surely it's better just to take a slice? That way you're sure that the pointer isn't null, too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, that should work

Comment thread winit-win32/src/dnd.rs Outdated
@eira-fransham eira-fransham merged commit e5ee07f into drag-n-drop Jun 4, 2026
50 checks passed
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