[Openmcl-devel] Accessing method in CoreGraphics

Gary Byers gb at clozure.com
Fri Apr 15 11:51:05 PDT 2005



On Fri, 15 Apr 2005, Duncan Rose wrote:

>
> Whilst trawling the web recently I came across a page with an
> interesting tidbit on it (from my point of view; page for anybody
> interested is http://www.advogato.org/article/627.html) in the section
> titled 'Is it possible to run a GUI application that doesn't reside in
> a bundle?'.
>
> In short apparently a CoreGraphics framework function
> 'CPSEnableForegroundOperation' can be used for this. This method is
> referenced elsewhere; a 'find' in the framework directory returns:
>

You might also want to look at OpenMCL's Cocoa demo, which uses
this technique to ... enable foreground operation.

> Binary file
> ./ApplicationServices.framework/Versions/A/Frameworks/
> CoreGraphics.framework/CoreGraphics matches
> Binary file
> ./ApplicationServices.framework/Versions/A/Frameworks/
> CoreGraphics.framework/CoreGraphics_profile matches
> Binary file
> ./ApplicationServices.framework/Versions/A/Frameworks/
> CoreGraphics.framework/Versions/A/CoreGraphics matches
> Binary file
> ./ApplicationServices.framework/Versions/A/Frameworks/
> CoreGraphics.framework/Versions/A/CoreGraphics_profile matches
> Binary file ./GLUT.framework/GLUT matches
> Binary file ./GLUT.framework/Versions/A/GLUT matches
> Binary file ./JavaVM.framework/Versions/1.4.1/Libraries/libawt.jnilib
> matches)
>
> I'm trying to use this with the following code:
>
>    (rlet ((psn-struct :<P>rocess<S>erial<Number>))
>      (#_GetCurrentProcess psn-struct)
>      (#_CPSEnableForegroundOperation psn-struct))
>
> This (expectedly) fails to compile with the following report:
>
>  > Error in process listener(1): Foreign function not found:
> OS::|CPSEnableForegroundOperation|
>  > While executing: CCL::LOAD-EXTERNAL-FUNCTION
>  > Type :POP to abort.

It's not defined in the headers; the Cocoa demo uses EXTERNAL-CALL
to access it.

;;; From "ccl:examples;objc-window.lisp":
#+apple-objc
(defun enable-foreground ()
  (%stack-block ((psn 8))
    (external-call "_GetCurrentProcess" :address psn)
    (external-call "_CPSEnableForegroundOperation" :address psn)
    (eql 0 (external-call "_SetFrontProcess" :address psn :signed-halfword))))

I believe that it's likely that #_GetCurrentProcess and #_SetFrontProcess -
as well as a better-looking definition of the PSN structure - are probably
defined in Carbon headers.

>
> Unfortunately I can't find any reference to the function in any header
> file on my system (I guess I can't update the interface database in
> this case).

The last time that I did a Google search, I was (mildly) surprised
at how widely-used CPSEnableForegroundOperation was.  Some people
seem to have reverse-engineered it and concluded that it takes
additional mysterious arguments besides a PSN; I don't believe this
to be the case.

Among the applications/frameworks that use it (or did, the last time
that I looked) ar Java and GLUT.  I have no idea why it's a secret,
and suppose that it may disappear/gratuitously change in the future.
(In that latter respect, it's similar to many documented OSX functions.)

>
> Is there something obvious I'm missing, or something obscure I can try
> (to invoke the function)?


>
> -Duncan
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list