-
Notifications
You must be signed in to change notification settings - Fork 911
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 <[email protected]>
Co-authored-by: Kirill Chibisov <[email protected]>
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 <[email protected]>
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).
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? |
It's very frustrating to see PRs languish and become outdated due to API reworks. This solves an issue (#1550) that has been linked to by several users of other UI frameworks and GUI apps who keep running into it again and again. I would offer to help push this over the finish line, but I have no idea if it would even be looked at or bikeshed to death again and become unmergeable due to conflicts. Imagine my frustration when I had to go to a third-party repo (iced)'s issues list to see that this PR even existed (it's not mentioned anywhere in #1550) and has been sitting here unmerged for almost two years while its creator has diligently responded to every request made by the maintainers. |
You can open a PR with the new proposed events, with impl only for one backend and see how it works with the recent pointer API rework. I myself don't have issues with the suggested design, since it's mostly about dropping into your window, starting drag is not really possible from winit and it'll require the same work as e.g. clipboard APIs. Though, it's not that much. |
I will see If I can update this PR once again when I have some time. For starting a drag operation, there is |
CHANGELOG.md
if knowledge of this change could be valuable to users