summaryrefslogtreecommitdiff
path: root/src/SFML/Window/OSX
diff options
context:
space:
mode:
authorJames Cowgill <jcowgill@debian.org>2018-10-16 22:26:31 +0100
committerJames Cowgill <jcowgill@debian.org>2018-10-16 22:26:31 +0100
commitf57a5d96a92d1208d252b7d3f97b3b5c3b69fd12 (patch)
treef2c152c29b5cac3a1b21cbae02c82b006ae7cdb4 /src/SFML/Window/OSX
parent088cbaedcc0634d0949ca8a92236e62a6d6caf71 (diff)
parent08bb1c372efcc9e2054e64b80959f025c8f43744 (diff)
Update upstream source from tag 'upstream/2.5.1+dfsg'
Update to upstream version '2.5.1+dfsg' with Debian dir 8171c41179aa4509b53f92cff2b893d4ceafc883
Diffstat (limited to 'src/SFML/Window/OSX')
-rw-r--r--src/SFML/Window/OSX/CursorImpl.mm44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/SFML/Window/OSX/CursorImpl.mm b/src/SFML/Window/OSX/CursorImpl.mm
index 5f41376..ed905ef 100644
--- a/src/SFML/Window/OSX/CursorImpl.mm
+++ b/src/SFML/Window/OSX/CursorImpl.mm
@@ -32,6 +32,21 @@
#import <SFML/Window/OSX/NSImage+raw.h>
#import <AppKit/AppKit.h>
+namespace
+{
+
+////////////////////////////////////////////////////////////
+NSCursor* loadFromSelector(SEL selector)
+{
+ // The caller is responsible for retaining the cursor.
+ if ([NSCursor respondsToSelector:selector])
+ return [NSCursor performSelector:selector];
+ else
+ return nil;
+}
+
+}
+
namespace sf
{
namespace priv
@@ -56,6 +71,8 @@ CursorImpl::~CursorImpl()
////////////////////////////////////////////////////////////
bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot)
{
+ [m_cursor release];
+
NSSize nssize = NSMakeSize(size.x, size.y);
NSImage* image = [NSImage imageWithRawData:pixels andSize:nssize];
NSPoint nshotspot = NSMakePoint(hotspot.x, hotspot.y);
@@ -65,10 +82,11 @@ bool CursorImpl::loadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hot
return m_cursor != nil;
}
-
////////////////////////////////////////////////////////////
bool CursorImpl::loadFromSystem(Cursor::Type type)
{
+ [m_cursor release];
+
switch (type)
{
default: return false;
@@ -80,14 +98,28 @@ bool CursorImpl::loadFromSystem(Cursor::Type type)
case Cursor::SizeVertical: m_cursor = [NSCursor resizeUpDownCursor]; break;
case Cursor::Cross: m_cursor = [NSCursor crosshairCursor]; break;
case Cursor::NotAllowed: m_cursor = [NSCursor operationNotAllowedCursor]; break;
+
+ // These cursor types are undocumented, may not be available on some platforms
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wundeclared-selector"
+ case Cursor::SizeBottomLeftTopRight:
+ m_cursor = loadFromSelector(@selector(_windowResizeNorthEastSouthWestCursor));
+ break;
+
+ case Cursor::SizeTopLeftBottomRight:
+ m_cursor = loadFromSelector(@selector(_windowResizeNorthWestSouthEastCursor));
+ break;
+
+ case Cursor::Help:
+ m_cursor = loadFromSelector(@selector(_helpCursor));
+ break;
+#pragma clang diagnostic pop
}
- // Since we didn't allocate the cursor ourself, we have to retain it
- // in order to not break the retain count.
- [m_cursor retain];
+ if (m_cursor)
+ [m_cursor retain];
- // For all non-default cases, it was a success.
- return true;
+ return m_cursor != nil;
}