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;
75 int i, s_w, s_h, r_stride, p_stride, bytes_per_pixel, bytes_per_row;
77 MirGraphicsRegion region;
78 MIR_mir_buffer_stream_get_graphics_region(stream, ®ion);
84 bytes_per_row = bytes_per_pixel * s_w;
87 pixels = (
char*)surface->
pixels;
89 r_stride = region.stride;
90 p_stride = surface->
pitch;
92 for (i = 0; i < s_h; i++)
94 memcpy(dest, pixels, bytes_per_row);
101 MIR_CreateCursor(
SDL_Surface* surface,
int hot_x,
int hot_y)
103 MirCursorConfiguration* conf;
106 int s_w = surface->
w;
107 int s_h = surface->
h;
110 SDL_Cursor* cursor = MIR_CreateDefaultCursor();
111 MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->
driverdata;
113 stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->
connection,
115 mir_buffer_usage_software);
117 conf = MIR_mir_cursor_configuration_from_buffer_stream(stream, hot_x, hot_y);
119 CopySurfacePixelsToMirStream(surface, stream);
120 MIR_mir_buffer_stream_swap_buffers_sync(stream);
122 mir_cursor->conf = conf;
123 mir_cursor->stream =
stream;
131 char const* cursor_name =
NULL;
132 MirCursorConfiguration* conf;
133 SDL_Cursor* cursor = MIR_CreateDefaultCursor();
137 cursor_name = MIR_mir_arrow_cursor_name;
140 cursor_name = MIR_mir_caret_cursor_name;
143 cursor_name = MIR_mir_busy_cursor_name;
147 cursor_name = MIR_mir_arrow_cursor_name;
150 cursor_name = MIR_mir_busy_cursor_name;
153 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
156 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
159 cursor_name = MIR_mir_horizontal_resize_cursor_name;
162 cursor_name = MIR_mir_vertical_resize_cursor_name;
165 cursor_name = MIR_mir_omnidirectional_resize_cursor_name;
169 cursor_name = MIR_mir_closed_hand_cursor_name;
172 cursor_name = MIR_mir_open_hand_cursor_name;
179 conf = MIR_mir_cursor_configuration_from_name(cursor_name);
192 MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->
driverdata;
194 if (mir_cursor->conf)
195 MIR_mir_cursor_configuration_destroy(mir_cursor->conf);
196 if (mir_cursor->stream)
197 MIR_mir_buffer_stream_release_sync(mir_cursor->stream);
213 if (mir_window && MIR_mir_surface_is_valid(mir_window->
surface)) {
214 MIR_Cursor* mir_cursor = (MIR_Cursor*)cursor->
driverdata;
216 if (mir_cursor->conf) {
217 MIR_mir_wait_for(MIR_mir_surface_configure_cursor(mir_window->
surface, mir_cursor->conf));
221 else if(mir_window && MIR_mir_surface_is_valid(mir_window->
surface)) {
222 MIR_mir_wait_for(MIR_mir_surface_configure_cursor(mir_window->
surface,
NULL));
235 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.
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
void(* FreeCursor)(SDL_Cursor *cursor)
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)
#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()