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;
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
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
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 
posix_thread.h
_glfwRestoreVideoModeNS
void _glfwRestoreVideoModeNS(_GLFWmonitor *monitor)
VkSurfaceKHR
uint64_t VkSurfaceKHR
Definition: internal.h:121
_GLFWtimerNS::frequency
uint64_t frequency
Definition: cocoa_platform.h:159
_GLFWlibraryNS::unicodeData
id unicodeData
Definition: cocoa_platform.h:111
_GLFWlibraryNS::bundle
CFBundleRef bundle
Definition: cocoa_platform.h:127
_GLFWwindowNS
Definition: cocoa_platform.h:80
_GLFWlibraryNS
Definition: cocoa_platform.h:103
cocoa_joystick.h
_GLFWwindowNS::layer
id layer
Definition: cocoa_platform.h:85
_GLFWlibraryNS::restoreCursorPosX
double restoreCursorPosX
Definition: cocoa_platform.h:122
_GLFWwindowNS::yscale
float yscale
Definition: cocoa_platform.h:92
VkMacOSSurfaceCreateInfoMVK::sType
VkStructureType sType
Definition: cocoa_platform.h:41
PFN_TISGetInputSourceProperty
void *(* PFN_TISGetInputSourceProperty)(TISInputSourceRef, CFStringRef)
Definition: cocoa_platform.h:72
_glfwInitTimerNS
void _glfwInitTimerNS(void)
Definition: cocoa_time.c:38
osmesa_context.h
VkMacOSSurfaceCreateInfoMVK::pNext
const void * pNext
Definition: cocoa_platform.h:42
_GLFWmonitorNS::displayID
CGDirectDisplayID displayID
Definition: cocoa_platform.h:140
_GLFWwindowNS::fbWidth
int fbWidth
Definition: cocoa_platform.h:91
_GLFWmonitorNS::unitNumber
uint32_t unitNumber
Definition: cocoa_platform.h:142
VkInstance
void * VkInstance
Definition: internal.h:119
VkMacOSSurfaceCreateInfoMVK
Definition: cocoa_platform.h:39
_GLFWlibraryNS::restoreCursorPosY
double restoreCursorPosY
Definition: cocoa_platform.h:122
_GLFWwindowNS::height
int height
Definition: cocoa_platform.h:90
_GLFWmonitorNS::previousMode
CGDisplayModeRef previousMode
Definition: cocoa_platform.h:141
VkMacOSSurfaceCreateFlagsMVK
VkFlags VkMacOSSurfaceCreateFlagsMVK
Definition: cocoa_platform.h:37
_GLFWcursorNS::object
id object
Definition: cocoa_platform.h:151
_GLFWlibraryNS::eventSource
CGEventSourceRef eventSource
Definition: cocoa_platform.h:105
_GLFWlibraryNS::keyName
char keyName[64]
Definition: cocoa_platform.h:116
id
void * id
Definition: cocoa_platform.h:34
_GLFWlibraryNS::nibObjects
id nibObjects
Definition: cocoa_platform.h:114
_GLFWlibraryNS::disabledCursorWindow
_GLFWwindow * disabledCursorWindow
Definition: cocoa_platform.h:124
_GLFWlibraryNS::delegate
id delegate
Definition: cocoa_platform.h:106
GLFW_KEY_LAST
#define GLFW_KEY_LAST
Definition: glfw3.h:483
_GLFWwindow
Definition: internal.h:366
_GLFWwindowNS::cursorWarpDeltaX
double cursorWarpDeltaX
Definition: cocoa_platform.h:97
void
typedef void(GLAD_API_PTR *GLDEBUGPROC)(GLenum source
VkMacOSSurfaceCreateInfoMVK::pView
const void * pView
Definition: cocoa_platform.h:44
_GLFWlibraryNS::cascadePoint
CGPoint cascadePoint
Definition: cocoa_platform.h:120
APIENTRY
#define APIENTRY
Definition: glfw3.h:106
_GLFWcursorNS
struct _GLFWcursorNS _GLFWcursorNS
_GLFWmonitorNS
struct _GLFWmonitorNS _GLFWmonitorNS
VkAllocationCallbacks
struct VkAllocationCallbacks VkAllocationCallbacks
Definition: internal.h:163
_glfwPollMonitorsNS
void _glfwPollMonitorsNS(void)
VkMacOSSurfaceCreateInfoMVK::flags
VkMacOSSurfaceCreateFlagsMVK flags
Definition: cocoa_platform.h:43
_GLFWlibraryNS::keyUpMonitor
id keyUpMonitor
Definition: cocoa_platform.h:113
PFN_vkCreateMacOSSurfaceMVK
VkResult(APIENTRY * PFN_vkCreateMacOSSurfaceMVK)(VkInstance, const VkMacOSSurfaceCreateInfoMVK *, const VkAllocationCallbacks *, VkSurfaceKHR *)
Definition: cocoa_platform.h:47
_GLFWwindowNS::delegate
id delegate
Definition: cocoa_platform.h:83
VkFlags
uint32_t VkFlags
Definition: internal.h:122
PFN_TISCopyCurrentKeyboardLayoutInputSource
TISInputSourceRef(* PFN_TISCopyCurrentKeyboardLayoutInputSource)(void)
Definition: cocoa_platform.h:70
egl_context.h
_GLFWlibraryNS::tis
struct _GLFWlibraryNS::@0 tis
_GLFWlibraryNS::GetInputSourceProperty
PFN_TISGetInputSourceProperty GetInputSourceProperty
Definition: cocoa_platform.h:129
nsgl_context.h
_GLFWlibraryNS::helper
id helper
Definition: cocoa_platform.h:112
_GLFWlibraryNS::scancodes
short int scancodes[GLFW_KEY_LAST+1]
Definition: cocoa_platform.h:118
PFN_LMGetKbdType
UInt8(* PFN_LMGetKbdType)(void)
Definition: cocoa_platform.h:74
_GLFWlibraryNS::keycodes
short int keycodes[256]
Definition: cocoa_platform.h:117
_GLFWwindowNS::width
int width
Definition: cocoa_platform.h:90
_GLFWwindowNS::maximized
GLFWbool maximized
Definition: cocoa_platform.h:87
_GLFWwindowNS::xscale
float xscale
Definition: cocoa_platform.h:92
_GLFWwindowNS::cursorWarpDeltaY
double cursorWarpDeltaY
Definition: cocoa_platform.h:97
_GLFWlibraryNS
struct _GLFWlibraryNS _GLFWlibraryNS
_GLFWtimerNS
Definition: cocoa_platform.h:157
_GLFWtimerNS
struct _GLFWtimerNS _GLFWtimerNS
_GLFWwindowNS::object
id object
Definition: cocoa_platform.h:82
_GLFWlibraryNS::kPropertyUnicodeKeyLayoutData
CFStringRef kPropertyUnicodeKeyLayoutData
Definition: cocoa_platform.h:131
_GLFWmonitorNS
Definition: cocoa_platform.h:138
_GLFWmonitor
Definition: internal.h:423
VkResult
VkResult
Definition: internal.h:135
_GLFWlibraryNS::CopyCurrentKeyboardLayoutInputSource
PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource
Definition: cocoa_platform.h:128
VkStructureType
VkStructureType
Definition: internal.h:125
_GLFWlibraryNS::cursorHidden
GLFWbool cursorHidden
Definition: cocoa_platform.h:108
GLFWvidmode
Video mode type.
Definition: glfw3.h:1525
GLFWbool
int GLFWbool
Definition: internal.h:62
VkMacOSSurfaceCreateInfoMVK
struct VkMacOSSurfaceCreateInfoMVK VkMacOSSurfaceCreateInfoMVK
_GLFWlibraryNS::inputSource
TISInputSourceRef inputSource
Definition: cocoa_platform.h:109
_GLFWmonitorNS::screen
id screen
Definition: cocoa_platform.h:143
_GLFWlibraryNS::autoreleasePool
id autoreleasePool
Definition: cocoa_platform.h:107
_GLFWcursorNS
Definition: cocoa_platform.h:149
_GLFWlibraryNS::clipboardString
char * clipboardString
Definition: cocoa_platform.h:119
_GLFWwindowNS
struct _GLFWwindowNS _GLFWwindowNS
_GLFWlibraryNS::GetKbdType
PFN_LMGetKbdType GetKbdType
Definition: cocoa_platform.h:130
_GLFWwindowNS::view
id view
Definition: cocoa_platform.h:84
_glfwSetVideoModeNS
void _glfwSetVideoModeNS(_GLFWmonitor *monitor, const GLFWvidmode *desired)
_GLFWwindowNS::fbHeight
int fbHeight
Definition: cocoa_platform.h:91
_GLFWlibraryNS::hidManager
IOHIDManagerRef hidManager
Definition: cocoa_platform.h:110


mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07