cocoa_platform.h
Go to the documentation of this file.
1 //========================================================================
2 // GLFW 3.3 macOS - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
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 <stdint.h>
28 #include <dlfcn.h>
29 
30 #include <Carbon/Carbon.h>
31 #if defined(__OBJC__)
32 #import <Cocoa/Cocoa.h>
33 #else
34 typedef void* id;
35 #endif
36 
38 
40 {
42  const void* pNext;
44  const void* pView;
46 
48 
49 #include "posix_thread.h"
50 #include "cocoa_joystick.h"
51 #include "nsgl_context.h"
52 #include "egl_context.h"
53 #include "osmesa_context.h"
54 
55 #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
56 #define _glfw_dlclose(handle) dlclose(handle)
57 #define _glfw_dlsym(handle, name) dlsym(handle, name)
58 
59 #define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view)
60 #define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
61 
62 #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
63 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
64 #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns
65 #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns
66 #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns
67 
68 // HIToolbox.framework pointer typedefs
69 #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
70 typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void);
71 #define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource
72 typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef);
73 #define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty
74 typedef UInt8 (*PFN_LMGetKbdType)(void);
75 #define LMGetKbdType _glfw.ns.tis.GetKbdType
76 
77 
78 // Cocoa-specific per-window data
79 //
80 typedef struct _GLFWwindowNS
81 {
82  id object;
84  id view;
85  id layer;
86 
88 
89  // Cached window properties to filter out duplicate events
90  int width, height;
91  int fbWidth, fbHeight;
92  float xscale, yscale;
93 
94  // The total sum of the distances the cursor has been warped
95  // since the last cursor motion event was processed
96  // This is kept to counteract Cocoa doing the same internally
97  double cursorWarpDeltaX, cursorWarpDeltaY;
98 
100 
101 // Cocoa-specific global data
102 //
103 typedef struct _GLFWlibraryNS
104 {
105  CGEventSourceRef eventSource;
109  TISInputSourceRef inputSource;
110  IOHIDManagerRef hidManager;
112  id helper;
115 
116  char keyName[64];
117  short int keycodes[256];
118  short int scancodes[GLFW_KEY_LAST + 1];
120  CGPoint cascadePoint;
121  // Where to place the cursor when re-enabled
122  double restoreCursorPosX, restoreCursorPosY;
123  // The window whose disabled cursor mode is active
125 
126  struct {
127  CFBundleRef bundle;
132  } tis;
133 
135 
136 // Cocoa-specific per-monitor data
137 //
138 typedef struct _GLFWmonitorNS
139 {
140  CGDirectDisplayID displayID;
141  CGDisplayModeRef previousMode;
142  uint32_t unitNumber;
143  id screen;
144 
146 
147 // Cocoa-specific per-cursor data
148 //
149 typedef struct _GLFWcursorNS
150 {
151  id object;
152 
153 } _GLFWcursorNS;
154 
155 // Cocoa-specific global timer data
156 //
157 typedef struct _GLFWtimerNS
158 {
159  uint64_t frequency;
160 
161 } _GLFWtimerNS;
162 
163 
164 void _glfwInitTimerNS(void);
165 
166 void _glfwPollMonitorsNS(void);
167 void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
169 
void *(* PFN_TISGetInputSourceProperty)(TISInputSourceRef, CFStringRef)
CGPoint cascadePoint
void * id
uint32_t unitNumber
TISInputSourceRef(* PFN_TISCopyCurrentKeyboardLayoutInputSource)(void)
void _glfwInitTimerNS(void)
Definition: cocoa_time.c:38
PFN_LMGetKbdType GetKbdType
struct _GLFWlibraryNS _GLFWlibraryNS
void _glfwRestoreVideoModeNS(_GLFWmonitor *monitor)
uint64_t frequency
IOHIDManagerRef hidManager
struct _GLFWtimerNS _GLFWtimerNS
GLFWbool cursorHidden
CGDisplayModeRef previousMode
int GLFWbool
Definition: internal.h:62
PFN_TISGetInputSourceProperty GetInputSourceProperty
double cursorWarpDeltaY
void * VkInstance
Definition: internal.h:119
VkMacOSSurfaceCreateFlagsMVK flags
struct _GLFWmonitorNS _GLFWmonitorNS
CGDirectDisplayID displayID
TISInputSourceRef inputSource
uint64_t VkSurfaceKHR
Definition: internal.h:121
CFStringRef kPropertyUnicodeKeyLayoutData
UInt8(* PFN_LMGetKbdType)(void)
CGEventSourceRef eventSource
char * clipboardString
_GLFWwindow * disabledCursorWindow
VkStructureType
Definition: internal.h:125
#define APIENTRY
Definition: glfw3.h:106
double restoreCursorPosY
VkResult(APIENTRY * PFN_vkCreateMacOSSurfaceMVK)(VkInstance, const VkMacOSSurfaceCreateInfoMVK *, const VkAllocationCallbacks *, VkSurfaceKHR *)
void _glfwSetVideoModeNS(_GLFWmonitor *monitor, const GLFWvidmode *desired)
PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource
typedef void(GLAD_API_PTR *GLDEBUGPROC)(GLenum source
#define GLFW_KEY_LAST
Definition: glfw3.h:483
struct VkAllocationCallbacks VkAllocationCallbacks
Definition: internal.h:163
Video mode type.
Definition: glfw3.h:1525
struct _GLFWcursorNS _GLFWcursorNS
void _glfwPollMonitorsNS(void)
struct _GLFWwindowNS _GLFWwindowNS
CFBundleRef bundle
VkFlags VkMacOSSurfaceCreateFlagsMVK
uint32_t VkFlags
Definition: internal.h:122
struct VkMacOSSurfaceCreateInfoMVK VkMacOSSurfaceCreateInfoMVK
GLFWbool maximized
VkResult
Definition: internal.h:135


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:19