~zbigniew-chyla/widelands/use-sdl-color-cursor

Viewing all changes in revision 8809.

  • Committer: Zbigniew Chyla
  • Date: 2018-09-06 13:03:36 UTC
  • Revision ID: zbigniew.chyla@gmail.com-20180906130336-5ch3yabz1n6o0nfv
Use color SDL cursor if possible (with fallback to old approach)

Currently Widelands paints mouse cursor manually which is bad for user
experience - at 25 FPS the cursor lags behind the actual mouse position
and the user gets impression that there's "something wrong" with the
mouse.

SDL since v2 supports color cursors (SDL_CreateColorCursor) so we can
paint our custom (color) hand using SDL cursor.

Use SDL cursor in WLApplication by:
 - creating SDL_Cursor for both states (normal/clicked) on startup,
 - switching between cursors on button up/down events.
To avoid regressions on systems/setups that don't support our color
cursors keep the old code as a fallback, i.e. if SDL_CreateColorCursor
fails, disable SDL cursor and paint cursor manually.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: