-
Notifications
You must be signed in to change notification settings - Fork 888
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
Rework DnD #2615
base: master
Are you sure you want to change the base?
Rework DnD #2615
Conversation
Could you elaborate why this is needed? Don't you get pointer motion events during DnD? It's just strange that we have 2 sources of pointer events during dnd with that. |
This is also a breaking change. |
You get the cursor event only right before the |
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.
Just to ensure, have you tested the X11 part of it? (I just can't do that myself, but I guess that you can easily do that with any file manager)
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
I haven't tested X11 nor macOS but I can test X11 later today. |
Alright, X11 should be fine now. The returned coordinates were root window coordinates so I had to translate them before dispatching the event. |
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 think it's a bit more clear which events.
Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
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 agree that it makes sense to have for DroppedFile
, but not so sure about HoveredFile
? It seems like, for that to be useful, you'd have to receive the event continuously (which you at least don't on macOS)
That would strange, I'd assume you can know that you're over some element while doing drag and drop? Maybe the event is sent via some side channel, so we should plumb it to hovered? |
It is the same behavior on Windows and Linux too, the event is emitted only once upon entering the window. |
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.
macOS impl tested and approved from my side.
It is the same behavior on Windows and Linux too, the event is emitted only once upon entering the window.
HoveredFile.position
still doesn't really make sense to me, perhaps we should instead just emit two events CursorMoved { position } + HoveredFile { path }
(or the other way around, if that's better)?
Adding the cursor position to these events removes the need to sync with other events.
(Though I do believe you when you say it's useful, I don't use the API myself, so it's not a blocker for me).
However, I think we might want to send CursorMotion events instead of @madsmtm do you get any cursor events when moving drag and drop over the window, don't you get CurserMoved?
I think what we should do is to plumb the current mouse position inside the Though, it could be hard to plumb the mouse/touch position inside the dnd, though you can broadcast on such platforms that you're doing DND and emit extra bits... |
using |
Ah, so it pairs with some API to set DND zones? On Wayland most of the time you should be fine with The thing is that winit should send either CursorMoved or Hovered event, it shouldn't send both at the same time. |
why not both? if the OS sends them both, I think winit should pass that through as well |
Nope, you get neither But it seems you can opt-in to getting updates about the current drag operation, so one could probably implement a Should we consider postponing this PR to 0.29? It seems like there's still quite some work to do figuring out the desired design (and implementing it, and testing it). |
I guess using I'm not sure I like |
We may do so if it'll be the only PR left. |
DroppedFile
and HoveredFile
events
I went with |
Use of
I much prefer the API in this PR (just send the coordinates). The current API (i.e. this PR) seems fine except maybe one thing: it clones a Also the API should be clear on whether Edit: clarify that "current API = this PR" |
Using I initially had |
Rust doesn't support multi-trait objects (yet) but you can do this: pub trait HasPath: Debug + PartialEq + Eq + AsRef<Path> {} But this is somewhat irrelevant in my opinion. Do we want to lock winit into an API which copies a bunch of paths on every mouse movement? Or is it irrelevant since all platforms re-send those on each movement anyway? |
Only Windows doesn't send it on each movement, x11 and macOS do. |
I think I'd prefer to just leave paths out of And maybe even remove it from |
I doubt that it can change but I'd say keep it for ease-of-use |
@kchibisov It is been a while, and now that I have some time to work on this and fix conflicts, do you think this rework should land soon? |
Is this PR still compatible with the recent winit API changes or does it need updating? |
CHANGELOG.md
if knowledge of this change could be valuable to users