diff --git a/buildconfig/Setup_Darwin.in b/buildconfig/Setup_Darwin.in index 108260c6c1..8ce19cd21e 100644 --- a/buildconfig/Setup_Darwin.in +++ b/buildconfig/Setup_Darwin.in @@ -1,5 +1,4 @@ #This file defines platform specific modules for mac os x SCRAP = scrap src_c/scrap.c $(SDL) $(SCRAP) $(DEBUG) -sdlmain_osx src_c/sdlmain_osx.m $(SDL) $(DEBUG) _camera src_c/_camera.c $(SDL) $(DEBUG) diff --git a/buildconfig/config_darwin.py b/buildconfig/config_darwin.py index 9503ea7033..224f8074c7 100644 --- a/buildconfig/config_darwin.py +++ b/buildconfig/config_darwin.py @@ -134,9 +134,7 @@ def main(auto_config=False): Dependency('JPEG', 'jpeglib.h', 'libjpeg', ['jpeg']), Dependency('PORTMIDI', 'portmidi.h', 'libportmidi', ['portmidi']), Dependency('PORTTIME', 'porttime.h', '', []), - find_freetype(), - # Scrap is included in sdlmain_osx, there is nothing to look at. - # Dependency('SCRAP', '','',[]), + find_freetype() ]) print('Hunting dependencies...') diff --git a/src_c/sdlmain_osx.m b/src_c/sdlmain_osx.m deleted file mode 100644 index 60a2ab5456..0000000000 --- a/src_c/sdlmain_osx.m +++ /dev/null @@ -1,213 +0,0 @@ -/* - pygame-ce - Python Game Library - Copyright (C) 2009 Brian Fisher - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* Mac OS X functions to accommodate the fact SDLMain.m is not included */ - -#include "pygame.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pgcompat.h" - -#include - -struct CPSProcessSerNum { - UInt32 lo; - UInt32 hi; -}; - -typedef struct CPSProcessSerNum CPSProcessSerNum; - -extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn); -extern OSErr CPSEnableForegroundOperation(CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); -extern OSErr CPSSetFrontProcess(CPSProcessSerNum *psn); -extern OSErr CPSSetProcessName(CPSProcessSerNum *psn, const char *processname); - -static NSString * -getApplicationName(void) -{ - const NSDictionary *dict; - NSString *appName = 0; - - /* Determine the application name */ - dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); - if (dict) - appName = [dict objectForKey: @"CFBundleName"]; - - if (![appName length]) - appName = [[NSProcessInfo processInfo] processName]; - - return appName; -} - -static PyObject * -_WMEnable(PyObject *self) -{ - CPSProcessSerNum psn; - const char* nameString; - NSString* nameNSString; - - if (!CPSGetCurrentProcess(&psn)) { - nameNSString = getApplicationName(); - nameString = [nameNSString UTF8String]; - CPSSetProcessName(&psn, nameString); - - if (!CPSEnableForegroundOperation(&psn, 0x03, 0x3C, 0x2C, 0x1103)) { - if (CPSSetFrontProcess(&psn)) - return RAISE(pgExc_SDLError, "CPSSetFrontProcess failed"); - } - else - return RAISE(pgExc_SDLError, "CPSEnableForegroundOperation failed"); - } - else - return RAISE(pgExc_SDLError, "CPSGetCurrentProcess failed"); - - Py_RETURN_TRUE; -} - -//############################################################################# -// Defining the NSApplication class we will use -//############################################################################# -@interface PYGSDLApplication : NSApplication -@end - -/* For some reason, Apple removed setAppleMenu from the headers in 10.4, - but the method still is there and works. To avoid warnings, we declare - it ourselves here. */ -@interface NSApplication(SDL_Missing_Methods) -- (void)setAppleMenu:(NSMenu *)menu; -@end - -@implementation PYGSDLApplication -/* Invoked from the Quit menu item */ -- (void)terminate:(id)sender -{ - SDL_Event event; - event.type = SDL_QUIT; - SDL_PushEvent(&event); -} -@end - -/* The below functions are unused for now, hence commented -static void -setApplicationMenu(void) -{ - NSMenu *appleMenu; - NSMenuItem *menuItem; - NSString *title; - NSString *appName; - - appName = getApplicationName(); - appleMenu = [[NSMenu alloc] initWithTitle:@""]; - - - title = [@"About " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; - - [appleMenu addItem:[NSMenuItem separatorItem]]; - - title = [@"Hide " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"]; - - menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; - -#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 - [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; -#else - [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)]; -#endif - - - [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; - - [appleMenu addItem:[NSMenuItem separatorItem]]; - - title = [@"Quit " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; - - - menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; - [menuItem setSubmenu:appleMenu]; - [[NSApp mainMenu] addItem:menuItem]; - - [NSApp setAppleMenu:appleMenu]; - - [appleMenu release]; - [menuItem release]; -} - -static void -setupWindowMenu(void) -{ - NSMenu *windowMenu; - NSMenuItem *windowMenuItem, *menuItem; - - windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; - - menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; - [windowMenu addItem:menuItem]; - [menuItem release]; - - windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; - [windowMenuItem setSubmenu:windowMenu]; - [[NSApp mainMenu] addItem:windowMenuItem]; - - [NSApp setWindowsMenu:windowMenu]; - - [windowMenu release]; - [windowMenuItem release]; -} -*/ - -static PyMethodDef macosx_builtins[] = -{ - {"WMEnable", (PyCFunction)_WMEnable, METH_NOARGS, "Enables Foreground Operation when Window Manager is not available" }, - {NULL, NULL, 0, NULL} -}; - -MODINIT_DEFINE (sdlmain_osx) -{ - /* create the module */ - static struct PyModuleDef _module = { - PyModuleDef_HEAD_INIT, - "sdlmain_osx", - NULL, - -1, - macosx_builtins, - NULL, - NULL, - NULL, - NULL - }; - - /*imported needed apis*/ - import_pygame_base(); - if (PyErr_Occurred()) { - return NULL; - } - - return PyModule_Create(&_module); -}