src/events/SDL_mouse.c
changeset 6302 b0ae93a5b8d6
parent 6301 e8a69c5378e7
child 6666 018f8019ce36
equal deleted inserted replaced
6301:e8a69c5378e7 6302:b0ae93a5b8d6
   321     }
   321     }
   322 
   322 
   323     /* Set the relative mode */
   323     /* Set the relative mode */
   324     mouse->relative_mode = enabled;
   324     mouse->relative_mode = enabled;
   325 
   325 
   326     if (!enabled && mouse->focus) {
   326     if (enabled) {
       
   327         /* Save the expected mouse position */
       
   328         mouse->original_x = mouse->x;
       
   329         mouse->original_y = mouse->y;
       
   330     } else if (mouse->focus) {
   327         /* Restore the expected mouse position */
   331         /* Restore the expected mouse position */
   328         SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
   332         SDL_WarpMouseInWindow(mouse->focus, mouse->original_x, mouse->original_y);
   329     }
   333     }
   330 
   334 
   331     /* Flush pending mouse motion */
   335     /* Flush pending mouse motion */
   332     SDL_FlushEvent(SDL_MOUSEMOTION);
   336     SDL_FlushEvent(SDL_MOUSEMOTION);
   333 
   337