Skip to content

Commit

Permalink
Merge pull request #490 from beoran/beoran-487-fix-some-osx-warnings
Browse files Browse the repository at this point in the history
Fix several OSX compilation and deprecation warnings.
  • Loading branch information
beoran committed Sep 9, 2015
2 parents a14cc8c + f51bd76 commit ebaa685
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
4 changes: 2 additions & 2 deletions addons/image/macosx.m
Expand Up @@ -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++) {
Expand Down
15 changes: 15 additions & 0 deletions addons/native_dialog/osx_dialog.m
Expand Up @@ -4,6 +4,18 @@

#import <Cocoa/Cocoa.h>

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

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

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



#define add_menu(name, sel, eq) \
[menu addItem: [[[NSMenuItem allocWithZone: [NSMenu menuZone]] \
initWithTitle: name \
Expand Down Expand Up @@ -581,6 +595,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)
Expand Down
6 changes: 3 additions & 3 deletions src/allegro.c
@@ -1,6 +1,6 @@
/* ______ ___ ___
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions src/macosx/hidjoy.m
Expand Up @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions src/macosx/osxgl.m
Expand Up @@ -1153,6 +1153,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
*/
Expand All @@ -1161,10 +1165,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];
Expand Down

0 comments on commit ebaa685

Please sign in to comment.