diff options
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/detect.py | 4 | ||||
-rw-r--r-- | platform/osx/os_osx.h | 3 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 37 |
3 files changed, 33 insertions, 11 deletions
diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 1e9631fae0..72b8aa99f8 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -23,8 +23,8 @@ def get_opts(): return [ ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'), - EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), - BoolVariable('separate_debug_symbols', 'Create a separate file with the debug symbols', False), + EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), + BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False), ] diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index c1022a1aca..7bd5b16f36 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -109,6 +109,7 @@ public: bool minimized; bool maximized; bool zoomed; + bool resizable; Size2 window_size; Rect2 restore_rect; @@ -116,6 +117,7 @@ public: String open_with_filename; Point2 im_position; + bool im_active; ImeCallback im_callback; void *im_target; @@ -232,6 +234,7 @@ public: virtual bool get_window_per_pixel_transparency_enabled() const; virtual void set_window_per_pixel_transparency_enabled(bool p_enabled); + virtual void set_ime_active(const bool p_active); virtual void set_ime_position(const Point2 &p_pos); virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index bde0b4e898..4ece1e0325 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -913,7 +913,7 @@ static int remapKey(unsigned int key) { CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); if (!layoutData) - return nil; + return 0; const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); @@ -959,7 +959,7 @@ static int remapKey(unsigned int key) { push_to_key_event_buffer(ke); } - if ((OS_OSX::singleton->im_position.x != 0) && (OS_OSX::singleton->im_position.y != 0)) + if (OS_OSX::singleton->im_active == true) [self interpretKeyEvents:[NSArray arrayWithObject:event]]; } @@ -1129,6 +1129,10 @@ String OS_OSX::get_unique_id() const { return serial_number; } +void OS_OSX::set_ime_active(const bool p_active) { + im_active = p_active; +} + void OS_OSX::set_ime_position(const Point2 &p_pos) { im_position = p_pos; } @@ -1184,6 +1188,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a if (p_desired.borderless_window) { styleMask = NSWindowStyleMaskBorderless; } else { + resizable = p_desired.resizable; styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (p_desired.resizable ? NSWindowStyleMaskResizable : 0); } @@ -1480,7 +1485,7 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) { if (cursor_shape == p_shape) return; - if (mouse_mode != MOUSE_MODE_VISIBLE) { + if (mouse_mode != MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) { cursor_shape = p_shape; return; } @@ -1545,7 +1550,9 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c image = texture->get_data(); - NSBitmapImageRep *imgrep = [[[NSBitmapImageRep alloc] + ERR_FAIL_COND(!image.is_valid()); + + NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:int(texture_size.width) pixelsHigh:int(texture_size.height) @@ -1555,7 +1562,7 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:int(texture_size.width) * 4 - bitsPerPixel:32] autorelease]; + bitsPerPixel:32]; ERR_FAIL_COND(imgrep == nil); uint8_t *pixels = [imgrep bitmapData]; @@ -1587,16 +1594,20 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c image->unlock(); - NSImage *nsimage = [[[NSImage alloc] initWithSize:NSMakeSize(texture_size.width, texture_size.height)] autorelease]; + NSImage *nsimage = [[NSImage alloc] initWithSize:NSMakeSize(texture_size.width, texture_size.height)]; [nsimage addRepresentation:imgrep]; NSCursor *cursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(p_hotspot.x, p_hotspot.y)]; + [cursors[p_shape] release]; cursors[p_shape] = cursor; if (p_shape == CURSOR_ARROW) { [cursor set]; } + + [imgrep release]; + [nsimage release]; } else { // Reset to default system cursor cursors[p_shape] = NULL; @@ -1740,7 +1751,8 @@ String OS_OSX::get_godot_dir_name() const { String OS_OSX::get_system_dir(SystemDir p_dir) const { - NSSearchPathDirectory id = 0; + NSSearchPathDirectory id; + bool found = true; switch (p_dir) { case SYSTEM_DIR_DESKTOP: { @@ -1761,10 +1773,13 @@ String OS_OSX::get_system_dir(SystemDir p_dir) const { case SYSTEM_DIR_PICTURES: { id = NSPicturesDirectory; } break; + default: { + found = false; + } } String ret; - if (id) { + if (found) { NSArray *paths = NSSearchPathForDirectoriesInDomains(id, NSUserDomainMask, YES); if (paths && [paths count] >= 1) { @@ -2110,6 +2125,8 @@ void OS_OSX::set_window_resizable(bool p_enabled) { [window_object setStyleMask:[window_object styleMask] | NSWindowStyleMaskResizable]; else [window_object setStyleMask:[window_object styleMask] & ~NSWindowStyleMaskResizable]; + + resizable = p_enabled; }; bool OS_OSX::is_window_resizable() const { @@ -2219,7 +2236,7 @@ void OS_OSX::set_borderless_window(bool p_borderless) { if (layered_window) set_window_per_pixel_transparency_enabled(false); - [window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; + [window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (resizable ? NSWindowStyleMaskResizable : 0)]; // Force update of the window styles NSRect frameRect = [window_object frame]; @@ -2529,6 +2546,7 @@ OS_OSX::OS_OSX() { mouse_mode = OS::MOUSE_MODE_VISIBLE; main_loop = NULL; singleton = this; + im_active = false; im_position = Point2(); im_callback = NULL; im_target = NULL; @@ -2615,6 +2633,7 @@ OS_OSX::OS_OSX() { minimized = false; window_size = Vector2(1024, 600); zoomed = false; + resizable = false; Vector<Logger *> loggers; loggers.push_back(memnew(OSXTerminalLogger)); |