News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

Fix window focus/unfocus events on SDL2

Started by ArthurDenture, October 27, 2013, 08:24:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ArthurDenture

I built the SDL2 backend at head and noticed that every time I moved the mouse out of the Simutrans window, the current open dialog closed.

It turned out that r6702 ("ADD: loading gui themes on runtime") added a new "#define SYSTEM_RELOAD_WINDOWS 3" to simevent.h for a custom reload-theme event, which conflicted with the existing "#define SIM_SYSTEM_UPDATE 3" in simsys.h. SDL1 didn't notice anything b/c that event turns out to seemingly never get fired, but SDL2 was firing that event when the game window was focused or unfocused.

There was a comment on simevent.h warning about the duplicate event definitions, but even better than having to notice the comment is simply to make the code safe by eliminating the duplication. So I got rid of the defines in simsys.h and replaced their usages with the ones from simevent.h. As for the conflicting SIM_SYSTEM_UPDATE event, it was never used for anything, I went ahead and just ripped it out, getting rid of all of the SDL event handling that could have generated it.

Patch is attached.

kierongreen


Max-Max

Hmm, shouldn't those defines be an enum? Then it would be more natural to seek out the enum list when adding new messages.
- My code doesn't have bugs. It develops random features...

Ters

Quote from: Max-Max on October 27, 2013, 11:19:32 PM
Hmm, shouldn't those defines be an enum? Then it would be more natural to seek out the enum list when adding new messages.

I thought the same. One thing that may rule out an enum is if some backends need som internal event types.