From 2eeed7bbd629adc25b7baddd55e71f4f55e608ea Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 12 Dec 2009 01:47:59 +0000 Subject: [PATCH] more mac app focus issues --- direct/src/directscripts/RunPanda3D.js | 36 ++++++++++++++++++++------ direct/src/p3d/Packager.py | 13 +++++++++- direct/src/showbase/Sources.pp | 3 ++- direct/src/showbase/WxGlobal.py | 8 +++--- direct/src/showbase/showBase.cxx | 22 ++++++++++++++-- direct/src/showbase/showBase.h | 4 +++ direct/src/showbase/showBase_assist.mm | 19 ++++++++++++++ 7 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 direct/src/showbase/showBase_assist.mm diff --git a/direct/src/directscripts/RunPanda3D.js b/direct/src/directscripts/RunPanda3D.js index 943bc31914..4b3d6f23a1 100644 --- a/direct/src/directscripts/RunPanda3D.js +++ b/direct/src/directscripts/RunPanda3D.js @@ -14,9 +14,10 @@ var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : f var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; -function P3D_Generateobj(objAttrs, params, embedAttrs) +function P3D_Generateobj(objAttrs, params, embedAttrs, imageAttrs) { var str = ''; + if (isIE && isWin && !isOpera) { str += ' '; } - str += ''; } else { - str += ' +extern "C" { void CPSEnableForegroundOperation(ProcessSerialNumber* psn); } +#endif #include "showBase.h" @@ -59,8 +68,17 @@ get_config_showbase() { // At the moment, this is a no-op except on Mac. void init_app_for_gui() { - // Actually, this may not be necessary after all. Let's assume the - // user will always be running from a bundle or from pythonw. +#ifdef IS_OSX + // Rudely bring the application to the foreground. This is + // particularly important when running wx via the plugin, since the + // plugin app is seen as separate from the browser app, even though + // the user sees them as the same thing. We need to bring the + // plugin app to the foreground to make its wx windows visible. + activate_osx_application(); +#endif + + // We don't appear need to do the following, however, if we launch + // the plugin correctly from its own bundle. /* static bool initted_for_gui = false; if (!initted_for_gui) { diff --git a/direct/src/showbase/showBase.h b/direct/src/showbase/showBase.h index 68c2667682..8b9c24f40a 100644 --- a/direct/src/showbase/showBase.h +++ b/direct/src/showbase/showBase.h @@ -51,6 +51,10 @@ EXPCL_DIRECT bool query_fullscreen_testresult(int xsize, int ysize); EXPCL_DIRECT void store_accessibility_shortcut_keys(); EXPCL_DIRECT void allow_accessibility_shortcut_keys(bool allowKeys); +#ifdef IS_OSX +void activate_osx_application(); +#endif + END_PUBLISH diff --git a/direct/src/showbase/showBase_assist.mm b/direct/src/showbase/showBase_assist.mm new file mode 100644 index 0000000000..2eb8c0c3bc --- /dev/null +++ b/direct/src/showbase/showBase_assist.mm @@ -0,0 +1,19 @@ +#ifndef CPPPARSER +#include "showBase.h" + +#ifdef IS_OSX + +#include + +//////////////////////////////////////////////////////////////////// +// Function: activate_osx_application +// Description: Activates the current application for Mac OSX. +//////////////////////////////////////////////////////////////////// +void +activate_osx_application() { + cerr << "activate_osx_application\n"; + [ [NSApplication sharedApplication] activateIgnoringOtherApps: YES ]; +} + +#endif // IS_OSX +#endif // CPPPARSER