diff --git a/test/testrelative.c b/test/testrelative.c index 4425cb8d3..3b6ef810e 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -49,12 +49,20 @@ loop(){ } } for (i = 0; i < state->num_windows; ++i) { + SDL_Rect viewport; SDL_Renderer *renderer = state->renderers[i]; if (state->windows[i] == NULL) continue; SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderClear(renderer); + /* Wrap the cursor rectangle at the screen edges to keep it visible */ + SDL_RenderGetViewport(renderer, &viewport); + if (rect.x < viewport.x) rect.x += viewport.w; + if (rect.y < viewport.y) rect.y += viewport.h; + if (rect.x > viewport.x + viewport.w) rect.x -= viewport.w; + if (rect.y > viewport.y + viewport.h) rect.y -= viewport.h; + DrawRects(renderer, &rect); SDL_RenderPresent(renderer);