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;
48 MIR_CreateDefaultCursor()
55 MIR_Cursor* mir_cursor =
SDL_calloc(1,
sizeof(MIR_Cursor));
57 mir_cursor->conf =
NULL;
58 mir_cursor->stream =
NULL;
59 mir_cursor->name =
NULL;
79 int i, s_w, s_h, r_stride, p_stride, bytes_per_pixel, bytes_per_row;
81 MirGraphicsRegion region;
82 MIR_mir_buffer_stream_get_graphics_region(stream, ®ion);
88 bytes_per_row = bytes_per_pixel * s_w;
91 pixels = (
char*)surface->
pixels;
93 r_stride = region.stride;
94 p_stride = surface->
pitch;
96 for (i = 0; i < s_h; i++)
107 MirCursorConfiguration* conf;
110 int s_w = surface->
w;
111 int s_h = surface->
h;
114 SDL_Cursor* cursor = MIR_CreateDefaultCursor();
115 MIR_Cursor* mir_cursor;
123 stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->
connection,
125 mir_buffer_usage_software);
127 conf = MIR_mir_cursor_configuration_from_buffer_stream(stream, hot_x, hot_y);
129 CopySurfacePixelsToMirStream(surface, stream);
130 MIR_mir_buffer_stream_swap_buffers_sync(stream);
132 mir_cursor->conf = conf;
133 mir_cursor->stream =
stream;
141 char const* cursor_name =
NULL;
143 MIR_Cursor* mir_cursor;
147 cursor_name = MIR_mir_arrow_cursor_name;
150 cursor_name = MIR_mir_caret_cursor_name;
153 cursor_name = MIR_mir_busy_cursor_name;
157 cursor_name = MIR_mir_arrow_cursor_name;
160 cursor_name = MIR_mir_busy_cursor_name;
163 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
166 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
169 cursor_name = MIR_mir_horizontal_resize_cursor_name;
172 cursor_name = MIR_mir_vertical_resize_cursor_name;
175 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
179 cursor_name = MIR_mir_closed_hand_cursor_name;
182 cursor_name = MIR_mir_open_hand_cursor_name;
189 cursor = MIR_CreateDefaultCursor();
195 mir_cursor->name = cursor_name;
206 MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->
driverdata;
208 if (mir_cursor->conf)
209 MIR_mir_cursor_configuration_destroy(mir_cursor->conf);
210 if (mir_cursor->stream)
211 MIR_mir_buffer_stream_release_sync(mir_cursor->stream);
227 if (mir_window && MIR_mir_window_is_valid(mir_window->
window)) {
228 MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->
driverdata;
230 if (mir_cursor->name !=
NULL) {
231 MirWindowSpec*
spec = MIR_mir_create_window_spec(mir_data->
connection);
232 MIR_mir_window_spec_set_cursor_name(spec, mir_cursor->name);
233 MIR_mir_window_apply_spec(mir_window->
window, spec);
234 MIR_mir_window_spec_release(spec);
237 if (mir_cursor->conf) {
238 MIR_mir_window_configure_cursor(mir_window->
window, mir_cursor->conf);
242 else if(mir_window && MIR_mir_window_is_valid(mir_window->
window)) {
243 MIR_mir_window_configure_cursor(mir_window->
window,
NULL);
256 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)
MirPixelFormat pixel_format
A collection of pixels used in software blitting.
GLuint const GLchar * name
MirConnection * connection
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
MIR_Window * current_window
SDL_SystemCursor
Cursor types for SDL_CreateSystemCursor().
GLint GLint GLint GLint GLint GLint y
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
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()
EGLSurface EGLNativeWindowType * window
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()
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