• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //========================================================================
2 // GLFW 3.2 Mir - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2014-2015 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 #ifndef _glfw3_mir_platform_h_
28 #define _glfw3_mir_platform_h_
29 
30 #include <sys/queue.h>
31 #include <pthread.h>
32 #include <dlfcn.h>
33 
34 #include <mir_toolkit/mir_client_library.h>
35 
36 typedef VkFlags VkMirSurfaceCreateFlagsKHR;
37 
38 typedef struct VkMirSurfaceCreateInfoKHR
39 {
40     VkStructureType             sType;
41     const void*                 pNext;
42     VkMirSurfaceCreateFlagsKHR  flags;
43     MirConnection*              connection;
44     MirSurface*                 mirSurface;
45 } VkMirSurfaceCreateInfoKHR;
46 
47 typedef VkResult (APIENTRY *PFN_vkCreateMirSurfaceKHR)(VkInstance,const VkMirSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
48 typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice,uint32_t,MirConnection*);
49 
50 #include "posix_tls.h"
51 #include "posix_time.h"
52 #include "linux_joystick.h"
53 #include "xkb_unicode.h"
54 #include "egl_context.h"
55 
56 #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
57 #define _glfw_dlclose(handle) dlclose(handle)
58 #define _glfw_dlsym(handle, name) dlsym(handle, name)
59 
60 #define _GLFW_EGL_NATIVE_WINDOW  ((EGLNativeWindowType) window->mir.window)
61 #define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.mir.display)
62 
63 #define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowMir  mir
64 #define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorMir mir
65 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryMir mir
66 #define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorMir  mir
67 
68 #define _GLFW_PLATFORM_CONTEXT_STATE
69 #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
70 
71 
72 // Mir-specific Event Queue
73 //
74 typedef struct EventQueue
75 {
76     TAILQ_HEAD(, EventNode) head;
77 } EventQueue;
78 
79 // Mir-specific per-window data
80 //
81 typedef struct _GLFWwindowMir
82 {
83     MirSurface*             surface;
84     int                     width;
85     int                     height;
86     MirEGLNativeWindowType  window;
87 
88 } _GLFWwindowMir;
89 
90 // Mir-specific per-monitor data
91 //
92 typedef struct _GLFWmonitorMir
93 {
94     int cur_mode;
95     int output_id;
96     int x;
97     int y;
98 
99 } _GLFWmonitorMir;
100 
101 // Mir-specific global data
102 //
103 typedef struct _GLFWlibraryMir
104 {
105     MirConnection*          connection;
106     MirEGLNativeDisplayType display;
107     MirCursorConfiguration* default_conf;
108     EventQueue* event_queue;
109 
110     short int       publicKeys[256];
111 
112     pthread_mutex_t event_mutex;
113     pthread_cond_t  event_cond;
114 
115 } _GLFWlibraryMir;
116 
117 // Mir-specific per-cursor data
118 // TODO: Only system cursors are implemented in Mir atm. Need to wait for support.
119 //
120 typedef struct _GLFWcursorMir
121 {
122     MirCursorConfiguration* conf;
123     MirBufferStream*        custom_cursor;
124 } _GLFWcursorMir;
125 
126 
127 extern void _glfwInitEventQueueMir(EventQueue* queue);
128 extern void _glfwDeleteEventQueueMir(EventQueue* queue);
129 
130 #endif // _glfw3_mir_platform_h_
131