Skip to content
Permalink
Browse files

Fix several OSX compilation and deprecation warnings.

In particular Gestalt() has been replaced by NSAppKitVersionNumber.
  • Loading branch information...
beoran committed Sep 7, 2015
1 parent 597886c commit b0241f1447dd5ccafd42b33c9de1ed0c9d3ccd8e
Showing with 31 additions and 15 deletions.
  1. +2 −2 addons/image/macosx.m
  2. +14 −0 addons/native_dialog/osx_dialog.m
  3. +3 −3 src/allegro.c
  4. +7 −6 src/macosx/hidjoy.m
  5. +5 −4 src/macosx/osxgl.m
@@ -62,8 +62,8 @@
int i, j;
{
for (i = 0; i < h; i++) {
uint8_t *data_row = lock->data + lock->pitch * i;
uint8_t *source_row = pixels + w * samples * i;
uint8_t *data_row = (uint8_t *) lock->data + lock->pitch * i;
uint8_t *source_row = (uint8_t *) pixels + w * samples * i;
if (samples == 4) {
if (premul) {
for (j = 0; j < w; j++) {
@@ -4,6 +4,12 @@

#import <Cocoa/Cocoa.h>

/* Normally we should include aintosx.h to get this prototype but it doesn't
* work. So repeat the prototype here as a stopgap measure.
*/
void _al_osx_clear_mouse_state(void);


bool _al_init_native_dialog_addon(void)
{
return true;
@@ -509,6 +515,13 @@ - (NSMenuItem *) build_menu_item:(ALLEGRO_MENU_ITEM *)aitem
static volatile ALLEGRO_EVENT_QUEUE *queue = NULL;
static ALLEGRO_MUTEX *mutex;

/* Declare this here to avoid getting a warning.
* There seems to be no better way to do this...
*/
@interface NSApplication(AllegroOSX)
- (void)setAppleMenu:(NSMenu *) menu;
@end

#define add_menu(name, sel, eq) \
[menu addItem: [[[NSMenuItem allocWithZone: [NSMenu menuZone]] \
initWithTitle: name \
@@ -581,6 +594,7 @@ - (NSMenuItem *) build_menu_item:(ALLEGRO_MENU_ITEM *)aitem
mutex = NULL;
al_destroy_event_queue((ALLEGRO_EVENT_QUEUE *)queue);
queue = NULL;
return NULL;
}

static void ensure_event_thread(void)
@@ -1,6 +1,6 @@
/* ______ ___ ___
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
@@ -19,7 +19,7 @@
#include "allegro5/allegro.h"
#include "allegro5/platform/alplatf.h"
#include "allegro5/internal/aintern.h"

#include ALLEGRO_INTERNAL_HEADER


/* Function: al_get_allegro_version
@@ -765,17 +765,18 @@ static bool get_joystick_active(ALLEGRO_JOYSTICK *joy_)

#endif // Leopard+

#ifndef NSAppKitVersionNumber10_5
#define NSAppKitVersionNumber10_5 949
#endif



ALLEGRO_JOYSTICK_DRIVER* _al_osx_get_joystick_driver_10_4(void);
ALLEGRO_JOYSTICK_DRIVER* _al_osx_get_joystick_driver_10_5(void);

ALLEGRO_JOYSTICK_DRIVER* _al_osx_get_joystick_driver(void)
{
SInt32 major, minor;

Gestalt(gestaltSystemVersionMajor, &major);
Gestalt(gestaltSystemVersionMinor, &minor);

if (major >= 10 && minor >= 5) {
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_5) {
return _al_osx_get_joystick_driver_10_5();
}
else {
@@ -1152,6 +1152,10 @@ +(void) runFullScreenDisplay: (NSValue*) display_object
return compat;
}

#ifndef NSAppKitVersionNumber10_7
#define NSAppKitVersionNumber10_7 1138
#endif

/* create_display_fs:
* Create a fullscreen display - capture the display
*/
@@ -1160,10 +1164,7 @@ +(void) runFullScreenDisplay: (NSValue*) display_object
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ALLEGRO_DEBUG("Switching to fullscreen mode sized %dx%d\n", w, h);

int32_t system_version;
if (Gestalt(gestaltSystemVersion, &system_version) != noErr)
system_version = 0;
#define IS_LION (system_version >= 0x1070)
#define IS_LION (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_7)

if (al_get_new_display_adapter() >= al_get_num_video_adapters()) {
[pool drain];

0 comments on commit b0241f1

Please sign in to comment.
You can’t perform that action at this time.