-
Notifications
You must be signed in to change notification settings - Fork 9
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
SDL_DragEvent: Add SDL_DragEvents #13
base: master
Are you sure you want to change the base?
Conversation
These closely mirror the Drop events, specifically with BEGIN and COMPLETE. When dragging n files, 1 BEGIN, n FILE and 1 COMPLETE events are sent per mouse movement.
Awesome! Just to solidify my understanding of the API:
Does this mean, for every mouse-move, we would get a BEGIN - FILE - COMPLETE set of events? I wonder if we could simplify and just use a single event (either |
Trying to fix up the CI here: #14 - the |
This is correct. I did this for two reasons:
There are probably other reasons as well, but that was the main one I thought of. Let me know if you can think of a way around this -- I agree that it's pretty convoluted! |
Cool, those seem like reasonable considerations to me - thanks Zach! You might want to merge |
Interestingly enough it looks like Wayland responds to all those X events I set up! So Linux is done in theory 😄 |
That's awesome, @zbaylin ! |
posted = (SDL_PushEvent(&event) > 0); | ||
if (!posted) { | ||
return 0; | ||
} |
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 assignment seems unnecessary, and a bit confusing. I'd expect posted
to be read from again later, but it isn't. So it would be simpler to just check the result directly I think:
posted = (SDL_PushEvent(&event) > 0); | |
if (!posted) { | |
return 0; | |
} | |
if (SDL_PushEvent(&event) == 0) { | |
return 0; | |
} |
event.drag.windowID = window ? window->id : 0; | ||
event.drag.x = x; | ||
event.drag.y = y; | ||
posted = (SDL_PushEvent(&event) > 0); |
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.
posted
is an ambiguous name. It's not immediately obvious whether it refers to a boolean or a count of items posted, for example. Therefore I prefer using isPosted
for booleans.
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.
Sounds good. All the variable names I used I either borrowed from other functions (see SDL_dropevents.c
) or modeled them closely after others. In this case it doesn't matter because I can remove the posted
reference altogether though!
SDL_bool dragging; | ||
SDL_bool dropping; |
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.
Same here:
SDL_bool dragging; | |
SDL_bool dropping; | |
SDL_bool isDragging; | |
SDL_bool isDropping; |
These closely mirror the Drop events, specifically with BEGIN and COMPLETE. When dragging n files, 1 BEGIN, n FILE and 1 COMPLETE events are sent per mouse movement.
Note that currently only the macOS implementation works, but the scaffolding is there for easy Windows/Linux additions!