26 #include "../../SDL_internal.h" 28 #if SDL_VIDEO_DRIVER_MIR 44 #define MIR_DRIVER_NAME "mir" 46 static const Uint32 mir_pixel_format_to_sdl_format[] = {
62 return mir_pixel_format_to_sdl_format[
format];
109 if (!MIR_mir_connection_is_valid(connection)) {
111 MIR_mir_connection_get_error_message(connection));
116 MIR_mir_connection_release(connection);
133 MIR_PumpEvents(
_THIS)
138 MIR_CreateDevice(
int device_index)
170 device->
free = MIR_DeleteDevice;
248 MIR_DRIVER_NAME,
"SDL Mir video driver",
249 MIR_Available, MIR_CreateDevice
253 MIR_ConvertModeToSDLMode(MirOutputMode
const*
mode, MirPixelFormat
format)
257 .w = MIR_mir_output_mode_get_width(mode),
258 .h = MIR_mir_output_mode_get_height(mode),
259 .refresh_rate = MIR_mir_output_mode_get_refresh_rate(mode),
274 MIR_InitDisplayFromOutput(
_THIS, MirOutput*
output)
279 MirPixelFormat
format = MIR_mir_output_get_current_pixel_format(output);
280 int num_modes = MIR_mir_output_get_num_modes(output);
281 SDL_DisplayMode current_mode = MIR_ConvertModeToSDLMode(MIR_mir_output_get_current_mode(output), format);
286 display.
name = (
char*)MIR_mir_output_type_name(MIR_mir_output_get_type(output));
288 for (m = 0; m < num_modes; m++) {
289 MirOutputMode
const*
mode = MIR_mir_output_get_mode(output, m);
290 MIR_AddModeToDisplay(&display, mode, format);
301 MIR_InitDisplays(
_THIS)
304 int num_outputs = MIR_mir_display_config_get_num_outputs(mir_data->
display_config);
307 for (d = 0; d < num_outputs; d++) {
308 MirOutput* output = MIR_mir_display_config_get_mutable_output(mir_data->
display_config, d);
310 MirOutputConnectionState
state = MIR_mir_output_get_connection_state(output);
312 if (enabled && state == mir_output_connection_state_connected) {
313 MIR_InitDisplayFromOutput(
_this, output);
328 if (!MIR_mir_connection_is_valid(mir_data->
connection)) {
329 return SDL_SetError(
"Failed to connect to the mir server: %s",
330 MIR_mir_connection_get_error_message(mir_data->
connection));
335 MIR_InitDisplays(
_this);
342 MIR_CleanUpDisplayConfig(
_THIS)
360 MIR_CleanUpDisplayConfig(
_this);
367 MIR_mir_connection_release(mir_data->
connection);
376 MirOutput
const* output = display->
driverdata;
378 rect->
x = MIR_mir_output_get_position_x(output);
379 rect->
y = MIR_mir_output_get_position_y(output);
396 int num_modes = MIR_mir_output_get_num_modes(output);
398 MIR_mir_output_get_current_pixel_format(output));
400 for (m = 0; m < num_modes; m++) {
401 MirOutputMode
const* mir_mode = MIR_mir_output_get_mode(output, m);
402 int width = MIR_mir_output_mode_get_width(mir_mode);
403 int height = MIR_mir_output_mode_get_height(mir_mode);
404 double refresh_rate = MIR_mir_output_mode_get_refresh_rate(mir_mode);
406 if (mode->
format == sdl_format &&
412 MIR_mir_output_set_current_mode(output, mir_mode);
int(* Vulkan_LoadLibrary)(_THIS, const char *path)
#define MIR_GL_GetSwapInterval
void(* RestoreWindow)(_THIS, SDL_Window *window)
void MIR_MinimizeWindow(_THIS, SDL_Window *window)
#define MIR_GL_GetProcAddress
void MIR_HideWindow(_THIS, SDL_Window *window)
int MIR_CreateWindowFramebuffer(_THIS, SDL_Window *sdl_window, Uint32 *format, void **pixels, int *pitch)
int MIR_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
SDL_bool(* IsScreenKeyboardShown)(_THIS, SDL_Window *window)
int MIR_CreateWindow(_THIS, SDL_Window *window)
VideoBootStrap MIR_bootstrap
MirPixelFormat pixel_format
MirDisplayConfig * display_config
A collection of pixels used in software blitting.
int(* GL_SetSwapInterval)(_THIS, int interval)
void(* ShowWindow)(_THIS, SDL_Window *window)
The structure that defines a display mode.
void(* StartTextInput)(_THIS)
void(* SetWindowSize)(_THIS, SDL_Window *window)
void MIR_DestroyWindow(_THIS, SDL_Window *window)
void MIR_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
int(* GL_LoadLibrary)(_THIS, const char *path)
GLint GLint GLsizei width
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
#define MIR_GL_SetSwapInterval
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
static SDL_VideoDevice * _this
void SDL_MIR_UnloadSymbols(void)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
void(* HideWindow)(_THIS, SDL_Window *window)
static SDL_AudioDeviceID device
MirConnection * connection
void(* RaiseWindow)(_THIS, SDL_Window *window)
int(* SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
void(* SetTextInputRect)(_THIS, SDL_Rect *rect)
SDL_bool(* Vulkan_GetInstanceExtensions)(_THIS, SDL_Window *window, unsigned *count, const char **names)
MIR_Window * current_window
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
SDL_bool(* Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
SDL_GLContext MIR_GL_CreateContext(_THIS, SDL_Window *window)
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
void MIR_RestoreWindow(_THIS, SDL_Window *window)
void MIR_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
void(* Vulkan_UnloadLibrary)(_THIS)
int MIR_GL_SwapWindow(_THIS, SDL_Window *window)
void MIR_MaximizeWindow(_THIS, SDL_Window *window)
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
SDL_DisplayMode current_mode
#define MIR_GL_UnloadLibrary
SDL_VideoDisplay * displays
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
void(* DestroyWindow)(_THIS, SDL_Window *window)
void(* StopTextInput)(_THIS)
int MIR_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
int MIR_UpdateWindowFramebuffer(_THIS, SDL_Window *sdl_window, const SDL_Rect *rects, int numrects)
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
int MIR_SetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 const *ramp)
SDL_bool(* HasScreenKeyboardSupport)(_THIS)
GLenum GLenum GLsizei const GLuint GLboolean enabled
void MIR_SetWindowTitle(_THIS, SDL_Window *window)
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
void MIR_DestroyWindowFramebuffer(_THIS, SDL_Window *sdl_window)
void(* GL_UnloadLibrary)(_THIS)
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(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
int(* ShowMessageBox)(_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid)
void(* SetWindowMaximumSize)(_THIS, SDL_Window *window)
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
#define SDL_OutOfMemory()
SDL_DisplayMode desktop_mode
#define MIR_GL_DeleteContext
SDL_WindowShaper *(* CreateShaper)(SDL_Window *window)
GLint GLint GLsizei GLsizei height
int(* ResizeWindowShape)(SDL_Window *window)
EGLSurface EGLNativeWindowType * window
void(* SetWindowPosition)(_THIS, SDL_Window *window)
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
void(* ShowScreenKeyboard)(_THIS, SDL_Window *window)
The type used to identify a window.
int(* GetWindowGammaRamp)(_THIS, SDL_Window *window, Uint16 *ramp)
void(* MinimizeWindow)(_THIS, SDL_Window *window)
SDL_bool(* HasClipboardText)(_THIS)
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
SDL_ShapeDriver shape_driver
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents...
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
char *(* GetClipboardText)(_THIS)
void(* SetWindowTitle)(_THIS, SDL_Window *window)
void(* SetWindowResizable)(_THIS, SDL_Window *window, SDL_bool resizable)
int(* GL_GetSwapInterval)(_THIS)
void(* MaximizeWindow)(_THIS, SDL_Window *window)
int(* SetClipboardText)(_THIS, const char *text)
Uint32 MIR_GetSDLPixelFormat(MirPixelFormat format)
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
void(* OnWindowEnter)(_THIS, SDL_Window *window)
void(* SuspendScreenSaver)(_THIS)
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
#define SDL_Unsupported()
int SDL_MIR_LoadSymbols(void)
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
SDL_bool MIR_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
void MIR_SetWindowMaximumSize(_THIS, SDL_Window *window)
int MIR_GL_LoadLibrary(_THIS, const char *path)
void *(* GL_GetProcAddress)(_THIS, const char *proc)
A rectangle, with the origin at the upper left.
void MIR_SetWindowMinimumSize(_THIS, SDL_Window *window)
void MIR_SetWindowSize(_THIS, SDL_Window *window)
void(* PumpEvents)(_THIS)
void(* HideScreenKeyboard)(_THIS, SDL_Window *window)