// FIXME implement int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot) { MirBufferStream* stream; MirPixelFormat pixel_format = findValidPixelFormat(); int i_w = image->width; int i_h = image->height; if (pixel_format == mir_pixel_format_invalid) { _glfwInputError(GLFW_PLATFORM_ERROR, "Mir: Unable to find a correct pixel format"); return GL_FALSE; } stream = mir_connection_create_buffer_stream_sync(_glfw.mir.connection, i_w, i_h, pixel_format, mir_buffer_usage_software); cursor->mir.conf = mir_cursor_configuration_from_buffer_stream(stream, xhot, yhot); char* dest; unsigned char *pixels; int i, r_stride, bytes_per_pixel, bytes_per_row; MirGraphicsRegion region; mir_buffer_stream_get_graphics_region(stream, ®ion); // FIXME Figure this out based on the current_pf bytes_per_pixel = 4; bytes_per_row = bytes_per_pixel * i_w; dest = region.vaddr; pixels = image->pixels; r_stride = region.stride; for (i = 0; i < i_h; i++) { memcpy(dest, pixels, bytes_per_row); dest += r_stride; pixels += r_stride; } cursor->mir.custom_cursor = stream; return GL_TRUE; }
static int createSurface(_GLFWwindow* window) { MirSurfaceSpec* spec; MirBufferUsage buffer_usage = mir_buffer_usage_hardware; MirPixelFormat pixel_format = findValidPixelFormat(); if (pixel_format == mir_pixel_format_invalid) { _glfwInputError(GLFW_PLATFORM_ERROR, "Mir: Unable to find a correct pixel format"); return GL_FALSE; } spec = mir_connection_create_spec_for_normal_surface(_glfw.mir.connection, window->mir.width, window->mir.height, pixel_format); mir_surface_spec_set_buffer_usage(spec, buffer_usage); mir_surface_spec_set_name(spec, "MirSurface"); window->mir.surface = mir_surface_create_sync(spec); mir_surface_spec_release(spec); if (!mir_surface_is_valid(window->mir.surface)) { _glfwInputError(GLFW_PLATFORM_ERROR, "Mir: Unable to create surface: %s", mir_surface_get_error_message(window->mir.surface)); return GL_FALSE; } mir_surface_set_event_handler(window->mir.surface, addNewEvent, window); return GL_TRUE; }
{ .name = "MirSurface", .width = window->mir.width, .height = window->mir.height, .pixel_format = mir_pixel_format_invalid, .buffer_usage = mir_buffer_usage_hardware, .output_id = mir_display_output_id_invalid }; MirEventDelegate delegate = { addNewEvent, window }; params.pixel_format = findValidPixelFormat(); if (params.pixel_format == mir_pixel_format_invalid) { _glfwInputError(GLFW_PLATFORM_ERROR, "Mir: Unable to find a correct pixel format"); return GL_FALSE; } window->mir.surface = mir_connection_create_surface_sync(_glfw.mir.connection, ¶ms); if (!mir_surface_is_valid(window->mir.surface)) { _glfwInputError(GLFW_PLATFORM_ERROR, "Mir: Unable to create surface: %s", mir_surface_get_error_message(window->mir.surface));