Just a quick suggestion. As we now provide an SDL_WindowID in the
SDL_Event.X structure. Do you think it would be a good idea if rather than
placing it in each possible event type, as it exists in most events, we
placed it in the SDL_Event root?
I say this as I’m finding myself wanting to quickly filter which GUI objects
or in game event functions I run through based on the relevant window, which
currently is implemented as a big switch statement.
Can you explain this a little more? The way I read what you said,
which is by no means anything like what you meant, is that you want to
do a switch statement based on window id. Which doesn’t seem like a
very good idea to me. It seems to assume that you will always have the
same window ids generated in the same order on every platform. I know
that is supposed to be the case, but it just might not be and then
your code doesn’t work. Personally, I’d use a hash table (STL
hash_map) to associate window ids with handlers, then I never have to
worry about the actual value of a window id.
OTOH, I like the idea of adding the window id to the event root so
that it is easy to direct events to the correct handler for that
event. The drawbacks are that it would, in effect, add a window id to
events that do not have a valid window id so we would have to have a
way to mark those as invalid, such as window id -1. Doing that adds a
bunch of potential gotchas and misunderstandings. How many people
would get very surprised to get a window id of -1 with every joystick
input event? Joysticks aren’t associated with any window so you either
have to have special code to handle them or SDL would need to send
duplicate joystick events to each existing window, each event
differing only by the window id. Which seems a bit odd to me. I mean,
it actually seems reasonable until I think about having 10 or more
windows on the screen forcing SDL to send 10 copies of the same event
to my program. And then I think about the SDL queue being only 128
items long and I start to see the queue filled to over full every time
I wiggle the joystick. And, that seems unreasonable to me.
Oh well, it seems a lot easier to just do a switch on event type with
one entry for every event that has a window id and one entry for each
event type that does not have a window id and work from there.
If I have completely misunderstood what you said, please explain what
you meant in more detail.
Bob PendletonOn Sat, Nov 14, 2009 at 4:36 PM, Scribe <ali_lowe at sky.com> wrote:
What do you think?
SDL mailing list
SDL at lists.libsdl.org