I have a standalone XULRunner application that was previously running XULRunner 1.9.2 (old, I know). I just upgraded to XULRunner 33.
Previously, When I was developing locally (MacBook Pro with Mac OS X 10.9.5), I would often Cmd+Tab between my IDE and my application.
After the upgrade, I can no longer do this. I still get a window on my desktop (as defined in main.xul
), but it no longer appears in my Cmd+Tab list. I have to "find" it on the desktop.
Closing the window quits the application, etc., and the fact that I'm getting an application window at all implies that my main.xul
is correct... but I don't know why this is.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://my-app-name/skin/css/main.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://my-app-name/locale/main.dtd">
<window id="main" title="&window-title;" width="750" height="530" persist="width,height,screenX,screenY,sizemode" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script><!-- MY APPLICATION CODE HERE --></script>
<keyset>
<key modifiers="accel" key="W" oncommand="window.close()"/>
<key modifiers="accel" key="Q" id="quit"/>
</keyset>
<toolbox>
<menubar>
<menu id="menu_file" label="File" hidden="true">
<menupopup>
<menuitem id="menu_FileQuitItem" key="quit" label="Quit" oncommand="goQuitApplication();"/>
</menupopup>
</menu>
</menubar>
</toolbox>
</window>
I've read through the Windows and menus in XULRunner tutorial:
The same code on XULRunner 1.9.2 runs fine and I can "activate" the window. With the new XULRunner, the window title appears greyed out in Mac OS X and is not selectable.
Any ideas of what to try?
I don't know if it's helpful, but I also used to get a menu bar in OS X as well, when the window was selected. Even now if I click on the window's title bar, the menu bar that OS X displays does not show my application's menu.
I don't know what was changed, or when they changed it, but this behavior is somewhat documented on MDN.
On the Mac, before you can run a XULRunner application with everything intact, you must install it using the
--install-app
xulrunner commandline flag. Installing the application creates an OS X application bundle:
The page goes on with some steps for how to do this, but I was never able to get them to work with modern XULRunner versions.
The only way I was ever able to get modern XULRunner versions to fully work is to create the application bundle manually.
In this example, I am going to use the "hello world" example referenced in the MDN docs.
Step 1:
Create the following directory structure.
hello.app/
Contents/
MacOS/
Resources/
Step 2:
Download the version of XULRunner runtime you want (I'm using 33), and extract the XUL.framework
.
Step 3:
Copy all of the files inside XUL.framework/Versions/Current/
to hello.app/Contents/MacOS/
.
Also copy the dependentlibs.list
into hello.app/Contents/Resources/
Step 4:
Download the example files, and copy the following files and directories to hello.app/Contents/Resources/
.
chrome/
defaults/
application.ini
chrome.manifest
Step 5:
Due to another issue, the xulrunner
binary will not automatically find the application.ini
like it's supposed to. To work around this, we will need a stub loader, like this one I wrote previously.
#!/bin/sh
runpath="`dirname "$0"`"
contentsdir="`cd "$runpath"/.. > /dev/null && pwd`"
exec "$runpath/xulrunner" --app "$contentsdir/Resources/application.ini"
Create a new file named hello
at hello.app/Contents/MacOS/hello
, put the code above inside, and give it executable permissions (chmod +x hello
).
Step 6:
Now we need a Info.plist
file. Here is one I created based on the Deploying XULRunner example. Note that the CFBundleExecutable
must match the stub loader file name above.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>hello</string>
<key>CFBundleGetInfoString</key>
<string>1.0</string>
<key>CFBundleIconFile</key>
<string>app_icon.icns</string>
<key>CFBundleIdentifier</key>
<string>net.yourcompany.yourapplication</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>applicationName</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
Save this file under hello.app/Info.plist
.
Step 7:
Create a new file named PkgInfo
at hello.app/PkgInfo
, and put this text inside.
APPL????
Step 8:
You should now be able to run your application with and menu and doc icon, and Cmd + Tab capabilities. You can open it by Finder, or the command line.
$ ./hello.app/Contents/MacOS/hello
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With