mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-11-04 01:34:38 +00:00 
			
		
		
		
	Move special sentinel handling inside SDL_PeepEvents()
This commit is contained in:
		@@ -721,10 +721,15 @@ SDL_PeepEventsInternal(SDL_Event * events, int numevents, SDL_eventaction action
 | 
				
			|||||||
                            SDL_CutEvent(entry);
 | 
					                            SDL_CutEvent(entry);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if (type != SDL_POLLSENTINEL || include_sentinel) {
 | 
					                    if (type == SDL_POLLSENTINEL) {
 | 
				
			||||||
                        ++used;
 | 
					                        /* Special handling for the sentinel event */
 | 
				
			||||||
 | 
					                        if (!include_sentinel || SDL_AtomicGet(&SDL_sentinel_pending) > 0) {
 | 
				
			||||||
 | 
					                            /* Skip it, we don't want to include it or there's another one pending */
 | 
				
			||||||
 | 
					                            continue;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                    ++used;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (SDL_EventQ.lock) {
 | 
					        if (SDL_EventQ.lock) {
 | 
				
			||||||
@@ -983,7 +988,6 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* First check for existing events */
 | 
					    /* First check for existing events */
 | 
				
			||||||
retry:
 | 
					 | 
				
			||||||
    switch (SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT, include_sentinel)) {
 | 
					    switch (SDL_PeepEventsInternal(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT, include_sentinel)) {
 | 
				
			||||||
    case -1:
 | 
					    case -1:
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
@@ -996,10 +1000,6 @@ retry:
 | 
				
			|||||||
    default:
 | 
					    default:
 | 
				
			||||||
        if (event && event->type == SDL_POLLSENTINEL) {
 | 
					        if (event && event->type == SDL_POLLSENTINEL) {
 | 
				
			||||||
            /* Reached the end of a poll cycle, and not willing to wait */
 | 
					            /* Reached the end of a poll cycle, and not willing to wait */
 | 
				
			||||||
            if (SDL_AtomicGet(&SDL_sentinel_pending) > 0) {
 | 
					 | 
				
			||||||
                /* We have another sentinel pending, skip this and keep going */
 | 
					 | 
				
			||||||
                goto retry;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return 0;
 | 
					            return 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /* Has existing events */
 | 
					        /* Has existing events */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user