@@ -278,8 +278,11 @@ static void lazy_init(void) {
278278 backend_inited = true ;
279279
280280 NSApp = [NSApplication sharedApplication ];
281+ [NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
281282
282283#ifndef PYPY
284+ /* TODO: remove ifndef after the new PyPy with the PyOS_InputHook implementation
285+ get released: https://bitbucket.org/pypy/pypy/commits/caaf91a */
283286 PyOS_InputHook = wait_for_stdin;
284287#endif
285288
@@ -2579,27 +2582,13 @@ static void context_cleanup(const void* info)
25792582 Timer_new, /* tp_new */
25802583};
25812584
2585+ #ifndef COMPILING_FOR_10_6
25822586static bool verify_framework (void )
25832587{
25842588 ProcessSerialNumber psn;
2585- /* These methods are deprecated, but they don't require the app to
2586- have started */
2587- #ifdef COMPILING_FOR_10_6
2588- NSApp = [NSApplication sharedApplication ];
2589- [NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
2590- NSApplicationActivationPolicy activationPolicy = [NSApp activationPolicy ];
2591- switch (activationPolicy) {
2592- case NSApplicationActivationPolicyRegular:
2593- case NSApplicationActivationPolicyAccessory:
2594- return true ;
2595- case NSApplicationActivationPolicyProhibited:
2596- break ;
2597- }
2598- #else
25992589 if (CGMainDisplayID ()!=0
26002590 && GetCurrentProcess (&psn)==noErr
26012591 && SetFrontProcess (&psn)==noErr) return true ;
2602- #endif
26032592 PyErr_SetString (PyExc_ImportError,
26042593 " Python is not installed as a framework. The Mac OS X backend will "
26052594 " not be able to function correctly if Python is not installed as a "
@@ -2611,6 +2600,7 @@ static bool verify_framework(void)
26112600 " Matplotlib FAQ for more information." );
26122601 return false ;
26132602}
2603+ #endif
26142604
26152605static struct PyMethodDef methods[] = {
26162606 {" event_loop_is_running" ,
@@ -2661,8 +2651,11 @@ static bool verify_framework(void)
26612651 || PyType_Ready (&TimerType) < 0 )
26622652 return NULL ;
26632653
2654+ #ifndef COMPILING_FOR_10_6
2655+ /* if >=10.6 invoke setActivationPolicy in lazy_init */
26642656 if (!verify_framework ())
26652657 return NULL ;
2658+ #endif
26662659
26672660 module = PyModule_Create (&moduledef);
26682661 if (!module)
0 commit comments