Table of Contents


AppleWM - Apple rootless window management extension.


#include <X11/extensions/applewm.h>
Bool XAppleWMQueryExtension (Display *dpy, 
        int *event_basep, int *error_basep);

Status XAppleWMQueryVersion (Display *dpy,
        int *major_versionp, int *minor_versionp);

Bool XAppleWMDisableUpdate (Display *dpy, int screen);

Bool XAppleWMReenableUpdate (Display *dpy, int screen);

Bool XAppleWMSelectInput (Display *dpy, unsigned long mask);

Bool XAppleWMSetWindowMenu (Display *dpy, int nitems,
        const char **items);

Bool XAppleWMSetWindowMenuWithShortcuts (Display *dpy,
        int nitems, const char **items,
        const char *shortcuts);

Bool XAppleWMSetWindowMenuCheck (Display *dpy, int index);

Bool XAppleWMSetFrontProcess (Display *dpy);

Bool XAppleWMSetWindowLevel (Display *dpy, Window window,
        int level);

Bool XAppleWMSetCanQuit (Display *dpy, Bool state);

Bool XAppleWMFrameGetRect (Display *dpy,
        unsigned int frame_class,
        unsigned int frame_rect,
        short inner_x, short inner_y,
        short inner_w, short inner_h,
        short outer_x, short outer_y,
        short outer_w, short outer_h,
        short *ret_x, short *ret_y,
        short *ret_w, short *ret_h);

unsigned int XAppleWMFrameHitTest (Display *dpy,
        unsigned int frame_class,
        short point_x, short point_y,
        short inner_x, short inner_y,
        short inner_w, short inner_h,
        short outer_x, short outer_y,
        short outer_w, short outer_h);

Bool XAppleWMFrameDraw (Display *dpy, int screen,
        Window window,
        unsigned int frame_class,
        unsigned int frame_attr,
        short inner_x, short inner_y,
        short inner_w, short inner_h,
        short outer_x, short outer_y,
        short outer_w, short outer_h,
        unsigned int title_length,
        const unsigned char *title_bytes);


Specifies the connection to the X server.

Specifies which screen.

Mask of event types the client is interested in.

Specifies which window.

Specifies the window level.

Specifies the class of window frame decoration.

Specifies which rectangle to return from the window frame decoration.

A mask specifying the attributes of the window frame decoration.

Rectangle of the window content inside the window frame decoration.

Rectangle of the outer border of the window frame decoration.

Specifies the coordinates of the mouse up event.



typedef struct {
    int type;               /* of event */
    unsigned long serial;   /* # of last request processed by server */
    Bool send_event;        /* true if came from a SendEvent request */
    Display *display;       /* Display the event was read from */
    Window window;          /* window of event */
    Time time;              /* server timestamp when event happened */
    int kind;               /* subtype of event */
    int arg;
} XAppleWMNotifyEvent;
XAppleWMNotifyEvent is sent to a client who has requested notification of AppleWM events with XAppleWMSelectInput.

Event types:

#define AppleWMControllerNotify               0
#define AppleWMActivationNotify               1
#define AppleWMPasteboardNotify               2

Event masks:

#define AppleWMControllerNotifyMask           (1L << 0)
#define AppleWMActivationNotifyMask           (1L << 1)
#define AppleWMPasteboardNotifyMask           (1L << 2)

Kinds of ControllerNotify events:

#define AppleWMMinimizeWindow                 0
#define AppleWMZoomWindow                     1
#define AppleWMCloseWindow                    2
#define AppleWMBringAllToFront                3
#define AppleWMHideWindow                     4
#define AppleWMHideAll                        5
#define AppleWMShowAll                        6
#define AppleWMWindowMenuItem                 9
#define AppleWMWindowMenuNotify               10
#define AppleWMNextWindow                     11
#define AppleWMPreviousWindow                 12

Kinds of ActivationNotify events:

#define AppleWMIsActive                       0
#define AppleWMIsInactive                     1

Kinds of PasteboardNotify events:

#define AppleWMCopyToPasteboard               0

Window Parameters

Window level ids for XAppleWMSetWindowLevel:

#define AppleWMWindowLevelNormal              0
#define AppleWMWindowLevelFloating            1
#define AppleWMWindowLevelTornOff             2
#define AppleWMWindowLevelDock                3
#define AppleWMWindowLevelDesktop             4
#define AppleWMNumWindowLevels                5

Values for frame_rect argument to XAppleWMFrameGetRect:

#define AppleWMFrameRectTitleBar              1
#define AppleWMFrameRectTracking              2
#define AppleWMFrameRectGrowBox               3

Window frame classes:

#define AppleWMFrameClassDocument             1 << 0
#define AppleWMFrameClassDialog               1 << 1
#define AppleWMFrameClassModalDialog          1 << 2
#define AppleWMFrameClassSystemModalDialog    1 << 3
#define AppleWMFrameClassUtility              1 << 4
#define AppleWMFrameClassToolbar              1 << 5
#define AppleWMFrameClassMenu                 1 << 6
#define AppleWMFrameClassSplash               1 << 7
#define AppleWMFrameClassBorderless           1 << 8

Window frame attributes:

#define AppleWMFrameActive                    0x0001
#define AppleWMFrameUrgent                    0x0002
#define AppleWMFrameTitle                     0x0004
#define AppleWMFramePrelight                  0x0008
#define AppleWMFrameShaded                    0x0010
#define AppleWMFrameCloseBox                  0x0100
#define AppleWMFrameCollapseBox               0x0200
#define AppleWMFrameZoomBox                   0x0400
#define AppleWMFrameAnyBox                    0x0700
#define AppleWMFrameCloseBoxClicked           0x0800
#define AppleWMFrameCollapseBoxClicked        0x1000
#define AppleWMFrameZoomBoxClicked            0x2000
#define AppleWMFrameAnyBoxClicked             0x3800
#define AppleWMFrameGrowBox                   0x4000


AppleWM is a simple library designed to interface with the Apple-WM extension. This extension allows X window managers to better interact with the Mac OS X Aqua user interface when running X11 in a rootless mode.

A more complete description will be forthcoming eventually.


XAppleWMDisableUpdate causes any updates to the windows on the screen to be queued until updates are reenabled with XAppleWMReenableUpdate. This is useful to avoid intermediate redraws to the screen if a number of changes are going to be made at once. Updates should only be disabled temporarily while drawing to a window. These calls may be nested and each call to XAppleWMDisableUpdate must be paired with a subsequent call to XAppleWMReenableUpdate. Updating is not reenabled until the last unnested call to XAppleWMReenableUpdate. Disabling updates applies to window content; however, it is implementation dependent whether window size and position changes are disabled as well.

XAppleWMSelectInput is used to request that a client receive notification of the AppleWM events listed above. The event mask specifies the event types the client is interested in receiving. Passing an event mask of 0 stops notification of events.

XAppleWMSetWindowMenu and XAppleWMSetWindowMenuWithShortcuts set the list of windows displayed in the X server's "Window" menu in the Aqua menu bar. Other items may be listed in this menu by the X server, but a part of this menu is set aside for use by the Apple-WM extension. This is intended to be used to set a list of important top-level X11 windows.

One item of the X server's "Window" menu can have a checkmark beside it to indicate it is the active or front most window. XAppleWMSetWindowMenuCheck can be used to set the item number to put a checkmark beside.

XAppleWMSetFrontProcess directs the X server to make itself the front most application among all the other Mac OS X applications. This causes X11 windows to move above other applications' windows and for the X server to start receiving keyboard and mouse events.

Windows can be placed into different Aqua window levels with XAppleWMSetWindowLevel. The stacking of window levels takes precedence over the stacking of windows within a level. Thus the bottom window in a level will obscure even the top most window of a lower window level. By default all windows are placed in the lowest window level, AppleWMWindowLevelNormal. When a window is moved to a new level, it is ordered in front of all of its peers at the new level. Note, X11 does not have the concept of window levels and this function does not change the X11 window order. The result of trying to reorder an X11 window above another window of higher level is undefined. This should probably be changed.

By default, the X server will ask for confirmation whenever the user requests that it quit from the Aqua UI. XAppleWMSetCanQuit can be used to change this behavior. If a state of TRUE is passed, the X server will quit without confirmation when requested. If FALSE is passed, the default behavior is used.

XAppleWMFrameDraw can be used to decorate a top-level window with the standard Aqua window frame and widgets. The frame_class controls the overall look of the window frame and frame_attr specifies the details of how the various UI elements should be drawn. The dimensions of the X11 window content are passed as the inner_* rectangle and the dimensions of the Aqua window frame are passed as the outer_* rectangle. XAppleWMFrameGetRect is used to calculate the size of the outer rectangle from the size of the window content, which is being reparented.

XAppleWMFrameGetRect returns a rectangle that encloses an element of the window frame decoration. The frame_rect argument specifies the element of interest. The inner_* and outer_* rectangles (as described above) specify the window geometry. If AppleWMFrameRectTitleBar is passed for frame_rect, the inner_* parameters are ignored. The returned rectangle has the dimensions of the outer_* rectangle except that its height is equal to the constant title bar height for the specified frame_class. The proper outer rectangle for a given window content size is the union of inner rectangle and the title bar rectangle. The AppleWMFrameRectTracking and AppleWMFrameRectGrowBox rectangles are primarily intended to be used by the window manager to determine the correct placement for child windows to receive events. The tracking rectangle is the area of the window containing the close, collapse and zoom boxes. Typically when the cursor is over this area, the window manager will highlight the close, collapse, and zoom buttons to conform to the standard Aqua interface.

If a mouse up or down event is received in the tracking rectangle, XAppleWMFrameHitTest is used to determine which button was clicked. XAppleWMFrameHitTest returns AppleWMFrameCloseBox, AppleWMFrameCollapseBox, or AppleWMFrameZoomBox to indicate which button was clicked. If no button was clicked, 0 will be returned.

Other functions include: XAppleWMQueryExtension, which returns the event and error base codes and XAppleWMQueryVersion, which returns the current version of the extension. (This information is cached by the library.)


AppleWM is only intended to be used on Mac OS X when running a rootless X server.

Table of Contents