static SDL_Cursor* MIR_CreateSystemCursor(SDL_SystemCursor id) { switch(id) { case SDL_SYSTEM_CURSOR_ARROW: break; case SDL_SYSTEM_CURSOR_IBEAM: break; case SDL_SYSTEM_CURSOR_WAIT: break; case SDL_SYSTEM_CURSOR_CROSSHAIR: break; case SDL_SYSTEM_CURSOR_WAITARROW: break; case SDL_SYSTEM_CURSOR_SIZENWSE: break; case SDL_SYSTEM_CURSOR_SIZENESW: break; case SDL_SYSTEM_CURSOR_SIZEWE: break; case SDL_SYSTEM_CURSOR_SIZENS: break; case SDL_SYSTEM_CURSOR_SIZEALL: break; case SDL_SYSTEM_CURSOR_NO: break; case SDL_SYSTEM_CURSOR_HAND: break; default: SDL_assert(0); return NULL; } return MIR_CreateDefaultCursor(); }
static SDL_Cursor* MIR_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y) { MirCursorConfiguration* conf; MirBufferStream* stream; int s_w = surface->w; int s_h = surface->h; MIR_Data* mir_data = (MIR_Data*)SDL_GetVideoDevice()->driverdata; SDL_Cursor* cursor = MIR_CreateDefaultCursor(); MIR_Cursor* mir_cursor; if (!cursor) { return NULL; } mir_cursor = (MIR_Cursor*)cursor->driverdata; stream = MIR_mir_connection_create_buffer_stream_sync(mir_data->connection, s_w, s_h, mir_data->pixel_format, mir_buffer_usage_software); conf = MIR_mir_cursor_configuration_from_buffer_stream(stream, hot_x, hot_y); CopySurfacePixelsToMirStream(surface, stream); MIR_mir_buffer_stream_swap_buffers_sync(stream); mir_cursor->conf = conf; mir_cursor->stream = stream; return cursor; }
/* TODO Actually implement the cursor, need to wait for mir support */ void MIR_InitMouse() { SDL_Mouse* mouse = SDL_GetMouse(); mouse->CreateCursor = MIR_CreateCursor; mouse->ShowCursor = MIR_ShowCursor; mouse->FreeCursor = MIR_FreeCursor; mouse->WarpMouse = MIR_WarpMouse; mouse->CreateSystemCursor = MIR_CreateSystemCursor; mouse->SetRelativeMouseMode = MIR_SetRelativeMouseMode; SDL_SetDefaultCursor(MIR_CreateDefaultCursor()); }
static SDL_Cursor* MIR_CreateCursor(SDL_Surface* sruface, int hot_x, int hot_y) { return MIR_CreateDefaultCursor(); }
static SDL_Cursor* MIR_CreateSystemCursor(SDL_SystemCursor id) { char const* cursor_name = NULL; SDL_Cursor* cursor; MIR_Cursor* mir_cursor; switch(id) { case SDL_SYSTEM_CURSOR_ARROW: cursor_name = MIR_mir_arrow_cursor_name; break; case SDL_SYSTEM_CURSOR_IBEAM: cursor_name = MIR_mir_caret_cursor_name; break; case SDL_SYSTEM_CURSOR_WAIT: cursor_name = MIR_mir_busy_cursor_name; break; case SDL_SYSTEM_CURSOR_CROSSHAIR: /* Unsupported */ cursor_name = MIR_mir_arrow_cursor_name; break; case SDL_SYSTEM_CURSOR_WAITARROW: cursor_name = MIR_mir_busy_cursor_name; break; case SDL_SYSTEM_CURSOR_SIZENWSE: cursor_name = MIR_mir_omnidirectional_resize_cursor_name; break; case SDL_SYSTEM_CURSOR_SIZENESW: cursor_name = MIR_mir_omnidirectional_resize_cursor_name; break; case SDL_SYSTEM_CURSOR_SIZEWE: cursor_name = MIR_mir_horizontal_resize_cursor_name; break; case SDL_SYSTEM_CURSOR_SIZENS: cursor_name = MIR_mir_vertical_resize_cursor_name; break; case SDL_SYSTEM_CURSOR_SIZEALL: cursor_name = MIR_mir_omnidirectional_resize_cursor_name; break; case SDL_SYSTEM_CURSOR_NO: /* Unsupported */ cursor_name = MIR_mir_closed_hand_cursor_name; break; case SDL_SYSTEM_CURSOR_HAND: cursor_name = MIR_mir_open_hand_cursor_name; break; default: SDL_assert(0); return NULL; } cursor = MIR_CreateDefaultCursor(); if (!cursor) { return NULL; } mir_cursor = (MIR_Cursor*)cursor->driverdata; mir_cursor->name = cursor_name; return cursor; }