[Xquartz-dev] Apple-WM usage

Jeremy Huddleston jeremyhu at apple.com
Sat Apr 12 17:24:14 PDT 2008


Hi,

Sorry it took so long for me to respond to you.  I see two things of  
note in your aw.c.

1) You don't need to getenv("DISPLAY")... this is handled for you  
automagically by XOpenDisplay(NULL).
2) You need to do an XFlush(dpy) at the end.

Here's a sample.  Please let me know if you have anything else crop up.

#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/applewm.h>

int main(void) {
     Display *dpy;
     int apple_wm_event_base, apple_wm_error_base;
     int major, minor, patch;

     dpy = XOpenDisplay(NULL);
     if(!dpy) {
         fprintf(stderr, "can't open the display.");
         exit(1);
     }

     if (!XAppleWMQueryExtension (dpy, &apple_wm_event_base,  
&apple_wm_error_base)) {
         fprintf (stderr, "can't open AppleWM server extension\n");
         exit (1);
     }
     printf("AppleWM event base: %d, error base: %d\n",  
apple_wm_event_base, apple_wm_error_base);

     XAppleWMQueryVersion(dpy, &major, &minor, &patch);
     printf("Server Version: major: %d, minor: %d, patch: %d\n",  
major, minor, patch);

     fprintf(stderr, "XAppleWMSetFrontProcess: %d\n",  
XAppleWMSetFrontProcess(dpy));
     XFlush(dpy);
     return 0;
}




On Apr 8, 2008, at 14:00, xquartz-dev.5.mzs at spamgourmet.com wrote:
> Hi,
>
> I have been investigating using a window manager other than quartz- 
> wm. There was a post to the Apple X11-users list about Apple-WM and  
> it sparked my curiousity. You can run 'man AppleWM' to see what I am  
> talking about.
>
> My idea was to patch an open source window manager so that it would  
> do the Apple-WM stuff optionally, so I started off by writing a  
> little program to do some Apple-WM stuff. It appears that few of the  
> routines I call have any effect sadly. I have attached the source  
> file wm.c as an example. It takes one option, the window id in hex  
> which you can learn from something like xwininfo or xlsclients:
>
> I have an .xinitrc that ends like so:
>
> quartz-wm --only-proxy &
> exec blackbox
>
> Then I run this:
>
> grief:AppleWM mzs$ gcc aw.c -o aw -L/usr/X11/lib -lX11 -lAppleWM - 
> DDEBUG
> grief:AppleWM mzs$ xterm &
> [1] 17560
> grief:AppleWM mzs$ xlsclients -l
> Window 0x20000d:
>  Machine:  grief.fnal.gov
>  Name:  xterm
>  Icon Name:  xterm
>  Command:  xterm
>  Instance/Class:  xterm/XTerm
> grief:AppleWM mzs$ ./aw 0x20000d
> strtoul(0x20000d, NULL, 16): 0x20000d
> XOpenDisplay(/tmp/launch-IbGgSt/:0): 0x800000
> XAppleWMQueryExtension: 1
> event base: 68, error base: 130
> XAppleWMQueryVersion: 1
> major: 1, minor 0, patch 0
> True = 1, False = 0
> XAppleWMSetCanQuit(dpy, False): 1
> XAppleWMSetFrontProcess(dpy): 1
> XAppleWMSetWindowLevel(dpy, window, 0): 1
> XAppleWMSetFrontProcess(dpy): 1
> XAppleWMSetWindowLevel(dpy, window, 0): 1
>
> Even though all those are returning 'True' XAppleWMSetCanQuit,  
> XAppleWMSetFrontProcess, and XAppleWMSetWindowLevel appear to nat  
> have any effect.
>
> An example of the rationale for doing this is so:
>
> For example you would like X11.app to pop-up a dialog box asking you  
> to verify that you indeed wish to quit. So when you start-up your  
> X11 session would like to do the XAppleWMSetCanQuit function.
>
> There are lots of other places the window manager would like to do  
> other Apple-WM specific things.
>
> I have also tried to compile aw.c with -framework AppKit with no  
> difference in behavior. Is there something I am doing wrong? Does it  
> have to be the actual window manager that calls these? What is the  
> future of Apple-WM?
>
> I wanted to see if Apple-WM was actually being used, so I created  
> inter.c which I have attached also. There is a comment at the  
> beginning of the source file that explains how I used it. I see in  
> the log file that XAppleWMSetCanQuit is being used by quartz-wm:
>
> -[x_screen update_geometry]
> -[x_screen update_geometry]: head 0: 0,22 1680x1028
> -[x_screen update_geometry]: head 1: 1680,0 1280x1024
> -[x_screen update_geometry]: main head has index 0
> -[x_screen init_with_screen_id:]: 0, 2960x1050x24, root:44, 2 heads
> -[x_screen adopt_window:initializing:]: 20000d
> -[x_window init_with_id:screen:initializing:]: 20000d
> -[x_window reparent_in]: 20000d
> -[x_window update_shape:]: 20000d
> -[x_window update_inner_windows:outer:inner:]: 20000d
> -[x_window send_configure]: 20000d
> -[x_window focus:raise:force:]: 20000d
> XAppleWMSetCanQuit = 0x0x032780
> XAppleWMFrameDraw = 0x0x031790
> XAppleWMSetCanQuit: 0x810c00, 0
> ...
>
> There is a bunch of Notify stuff with window 44 though, I wonder if  
> that has something to do with the use of AppleWM?
>
> Oh I am currently running the more recent release candidate (rc2)  
> and there is that bug in this one where the Windows do not come  
> forward until the dock icon is clicked twice. Possibly quartx-wm is  
> not doing the XAppleWMSetWindowLevel stuff correctly itself.
>
> What I was planning on doing was patching blackbox so that it would  
> work better in rootless mode on OS X. For example the aforementioned  
> XAppleWMSetCanQuit. Also behavior such as this:
>
> When I click on an X11 window in the background it gets focus and  
> comes to the foreground.
>
> When I hold down a modifier and drag an X11 window in the background  
> it gets focus and moves around but does not come to the forground.
>
> etc...
>
> I was hoping to ge this to work with the aid of Apple-WM but am  
> having trouble getting it to do anything at all at this point and  
> would really appreciate any helpful ideas.
>
> Thanks,
> mzs
> <aw.c><inter.c>_______________________________________________
> Xquartz-dev mailing list
> Xquartz-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo/xquartz-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3221 bytes
Desc: not available
Url : http://lists.macosforge.org/pipermail/xquartz-dev/attachments/20080412/3017d81f/smime-0001.bin


More information about the Xquartz-dev mailing list