ScrapExplorer - cocoa_platform.h

Home / ext / glfw / src Lines: 1 | Size: 12920 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1//======================================================================== 2// GLFW 3.5 macOS - www.glfw.org 3//------------------------------------------------------------------------ 4// Copyright (c) 2009-2019 Camilla Löwy <[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 27#include <stdint.h> 28 29#include <Carbon/Carbon.h> 30#include <IOKit/hid/IOHIDLib.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#ifndef GL_SILENCE_DEPRECATION 35#define GL_SILENCE_DEPRECATION 36#endif 37 38#if defined(__OBJC__) 39#import <Cocoa/Cocoa.h> 40#else 41typedef void* id; 42#endif 43 44// NOTE: Many Cocoa enum values have been renamed and we need to build across 45// SDK versions where one is unavailable or deprecated. 46// We use the newer names in code and replace them with the older names if 47// the base SDK does not provide the newer names. 48 49#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 50 #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval 51 #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity 52#endif 53 54#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 55 #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat 56 #define NSEventMaskAny NSAnyEventMask 57 #define NSEventMaskKeyUp NSKeyUpMask 58 #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask 59 #define NSEventModifierFlagCommand NSCommandKeyMask 60 #define NSEventModifierFlagControl NSControlKeyMask 61 #define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask 62 #define NSEventModifierFlagOption NSAlternateKeyMask 63 #define NSEventModifierFlagShift NSShiftKeyMask 64 #define NSEventTypeApplicationDefined NSApplicationDefined 65 #define NSWindowStyleMaskBorderless NSBorderlessWindowMask 66 #define NSWindowStyleMaskClosable NSClosableWindowMask 67 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask 68 #define NSWindowStyleMaskResizable NSResizableWindowMask 69 #define NSWindowStyleMaskTitled NSTitledWindowMask 70#endif 71 72// NOTE: Many Cocoa dynamically linked constants have been renamed and we need 73// to build across SDK versions where one is unavailable or deprecated. 74// We use the newer names in code and replace them with the older names if 75// the deployment target is older than the newer names. 76 77#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300 78 #define NSPasteboardTypeURL NSURLPboardType 79#endif 80 81typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; 82typedef VkFlags VkMetalSurfaceCreateFlagsEXT; 83 84typedef struct VkMacOSSurfaceCreateInfoMVK 85{ 86 VkStructureType sType; 87 const void* pNext; 88 VkMacOSSurfaceCreateFlagsMVK flags; 89 const void* pView; 90} VkMacOSSurfaceCreateInfoMVK; 91 92typedef struct VkMetalSurfaceCreateInfoEXT 93{ 94 VkStructureType sType; 95 const void* pNext; 96 VkMetalSurfaceCreateFlagsEXT flags; 97 const void* pLayer; 98} VkMetalSurfaceCreateInfoEXT; 99 100typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*); 101typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*); 102 103#define GLFW_COCOA_WINDOW_STATE _GLFWwindowNS ns; 104#define GLFW_COCOA_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns; 105#define GLFW_COCOA_MONITOR_STATE _GLFWmonitorNS ns; 106#define GLFW_COCOA_CURSOR_STATE _GLFWcursorNS ns; 107 108#define GLFW_NSGL_CONTEXT_STATE _GLFWcontextNSGL nsgl; 109#define GLFW_NSGL_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl; 110 111// HIToolbox.framework pointer typedefs 112#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData 113typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void); 114#define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource 115typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef); 116#define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty 117typedef UInt8 (*PFN_LMGetKbdType)(void); 118#define LMGetKbdType _glfw.ns.tis.GetKbdType 119 120 121// NSGL-specific per-context data 122// 123typedef struct _GLFWcontextNSGL 124{ 125 id pixelFormat; 126 id object; 127} _GLFWcontextNSGL; 128 129// NSGL-specific global data 130// 131typedef struct _GLFWlibraryNSGL 132{ 133 // dlopen handle for OpenGL.framework (for glfwGetProcAddress) 134 CFBundleRef framework; 135} _GLFWlibraryNSGL; 136 137// Cocoa-specific per-window data 138// 139typedef struct _GLFWwindowNS 140{ 141 id object; 142 id delegate; 143 id view; 144 id layer; 145 146 GLFWbool maximized; 147 GLFWbool occluded; 148 GLFWbool scaleFramebuffer; 149 150 // Cached window properties to filter out duplicate events 151 int width, height; 152 int fbWidth, fbHeight; 153 float xscale, yscale; 154 155 // The total sum of the distances the cursor has been warped 156 // since the last cursor motion event was processed 157 // This is kept to counteract Cocoa doing the same internally 158 double cursorWarpDeltaX, cursorWarpDeltaY; 159} _GLFWwindowNS; 160 161// Cocoa-specific global data 162// 163typedef struct _GLFWlibraryNS 164{ 165 CGEventSourceRef eventSource; 166 id delegate; 167 GLFWbool cursorHidden; 168 TISInputSourceRef inputSource; 169 IOHIDManagerRef hidManager; 170 id unicodeData; 171 id helper; 172 id keyUpMonitor; 173 id nibObjects; 174 175 char keynames[GLFW_KEY_LAST + 1][17]; 176 short int keycodes[256]; 177 short int scancodes[GLFW_KEY_LAST + 1]; 178 char* clipboardString; 179 CGPoint cascadePoint; 180 // Where to place the cursor when re-enabled 181 double restoreCursorPosX, restoreCursorPosY; 182 // The window whose disabled cursor mode is active 183 _GLFWwindow* disabledCursorWindow; 184 185 struct { 186 CFBundleRef bundle; 187 PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource; 188 PFN_TISGetInputSourceProperty GetInputSourceProperty; 189 PFN_LMGetKbdType GetKbdType; 190 CFStringRef kPropertyUnicodeKeyLayoutData; 191 } tis; 192} _GLFWlibraryNS; 193 194// Cocoa-specific per-monitor data 195// 196typedef struct _GLFWmonitorNS 197{ 198 CGDirectDisplayID displayID; 199 CGDisplayModeRef previousMode; 200 uint32_t unitNumber; 201 id screen; 202 double fallbackRefreshRate; 203} _GLFWmonitorNS; 204 205// Cocoa-specific per-cursor data 206// 207typedef struct _GLFWcursorNS 208{ 209 id object; 210} _GLFWcursorNS; 211 212 213GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform); 214int _glfwInitCocoa(void); 215void _glfwTerminateCocoa(void); 216 217GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); 218void _glfwDestroyWindowCocoa(_GLFWwindow* window); 219void _glfwSetWindowTitleCocoa(_GLFWwindow* window, const char* title); 220void _glfwSetWindowIconCocoa(_GLFWwindow* window, int count, const GLFWimage* images); 221void _glfwGetWindowPosCocoa(_GLFWwindow* window, int* xpos, int* ypos); 222void _glfwSetWindowPosCocoa(_GLFWwindow* window, int xpos, int ypos); 223void _glfwGetWindowSizeCocoa(_GLFWwindow* window, int* width, int* height); 224void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height); 225void _glfwSetWindowSizeLimitsCocoa(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); 226void _glfwSetWindowAspectRatioCocoa(_GLFWwindow* window, int numer, int denom); 227void _glfwGetFramebufferSizeCocoa(_GLFWwindow* window, int* width, int* height); 228void _glfwGetWindowFrameSizeCocoa(_GLFWwindow* window, int* left, int* top, int* right, int* bottom); 229void _glfwGetWindowContentScaleCocoa(_GLFWwindow* window, float* xscale, float* yscale); 230void _glfwIconifyWindowCocoa(_GLFWwindow* window); 231void _glfwRestoreWindowCocoa(_GLFWwindow* window); 232void _glfwMaximizeWindowCocoa(_GLFWwindow* window); 233void _glfwShowWindowCocoa(_GLFWwindow* window); 234void _glfwHideWindowCocoa(_GLFWwindow* window); 235void _glfwRequestWindowAttentionCocoa(_GLFWwindow* window); 236void _glfwFocusWindowCocoa(_GLFWwindow* window); 237void _glfwSetWindowMonitorCocoa(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); 238GLFWbool _glfwWindowFocusedCocoa(_GLFWwindow* window); 239GLFWbool _glfwWindowIconifiedCocoa(_GLFWwindow* window); 240GLFWbool _glfwWindowVisibleCocoa(_GLFWwindow* window); 241GLFWbool _glfwWindowMaximizedCocoa(_GLFWwindow* window); 242GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window); 243GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window); 244void _glfwSetWindowResizableCocoa(_GLFWwindow* window, GLFWbool enabled); 245void _glfwSetWindowDecoratedCocoa(_GLFWwindow* window, GLFWbool enabled); 246void _glfwSetWindowFloatingCocoa(_GLFWwindow* window, GLFWbool enabled); 247float _glfwGetWindowOpacityCocoa(_GLFWwindow* window); 248void _glfwSetWindowOpacityCocoa(_GLFWwindow* window, float opacity); 249void _glfwSetWindowMousePassthroughCocoa(_GLFWwindow* window, GLFWbool enabled); 250 251void _glfwSetRawMouseMotionCocoa(_GLFWwindow *window, GLFWbool enabled); 252GLFWbool _glfwRawMouseMotionSupportedCocoa(void); 253 254void _glfwPollEventsCocoa(void); 255void _glfwWaitEventsCocoa(void); 256void _glfwWaitEventsTimeoutCocoa(double timeout); 257void _glfwPostEmptyEventCocoa(void); 258 259void _glfwGetCursorPosCocoa(_GLFWwindow* window, double* xpos, double* ypos); 260void _glfwSetCursorPosCocoa(_GLFWwindow* window, double xpos, double ypos); 261void _glfwSetCursorModeCocoa(_GLFWwindow* window, int mode); 262const char* _glfwGetScancodeNameCocoa(int scancode); 263int _glfwGetKeyScancodeCocoa(int key); 264GLFWbool _glfwCreateCursorCocoa(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot); 265GLFWbool _glfwCreateStandardCursorCocoa(_GLFWcursor* cursor, int shape); 266void _glfwDestroyCursorCocoa(_GLFWcursor* cursor); 267void _glfwSetCursorCocoa(_GLFWwindow* window, _GLFWcursor* cursor); 268void _glfwSetClipboardStringCocoa(const char* string); 269const char* _glfwGetClipboardStringCocoa(void); 270 271EGLenum _glfwGetEGLPlatformCocoa(EGLint** attribs); 272EGLNativeDisplayType _glfwGetEGLNativeDisplayCocoa(void); 273EGLNativeWindowType _glfwGetEGLNativeWindowCocoa(_GLFWwindow* window); 274 275void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions); 276GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); 277VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); 278 279void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor); 280void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos); 281void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale); 282void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); 283GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count); 284GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode); 285GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp); 286void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); 287 288void _glfwPollMonitorsCocoa(void); 289void _glfwSetVideoModeCocoa(_GLFWmonitor* monitor, const GLFWvidmode* desired); 290void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor); 291 292float _glfwTransformYCocoa(float y); 293 294void* _glfwLoadLocalVulkanLoaderCocoa(void); 295 296GLFWbool _glfwInitNSGL(void); 297void _glfwTerminateNSGL(void); 298GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, 299 const _GLFWctxconfig* ctxconfig, 300 const _GLFWfbconfig* fbconfig); 301void _glfwDestroyContextNSGL(_GLFWwindow* window); 302 303
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.