src/video/wayland/SDL_waylandmouse.c
changeset 8104 2e4f1bd21196
parent 8062 4fc5f66d63cc
child 8116 f7c2f71251e5
equal deleted inserted replaced
8103:d4a88c49247e 8104:2e4f1bd21196
    29 #include <fcntl.h>
    29 #include <fcntl.h>
    30 #include <unistd.h>
    30 #include <unistd.h>
    31 #include <stdlib.h>
    31 #include <stdlib.h>
    32 #include <limits.h>
    32 #include <limits.h>
    33 
    33 
       
    34 #include "../../SDL_internal.h"
    34 #include "../SDL_sysvideo.h"
    35 #include "../SDL_sysvideo.h"
    35 
    36 
    36 #include "SDL_config.h"
       
    37 #include "SDL_mouse.h"
    37 #include "SDL_mouse.h"
    38 #include "../../events/SDL_mouse_c.h"
    38 #include "../../events/SDL_mouse_c.h"
    39 #include "SDL_waylandvideo.h"
    39 #include "SDL_waylandvideo.h"
    40 #include "SDL_waylandevents_c.h"
    40 #include "SDL_waylandevents_c.h"
       
    41 
       
    42 #include "SDL_waylanddyn.h"
       
    43 #include "wayland-cursor.h"
    41 
    44 
    42 #include "SDL_assert.h"
    45 #include "SDL_assert.h"
    43 
    46 
    44 #if SDL_VIDEO_DRIVER_WAYLAND
    47 #if SDL_VIDEO_DRIVER_WAYLAND
    45 
    48 
   208          * if we are fetching this from a wl_cursor_theme, so don't store a
   211          * if we are fetching this from a wl_cursor_theme, so don't store a
   209          * reference to it here */
   212          * reference to it here */
   210         data->buffer = NULL;
   213         data->buffer = NULL;
   211         data->surface = wl_compositor_create_surface(d->compositor);
   214         data->surface = wl_compositor_create_surface(d->compositor);
   212         wl_surface_attach(data->surface,
   215         wl_surface_attach(data->surface,
   213                           wl_cursor_image_get_buffer(wlcursor->images[0]),
   216                           WAYLAND_wl_cursor_image_get_buffer(wlcursor->images[0]),
   214                           0,
   217                           0,
   215                           0);
   218                           0);
   216         wl_surface_damage(data->surface,
   219         wl_surface_damage(data->surface,
   217                           0,
   220                           0,
   218                           0,
   221                           0,
   234 {
   237 {
   235     SDL_VideoDevice *device = SDL_GetVideoDevice();
   238     SDL_VideoDevice *device = SDL_GetVideoDevice();
   236     SDL_VideoData *data = device->driverdata;
   239     SDL_VideoData *data = device->driverdata;
   237 
   240 
   238     return CreateCursorFromWlCursor (data,
   241     return CreateCursorFromWlCursor (data,
   239                                      wl_cursor_theme_get_cursor(data->cursor_theme,
   242                                      WAYLAND_wl_cursor_theme_get_cursor(data->cursor_theme,
   240                                                                 "left_ptr"));
   243                                                                 "left_ptr"));
   241 }
   244 }
   242 
   245 
   243 static SDL_Cursor *
   246 static SDL_Cursor *
   244 Wayland_CreateSystemCursor(SDL_SystemCursor id)
   247 Wayland_CreateSystemCursor(SDL_SystemCursor id)
   252     {
   255     {
   253     default:
   256     default:
   254         SDL_assert(0);
   257         SDL_assert(0);
   255         return NULL;
   258         return NULL;
   256     case SDL_SYSTEM_CURSOR_ARROW:
   259     case SDL_SYSTEM_CURSOR_ARROW:
   257         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
   260         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "left_ptr");
   258         break;
   261         break;
   259     case SDL_SYSTEM_CURSOR_IBEAM:
   262     case SDL_SYSTEM_CURSOR_IBEAM:
   260         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "xterm");
   263         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "xterm");
   261         break;
   264         break;
   262     case SDL_SYSTEM_CURSOR_WAIT:
   265     case SDL_SYSTEM_CURSOR_WAIT:
   263         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "wait");
   266         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "wait");
   264         break;
   267         break;
   265     case SDL_SYSTEM_CURSOR_CROSSHAIR:
   268     case SDL_SYSTEM_CURSOR_CROSSHAIR:
   266         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   269         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   267         break;
   270         break;
   268     case SDL_SYSTEM_CURSOR_WAITARROW:
   271     case SDL_SYSTEM_CURSOR_WAITARROW:
   269         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "wait");
   272         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "wait");
   270         break;
   273         break;
   271     case SDL_SYSTEM_CURSOR_SIZENWSE:
   274     case SDL_SYSTEM_CURSOR_SIZENWSE:
   272         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   275         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   273         break;
   276         break;
   274     case SDL_SYSTEM_CURSOR_SIZENESW:
   277     case SDL_SYSTEM_CURSOR_SIZENESW:
   275         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   278         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   276         break;
   279         break;
   277     case SDL_SYSTEM_CURSOR_SIZEWE:
   280     case SDL_SYSTEM_CURSOR_SIZEWE:
   278         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   281         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   279         break;
   282         break;
   280     case SDL_SYSTEM_CURSOR_SIZENS:
   283     case SDL_SYSTEM_CURSOR_SIZENS:
   281         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   284         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   282         break;
   285         break;
   283     case SDL_SYSTEM_CURSOR_SIZEALL:
   286     case SDL_SYSTEM_CURSOR_SIZEALL:
   284         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   287         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   285         break;
   288         break;
   286     case SDL_SYSTEM_CURSOR_NO:
   289     case SDL_SYSTEM_CURSOR_NO:
   287         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "xterm");
   290         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "xterm");
   288         break;
   291         break;
   289     case SDL_SYSTEM_CURSOR_HAND:
   292     case SDL_SYSTEM_CURSOR_HAND:
   290         cursor = wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   293         cursor = WAYLAND_wl_cursor_theme_get_cursor(d->cursor_theme, "hand1");
   291         break;
   294         break;
   292     }
   295     }
   293 
   296 
   294     SDL_Cursor *sdl_cursor = CreateCursorFromWlCursor (d, cursor);
   297     SDL_Cursor *sdl_cursor = CreateCursorFromWlCursor (d, cursor);
   295 
   298