1 /*
2  * quartz.h
3  *
4  * External interface of the Quartz display modes seen by the generic, mode
5  * independent parts of the Darwin X server.
6  *
7  * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
8  * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons.
9  *                 All Rights Reserved.
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  *
29  * Except as contained in this notice, the name(s) of the above copyright
30  * holders shall not be used in advertising or otherwise to promote the sale,
31  * use or other dealings in this Software without prior written authorization.
32  */
33 
34 #ifndef _QUARTZ_H
35 #define _QUARTZ_H
36 
37 #include <X11/Xdefs.h>
38 #include "privates.h"
39 
40 #include "screenint.h"
41 #include "window.h"
42 #include "pixmap.h"
43 
44 /*------------------------------------------
45    Quartz display mode function types
46    ------------------------------------------*/
47 
48 /*
49  * Display mode initialization
50  */
51 typedef void (*DisplayInitProc)(void);
52 typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen);
53 typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen);
54 typedef void (*InitInputProc)(int argc, char **argv);
55 
56 /*
57  * Cursor functions
58  */
59 typedef Bool (*InitCursorProc)(ScreenPtr pScreen);
60 
61 /*
62  * Suspend and resume X11 activity
63  */
64 typedef void (*SuspendScreenProc)(ScreenPtr pScreen);
65 typedef void (*ResumeScreenProc)(ScreenPtr pScreen);
66 
67 /*
68  * Screen state change support
69  */
70 typedef void (*AddPseudoramiXScreensProc)
71     (int *x, int *y, int *width, int *height, ScreenPtr pScreen);
72 typedef void (*UpdateScreenProc)(ScreenPtr pScreen);
73 
74 /*
75  * Rootless helper functions
76  */
77 typedef Bool (*IsX11WindowProc)(int windowNumber);
78 typedef void (*HideWindowsProc)(Bool hide);
79 
80 /*
81  * Rootless functions for optional export to GLX layer
82  */
83 typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create);
84 typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow);
85 typedef Bool (*CreateSurfaceProc)
86     (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
87     unsigned int client_id, unsigned int *surface_id,
88     unsigned int key[2], void (*notify)(void *arg, void *data),
89     void *notify_data);
90 typedef Bool (*DestroySurfaceProc)
91     (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
92     void (*notify)(void *arg, void *data), void *notify_data);
93 
94 /*
95  * Quartz display mode function list
96  */
97 typedef struct _QuartzModeProcs {
98     DisplayInitProc DisplayInit;
99     AddScreenProc AddScreen;
100     SetupScreenProc SetupScreen;
101     InitInputProc InitInput;
102 
103     InitCursorProc InitCursor;
104 
105     SuspendScreenProc SuspendScreen;
106     ResumeScreenProc ResumeScreen;
107 
108     AddPseudoramiXScreensProc AddPseudoramiXScreens;
109     UpdateScreenProc UpdateScreen;
110 
111     IsX11WindowProc IsX11Window;
112     HideWindowsProc HideWindows;
113 
114     FrameForWindowProc FrameForWindow;
115     TopLevelParentProc TopLevelParent;
116     CreateSurfaceProc CreateSurface;
117     DestroySurfaceProc DestroySurface;
118 } QuartzModeProcsRec, *QuartzModeProcsPtr;
119 
120 extern QuartzModeProcsPtr quartzProcs;
121 
122 extern Bool XQuartzFullscreenVisible; /* Are the windows visible (predicated on !rootless) */
123 extern Bool XQuartzServerVisible;     /* Is the server visible ... TODO: Refactor to "active" */
124 extern Bool XQuartzEnableKeyEquivalents;
125 extern Bool XQuartzRootlessDefault;  /* Is our default mode rootless? */
126 extern Bool XQuartzIsRootless;       /* Is our current mode rootless (or FS)? */
127 extern Bool XQuartzFullscreenMenu;   /* Show the menu bar (autohide) while in FS */
128 extern Bool XQuartzFullscreenDisableHotkeys;
129 extern Bool XQuartzOptionSendsAlt;   /* Alt or Mode_switch? */
130 
131 extern int32_t XQuartzShieldingWindowLevel; /* CGShieldingWindowLevel() or 0 */
132 
133 // Other shared data
134 extern DevPrivateKeyRec quartzScreenKeyRec;
135 #define quartzScreenKey (&quartzScreenKeyRec)
136 extern int aquaMenuBarHeight;
137 
138 // Name of GLX bundle for native OpenGL
139 extern const char      *quartzOpenGLBundle;
140 
141 Bool
142 QuartzAddScreen(int index, ScreenPtr pScreen);
143 Bool
144 QuartzSetupScreen(int index, ScreenPtr pScreen);
145 void
146 QuartzInitOutput(int argc, char **argv);
147 void
148 QuartzInitInput(int argc, char **argv);
149 void
150 QuartzInitServer(int argc, char **argv, char **envp);
151 void
152 QuartzGiveUp(void);
153 void
154 QuartzProcessEvent(xEvent *xe);
155 void
156 QuartzUpdateScreens(void);
157 
158 void
159 QuartzShow(void);
160 void
161 QuartzHide(void);
162 void
163 QuartzSetRootClip(int mode);
164 void
165 QuartzSpaceChanged(uint32_t space_id);
166 
167 void
168 QuartzSetRootless(Bool state);
169 void
170 QuartzShowFullscreen(Bool state);
171 
172 int
173 server_main(int argc, char **argv, char **envp);
174 #endif
175