Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
cocoa_platform.h
Go to the documentation of this file.
1//========================================================================
2// GLFW 3.4 macOS - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2019 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
32// NOTE: All of NSGL was deprecated in the 10.14 SDK
33// This disables the pointless warnings for every symbol we use
34#define GL_SILENCE_DEPRECATION
35
36#if defined(__OBJC__)
37#import <Cocoa/Cocoa.h>
38#else
39typedef void* id;
40#endif
41
42// NOTE: Many Cocoa enum values have been renamed and we need to build across
43// SDK versions where one is unavailable or the other deprecated
44// We use the newer names in code and these macros to handle compatibility
45#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
46 #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
47 #define NSEventMaskAny NSAnyEventMask
48 #define NSEventMaskKeyUp NSKeyUpMask
49 #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
50 #define NSEventModifierFlagCommand NSCommandKeyMask
51 #define NSEventModifierFlagControl NSControlKeyMask
52 #define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
53 #define NSEventModifierFlagOption NSAlternateKeyMask
54 #define NSEventModifierFlagShift NSShiftKeyMask
55 #define NSEventTypeApplicationDefined NSApplicationDefined
56 #define NSWindowStyleMaskBorderless NSBorderlessWindowMask
57 #define NSWindowStyleMaskClosable NSClosableWindowMask
58 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
59 #define NSWindowStyleMaskResizable NSResizableWindowMask
60 #define NSWindowStyleMaskTitled NSTitledWindowMask
61#endif
62
65
67{
69 const void* pNext;
71 const void* pView;
73
75{
77 const void* pNext;
79 const void* pLayer;
81
84
85#include "posix_thread.h"
86#include "cocoa_joystick.h"
87#include "nsgl_context.h"
88
89#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
90#define _glfw_dlclose(handle) dlclose(handle)
91#define _glfw_dlsym(handle, name) dlsym(handle, name)
92
93#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
94#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
95#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns
96#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns
97#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns
98
99// HIToolbox.framework pointer typedefs
100#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
101typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void);
102#define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource
103typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef);
104#define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty
105typedef UInt8 (*PFN_LMGetKbdType)(void);
106#define LMGetKbdType _glfw.ns.tis.GetKbdType
107
108
109// Cocoa-specific per-window data
110//
111typedef struct _GLFWwindowNS
112{
117
121
122 // Cached window properties to filter out duplicate events
126
127 // The total sum of the distances the cursor has been warped
128 // since the last cursor motion event was processed
129 // This is kept to counteract Cocoa doing the same internally
131
133
134// Cocoa-specific global data
135//
136typedef struct _GLFWlibraryNS
137{
138 CGEventSourceRef eventSource;
141 TISInputSourceRef inputSource;
142 IOHIDManagerRef hidManager;
147
148 char keynames[GLFW_KEY_LAST + 1][17];
149 short int keycodes[256];
150 short int scancodes[GLFW_KEY_LAST + 1];
153 // Where to place the cursor when re-enabled
155 // The window whose disabled cursor mode is active
157
158 struct {
159 CFBundleRef bundle;
165
167
168// Cocoa-specific per-monitor data
169//
170typedef struct _GLFWmonitorNS
171{
172 CGDirectDisplayID displayID;
173 CGDisplayModeRef previousMode;
177
179
180// Cocoa-specific per-cursor data
181//
182typedef struct _GLFWcursorNS
183{
185
187
188// Cocoa-specific global timer data
189//
190typedef struct _GLFWtimerNS
191{
193
195
196
197void _glfwInitTimerNS(void);
198
199void _glfwPollMonitorsNS(void);
200void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
202
203float _glfwTransformYNS(float y);
204
206
void _glfwInitTimerNS(void)
Definition: cocoa_time.c:40
VkFlags VkMacOSSurfaceCreateFlagsMVK
void _glfwRestoreVideoModeNS(_GLFWmonitor *monitor)
float _glfwTransformYNS(float y)
Definition: cocoa_window.m:889
void * _glfwLoadLocalVulkanLoaderNS(void)
Definition: cocoa_init.m:466
void * id
TISInputSourceRef(* PFN_TISCopyCurrentKeyboardLayoutInputSource)(void)
UInt8(* PFN_LMGetKbdType)(void)
void *(* PFN_TISGetInputSourceProperty)(TISInputSourceRef, CFStringRef)
VkResult(APIENTRY * PFN_vkCreateMetalSurfaceEXT)(VkInstance, const VkMetalSurfaceCreateInfoEXT *, const VkAllocationCallbacks *, VkSurfaceKHR *)
VkFlags VkMetalSurfaceCreateFlagsEXT
VkResult(APIENTRY * PFN_vkCreateMacOSSurfaceMVK)(VkInstance, const VkMacOSSurfaceCreateInfoMVK *, const VkAllocationCallbacks *, VkSurfaceKHR *)
void _glfwSetVideoModeNS(_GLFWmonitor *monitor, const GLFWvidmode *desired)
void _glfwPollMonitorsNS(void)
#define APIENTRY
Compiler- and platform-specific preprocessor work.
Definition: glfw3.h:125
#define GLFW_KEY_LAST
Definition: glfw3.h:515
uint64_t VkSurfaceKHR
Definition: internal.h:120
void * VkInstance
Definition: internal.h:118
int GLFWbool
Definition: internal.h:61
unsigned int uint32_t
Definition: stdint.h:80
unsigned __int64 uint64_t
Definition: stdint.h:90
TISInputSourceRef inputSource
struct _GLFWlibraryNS::@15 tis
char * clipboardString
PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource
IOHIDManagerRef hidManager
CGPoint cascadePoint
CFBundleRef bundle
short int scancodes[GLFW_KEY_LAST+1]
double restoreCursorPosY
short int keycodes[256]
_GLFWwindow * disabledCursorWindow
PFN_LMGetKbdType GetKbdType
double restoreCursorPosX
char keynames[GLFW_KEY_LAST+1][17]
CFStringRef kPropertyUnicodeKeyLayoutData
PFN_TISGetInputSourceProperty GetInputSourceProperty
GLFWbool cursorHidden
CGEventSourceRef eventSource
uint32_t unitNumber
double fallbackRefreshRate
CGDirectDisplayID displayID
CGDisplayModeRef previousMode
uint64_t frequency
double cursorWarpDeltaX
double cursorWarpDeltaY
GLFWbool occluded
GLFWbool maximized
Video mode type.
Definition: glfw3.h:1792
VkMacOSSurfaceCreateFlagsMVK flags
VkMetalSurfaceCreateFlagsEXT flags
uint32_t VkFlags
Definition: vulkan.h:1688
VkResult
Definition: vulkan.h:842
VkStructureType
Definition: vulkan.h:897