Christian Convey wrote:
>> Greg Ercolano wrote:
>>> Do you find your app opens 'below' other windows, and that ALL widgets
>>> in your app, not just the menu bar, are unresponsive to mouse clicks?
>>> If so, make sure you've first created a real Mac ".app bundle" for your
>>> app.
>>>
>>> I think someone wrote an article for this on the FLTK website,
>>> but I can't find it by searching the Articles for "bundle".
>>> I do have this info on my 'cheat' page for how to make Mac bundles:
>>> http://seriss.com/people/erco/fltk/#MacBundle
>> I should add that Leopard pretty much requires your GUI apps are
>> formed into a ".app bundle" now.
>>
>> Apple has been warning for a while that the ".app bundle" is the proper
>> way to do things. I agree with Apple on this, as I always hated the whole
>> magic pixie-dust idea of hidden data/resource forks on files.
>
> Thanks, Greg and Ian. My program *does* only show up below other windows,
> but it does have within it an Fl_Gl_Window that responds properly to mouse
> clicks. So it partially has the qualities that Greg says suggest the need
> for making an app bundle.
>
> I hadn't really looked at app bundles before, since my terminal-based
> programs ported from Linux worked just fine. I guess it's time for me to
> drink a little more of the Apply Cool-Aid.
>
> I'm using CMake to build the project, so I'm going to need to look into how
> CMake does OS X bundles. Man, this OS X programming is one... learning
> opportunity... after another :)
>
> Thanks again for all the help.
>
> - Christian
The following code in fltk2.0 makes the compiled program work without
having to be in a "bundle":
// bring the application into foreground without a 'CARB' resource
Boolean same_psn;
ProcessSerialNumber cur_psn, front_psn;
if (!GetCurrentProcess( &cur_psn ) && !GetFrontProcess( &front_psn ) &&
!SameProcess( &front_psn, &cur_psn, &same_psn ) && !same_psn ) {
// If we are in a .app bundle this is not necessary, so don't do it.
// It also prevents some bundle functions such as LSBackgroundOnly.
// This mess figures out if we are bundled:
CFBundleRef bundle = CFBundleGetMainBundle();
if ( bundle ) {
FSRef execFs;
CFURLRef execUrl = CFBundleCopyExecutableURL( bundle );
CFURLGetFSRef( execUrl, &execFs );
FSRef bundleFs;
GetProcessBundleLocation( &cur_psn, &bundleFs );
if ( !FSCompareFSRefs( &execFs, &bundleFs ) )
bundle = NULL;
CFRelease(execUrl);
}
if ( !bundle ) {
OSErr err = 1;
#ifdef MAC_OS_X_VERSION_10_3
// newer supported API
if (TransformProcessType != NULL)
err = TransformProcessType( &cur_psn,
kProcessTransformToForegroundApplication );
#else
// undocumented API
if (CPSEnableForegroundOperation != NULL)
err = CPSEnableForegroundOperation( &cur_psn, 0x03, 0x3C, 0x2C,
0x1103 );
#endif
if (err == noErr)
SetFrontProcess( &cur_psn );
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk