dixstruct.h (6678B)
1 /*********************************************************** 2 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 3 4 All Rights Reserved 5 6 Permission to use, copy, modify, and distribute this software and its 7 documentation for any purpose and without fee is hereby granted, 8 provided that the above copyright notice appear in all copies and that 9 both that copyright notice and this permission notice appear in 10 supporting documentation, and that the name of Digital not be 11 used in advertising or publicity pertaining to distribution of the 12 software without specific, written prior permission. 13 14 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 15 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 16 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 17 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 18 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 19 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 20 SOFTWARE. 21 22 ******************************************************************/ 23 24 #ifndef DIXSTRUCT_H 25 #define DIXSTRUCT_H 26 27 #include "client.h" 28 #include "dix.h" 29 #include "resource.h" 30 #include "cursor.h" 31 #include "gc.h" 32 #include "pixmap.h" 33 #include "privates.h" 34 #include <X11/Xmd.h> 35 36 /* 37 * direct-mapped hash table, used by resource manager to store 38 * translation from client ids to server addresses. 39 */ 40 41 extern _X_EXPORT CallbackListPtr ClientStateCallback; 42 43 typedef struct { 44 ClientPtr client; 45 xConnSetupPrefix *prefix; 46 xConnSetup *setup; 47 } NewClientInfoRec; 48 49 typedef void (*ReplySwapPtr) (ClientPtr /* pClient */ , 50 int /* size */ , 51 void * /* pbuf */ ); 52 53 extern _X_EXPORT void 54 ReplyNotSwappd(ClientPtr /* pClient */ , 55 int /* size */ , 56 void * /* pbuf */ ) _X_NORETURN; 57 58 typedef enum { ClientStateInitial, 59 ClientStateRunning, 60 ClientStateRetained, 61 ClientStateGone 62 } ClientState; 63 64 typedef struct _saveSet { 65 struct _Window *windowPtr; 66 Bool toRoot; 67 Bool map; 68 } SaveSetElt; 69 #define SaveSetWindow(ss) ((ss).windowPtr) 70 #define SaveSetToRoot(ss) ((ss).toRoot) 71 #define SaveSetShouldMap(ss) ((ss).map) 72 #define SaveSetAssignWindow(ss,w) ((ss).windowPtr = (w)) 73 #define SaveSetAssignToRoot(ss,tr) ((ss).toRoot = (tr)) 74 #define SaveSetAssignMap(ss,m) ((ss).map = (m)) 75 76 typedef struct _Client { 77 void *requestBuffer; 78 void *osPrivate; /* for OS layer, including scheduler */ 79 struct xorg_list ready; /* List of clients ready to run */ 80 struct xorg_list output_pending; /* List of clients with output queued */ 81 Mask clientAsMask; 82 short index; 83 unsigned char majorOp, minorOp; 84 unsigned int swapped:1; 85 unsigned int local:1; 86 unsigned int big_requests:1; /* supports large requests */ 87 unsigned int clientGone:1; 88 unsigned int closeDownMode:2; 89 unsigned int clientState:2; 90 signed char smart_priority; 91 short noClientException; /* this client died or needs to be killed */ 92 int priority; 93 ReplySwapPtr pSwapReplyFunc; 94 XID errorValue; 95 int sequence; 96 int ignoreCount; /* count for Attend/IgnoreClient */ 97 int numSaved; 98 SaveSetElt *saveSet; 99 int (**requestVector) (ClientPtr /* pClient */ ); 100 CARD32 req_len; /* length of current request */ 101 unsigned int replyBytesRemaining; 102 PrivateRec *devPrivates; 103 unsigned short mapNotifyMask; 104 unsigned short newKeyboardNotifyMask; 105 unsigned char xkbClientFlags; 106 KeyCode minKC, maxKC; 107 108 int smart_start_tick; 109 int smart_stop_tick; 110 111 DeviceIntPtr clientPtr; 112 ClientIdPtr clientIds; 113 int req_fds; 114 } ClientRec; 115 116 static inline void 117 SetReqFds(ClientPtr client, int req_fds) { 118 if (client->req_fds != 0 && req_fds != client->req_fds) 119 LogMessage(X_ERROR, "Mismatching number of request fds %d != %d\n", req_fds, client->req_fds); 120 client->req_fds = req_fds; 121 } 122 123 /* 124 * Scheduling interface 125 */ 126 extern long SmartScheduleTime; 127 extern long SmartScheduleInterval; 128 extern long SmartScheduleSlice; 129 extern long SmartScheduleMaxSlice; 130 #ifdef HAVE_SETITIMER 131 extern Bool SmartScheduleSignalEnable; 132 #else 133 #define SmartScheduleSignalEnable FALSE 134 #endif 135 extern void SmartScheduleStartTimer(void); 136 extern void SmartScheduleStopTimer(void); 137 138 /* Client has requests queued or data on the network */ 139 void mark_client_ready(ClientPtr client); 140 141 /* 142 * Client has requests queued or data on the network, but awaits a 143 * server grab release 144 */ 145 void mark_client_saved_ready(ClientPtr client); 146 147 /* Client has no requests queued and no data on network */ 148 void mark_client_not_ready(ClientPtr client); 149 150 static inline Bool client_is_ready(ClientPtr client) 151 { 152 return !xorg_list_is_empty(&client->ready); 153 } 154 155 Bool 156 clients_are_ready(void); 157 158 extern struct xorg_list output_pending_clients; 159 160 static inline void 161 output_pending_mark(ClientPtr client) 162 { 163 if (!client->clientGone && xorg_list_is_empty(&client->output_pending)) 164 xorg_list_append(&client->output_pending, &output_pending_clients); 165 } 166 167 static inline void 168 output_pending_clear(ClientPtr client) 169 { 170 xorg_list_del(&client->output_pending); 171 } 172 173 static inline Bool any_output_pending(void) { 174 return !xorg_list_is_empty(&output_pending_clients); 175 } 176 177 #define SMART_MAX_PRIORITY (20) 178 #define SMART_MIN_PRIORITY (-20) 179 180 extern void SmartScheduleInit(void); 181 182 /* This prototype is used pervasively in Xext, dix */ 183 #define DISPATCH_PROC(func) int func(ClientPtr /* client */) 184 185 typedef struct _WorkQueue { 186 struct _WorkQueue *next; 187 Bool (*function) (ClientPtr /* pClient */ , 188 void * /* closure */ 189 ); 190 ClientPtr client; 191 void *closure; 192 } WorkQueueRec; 193 194 extern _X_EXPORT TimeStamp currentTime; 195 196 extern _X_EXPORT int 197 CompareTimeStamps(TimeStamp /*a */ , 198 TimeStamp /*b */ ); 199 200 extern _X_EXPORT TimeStamp 201 ClientTimeToServerTime(CARD32 /*c */ ); 202 203 typedef struct _CallbackRec { 204 CallbackProcPtr proc; 205 void *data; 206 Bool deleted; 207 struct _CallbackRec *next; 208 } CallbackRec, *CallbackPtr; 209 210 typedef struct _CallbackList { 211 int inCallback; 212 Bool deleted; 213 int numDeleted; 214 CallbackPtr list; 215 } CallbackListRec; 216 217 /* proc vectors */ 218 219 extern int (*InitialVector[3]) (ClientPtr /*client */ ); 220 221 extern _X_EXPORT int (*ProcVector[256]) (ClientPtr /*client */ ); 222 223 extern _X_EXPORT int (*SwappedProcVector[256]) (ClientPtr /*client */ ); 224 225 extern ReplySwapPtr ReplySwapVector[256]; 226 227 extern _X_EXPORT int 228 ProcBadRequest(ClientPtr /*client */ ); 229 230 #endif /* DIXSTRUCT_H */