more mac app focus issues

This commit is contained in:
David Rose 2009-12-12 01:47:59 +00:00
parent 8795e86f45
commit 2eeed7bbd6
7 changed files with 90 additions and 15 deletions

View File

@ -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 += '<object ';
@ -29,17 +30,25 @@ function P3D_Generateobj(objAttrs, params, embedAttrs)
{
str += '<param name="' + i + '" value="' + params[i] + '" /> ';
}
str += '</object>';
}
else
{
str += '<embed ';
str += '<object ';
for (var i in embedAttrs)
{
str += i + '="' + embedAttrs[i] + '" ';
}
str += '> </embed>';
str += '> ';
}
if (imageAttrs["src"]) {
str += '<img ';
for (var i in imageAttrs)
{
str += i + '="' + imageAttrs[i] + '" ';
}
str += '>';
}
str += '</object>';
document.write(str);
}
@ -49,7 +58,7 @@ function P3D_RunContent(){
P3D_GetArgs
(arguments, "clsid:924b4927-d3ba-41ea-9f7e-8a89194ab3ac",
"application/x-panda3d");
P3D_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
P3D_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs, ret.imageAttrs);
}
function P3D_GetArgs(args, classid, mimeType){
@ -57,6 +66,7 @@ function P3D_GetArgs(args, classid, mimeType){
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
ret.imageAttrs = new Object();
for (var i = 0; i < args.length; i = i + 2){
var currArg = args[i].toLowerCase();
@ -64,7 +74,7 @@ function P3D_GetArgs(args, classid, mimeType){
switch (currArg){
case "src":
case "data":
ret.embedAttrs['src'] = args[i+1];
ret.embedAttrs['data'] = args[i+1];
ret.params['data'] = args[i+1];
break;
@ -72,9 +82,19 @@ function P3D_GetArgs(args, classid, mimeType){
ret.objAttrs['codebase'] = args[i+1];
break;
case "id":
case "noplugin_img":
ret.imageAttrs["src"] = args[i+1];
break;
case "splash_img":
ret.imageAttrs["src"] = ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
case "width":
case "height":
ret.imageAttrs[args[i]] = ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
break;
case "id":
case "align":
case "vspace":
case "hspace":

View File

@ -2694,11 +2694,22 @@ class Packager:
# includes specifications in the plist file to avoid
# creating a dock icon and stuff.
resources = []
# Find p3dpython.plist in the direct source tree.
import direct
plist = Filename(direct.__path__[0], 'plugin/p3dpython.plist')
## # Find panda3d.icns in the models tree.
## filename = Filename('plugin_images/panda3d.icns')
## found = filename.resolveFilename(getModelPath().getValue())
## if not found:
## found = filename.resolveFilename("models")
## if found:
## resources.append(filename)
self.do_makeBundle('P3DPython.app', plist, executable = 'p3dpython',
dependencyDir = '')
resources = resources, dependencyDir = '')
else:
# Anywhere else, we just ship the executable file p3dcert.exe.

View File

@ -16,7 +16,8 @@
User32.lib
#define SOURCES \
showBase.cxx showBase.h
showBase.cxx showBase.h \
$[if $[IS_OSX],showBase_assist.mm]
#define IGATESCAN all
#end lib_target

View File

@ -8,8 +8,10 @@ def wxLoop(self):
return Task.cont
def spawnWxLoop():
if hasattr(base, 'wxApp') and base.wxApp:
base.wxApp.Exit()
if not getattr(base, 'wxApp', None):
# Create a new base.wxApp, but only if it's not already
# created.
base.wxApp = wx.App(False)
# Spawn this task
taskMgr.add(wxLoop, "wxLoop")

View File

@ -12,6 +12,15 @@
//
////////////////////////////////////////////////////////////////////
#ifdef __APPLE__
// We have to include this before we include any Panda libraries,
// because one of the things we pick up in Panda defines a macro for
// TCP_NODELAY and friends, causing heartaches for the header files
// picked up here.
#include <Carbon/Carbon.h>
extern "C" { void CPSEnableForegroundOperation(ProcessSerialNumber* psn); }
#endif
#include "showBase.h"
#include "throw_event.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) {

View File

@ -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

View File

@ -0,0 +1,19 @@
#ifndef CPPPARSER
#include "showBase.h"
#ifdef IS_OSX
#include <AppKit/AppKit.h>
////////////////////////////////////////////////////////////////////
// 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