First import
[xorg_rtime.git] / xorg-server-1.4 / hw / darwin / quartz / cr / crAppleWM.m
blob0741d4e58bd3cecfa63b5c4c6336369a280020b5
1 /*
2  * Cocoa rootless implementation functions for AppleWM extension
3  */
4 /*
5  * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  * Except as contained in this notice, the name(s) of the above copyright
26  * holders shall not be used in advertising or otherwise to promote the sale,
27  * use or other dealings in this Software without prior written authorization.
28  */
29 /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2003/06/30 01:45:13 torrey Exp $ */
30 #ifdef HAVE_XORG_CONFIG_H
31 #include <xorg-config.h>
32 #endif
33 #include "quartz/quartzCommon.h"
34 #include "quartz/cr/cr.h"
36 #undef BOOL
37 #define BOOL xBOOL
38 #include "rootless.h"
39 #include "X11/X.h"
40 #define _APPLEWM_SERVER_
41 #include "X11/extensions/applewm.h"
42 #include "quartz/applewmExt.h"
43 #undef BOOL
45 #define StdDocumentStyleMask (NSTitledWindowMask | \
46                               NSClosableWindowMask | \
47                               NSMiniaturizableWindowMask | \
48                               NSResizableWindowMask)
50 static int
51 CRDisableUpdate(void)
53     return Success;
57 static int
58 CREnableUpdate(void)
60     return Success;
64 static int CRSetWindowLevel(
65     WindowPtr pWin,
66     int level)
68     CRWindowPtr crWinPtr;
70     crWinPtr = (CRWindowPtr) RootlessFrameForWindow(pWin, TRUE);
71     if (crWinPtr == 0)
72         return BadWindow;
74     RootlessStopDrawing(pWin, FALSE);
76     [crWinPtr->window setLevel:level];
78     return Success;
82 static int CRFrameGetRect(
83     int type,
84     int class,
85     const BoxRec *outer,
86     const BoxRec *inner,
87     BoxRec *ret)
89     return Success;
93 static int CRFrameHitTest(
94     int class,
95     int x,
96     int y,
97     const BoxRec *outer,
98     const BoxRec *inner,
99     int *ret)
101     return 0;
105 static int CRFrameDraw(
106     WindowPtr pWin,
107     int class,
108     unsigned int attr,
109     const BoxRec *outer,
110     const BoxRec *inner,
111     unsigned int title_len,
112     const unsigned char *title_bytes)
114     CRWindowPtr crWinPtr;
115     NSWindow *window;
116     Bool hasResizeIndicator;
118     /* We assume the window has not yet been framed so
119        RootlessFrameForWindow() will cause it to be. Record the window
120        style so that the appropriate one will be used when it is framed.
121        If the window is already framed, we can't change the window
122        style and the following will have no effect. */
124     nextWindowToFrame = pWin;
125     if (class == AppleWMFrameClassDocument)
126         nextWindowStyle = StdDocumentStyleMask;
127     else
128         nextWindowStyle = NSBorderlessWindowMask;
130     crWinPtr = (CRWindowPtr) RootlessFrameForWindow(pWin, TRUE);
131     if (crWinPtr == 0)
132         return BadWindow;
134     window = crWinPtr->window;
136     [window setTitle:[NSString stringWithCString:title_bytes
137                                length:title_len]];
139     hasResizeIndicator = (attr & AppleWMFrameGrowBox) ? YES : NO;
140     [window setShowsResizeIndicator:hasResizeIndicator];
142     return Success;
146 static AppleWMProcsRec crAppleWMProcs = {
147     CRDisableUpdate,
148     CREnableUpdate,
149     CRSetWindowLevel,
150     CRFrameGetRect,
151     CRFrameHitTest,
152     CRFrameDraw
156 void CRAppleWMInit(void)
158     AppleWMExtensionInit(&crAppleWMProcs);