Change DoDragDropAsync trigger event to PointerPressedEventArgs - #20988
Conversation
|
You can test this PR using the following package version. |
Why not? What about cases like this: protected override async void OnPointerMoved(PointerEventArgs e)
{
if (_initialPoint.HasValue)
{
var currentPoint = e.GetCurrentPoint(this);
var delta = _initialPoint.Value - currentPoint.Position;
if (Math.Abs(delta.X) > _cxDrag || Math.Abs(delta.Y) > _cyDrag)
{
// Start Drag
var result = await DragDrop.DoDragDropAsync(...);
}
}
}where you want to ensure the cursor is moved a minimum distance before initiating drag, which is done in PointerMoved? Why make the user store the PointerPressed args to do something like this? |
|
@amwx the answer is Wayland. <arg name="serial" type="uint" summary="serial number of the implicit grab on the origin"/>Where implicit grab is initiated on pointer press. It might work with pre-stored PointerPressed though, not sure exactly. @kekekeks in case if we can resolve something like "current implicit grab serial from the specified pointer id". |
|
It should work with stored event, the protocol is async, after all. But we need to use the initial pointer press to start the dnd operation. |
|
I see... I just don't like the limiting of the public API based on one platform. IMO single platform limitations should be handled internally, but I'm also not the one to manage/maintain all this and have limited Wayland knowledge so what do I know... Though instead of just saying "not valid", that rationale should've been included in the initial description since pretty much every other platform doesn't have this issue. I live in Windows world, so the only thing I know about Wayland is that every time I learn something new about it I hate it more :) and I'm sure there's other Avalonia users that have limited knowledge on Wayland too |
Yes, you're completely right about that. The discussion mostly took place internally, and I should have conveyed the rationale more clearly. Note that it's not only Wayland. In the new XDND implementation, we're taking an explicit pointer grab when drag starts. This causes the pointer to be completely locked up, system-wide, if, for example, a breakpoint is triggered, or user code causes the application to freeze for any reason. Instead, we want to rely on the implicit grab that X11 takes when the pointer is pressed. We can only do that if the drag is started from a pointer-pressed event. |
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
# Conflicts: # api/Avalonia.nupkg.xml
|
You can test this PR using the following package version. |
What does the pull request do?
This PR changes the type of the
triggerEventparameter ofDragDrop.DoDragDropAsyncfromPointerEventArgstoPointerPressedEventArgs.It is not valid to start a drag from other types of events.