22 #include "../../SDL_internal.h"
24 #if SDL_VIDEO_DRIVER_WAYLAND
26 #include <sys/types.h>
33 #include "../SDL_sysvideo.h"
36 #include "../../events/SDL_mouse_c.h"
41 #include "wayland-cursor.h"
58 wayland_create_tmp_file(off_t
size)
60 static const char template[] =
"/sdl-shared-XXXXXX";
62 char tmp_path[PATH_MAX];
73 fd = mkostemp(tmp_path, O_CLOEXEC);
77 if (ftruncate(
fd,
size) < 0) {
86 mouse_buffer_release(
void *
data,
struct wl_buffer *
buffer)
90 static const struct wl_buffer_listener mouse_buffer_listener = {
95 create_buffer_from_shm(Wayland_CursorData *
d,
102 struct wl_shm_pool *shm_pool;
109 shm_fd = wayland_create_tmp_file(
size);
112 return SDL_SetError(
"Creating mouse cursor buffer failed.");
115 d->shm_data = mmap(
NULL,
117 PROT_READ | PROT_WRITE,
121 if (
d->shm_data == MAP_FAILED) {
129 shm_pool = wl_shm_create_pool(
data->shm, shm_fd,
size);
130 d->buffer = wl_shm_pool_create_buffer(shm_pool,
136 wl_buffer_add_listener(
d->buffer,
137 &mouse_buffer_listener,
140 wl_shm_pool_destroy (shm_pool);
155 Wayland_CursorData *
data = calloc (1,
sizeof (Wayland_CursorData));
168 if (create_buffer_from_shm (
data,
171 WL_SHM_FORMAT_ARGB8888) < 0)
183 wl_surface_set_user_data(
data->surface,
NULL);
197 CreateCursorFromWlCursor(
SDL_VideoData *
d,
struct wl_cursor *wlcursor)
203 Wayland_CursorData *
data = calloc (1,
sizeof (Wayland_CursorData));
211 data->buffer = WAYLAND_wl_cursor_image_get_buffer(wlcursor->images[0]);
212 data->surface = wl_compositor_create_surface(
d->compositor);
213 wl_surface_set_user_data(
data->surface,
NULL);
214 data->hot_x = wlcursor->images[0]->hotspot_x;
215 data->hot_y = wlcursor->images[0]->hotspot_y;
216 data->w = wlcursor->images[0]->width;
217 data->h = wlcursor->images[0]->height;
218 data->cursor= wlcursor;
227 Wayland_CreateDefaultCursor()
232 return CreateCursorFromWlCursor (
data,
233 WAYLAND_wl_cursor_theme_get_cursor(
data->cursor_theme,
251 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"left_ptr");
254 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"xterm");
257 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"watch");
260 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"hand1");
263 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"watch");
266 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"hand1");
269 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"hand1");
272 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"hand1");
275 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"hand1");
278 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"hand1");
281 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"xterm");
284 cursor = WAYLAND_wl_cursor_theme_get_cursor(
d->cursor_theme,
"hand1");
288 return CreateCursorFromWlCursor(
d,
cursor);
294 Wayland_CursorData *
d;
305 if (
d->buffer && !
d->cursor)
306 wl_buffer_destroy(
d->buffer);
309 wl_surface_destroy(
d->surface);
322 struct wl_pointer *
pointer =
d->pointer;
331 wl_pointer_set_cursor (
pointer, 0,
335 wl_surface_attach(
data->surface,
data->buffer, 0, 0);
336 wl_surface_damage(
data->surface, 0, 0,
data->w,
data->h);
337 wl_surface_commit(
data->surface);
341 wl_pointer_set_cursor (
pointer, 0,
357 Wayland_WarpMouseGlobal(
int x,
int y)
375 Wayland_InitMouse(
void)
391 Wayland_FiniMouse(
void)
#define SDL_assert(condition)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define SDL_OutOfMemory()
#define SDL_Unsupported()
int uint32_t uint32_t uint32_t uint32_t uint32_t int drmModeModeInfoPtr mode int uint32_t uint32_t uint32_t uint32_t int32_t hot_x
SDL_Mouse * SDL_GetMouse(void)
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor().
@ SDL_SYSTEM_CURSOR_SIZENS
@ SDL_SYSTEM_CURSOR_ARROW
@ SDL_SYSTEM_CURSOR_SIZENWSE
@ SDL_SYSTEM_CURSOR_SIZENESW
@ SDL_SYSTEM_CURSOR_IBEAM
@ SDL_SYSTEM_CURSOR_WAITARROW
@ SDL_SYSTEM_CURSOR_SIZEALL
@ SDL_SYSTEM_CURSOR_SIZEWE
@ SDL_SYSTEM_CURSOR_CROSSHAIR
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei width
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLsizei const void * pointer
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
@ SDL_PIXELFORMAT_ARGB8888
SDL_VideoDevice * SDL_GetVideoDevice(void)
int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input)
EGLSurface EGLNativeWindowType * window
static SDL_AudioDeviceID device
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
int(* SetRelativeMouseMode)(SDL_bool enabled)
void(* WarpMouse)(SDL_Window *window, int x, int y)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
void(* FreeCursor)(SDL_Cursor *cursor)
int(* ShowCursor)(SDL_Cursor *cursor)
int(* WarpMouseGlobal)(int x, int y)
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
A collection of pixels used in software blitting.
struct wl_compositor * compositor
The type used to identify a window.