-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Verify that the drop source target window is in-process #10319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verify that the drop source target window is in-process #10319
Conversation
* Fix the tracking of the last drop target window in DragLeaveTarget. * Exclude the Effect property from the check for if the drag image has been updated. * Prevent the drag image from being updated during GiveFeedback when the image is updated from another process. * Only notify the drag-image manager that the cursor has left the drop target if the window is in-process.
|
@weltkante - Thoughts? |
JeremyKuhne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few minor comments.
| internal const string CF_DRAGSOURCEHELPERFLAGS = "DragSourceHelperFlags"; | ||
| internal const string CF_DRAGWINDOW = "DragWindow"; | ||
| internal const string CF_DROPDESCRIPTION = "DropDescription"; | ||
| internal const string CF_INSHELLDRAGLOOP = "InShellDragLoop"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one can come from CsWin32 with CFSTR_INDRAGLOOP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is cool. First time I've seen that.
| internal const string CF_DRAGIMAGEBITS = "DragImageBits"; | ||
| internal const string CF_DRAGSOURCEHELPERFLAGS = "DragSourceHelperFlags"; | ||
| internal const string CF_DRAGWINDOW = "DragWindow"; | ||
| internal const string CF_DROPDESCRIPTION = "DropDescription"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be replaced with CFSTR_DROPDESCRIPTION using CsWin32.
| /// </summary> | ||
| internal static class DragDropHelper | ||
| { | ||
| private const int DSH_ALLOWDROPDESCRIPTIONTEXT = 0x0001; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can come from DSH_FLAGS in CsWin32.
| internal static class DragDropHelper | ||
| { | ||
| private const int DSH_ALLOWDROPDESCRIPTIONTEXT = 0x0001; | ||
| internal const string CF_COMPUTEDIMAGE = "ComputedImage"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to document where these formats come from in the comments here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe a couple of these formats are unnecessary, but I'll document what I know about the ones that are needed.
| } | ||
|
|
||
| private bool IsDropTargetWindowInCurrentThread() => !_lastHwndTarget.IsNull | ||
| && PInvoke.GetWindowThreadProcessId(_lastHwndTarget, out _) == PInvoke.GetCurrentThreadId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should stash the window's thread to avoid the repeated call? It would also be slightly faster if you also use the unsafe overload and pass null for the process id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Thank you for your help.
from just looking at the changes it looks good to me, can't see any problems with it. won't have time to tests it myself at the moment. |
lonitra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mainly some small stylistic comments, otherwise LGTM!
src/System.Windows.Forms/src/System/Windows/Forms/DropSource.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/DragDropHelper.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/DragDropHelper.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/DragDropHelper.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/DragDropHelper.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/GiveFeedbackEventArgs.cs
Show resolved
Hide resolved
lonitra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Fixes #8903
Proposed changes
DragLeaveTarget.DragLeaveTargetthat the cursor has left the target window only if it is in-process.GiveFeeback.Customer Impact
Regression?
Risk
Screenshots
Before
Drag-image-cross-process-before.mp4
After
Drag-image-cross-process-after.mp4
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow