58 const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
59 return [window->ns.view mouse:pos inRect:[window->ns.view frame]];
66 if (!
_glfw.ns.cursorHidden)
77 if (
_glfw.ns.cursorHidden)
93 [(NSCursor*) window->cursor->ns.object set];
95 [[NSCursor arrowCursor] set];
107 _glfw.ns.disabledCursorWindow = window;
109 &
_glfw.ns.restoreCursorPosX,
110 &
_glfw.ns.restoreCursorPosY);
112 CGAssociateMouseAndMouseCursorPosition(
false);
114 else if (
_glfw.ns.disabledCursorWindow == window)
117 CGAssociateMouseAndMouseCursorPosition(
true);
119 _glfw.ns.restoreCursorPosX,
120 _glfw.ns.restoreCursorPosY);
123 if (cursorInContentArea(window))
124 updateCursorImage(window);
132 const CGRect bounds = CGDisplayBounds(window->
monitor->ns.displayID);
133 const NSRect frame = NSMakeRect(bounds.origin.x,
138 [window->ns.object setFrame:frame display:YES];
156static int translateFlags(NSUInteger flags)
176static int translateKey(
unsigned int key)
178 if (key >=
sizeof(
_glfw.ns.keycodes) /
sizeof(
_glfw.ns.keycodes[0]))
181 return _glfw.ns.keycodes[key];
186static NSUInteger translateKeyToModifierFlag(
int key)
211static const NSRange kEmptyRange = { NSNotFound, 0 };
223- (instancetype)initWithGlfwWindow:(
_GLFWwindow *)initWindow;
229- (instancetype)initWithGlfwWindow:(
_GLFWwindow *)initWindow
238- (BOOL)windowShouldClose:(
id)sender
244- (void)windowDidResize:(NSNotification *)notification
247 [window->context.nsgl.object update];
252 const int maximized = [window->ns.object isZoomed];
253 if (
window->ns.maximized != maximized)
255 window->ns.maximized = maximized;
259 const NSRect contentRect = [window->ns.view frame];
260 const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
262 if (fbRect.size.width !=
window->ns.fbWidth ||
270 if (contentRect.size.width !=
window->ns.width ||
279- (void)windowDidMove:(NSNotification *)notification
282 [window->context.nsgl.object update];
292- (void)windowDidMiniaturize:(NSNotification *)notification
300- (void)windowDidDeminiaturize:(NSNotification *)notification
308- (void)windowDidBecomeKey:(NSNotification *)notification
317- (void)windowDidResignKey:(NSNotification *)notification
325- (void)windowDidChangeOcclusionState:(NSNotification* )notification
327 if ([
window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
347- (instancetype)initWithGlfwWindow:(
_GLFWwindow *)initWindow;
353- (instancetype)initWithGlfwWindow:(
_GLFWwindow *)initWindow
360 markedText = [[NSMutableAttributedString alloc] init];
362 [
self updateTrackingAreas];
365 [
self registerForDraggedTypes:@[(__bridge NSString*) kUTTypeURL]];
373 [trackingArea release];
374 [markedText release];
380 return [window->ns.object isOpaque];
383- (BOOL)canBecomeKeyView
388- (BOOL)acceptsFirstResponder
393- (BOOL)wantsUpdateLayer
401 [window->context.nsgl.object update];
406- (void)cursorUpdate:(NSEvent *)event
408 updateCursorImage(
window);
411- (BOOL)acceptsFirstMouse:(NSEvent *)event
416- (void)mouseDown:(NSEvent *)event
421 translateFlags([event modifierFlags]));
424- (void)mouseDragged:(NSEvent *)event
426 [
self mouseMoved:event];
429- (void)mouseUp:(NSEvent *)event
434 translateFlags([event modifierFlags]));
437- (void)mouseMoved:(NSEvent *)event
441 const double dx = [event deltaX] -
window->ns.cursorWarpDeltaX;
442 const double dy = [event deltaY] -
window->ns.cursorWarpDeltaY;
450 const NSRect contentRect = [window->ns.view frame];
452 const NSPoint pos = [event locationInWindow];
457 window->ns.cursorWarpDeltaX = 0;
458 window->ns.cursorWarpDeltaY = 0;
461- (void)rightMouseDown:(NSEvent *)event
466 translateFlags([event modifierFlags]));
469- (void)rightMouseDragged:(NSEvent *)event
471 [
self mouseMoved:event];
474- (void)rightMouseUp:(NSEvent *)event
479 translateFlags([event modifierFlags]));
482- (void)otherMouseDown:(NSEvent *)event
485 (
int) [event buttonNumber],
487 translateFlags([event modifierFlags]));
490- (void)otherMouseDragged:(NSEvent *)event
492 [
self mouseMoved:event];
495- (void)otherMouseUp:(NSEvent *)event
498 (
int) [event buttonNumber],
500 translateFlags([event modifierFlags]));
503- (void)mouseExited:(NSEvent *)event
511- (void)mouseEntered:(NSEvent *)event
519- (void)viewDidChangeBackingProperties
521 const NSRect contentRect = [window->ns.view frame];
522 const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
524 if (fbRect.size.width !=
window->ns.fbWidth ||
532 const float xscale = fbRect.size.width / contentRect.size.width;
533 const float yscale = fbRect.size.height / contentRect.size.height;
535 if (xscale !=
window->ns.xscale || yscale !=
window->ns.yscale)
537 window->ns.xscale = xscale;
538 window->ns.yscale = yscale;
542 [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
546- (void)drawRect:(NSRect)rect
551- (void)updateTrackingAreas
555 [
self removeTrackingArea:trackingArea];
556 [trackingArea release];
559 const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
560 NSTrackingActiveInKeyWindow |
561 NSTrackingEnabledDuringMouseDrag |
562 NSTrackingCursorUpdate |
563 NSTrackingInVisibleRect |
564 NSTrackingAssumeInside;
566 trackingArea = [[NSTrackingArea alloc] initWithRect:[
self bounds]
571 [
self addTrackingArea:trackingArea];
572 [
super updateTrackingAreas];
575- (void)keyDown:(NSEvent *)event
577 const int key = translateKey([event keyCode]);
578 const int mods = translateFlags([event modifierFlags]);
582 [
self interpretKeyEvents:@[event]];
585- (void)flagsChanged:(NSEvent *)event
588 const unsigned int modifierFlags =
590 const int key = translateKey([event keyCode]);
591 const int mods = translateFlags(modifierFlags);
592 const NSUInteger keyFlag = translateKeyToModifierFlag(key);
594 if (keyFlag & modifierFlags)
607- (void)keyUp:(NSEvent *)event
609 const int key = translateKey([event keyCode]);
610 const int mods = translateFlags([event modifierFlags]);
614- (void)scrollWheel:(NSEvent *)event
616 double deltaX = [event scrollingDeltaX];
617 double deltaY = [event scrollingDeltaY];
619 if ([event hasPreciseScrollingDeltas])
625 if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
629- (NSDragOperation)draggingEntered:(
id <NSDraggingInfo>)sender
633 return NSDragOperationGeneric;
636- (BOOL)performDragOperation:(
id <NSDraggingInfo>)sender
638 const NSRect contentRect = [window->ns.view frame];
640 const NSPoint pos = [sender draggingLocation];
643 NSPasteboard* pasteboard = [sender draggingPasteboard];
644 NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES};
645 NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]]
647 const NSUInteger count = [urls count];
650 char** paths = calloc(count,
sizeof(
char*));
652 for (NSUInteger i = 0; i < count; i++)
653 paths[i] =
_glfw_strdup([urls[i] fileSystemRepresentation]);
657 for (NSUInteger i = 0; i < count; i++)
667 return [markedText length] > 0;
670- (NSRange)markedRange
673 return NSMakeRange(0, [
markedText length] - 1);
678- (NSRange)selectedRange
683- (void)setMarkedText:(
id)string
684 selectedRange:(NSRange)selectedRange
685 replacementRange:(NSRange)replacementRange
687 [markedText release];
688 if ([
string isKindOfClass:[NSAttributedString
class]])
689 markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string];
691 markedText = [[NSMutableAttributedString alloc] initWithString:string];
696 [[markedText mutableString] setString:@""];
699- (NSArray*)validAttributesForMarkedText
701 return [NSArray array];
704- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range
705 actualRange:(NSRangePointer)actualRange
710- (NSUInteger)characterIndexForPoint:(NSPoint)point
715- (NSRect)firstRectForCharacterRange:(NSRange)range
716 actualRange:(NSRangePointer)actualRange
718 const NSRect frame = [window->ns.view frame];
719 return NSMakeRect(frame.origin.x, frame.origin.y, 0.0, 0.0);
722- (void)insertText:(
id)string replacementRange:(NSRange)replacementRange
724 NSString* characters;
725 NSEvent*
event = [NSApp currentEvent];
726 const int mods = translateFlags([event modifierFlags]);
729 if ([
string isKindOfClass:[NSAttributedString
class]])
730 characters = [string string];
732 characters = (NSString*)
string;
734 NSRange range = NSMakeRange(0, [characters length]);
739 if ([characters getBytes:&codepoint
740 maxLength:
sizeof(codepoint)
742 encoding:NSUTF32StringEncoding
745 remainingRange:&range])
747 if (codepoint >= 0xf700 && codepoint <= 0xf7ff)
755- (void)doCommandBySelector:(
SEL)selector
771- (BOOL)canBecomeKeyWindow
777- (BOOL)canBecomeMainWindow
792 if (window->ns.delegate == nil)
795 "Cocoa: Failed to create window delegate");
809 contentRect = NSMakeRect(xpos, ypos, mode.
width, mode.
height);
812 contentRect = NSMakeRect(0, 0, wndconfig->
width, wndconfig->
height);
815 initWithContentRect:contentRect
816 styleMask:getStyleMask(window)
817 backing:NSBackingStoreBuffered
820 if (window->ns.object == nil)
827 [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
830 [(NSWindow*) window->ns.object center];
831 _glfw.ns.cascadePoint =
832 NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
833 NSPointFromCGPoint(
_glfw.ns.cascadePoint)]);
837 const NSWindowCollectionBehavior behavior =
838 NSWindowCollectionBehaviorFullScreenPrimary |
839 NSWindowCollectionBehaviorManaged;
840 [window->ns.object setCollectionBehavior:behavior];
844 [window->ns.object setLevel:NSFloatingWindowLevel];
847 [window->ns.object zoom:nil];
851 [window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)];
854 window->ns.retina = wndconfig->
ns.
retina;
858 [window->ns.object setOpaque:NO];
859 [window->ns.object setHasShadow:NO];
860 [window->ns.object setBackgroundColor:[NSColor clearColor]];
863 [window->ns.object setContentView:window->ns.view];
864 [window->ns.object makeFirstResponder:window->ns.view];
865 [window->ns.object setTitle:@(wndconfig->title)];
866 [window->ns.object setDelegate:window->ns.delegate];
867 [window->ns.object setAcceptsMouseMovedEvents:YES];
868 [window->ns.object setRestorable:NO];
870#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
871 if ([window->ns.object respondsToSelector:
@selector(setTabbingMode:)])
872 [window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed];
890 return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
905 if (!createNativeWindow(window, wndconfig, fbconfig))
921 [window->ns.view setWantsLayer:YES];
922 window->ns.layer = [window->ns.view layer];
942 acquireMonitor(window);
954 if (
_glfw.ns.disabledCursorWindow == window)
957 [window->ns.object orderOut:nil];
960 releaseMonitor(window);
965 [window->ns.object setDelegate:nil];
966 [window->ns.delegate release];
967 window->ns.delegate = nil;
969 [window->ns.view release];
970 window->ns.view = nil;
972 [window->ns.object
close];
973 window->ns.object = nil;
984 NSString*
string = @(title);
985 [window->ns.object setTitle:string];
988 [window->ns.object setMiniwindowTitle:string];
996 "Cocoa: Regular windows do not have icons on macOS");
1003 const NSRect contentRect =
1004 [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
1007 *xpos = contentRect.origin.x;
1018 const NSRect contentRect = [window->ns.view frame];
1019 const NSRect dummyRect = NSMakeRect(x,
_glfwTransformYNS(y + contentRect.size.height - 1), 0, 0);
1020 const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
1021 [window->ns.object setFrameOrigin:frameRect.origin];
1030 const NSRect contentRect = [window->ns.view frame];
1033 *width = contentRect.size.width;
1035 *height = contentRect.size.height;
1047 acquireMonitor(window);
1051 NSRect contentRect =
1052 [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
1053 contentRect.origin.y += contentRect.size.height - height;
1054 contentRect.size = NSMakeSize(width, height);
1055 [window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect]
1063 int minwidth,
int minheight,
1064 int maxwidth,
int maxheight)
1069 [window->ns.object setContentMinSize:NSMakeSize(0, 0)];
1071 [window->ns.object setContentMinSize:NSMakeSize(minwidth, minheight)];
1074 [window->ns.object setContentMaxSize:NSMakeSize(DBL_MAX, DBL_MAX)];
1076 [window->ns.object setContentMaxSize:NSMakeSize(maxwidth, maxheight)];
1085 [window->ns.object setResizeIncrements:NSMakeSize(1.0, 1.0)];
1087 [window->ns.object setContentAspectRatio:NSMakeSize(numer, denom)];
1095 const NSRect contentRect = [window->ns.view frame];
1096 const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
1099 *width = (int) fbRect.size.width;
1101 *height = (int) fbRect.size.height;
1107 int* left,
int* top,
1108 int* right,
int* bottom)
1112 const NSRect contentRect = [window->ns.view frame];
1113 const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect];
1116 *left = contentRect.origin.x - frameRect.origin.x;
1118 *top = frameRect.origin.y + frameRect.size.height -
1119 contentRect.origin.y - contentRect.size.height;
1121 *right = frameRect.origin.x + frameRect.size.width -
1122 contentRect.origin.x - contentRect.size.width;
1124 *bottom = contentRect.origin.y - frameRect.origin.y;
1130 float* xscale,
float* yscale)
1134 const NSRect points = [window->ns.view frame];
1135 const NSRect pixels = [window->ns.view convertRectToBacking:points];
1138 *xscale = (float) (pixels.size.width / points.size.width);
1140 *yscale = (float) (pixels.size.height / points.size.height);
1148 [window->ns.object miniaturize:nil];
1155 if ([window->ns.object isMiniaturized])
1156 [window->ns.object deminiaturize:nil];
1157 else if ([window->ns.object isZoomed])
1158 [window->ns.object zoom:nil];
1165 if (![window->ns.object isZoomed])
1166 [window->ns.object zoom:nil];
1173 [window->ns.object orderFront:nil];
1180 [window->ns.object orderOut:nil];
1187 [NSApp requestUserAttention:NSInformationalRequest];
1198 [NSApp activateIgnoringOtherApps:YES];
1199 [window->ns.object makeKeyAndOrderFront:nil];
1206 int width,
int height,
1211 if (window->
monitor == monitor)
1215 if (monitor->
window == window)
1216 acquireMonitor(window);
1220 const NSRect contentRect =
1222 const NSRect frameRect =
1223 [window->ns.object frameRectForContentRect:contentRect
1224 styleMask:getStyleMask(window)];
1226 [window->ns.object setFrame:frameRect display:YES];
1233 releaseMonitor(window);
1241 const NSUInteger styleMask = getStyleMask(window);
1242 [window->ns.object setStyleMask:styleMask];
1244 [window->ns.object makeFirstResponder:window->ns.view];
1248 [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
1249 [window->ns.object setHasShadow:NO];
1251 acquireMonitor(window);
1257 NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
1258 styleMask:styleMask];
1259 [window->ns.object setFrame:frameRect display:YES];
1264 [window->ns.object setContentAspectRatio:NSMakeSize(window->numer,
1271 [window->ns.object setContentMinSize:NSMakeSize(window->minwidth,
1272 window->minheight)];
1278 [window->ns.object setContentMaxSize:NSMakeSize(window->maxwidth,
1279 window->maxheight)];
1283 [window->ns.object setLevel:NSFloatingWindowLevel];
1285 [window->ns.object setLevel:NSNormalWindowLevel];
1287 [window->ns.object setHasShadow:YES];
1290 [window->ns.object setTitle:[window->ns.object miniwindowTitle]];
1299 return [window->ns.object isKeyWindow];
1306 return [window->ns.object isMiniaturized];
1313 return [window->ns.object isVisible];
1320 return [window->ns.object isZoomed];
1328 const NSPoint point = [NSEvent mouseLocation];
1330 if ([NSWindow windowNumberAtPoint:point belowWindowWithWindowNumber:0] !=
1331 [window->ns.object windowNumber])
1336 return NSMouseInRect(point,
1337 [window->ns.object convertRectToScreen:[window->ns.view frame]], NO);
1345 return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
1352 [window->ns.object setStyleMask:getStyleMask(window)];
1359 [window->ns.object setStyleMask:getStyleMask(window)];
1360 [window->ns.object makeFirstResponder:window->ns.view];
1368 [window->ns.object setLevel:NSFloatingWindowLevel];
1370 [window->ns.object setLevel:NSNormalWindowLevel];
1377 [window->ns.object setIgnoresMouseEvents:enabled];
1384 return (
float) [window->ns.object alphaValue];
1391 [window->ns.object setAlphaValue:opacity];
1398 "Cocoa: Raw mouse motion not yet implemented");
1412 NSEvent*
event = [NSApp nextEventMatchingMask:NSEventMaskAny
1413 untilDate:[NSDate distantPast]
1414 inMode:NSDefaultRunLoopMode
1419 [NSApp sendEvent:event];
1432 NSEvent *
event = [NSApp nextEventMatchingMask:NSEventMaskAny
1433 untilDate:[NSDate distantFuture]
1434 inMode:NSDefaultRunLoopMode
1436 [NSApp sendEvent:event];
1447 NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
1448 NSEvent*
event = [NSApp nextEventMatchingMask:NSEventMaskAny
1450 inMode:NSDefaultRunLoopMode
1453 [NSApp sendEvent:event];
1464 NSEvent*
event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
1465 location:NSMakePoint(0, 0)
1473 [NSApp postEvent:event atStart:YES];
1482 const NSRect contentRect = [window->ns.view frame];
1484 const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
1489 *ypos = contentRect.size.height - pos.y;
1498 updateCursorImage(window);
1500 const NSRect contentRect = [window->ns.view frame];
1502 const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
1504 window->ns.cursorWarpDeltaX += x - pos.x;
1505 window->ns.cursorWarpDeltaY += y - contentRect.
size.height + pos.y;
1509 CGDisplayMoveCursorToPoint(window->
monitor->ns.displayID,
1514 const NSRect localRect = NSMakeRect(x, contentRect.size.height - y - 1, 0, 0);
1515 const NSRect globalRect = [window->ns.object convertRectToScreen:localRect];
1516 const NSPoint globalPoint = globalRect.origin;
1518 CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
1529 updateCursorMode(window);
1537 if (scancode < 0 || scancode > 0xff ||
1544 const int key =
_glfw.ns.keycodes[scancode];
1546 UInt32 deadKeyState = 0;
1547 UniChar characters[4];
1548 UniCharCount characterCount = 0;
1550 if (UCKeyTranslate([(NSData*)
_glfw.ns.unicodeData bytes],
1552 kUCKeyActionDisplay,
1555 kUCKeyTranslateNoDeadKeysBit,
1557 sizeof(characters) /
sizeof(characters[0]),
1559 characters) != noErr)
1564 if (!characterCount)
1567 CFStringRef
string = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
1571 CFStringGetCString(
string,
1572 _glfw.ns.keynames[key],
1573 sizeof(
_glfw.ns.keynames[key]),
1574 kCFStringEncodingUTF8);
1577 return _glfw.ns.keynames[key];
1584 return _glfw.ns.scancodes[key];
1594 NSBitmapImageRep* rep;
1596 rep = [[NSBitmapImageRep alloc]
1597 initWithBitmapDataPlanes:NULL
1598 pixelsWide:image->width
1599 pixelsHigh:image->height
1604 colorSpaceName:NSCalibratedRGBColorSpace
1605 bitmapFormat:NSBitmapFormatAlphaNonpremultiplied
1606 bytesPerRow:image->width * 4
1614 native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)];
1615 [native addRepresentation:rep];
1617 cursor->ns.object = [[NSCursor alloc] initWithImage:native
1618 hotSpot:NSMakePoint(xhot, yhot)];
1623 if (cursor->ns.object == nil)
1635 SEL cursorSelector =
NULL;
1641 cursorSelector = NSSelectorFromString(
@"_windowResizeEastWestCursor");
1644 cursorSelector = NSSelectorFromString(
@"_windowResizeNorthSouthCursor");
1647 cursorSelector = NSSelectorFromString(
@"_windowResizeNorthWestSouthEastCursor");
1650 cursorSelector = NSSelectorFromString(
@"_windowResizeNorthEastSouthWestCursor");
1654 if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
1656 id object = [NSCursor performSelector:cursorSelector];
1657 if ([
object isKindOfClass:[NSCursor
class]])
1658 cursor->ns.object = object;
1661 if (!cursor->ns.object)
1666 cursor->ns.object = [NSCursor arrowCursor];
1669 cursor->ns.object = [NSCursor IBeamCursor];
1672 cursor->ns.object = [NSCursor crosshairCursor];
1675 cursor->ns.object = [NSCursor pointingHandCursor];
1678 cursor->ns.object = [NSCursor resizeLeftRightCursor];
1681 cursor->ns.object = [NSCursor resizeUpDownCursor];
1684 cursor->ns.object = [NSCursor closedHandCursor];
1687 cursor->ns.object = [NSCursor operationNotAllowedCursor];
1692 if (!cursor->ns.object)
1695 "Cocoa: Standard cursor shape unavailable");
1699 [cursor->ns.object retain];
1708 if (cursor->ns.object)
1709 [(NSCursor*) cursor->ns.object release];
1716 if (cursorInContentArea(window))
1717 updateCursorImage(window);
1724 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
1725 [pasteboard declareTypes:@[NSPasteboardTypeString] owner:nil];
1726 [pasteboard setString:@(string) forType:NSPasteboardTypeString];
1734 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
1736 if (![[pasteboard types] containsObject:NSPasteboardTypeString])
1739 "Cocoa: Failed to retrieve string from pasteboard");
1743 NSString*
object = [pasteboard stringForType:NSPasteboardTypeString];
1747 "Cocoa: Failed to retrieve object from pasteboard");
1751 free(
_glfw.ns.clipboardString);
1754 return _glfw.ns.clipboardString;
1779 *attribs = calloc(3,
sizeof(
EGLint));
1781 (*attribs)[1] = type;
1797 return window->ns.layer;
1804 extensions[0] =
"VK_KHR_surface";
1805 extensions[1] =
"VK_EXT_metal_surface";
1809 extensions[0] =
"VK_KHR_surface";
1810 extensions[1] =
"VK_MVK_macos_surface";
1828#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
1831 NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
1835 "Cocoa: Failed to find QuartzCore.framework");
1840 window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer];
1841 if (!window->ns.layer)
1844 "Cocoa: Failed to create layer for view");
1848 if (window->ns.retina)
1849 [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
1851 [window->ns.view setLayer:window->ns.layer];
1852 [window->ns.view setWantsLayer:YES];
1856 if (
_glfw.
vk.EXT_metal_surface)
1863 if (!vkCreateMetalSurfaceEXT)
1866 "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension");
1870 memset(&sci, 0,
sizeof(sci));
1872 sci.
pLayer = window->ns.layer;
1874 err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface);
1883 if (!vkCreateMacOSSurfaceMVK)
1886 "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension");
1890 memset(&sci, 0,
sizeof(sci));
1892 sci.
pView = window->ns.view;
1894 err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface);
1900 "Cocoa: Failed to create Vulkan surface: %s",
1921 return window->ns.object;
void _glfwRestoreVideoModeNS(_GLFWmonitor *monitor)
void _glfwPlatformGetVideoMode(_GLFWmonitor *monitor, GLFWvidmode *mode)
void _glfwSetVideoModeNS(_GLFWmonitor *monitor, const GLFWvidmode *desired)
void _glfwPlatformGetMonitorPos(_GLFWmonitor *monitor, int *xpos, int *ypos)
void _glfwPlatformSetWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor, int xpos, int ypos, int width, int height, int refreshRate)
void _glfwPlatformGetWindowContentScale(_GLFWwindow *window, float *xscale, float *yscale)
void _glfwPlatformSetCursorPos(_GLFWwindow *window, double x, double y)
void _glfwPlatformSetWindowResizable(_GLFWwindow *window, GLFWbool enabled)
int _glfwPlatformWindowIconified(_GLFWwindow *window)
void _glfwPlatformMaximizeWindow(_GLFWwindow *window)
EGLenum _glfwPlatformGetEGLPlatform(EGLint **attribs)
void _glfwPlatformIconifyWindow(_GLFWwindow *window)
float _glfwTransformYNS(float y)
void _glfwPlatformSetWindowSize(_GLFWwindow *window, int width, int height)
void _glfwPlatformWaitEvents(void)
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow *window, int minwidth, int minheight, int maxwidth, int maxheight)
void _glfwPlatformGetRequiredInstanceExtensions(char **extensions)
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, _GLFWwindow *window, const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface)
int _glfwPlatformFramebufferTransparent(_GLFWwindow *window)
int _glfwPlatformCreateCursor(_GLFWcursor *cursor, const GLFWimage *image, int xhot, int yhot)
void _glfwPlatformPollEvents(void)
void _glfwPlatformGetFramebufferSize(_GLFWwindow *window, int *width, int *height)
int _glfwPlatformWindowVisible(_GLFWwindow *window)
void _glfwPlatformSetCursor(_GLFWwindow *window, _GLFWcursor *cursor)
void _glfwPlatformGetWindowSize(_GLFWwindow *window, int *width, int *height)
void _glfwPlatformSetWindowPos(_GLFWwindow *window, int x, int y)
void _glfwPlatformGetWindowFrameSize(_GLFWwindow *window, int *left, int *top, int *right, int *bottom)
void _glfwPlatformSetWindowIcon(_GLFWwindow *window, int count, const GLFWimage *images)
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow *window)
const char * _glfwPlatformGetScancodeName(int scancode)
void _glfwPlatformSetWindowDecorated(_GLFWwindow *window, GLFWbool enabled)
void _glfwPlatformGetWindowPos(_GLFWwindow *window, int *xpos, int *ypos)
void _glfwPlatformSetWindowOpacity(_GLFWwindow *window, float opacity)
float _glfwPlatformGetWindowOpacity(_GLFWwindow *window)
void _glfwPlatformDestroyCursor(_GLFWcursor *cursor)
void _glfwPlatformRestoreWindow(_GLFWwindow *window)
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
void _glfwPlatformSetCursorMode(_GLFWwindow *window, int mode)
int _glfwPlatformWindowHovered(_GLFWwindow *window)
void _glfwPlatformDestroyWindow(_GLFWwindow *window)
void _glfwPlatformWaitEventsTimeout(double timeout)
void _glfwPlatformHideWindow(_GLFWwindow *window)
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily)
int _glfwPlatformWindowMaximized(_GLFWwindow *window)
void _glfwPlatformSetClipboardString(const char *string)
void _glfwPlatformShowWindow(_GLFWwindow *window)
GLFWAPI id glfwGetCocoaWindow(GLFWwindow *handle)
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
int _glfwPlatformWindowFocused(_GLFWwindow *window)
void _glfwPlatformPostEmptyEvent(void)
int _glfwPlatformGetKeyScancode(int key)
int _glfwPlatformCreateStandardCursor(_GLFWcursor *cursor, int shape)
int _glfwPlatformCreateWindow(_GLFWwindow *window, const _GLFWwndconfig *wndconfig, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow *window, int numer, int denom)
const char * _glfwPlatformGetClipboardString(void)
void _glfwPlatformGetCursorPos(_GLFWwindow *window, double *xpos, double *ypos)
void _glfwPlatformRequestWindowAttention(_GLFWwindow *window)
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
void _glfwPlatformSetWindowTitle(_GLFWwindow *window, const char *title)
void _glfwPlatformFocusWindow(_GLFWwindow *window)
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow *window, GLFWbool enabled)
void _glfwPlatformSetWindowFloating(_GLFWwindow *window, GLFWbool enabled)
GLFWbool _glfwInitEGL(void)
GLFWbool _glfwCreateContextEGL(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
#define EGL_DEFAULT_DISPLAY
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE
void * EGLNativeDisplayType
void * EGLNativeWindowType
#define EGL_PLATFORM_ANGLE_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE
#define GLFW_EGL_CONTEXT_API
#define GLFW_NATIVE_CONTEXT_API
#define GLFW_CURSOR_DISABLED
#define GLFW_ANGLE_PLATFORM_TYPE_METAL
#define GLFW_CURSOR_HIDDEN
#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL
#define GLFW_CURSOR_NORMAL
#define GLFW_OSMESA_CONTEXT_API
#define GLFW_CURSOR_UNAVAILABLE
The specified cursor shape is not available.
#define GLFW_FORMAT_UNAVAILABLE
The requested format is not supported or available.
#define GLFW_FEATURE_UNAVAILABLE
The requested feature is not provided by the platform.
#define GLFW_API_UNAVAILABLE
GLFW could not find support for the requested API on the system.
#define GLFW_FEATURE_UNIMPLEMENTED
The requested feature is not implemented for the platform.
#define GLFW_INVALID_VALUE
One of the arguments to the function was an invalid value.
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
#define GLFW_KEY_RIGHT_ALT
#define GLFW_KEY_LEFT_ALT
#define GLFW_KEY_LEFT_SHIFT
#define GLFW_KEY_CAPS_LOCK
#define GLFW_KEY_LEFT_CONTROL
#define GLFW_KEY_RIGHT_CONTROL
#define GLFW_KEY_RIGHT_SUPER
#define GLFW_KEY_LEFT_SUPER
#define GLFW_KEY_RIGHT_SHIFT
#define GLFW_MOD_SHIFT
If this bit is set one or more Shift keys were held down.
#define GLFW_MOD_SUPER
If this bit is set one or more Super keys were held down.
#define GLFW_MOD_CONTROL
If this bit is set one or more Control keys were held down.
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
#define GLFW_MOD_CAPS_LOCK
If this bit is set the Caps Lock key is enabled.
#define GLFW_RESIZE_EW_CURSOR
The horizontal resize/move arrow shape.
#define GLFW_NOT_ALLOWED_CURSOR
The operation-not-allowed shape.
#define GLFW_IBEAM_CURSOR
The text input I-beam cursor shape.
#define GLFW_RESIZE_ALL_CURSOR
The omni-directional resize/move cursor shape.
#define GLFW_ARROW_CURSOR
The regular arrow cursor shape.
#define GLFW_CROSSHAIR_CURSOR
The crosshair cursor shape.
#define GLFW_RESIZE_NS_CURSOR
The vertical resize/move arrow shape.
#define GLFW_POINTING_HAND_CURSOR
The pointing hand cursor shape.
#define GLFW_RESIZE_NESW_CURSOR
The top-right to bottom-left diagonal resize/move arrow shape.
#define GLFW_RESIZE_NWSE_CURSOR
The top-left to bottom-right diagonal resize/move arrow shape.
struct GLFWwindow GLFWwindow
Opaque window object.
void _glfwInputError(int code, const char *format,...)
char * _glfw_strdup(const char *source)
NSTrackingArea * trackingArea
NSMutableAttributedString * markedText
void _glfwInputMonitorWindow(_GLFWmonitor *monitor, _GLFWwindow *window)
void _glfwInputFramebufferSize(_GLFWwindow *window, int width, int height)
void _glfwInputWindowIconify(_GLFWwindow *window, GLFWbool iconified)
void _glfwInputWindowMaximize(_GLFWwindow *window, GLFWbool maximized)
void _glfwInputWindowSize(_GLFWwindow *window, int width, int height)
void _glfwInputWindowMonitor(_GLFWwindow *window, _GLFWmonitor *monitor)
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
void _glfwInputWindowPos(_GLFWwindow *window, int xpos, int ypos)
const char * _glfwGetVulkanResultString(VkResult result)
void _glfwInputWindowContentScale(_GLFWwindow *window, float xscale, float yscale)
void _glfwInputWindowDamage(_GLFWwindow *window)
void _glfwInputWindowCloseRequest(_GLFWwindow *window)
void _glfwInputWindowFocus(_GLFWwindow *window, GLFWbool focused)
@ VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK
@ VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT
GLFWbool _glfwCreateContextNSGL(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
GLFWbool _glfwInitNSGL(void)
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
GLFWbool _glfwInitOSMesa(void)
_GLFWdestroycontextfun destroy
GLFWbool ANGLE_platform_angle_metal
GLFWbool ANGLE_platform_angle
GLFWbool ANGLE_platform_angle_opengl
struct _GLFWlibrary::@25 vk
struct _GLFWlibrary::@23 hints
char keys[GLFW_KEY_LAST+1]
struct _GLFWwndconfig::@18 ns
@ VK_ERROR_EXTENSION_NOT_PRESENT
#define vkGetInstanceProcAddr