imEvToWire.c revision e9fcaa8a
1/*********************************************************** 2Copyright 1993 by Digital Equipment Corporation, Maynard, Massachusetts, 3 4 All Rights Reserved 5 6Permission to use, copy, modify, and distribute this software and its 7documentation for any purpose and without fee is hereby granted, 8provided that the above copyright notice appear in all copies and that 9both that copyright notice and this permission notice appear in 10supporting documentation, and that the name of Digital not be 11used in advertising or publicity pertaining to distribution of the 12software without specific, written prior permission. 13 14DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 15ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 16DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 17ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 18WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 19ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 20SOFTWARE. 21 22******************************************************************/ 23 24#ifdef HAVE_CONFIG_H 25#include <config.h> 26#endif 27#include <X11/Xlibint.h> 28#include <X11/Xlib.h> 29#include "Ximint.h" 30 31 32#define sw16(n, s) ((s) ? \ 33 (((n) << 8 & 0xff00) | \ 34 ((n) >> 8 & 0xff) \ 35 ) : n) 36 37#define sw32(n, s) ((s) ? \ 38 (((n) << 24 & 0xff000000) | \ 39 ((n) << 8 & 0xff0000) | \ 40 ((n) >> 8 & 0xff00) | \ 41 ((n) >> 24 & 0xff) \ 42 ) : n) 43 44Status 45_XimProtoEventToWire( 46 register XEvent *re, /* pointer to where event should be reformatted */ 47 register xEvent *event, /* wire protocol event */ 48 Bool sw) /* swap byte? */ 49{ 50 switch (event->u.u.type = re->type) { 51 case KeyPress: 52 case KeyRelease: 53 { 54 register XKeyEvent *ev = (XKeyEvent*) re; 55 event->u.keyButtonPointer.root = sw32(ev->root, sw); 56 event->u.keyButtonPointer.event = 57 sw32(ev->window, sw); 58 event->u.keyButtonPointer.child = 59 sw32(ev->subwindow, sw); 60 event->u.keyButtonPointer.time = sw32(ev->time, sw); 61 event->u.keyButtonPointer.eventX = sw16(ev->x, sw) ; 62 event->u.keyButtonPointer.eventY = sw16(ev->y, sw) ; 63 event->u.keyButtonPointer.rootX = 64 sw16(ev->x_root, sw); 65 event->u.keyButtonPointer.rootY = 66 sw16(ev->y_root, sw); 67 event->u.keyButtonPointer.state = sw16(ev->state, sw); 68 event->u.keyButtonPointer.sameScreen = ev->same_screen; 69 event->u.u.detail = ev->keycode; 70 } 71 break; 72 case ButtonPress: 73 case ButtonRelease: 74 { 75 register XButtonEvent *ev = (XButtonEvent *) re; 76 event->u.keyButtonPointer.root = sw32(ev->root, sw); 77 event->u.keyButtonPointer.event = sw32(ev->window, sw); 78 event->u.keyButtonPointer.child = sw32(ev->subwindow, sw); 79 event->u.keyButtonPointer.time = sw32(ev->time, sw); 80 event->u.keyButtonPointer.eventX = sw16(ev->x, sw); 81 event->u.keyButtonPointer.eventY = sw16(ev->y, sw); 82 event->u.keyButtonPointer.rootX = sw16(ev->x_root, sw); 83 event->u.keyButtonPointer.rootY = sw16(ev->y_root, sw); 84 event->u.keyButtonPointer.state = sw16(ev->state, sw); 85 event->u.keyButtonPointer.sameScreen = ev->same_screen; 86 event->u.u.detail = ev->button; 87 } 88 break; 89 case MotionNotify: 90 { 91 register XMotionEvent *ev = (XMotionEvent *)re; 92 event->u.keyButtonPointer.root = sw32(ev->root, sw); 93 event->u.keyButtonPointer.event = sw32(ev->window, sw); 94 event->u.keyButtonPointer.child = sw32(ev->subwindow, sw); 95 event->u.keyButtonPointer.time = sw32(ev->time, sw); 96 event->u.keyButtonPointer.eventX= sw16(ev->x, sw); 97 event->u.keyButtonPointer.eventY= sw16(ev->y, sw); 98 event->u.keyButtonPointer.rootX = sw16(ev->x_root, sw); 99 event->u.keyButtonPointer.rootY = sw16(ev->y_root, sw); 100 event->u.keyButtonPointer.state = sw16(ev->state, sw); 101 event->u.keyButtonPointer.sameScreen= ev->same_screen; 102 event->u.u.detail = ev->is_hint; 103 } 104 break; 105 case EnterNotify: 106 case LeaveNotify: 107 { 108 register XCrossingEvent *ev = (XCrossingEvent *) re; 109 event->u.enterLeave.root = sw32(ev->root, sw); 110 event->u.enterLeave.event = sw32(ev->window, sw); 111 event->u.enterLeave.child = sw32(ev->subwindow, sw); 112 event->u.enterLeave.time = sw32(ev->time, sw); 113 event->u.enterLeave.eventX = sw16(ev->x, sw); 114 event->u.enterLeave.eventY = sw16(ev->y, sw); 115 event->u.enterLeave.rootX = sw16(ev->x_root, sw); 116 event->u.enterLeave.rootY = sw16(ev->y_root, sw); 117 event->u.enterLeave.state = sw16(ev->state, sw); 118 event->u.enterLeave.mode = ev->mode; 119 event->u.enterLeave.flags = 0; 120 if (ev->same_screen) { 121 event->u.enterLeave.flags |= ELFlagSameScreen; 122 } 123 if (ev->focus) { 124 event->u.enterLeave.flags |= ELFlagFocus; 125 } 126 event->u.u.detail = ev->detail; 127 } 128 break; 129 case FocusIn: 130 case FocusOut: 131 { 132 register XFocusChangeEvent *ev = (XFocusChangeEvent *) re; 133 event->u.focus.window = sw32(ev->window, sw); 134 event->u.focus.mode = ev->mode; 135 event->u.u.detail = ev->detail; 136 } 137 break; 138 case KeymapNotify: 139 { 140 register XKeymapEvent *ev = (XKeymapEvent *) re; 141 memcpy((char *)(((xKeymapEvent *) event)->map), 142 &ev->key_vector[1], 143 sizeof (((xKeymapEvent *) event)->map)); 144 } 145 break; 146 case Expose: 147 { 148 register XExposeEvent *ev = (XExposeEvent *) re; 149 event->u.expose.window = sw32(ev->window, sw); 150 event->u.expose.x = sw16(ev->x, sw); 151 event->u.expose.y = sw16(ev->y, sw); 152 event->u.expose.width = sw16(ev->width, sw); 153 event->u.expose.height = sw16(ev->height, sw); 154 event->u.expose.count = sw16(ev->count, sw); 155 } 156 break; 157 case GraphicsExpose: 158 { 159 register XGraphicsExposeEvent *ev = 160 (XGraphicsExposeEvent *) re; 161 event->u.graphicsExposure.drawable = sw32(ev->drawable, sw); 162 event->u.graphicsExposure.x = sw16(ev->x, sw); 163 event->u.graphicsExposure.y = sw16(ev->y, sw); 164 event->u.graphicsExposure.width = sw16(ev->width, sw); 165 event->u.graphicsExposure.height = sw16(ev->height, sw); 166 event->u.graphicsExposure.count = sw16(ev->count, sw); 167 event->u.graphicsExposure.majorEvent= ev->major_code; 168 event->u.graphicsExposure.minorEvent= sw16(ev->minor_code, sw); 169 } 170 break; 171 case NoExpose: 172 { 173 register XNoExposeEvent *ev = (XNoExposeEvent *) re; 174 event->u.noExposure.drawable = sw32(ev->drawable, sw); 175 event->u.noExposure.majorEvent = ev->major_code; 176 event->u.noExposure.minorEvent = sw16(ev->minor_code, sw); 177 } 178 break; 179 case VisibilityNotify: 180 { 181 register XVisibilityEvent *ev = (XVisibilityEvent *) re; 182 event->u.visibility.window = sw32(ev->window, sw); 183 event->u.visibility.state = ev->state; 184 } 185 break; 186 case CreateNotify: 187 { 188 register XCreateWindowEvent *ev = 189 (XCreateWindowEvent *) re; 190 event->u.createNotify.window = sw32(ev->window, sw); 191 event->u.createNotify.parent = sw32(ev->parent, sw); 192 event->u.createNotify.x = sw16(ev->x, sw); 193 event->u.createNotify.y = sw16(ev->y, sw); 194 event->u.createNotify.width = sw16(ev->width, sw); 195 event->u.createNotify.height = sw16(ev->height, sw); 196 event->u.createNotify.borderWidth = sw16(ev->border_width, sw); 197 event->u.createNotify.override = ev->override_redirect; 198 } 199 break; 200 case DestroyNotify: 201 { 202 register XDestroyWindowEvent *ev = 203 (XDestroyWindowEvent *) re; 204 event->u.destroyNotify.window = sw32(ev->window, sw); 205 event->u.destroyNotify.event = sw32(ev->event, sw); 206 } 207 break; 208 case UnmapNotify: 209 { 210 register XUnmapEvent *ev = (XUnmapEvent *) re; 211 event->u.unmapNotify.window = sw32(ev->window, sw); 212 event->u.unmapNotify.event = sw32(ev->event, sw); 213 event->u.unmapNotify.fromConfigure = ev->from_configure; 214 } 215 break; 216 case MapNotify: 217 { 218 register XMapEvent *ev = (XMapEvent *) re; 219 event->u.mapNotify.window = sw32(ev->window, sw); 220 event->u.mapNotify.event = sw32(ev->event, sw); 221 event->u.mapNotify.override = ev->override_redirect; 222 } 223 break; 224 case MapRequest: 225 { 226 register XMapRequestEvent *ev = (XMapRequestEvent *) re; 227 event->u.mapRequest.window = sw32(ev->window, sw); 228 event->u.mapRequest.parent = sw32(ev->parent, sw); 229 } 230 break; 231 case ReparentNotify: 232 { 233 register XReparentEvent *ev = (XReparentEvent *) re; 234 event->u.reparent.window = sw32(ev->window, sw); 235 event->u.reparent.event = sw32(ev->event, sw); 236 event->u.reparent.parent = sw32(ev->parent, sw); 237 event->u.reparent.x = sw16(ev->x, sw); 238 event->u.reparent.y = sw16(ev->y, sw); 239 event->u.reparent.override = ev->override_redirect; 240 } 241 break; 242 case ConfigureNotify: 243 { 244 register XConfigureEvent *ev = (XConfigureEvent *) re; 245 event->u.configureNotify.window = sw32(ev->window, sw); 246 event->u.configureNotify.event = sw32(ev->event, sw); 247 event->u.configureNotify.aboveSibling = sw32(ev->above, sw); 248 event->u.configureNotify.x = sw16(ev->x, sw); 249 event->u.configureNotify.y = sw16(ev->y, sw); 250 event->u.configureNotify.width = sw16(ev->width, sw); 251 event->u.configureNotify.height = sw16(ev->height, sw); 252 event->u.configureNotify.borderWidth= sw16(ev->border_width, sw); 253 event->u.configureNotify.override = ev->override_redirect; 254 } 255 break; 256 case ConfigureRequest: 257 { 258 register XConfigureRequestEvent *ev = 259 (XConfigureRequestEvent *) re; 260 event->u.configureRequest.window = sw32(ev->window, sw); 261 event->u.configureRequest.parent = sw32(ev->parent, sw); 262 event->u.configureRequest.sibling = sw32(ev->above, sw); 263 event->u.configureRequest.x = sw16(ev->x, sw); 264 event->u.configureRequest.y = sw16(ev->y, sw); 265 event->u.configureRequest.width = sw16(ev->width, sw); 266 event->u.configureRequest.height = sw16(ev->height, sw); 267 event->u.configureRequest.borderWidth= sw16(ev->border_width, sw); 268 event->u.configureRequest.valueMask= sw16(ev->value_mask, sw); 269 event->u.u.detail = ev->detail; 270 } 271 break; 272 case GravityNotify: 273 { 274 register XGravityEvent *ev = (XGravityEvent *) re; 275 event->u.gravity.window = sw32(ev->window, sw); 276 event->u.gravity.event = sw32(ev->event, sw); 277 event->u.gravity.x = sw16(ev->x, sw); 278 event->u.gravity.y = sw16(ev->y, sw); 279 } 280 break; 281 case ResizeRequest: 282 { 283 register XResizeRequestEvent *ev = 284 (XResizeRequestEvent *) re; 285 event->u.resizeRequest.window = sw32(ev->window, sw); 286 event->u.resizeRequest.width = sw16(ev->width, sw); 287 event->u.resizeRequest.height = sw16(ev->height, sw); 288 } 289 break; 290 case CirculateNotify: 291 { 292 register XCirculateEvent *ev = (XCirculateEvent *) re; 293 event->u.circulate.window = sw32(ev->window, sw); 294 event->u.circulate.event = sw32(ev->event, sw); 295 event->u.circulate.place = ev->place; 296 } 297 break; 298 case CirculateRequest: 299 { 300 register XCirculateRequestEvent *ev = 301 (XCirculateRequestEvent *) re; 302 event->u.circulate.window = sw32(ev->window, sw); 303 event->u.circulate.event = sw32(ev->parent, sw); 304 event->u.circulate.place = ev->place; 305 } 306 break; 307 case PropertyNotify: 308 { 309 register XPropertyEvent *ev = (XPropertyEvent *) re; 310 event->u.property.window = sw32(ev->window, sw); 311 event->u.property.atom = sw32(ev->atom, sw); 312 event->u.property.time = sw32(ev->time, sw); 313 event->u.property.state = ev->state; 314 } 315 break; 316 case SelectionClear: 317 { 318 register XSelectionClearEvent *ev = 319 (XSelectionClearEvent *) re; 320 event->u.selectionClear.window = sw32(ev->window, sw); 321 event->u.selectionClear.atom = sw32(ev->selection, sw); 322 event->u.selectionClear.time = sw32(ev->time, sw); 323 } 324 break; 325 case SelectionRequest: 326 { 327 register XSelectionRequestEvent *ev = 328 (XSelectionRequestEvent *) re; 329 event->u.selectionRequest.owner = sw32(ev->owner, sw); 330 event->u.selectionRequest.requestor = sw32(ev->requestor, sw); 331 event->u.selectionRequest.selection = sw32(ev->selection, sw); 332 event->u.selectionRequest.target = sw32(ev->target, sw); 333 event->u.selectionRequest.property = sw32(ev->property, sw); 334 event->u.selectionRequest.time = sw32(ev->time, sw); 335 } 336 break; 337 case SelectionNotify: 338 { 339 register XSelectionEvent *ev = (XSelectionEvent *) re; 340 event->u.selectionNotify.requestor = sw32(ev->requestor, sw); 341 event->u.selectionNotify.selection = sw32(ev->selection, sw); 342 event->u.selectionNotify.target = sw32(ev->target, sw); 343 event->u.selectionNotify.property = sw32(ev->property, sw); 344 event->u.selectionNotify.time = sw32(ev->time, sw); 345 } 346 break; 347 case ColormapNotify: 348 { 349 register XColormapEvent *ev = (XColormapEvent *) re; 350 event->u.colormap.window = sw32(ev->window, sw); 351 event->u.colormap.colormap = sw32(ev->colormap, sw); 352 event->u.colormap.new = ev->new; 353 event->u.colormap.state = ev->state; 354 } 355 break; 356 case ClientMessage: 357 { 358 register int i; 359 register XClientMessageEvent *ev 360 = (XClientMessageEvent *) re; 361 event->u.clientMessage.window = sw32(ev->window, sw); 362 event->u.u.detail = ev->format; 363 switch (ev->format) { 364 case 8: 365 event->u.clientMessage.u.b.type = sw32(ev->message_type, sw); 366 for (i = 0; i < 20; i++) 367 event->u.clientMessage.u.b.bytes[i] = ev->data.b[i]; 368 break; 369 case 16: 370 event->u.clientMessage.u.s.type = sw32(ev->message_type, sw); 371 event->u.clientMessage.u.s.shorts0 = sw16(ev->data.s[0], sw); 372 event->u.clientMessage.u.s.shorts1 = sw16(ev->data.s[1], sw); 373 event->u.clientMessage.u.s.shorts2 = sw16(ev->data.s[2], sw); 374 event->u.clientMessage.u.s.shorts3 = sw16(ev->data.s[3], sw); 375 event->u.clientMessage.u.s.shorts4 = sw16(ev->data.s[4], sw); 376 event->u.clientMessage.u.s.shorts5 = sw16(ev->data.s[5], sw); 377 event->u.clientMessage.u.s.shorts6 = sw16(ev->data.s[6], sw); 378 event->u.clientMessage.u.s.shorts7 = sw16(ev->data.s[7], sw); 379 event->u.clientMessage.u.s.shorts8 = sw16(ev->data.s[8], sw); 380 event->u.clientMessage.u.s.shorts9 = sw16(ev->data.s[9], sw); 381 break; 382 case 32: 383 event->u.clientMessage.u.l.type = sw32(ev->message_type, sw); 384 event->u.clientMessage.u.l.longs0 = sw32(ev->data.l[0], sw); 385 event->u.clientMessage.u.l.longs1 = sw32(ev->data.l[1], sw); 386 event->u.clientMessage.u.l.longs2 = sw32(ev->data.l[2], sw); 387 event->u.clientMessage.u.l.longs3 = sw32(ev->data.l[3], sw); 388 event->u.clientMessage.u.l.longs4 = sw32(ev->data.l[4], sw); 389 break; 390 default: 391 /* client passing bogus data, let server complain */ 392 break; 393 } 394 } 395 break; 396 case MappingNotify: 397 { 398 register XMappingEvent *ev = (XMappingEvent *) re; 399 event->u.mappingNotify.firstKeyCode = ev->first_keycode; 400 event->u.mappingNotify.request = ev->request; 401 event->u.mappingNotify.count = ev->count; 402 } 403 break; 404 405 default: 406 return(0); 407 } 408 /* Common process */ 409 if (((XAnyEvent *)re)->send_event) 410 event->u.u.type |= 0x80; 411 event->u.u.sequenceNumber = 412 ((XAnyEvent *)re)->serial & ~((unsigned long)0xffff); 413 event->u.u.sequenceNumber = sw16(event->u.u.sequenceNumber, sw); 414 return(1); 415} 416 417 418/* 419 * reformat a wire event into an XEvent structure of the right type. 420 */ 421Bool 422_XimProtoWireToEvent( 423 register XEvent *re, /* pointer to where event should be reformatted */ 424 register xEvent *event, /* wire protocol event */ 425 Bool sw) /* swap byte? */ 426{ 427 428 re->type = event->u.u.type & 0x7f; 429 ((XAnyEvent *)re)->serial = sw16(event->u.u.sequenceNumber, sw); 430 ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0); 431 ((XAnyEvent *)re)->display = NULL; 432 433 /* Ignore the leading bit of the event type since it is set when a 434 client sends an event rather than the server. */ 435 436 switch (event-> u.u.type & 0177) { 437 case KeyPress: 438 case KeyRelease: 439 { 440 register XKeyEvent *ev = (XKeyEvent*) re; 441 ev->root = sw32(event->u.keyButtonPointer.root, sw); 442 ev->window = sw32(event->u.keyButtonPointer.event, sw); 443 ev->subwindow = sw32(event->u.keyButtonPointer.child, sw); 444 ev->time = sw32(event->u.keyButtonPointer.time, sw); 445 ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw)); 446 ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw)); 447 ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw)); 448 ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw)); 449 ev->state = sw16(event->u.keyButtonPointer.state, sw); 450 ev->same_screen = event->u.keyButtonPointer.sameScreen; 451 ev->keycode = event->u.u.detail; 452 } 453 break; 454 case ButtonPress: 455 case ButtonRelease: 456 { 457 register XButtonEvent *ev = (XButtonEvent *) re; 458 ev->root = sw32(event->u.keyButtonPointer.root, sw); 459 ev->window = sw32(event->u.keyButtonPointer.event, sw); 460 ev->subwindow = sw32(event->u.keyButtonPointer.child, sw); 461 ev->time = sw32(event->u.keyButtonPointer.time, sw); 462 ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw)); 463 ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw)); 464 ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw)); 465 ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw)); 466 ev->state = sw16(event->u.keyButtonPointer.state, sw); 467 ev->same_screen = event->u.keyButtonPointer.sameScreen; 468 ev->button = event->u.u.detail; 469 } 470 break; 471 case MotionNotify: 472 { 473 register XMotionEvent *ev = (XMotionEvent *)re; 474 ev->root = sw32(event->u.keyButtonPointer.root, sw); 475 ev->window = sw32(event->u.keyButtonPointer.event, sw); 476 ev->subwindow = sw32(event->u.keyButtonPointer.child, sw); 477 ev->time = sw32(event->u.keyButtonPointer.time, sw); 478 ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw)); 479 ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw)); 480 ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw)); 481 ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw)); 482 ev->state = sw16(event->u.keyButtonPointer.state, sw); 483 ev->same_screen = event->u.keyButtonPointer.sameScreen; 484 ev->is_hint = event->u.u.detail; 485 } 486 break; 487 case EnterNotify: 488 case LeaveNotify: 489 { 490 register XCrossingEvent *ev = (XCrossingEvent *) re; 491 ev->root = sw32(event->u.enterLeave.root, sw); 492 ev->window = sw32(event->u.enterLeave.event, sw); 493 ev->subwindow = sw32(event->u.enterLeave.child, sw); 494 ev->time = sw32(event->u.enterLeave.time, sw); 495 ev->x = cvtINT16toInt(sw16(event->u.enterLeave.eventX, sw)); 496 ev->y = cvtINT16toInt(sw16(event->u.enterLeave.eventY, sw)); 497 ev->x_root = cvtINT16toInt(sw16(event->u.enterLeave.rootX, sw)); 498 ev->y_root = cvtINT16toInt(sw16(event->u.enterLeave.rootY, sw)); 499 ev->state = sw16(event->u.enterLeave.state, sw); 500 ev->mode = event->u.enterLeave.mode; 501 ev->same_screen = (event->u.enterLeave.flags & 502 ELFlagSameScreen) && True; 503 ev->focus = (event->u.enterLeave.flags & 504 ELFlagFocus) && True; 505 ev->detail = event->u.u.detail; 506 } 507 break; 508 case FocusIn: 509 case FocusOut: 510 { 511 register XFocusChangeEvent *ev = (XFocusChangeEvent *) re; 512 ev->window = sw32(event->u.focus.window, sw); 513 ev->mode = event->u.focus.mode; 514 ev->detail = event->u.u.detail; 515 } 516 break; 517 case KeymapNotify: 518 { 519 register XKeymapEvent *ev = (XKeymapEvent *) re; 520 ev->window = None; 521 memcpy(&ev->key_vector[1], 522 (char *)((xKeymapEvent *) event)->map, 523 sizeof (((xKeymapEvent *) event)->map)); 524 } 525 break; 526 case Expose: 527 { 528 register XExposeEvent *ev = (XExposeEvent *) re; 529 ev->window = sw32(event->u.expose.window, sw); 530 ev->x = sw16(event->u.expose.x, sw); 531 ev->y = sw16(event->u.expose.y, sw); 532 ev->width = sw16(event->u.expose.width, sw); 533 ev->height = sw16(event->u.expose.height, sw); 534 ev->count = sw16(event->u.expose.count, sw); 535 } 536 break; 537 case GraphicsExpose: 538 { 539 register XGraphicsExposeEvent *ev = 540 (XGraphicsExposeEvent *) re; 541 ev->drawable = sw32(event->u.graphicsExposure.drawable, sw); 542 ev->x = sw16(event->u.graphicsExposure.x, sw); 543 ev->y = sw16(event->u.graphicsExposure.y, sw); 544 ev->width = sw16(event->u.graphicsExposure.width, sw); 545 ev->height = sw16(event->u.graphicsExposure.height, sw); 546 ev->count = sw16(event->u.graphicsExposure.count, sw); 547 ev->major_code = event->u.graphicsExposure.majorEvent; 548 ev->minor_code = sw16(event->u.graphicsExposure.minorEvent, sw); 549 } 550 break; 551 case NoExpose: 552 { 553 register XNoExposeEvent *ev = (XNoExposeEvent *) re; 554 ev->drawable = sw32(event->u.noExposure.drawable, sw); 555 ev->major_code = event->u.noExposure.majorEvent; 556 ev->minor_code = sw16(event->u.noExposure.minorEvent, sw); 557 } 558 break; 559 case VisibilityNotify: 560 { 561 register XVisibilityEvent *ev = (XVisibilityEvent *) re; 562 ev->window = sw32(event->u.visibility.window, sw); 563 ev->state = event->u.visibility.state; 564 } 565 break; 566 case CreateNotify: 567 { 568 register XCreateWindowEvent *ev = 569 (XCreateWindowEvent *) re; 570 ev->window = sw32(event->u.createNotify.window, sw); 571 ev->parent = sw32(event->u.createNotify.parent, sw); 572 ev->x = cvtINT16toInt(sw16(event->u.createNotify.x, sw)); 573 ev->y = cvtINT16toInt(sw16(event->u.createNotify.y, sw)); 574 ev->width = sw16(event->u.createNotify.width, sw); 575 ev->height = sw16(event->u.createNotify.height, sw); 576 ev->border_width = sw16(event->u.createNotify.borderWidth, sw); 577 ev->override_redirect = event->u.createNotify.override; 578 } 579 break; 580 case DestroyNotify: 581 { 582 register XDestroyWindowEvent *ev = 583 (XDestroyWindowEvent *) re; 584 ev->window = sw32(event->u.destroyNotify.window, sw); 585 ev->event = sw32(event->u.destroyNotify.event, sw); 586 } 587 break; 588 case UnmapNotify: 589 { 590 register XUnmapEvent *ev = (XUnmapEvent *) re; 591 ev->window = sw32(event->u.unmapNotify.window, sw); 592 ev->event = sw32(event->u.unmapNotify.event, sw); 593 ev->from_configure = event->u.unmapNotify.fromConfigure; 594 } 595 break; 596 case MapNotify: 597 { 598 register XMapEvent *ev = (XMapEvent *) re; 599 ev->window = sw32(event->u.mapNotify.window, sw); 600 ev->event = sw32(event->u.mapNotify.event, sw); 601 ev->override_redirect = event->u.mapNotify.override; 602 } 603 break; 604 case MapRequest: 605 { 606 register XMapRequestEvent *ev = (XMapRequestEvent *) re; 607 ev->window = sw32(event->u.mapRequest.window, sw); 608 ev->parent = sw32(event->u.mapRequest.parent, sw); 609 } 610 break; 611 case ReparentNotify: 612 { 613 register XReparentEvent *ev = (XReparentEvent *) re; 614 ev->event = sw32(event->u.reparent.event, sw); 615 ev->window = sw32(event->u.reparent.window, sw); 616 ev->parent = sw32(event->u.reparent.parent, sw); 617 ev->x = cvtINT16toInt(sw16(event->u.reparent.x, sw)); 618 ev->y = cvtINT16toInt(sw16(event->u.reparent.y, sw)); 619 ev->override_redirect = event->u.reparent.override; 620 } 621 break; 622 case ConfigureNotify: 623 { 624 register XConfigureEvent *ev = (XConfigureEvent *) re; 625 ev->event = sw32(event->u.configureNotify.event, sw); 626 ev->window = sw32(event->u.configureNotify.window, sw); 627 ev->above = sw32(event->u.configureNotify.aboveSibling, sw); 628 ev->x = cvtINT16toInt(sw16(event->u.configureNotify.x, sw)); 629 ev->y = cvtINT16toInt(sw16(event->u.configureNotify.y, sw)); 630 ev->width = sw16(event->u.configureNotify.width, sw); 631 ev->height = sw16(event->u.configureNotify.height, sw); 632 ev->border_width = sw16(event->u.configureNotify.borderWidth, sw); 633 ev->override_redirect = event->u.configureNotify.override; 634 } 635 break; 636 case ConfigureRequest: 637 { 638 register XConfigureRequestEvent *ev = 639 (XConfigureRequestEvent *) re; 640 ev->window = sw32(event->u.configureRequest.window, sw); 641 ev->parent = sw32(event->u.configureRequest.parent, sw); 642 ev->above = sw32(event->u.configureRequest.sibling, sw); 643 ev->x = cvtINT16toInt(sw16(event->u.configureRequest.x, sw)); 644 ev->y = cvtINT16toInt(sw16(event->u.configureRequest.y, sw)); 645 ev->width = sw16(event->u.configureRequest.width, sw); 646 ev->height = sw16(event->u.configureRequest.height, sw); 647 ev->border_width = sw16(event->u.configureRequest.borderWidth, sw); 648 ev->value_mask = sw16(event->u.configureRequest.valueMask, sw); 649 ev->detail = event->u.u.detail; 650 } 651 break; 652 case GravityNotify: 653 { 654 register XGravityEvent *ev = (XGravityEvent *) re; 655 ev->window = sw32(event->u.gravity.window, sw); 656 ev->event = sw32(event->u.gravity.event, sw); 657 ev->x = cvtINT16toInt(sw16(event->u.gravity.x, sw)); 658 ev->y = cvtINT16toInt(sw16(event->u.gravity.y, sw)); 659 } 660 break; 661 case ResizeRequest: 662 { 663 register XResizeRequestEvent *ev = 664 (XResizeRequestEvent *) re; 665 ev->window = sw32(event->u.resizeRequest.window, sw); 666 ev->width = sw16(event->u.resizeRequest.width, sw); 667 ev->height = sw16(event->u.resizeRequest.height, sw); 668 } 669 break; 670 case CirculateNotify: 671 { 672 register XCirculateEvent *ev = (XCirculateEvent *) re; 673 ev->window = sw32(event->u.circulate.window, sw); 674 ev->event = sw32(event->u.circulate.event, sw); 675 ev->place = event->u.circulate.place; 676 } 677 break; 678 case CirculateRequest: 679 { 680 register XCirculateRequestEvent *ev = 681 (XCirculateRequestEvent *) re; 682 ev->window = sw32(event->u.circulate.window, sw); 683 ev->parent = sw32(event->u.circulate.event, sw); 684 ev->place = event->u.circulate.place; 685 } 686 break; 687 case PropertyNotify: 688 { 689 register XPropertyEvent *ev = (XPropertyEvent *) re; 690 ev->window = sw32(event->u.property.window, sw); 691 ev->atom = sw32(event->u.property.atom, sw); 692 ev->time = sw32(event->u.property.time, sw); 693 ev->state = event->u.property.state; 694 } 695 break; 696 case SelectionClear: 697 { 698 register XSelectionClearEvent *ev = 699 (XSelectionClearEvent *) re; 700 ev->window = sw32(event->u.selectionClear.window, sw); 701 ev->selection = sw32(event->u.selectionClear.atom, sw); 702 ev->time = sw32(event->u.selectionClear.time, sw); 703 } 704 break; 705 case SelectionRequest: 706 { 707 register XSelectionRequestEvent *ev = 708 (XSelectionRequestEvent *) re; 709 ev->owner = sw32(event->u.selectionRequest.owner, sw); 710 ev->requestor = sw32(event->u.selectionRequest.requestor, sw); 711 ev->selection = sw32(event->u.selectionRequest.selection, sw); 712 ev->target = sw32(event->u.selectionRequest.target, sw); 713 ev->property = sw32(event->u.selectionRequest.property, sw); 714 ev->time = sw32(event->u.selectionRequest.time, sw); 715 } 716 break; 717 case SelectionNotify: 718 { 719 register XSelectionEvent *ev = (XSelectionEvent *) re; 720 ev->requestor = sw32(event->u.selectionNotify.requestor, sw); 721 ev->selection = sw32(event->u.selectionNotify.selection, sw); 722 ev->target = sw32(event->u.selectionNotify.target, sw); 723 ev->property = sw32(event->u.selectionNotify.property, sw); 724 ev->time = sw32(event->u.selectionNotify.time, sw); 725 } 726 break; 727 case ColormapNotify: 728 { 729 register XColormapEvent *ev = (XColormapEvent *) re; 730 ev->window = sw32(event->u.colormap.window, sw); 731 ev->colormap = sw32(event->u.colormap.colormap, sw); 732 ev->new = event->u.colormap.new; 733 ev->state = event->u.colormap.state; 734 } 735 break; 736 case ClientMessage: 737 { 738 register int i; 739 register XClientMessageEvent *ev 740 = (XClientMessageEvent *) re; 741 ev->window = sw32(event->u.clientMessage.window, sw); 742 ev->format = event->u.u.detail; 743 switch (ev->format) { 744 case 8: 745 ev->message_type = sw32(event->u.clientMessage.u.b.type, sw); 746 for (i = 0; i < 20; i++) 747 ev->data.b[i] = event->u.clientMessage.u.b.bytes[i]; 748 break; 749 case 16: 750 ev->message_type = sw32(event->u.clientMessage.u.s.type, sw); 751 ev->data.s[0] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts0, sw)); 752 ev->data.s[1] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts1, sw)); 753 ev->data.s[2] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts2, sw)); 754 ev->data.s[3] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts3, sw)); 755 ev->data.s[4] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts4, sw)); 756 ev->data.s[5] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts5, sw)); 757 ev->data.s[6] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts6, sw)); 758 ev->data.s[7] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts7, sw)); 759 ev->data.s[8] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts8, sw)); 760 ev->data.s[9] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts9, sw)); 761 break; 762 case 32: 763 ev->message_type = sw32(event->u.clientMessage.u.l.type, sw); 764 ev->data.l[0] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs0, sw)); 765 ev->data.l[1] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs1, sw)); 766 ev->data.l[2] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs2, sw)); 767 ev->data.l[3] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs3, sw)); 768 ev->data.l[4] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs4, sw)); 769 break; 770 default: /* XXX should never occur */ 771 break; 772 } 773 } 774 break; 775 case MappingNotify: 776 { 777 register XMappingEvent *ev = (XMappingEvent *)re; 778 ev->window = 0; 779 ev->first_keycode = event->u.mappingNotify.firstKeyCode; 780 ev->request = event->u.mappingNotify.request; 781 ev->count = event->u.mappingNotify.count; 782 } 783 break; 784 default: 785 return(False); 786 } 787 return(True); 788} 789