1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3                   "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
4[
5<!ENTITY % defs SYSTEM "defs.ent"> %defs;
6]>
7
8
9<article id="appgroup">
10
11<articleinfo>
12   <title>Description of the Application Group Extension</title>
13   <subtitle>Implementation for the X11 Sample Server</subtitle>
14   <authorgroup>
15      <author>
16         <firstname>Kaleb </firstname><surname>KEITHLEY</surname>
17         <affiliation><orgname>FUJITSU Limited.</orgname></affiliation>
18      </author>
19   </authorgroup>
20   <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo>
21   <releaseinfo>Version 1.0</releaseinfo>
22   <copyright><year>1996</year><holder>X Consortium</holder></copyright>
23
24<legalnotice>
25<para>
26Permission is hereby granted, free of charge, to any person obtaining a copy
27of this software and associated documentation files (the "Software"), to deal
28in the Software without restriction, including without limitation the rights
29to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
30copies of the Software, and to permit persons to whom the Software is
31furnished to do so, subject to the following conditions:
32</para>
33
34<para>
35The above copyright notice and this permission notice shall be included in
36all copies or substantial portions of the Software.
37</para>
38
39<para>
40THE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
43X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
44AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
45CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46</para>
47
48<para>
49Except as contained in this notice, the name of the X Consortium shall
50not be used in advertising or otherwise to promote the sale, use or
51other dealings in this Software without prior written authorization
52from the X Consortium.
53</para>
54<para>X Window System is a trademark of The Open Group.</para>
55</legalnotice>
56
57<legalnotice>
58<para>WindowsNT is a trademark of Microsoft, Inc.</para>
59<para>Macintosh and Apple are trademarks of Apple Computer, Inc.</para>
60</legalnotice>
61
62<abstract>
63<para>
64The following document explains the server side of the Application
65Group Extension.
66</para>
67</abstract>
68
69</articleinfo>
70
71<para>
72To understand this document and the accompanying source code, you
73should know the C language, should be familiar with X server
74internals, and should also have a general knowledge of the X
75Window System.
76</para>
77
78<sect1 id="AppGroup_Server_Public_Functions">
79<title>AppGroup Server Public Functions</title>
80<para>
81The AppGroup extension adds seven new functions that are called
82from elsewhere in the server. They are: XagExtensionInit,
83XagDefaultColormap, XagRootVisual, XagLeader, XagIsControlledRoot,
84XagConnectionInfo, XagCallClientStateChange.
85</para>
86<para>
87XagExtensionInit is the extension initialization function called
88from InitExtension in mi/miinitext.c. Note that an new resource
89type, RT_APPGROUP, is created, specifying the destructor function
90XagAppGroupFree.
91</para>
92<para>
93XagDefaultColormap returns the colormap ID that was specified in
94the creation of the AppGroup. Any time CopyFromParent is specified
95for a top-level window's colormap, i.e. in a CreateWindow or
96ChangeWindowAttributes request, this function is called to see
97if there is an AppGroup specific colormap to use. If there is
98one, its ID is returned, otherwise None is returned.
99</para>
100<para>
101XagRootVisual returns the visual ID that was specified in the
102creation of the Appgroup. Like XagDefaultColormap, when CopyFromParent
103is specified for a top-level window's visual in a CreateWindow
104request, this function is called to see if there is an AppGroup
105specific visual to use. If there is one, its ID is returned,
106otherwise 0 (zero) is returned.
107</para>
108<para>
109XagLeader returns the ClientPtr of the client that is the AppGroup
110Leader. Normally when an application maps or configures a top-level
111window a MapRequest or ConfigureRequest event is delivered to the
112client, e.g. a window manager, that has selected SubstructureRedirect
113on the root window. However, when the application is part of an
114AppGroup, the MapRequest and ConfigureRequest events are delivered
115to the AppGroup Leader instead.
116</para>
117<para>
118XagIsControlledRoot returns a boolean: True if the window is a
119top-level window of a client in an AppGroup, False otherwise.
120In a combined server, i.e. one that provides both UI and printing,
121the application may create and map windows on the "printing"
122screens; thus it becomes necessary to discriminate between the
123AppGroup's root window and other root windows. If an AppGroup
124member creates and maps a [top-level] window then the window's
125parent [the root window] is tested to determine whether to send
126MapRequest or ConfigureRequest events to the AppGroup Leader to
127to some other client.
128</para>
129<para>
130In the trivial case XagIsControlledRoot returns True if the parent
131window has no parent itself, i.e. it is a root window. In the case
132where the application is embedded, indicated by the singleScreen
133attribute being True, the parent's drawable ID is compared to the
134AppGroup's root window ID, and if it is the same, True is returned.
135If neither case is true, then False is returned.
136</para>
137<para>
138XagConnectionInfo returns an abbreviated version of the connection
139setup information. When an embedded AppGroup is created the server
140returns only the information about the [UI] screen that the
141application is embedded within in the connection setup in order to
142prevent the application from creating windows on other screens;
143thus attempting to guarantee that any window that should be embedded
144can be reparented into the AppGroup Leader's window hierarchy.
145</para>
146<para>
147XagCallClientStateChange is called to invoke the extension's client
148state change callback additional times as necessary -- currently
149only once, after the auth data becomes available between
150ClientStateInitial and ClientStateConnected. Client state change
151callbacks were introduced in the Record extension, which specifies
152when the callbacks are invoked. Unfortunately the points at which
153they are called are not necessarily the best as far as the AppGroup
154Extension is concerned. Adding an additional state and calling all
155the callbacks works too, however this seemed unnecessary overkill.
156</para>
157</sect1>
158
159<sect1 id="AppGroup_Server_Private_APIs">
160<title>AppGroup Server Private APIs</title>
161<para>
162The AppGroup extension adds the following functions which are
163private to the extension: ProcXagDispatch and SProcXagDispatch,
164ProcXagQueryVersion and SProcXagQueryVersion, ProcXagCreate and
165SProcXagCreate, ProcXagDestroy and SProcXagDestroy,
166ProcGetAttr and SProcGetAttr, ProcXagQuery and SProcXagQuery,
167ProcXagCreateAssoc and SProcXagCreateAssoc, ProcXagDestroyAssoc
168and SProcXagDestroyAssoc, XagResetProc, and XagAppGroupFree.
169</para>
170<para>
171The ProcXagDispatch, SProcXagDispatch, and XagResetProc functions
172should be familiar to anyone familiar with X server internals and
173I won't elaborate on them here. Similarly the wrapper functions:
174SProcXagQueryVersion, SProcXagCreate, SProcXagDestroy, SProcXagGetAttr,
175SProcXagQuery, SProcXagCreateAssoc, and SProcXagDestroyAssoc, as
176wrappers which handle swapping integer data into the host's byte
177order will not be explained in any detail.
178</para>
179<para>
180ProcXagQueryVersion returns the major and minor versions of the
181AppGroup extension supported by the server.
182</para>
183<para>
184ProcXagCreate creates an AppGroup. A new record in a linked list
185of AppGroups is allocated and initialized. The attributes from the
186request are validated and copied to the AppGroup record. If necessary
187an abbreviated version of the connection setup information is compiled
188and also stored in the AppGroup record. The first time an AppGroup
189is created a client-state-change callback is registered and a
190reference count is incremented.
191</para>
192<para>
193ProcXagDestroy destroys an AppGroup an AppGroup by calling
194FreeResource specifying the AppGroup ID. This will result in
195the destructor function XagAppGroupFree being called. The
196reference count is decremented and when it reaches zero the
197client-state-change callback is deleted.
198</para>
199<para>
200ProcXagGetAttr returns the AppGroup Attributes to the requesting
201client.
202</para>
203<para>
204ProcXagQuery returns the AppGroup ID of an arbitrary resource to
205the requesting client.
206</para>
207<para>
208ProcXagCreateAssoc creates an association between an X window ID
209and system-specific data. In native X this functionality is
210unnecessary but for various personal computers, e.g. Macintosh,
211OS/2, and MS-Windows it is necessary to associate an X window ID
212with the system's native window identifier so that when the
213AppGroup Leader issues a ReparentWindow request the personal
214computer X server can lookup the system-specific window ID and
215make the necessary function call(s) with it.
216</para>
217<para>
218ProcXagDestroyAssoc destroys the association created with
219ProcXagCreateAssoc.
220</para>
221<para>
222XagResetProc removes the client-state-change callback, sets the
223reference count to zero, and frees all the AppGroup records in
224the linked list by calling XagAppGroupFree.
225</para>
226<para>
227XagAppGroupFree calls CloseDownClient for each client in an
228AppGroup if the AppGroup has a leader, unlinks the AppGroup
229record from the linked list, frees allocated memory referenced
230by the record, and finally frees the record itself.
231</para>
232</sect1>
233
234<sect1 id='Known_Problems_in_this_release'>
235<title>Known Problems in this release.</title>
236<para>
237In a combined UI/Print server the connection setup returned to an
238embedded application will not have information about the print
239screens.
240</para>
241<para>
242The LBX proxy caches connection setup information and will return
243incorrect connection setup information to an embedded client.
244</para>
245</sect1>
246</article>
247