mir_platform.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //========================================================================
  2. // GLFW 3.3 Mir - www.glfw.org
  3. //------------------------------------------------------------------------
  4. // Copyright (c) 2014-2017 Brandon Schaefer <[email protected]>
  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. #include <sys/queue.h>
  27. #include <pthread.h>
  28. #include <dlfcn.h>
  29. #include <mir_toolkit/mir_client_library.h>
  30. typedef VkFlags VkMirWindowCreateFlagsKHR;
  31. typedef struct VkMirWindowCreateInfoKHR
  32. {
  33. VkStructureType sType;
  34. const void* pNext;
  35. VkMirWindowCreateFlagsKHR flags;
  36. MirConnection* connection;
  37. MirWindow* mirWindow;
  38. } VkMirWindowCreateInfoKHR;
  39. typedef VkResult (APIENTRY *PFN_vkCreateMirWindowKHR)(VkInstance,const VkMirWindowCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
  40. typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice,uint32_t,MirConnection*);
  41. #include "posix_thread.h"
  42. #include "posix_time.h"
  43. #include "linux_joystick.h"
  44. #include "xkb_unicode.h"
  45. #include "egl_context.h"
  46. #include "osmesa_context.h"
  47. #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
  48. #define _glfw_dlclose(handle) dlclose(handle)
  49. #define _glfw_dlsym(handle, name) dlsym(handle, name)
  50. #define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->mir.nativeWindow)
  51. #define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.mir.display)
  52. #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowMir mir
  53. #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorMir mir
  54. #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryMir mir
  55. #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorMir mir
  56. #define _GLFW_PLATFORM_CONTEXT_STATE
  57. #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
  58. // Mir-specific Event Queue
  59. //
  60. typedef struct EventQueue
  61. {
  62. TAILQ_HEAD(, EventNode) head;
  63. } EventQueue;
  64. // Mir-specific per-window data
  65. //
  66. typedef struct _GLFWwindowMir
  67. {
  68. MirWindow* window;
  69. int width;
  70. int height;
  71. MirEGLNativeWindowType nativeWindow;
  72. _GLFWcursor* currentCursor;
  73. } _GLFWwindowMir;
  74. // Mir-specific per-monitor data
  75. //
  76. typedef struct _GLFWmonitorMir
  77. {
  78. int curMode;
  79. int outputId;
  80. int x;
  81. int y;
  82. } _GLFWmonitorMir;
  83. // Mir-specific global data
  84. //
  85. typedef struct _GLFWlibraryMir
  86. {
  87. MirConnection* connection;
  88. MirEGLNativeDisplayType display;
  89. EventQueue* eventQueue;
  90. short int keycodes[256];
  91. short int scancodes[GLFW_KEY_LAST + 1];
  92. pthread_mutex_t eventMutex;
  93. pthread_cond_t eventCond;
  94. // The window whose disabled cursor mode is active
  95. _GLFWwindow* disabledCursorWindow;
  96. } _GLFWlibraryMir;
  97. // Mir-specific per-cursor data
  98. // TODO: Only system cursors are implemented in Mir atm. Need to wait for support.
  99. //
  100. typedef struct _GLFWcursorMir
  101. {
  102. MirCursorConfiguration* conf;
  103. MirBufferStream* customCursor;
  104. char const* cursorName; // only needed for system cursors
  105. } _GLFWcursorMir;
  106. extern void _glfwPollMonitorsMir(void);
  107. extern void _glfwInitEventQueueMir(EventQueue* queue);
  108. extern void _glfwDeleteEventQueueMir(EventQueue* queue);