src/video/wayland/SDL_waylandevents.c
changeset 9555 fff4b6354b99
parent 9554 879f71e1478b
child 9556 db92b9d74129
equal deleted inserted replaced
9554:879f71e1478b 9555:fff4b6354b99
   135 static SDL_bool
   135 static SDL_bool
   136 ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
   136 ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
   137 {
   137 {
   138     SDL_WindowData *window_data = input->pointer_focus;
   138     SDL_WindowData *window_data = input->pointer_focus;
   139     SDL_Window *window = window_data->sdlwindow;
   139     SDL_Window *window = window_data->sdlwindow;
   140     SDL_bool ret = SDL_FALSE;
       
   141 
   140 
   142     if (window->hit_test) {
   141     if (window->hit_test) {
   143         const SDL_Point point = { wl_fixed_to_int(input->sx_w), wl_fixed_to_int(input->sy_w) };
   142         const SDL_Point point = { wl_fixed_to_int(input->sx_w), wl_fixed_to_int(input->sy_w) };
   144         const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
   143         const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
       
   144         static const uint32_t directions[] = {
       
   145             WL_SHELL_SURFACE_RESIZE_TOP_LEFT, WL_SHELL_SURFACE_RESIZE_TOP,
       
   146             WL_SHELL_SURFACE_RESIZE_TOP_RIGHT, WL_SHELL_SURFACE_RESIZE_RIGHT,
       
   147             WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, WL_SHELL_SURFACE_RESIZE_BOTTOM,
       
   148             WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT, WL_SHELL_SURFACE_RESIZE_LEFT
       
   149         };
   145         switch (rc) {
   150         switch (rc) {
   146             case SDL_HITTEST_DRAGGABLE: {
   151             case SDL_HITTEST_DRAGGABLE:
   147                     wl_shell_surface_move(window_data->shell_surface, input->seat, serial);
   152                 wl_shell_surface_move(window_data->shell_surface, input->seat, serial);
   148                     ret = SDL_TRUE;
   153                 return SDL_TRUE;
   149                 }
   154 
   150                 break;
   155             case SDL_HITTEST_RESIZE_TOPLEFT:
   151             case SDL_HITTEST_RESIZE_TOPLEFT: {
   156             case SDL_HITTEST_RESIZE_TOP:
   152                     wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_TOP_LEFT);
   157             case SDL_HITTEST_RESIZE_TOPRIGHT:
   153                     ret = SDL_TRUE;
   158             case SDL_HITTEST_RESIZE_RIGHT:
   154                 }
   159             case SDL_HITTEST_RESIZE_BOTTOMRIGHT:
   155                 break;
   160             case SDL_HITTEST_RESIZE_BOTTOM:
   156             case SDL_HITTEST_RESIZE_TOP: {
   161             case SDL_HITTEST_RESIZE_BOTTOMLEFT:
   157                     wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_TOP);
   162             case SDL_HITTEST_RESIZE_LEFT:
   158                     ret = SDL_TRUE;
   163                 wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
   159                 }
   164                 return SDL_TRUE;
   160                 break;
   165 
   161             case SDL_HITTEST_RESIZE_TOPRIGHT: {
   166             default: return SDL_FALSE;
   162                     wl_shell_surface_resize(window_data->shell_surface, input->seat, serial,  WL_SHELL_SURFACE_RESIZE_TOP_RIGHT);
       
   163                     ret = SDL_TRUE;
       
   164                 }
       
   165                 break;
       
   166             case SDL_HITTEST_RESIZE_RIGHT: {
       
   167                     wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_RIGHT);
       
   168                     ret = SDL_TRUE;
       
   169                 }
       
   170                 break;
       
   171             case SDL_HITTEST_RESIZE_BOTTOMRIGHT: {
       
   172                     wl_shell_surface_resize(window_data->shell_surface, input->seat, serial,  WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT);
       
   173                     ret = SDL_TRUE;
       
   174                 }
       
   175                 break;
       
   176             case SDL_HITTEST_RESIZE_BOTTOM: {
       
   177                     wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_BOTTOM);
       
   178                     ret = SDL_TRUE;
       
   179                 }
       
   180                 break;
       
   181             case SDL_HITTEST_RESIZE_BOTTOMLEFT: {
       
   182                     wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT);
       
   183                     ret = SDL_TRUE;
       
   184                 }
       
   185                 break;
       
   186             case SDL_HITTEST_RESIZE_LEFT: {
       
   187                     wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, WL_SHELL_SURFACE_RESIZE_LEFT);
       
   188                     ret = SDL_TRUE;
       
   189                 }
       
   190                 break;
       
   191             default:
       
   192                 break;
       
   193         }
   167         }
   194     }
   168     }
   195 
   169 
   196     return ret;
   170     return SDL_FALSE;
   197 }
   171 }
   198 
   172 
   199 static void
   173 static void
   200 pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
   174 pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
   201                       uint32_t time, uint32_t button, uint32_t state_w)
   175                       uint32_t time, uint32_t button, uint32_t state_w)