medfall

A super great game engine
Log | Files | Refs

mir_platform.h (4157B)


      1 //========================================================================
      2 // GLFW 3.3 Mir - www.glfw.org
      3 //------------------------------------------------------------------------
      4 // Copyright (c) 2014-2017 Brandon Schaefer <brandon.schaefer@canonical.com>
      5 //
      6 // This software is provided 'as-is', without any express or implied
      7 // warranty. In no event will the authors be held liable for any damages
      8 // arising from the use of this software.
      9 //
     10 // Permission is granted to anyone to use this software for any purpose,
     11 // including commercial applications, and to alter it and redistribute it
     12 // freely, subject to the following restrictions:
     13 //
     14 // 1. The origin of this software must not be misrepresented; you must not
     15 //    claim that you wrote the original software. If you use this software
     16 //    in a product, an acknowledgment in the product documentation would
     17 //    be appreciated but is not required.
     18 //
     19 // 2. Altered source versions must be plainly marked as such, and must not
     20 //    be misrepresented as being the original software.
     21 //
     22 // 3. This notice may not be removed or altered from any source
     23 //    distribution.
     24 //
     25 //========================================================================
     26 
     27 #include <sys/queue.h>
     28 #include <pthread.h>
     29 #include <dlfcn.h>
     30 
     31 #include <mir_toolkit/mir_client_library.h>
     32 
     33 typedef VkFlags VkMirWindowCreateFlagsKHR;
     34 
     35 typedef struct VkMirWindowCreateInfoKHR
     36 {
     37     VkStructureType             sType;
     38     const void*                 pNext;
     39     VkMirWindowCreateFlagsKHR   flags;
     40     MirConnection*              connection;
     41     MirWindow*                  mirWindow;
     42 } VkMirWindowCreateInfoKHR;
     43 
     44 typedef VkResult (APIENTRY *PFN_vkCreateMirWindowKHR)(VkInstance,const VkMirWindowCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
     45 typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice,uint32_t,MirConnection*);
     46 
     47 #include "posix_thread.h"
     48 #include "posix_time.h"
     49 #include "linux_joystick.h"
     50 #include "xkb_unicode.h"
     51 #include "egl_context.h"
     52 #include "osmesa_context.h"
     53 
     54 #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
     55 #define _glfw_dlclose(handle) dlclose(handle)
     56 #define _glfw_dlsym(handle, name) dlsym(handle, name)
     57 
     58 #define _GLFW_EGL_NATIVE_WINDOW  ((EGLNativeWindowType) window->mir.nativeWindow)
     59 #define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.mir.display)
     60 
     61 #define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowMir  mir
     62 #define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorMir mir
     63 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryMir mir
     64 #define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorMir  mir
     65 
     66 #define _GLFW_PLATFORM_CONTEXT_STATE
     67 #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
     68 
     69 
     70 // Mir-specific Event Queue
     71 //
     72 typedef struct EventQueue
     73 {
     74     TAILQ_HEAD(, EventNode) head;
     75 } EventQueue;
     76 
     77 // Mir-specific per-window data
     78 //
     79 typedef struct _GLFWwindowMir
     80 {
     81     MirWindow*              window;
     82     int                     width;
     83     int                     height;
     84     MirEGLNativeWindowType  nativeWindow;
     85     _GLFWcursor*            currentCursor;
     86 
     87 } _GLFWwindowMir;
     88 
     89 // Mir-specific per-monitor data
     90 //
     91 typedef struct _GLFWmonitorMir
     92 {
     93     int curMode;
     94     int outputId;
     95     int x;
     96     int y;
     97 
     98 } _GLFWmonitorMir;
     99 
    100 // Mir-specific global data
    101 //
    102 typedef struct _GLFWlibraryMir
    103 {
    104     MirConnection*          connection;
    105     MirEGLNativeDisplayType display;
    106     EventQueue* eventQueue;
    107 
    108     short int keycodes[256];
    109     short int scancodes[GLFW_KEY_LAST + 1];
    110 
    111     pthread_mutex_t eventMutex;
    112     pthread_cond_t  eventCond;
    113 
    114     // The window whose disabled cursor mode is active
    115     _GLFWwindow* disabledCursorWindow;
    116 
    117 } _GLFWlibraryMir;
    118 
    119 // Mir-specific per-cursor data
    120 // TODO: Only system cursors are implemented in Mir atm. Need to wait for support.
    121 //
    122 typedef struct _GLFWcursorMir
    123 {
    124     MirCursorConfiguration* conf;
    125     MirBufferStream*        customCursor;
    126     char const*             cursorName; // only needed for system cursors
    127 } _GLFWcursorMir;
    128 
    129 
    130 extern void _glfwPollMonitorsMir(void);
    131 extern void _glfwInitEventQueueMir(EventQueue* queue);
    132 extern void _glfwDeleteEventQueueMir(EventQueue* queue);
    133