Skip to content

Commit 2c9615c

Browse files
committed
Improve multi window test
1 parent ccb3c22 commit 2c9615c

File tree

1 file changed

+10
-35
lines changed

1 file changed

+10
-35
lines changed

test/testmultiwindow.c

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,6 @@ static void DestroyTestState(TestState *testState)
6161
}
6262
}
6363

64-
static bool TestStateDone(TestState *testState)
65-
{
66-
#ifdef SDL_PLATFORM_EMSCRIPTEN
67-
(void)testState;
68-
return false;
69-
#else
70-
int i;
71-
72-
for (i = 0; i < MAX_WINDOWS; ++i) {
73-
if(testState->testWindows[i]) {
74-
return false;
75-
}
76-
}
77-
78-
return true;
79-
#endif
80-
}
81-
8264
static TestWindow *createTestWindowAtMousePosition(SDLTest_CommonState *state)
8365
{
8466
static int windowId = 0;
@@ -204,27 +186,11 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
204186
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
205187
{
206188
TestState *testState = appstate;
207-
SDL_Window *targetWindow = SDL_GetWindowFromEvent(event);
208-
int i;
209189

210190
switch (event->type) {
211191
case SDL_EVENT_QUIT:
212-
return SDL_APP_SUCCESS;
213192
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
214-
case SDL_EVENT_WINDOW_DESTROYED:
215-
case SDL_EVENT_MOUSE_BUTTON_DOWN:
216-
if (targetWindow) {
217-
for (i = 0; i < MAX_WINDOWS; ++i) {
218-
if (testState->testWindows[i] && testState->testWindows[i]->window == targetWindow) {
219-
DestroyTestWindow(testState->testWindows[i]);
220-
SDL_zero(testState->testWindows[i]);
221-
if (TestStateDone(testState)) {
222-
return SDL_APP_SUCCESS;
223-
}
224-
}
225-
}
226-
}
227-
break;
193+
return SDL_APP_SUCCESS;
228194
default:
229195
break;
230196
}
@@ -245,12 +211,21 @@ SDL_AppResult SDL_AppIterate(void *appstate)
245211
}
246212

247213
if (now - testState->lastCreate > 1000) {
214+
bool added = false;
248215
for (i = 0; i < MAX_WINDOWS; ++i) {
249216
if (!testState->testWindows[i]) {
250217
testState->testWindows[i] = createTestWindowAtMousePosition(testState->state);
218+
added = true;
251219
break;
252220
}
253221
}
222+
/* Remove all windows if full */
223+
if (!added) {
224+
for (i = 0; i < MAX_WINDOWS; ++i) {
225+
DestroyTestWindow(testState->testWindows[i]);
226+
SDL_zero(testState->testWindows[i]);
227+
}
228+
}
254229
testState->lastCreate = now;
255230
}
256231
return SDL_APP_CONTINUE;

0 commit comments

Comments
 (0)