static int
MIR_Available()
{
    int available = 0;

    if (SDL_MIR_LoadSymbols()) {

        /* Lets ensure we can connect to the mir server */
        MirConnection* connection = MIR_mir_connect_sync(NULL, __PRETTY_FUNCTION__);

        if (!MIR_mir_connection_is_valid(connection)) {
            SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Unable to connect to the mir server %s",
                MIR_mir_connection_get_error_message(connection));

            return available;
        }

        MIR_mir_connection_release(connection);

        available = 1;
        SDL_MIR_UnloadSymbols();
    }

    return available;
}
示例#2
0
文件: SDL_mirvideo.c 项目: rayyee/SDL
static int
MIR_Available()
{
    int available = 0;

    if (SDL_MIR_LoadSymbols()) {
        /* !!! FIXME: try to make a MirConnection here. */
        available = 1;
        SDL_MIR_UnloadSymbols();
    }

    return available;
}
示例#3
0
/* returns non-zero if all needed symbols were loaded. */
int
SDL_MIR_LoadSymbols(void)
{
    int rc = 1;                 /* always succeed if not using Dynamic MIR stuff. */

    /* deal with multiple modules (dga, wayland, mir, etc) needing these symbols... */
    if (mir_load_refcount++ == 0) {
#ifdef SDL_VIDEO_DRIVER_MIR_DYNAMIC
        int i;
        int *thismod = NULL;
        for (i = 0; i < SDL_TABLESIZE(mirlibs); i++) {
            if (mirlibs[i].libname != NULL) {
                mirlibs[i].lib = SDL_LoadObject(mirlibs[i].libname);
            }
        }

#define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 1; /* default yes */
#define SDL_MIR_SYM(rc,fn,params)
#include "SDL_mirsym.h"
#undef SDL_MIR_MODULE
#undef SDL_MIR_SYM

#define SDL_MIR_MODULE(modname) thismod = &SDL_MIR_HAVE_##modname;
#define SDL_MIR_SYM(rc,fn,params) MIR_##fn = (SDL_DYNMIRFN_##fn) MIR_GetSym(#fn,thismod);
#include "SDL_mirsym.h"
#undef SDL_MIR_MODULE
#undef SDL_MIR_SYM

        if ((SDL_MIR_HAVE_MIR_CLIENT) && (SDL_MIR_HAVE_XKBCOMMON)) {
            /* all required symbols loaded. */
            SDL_ClearError();
        } else {
            /* in case something got loaded... */
            SDL_MIR_UnloadSymbols();
            rc = 0;
        }

#else  /* no dynamic MIR */

#define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 1; /* default yes */
#define SDL_MIR_SYM(rc,fn,params) MIR_##fn = fn;
#include "SDL_mirsym.h"
#undef SDL_MIR_MODULE
#undef SDL_MIR_SYM

#endif
    }

    return rc;
}
static SDL_VideoDevice*
MIR_CreateDevice(int device_index)
{
    MIR_Data* mir_data;
    SDL_VideoDevice* device = NULL;

    if (!SDL_MIR_LoadSymbols()) {
        return NULL;
    }

    device = SDL_calloc(1, sizeof(SDL_VideoDevice));
    if (!device) {
        SDL_MIR_UnloadSymbols();
        SDL_OutOfMemory();
        return NULL;
    }

    mir_data = SDL_calloc(1, sizeof(MIR_Data));
    if (!mir_data) {
        SDL_free(device);
        SDL_MIR_UnloadSymbols();
        SDL_OutOfMemory();
        return NULL;
    }

    device->driverdata = mir_data;

    /* mirvideo */
    device->VideoInit        = MIR_VideoInit;
    device->VideoQuit        = MIR_VideoQuit;
    device->GetDisplayBounds = MIR_GetDisplayBounds;
    device->GetDisplayModes  = MIR_GetDisplayModes;
    device->SetDisplayMode   = MIR_SetDisplayMode;
    device->free             = MIR_DeleteDevice;

    /* miropengles */
    device->GL_SwapWindow      = MIR_GL_SwapWindow;
    device->GL_MakeCurrent     = MIR_GL_MakeCurrent;
    device->GL_CreateContext   = MIR_GL_CreateContext;
    device->GL_DeleteContext   = MIR_GL_DeleteContext;
    device->GL_LoadLibrary     = MIR_GL_LoadLibrary;
    device->GL_UnloadLibrary   = MIR_GL_UnloadLibrary;
    device->GL_GetSwapInterval = MIR_GL_GetSwapInterval;
    device->GL_SetSwapInterval = MIR_GL_SetSwapInterval;
    device->GL_GetProcAddress  = MIR_GL_GetProcAddress;

    /* mirwindow */
    device->CreateSDLWindow         = MIR_CreateWindow;
    device->DestroyWindow        = MIR_DestroyWindow;
    device->GetWindowWMInfo      = MIR_GetWindowWMInfo;
    device->SetWindowFullscreen  = MIR_SetWindowFullscreen;
    device->MaximizeWindow       = MIR_MaximizeWindow;
    device->MinimizeWindow       = MIR_MinimizeWindow;
    device->RestoreWindow        = MIR_RestoreWindow;
    device->ShowWindow           = MIR_RestoreWindow;
    device->HideWindow           = MIR_HideWindow;
    device->SetWindowSize        = MIR_SetWindowSize;
    device->SetWindowMinimumSize = MIR_SetWindowMinimumSize;
    device->SetWindowMaximumSize = MIR_SetWindowMaximumSize;
    device->SetWindowTitle       = MIR_SetWindowTitle;
    device->SetWindowGrab        = MIR_SetWindowGrab;
    device->SetWindowGammaRamp   = MIR_SetWindowGammaRamp;
    device->GetWindowGammaRamp   = MIR_GetWindowGammaRamp;

    device->CreateSDLWindowFrom     = NULL;
    device->SetWindowIcon        = NULL;
    device->RaiseWindow          = NULL;
    device->SetWindowBordered    = NULL;
    device->SetWindowResizable   = NULL;
    device->OnWindowEnter        = NULL;
    device->SetWindowPosition    = NULL;

    /* mirframebuffer */
    device->CreateWindowFramebuffer  = MIR_CreateWindowFramebuffer;
    device->UpdateWindowFramebuffer  = MIR_UpdateWindowFramebuffer;
    device->DestroyWindowFramebuffer = MIR_DestroyWindowFramebuffer;

    device->shape_driver.CreateShaper      = MIR_CreateShaper;
    device->shape_driver.SetWindowShape    = MIR_SetWindowShape;
    device->shape_driver.ResizeWindowShape = MIR_ResizeWindowShape;

    device->PumpEvents = MIR_PumpEvents;

    device->SuspendScreenSaver = NULL;

    device->StartTextInput   = NULL;
    device->StopTextInput    = NULL;
    device->SetTextInputRect = NULL;

    device->HasScreenKeyboardSupport = NULL;
    device->ShowScreenKeyboard       = NULL;
    device->HideScreenKeyboard       = NULL;
    device->IsScreenKeyboardShown    = NULL;

    device->SetClipboardText = NULL;
    device->GetClipboardText = NULL;
    device->HasClipboardText = NULL;

    device->ShowMessageBox = NULL;

#if SDL_VIDEO_VULKAN
    device->Vulkan_LoadLibrary = MIR_Vulkan_LoadLibrary;
    device->Vulkan_UnloadLibrary = MIR_Vulkan_UnloadLibrary;
    device->Vulkan_GetInstanceExtensions = MIR_Vulkan_GetInstanceExtensions;
    device->Vulkan_CreateSurface = MIR_Vulkan_CreateSurface;
#endif

    return device;
}
static void
MIR_DeleteDevice(SDL_VideoDevice* device)
{
    SDL_free(device);
    SDL_MIR_UnloadSymbols();
}