26 #include "../../SDL_internal.h" 28 #if SDL_VIDEO_DRIVER_MIR 40 #define MIR_DRIVER_NAME "mir" 42 static const Uint32 mir_pixel_format_to_sdl_format[] = {
58 return mir_pixel_format_to_sdl_format[
format];
117 MIR_PumpEvents(
_THIS)
122 MIR_CreateDevice(
int device_index)
154 device->
free = MIR_DeleteDevice;
225 MIR_DRIVER_NAME,
"SDL Mir video driver",
226 MIR_Available, MIR_CreateDevice
230 MIR_ConvertModeToSDLMode(MirOutputMode
const*
mode, MirPixelFormat
format)
234 .w = MIR_mir_output_mode_get_width(mode),
235 .h = MIR_mir_output_mode_get_height(mode),
236 .refresh_rate = MIR_mir_output_mode_get_refresh_rate(mode),
251 MIR_InitDisplayFromOutput(
_THIS, MirOutput*
output)
256 MirPixelFormat
format = MIR_mir_output_get_current_pixel_format(output);
257 int num_modes = MIR_mir_output_get_num_modes(output);
258 SDL_DisplayMode current_mode = MIR_ConvertModeToSDLMode(mir_output_get_current_mode(output), format);
263 display.
name = (
char*)MIR_mir_output_type_name(MIR_mir_output_get_type(output));
265 for (m = 0; m < num_modes; m++) {
266 MirOutputMode
const*
mode = MIR_mir_output_get_mode(output, m);
267 MIR_AddModeToDisplay(&display, mode, format);
278 MIR_InitDisplays(
_THIS)
281 int num_outputs = MIR_mir_display_config_get_num_outputs(mir_data->
display_config);
284 for (d = 0; d < num_outputs; d++) {
285 MirOutput* output = MIR_mir_display_config_get_mutable_output(mir_data->
display_config, d);
287 MirOutputConnectionState
state = MIR_mir_output_get_connection_state(output);
289 if (enabled && state == mir_output_connection_state_connected) {
290 MIR_InitDisplayFromOutput(
_this, output);
300 mir_data->
connection = MIR_mir_connect_sync(
NULL, __PRETTY_FUNCTION__);
305 if (!MIR_mir_connection_is_valid(mir_data->
connection)) {
306 return SDL_SetError(
"Failed to connect to the mir server: %s",
307 MIR_mir_connection_get_error_message(mir_data->
connection));
312 MIR_InitDisplays(
_this);
319 MIR_CleanUpDisplayConfig(
_THIS)
337 MIR_CleanUpDisplayConfig(
_this);
344 MIR_mir_connection_release(mir_data->
connection);
353 MirOutput
const* output = display->
driverdata;
355 rect->
x = MIR_mir_output_get_position_x(output);
356 rect->
y = MIR_mir_output_get_position_y(output);
373 int num_modes = MIR_mir_output_get_num_modes(output);
375 MIR_mir_output_get_current_pixel_format(output));
377 for (m = 0; m < num_modes; m++) {
378 MirOutputMode
const* mir_mode = MIR_mir_output_get_mode(output, m);
379 int width = MIR_mir_output_mode_get_width(mir_mode);
380 int height = MIR_mir_output_mode_get_height(mir_mode);
381 double refresh_rate = MIR_mir_output_mode_get_refresh_rate(mir_mode);
383 if (mode->
format == sdl_format &&
389 MIR_mir_output_set_current_mode(output, mir_mode);
#define MIR_GL_GetSwapInterval
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
void(* RestoreWindow)(_THIS, SDL_Window *window)
void MIR_MinimizeWindow(_THIS, SDL_Window *window)
GLint GLint GLsizei width
void MIR_HideWindow(_THIS, SDL_Window *window)
int MIR_CreateWindowFramebuffer(_THIS, SDL_Window *sdl_window, Uint32 *format, void **pixels, int *pitch)
void MIR_GL_UnloadLibrary(_THIS)
int MIR_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
SDL_bool(* IsScreenKeyboardShown)(_THIS, SDL_Window *window)
int MIR_CreateWindow(_THIS, SDL_Window *window)
int(* CreateWindowFrom)(_THIS, SDL_Window *window, const void *data)
static SDL_Window * window
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(* GL_SwapWindow)(_THIS, SDL_Window *window)
uint32_t Uint32
An unsigned 32-bit integer type.
GLint GLint GLsizei GLsizei height
void MIR_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
int(* GL_LoadLibrary)(_THIS, const char *path)
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)
void(* HideWindow)(_THIS, SDL_Window *window)
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)
void * SDL_calloc(size_t nmemb, size_t size)
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_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 MIR_MaximizeWindow(_THIS, SDL_Window *window)
void(* SetWindowMinimumSize)(_THIS, SDL_Window *window)
SDL_DisplayMode current_mode
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 * MIR_GL_GetProcAddress(_THIS, const char *proc)
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
int(* ShowMessageBox)(_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid)
void(* SetWindowMaximumSize)(_THIS, SDL_Window *window)
#define SDL_OutOfMemory()
SDL_DisplayMode desktop_mode
#define MIR_GL_DeleteContext
SDL_WindowShaper *(* CreateShaper)(SDL_Window *window)
int(* ResizeWindowShape)(SDL_Window *window)
void(* SetWindowPosition)(_THIS, SDL_Window *window)
void(* ShowScreenKeyboard)(_THIS, SDL_Window *window)
int(* CreateWindow)(_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
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)
void MIR_GL_SwapWindow(_THIS, SDL_Window *window)
#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)