Revision: 1ca236a64db0
Branch: default
Author: Phillip Nguyen <
evil.p...@gmail.com>
Date: Fri Dec 7 12:29:36 2012
Log: disable persistent window state which prevented new windows from
displaying
after finishLaunching on 10.8
http://code.google.com/p/pyglet/source/detail?r=1ca236a64db0
Modified:
/pyglet/app/cocoa.py
=======================================
--- /pyglet/app/cocoa.py Thu Oct 11 17:32:01 2012
+++ /pyglet/app/cocoa.py Fri Dec 7 12:29:36 2012
@@ -46,6 +46,7 @@
NSAutoreleasePool = ObjCClass('NSAutoreleasePool')
NSDate = ObjCClass('NSDate')
NSEvent = ObjCClass('NSEvent')
+NSUserDefaults = ObjCClass('NSUserDefaults')
def add_menu_item(menu, title, action, key):
title = CFSTR(title)
@@ -91,6 +92,13 @@
self.pool = NSAutoreleasePool.alloc().init()
create_menu()
self.NSApp.setActivationPolicy_(NSApplicationActivationPolicyRegular)
+ # Prevent Lion / Mountain Lion from automatically saving
application state.
+ # If we don't do this, new windows will not display on 10.8 after
finishLaunching
+ # has been called.
+ defaults = NSUserDefaults.standardUserDefaults()
+ ignoreState = CFSTR("ApplerPersistenceIgnoreState")
+ if not defaults.objectForKey_(ignoreState):
+ defaults.setBool_forKey_(True, ignoreState)
def start(self):
self.NSApp.finishLaunching()