MIR: Support relative mouse mode
authorBrandon Schaefer <brandon.schaefer@canonical.com>
Tue, 07 Jun 2016 09:01:23 -0700
changeset 101807356b2938fba
parent 10179 7cbfd97f1430
child 10181 b82c0f22d22a
MIR: Support relative mouse mode
src/video/mir/SDL_mirevents.c
src/video/mir/SDL_mirmouse.c
     1.1 --- a/src/video/mir/SDL_mirevents.c	Mon May 23 15:29:25 2016 -0300
     1.2 +++ b/src/video/mir/SDL_mirevents.c	Tue Jun 07 09:01:23 2016 -0700
     1.3 @@ -136,7 +136,8 @@
     1.4  static void
     1.5  HandleMouseMotion(SDL_Window* sdl_window, int x, int y)
     1.6  {
     1.7 -    SDL_SendMouseMotion(sdl_window, 0, 0, x, y);
     1.8 +    SDL_Mouse* mouse = SDL_GetMouse();
     1.9 +    SDL_SendMouseMotion(sdl_window, 0, mouse->relative_mode, x, y);
    1.10  }
    1.11  
    1.12  static void
    1.13 @@ -218,11 +219,20 @@
    1.14              SDL_Mouse* mouse = SDL_GetMouse();
    1.15              x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_x);
    1.16              y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_y);
    1.17 +
    1.18 +            if (mouse && (mouse->x != x || mouse->y != y)) {
    1.19 +                if (mouse->relative_mode) {
    1.20 +                    int relative_x = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_relative_x);
    1.21 +                    int relative_y = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_relative_y);
    1.22 +                    HandleMouseMotion(sdl_window, relative_x, relative_y);
    1.23 +                }
    1.24 +                else {
    1.25 +                    HandleMouseMotion(sdl_window, x, y);
    1.26 +                }
    1.27 +            }
    1.28 +
    1.29              hscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_hscroll);
    1.30              vscroll = MIR_mir_pointer_event_axis_value(pointer, mir_pointer_axis_vscroll);
    1.31 -
    1.32 -            if (mouse && (mouse->x != x || mouse->y != y))
    1.33 -                HandleMouseMotion(sdl_window, x, y);
    1.34              if (vscroll != 0 || hscroll != 0)
    1.35                  HandleMouseScroll(sdl_window, hscroll, vscroll);
    1.36          }
     2.1 --- a/src/video/mir/SDL_mirmouse.c	Mon May 23 15:29:25 2016 -0300
     2.2 +++ b/src/video/mir/SDL_mirmouse.c	Tue Jun 07 09:01:23 2016 -0700
     2.3 @@ -252,7 +252,7 @@
     2.4  static int
     2.5  MIR_SetRelativeMouseMode(SDL_bool enabled)
     2.6  {
     2.7 -    return SDL_Unsupported();
     2.8 +    return 0;
     2.9  }
    2.10  
    2.11  /* TODO Actually implement the cursor, need to wait for mir support */