-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Replace SDL_WINDOWEVENT #6772
Comments
I like it! |
This has definitely tripped up some developers before, +1 |
First option gives you ability handle all SDL_WINDOWEVENT events in one condition. |
Is that a common situation? Each windowevent has a fairly different meaning which usually needs fairly different code to handle properly. |
The original motivation was to have the window events isolated to the SDL_video.h header for clean separation, but there hasn't been much value in that, and I think this change makes total sense. |
If that's really needed for something, how about: switch (myevent->type) {
default:
if (myevent->type & SDL_WINDOWEVENT) { Make |
There is a lot of confusion about events right now. Window events are grouped under If the events API is to be changed for the better, I suggest grouping all events as is currently done for window events. This gives additional possibilities (which I am currently using), because I can, with one condition or So, instead of removing the
Also pay attention to the nomenclature — it is different from the current one. Constants and function names should be set in such a way as to use common parts (as above The topic of naming conventions should also be addressed, as SDL functions also have different styles. For example, we have the functions |
There is a bug open about deciding what to do about this for SDL3, fwiw. I'm personally in favor of more consistency but I don't want a dogmatic requirement that everything get named SDL_SubsystemNounVerb. I don't know how that discussion will shake out yet. |
SDL events are already grouped by value, so you can have code which gathers all joystick events by checking whether the event enum's integer value is within a certain range. Maybe that should be a more formalized concept in SDL3? That said, personally it's never been any trouble at all to just have those few joystick events in a switch case fallthrough setup. |
Honestly I'm not a fan of this personally...but perhaps a separate field in the event can make everyone happy? // the usual:
switch (event->type) {
case SDL_EVENT_WINDOW_FOCUS_LOST: do_something(); break;
} // with categories:
switch (event->category) {
// do_something_with_window_events will check event->type.
case SDL_EVENT_CATEGORY_WINDOW: do_something_with_window_events(event); break;
} I don't know if this is a good idea, I'm just spitballing here. Maybe we just add an SDL_GetEventCategory() function that knows how to split the types up for you, idk. |
I don't like this approach, because it is unclear and it force you to do much longer The category system proposed by @icculus sounds like a decent compromise between grouping events and ranging event values. After removing the current grouping of (window) events and introducing categories, everyone should be happy, because it will be possible to freely process events — with the distinction of subsystems and without. So, I am definitely in favor of the proposed categories. |
I didn't find such a topic.
I am not talking about a dogmatic requirement, but about a convention that is clear, easy to understand and compatible with IDE tools (code completion, searching text etc.) — it's just a reasonable approach. Eskil Steenberg said something about this in the video entitled. "How I program C" — it is a really good naming that makes working with code much much easier. The only difference I use from Eskil is a different approach to getters and setters. Eskil uses Regular functions:
Getters (same pattern for setters):
See how the words in the identifiers stack up — the beginning fragments are consistent, which is easy to filter, while getters and setters are easy to distinguish from regular functions. Three variants of getters should also be taken into account, i.e. the prefixes |
Here: #6569 |
Sam copied your (very good!) comment into 6569, and feel free to carry on with that topic over there if you like, and we can continue on with event system change conversation here. |
Ok, there's a first shot at this API change in the pull request. Since the discussion was happening here, I'll mention that it doesn't have any sort of event category thing at this point, but that would be a separate thing if we decide to do it. Feedback on the patch is welcome over in #6863. Thanks! |
Ok, there's a first shot at this API change in the pull request. Since the discussion was happening here, I'll mention that it doesn't have any sort of event category thing at this point, but that would be a separate thing if we decide to do it. Feedback on the patch is welcome over in #6867. Thanks! |
So it doesn't get lost in a closed bug, I moved the event category idea to #6869, for those that would like to follow along. |
It's awkward to have:
Why not just make the window events toplevel events in SDL3?
The text was updated successfully, but these errors were encountered: