src/video/wayland/SDL_waylandevents.c
changeset 9555 fff4b6354b99
parent 9554 879f71e1478b
child 9556 db92b9d74129
     1.1 --- a/src/video/wayland/SDL_waylandevents.c	Sun Apr 12 20:40:06 2015 -0400
     1.2 +++ b/src/video/wayland/SDL_waylandevents.c	Sun Apr 12 20:59:48 2015 -0400
     1.3 @@ -137,63 +137,37 @@
     1.4  {
     1.5      SDL_WindowData *window_data = input->pointer_focus;
     1.6      SDL_Window *window = window_data->sdlwindow;
     1.7 -    SDL_bool ret = SDL_FALSE;
     1.8  
     1.9      if (window->hit_test) {
    1.10          const SDL_Point point = { wl_fixed_to_int(input->sx_w), wl_fixed_to_int(input->sy_w) };
    1.11          const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
    1.12 +        static const uint32_t directions[] = {
    1.13 +            WL_SHELL_SURFACE_RESIZE_TOP_LEFT, WL_SHELL_SURFACE_RESIZE_TOP,
    1.14 +            WL_SHELL_SURFACE_RESIZE_TOP_RIGHT, WL_SHELL_SURFACE_RESIZE_RIGHT,
    1.15 +            WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, WL_SHELL_SURFACE_RESIZE_BOTTOM,
    1.16 +            WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT, WL_SHELL_SURFACE_RESIZE_LEFT
    1.17 +        };
    1.18          switch (rc) {
    1.19 -            case SDL_HITTEST_DRAGGABLE: {
    1.20 -                    wl_shell_surface_move(window_data->shell_surface, input->seat, serial);
    1.21 -                    ret = SDL_TRUE;
    1.22 -                }
    1.23 -                break;
    1.24 -            case SDL_HITTEST_RESIZE_TOPLEFT: {
    1.25 -                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_TOP_LEFT);
    1.26 -                    ret = SDL_TRUE;
    1.27 -                }
    1.28 -                break;
    1.29 -            case SDL_HITTEST_RESIZE_TOP: {
    1.30 -                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_TOP);
    1.31 -                    ret = SDL_TRUE;
    1.32 -                }
    1.33 -                break;
    1.34 -            case SDL_HITTEST_RESIZE_TOPRIGHT: {
    1.35 -                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial,  WL_SHELL_SURFACE_RESIZE_TOP_RIGHT);
    1.36 -                    ret = SDL_TRUE;
    1.37 -                }
    1.38 -                break;
    1.39 -            case SDL_HITTEST_RESIZE_RIGHT: {
    1.40 -                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_RIGHT);
    1.41 -                    ret = SDL_TRUE;
    1.42 -                }
    1.43 -                break;
    1.44 -            case SDL_HITTEST_RESIZE_BOTTOMRIGHT: {
    1.45 -                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial,  WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT);
    1.46 -                    ret = SDL_TRUE;
    1.47 -                }
    1.48 -                break;
    1.49 -            case SDL_HITTEST_RESIZE_BOTTOM: {
    1.50 -                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_BOTTOM);
    1.51 -                    ret = SDL_TRUE;
    1.52 -                }
    1.53 -                break;
    1.54 -            case SDL_HITTEST_RESIZE_BOTTOMLEFT: {
    1.55 -                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT);
    1.56 -                    ret = SDL_TRUE;
    1.57 -                }
    1.58 -                break;
    1.59 -            case SDL_HITTEST_RESIZE_LEFT: {
    1.60 -                    wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_LEFT);
    1.61 -                    ret = SDL_TRUE;
    1.62 -                }
    1.63 -                break;
    1.64 -            default:
    1.65 -                break;
    1.66 +            case SDL_HITTEST_DRAGGABLE:
    1.67 +                wl_shell_surface_move(window_data->shell_surface, input->seat, serial);
    1.68 +                return SDL_TRUE;
    1.69 +
    1.70 +            case SDL_HITTEST_RESIZE_TOPLEFT:
    1.71 +            case SDL_HITTEST_RESIZE_TOP:
    1.72 +            case SDL_HITTEST_RESIZE_TOPRIGHT:
    1.73 +            case SDL_HITTEST_RESIZE_RIGHT:
    1.74 +            case SDL_HITTEST_RESIZE_BOTTOMRIGHT:
    1.75 +            case SDL_HITTEST_RESIZE_BOTTOM:
    1.76 +            case SDL_HITTEST_RESIZE_BOTTOMLEFT:
    1.77 +            case SDL_HITTEST_RESIZE_LEFT:
    1.78 +                wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
    1.79 +                return SDL_TRUE;
    1.80 +
    1.81 +            default: return SDL_FALSE;
    1.82          }
    1.83      }
    1.84  
    1.85 -    return ret;
    1.86 +    return SDL_FALSE;
    1.87  }
    1.88  
    1.89  static void