26 #include "../../SDL_internal.h" 28 #if SDL_VIDEO_DRIVER_MIR 30 #include "../../events/SDL_mouse_c.h" 31 #include "../SDL_sysvideo.h" 42 MirCursorConfiguration* conf;
47 MIR_CreateDefaultCursor()
54 MIR_Cursor* mir_cursor =
SDL_calloc(1,
sizeof(MIR_Cursor));
56 mir_cursor->conf =
NULL;
57 mir_cursor->stream =
NULL;
77 int i, s_w, s_h, r_stride, p_stride, bytes_per_pixel, bytes_per_row;
79 MirGraphicsRegion region;
80 MIR_mir_buffer_stream_get_graphics_region(stream, ®ion);
86 bytes_per_row = bytes_per_pixel * s_w;
89 pixels = (
char*)surface->
pixels;
91 r_stride = region.stride;
92 p_stride = surface->
pitch;
94 for (i = 0; i < s_h; i++)
103 MIR_CreateCursor(
SDL_Surface* surface,
int hot_x,
int hot_y)
105 MirCursorConfiguration* conf;
108 int s_w = surface->
w;
109 int s_h = surface->
h;
112 SDL_Cursor* cursor = MIR_CreateDefaultCursor();
113 MIR_Cursor* mir_cursor;
121 stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->
connection,
123 mir_buffer_usage_software);
125 conf = MIR_mir_cursor_configuration_from_buffer_stream(stream, hot_x, hot_y);
127 CopySurfacePixelsToMirStream(surface, stream);
128 MIR_mir_buffer_stream_swap_buffers_sync(stream);
130 mir_cursor->conf = conf;
131 mir_cursor->stream =
stream;
139 char const* cursor_name =
NULL;
140 SDL_Cursor* cursor = MIR_CreateDefaultCursor();
141 MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->
driverdata;
149 cursor_name = MIR_mir_arrow_cursor_name;
152 cursor_name = MIR_mir_caret_cursor_name;
155 cursor_name = MIR_mir_busy_cursor_name;
159 cursor_name = MIR_mir_arrow_cursor_name;
162 cursor_name = MIR_mir_busy_cursor_name;
165 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
168 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
171 cursor_name = MIR_mir_horizontal_resize_cursor_name;
174 cursor_name = MIR_mir_vertical_resize_cursor_name;
177 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
181 cursor_name = MIR_mir_closed_hand_cursor_name;
184 cursor_name = MIR_mir_open_hand_cursor_name;
191 mir_cursor->conf = MIR_mir_cursor_configuration_from_name(cursor_name);
202 MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->
driverdata;
204 if (mir_cursor->conf)
205 MIR_mir_cursor_configuration_destroy(mir_cursor->conf);
206 if (mir_cursor->stream)
207 MIR_mir_buffer_stream_release_sync(mir_cursor->stream);
223 if (mir_window && MIR_mir_surface_is_valid(mir_window->
surface)) {
224 MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->
driverdata;
226 if (mir_cursor->conf) {
227 MIR_mir_surface_configure_cursor(mir_window->
surface, mir_cursor->conf);
231 else if(mir_window && MIR_mir_surface_is_valid(mir_window->
surface)) {
232 MIR_mir_surface_configure_cursor(mir_window->
surface,
NULL);
245 MIR_WarpMouseGlobal(
int x,
int y)
SDL_Mouse * SDL_GetMouse(void)
int(* ShowCursor)(SDL_Cursor *cursor)
GLint GLint GLint GLint GLint x
int(* SetRelativeMouseMode)(SDL_bool enabled)
static SDL_Window * window
MirPixelFormat pixel_format
A collection of pixels used in software blitting.
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
MirConnection * connection
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
void * SDL_calloc(size_t nmemb, size_t size)
MIR_Window * current_window
GLint GLint GLint GLint GLint GLint y
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor().
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
int(* WarpMouseGlobal)(int x, int y)
GLenum GLenum GLsizei const GLuint GLboolean enabled
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
void(* FreeCursor)(SDL_Cursor *cursor)
#define SDL_assert(condition)
#define SDL_OutOfMemory()
The type used to identify a window.
void(* WarpMouse)(SDL_Window *window, int x, int y)
SDL_VideoDevice * SDL_GetVideoDevice(void)
SDL_Cursor *(* CreateSystemCursor)(SDL_SystemCursor id)
#define SDL_Unsupported()