cleanup SDL_EventState
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index a6c2dd6..5611f39 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -1236,8 +1236,7 @@ SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
Uint8
SDL_EventState(Uint32 type, int state)
{
- const SDL_bool isdnd = ((state == SDL_DISABLE) || (state == SDL_ENABLE)) &&
- ((type == SDL_DROPFILE) || (type == SDL_DROPTEXT));
+ const SDL_bool isde = (state == SDL_DISABLE) || (state == SDL_ENABLE);
Uint8 current_state;
Uint8 hi = ((type >> 8) & 0xff);
Uint8 lo = (type & 0xff);
@@ -1249,44 +1248,32 @@ SDL_EventState(Uint32 type, int state)
current_state = SDL_ENABLE;
}
- if (state != current_state)
- {
- switch (state) {
- case SDL_DISABLE:
+ if (isde && state != current_state) {
+ if (state == SDL_DISABLE) {
/* Disable this event type and discard pending events */
if (!SDL_disabled_events[hi]) {
SDL_disabled_events[hi] = (SDL_DisabledEventBlock*) SDL_calloc(1, sizeof(SDL_DisabledEventBlock));
- if (!SDL_disabled_events[hi]) {
- /* Out of memory, nothing we can do... */
- break;
- }
}
- SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31));
- SDL_FlushEvent(type);
- break;
- case SDL_ENABLE:
+ /* Out of memory, nothing we can do... */
+ if (SDL_disabled_events[hi]) {
+ SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31));
+ SDL_FlushEvent(type);
+ }
+ } else { // state == SDL_ENABLE
SDL_disabled_events[hi]->bits[lo/32] &= ~(1 << (lo&31));
- break;
- default:
- /* Querying state... */
- break;
}
#if !SDL_JOYSTICK_DISABLED
- if (state == SDL_DISABLE || state == SDL_ENABLE) {
- SDL_CalculateShouldUpdateJoysticks();
- }
+ SDL_CalculateShouldUpdateJoysticks();
#endif
#if !SDL_SENSOR_DISABLED
- if (state == SDL_DISABLE || state == SDL_ENABLE) {
- SDL_CalculateShouldUpdateSensors();
- }
+ SDL_CalculateShouldUpdateSensors();
#endif
}
/* turn off drag'n'drop support if we've disabled the events.
This might change some UI details at the OS level. */
- if (isdnd) {
+ if (isde && ((type == SDL_DROPFILE) || (type == SDL_DROPTEXT))) {
SDL_ToggleDragAndDropSupport();
}