Skip to content

Commit

Permalink
Fixed bug 2866 - testrelative.c: patch to make the orange box wrap ar…
Browse files Browse the repository at this point in the history
…ound

Eric Wasylishen

Here's a patch to make the 'testrelative' demo program more useful: it just makes the orange rectangle wrap around. Previously, the orange cursor would just disappear off screen if you move the mouse a lot in one direction, so it was hard to tell if relative mouse mode was still working.
  • Loading branch information
philippwiesemann committed Feb 7, 2015
1 parent 60329e6 commit c17a5b1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/testrelative.c
Expand Up @@ -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);
Expand Down

0 comments on commit c17a5b1

Please sign in to comment.