00001 /* $Xorg: EditresP.h,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */ 00002 00003 /* 00004 00005 Copyright 1989, 1998 The Open Group 00006 00007 Permission to use, copy, modify, distribute, and sell this software and its 00008 documentation for any purpose is hereby granted without fee, provided that 00009 the above copyright notice appear in all copies and that both that 00010 copyright notice and this permission notice appear in supporting 00011 documentation. 00012 00013 The above copyright notice and this permission notice shall be included in 00014 all copies or substantial portions of the Software. 00015 00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00022 00023 Except as contained in this notice, the name of The Open Group shall not be 00024 used in advertising or otherwise to promote the sale, use or other dealings 00025 in this Software without prior written authorization from The Open Group. 00026 00027 */ 00028 /* $XFree86: xc/lib/Xmu/EditresP.h,v 1.5 2001/01/17 19:42:55 dawes Exp $ */ 00029 00030 /* 00031 * Author: Chris D. Peterson, MIT X Consortium 00032 */ 00033 00034 /************************************************************ 00035 00036 The Editres Protocol 00037 00038 00039 The Client message sent to the application is: 00040 00041 ATOM = "ResEditor" --- RES_EDITOR_NAME 00042 00043 FORMAT = 32 --- RES_EDIT_SEND_EVENT_FORMAT 00044 00045 l[0] = timestamp 00046 l[1] = command atom name 00047 l[2] = ident of command 00048 l[3] = protocol version number to use 00049 00050 00051 00052 The binary protocol has the following format: 00053 00054 Card8: 8-bit unsingned integer 00055 Card16: 16-bit unsingned integer 00056 Card32: 32-bit unsingned integer 00057 Int16: 16-bit signed integer 00058 Window: 32-bit value 00059 Widget: 32-bit value 00060 String8: ListOfCard8 00061 00062 [a][b][c] represent an exclusive list of choices. 00063 00064 All widgets are passed as a list of widgets, containing the 00065 full instance heirarch of this widget. The hierarchy is ordered 00066 from parent to child. Thus the first element of each list is 00067 the root of the widget tree (this makes verifying that the widget 00068 still exists, MUCH faster). 00069 00070 ListOfFoo comprises a list of things in the following format: 00071 00072 number: Card16 00073 <number> things: ???? 00074 00075 This is a synchronous protocol, every request MUST be followed by a 00076 reply. 00077 00078 Request: 00079 00080 Serial Number: Card8 00081 Op Code: Card8 - { SendWidgetTree = 0, 00082 SetValues = 1, 00083 GetResources = 2, 00084 GetGeometry = 3, 00085 FindChild = 4, 00086 GetValues = 5 } 00087 Length: Card32 00088 Data: 00089 00090 Reply: 00091 00092 Serial Number: Card8 00093 Type: Card8 - { Formatted = 0, 00094 Unformatted = 1, 00095 ProtocolMismatch = 2 00096 } 00097 Length: Card32 00098 00099 00100 Byte Order: 00101 00102 All Fields are MSB -> LSB 00103 00104 Data: 00105 00106 Formatted: 00107 00108 The data contains the reply information for the request as 00109 specified below if the reply type is "Formatted". The return 00110 values for the other reply types are shown below. 00111 00112 Unformatted: 00113 00114 Message: String8 00115 00116 ProtocolMismatch: 00117 00118 RequestedVersion: Card8 00119 00120 ------------------------------------------------------------ 00121 00122 SendWidgetTree: 00123 00124 ---> 00125 00126 Number of Entries: Card16 00127 Entry: 00128 widget: ListOfWidgets 00129 name: String8 00130 class: String8 00131 window: Card32 00132 toolkit: String8 00133 00134 Send Widget Tree returns the toolkit type, and a fuly specified list 00135 of widgets for each widget in the tree. This is enough information 00136 to completely reconstruct the entire widget heirarchy. 00137 00138 The window return value contains the Xid of the window currently 00139 used by this widget. If the widget is unrealized then 0 is returned, 00140 and if widget is a non-windowed object a value of 2 is returned. 00141 00142 SetValues: 00143 00144 name: String8 00145 type: String8 00146 value: String8 00147 Number of Entries: Card16 00148 Entry: 00149 widget: ListOfWidgets 00150 00151 ---> 00152 00153 Number of Entries: Card16 00154 Entry: 00155 widget: ListOfWidgets 00156 message: String8 00157 00158 SetValues will allow the same resource to be set on a number of 00159 widgets. This function will return an error message if the SetValues 00160 request caused an Xt error. 00161 00162 GetValues: 00163 00164 names: ListOfString8 00165 widget: Widget 00166 00167 ---> 00168 novalues: ListOfCard16 00169 values: ListOfString8 00170 00171 GetValues will allow a number of resource values to be read 00172 on a particular widget. The request specifies the names of 00173 the resources wanted and the widget id these resources are 00174 from. The reply returns a list of indices from the requests 00175 name list of resources for which a value can not be returned. 00176 It also returns a list of returned values, in the order of the 00177 requests names list, skipping those indices present in novalues. 00178 00179 GetResources: 00180 00181 Number of Entries: Card16 00182 Entry 00183 widget: ListOfWidgets: 00184 00185 ----> 00186 00187 Number of Entries: Card16 00188 Entry 00189 Widget: ListOfWidgets: 00190 Error: Bool 00191 00192 [ Message: String 8 ] 00193 [ Number of Resources: Card16 00194 Resource: 00195 Kind: {normal, constraint} 00196 Name: String8 00197 Class: String8 00198 Type: String8 ] 00199 00200 GetResource retrieves the kind, name, class and type for every 00201 widget passed to it. If an error occured with the resource fetch 00202 Error will be set to True for the given widget and a message 00203 is returned rather than the resource info. 00204 00205 GetGeometry: 00206 00207 Number of Entries: Card16 00208 Entry 00209 Widget: ListOfWidgets: 00210 00211 ----> 00212 00213 Number of Entries: Card16 00214 Entry 00215 Widget: ListOfWidgets: 00216 Error: Bool 00217 00218 [ message: String 8 ] 00219 [ mapped: Boolean 00220 X: Int16 00221 Y: Int16 00222 Width: Card16 00223 Height: Card16 00224 BorderWidth: Card16 ] 00225 00226 GetGeometry retreives the mapping state, x, y, width, height 00227 and border width for each widget specified. If an error occured 00228 with the geometry fetch "Error" will be set to True for the given 00229 widget and a message is returned rather than the geometry info. 00230 X an Y corrospond to the root coordinates of the upper left corner 00231 of the widget (outside the window border). 00232 00233 FindChild: 00234 00235 Widget: ListOfWidgets 00236 X: Int16 00237 Y: Int16 00238 00239 ---> 00240 00241 Widget: ListOfWidgets 00242 00243 Find Child returns a descendent of the widget specified that 00244 is at the root coordinates specified. 00245 00246 NOTE: 00247 00248 The returned widget is undefined if the point is contained in 00249 two or more mapped widgets, or in two overlapping Rect objs. 00250 00251 GetValues: 00252 00253 names: ListOfString8 00254 widget: Widget 00255 00256 ---> 00257 00258 values: ListOfString8 00259 00260 GetValues will allow a number of resource values to be read 00261 on a particular widget. Currently only InterViews 3.0.1 Styles 00262 and their attributes are supported. In addition, the current 00263 user interface only supports the return of 1 resource. The ability 00264 to specify and return multiple resources is defined for future editres 00265 interfaces where some or all of a widgets resource values are returned 00266 and displayed at once. 00267 00268 00269 ************************************************************/ 00270 00271 #include <X11/Intrinsic.h> 00272 #include <X11/Xfuncproto.h> 00273 00274 #define XER_NBBY 8 /* number of bits in a byte */ 00275 #define BYTE_MASK 255 00276 00277 #define HEADER_SIZE 6 00278 00279 #define EDITRES_IS_OBJECT 2 00280 #define EDITRES_IS_UNREALIZED 0 00281 00282 /* 00283 * Format for atoms 00284 */ 00285 #define EDITRES_FORMAT 8 00286 #define EDITRES_SEND_EVENT_FORMAT 32 00287 00288 /* 00289 * Atoms 00290 */ 00291 #define EDITRES_NAME "Editres" 00292 #define EDITRES_COMMAND_ATOM "EditresCommand" 00293 #define EDITRES_COMM_ATOM "EditresComm" 00294 #define EDITRES_CLIENT_VALUE "EditresClientVal" 00295 #define EDITRES_PROTOCOL_ATOM "EditresProtocol" 00296 00297 typedef enum { 00298 SendWidgetTree = 0, 00299 SetValues = 1, 00300 GetResources = 2, 00301 GetGeometry = 3, 00302 FindChild = 4, 00303 GetValues = 5 00304 } EditresCommand; 00305 00306 typedef enum { 00307 NormalResource = 0, 00308 ConstraintResource = 1 00309 } ResourceType; 00310 00311 /* 00312 * The type of a resource identifier 00313 */ 00314 typedef unsigned char ResIdent; 00315 00316 typedef enum { 00317 PartialSuccess = 0, 00318 Failure = 1, 00319 ProtocolMismatch = 2 00320 } EditResError; 00321 00322 typedef struct _WidgetInfo { 00323 unsigned short num_widgets; 00324 unsigned long *ids; 00325 Widget real_widget; 00326 } WidgetInfo; 00327 00328 typedef struct _ProtocolStream { 00329 unsigned long size, alloc; 00330 unsigned char *real_top, *top, *current; 00331 } ProtocolStream; 00332 00333 /************************************************************ 00334 * Function definitions for reading and writing protocol requests 00335 ************************************************************/ 00336 _XFUNCPROTOBEGIN 00337 00338 void _XEditResPutString8 00339 ( 00340 ProtocolStream *stream, 00341 char *str 00342 ); 00343 00344 void _XEditResPut8 00345 ( 00346 ProtocolStream *stream, 00347 unsigned int value 00348 ); 00349 00350 void _XEditResPut16 00351 ( 00352 ProtocolStream *stream, 00353 unsigned int value 00354 ); 00355 00356 void _XEditResPut32 00357 ( 00358 ProtocolStream *stream, 00359 unsigned long value 00360 ); 00361 00362 void _XEditResPutWidgetInfo 00363 ( 00364 ProtocolStream *stream, 00365 WidgetInfo *info 00366 ); 00367 00368 void _XEditResResetStream 00369 ( 00370 ProtocolStream *stream 00371 ); 00372 00373 Bool _XEditResGet8 00374 ( 00375 ProtocolStream *stream, 00376 unsigned char *value 00377 ); 00378 00379 Bool _XEditResGet16 00380 ( 00381 ProtocolStream *stream, 00382 unsigned short *value 00383 ); 00384 00385 Bool _XEditResGetSigned16 00386 ( 00387 ProtocolStream *stream, 00388 short *value 00389 ); 00390 00391 Bool _XEditResGet32 00392 ( 00393 ProtocolStream *stream, 00394 unsigned long *value 00395 ); 00396 00397 Bool _XEditResGetString8 00398 ( 00399 ProtocolStream *stream, 00400 char **str 00401 ); 00402 00403 Bool _XEditResGetWidgetInfo 00404 ( 00405 ProtocolStream *stream, 00406 WidgetInfo *info 00407 ); 00408 00409 _XFUNCPROTOEND
1.5.1