github.com/BurntSushi/xgb@v0.0.0-20210121224620-deaf085860bc/xproto/xproto.go (about) 1 // Package xproto is the X client API for the extension. 2 package xproto 3 4 // This file is automatically generated from xproto.xml. Edit at your peril! 5 6 import ( 7 "github.com/BurntSushi/xgb" 8 ) 9 10 // Setup parses the setup bytes retrieved when 11 // connecting into a SetupInfo struct. 12 func Setup(c *xgb.Conn) *SetupInfo { 13 setup := new(SetupInfo) 14 SetupInfoRead(c.SetupBytes, setup) 15 return setup 16 } 17 18 // DefaultScreen gets the default screen info from SetupInfo. 19 func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo { 20 return &s.Roots[c.DefaultScreen] 21 } 22 23 // BadAccess is the error number for a BadAccess. 24 const BadAccess = 10 25 26 type AccessError RequestError 27 28 // AccessErrorNew constructs a AccessError value that implements xgb.Error from a byte slice. 29 func AccessErrorNew(buf []byte) xgb.Error { 30 v := AccessError(RequestErrorNew(buf).(RequestError)) 31 v.NiceName = "Access" 32 return v 33 } 34 35 // SequenceId returns the sequence id attached to the BadAccess error. 36 // This is mostly used internally. 37 func (err AccessError) SequenceId() uint16 { 38 return err.Sequence 39 } 40 41 // BadId returns the 'BadValue' number if one exists for the BadAccess error. If no bad value exists, 0 is returned. 42 func (err AccessError) BadId() uint32 { 43 return err.BadValue 44 } 45 46 // Error returns a rudimentary string representation of the BadAccess error. 47 func (err AccessError) Error() string { 48 fieldVals := make([]string, 0, 4) 49 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 50 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 51 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 52 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 53 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 54 return "BadAccess {" + xgb.StringsJoin(fieldVals, ", ") + "}" 55 } 56 57 func init() { 58 xgb.NewErrorFuncs[10] = AccessErrorNew 59 } 60 61 const ( 62 AccessControlDisable = 0 63 AccessControlEnable = 1 64 ) 65 66 // BadAlloc is the error number for a BadAlloc. 67 const BadAlloc = 11 68 69 type AllocError RequestError 70 71 // AllocErrorNew constructs a AllocError value that implements xgb.Error from a byte slice. 72 func AllocErrorNew(buf []byte) xgb.Error { 73 v := AllocError(RequestErrorNew(buf).(RequestError)) 74 v.NiceName = "Alloc" 75 return v 76 } 77 78 // SequenceId returns the sequence id attached to the BadAlloc error. 79 // This is mostly used internally. 80 func (err AllocError) SequenceId() uint16 { 81 return err.Sequence 82 } 83 84 // BadId returns the 'BadValue' number if one exists for the BadAlloc error. If no bad value exists, 0 is returned. 85 func (err AllocError) BadId() uint32 { 86 return err.BadValue 87 } 88 89 // Error returns a rudimentary string representation of the BadAlloc error. 90 func (err AllocError) Error() string { 91 fieldVals := make([]string, 0, 4) 92 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 93 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 94 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 95 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 96 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 97 return "BadAlloc {" + xgb.StringsJoin(fieldVals, ", ") + "}" 98 } 99 100 func init() { 101 xgb.NewErrorFuncs[11] = AllocErrorNew 102 } 103 104 const ( 105 AllowAsyncPointer = 0 106 AllowSyncPointer = 1 107 AllowReplayPointer = 2 108 AllowAsyncKeyboard = 3 109 AllowSyncKeyboard = 4 110 AllowReplayKeyboard = 5 111 AllowAsyncBoth = 6 112 AllowSyncBoth = 7 113 ) 114 115 type Arc struct { 116 X int16 117 Y int16 118 Width uint16 119 Height uint16 120 Angle1 int16 121 Angle2 int16 122 } 123 124 // ArcRead reads a byte slice into a Arc value. 125 func ArcRead(buf []byte, v *Arc) int { 126 b := 0 127 128 v.X = int16(xgb.Get16(buf[b:])) 129 b += 2 130 131 v.Y = int16(xgb.Get16(buf[b:])) 132 b += 2 133 134 v.Width = xgb.Get16(buf[b:]) 135 b += 2 136 137 v.Height = xgb.Get16(buf[b:]) 138 b += 2 139 140 v.Angle1 = int16(xgb.Get16(buf[b:])) 141 b += 2 142 143 v.Angle2 = int16(xgb.Get16(buf[b:])) 144 b += 2 145 146 return b 147 } 148 149 // ArcReadList reads a byte slice into a list of Arc values. 150 func ArcReadList(buf []byte, dest []Arc) int { 151 b := 0 152 for i := 0; i < len(dest); i++ { 153 dest[i] = Arc{} 154 b += ArcRead(buf[b:], &dest[i]) 155 } 156 return xgb.Pad(b) 157 } 158 159 // Bytes writes a Arc value to a byte slice. 160 func (v Arc) Bytes() []byte { 161 buf := make([]byte, 12) 162 b := 0 163 164 xgb.Put16(buf[b:], uint16(v.X)) 165 b += 2 166 167 xgb.Put16(buf[b:], uint16(v.Y)) 168 b += 2 169 170 xgb.Put16(buf[b:], v.Width) 171 b += 2 172 173 xgb.Put16(buf[b:], v.Height) 174 b += 2 175 176 xgb.Put16(buf[b:], uint16(v.Angle1)) 177 b += 2 178 179 xgb.Put16(buf[b:], uint16(v.Angle2)) 180 b += 2 181 182 return buf[:b] 183 } 184 185 // ArcListBytes writes a list of Arc values to a byte slice. 186 func ArcListBytes(buf []byte, list []Arc) int { 187 b := 0 188 var structBytes []byte 189 for _, item := range list { 190 structBytes = item.Bytes() 191 copy(buf[b:], structBytes) 192 b += len(structBytes) 193 } 194 return xgb.Pad(b) 195 } 196 197 const ( 198 ArcModeChord = 0 199 ArcModePieSlice = 1 200 ) 201 202 type Atom uint32 203 204 func NewAtomId(c *xgb.Conn) (Atom, error) { 205 id, err := c.NewId() 206 if err != nil { 207 return 0, err 208 } 209 return Atom(id), nil 210 } 211 212 const ( 213 AtomNone = 0 214 AtomAny = 0 215 AtomPrimary = 1 216 AtomSecondary = 2 217 AtomArc = 3 218 AtomAtom = 4 219 AtomBitmap = 5 220 AtomCardinal = 6 221 AtomColormap = 7 222 AtomCursor = 8 223 AtomCutBuffer0 = 9 224 AtomCutBuffer1 = 10 225 AtomCutBuffer2 = 11 226 AtomCutBuffer3 = 12 227 AtomCutBuffer4 = 13 228 AtomCutBuffer5 = 14 229 AtomCutBuffer6 = 15 230 AtomCutBuffer7 = 16 231 AtomDrawable = 17 232 AtomFont = 18 233 AtomInteger = 19 234 AtomPixmap = 20 235 AtomPoint = 21 236 AtomRectangle = 22 237 AtomResourceManager = 23 238 AtomRgbColorMap = 24 239 AtomRgbBestMap = 25 240 AtomRgbBlueMap = 26 241 AtomRgbDefaultMap = 27 242 AtomRgbGrayMap = 28 243 AtomRgbGreenMap = 29 244 AtomRgbRedMap = 30 245 AtomString = 31 246 AtomVisualid = 32 247 AtomWindow = 33 248 AtomWmCommand = 34 249 AtomWmHints = 35 250 AtomWmClientMachine = 36 251 AtomWmIconName = 37 252 AtomWmIconSize = 38 253 AtomWmName = 39 254 AtomWmNormalHints = 40 255 AtomWmSizeHints = 41 256 AtomWmZoomHints = 42 257 AtomMinSpace = 43 258 AtomNormSpace = 44 259 AtomMaxSpace = 45 260 AtomEndSpace = 46 261 AtomSuperscriptX = 47 262 AtomSuperscriptY = 48 263 AtomSubscriptX = 49 264 AtomSubscriptY = 50 265 AtomUnderlinePosition = 51 266 AtomUnderlineThickness = 52 267 AtomStrikeoutAscent = 53 268 AtomStrikeoutDescent = 54 269 AtomItalicAngle = 55 270 AtomXHeight = 56 271 AtomQuadWidth = 57 272 AtomWeight = 58 273 AtomPointSize = 59 274 AtomResolution = 60 275 AtomCopyright = 61 276 AtomNotice = 62 277 AtomFontName = 63 278 AtomFamilyName = 64 279 AtomFullName = 65 280 AtomCapHeight = 66 281 AtomWmClass = 67 282 AtomWmTransientFor = 68 283 ) 284 285 // BadAtom is the error number for a BadAtom. 286 const BadAtom = 5 287 288 type AtomError ValueError 289 290 // AtomErrorNew constructs a AtomError value that implements xgb.Error from a byte slice. 291 func AtomErrorNew(buf []byte) xgb.Error { 292 v := AtomError(ValueErrorNew(buf).(ValueError)) 293 v.NiceName = "Atom" 294 return v 295 } 296 297 // SequenceId returns the sequence id attached to the BadAtom error. 298 // This is mostly used internally. 299 func (err AtomError) SequenceId() uint16 { 300 return err.Sequence 301 } 302 303 // BadId returns the 'BadValue' number if one exists for the BadAtom error. If no bad value exists, 0 is returned. 304 func (err AtomError) BadId() uint32 { 305 return err.BadValue 306 } 307 308 // Error returns a rudimentary string representation of the BadAtom error. 309 func (err AtomError) Error() string { 310 fieldVals := make([]string, 0, 4) 311 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 312 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 313 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 314 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 315 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 316 return "BadAtom {" + xgb.StringsJoin(fieldVals, ", ") + "}" 317 } 318 319 func init() { 320 xgb.NewErrorFuncs[5] = AtomErrorNew 321 } 322 323 const ( 324 AutoRepeatModeOff = 0 325 AutoRepeatModeOn = 1 326 AutoRepeatModeDefault = 2 327 ) 328 329 const ( 330 BackPixmapNone = 0 331 BackPixmapParentRelative = 1 332 ) 333 334 const ( 335 BackingStoreNotUseful = 0 336 BackingStoreWhenMapped = 1 337 BackingStoreAlways = 2 338 ) 339 340 const ( 341 BlankingNotPreferred = 0 342 BlankingPreferred = 1 343 BlankingDefault = 2 344 ) 345 346 type Button byte 347 348 const ( 349 ButtonIndexAny = 0 350 ButtonIndex1 = 1 351 ButtonIndex2 = 2 352 ButtonIndex3 = 3 353 ButtonIndex4 = 4 354 ButtonIndex5 = 5 355 ) 356 357 const ( 358 ButtonMask1 = 256 359 ButtonMask2 = 512 360 ButtonMask3 = 1024 361 ButtonMask4 = 2048 362 ButtonMask5 = 4096 363 ButtonMaskAny = 32768 364 ) 365 366 // ButtonPress is the event number for a ButtonPressEvent. 367 const ButtonPress = 4 368 369 type ButtonPressEvent struct { 370 Sequence uint16 371 Detail Button 372 Time Timestamp 373 Root Window 374 Event Window 375 Child Window 376 RootX int16 377 RootY int16 378 EventX int16 379 EventY int16 380 State uint16 381 SameScreen bool 382 // padding: 1 bytes 383 } 384 385 // ButtonPressEventNew constructs a ButtonPressEvent value that implements xgb.Event from a byte slice. 386 func ButtonPressEventNew(buf []byte) xgb.Event { 387 v := ButtonPressEvent{} 388 b := 1 // don't read event number 389 390 v.Detail = Button(buf[b]) 391 b += 1 392 393 v.Sequence = xgb.Get16(buf[b:]) 394 b += 2 395 396 v.Time = Timestamp(xgb.Get32(buf[b:])) 397 b += 4 398 399 v.Root = Window(xgb.Get32(buf[b:])) 400 b += 4 401 402 v.Event = Window(xgb.Get32(buf[b:])) 403 b += 4 404 405 v.Child = Window(xgb.Get32(buf[b:])) 406 b += 4 407 408 v.RootX = int16(xgb.Get16(buf[b:])) 409 b += 2 410 411 v.RootY = int16(xgb.Get16(buf[b:])) 412 b += 2 413 414 v.EventX = int16(xgb.Get16(buf[b:])) 415 b += 2 416 417 v.EventY = int16(xgb.Get16(buf[b:])) 418 b += 2 419 420 v.State = xgb.Get16(buf[b:]) 421 b += 2 422 423 if buf[b] == 1 { 424 v.SameScreen = true 425 } else { 426 v.SameScreen = false 427 } 428 b += 1 429 430 b += 1 // padding 431 432 return v 433 } 434 435 // Bytes writes a ButtonPressEvent value to a byte slice. 436 func (v ButtonPressEvent) Bytes() []byte { 437 buf := make([]byte, 32) 438 b := 0 439 440 // write event number 441 buf[b] = 4 442 b += 1 443 444 buf[b] = byte(v.Detail) 445 b += 1 446 447 b += 2 // skip sequence number 448 449 xgb.Put32(buf[b:], uint32(v.Time)) 450 b += 4 451 452 xgb.Put32(buf[b:], uint32(v.Root)) 453 b += 4 454 455 xgb.Put32(buf[b:], uint32(v.Event)) 456 b += 4 457 458 xgb.Put32(buf[b:], uint32(v.Child)) 459 b += 4 460 461 xgb.Put16(buf[b:], uint16(v.RootX)) 462 b += 2 463 464 xgb.Put16(buf[b:], uint16(v.RootY)) 465 b += 2 466 467 xgb.Put16(buf[b:], uint16(v.EventX)) 468 b += 2 469 470 xgb.Put16(buf[b:], uint16(v.EventY)) 471 b += 2 472 473 xgb.Put16(buf[b:], v.State) 474 b += 2 475 476 if v.SameScreen { 477 buf[b] = 1 478 } else { 479 buf[b] = 0 480 } 481 b += 1 482 483 b += 1 // padding 484 485 return buf 486 } 487 488 // SequenceId returns the sequence id attached to the ButtonPress event. 489 // Events without a sequence number (KeymapNotify) return 0. 490 // This is mostly used internally. 491 func (v ButtonPressEvent) SequenceId() uint16 { 492 return v.Sequence 493 } 494 495 // String is a rudimentary string representation of ButtonPressEvent. 496 func (v ButtonPressEvent) String() string { 497 fieldVals := make([]string, 0, 12) 498 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 499 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 500 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 501 fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) 502 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 503 fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) 504 fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) 505 fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) 506 fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) 507 fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) 508 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 509 fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) 510 return "ButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" 511 } 512 513 func init() { 514 xgb.NewEventFuncs[4] = ButtonPressEventNew 515 } 516 517 // ButtonRelease is the event number for a ButtonReleaseEvent. 518 const ButtonRelease = 5 519 520 type ButtonReleaseEvent ButtonPressEvent 521 522 // ButtonReleaseEventNew constructs a ButtonReleaseEvent value that implements xgb.Event from a byte slice. 523 func ButtonReleaseEventNew(buf []byte) xgb.Event { 524 return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) 525 } 526 527 // Bytes writes a ButtonReleaseEvent value to a byte slice. 528 func (v ButtonReleaseEvent) Bytes() []byte { 529 return ButtonPressEvent(v).Bytes() 530 } 531 532 // SequenceId returns the sequence id attached to the ButtonRelease event. 533 // Events without a sequence number (KeymapNotify) return 0. 534 // This is mostly used internally. 535 func (v ButtonReleaseEvent) SequenceId() uint16 { 536 return v.Sequence 537 } 538 539 func (v ButtonReleaseEvent) String() string { 540 fieldVals := make([]string, 0, 12) 541 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 542 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 543 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 544 fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) 545 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 546 fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) 547 fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) 548 fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) 549 fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) 550 fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) 551 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 552 fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) 553 return "ButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" 554 } 555 556 func init() { 557 xgb.NewEventFuncs[5] = ButtonReleaseEventNew 558 } 559 560 const ( 561 CapStyleNotLast = 0 562 CapStyleButt = 1 563 CapStyleRound = 2 564 CapStyleProjecting = 3 565 ) 566 567 type Char2b struct { 568 Byte1 byte 569 Byte2 byte 570 } 571 572 // Char2bRead reads a byte slice into a Char2b value. 573 func Char2bRead(buf []byte, v *Char2b) int { 574 b := 0 575 576 v.Byte1 = buf[b] 577 b += 1 578 579 v.Byte2 = buf[b] 580 b += 1 581 582 return b 583 } 584 585 // Char2bReadList reads a byte slice into a list of Char2b values. 586 func Char2bReadList(buf []byte, dest []Char2b) int { 587 b := 0 588 for i := 0; i < len(dest); i++ { 589 dest[i] = Char2b{} 590 b += Char2bRead(buf[b:], &dest[i]) 591 } 592 return xgb.Pad(b) 593 } 594 595 // Bytes writes a Char2b value to a byte slice. 596 func (v Char2b) Bytes() []byte { 597 buf := make([]byte, 2) 598 b := 0 599 600 buf[b] = v.Byte1 601 b += 1 602 603 buf[b] = v.Byte2 604 b += 1 605 606 return buf[:b] 607 } 608 609 // Char2bListBytes writes a list of Char2b values to a byte slice. 610 func Char2bListBytes(buf []byte, list []Char2b) int { 611 b := 0 612 var structBytes []byte 613 for _, item := range list { 614 structBytes = item.Bytes() 615 copy(buf[b:], structBytes) 616 b += len(structBytes) 617 } 618 return xgb.Pad(b) 619 } 620 621 type Charinfo struct { 622 LeftSideBearing int16 623 RightSideBearing int16 624 CharacterWidth int16 625 Ascent int16 626 Descent int16 627 Attributes uint16 628 } 629 630 // CharinfoRead reads a byte slice into a Charinfo value. 631 func CharinfoRead(buf []byte, v *Charinfo) int { 632 b := 0 633 634 v.LeftSideBearing = int16(xgb.Get16(buf[b:])) 635 b += 2 636 637 v.RightSideBearing = int16(xgb.Get16(buf[b:])) 638 b += 2 639 640 v.CharacterWidth = int16(xgb.Get16(buf[b:])) 641 b += 2 642 643 v.Ascent = int16(xgb.Get16(buf[b:])) 644 b += 2 645 646 v.Descent = int16(xgb.Get16(buf[b:])) 647 b += 2 648 649 v.Attributes = xgb.Get16(buf[b:]) 650 b += 2 651 652 return b 653 } 654 655 // CharinfoReadList reads a byte slice into a list of Charinfo values. 656 func CharinfoReadList(buf []byte, dest []Charinfo) int { 657 b := 0 658 for i := 0; i < len(dest); i++ { 659 dest[i] = Charinfo{} 660 b += CharinfoRead(buf[b:], &dest[i]) 661 } 662 return xgb.Pad(b) 663 } 664 665 // Bytes writes a Charinfo value to a byte slice. 666 func (v Charinfo) Bytes() []byte { 667 buf := make([]byte, 12) 668 b := 0 669 670 xgb.Put16(buf[b:], uint16(v.LeftSideBearing)) 671 b += 2 672 673 xgb.Put16(buf[b:], uint16(v.RightSideBearing)) 674 b += 2 675 676 xgb.Put16(buf[b:], uint16(v.CharacterWidth)) 677 b += 2 678 679 xgb.Put16(buf[b:], uint16(v.Ascent)) 680 b += 2 681 682 xgb.Put16(buf[b:], uint16(v.Descent)) 683 b += 2 684 685 xgb.Put16(buf[b:], v.Attributes) 686 b += 2 687 688 return buf[:b] 689 } 690 691 // CharinfoListBytes writes a list of Charinfo values to a byte slice. 692 func CharinfoListBytes(buf []byte, list []Charinfo) int { 693 b := 0 694 var structBytes []byte 695 for _, item := range list { 696 structBytes = item.Bytes() 697 copy(buf[b:], structBytes) 698 b += len(structBytes) 699 } 700 return xgb.Pad(b) 701 } 702 703 const ( 704 CirculateRaiseLowest = 0 705 CirculateLowerHighest = 1 706 ) 707 708 // CirculateNotify is the event number for a CirculateNotifyEvent. 709 const CirculateNotify = 26 710 711 type CirculateNotifyEvent struct { 712 Sequence uint16 713 // padding: 1 bytes 714 Event Window 715 Window Window 716 // padding: 4 bytes 717 Place byte 718 // padding: 3 bytes 719 } 720 721 // CirculateNotifyEventNew constructs a CirculateNotifyEvent value that implements xgb.Event from a byte slice. 722 func CirculateNotifyEventNew(buf []byte) xgb.Event { 723 v := CirculateNotifyEvent{} 724 b := 1 // don't read event number 725 726 b += 1 // padding 727 728 v.Sequence = xgb.Get16(buf[b:]) 729 b += 2 730 731 v.Event = Window(xgb.Get32(buf[b:])) 732 b += 4 733 734 v.Window = Window(xgb.Get32(buf[b:])) 735 b += 4 736 737 b += 4 // padding 738 739 v.Place = buf[b] 740 b += 1 741 742 b += 3 // padding 743 744 return v 745 } 746 747 // Bytes writes a CirculateNotifyEvent value to a byte slice. 748 func (v CirculateNotifyEvent) Bytes() []byte { 749 buf := make([]byte, 32) 750 b := 0 751 752 // write event number 753 buf[b] = 26 754 b += 1 755 756 b += 1 // padding 757 758 b += 2 // skip sequence number 759 760 xgb.Put32(buf[b:], uint32(v.Event)) 761 b += 4 762 763 xgb.Put32(buf[b:], uint32(v.Window)) 764 b += 4 765 766 b += 4 // padding 767 768 buf[b] = v.Place 769 b += 1 770 771 b += 3 // padding 772 773 return buf 774 } 775 776 // SequenceId returns the sequence id attached to the CirculateNotify event. 777 // Events without a sequence number (KeymapNotify) return 0. 778 // This is mostly used internally. 779 func (v CirculateNotifyEvent) SequenceId() uint16 { 780 return v.Sequence 781 } 782 783 // String is a rudimentary string representation of CirculateNotifyEvent. 784 func (v CirculateNotifyEvent) String() string { 785 fieldVals := make([]string, 0, 6) 786 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 787 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 788 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 789 fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) 790 return "CirculateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 791 } 792 793 func init() { 794 xgb.NewEventFuncs[26] = CirculateNotifyEventNew 795 } 796 797 // CirculateRequest is the event number for a CirculateRequestEvent. 798 const CirculateRequest = 27 799 800 type CirculateRequestEvent CirculateNotifyEvent 801 802 // CirculateRequestEventNew constructs a CirculateRequestEvent value that implements xgb.Event from a byte slice. 803 func CirculateRequestEventNew(buf []byte) xgb.Event { 804 return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) 805 } 806 807 // Bytes writes a CirculateRequestEvent value to a byte slice. 808 func (v CirculateRequestEvent) Bytes() []byte { 809 return CirculateNotifyEvent(v).Bytes() 810 } 811 812 // SequenceId returns the sequence id attached to the CirculateRequest event. 813 // Events without a sequence number (KeymapNotify) return 0. 814 // This is mostly used internally. 815 func (v CirculateRequestEvent) SequenceId() uint16 { 816 return v.Sequence 817 } 818 819 func (v CirculateRequestEvent) String() string { 820 fieldVals := make([]string, 0, 6) 821 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 822 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 823 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 824 fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) 825 return "CirculateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" 826 } 827 828 func init() { 829 xgb.NewEventFuncs[27] = CirculateRequestEventNew 830 } 831 832 // ClientMessage is the event number for a ClientMessageEvent. 833 const ClientMessage = 33 834 835 type ClientMessageEvent struct { 836 Sequence uint16 837 Format byte 838 Window Window 839 Type Atom 840 Data ClientMessageDataUnion 841 } 842 843 // ClientMessageEventNew constructs a ClientMessageEvent value that implements xgb.Event from a byte slice. 844 func ClientMessageEventNew(buf []byte) xgb.Event { 845 v := ClientMessageEvent{} 846 b := 1 // don't read event number 847 848 v.Format = buf[b] 849 b += 1 850 851 v.Sequence = xgb.Get16(buf[b:]) 852 b += 2 853 854 v.Window = Window(xgb.Get32(buf[b:])) 855 b += 4 856 857 v.Type = Atom(xgb.Get32(buf[b:])) 858 b += 4 859 860 v.Data = ClientMessageDataUnion{} 861 b += ClientMessageDataUnionRead(buf[b:], &v.Data) 862 863 return v 864 } 865 866 // Bytes writes a ClientMessageEvent value to a byte slice. 867 func (v ClientMessageEvent) Bytes() []byte { 868 buf := make([]byte, 32) 869 b := 0 870 871 // write event number 872 buf[b] = 33 873 b += 1 874 875 buf[b] = v.Format 876 b += 1 877 878 b += 2 // skip sequence number 879 880 xgb.Put32(buf[b:], uint32(v.Window)) 881 b += 4 882 883 xgb.Put32(buf[b:], uint32(v.Type)) 884 b += 4 885 886 { 887 unionBytes := v.Data.Bytes() 888 copy(buf[b:], unionBytes) 889 b += len(unionBytes) 890 } 891 892 return buf 893 } 894 895 // SequenceId returns the sequence id attached to the ClientMessage event. 896 // Events without a sequence number (KeymapNotify) return 0. 897 // This is mostly used internally. 898 func (v ClientMessageEvent) SequenceId() uint16 { 899 return v.Sequence 900 } 901 902 // String is a rudimentary string representation of ClientMessageEvent. 903 func (v ClientMessageEvent) String() string { 904 fieldVals := make([]string, 0, 4) 905 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 906 fieldVals = append(fieldVals, xgb.Sprintf("Format: %d", v.Format)) 907 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 908 fieldVals = append(fieldVals, xgb.Sprintf("Type: %d", v.Type)) 909 return "ClientMessage {" + xgb.StringsJoin(fieldVals, ", ") + "}" 910 } 911 912 func init() { 913 xgb.NewEventFuncs[33] = ClientMessageEventNew 914 } 915 916 // ClientMessageDataUnion is a represention of the ClientMessageDataUnion union type. 917 // Note that to *create* a Union, you should *never* create 918 // this struct directly (unless you know what you're doing). 919 // Instead use one of the following constructors for 'ClientMessageDataUnion': 920 // ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion 921 // ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion 922 // ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion 923 type ClientMessageDataUnion struct { 924 Data8 []byte // size: 20 925 Data16 []uint16 // size: 20 926 Data32 []uint32 // size: 20 927 } 928 929 // ClientMessageDataUnionData8New constructs a new ClientMessageDataUnion union type with the Data8 field. 930 func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { 931 var b int 932 buf := make([]byte, 20) 933 934 copy(buf[b:], Data8[:20]) 935 b += int(20) 936 937 // Create the Union type 938 v := ClientMessageDataUnion{} 939 940 // Now copy buf into all fields 941 942 b = 0 // always read the same bytes 943 v.Data8 = make([]byte, 20) 944 copy(v.Data8[:20], buf[b:]) 945 b += int(20) 946 947 b = 0 // always read the same bytes 948 v.Data16 = make([]uint16, 10) 949 for i := 0; i < int(10); i++ { 950 v.Data16[i] = xgb.Get16(buf[b:]) 951 b += 2 952 } 953 954 b = 0 // always read the same bytes 955 v.Data32 = make([]uint32, 5) 956 for i := 0; i < int(5); i++ { 957 v.Data32[i] = xgb.Get32(buf[b:]) 958 b += 4 959 } 960 961 return v 962 } 963 964 // ClientMessageDataUnionData16New constructs a new ClientMessageDataUnion union type with the Data16 field. 965 func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { 966 var b int 967 buf := make([]byte, 20) 968 969 for i := 0; i < int(10); i++ { 970 xgb.Put16(buf[b:], Data16[i]) 971 b += 2 972 } 973 974 // Create the Union type 975 v := ClientMessageDataUnion{} 976 977 // Now copy buf into all fields 978 979 b = 0 // always read the same bytes 980 v.Data8 = make([]byte, 20) 981 copy(v.Data8[:20], buf[b:]) 982 b += int(20) 983 984 b = 0 // always read the same bytes 985 v.Data16 = make([]uint16, 10) 986 for i := 0; i < int(10); i++ { 987 v.Data16[i] = xgb.Get16(buf[b:]) 988 b += 2 989 } 990 991 b = 0 // always read the same bytes 992 v.Data32 = make([]uint32, 5) 993 for i := 0; i < int(5); i++ { 994 v.Data32[i] = xgb.Get32(buf[b:]) 995 b += 4 996 } 997 998 return v 999 } 1000 1001 // ClientMessageDataUnionData32New constructs a new ClientMessageDataUnion union type with the Data32 field. 1002 func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { 1003 var b int 1004 buf := make([]byte, 20) 1005 1006 for i := 0; i < int(5); i++ { 1007 xgb.Put32(buf[b:], Data32[i]) 1008 b += 4 1009 } 1010 1011 // Create the Union type 1012 v := ClientMessageDataUnion{} 1013 1014 // Now copy buf into all fields 1015 1016 b = 0 // always read the same bytes 1017 v.Data8 = make([]byte, 20) 1018 copy(v.Data8[:20], buf[b:]) 1019 b += int(20) 1020 1021 b = 0 // always read the same bytes 1022 v.Data16 = make([]uint16, 10) 1023 for i := 0; i < int(10); i++ { 1024 v.Data16[i] = xgb.Get16(buf[b:]) 1025 b += 2 1026 } 1027 1028 b = 0 // always read the same bytes 1029 v.Data32 = make([]uint32, 5) 1030 for i := 0; i < int(5); i++ { 1031 v.Data32[i] = xgb.Get32(buf[b:]) 1032 b += 4 1033 } 1034 1035 return v 1036 } 1037 1038 // ClientMessageDataUnionRead reads a byte slice into a ClientMessageDataUnion value. 1039 func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { 1040 var b int 1041 1042 b = 0 // re-read the same bytes 1043 v.Data8 = make([]byte, 20) 1044 copy(v.Data8[:20], buf[b:]) 1045 b += int(20) 1046 1047 b = 0 // re-read the same bytes 1048 v.Data16 = make([]uint16, 10) 1049 for i := 0; i < int(10); i++ { 1050 v.Data16[i] = xgb.Get16(buf[b:]) 1051 b += 2 1052 } 1053 1054 b = 0 // re-read the same bytes 1055 v.Data32 = make([]uint32, 5) 1056 for i := 0; i < int(5); i++ { 1057 v.Data32[i] = xgb.Get32(buf[b:]) 1058 b += 4 1059 } 1060 1061 return 20 1062 } 1063 1064 // ClientMessageDataUnionReadList reads a byte slice into a list of ClientMessageDataUnion values. 1065 func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) int { 1066 b := 0 1067 for i := 0; i < len(dest); i++ { 1068 dest[i] = ClientMessageDataUnion{} 1069 b += ClientMessageDataUnionRead(buf[b:], &dest[i]) 1070 } 1071 return xgb.Pad(b) 1072 } 1073 1074 // Bytes writes a ClientMessageDataUnion value to a byte slice. 1075 // Each field in a union must contain the same data. 1076 // So simply pick the first field and write that to the wire. 1077 func (v ClientMessageDataUnion) Bytes() []byte { 1078 buf := make([]byte, 20) 1079 b := 0 1080 1081 copy(buf[b:], v.Data8[:20]) 1082 b += int(20) 1083 return buf 1084 } 1085 1086 // ClientMessageDataUnionListBytes writes a list of ClientMessageDataUnion values to a byte slice. 1087 func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { 1088 b := 0 1089 var unionBytes []byte 1090 for _, item := range list { 1091 unionBytes = item.Bytes() 1092 copy(buf[b:], unionBytes) 1093 b += xgb.Pad(len(unionBytes)) 1094 } 1095 return b 1096 } 1097 1098 const ( 1099 ClipOrderingUnsorted = 0 1100 ClipOrderingYSorted = 1 1101 ClipOrderingYXSorted = 2 1102 ClipOrderingYXBanded = 3 1103 ) 1104 1105 const ( 1106 CloseDownDestroyAll = 0 1107 CloseDownRetainPermanent = 1 1108 CloseDownRetainTemporary = 2 1109 ) 1110 1111 const ( 1112 ColorFlagRed = 1 1113 ColorFlagGreen = 2 1114 ColorFlagBlue = 4 1115 ) 1116 1117 type Coloritem struct { 1118 Pixel uint32 1119 Red uint16 1120 Green uint16 1121 Blue uint16 1122 Flags byte 1123 // padding: 1 bytes 1124 } 1125 1126 // ColoritemRead reads a byte slice into a Coloritem value. 1127 func ColoritemRead(buf []byte, v *Coloritem) int { 1128 b := 0 1129 1130 v.Pixel = xgb.Get32(buf[b:]) 1131 b += 4 1132 1133 v.Red = xgb.Get16(buf[b:]) 1134 b += 2 1135 1136 v.Green = xgb.Get16(buf[b:]) 1137 b += 2 1138 1139 v.Blue = xgb.Get16(buf[b:]) 1140 b += 2 1141 1142 v.Flags = buf[b] 1143 b += 1 1144 1145 b += 1 // padding 1146 1147 return b 1148 } 1149 1150 // ColoritemReadList reads a byte slice into a list of Coloritem values. 1151 func ColoritemReadList(buf []byte, dest []Coloritem) int { 1152 b := 0 1153 for i := 0; i < len(dest); i++ { 1154 dest[i] = Coloritem{} 1155 b += ColoritemRead(buf[b:], &dest[i]) 1156 } 1157 return xgb.Pad(b) 1158 } 1159 1160 // Bytes writes a Coloritem value to a byte slice. 1161 func (v Coloritem) Bytes() []byte { 1162 buf := make([]byte, 12) 1163 b := 0 1164 1165 xgb.Put32(buf[b:], v.Pixel) 1166 b += 4 1167 1168 xgb.Put16(buf[b:], v.Red) 1169 b += 2 1170 1171 xgb.Put16(buf[b:], v.Green) 1172 b += 2 1173 1174 xgb.Put16(buf[b:], v.Blue) 1175 b += 2 1176 1177 buf[b] = v.Flags 1178 b += 1 1179 1180 b += 1 // padding 1181 1182 return buf[:b] 1183 } 1184 1185 // ColoritemListBytes writes a list of Coloritem values to a byte slice. 1186 func ColoritemListBytes(buf []byte, list []Coloritem) int { 1187 b := 0 1188 var structBytes []byte 1189 for _, item := range list { 1190 structBytes = item.Bytes() 1191 copy(buf[b:], structBytes) 1192 b += len(structBytes) 1193 } 1194 return xgb.Pad(b) 1195 } 1196 1197 type Colormap uint32 1198 1199 func NewColormapId(c *xgb.Conn) (Colormap, error) { 1200 id, err := c.NewId() 1201 if err != nil { 1202 return 0, err 1203 } 1204 return Colormap(id), nil 1205 } 1206 1207 // BadColormap is the error number for a BadColormap. 1208 const BadColormap = 12 1209 1210 type ColormapError ValueError 1211 1212 // ColormapErrorNew constructs a ColormapError value that implements xgb.Error from a byte slice. 1213 func ColormapErrorNew(buf []byte) xgb.Error { 1214 v := ColormapError(ValueErrorNew(buf).(ValueError)) 1215 v.NiceName = "Colormap" 1216 return v 1217 } 1218 1219 // SequenceId returns the sequence id attached to the BadColormap error. 1220 // This is mostly used internally. 1221 func (err ColormapError) SequenceId() uint16 { 1222 return err.Sequence 1223 } 1224 1225 // BadId returns the 'BadValue' number if one exists for the BadColormap error. If no bad value exists, 0 is returned. 1226 func (err ColormapError) BadId() uint32 { 1227 return err.BadValue 1228 } 1229 1230 // Error returns a rudimentary string representation of the BadColormap error. 1231 func (err ColormapError) Error() string { 1232 fieldVals := make([]string, 0, 4) 1233 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 1234 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 1235 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 1236 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 1237 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 1238 return "BadColormap {" + xgb.StringsJoin(fieldVals, ", ") + "}" 1239 } 1240 1241 func init() { 1242 xgb.NewErrorFuncs[12] = ColormapErrorNew 1243 } 1244 1245 const ( 1246 ColormapNone = 0 1247 ) 1248 1249 const ( 1250 ColormapAllocNone = 0 1251 ColormapAllocAll = 1 1252 ) 1253 1254 // ColormapNotify is the event number for a ColormapNotifyEvent. 1255 const ColormapNotify = 32 1256 1257 type ColormapNotifyEvent struct { 1258 Sequence uint16 1259 // padding: 1 bytes 1260 Window Window 1261 Colormap Colormap 1262 New bool 1263 State byte 1264 // padding: 2 bytes 1265 } 1266 1267 // ColormapNotifyEventNew constructs a ColormapNotifyEvent value that implements xgb.Event from a byte slice. 1268 func ColormapNotifyEventNew(buf []byte) xgb.Event { 1269 v := ColormapNotifyEvent{} 1270 b := 1 // don't read event number 1271 1272 b += 1 // padding 1273 1274 v.Sequence = xgb.Get16(buf[b:]) 1275 b += 2 1276 1277 v.Window = Window(xgb.Get32(buf[b:])) 1278 b += 4 1279 1280 v.Colormap = Colormap(xgb.Get32(buf[b:])) 1281 b += 4 1282 1283 if buf[b] == 1 { 1284 v.New = true 1285 } else { 1286 v.New = false 1287 } 1288 b += 1 1289 1290 v.State = buf[b] 1291 b += 1 1292 1293 b += 2 // padding 1294 1295 return v 1296 } 1297 1298 // Bytes writes a ColormapNotifyEvent value to a byte slice. 1299 func (v ColormapNotifyEvent) Bytes() []byte { 1300 buf := make([]byte, 32) 1301 b := 0 1302 1303 // write event number 1304 buf[b] = 32 1305 b += 1 1306 1307 b += 1 // padding 1308 1309 b += 2 // skip sequence number 1310 1311 xgb.Put32(buf[b:], uint32(v.Window)) 1312 b += 4 1313 1314 xgb.Put32(buf[b:], uint32(v.Colormap)) 1315 b += 4 1316 1317 if v.New { 1318 buf[b] = 1 1319 } else { 1320 buf[b] = 0 1321 } 1322 b += 1 1323 1324 buf[b] = v.State 1325 b += 1 1326 1327 b += 2 // padding 1328 1329 return buf 1330 } 1331 1332 // SequenceId returns the sequence id attached to the ColormapNotify event. 1333 // Events without a sequence number (KeymapNotify) return 0. 1334 // This is mostly used internally. 1335 func (v ColormapNotifyEvent) SequenceId() uint16 { 1336 return v.Sequence 1337 } 1338 1339 // String is a rudimentary string representation of ColormapNotifyEvent. 1340 func (v ColormapNotifyEvent) String() string { 1341 fieldVals := make([]string, 0, 6) 1342 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 1343 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 1344 fieldVals = append(fieldVals, xgb.Sprintf("Colormap: %d", v.Colormap)) 1345 fieldVals = append(fieldVals, xgb.Sprintf("New: %t", v.New)) 1346 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 1347 return "ColormapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 1348 } 1349 1350 func init() { 1351 xgb.NewEventFuncs[32] = ColormapNotifyEventNew 1352 } 1353 1354 const ( 1355 ColormapStateUninstalled = 0 1356 ColormapStateInstalled = 1 1357 ) 1358 1359 const ( 1360 ConfigWindowX = 1 1361 ConfigWindowY = 2 1362 ConfigWindowWidth = 4 1363 ConfigWindowHeight = 8 1364 ConfigWindowBorderWidth = 16 1365 ConfigWindowSibling = 32 1366 ConfigWindowStackMode = 64 1367 ) 1368 1369 // ConfigureNotify is the event number for a ConfigureNotifyEvent. 1370 const ConfigureNotify = 22 1371 1372 type ConfigureNotifyEvent struct { 1373 Sequence uint16 1374 // padding: 1 bytes 1375 Event Window 1376 Window Window 1377 AboveSibling Window 1378 X int16 1379 Y int16 1380 Width uint16 1381 Height uint16 1382 BorderWidth uint16 1383 OverrideRedirect bool 1384 // padding: 1 bytes 1385 } 1386 1387 // ConfigureNotifyEventNew constructs a ConfigureNotifyEvent value that implements xgb.Event from a byte slice. 1388 func ConfigureNotifyEventNew(buf []byte) xgb.Event { 1389 v := ConfigureNotifyEvent{} 1390 b := 1 // don't read event number 1391 1392 b += 1 // padding 1393 1394 v.Sequence = xgb.Get16(buf[b:]) 1395 b += 2 1396 1397 v.Event = Window(xgb.Get32(buf[b:])) 1398 b += 4 1399 1400 v.Window = Window(xgb.Get32(buf[b:])) 1401 b += 4 1402 1403 v.AboveSibling = Window(xgb.Get32(buf[b:])) 1404 b += 4 1405 1406 v.X = int16(xgb.Get16(buf[b:])) 1407 b += 2 1408 1409 v.Y = int16(xgb.Get16(buf[b:])) 1410 b += 2 1411 1412 v.Width = xgb.Get16(buf[b:]) 1413 b += 2 1414 1415 v.Height = xgb.Get16(buf[b:]) 1416 b += 2 1417 1418 v.BorderWidth = xgb.Get16(buf[b:]) 1419 b += 2 1420 1421 if buf[b] == 1 { 1422 v.OverrideRedirect = true 1423 } else { 1424 v.OverrideRedirect = false 1425 } 1426 b += 1 1427 1428 b += 1 // padding 1429 1430 return v 1431 } 1432 1433 // Bytes writes a ConfigureNotifyEvent value to a byte slice. 1434 func (v ConfigureNotifyEvent) Bytes() []byte { 1435 buf := make([]byte, 32) 1436 b := 0 1437 1438 // write event number 1439 buf[b] = 22 1440 b += 1 1441 1442 b += 1 // padding 1443 1444 b += 2 // skip sequence number 1445 1446 xgb.Put32(buf[b:], uint32(v.Event)) 1447 b += 4 1448 1449 xgb.Put32(buf[b:], uint32(v.Window)) 1450 b += 4 1451 1452 xgb.Put32(buf[b:], uint32(v.AboveSibling)) 1453 b += 4 1454 1455 xgb.Put16(buf[b:], uint16(v.X)) 1456 b += 2 1457 1458 xgb.Put16(buf[b:], uint16(v.Y)) 1459 b += 2 1460 1461 xgb.Put16(buf[b:], v.Width) 1462 b += 2 1463 1464 xgb.Put16(buf[b:], v.Height) 1465 b += 2 1466 1467 xgb.Put16(buf[b:], v.BorderWidth) 1468 b += 2 1469 1470 if v.OverrideRedirect { 1471 buf[b] = 1 1472 } else { 1473 buf[b] = 0 1474 } 1475 b += 1 1476 1477 b += 1 // padding 1478 1479 return buf 1480 } 1481 1482 // SequenceId returns the sequence id attached to the ConfigureNotify event. 1483 // Events without a sequence number (KeymapNotify) return 0. 1484 // This is mostly used internally. 1485 func (v ConfigureNotifyEvent) SequenceId() uint16 { 1486 return v.Sequence 1487 } 1488 1489 // String is a rudimentary string representation of ConfigureNotifyEvent. 1490 func (v ConfigureNotifyEvent) String() string { 1491 fieldVals := make([]string, 0, 11) 1492 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 1493 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 1494 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 1495 fieldVals = append(fieldVals, xgb.Sprintf("AboveSibling: %d", v.AboveSibling)) 1496 fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) 1497 fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) 1498 fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) 1499 fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) 1500 fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) 1501 fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) 1502 return "ConfigureNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 1503 } 1504 1505 func init() { 1506 xgb.NewEventFuncs[22] = ConfigureNotifyEventNew 1507 } 1508 1509 // ConfigureRequest is the event number for a ConfigureRequestEvent. 1510 const ConfigureRequest = 23 1511 1512 type ConfigureRequestEvent struct { 1513 Sequence uint16 1514 StackMode byte 1515 Parent Window 1516 Window Window 1517 Sibling Window 1518 X int16 1519 Y int16 1520 Width uint16 1521 Height uint16 1522 BorderWidth uint16 1523 ValueMask uint16 1524 } 1525 1526 // ConfigureRequestEventNew constructs a ConfigureRequestEvent value that implements xgb.Event from a byte slice. 1527 func ConfigureRequestEventNew(buf []byte) xgb.Event { 1528 v := ConfigureRequestEvent{} 1529 b := 1 // don't read event number 1530 1531 v.StackMode = buf[b] 1532 b += 1 1533 1534 v.Sequence = xgb.Get16(buf[b:]) 1535 b += 2 1536 1537 v.Parent = Window(xgb.Get32(buf[b:])) 1538 b += 4 1539 1540 v.Window = Window(xgb.Get32(buf[b:])) 1541 b += 4 1542 1543 v.Sibling = Window(xgb.Get32(buf[b:])) 1544 b += 4 1545 1546 v.X = int16(xgb.Get16(buf[b:])) 1547 b += 2 1548 1549 v.Y = int16(xgb.Get16(buf[b:])) 1550 b += 2 1551 1552 v.Width = xgb.Get16(buf[b:]) 1553 b += 2 1554 1555 v.Height = xgb.Get16(buf[b:]) 1556 b += 2 1557 1558 v.BorderWidth = xgb.Get16(buf[b:]) 1559 b += 2 1560 1561 v.ValueMask = xgb.Get16(buf[b:]) 1562 b += 2 1563 1564 return v 1565 } 1566 1567 // Bytes writes a ConfigureRequestEvent value to a byte slice. 1568 func (v ConfigureRequestEvent) Bytes() []byte { 1569 buf := make([]byte, 32) 1570 b := 0 1571 1572 // write event number 1573 buf[b] = 23 1574 b += 1 1575 1576 buf[b] = v.StackMode 1577 b += 1 1578 1579 b += 2 // skip sequence number 1580 1581 xgb.Put32(buf[b:], uint32(v.Parent)) 1582 b += 4 1583 1584 xgb.Put32(buf[b:], uint32(v.Window)) 1585 b += 4 1586 1587 xgb.Put32(buf[b:], uint32(v.Sibling)) 1588 b += 4 1589 1590 xgb.Put16(buf[b:], uint16(v.X)) 1591 b += 2 1592 1593 xgb.Put16(buf[b:], uint16(v.Y)) 1594 b += 2 1595 1596 xgb.Put16(buf[b:], v.Width) 1597 b += 2 1598 1599 xgb.Put16(buf[b:], v.Height) 1600 b += 2 1601 1602 xgb.Put16(buf[b:], v.BorderWidth) 1603 b += 2 1604 1605 xgb.Put16(buf[b:], v.ValueMask) 1606 b += 2 1607 1608 return buf 1609 } 1610 1611 // SequenceId returns the sequence id attached to the ConfigureRequest event. 1612 // Events without a sequence number (KeymapNotify) return 0. 1613 // This is mostly used internally. 1614 func (v ConfigureRequestEvent) SequenceId() uint16 { 1615 return v.Sequence 1616 } 1617 1618 // String is a rudimentary string representation of ConfigureRequestEvent. 1619 func (v ConfigureRequestEvent) String() string { 1620 fieldVals := make([]string, 0, 10) 1621 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 1622 fieldVals = append(fieldVals, xgb.Sprintf("StackMode: %d", v.StackMode)) 1623 fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) 1624 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 1625 fieldVals = append(fieldVals, xgb.Sprintf("Sibling: %d", v.Sibling)) 1626 fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) 1627 fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) 1628 fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) 1629 fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) 1630 fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) 1631 fieldVals = append(fieldVals, xgb.Sprintf("ValueMask: %d", v.ValueMask)) 1632 return "ConfigureRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" 1633 } 1634 1635 func init() { 1636 xgb.NewEventFuncs[23] = ConfigureRequestEventNew 1637 } 1638 1639 const ( 1640 CoordModeOrigin = 0 1641 CoordModePrevious = 1 1642 ) 1643 1644 // CreateNotify is the event number for a CreateNotifyEvent. 1645 const CreateNotify = 16 1646 1647 type CreateNotifyEvent struct { 1648 Sequence uint16 1649 // padding: 1 bytes 1650 Parent Window 1651 Window Window 1652 X int16 1653 Y int16 1654 Width uint16 1655 Height uint16 1656 BorderWidth uint16 1657 OverrideRedirect bool 1658 // padding: 1 bytes 1659 } 1660 1661 // CreateNotifyEventNew constructs a CreateNotifyEvent value that implements xgb.Event from a byte slice. 1662 func CreateNotifyEventNew(buf []byte) xgb.Event { 1663 v := CreateNotifyEvent{} 1664 b := 1 // don't read event number 1665 1666 b += 1 // padding 1667 1668 v.Sequence = xgb.Get16(buf[b:]) 1669 b += 2 1670 1671 v.Parent = Window(xgb.Get32(buf[b:])) 1672 b += 4 1673 1674 v.Window = Window(xgb.Get32(buf[b:])) 1675 b += 4 1676 1677 v.X = int16(xgb.Get16(buf[b:])) 1678 b += 2 1679 1680 v.Y = int16(xgb.Get16(buf[b:])) 1681 b += 2 1682 1683 v.Width = xgb.Get16(buf[b:]) 1684 b += 2 1685 1686 v.Height = xgb.Get16(buf[b:]) 1687 b += 2 1688 1689 v.BorderWidth = xgb.Get16(buf[b:]) 1690 b += 2 1691 1692 if buf[b] == 1 { 1693 v.OverrideRedirect = true 1694 } else { 1695 v.OverrideRedirect = false 1696 } 1697 b += 1 1698 1699 b += 1 // padding 1700 1701 return v 1702 } 1703 1704 // Bytes writes a CreateNotifyEvent value to a byte slice. 1705 func (v CreateNotifyEvent) Bytes() []byte { 1706 buf := make([]byte, 32) 1707 b := 0 1708 1709 // write event number 1710 buf[b] = 16 1711 b += 1 1712 1713 b += 1 // padding 1714 1715 b += 2 // skip sequence number 1716 1717 xgb.Put32(buf[b:], uint32(v.Parent)) 1718 b += 4 1719 1720 xgb.Put32(buf[b:], uint32(v.Window)) 1721 b += 4 1722 1723 xgb.Put16(buf[b:], uint16(v.X)) 1724 b += 2 1725 1726 xgb.Put16(buf[b:], uint16(v.Y)) 1727 b += 2 1728 1729 xgb.Put16(buf[b:], v.Width) 1730 b += 2 1731 1732 xgb.Put16(buf[b:], v.Height) 1733 b += 2 1734 1735 xgb.Put16(buf[b:], v.BorderWidth) 1736 b += 2 1737 1738 if v.OverrideRedirect { 1739 buf[b] = 1 1740 } else { 1741 buf[b] = 0 1742 } 1743 b += 1 1744 1745 b += 1 // padding 1746 1747 return buf 1748 } 1749 1750 // SequenceId returns the sequence id attached to the CreateNotify event. 1751 // Events without a sequence number (KeymapNotify) return 0. 1752 // This is mostly used internally. 1753 func (v CreateNotifyEvent) SequenceId() uint16 { 1754 return v.Sequence 1755 } 1756 1757 // String is a rudimentary string representation of CreateNotifyEvent. 1758 func (v CreateNotifyEvent) String() string { 1759 fieldVals := make([]string, 0, 10) 1760 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 1761 fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) 1762 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 1763 fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) 1764 fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) 1765 fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) 1766 fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) 1767 fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) 1768 fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) 1769 return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 1770 } 1771 1772 func init() { 1773 xgb.NewEventFuncs[16] = CreateNotifyEventNew 1774 } 1775 1776 type Cursor uint32 1777 1778 func NewCursorId(c *xgb.Conn) (Cursor, error) { 1779 id, err := c.NewId() 1780 if err != nil { 1781 return 0, err 1782 } 1783 return Cursor(id), nil 1784 } 1785 1786 // BadCursor is the error number for a BadCursor. 1787 const BadCursor = 6 1788 1789 type CursorError ValueError 1790 1791 // CursorErrorNew constructs a CursorError value that implements xgb.Error from a byte slice. 1792 func CursorErrorNew(buf []byte) xgb.Error { 1793 v := CursorError(ValueErrorNew(buf).(ValueError)) 1794 v.NiceName = "Cursor" 1795 return v 1796 } 1797 1798 // SequenceId returns the sequence id attached to the BadCursor error. 1799 // This is mostly used internally. 1800 func (err CursorError) SequenceId() uint16 { 1801 return err.Sequence 1802 } 1803 1804 // BadId returns the 'BadValue' number if one exists for the BadCursor error. If no bad value exists, 0 is returned. 1805 func (err CursorError) BadId() uint32 { 1806 return err.BadValue 1807 } 1808 1809 // Error returns a rudimentary string representation of the BadCursor error. 1810 func (err CursorError) Error() string { 1811 fieldVals := make([]string, 0, 4) 1812 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 1813 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 1814 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 1815 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 1816 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 1817 return "BadCursor {" + xgb.StringsJoin(fieldVals, ", ") + "}" 1818 } 1819 1820 func init() { 1821 xgb.NewErrorFuncs[6] = CursorErrorNew 1822 } 1823 1824 const ( 1825 CursorNone = 0 1826 ) 1827 1828 const ( 1829 CwBackPixmap = 1 1830 CwBackPixel = 2 1831 CwBorderPixmap = 4 1832 CwBorderPixel = 8 1833 CwBitGravity = 16 1834 CwWinGravity = 32 1835 CwBackingStore = 64 1836 CwBackingPlanes = 128 1837 CwBackingPixel = 256 1838 CwOverrideRedirect = 512 1839 CwSaveUnder = 1024 1840 CwEventMask = 2048 1841 CwDontPropagate = 4096 1842 CwColormap = 8192 1843 CwCursor = 16384 1844 ) 1845 1846 type DepthInfo struct { 1847 Depth byte 1848 // padding: 1 bytes 1849 VisualsLen uint16 1850 // padding: 4 bytes 1851 Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) 1852 } 1853 1854 // DepthInfoRead reads a byte slice into a DepthInfo value. 1855 func DepthInfoRead(buf []byte, v *DepthInfo) int { 1856 b := 0 1857 1858 v.Depth = buf[b] 1859 b += 1 1860 1861 b += 1 // padding 1862 1863 v.VisualsLen = xgb.Get16(buf[b:]) 1864 b += 2 1865 1866 b += 4 // padding 1867 1868 v.Visuals = make([]VisualInfo, v.VisualsLen) 1869 b += VisualInfoReadList(buf[b:], v.Visuals) 1870 1871 return b 1872 } 1873 1874 // DepthInfoReadList reads a byte slice into a list of DepthInfo values. 1875 func DepthInfoReadList(buf []byte, dest []DepthInfo) int { 1876 b := 0 1877 for i := 0; i < len(dest); i++ { 1878 dest[i] = DepthInfo{} 1879 b += DepthInfoRead(buf[b:], &dest[i]) 1880 } 1881 return xgb.Pad(b) 1882 } 1883 1884 // Bytes writes a DepthInfo value to a byte slice. 1885 func (v DepthInfo) Bytes() []byte { 1886 buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) 1887 b := 0 1888 1889 buf[b] = v.Depth 1890 b += 1 1891 1892 b += 1 // padding 1893 1894 xgb.Put16(buf[b:], v.VisualsLen) 1895 b += 2 1896 1897 b += 4 // padding 1898 1899 b += VisualInfoListBytes(buf[b:], v.Visuals) 1900 1901 return buf[:b] 1902 } 1903 1904 // DepthInfoListBytes writes a list of DepthInfo values to a byte slice. 1905 func DepthInfoListBytes(buf []byte, list []DepthInfo) int { 1906 b := 0 1907 var structBytes []byte 1908 for _, item := range list { 1909 structBytes = item.Bytes() 1910 copy(buf[b:], structBytes) 1911 b += len(structBytes) 1912 } 1913 return xgb.Pad(b) 1914 } 1915 1916 // DepthInfoListSize computes the size (bytes) of a list of DepthInfo values. 1917 func DepthInfoListSize(list []DepthInfo) int { 1918 size := 0 1919 for _, item := range list { 1920 size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) 1921 } 1922 return size 1923 } 1924 1925 // DestroyNotify is the event number for a DestroyNotifyEvent. 1926 const DestroyNotify = 17 1927 1928 type DestroyNotifyEvent struct { 1929 Sequence uint16 1930 // padding: 1 bytes 1931 Event Window 1932 Window Window 1933 } 1934 1935 // DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. 1936 func DestroyNotifyEventNew(buf []byte) xgb.Event { 1937 v := DestroyNotifyEvent{} 1938 b := 1 // don't read event number 1939 1940 b += 1 // padding 1941 1942 v.Sequence = xgb.Get16(buf[b:]) 1943 b += 2 1944 1945 v.Event = Window(xgb.Get32(buf[b:])) 1946 b += 4 1947 1948 v.Window = Window(xgb.Get32(buf[b:])) 1949 b += 4 1950 1951 return v 1952 } 1953 1954 // Bytes writes a DestroyNotifyEvent value to a byte slice. 1955 func (v DestroyNotifyEvent) Bytes() []byte { 1956 buf := make([]byte, 32) 1957 b := 0 1958 1959 // write event number 1960 buf[b] = 17 1961 b += 1 1962 1963 b += 1 // padding 1964 1965 b += 2 // skip sequence number 1966 1967 xgb.Put32(buf[b:], uint32(v.Event)) 1968 b += 4 1969 1970 xgb.Put32(buf[b:], uint32(v.Window)) 1971 b += 4 1972 1973 return buf 1974 } 1975 1976 // SequenceId returns the sequence id attached to the DestroyNotify event. 1977 // Events without a sequence number (KeymapNotify) return 0. 1978 // This is mostly used internally. 1979 func (v DestroyNotifyEvent) SequenceId() uint16 { 1980 return v.Sequence 1981 } 1982 1983 // String is a rudimentary string representation of DestroyNotifyEvent. 1984 func (v DestroyNotifyEvent) String() string { 1985 fieldVals := make([]string, 0, 3) 1986 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 1987 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 1988 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 1989 return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 1990 } 1991 1992 func init() { 1993 xgb.NewEventFuncs[17] = DestroyNotifyEventNew 1994 } 1995 1996 type Drawable uint32 1997 1998 func NewDrawableId(c *xgb.Conn) (Drawable, error) { 1999 id, err := c.NewId() 2000 if err != nil { 2001 return 0, err 2002 } 2003 return Drawable(id), nil 2004 } 2005 2006 // BadDrawable is the error number for a BadDrawable. 2007 const BadDrawable = 9 2008 2009 type DrawableError ValueError 2010 2011 // DrawableErrorNew constructs a DrawableError value that implements xgb.Error from a byte slice. 2012 func DrawableErrorNew(buf []byte) xgb.Error { 2013 v := DrawableError(ValueErrorNew(buf).(ValueError)) 2014 v.NiceName = "Drawable" 2015 return v 2016 } 2017 2018 // SequenceId returns the sequence id attached to the BadDrawable error. 2019 // This is mostly used internally. 2020 func (err DrawableError) SequenceId() uint16 { 2021 return err.Sequence 2022 } 2023 2024 // BadId returns the 'BadValue' number if one exists for the BadDrawable error. If no bad value exists, 0 is returned. 2025 func (err DrawableError) BadId() uint32 { 2026 return err.BadValue 2027 } 2028 2029 // Error returns a rudimentary string representation of the BadDrawable error. 2030 func (err DrawableError) Error() string { 2031 fieldVals := make([]string, 0, 4) 2032 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 2033 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 2034 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 2035 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 2036 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 2037 return "BadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2038 } 2039 2040 func init() { 2041 xgb.NewErrorFuncs[9] = DrawableErrorNew 2042 } 2043 2044 // EnterNotify is the event number for a EnterNotifyEvent. 2045 const EnterNotify = 7 2046 2047 type EnterNotifyEvent struct { 2048 Sequence uint16 2049 Detail byte 2050 Time Timestamp 2051 Root Window 2052 Event Window 2053 Child Window 2054 RootX int16 2055 RootY int16 2056 EventX int16 2057 EventY int16 2058 State uint16 2059 Mode byte 2060 SameScreenFocus byte 2061 } 2062 2063 // EnterNotifyEventNew constructs a EnterNotifyEvent value that implements xgb.Event from a byte slice. 2064 func EnterNotifyEventNew(buf []byte) xgb.Event { 2065 v := EnterNotifyEvent{} 2066 b := 1 // don't read event number 2067 2068 v.Detail = buf[b] 2069 b += 1 2070 2071 v.Sequence = xgb.Get16(buf[b:]) 2072 b += 2 2073 2074 v.Time = Timestamp(xgb.Get32(buf[b:])) 2075 b += 4 2076 2077 v.Root = Window(xgb.Get32(buf[b:])) 2078 b += 4 2079 2080 v.Event = Window(xgb.Get32(buf[b:])) 2081 b += 4 2082 2083 v.Child = Window(xgb.Get32(buf[b:])) 2084 b += 4 2085 2086 v.RootX = int16(xgb.Get16(buf[b:])) 2087 b += 2 2088 2089 v.RootY = int16(xgb.Get16(buf[b:])) 2090 b += 2 2091 2092 v.EventX = int16(xgb.Get16(buf[b:])) 2093 b += 2 2094 2095 v.EventY = int16(xgb.Get16(buf[b:])) 2096 b += 2 2097 2098 v.State = xgb.Get16(buf[b:]) 2099 b += 2 2100 2101 v.Mode = buf[b] 2102 b += 1 2103 2104 v.SameScreenFocus = buf[b] 2105 b += 1 2106 2107 return v 2108 } 2109 2110 // Bytes writes a EnterNotifyEvent value to a byte slice. 2111 func (v EnterNotifyEvent) Bytes() []byte { 2112 buf := make([]byte, 32) 2113 b := 0 2114 2115 // write event number 2116 buf[b] = 7 2117 b += 1 2118 2119 buf[b] = v.Detail 2120 b += 1 2121 2122 b += 2 // skip sequence number 2123 2124 xgb.Put32(buf[b:], uint32(v.Time)) 2125 b += 4 2126 2127 xgb.Put32(buf[b:], uint32(v.Root)) 2128 b += 4 2129 2130 xgb.Put32(buf[b:], uint32(v.Event)) 2131 b += 4 2132 2133 xgb.Put32(buf[b:], uint32(v.Child)) 2134 b += 4 2135 2136 xgb.Put16(buf[b:], uint16(v.RootX)) 2137 b += 2 2138 2139 xgb.Put16(buf[b:], uint16(v.RootY)) 2140 b += 2 2141 2142 xgb.Put16(buf[b:], uint16(v.EventX)) 2143 b += 2 2144 2145 xgb.Put16(buf[b:], uint16(v.EventY)) 2146 b += 2 2147 2148 xgb.Put16(buf[b:], v.State) 2149 b += 2 2150 2151 buf[b] = v.Mode 2152 b += 1 2153 2154 buf[b] = v.SameScreenFocus 2155 b += 1 2156 2157 return buf 2158 } 2159 2160 // SequenceId returns the sequence id attached to the EnterNotify event. 2161 // Events without a sequence number (KeymapNotify) return 0. 2162 // This is mostly used internally. 2163 func (v EnterNotifyEvent) SequenceId() uint16 { 2164 return v.Sequence 2165 } 2166 2167 // String is a rudimentary string representation of EnterNotifyEvent. 2168 func (v EnterNotifyEvent) String() string { 2169 fieldVals := make([]string, 0, 12) 2170 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 2171 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 2172 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 2173 fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) 2174 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 2175 fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) 2176 fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) 2177 fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) 2178 fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) 2179 fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) 2180 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 2181 fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) 2182 fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) 2183 return "EnterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2184 } 2185 2186 func init() { 2187 xgb.NewEventFuncs[7] = EnterNotifyEventNew 2188 } 2189 2190 const ( 2191 EventMaskNoEvent = 0 2192 EventMaskKeyPress = 1 2193 EventMaskKeyRelease = 2 2194 EventMaskButtonPress = 4 2195 EventMaskButtonRelease = 8 2196 EventMaskEnterWindow = 16 2197 EventMaskLeaveWindow = 32 2198 EventMaskPointerMotion = 64 2199 EventMaskPointerMotionHint = 128 2200 EventMaskButton1Motion = 256 2201 EventMaskButton2Motion = 512 2202 EventMaskButton3Motion = 1024 2203 EventMaskButton4Motion = 2048 2204 EventMaskButton5Motion = 4096 2205 EventMaskButtonMotion = 8192 2206 EventMaskKeymapState = 16384 2207 EventMaskExposure = 32768 2208 EventMaskVisibilityChange = 65536 2209 EventMaskStructureNotify = 131072 2210 EventMaskResizeRedirect = 262144 2211 EventMaskSubstructureNotify = 524288 2212 EventMaskSubstructureRedirect = 1048576 2213 EventMaskFocusChange = 2097152 2214 EventMaskPropertyChange = 4194304 2215 EventMaskColorMapChange = 8388608 2216 EventMaskOwnerGrabButton = 16777216 2217 ) 2218 2219 // Expose is the event number for a ExposeEvent. 2220 const Expose = 12 2221 2222 type ExposeEvent struct { 2223 Sequence uint16 2224 // padding: 1 bytes 2225 Window Window 2226 X uint16 2227 Y uint16 2228 Width uint16 2229 Height uint16 2230 Count uint16 2231 // padding: 2 bytes 2232 } 2233 2234 // ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. 2235 func ExposeEventNew(buf []byte) xgb.Event { 2236 v := ExposeEvent{} 2237 b := 1 // don't read event number 2238 2239 b += 1 // padding 2240 2241 v.Sequence = xgb.Get16(buf[b:]) 2242 b += 2 2243 2244 v.Window = Window(xgb.Get32(buf[b:])) 2245 b += 4 2246 2247 v.X = xgb.Get16(buf[b:]) 2248 b += 2 2249 2250 v.Y = xgb.Get16(buf[b:]) 2251 b += 2 2252 2253 v.Width = xgb.Get16(buf[b:]) 2254 b += 2 2255 2256 v.Height = xgb.Get16(buf[b:]) 2257 b += 2 2258 2259 v.Count = xgb.Get16(buf[b:]) 2260 b += 2 2261 2262 b += 2 // padding 2263 2264 return v 2265 } 2266 2267 // Bytes writes a ExposeEvent value to a byte slice. 2268 func (v ExposeEvent) Bytes() []byte { 2269 buf := make([]byte, 32) 2270 b := 0 2271 2272 // write event number 2273 buf[b] = 12 2274 b += 1 2275 2276 b += 1 // padding 2277 2278 b += 2 // skip sequence number 2279 2280 xgb.Put32(buf[b:], uint32(v.Window)) 2281 b += 4 2282 2283 xgb.Put16(buf[b:], v.X) 2284 b += 2 2285 2286 xgb.Put16(buf[b:], v.Y) 2287 b += 2 2288 2289 xgb.Put16(buf[b:], v.Width) 2290 b += 2 2291 2292 xgb.Put16(buf[b:], v.Height) 2293 b += 2 2294 2295 xgb.Put16(buf[b:], v.Count) 2296 b += 2 2297 2298 b += 2 // padding 2299 2300 return buf 2301 } 2302 2303 // SequenceId returns the sequence id attached to the Expose event. 2304 // Events without a sequence number (KeymapNotify) return 0. 2305 // This is mostly used internally. 2306 func (v ExposeEvent) SequenceId() uint16 { 2307 return v.Sequence 2308 } 2309 2310 // String is a rudimentary string representation of ExposeEvent. 2311 func (v ExposeEvent) String() string { 2312 fieldVals := make([]string, 0, 8) 2313 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 2314 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 2315 fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) 2316 fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) 2317 fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) 2318 fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) 2319 fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) 2320 return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2321 } 2322 2323 func init() { 2324 xgb.NewEventFuncs[12] = ExposeEventNew 2325 } 2326 2327 const ( 2328 ExposuresNotAllowed = 0 2329 ExposuresAllowed = 1 2330 ExposuresDefault = 2 2331 ) 2332 2333 const ( 2334 FamilyInternet = 0 2335 FamilyDECnet = 1 2336 FamilyChaos = 2 2337 FamilyServerInterpreted = 5 2338 FamilyInternet6 = 6 2339 ) 2340 2341 const ( 2342 FillRuleEvenOdd = 0 2343 FillRuleWinding = 1 2344 ) 2345 2346 const ( 2347 FillStyleSolid = 0 2348 FillStyleTiled = 1 2349 FillStyleStippled = 2 2350 FillStyleOpaqueStippled = 3 2351 ) 2352 2353 // FocusIn is the event number for a FocusInEvent. 2354 const FocusIn = 9 2355 2356 type FocusInEvent struct { 2357 Sequence uint16 2358 Detail byte 2359 Event Window 2360 Mode byte 2361 // padding: 3 bytes 2362 } 2363 2364 // FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. 2365 func FocusInEventNew(buf []byte) xgb.Event { 2366 v := FocusInEvent{} 2367 b := 1 // don't read event number 2368 2369 v.Detail = buf[b] 2370 b += 1 2371 2372 v.Sequence = xgb.Get16(buf[b:]) 2373 b += 2 2374 2375 v.Event = Window(xgb.Get32(buf[b:])) 2376 b += 4 2377 2378 v.Mode = buf[b] 2379 b += 1 2380 2381 b += 3 // padding 2382 2383 return v 2384 } 2385 2386 // Bytes writes a FocusInEvent value to a byte slice. 2387 func (v FocusInEvent) Bytes() []byte { 2388 buf := make([]byte, 32) 2389 b := 0 2390 2391 // write event number 2392 buf[b] = 9 2393 b += 1 2394 2395 buf[b] = v.Detail 2396 b += 1 2397 2398 b += 2 // skip sequence number 2399 2400 xgb.Put32(buf[b:], uint32(v.Event)) 2401 b += 4 2402 2403 buf[b] = v.Mode 2404 b += 1 2405 2406 b += 3 // padding 2407 2408 return buf 2409 } 2410 2411 // SequenceId returns the sequence id attached to the FocusIn event. 2412 // Events without a sequence number (KeymapNotify) return 0. 2413 // This is mostly used internally. 2414 func (v FocusInEvent) SequenceId() uint16 { 2415 return v.Sequence 2416 } 2417 2418 // String is a rudimentary string representation of FocusInEvent. 2419 func (v FocusInEvent) String() string { 2420 fieldVals := make([]string, 0, 4) 2421 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 2422 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 2423 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 2424 fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) 2425 return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2426 } 2427 2428 func init() { 2429 xgb.NewEventFuncs[9] = FocusInEventNew 2430 } 2431 2432 // FocusOut is the event number for a FocusOutEvent. 2433 const FocusOut = 10 2434 2435 type FocusOutEvent FocusInEvent 2436 2437 // FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. 2438 func FocusOutEventNew(buf []byte) xgb.Event { 2439 return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) 2440 } 2441 2442 // Bytes writes a FocusOutEvent value to a byte slice. 2443 func (v FocusOutEvent) Bytes() []byte { 2444 return FocusInEvent(v).Bytes() 2445 } 2446 2447 // SequenceId returns the sequence id attached to the FocusOut event. 2448 // Events without a sequence number (KeymapNotify) return 0. 2449 // This is mostly used internally. 2450 func (v FocusOutEvent) SequenceId() uint16 { 2451 return v.Sequence 2452 } 2453 2454 func (v FocusOutEvent) String() string { 2455 fieldVals := make([]string, 0, 4) 2456 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 2457 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 2458 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 2459 fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) 2460 return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2461 } 2462 2463 func init() { 2464 xgb.NewEventFuncs[10] = FocusOutEventNew 2465 } 2466 2467 type Font uint32 2468 2469 func NewFontId(c *xgb.Conn) (Font, error) { 2470 id, err := c.NewId() 2471 if err != nil { 2472 return 0, err 2473 } 2474 return Font(id), nil 2475 } 2476 2477 // BadFont is the error number for a BadFont. 2478 const BadFont = 7 2479 2480 type FontError ValueError 2481 2482 // FontErrorNew constructs a FontError value that implements xgb.Error from a byte slice. 2483 func FontErrorNew(buf []byte) xgb.Error { 2484 v := FontError(ValueErrorNew(buf).(ValueError)) 2485 v.NiceName = "Font" 2486 return v 2487 } 2488 2489 // SequenceId returns the sequence id attached to the BadFont error. 2490 // This is mostly used internally. 2491 func (err FontError) SequenceId() uint16 { 2492 return err.Sequence 2493 } 2494 2495 // BadId returns the 'BadValue' number if one exists for the BadFont error. If no bad value exists, 0 is returned. 2496 func (err FontError) BadId() uint32 { 2497 return err.BadValue 2498 } 2499 2500 // Error returns a rudimentary string representation of the BadFont error. 2501 func (err FontError) Error() string { 2502 fieldVals := make([]string, 0, 4) 2503 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 2504 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 2505 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 2506 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 2507 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 2508 return "BadFont {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2509 } 2510 2511 func init() { 2512 xgb.NewErrorFuncs[7] = FontErrorNew 2513 } 2514 2515 const ( 2516 FontNone = 0 2517 ) 2518 2519 const ( 2520 FontDrawLeftToRight = 0 2521 FontDrawRightToLeft = 1 2522 ) 2523 2524 type Fontable uint32 2525 2526 func NewFontableId(c *xgb.Conn) (Fontable, error) { 2527 id, err := c.NewId() 2528 if err != nil { 2529 return 0, err 2530 } 2531 return Fontable(id), nil 2532 } 2533 2534 type Fontprop struct { 2535 Name Atom 2536 Value uint32 2537 } 2538 2539 // FontpropRead reads a byte slice into a Fontprop value. 2540 func FontpropRead(buf []byte, v *Fontprop) int { 2541 b := 0 2542 2543 v.Name = Atom(xgb.Get32(buf[b:])) 2544 b += 4 2545 2546 v.Value = xgb.Get32(buf[b:]) 2547 b += 4 2548 2549 return b 2550 } 2551 2552 // FontpropReadList reads a byte slice into a list of Fontprop values. 2553 func FontpropReadList(buf []byte, dest []Fontprop) int { 2554 b := 0 2555 for i := 0; i < len(dest); i++ { 2556 dest[i] = Fontprop{} 2557 b += FontpropRead(buf[b:], &dest[i]) 2558 } 2559 return xgb.Pad(b) 2560 } 2561 2562 // Bytes writes a Fontprop value to a byte slice. 2563 func (v Fontprop) Bytes() []byte { 2564 buf := make([]byte, 8) 2565 b := 0 2566 2567 xgb.Put32(buf[b:], uint32(v.Name)) 2568 b += 4 2569 2570 xgb.Put32(buf[b:], v.Value) 2571 b += 4 2572 2573 return buf[:b] 2574 } 2575 2576 // FontpropListBytes writes a list of Fontprop values to a byte slice. 2577 func FontpropListBytes(buf []byte, list []Fontprop) int { 2578 b := 0 2579 var structBytes []byte 2580 for _, item := range list { 2581 structBytes = item.Bytes() 2582 copy(buf[b:], structBytes) 2583 b += len(structBytes) 2584 } 2585 return xgb.Pad(b) 2586 } 2587 2588 type Format struct { 2589 Depth byte 2590 BitsPerPixel byte 2591 ScanlinePad byte 2592 // padding: 5 bytes 2593 } 2594 2595 // FormatRead reads a byte slice into a Format value. 2596 func FormatRead(buf []byte, v *Format) int { 2597 b := 0 2598 2599 v.Depth = buf[b] 2600 b += 1 2601 2602 v.BitsPerPixel = buf[b] 2603 b += 1 2604 2605 v.ScanlinePad = buf[b] 2606 b += 1 2607 2608 b += 5 // padding 2609 2610 return b 2611 } 2612 2613 // FormatReadList reads a byte slice into a list of Format values. 2614 func FormatReadList(buf []byte, dest []Format) int { 2615 b := 0 2616 for i := 0; i < len(dest); i++ { 2617 dest[i] = Format{} 2618 b += FormatRead(buf[b:], &dest[i]) 2619 } 2620 return xgb.Pad(b) 2621 } 2622 2623 // Bytes writes a Format value to a byte slice. 2624 func (v Format) Bytes() []byte { 2625 buf := make([]byte, 8) 2626 b := 0 2627 2628 buf[b] = v.Depth 2629 b += 1 2630 2631 buf[b] = v.BitsPerPixel 2632 b += 1 2633 2634 buf[b] = v.ScanlinePad 2635 b += 1 2636 2637 b += 5 // padding 2638 2639 return buf[:b] 2640 } 2641 2642 // FormatListBytes writes a list of Format values to a byte slice. 2643 func FormatListBytes(buf []byte, list []Format) int { 2644 b := 0 2645 var structBytes []byte 2646 for _, item := range list { 2647 structBytes = item.Bytes() 2648 copy(buf[b:], structBytes) 2649 b += len(structBytes) 2650 } 2651 return xgb.Pad(b) 2652 } 2653 2654 // BadGContext is the error number for a BadGContext. 2655 const BadGContext = 13 2656 2657 type GContextError ValueError 2658 2659 // GContextErrorNew constructs a GContextError value that implements xgb.Error from a byte slice. 2660 func GContextErrorNew(buf []byte) xgb.Error { 2661 v := GContextError(ValueErrorNew(buf).(ValueError)) 2662 v.NiceName = "GContext" 2663 return v 2664 } 2665 2666 // SequenceId returns the sequence id attached to the BadGContext error. 2667 // This is mostly used internally. 2668 func (err GContextError) SequenceId() uint16 { 2669 return err.Sequence 2670 } 2671 2672 // BadId returns the 'BadValue' number if one exists for the BadGContext error. If no bad value exists, 0 is returned. 2673 func (err GContextError) BadId() uint32 { 2674 return err.BadValue 2675 } 2676 2677 // Error returns a rudimentary string representation of the BadGContext error. 2678 func (err GContextError) Error() string { 2679 fieldVals := make([]string, 0, 4) 2680 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 2681 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 2682 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 2683 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 2684 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 2685 return "BadGContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2686 } 2687 2688 func init() { 2689 xgb.NewErrorFuncs[13] = GContextErrorNew 2690 } 2691 2692 const ( 2693 GcFunction = 1 2694 GcPlaneMask = 2 2695 GcForeground = 4 2696 GcBackground = 8 2697 GcLineWidth = 16 2698 GcLineStyle = 32 2699 GcCapStyle = 64 2700 GcJoinStyle = 128 2701 GcFillStyle = 256 2702 GcFillRule = 512 2703 GcTile = 1024 2704 GcStipple = 2048 2705 GcTileStippleOriginX = 4096 2706 GcTileStippleOriginY = 8192 2707 GcFont = 16384 2708 GcSubwindowMode = 32768 2709 GcGraphicsExposures = 65536 2710 GcClipOriginX = 131072 2711 GcClipOriginY = 262144 2712 GcClipMask = 524288 2713 GcDashOffset = 1048576 2714 GcDashList = 2097152 2715 GcArcMode = 4194304 2716 ) 2717 2718 type Gcontext uint32 2719 2720 func NewGcontextId(c *xgb.Conn) (Gcontext, error) { 2721 id, err := c.NewId() 2722 if err != nil { 2723 return 0, err 2724 } 2725 return Gcontext(id), nil 2726 } 2727 2728 // GeGeneric is the event number for a GeGenericEvent. 2729 const GeGeneric = 35 2730 2731 type GeGenericEvent struct { 2732 Sequence uint16 2733 // padding: 22 bytes 2734 } 2735 2736 // GeGenericEventNew constructs a GeGenericEvent value that implements xgb.Event from a byte slice. 2737 func GeGenericEventNew(buf []byte) xgb.Event { 2738 v := GeGenericEvent{} 2739 b := 1 // don't read event number 2740 2741 b += 22 // padding 2742 2743 return v 2744 } 2745 2746 // Bytes writes a GeGenericEvent value to a byte slice. 2747 func (v GeGenericEvent) Bytes() []byte { 2748 buf := make([]byte, 32) 2749 b := 0 2750 2751 // write event number 2752 buf[b] = 35 2753 b += 1 2754 2755 b += 22 // padding 2756 2757 return buf 2758 } 2759 2760 // SequenceId returns the sequence id attached to the GeGeneric event. 2761 // Events without a sequence number (KeymapNotify) return 0. 2762 // This is mostly used internally. 2763 func (v GeGenericEvent) SequenceId() uint16 { 2764 return v.Sequence 2765 } 2766 2767 // String is a rudimentary string representation of GeGenericEvent. 2768 func (v GeGenericEvent) String() string { 2769 fieldVals := make([]string, 0, 1) 2770 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 2771 return "GeGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2772 } 2773 2774 func init() { 2775 xgb.NewEventFuncs[35] = GeGenericEventNew 2776 } 2777 2778 const ( 2779 GetPropertyTypeAny = 0 2780 ) 2781 2782 const ( 2783 GrabAny = 0 2784 ) 2785 2786 const ( 2787 GrabModeSync = 0 2788 GrabModeAsync = 1 2789 ) 2790 2791 const ( 2792 GrabStatusSuccess = 0 2793 GrabStatusAlreadyGrabbed = 1 2794 GrabStatusInvalidTime = 2 2795 GrabStatusNotViewable = 3 2796 GrabStatusFrozen = 4 2797 ) 2798 2799 // GraphicsExposure is the event number for a GraphicsExposureEvent. 2800 const GraphicsExposure = 13 2801 2802 type GraphicsExposureEvent struct { 2803 Sequence uint16 2804 // padding: 1 bytes 2805 Drawable Drawable 2806 X uint16 2807 Y uint16 2808 Width uint16 2809 Height uint16 2810 MinorOpcode uint16 2811 Count uint16 2812 MajorOpcode byte 2813 // padding: 3 bytes 2814 } 2815 2816 // GraphicsExposureEventNew constructs a GraphicsExposureEvent value that implements xgb.Event from a byte slice. 2817 func GraphicsExposureEventNew(buf []byte) xgb.Event { 2818 v := GraphicsExposureEvent{} 2819 b := 1 // don't read event number 2820 2821 b += 1 // padding 2822 2823 v.Sequence = xgb.Get16(buf[b:]) 2824 b += 2 2825 2826 v.Drawable = Drawable(xgb.Get32(buf[b:])) 2827 b += 4 2828 2829 v.X = xgb.Get16(buf[b:]) 2830 b += 2 2831 2832 v.Y = xgb.Get16(buf[b:]) 2833 b += 2 2834 2835 v.Width = xgb.Get16(buf[b:]) 2836 b += 2 2837 2838 v.Height = xgb.Get16(buf[b:]) 2839 b += 2 2840 2841 v.MinorOpcode = xgb.Get16(buf[b:]) 2842 b += 2 2843 2844 v.Count = xgb.Get16(buf[b:]) 2845 b += 2 2846 2847 v.MajorOpcode = buf[b] 2848 b += 1 2849 2850 b += 3 // padding 2851 2852 return v 2853 } 2854 2855 // Bytes writes a GraphicsExposureEvent value to a byte slice. 2856 func (v GraphicsExposureEvent) Bytes() []byte { 2857 buf := make([]byte, 32) 2858 b := 0 2859 2860 // write event number 2861 buf[b] = 13 2862 b += 1 2863 2864 b += 1 // padding 2865 2866 b += 2 // skip sequence number 2867 2868 xgb.Put32(buf[b:], uint32(v.Drawable)) 2869 b += 4 2870 2871 xgb.Put16(buf[b:], v.X) 2872 b += 2 2873 2874 xgb.Put16(buf[b:], v.Y) 2875 b += 2 2876 2877 xgb.Put16(buf[b:], v.Width) 2878 b += 2 2879 2880 xgb.Put16(buf[b:], v.Height) 2881 b += 2 2882 2883 xgb.Put16(buf[b:], v.MinorOpcode) 2884 b += 2 2885 2886 xgb.Put16(buf[b:], v.Count) 2887 b += 2 2888 2889 buf[b] = v.MajorOpcode 2890 b += 1 2891 2892 b += 3 // padding 2893 2894 return buf 2895 } 2896 2897 // SequenceId returns the sequence id attached to the GraphicsExposure event. 2898 // Events without a sequence number (KeymapNotify) return 0. 2899 // This is mostly used internally. 2900 func (v GraphicsExposureEvent) SequenceId() uint16 { 2901 return v.Sequence 2902 } 2903 2904 // String is a rudimentary string representation of GraphicsExposureEvent. 2905 func (v GraphicsExposureEvent) String() string { 2906 fieldVals := make([]string, 0, 10) 2907 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 2908 fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) 2909 fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) 2910 fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) 2911 fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) 2912 fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) 2913 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) 2914 fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) 2915 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) 2916 return "GraphicsExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" 2917 } 2918 2919 func init() { 2920 xgb.NewEventFuncs[13] = GraphicsExposureEventNew 2921 } 2922 2923 const ( 2924 GravityBitForget = 0 2925 GravityWinUnmap = 0 2926 GravityNorthWest = 1 2927 GravityNorth = 2 2928 GravityNorthEast = 3 2929 GravityWest = 4 2930 GravityCenter = 5 2931 GravityEast = 6 2932 GravitySouthWest = 7 2933 GravitySouth = 8 2934 GravitySouthEast = 9 2935 GravityStatic = 10 2936 ) 2937 2938 // GravityNotify is the event number for a GravityNotifyEvent. 2939 const GravityNotify = 24 2940 2941 type GravityNotifyEvent struct { 2942 Sequence uint16 2943 // padding: 1 bytes 2944 Event Window 2945 Window Window 2946 X int16 2947 Y int16 2948 } 2949 2950 // GravityNotifyEventNew constructs a GravityNotifyEvent value that implements xgb.Event from a byte slice. 2951 func GravityNotifyEventNew(buf []byte) xgb.Event { 2952 v := GravityNotifyEvent{} 2953 b := 1 // don't read event number 2954 2955 b += 1 // padding 2956 2957 v.Sequence = xgb.Get16(buf[b:]) 2958 b += 2 2959 2960 v.Event = Window(xgb.Get32(buf[b:])) 2961 b += 4 2962 2963 v.Window = Window(xgb.Get32(buf[b:])) 2964 b += 4 2965 2966 v.X = int16(xgb.Get16(buf[b:])) 2967 b += 2 2968 2969 v.Y = int16(xgb.Get16(buf[b:])) 2970 b += 2 2971 2972 return v 2973 } 2974 2975 // Bytes writes a GravityNotifyEvent value to a byte slice. 2976 func (v GravityNotifyEvent) Bytes() []byte { 2977 buf := make([]byte, 32) 2978 b := 0 2979 2980 // write event number 2981 buf[b] = 24 2982 b += 1 2983 2984 b += 1 // padding 2985 2986 b += 2 // skip sequence number 2987 2988 xgb.Put32(buf[b:], uint32(v.Event)) 2989 b += 4 2990 2991 xgb.Put32(buf[b:], uint32(v.Window)) 2992 b += 4 2993 2994 xgb.Put16(buf[b:], uint16(v.X)) 2995 b += 2 2996 2997 xgb.Put16(buf[b:], uint16(v.Y)) 2998 b += 2 2999 3000 return buf 3001 } 3002 3003 // SequenceId returns the sequence id attached to the GravityNotify event. 3004 // Events without a sequence number (KeymapNotify) return 0. 3005 // This is mostly used internally. 3006 func (v GravityNotifyEvent) SequenceId() uint16 { 3007 return v.Sequence 3008 } 3009 3010 // String is a rudimentary string representation of GravityNotifyEvent. 3011 func (v GravityNotifyEvent) String() string { 3012 fieldVals := make([]string, 0, 5) 3013 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 3014 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 3015 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 3016 fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) 3017 fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) 3018 return "GravityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3019 } 3020 3021 func init() { 3022 xgb.NewEventFuncs[24] = GravityNotifyEventNew 3023 } 3024 3025 const ( 3026 GxClear = 0 3027 GxAnd = 1 3028 GxAndReverse = 2 3029 GxCopy = 3 3030 GxAndInverted = 4 3031 GxNoop = 5 3032 GxXor = 6 3033 GxOr = 7 3034 GxNor = 8 3035 GxEquiv = 9 3036 GxInvert = 10 3037 GxOrReverse = 11 3038 GxCopyInverted = 12 3039 GxOrInverted = 13 3040 GxNand = 14 3041 GxSet = 15 3042 ) 3043 3044 type Host struct { 3045 Family byte 3046 // padding: 1 bytes 3047 AddressLen uint16 3048 Address []byte // size: xgb.Pad((int(AddressLen) * 1)) 3049 } 3050 3051 // HostRead reads a byte slice into a Host value. 3052 func HostRead(buf []byte, v *Host) int { 3053 b := 0 3054 3055 v.Family = buf[b] 3056 b += 1 3057 3058 b += 1 // padding 3059 3060 v.AddressLen = xgb.Get16(buf[b:]) 3061 b += 2 3062 3063 v.Address = make([]byte, v.AddressLen) 3064 copy(v.Address[:v.AddressLen], buf[b:]) 3065 b += int(v.AddressLen) 3066 3067 return b 3068 } 3069 3070 // HostReadList reads a byte slice into a list of Host values. 3071 func HostReadList(buf []byte, dest []Host) int { 3072 b := 0 3073 for i := 0; i < len(dest); i++ { 3074 dest[i] = Host{} 3075 b += HostRead(buf[b:], &dest[i]) 3076 } 3077 return xgb.Pad(b) 3078 } 3079 3080 // Bytes writes a Host value to a byte slice. 3081 func (v Host) Bytes() []byte { 3082 buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) 3083 b := 0 3084 3085 buf[b] = v.Family 3086 b += 1 3087 3088 b += 1 // padding 3089 3090 xgb.Put16(buf[b:], v.AddressLen) 3091 b += 2 3092 3093 copy(buf[b:], v.Address[:v.AddressLen]) 3094 b += int(v.AddressLen) 3095 3096 return buf[:b] 3097 } 3098 3099 // HostListBytes writes a list of Host values to a byte slice. 3100 func HostListBytes(buf []byte, list []Host) int { 3101 b := 0 3102 var structBytes []byte 3103 for _, item := range list { 3104 structBytes = item.Bytes() 3105 copy(buf[b:], structBytes) 3106 b += len(structBytes) 3107 } 3108 return xgb.Pad(b) 3109 } 3110 3111 // HostListSize computes the size (bytes) of a list of Host values. 3112 func HostListSize(list []Host) int { 3113 size := 0 3114 for _, item := range list { 3115 size += (4 + xgb.Pad((int(item.AddressLen) * 1))) 3116 } 3117 return size 3118 } 3119 3120 const ( 3121 HostModeInsert = 0 3122 HostModeDelete = 1 3123 ) 3124 3125 // BadIDChoice is the error number for a BadIDChoice. 3126 const BadIDChoice = 14 3127 3128 type IDChoiceError ValueError 3129 3130 // IDChoiceErrorNew constructs a IDChoiceError value that implements xgb.Error from a byte slice. 3131 func IDChoiceErrorNew(buf []byte) xgb.Error { 3132 v := IDChoiceError(ValueErrorNew(buf).(ValueError)) 3133 v.NiceName = "IDChoice" 3134 return v 3135 } 3136 3137 // SequenceId returns the sequence id attached to the BadIDChoice error. 3138 // This is mostly used internally. 3139 func (err IDChoiceError) SequenceId() uint16 { 3140 return err.Sequence 3141 } 3142 3143 // BadId returns the 'BadValue' number if one exists for the BadIDChoice error. If no bad value exists, 0 is returned. 3144 func (err IDChoiceError) BadId() uint32 { 3145 return err.BadValue 3146 } 3147 3148 // Error returns a rudimentary string representation of the BadIDChoice error. 3149 func (err IDChoiceError) Error() string { 3150 fieldVals := make([]string, 0, 4) 3151 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 3152 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 3153 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 3154 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 3155 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 3156 return "BadIDChoice {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3157 } 3158 3159 func init() { 3160 xgb.NewErrorFuncs[14] = IDChoiceErrorNew 3161 } 3162 3163 const ( 3164 ImageFormatXYBitmap = 0 3165 ImageFormatXYPixmap = 1 3166 ImageFormatZPixmap = 2 3167 ) 3168 3169 const ( 3170 ImageOrderLSBFirst = 0 3171 ImageOrderMSBFirst = 1 3172 ) 3173 3174 // BadImplementation is the error number for a BadImplementation. 3175 const BadImplementation = 17 3176 3177 type ImplementationError RequestError 3178 3179 // ImplementationErrorNew constructs a ImplementationError value that implements xgb.Error from a byte slice. 3180 func ImplementationErrorNew(buf []byte) xgb.Error { 3181 v := ImplementationError(RequestErrorNew(buf).(RequestError)) 3182 v.NiceName = "Implementation" 3183 return v 3184 } 3185 3186 // SequenceId returns the sequence id attached to the BadImplementation error. 3187 // This is mostly used internally. 3188 func (err ImplementationError) SequenceId() uint16 { 3189 return err.Sequence 3190 } 3191 3192 // BadId returns the 'BadValue' number if one exists for the BadImplementation error. If no bad value exists, 0 is returned. 3193 func (err ImplementationError) BadId() uint32 { 3194 return err.BadValue 3195 } 3196 3197 // Error returns a rudimentary string representation of the BadImplementation error. 3198 func (err ImplementationError) Error() string { 3199 fieldVals := make([]string, 0, 4) 3200 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 3201 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 3202 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 3203 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 3204 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 3205 return "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3206 } 3207 3208 func init() { 3209 xgb.NewErrorFuncs[17] = ImplementationErrorNew 3210 } 3211 3212 const ( 3213 InputFocusNone = 0 3214 InputFocusPointerRoot = 1 3215 InputFocusParent = 2 3216 InputFocusFollowKeyboard = 3 3217 ) 3218 3219 const ( 3220 JoinStyleMiter = 0 3221 JoinStyleRound = 1 3222 JoinStyleBevel = 2 3223 ) 3224 3225 const ( 3226 KbKeyClickPercent = 1 3227 KbBellPercent = 2 3228 KbBellPitch = 4 3229 KbBellDuration = 8 3230 KbLed = 16 3231 KbLedMode = 32 3232 KbKey = 64 3233 KbAutoRepeatMode = 128 3234 ) 3235 3236 const ( 3237 KeyButMaskShift = 1 3238 KeyButMaskLock = 2 3239 KeyButMaskControl = 4 3240 KeyButMaskMod1 = 8 3241 KeyButMaskMod2 = 16 3242 KeyButMaskMod3 = 32 3243 KeyButMaskMod4 = 64 3244 KeyButMaskMod5 = 128 3245 KeyButMaskButton1 = 256 3246 KeyButMaskButton2 = 512 3247 KeyButMaskButton3 = 1024 3248 KeyButMaskButton4 = 2048 3249 KeyButMaskButton5 = 4096 3250 ) 3251 3252 // KeyPress is the event number for a KeyPressEvent. 3253 const KeyPress = 2 3254 3255 type KeyPressEvent struct { 3256 Sequence uint16 3257 Detail Keycode 3258 Time Timestamp 3259 Root Window 3260 Event Window 3261 Child Window 3262 RootX int16 3263 RootY int16 3264 EventX int16 3265 EventY int16 3266 State uint16 3267 SameScreen bool 3268 // padding: 1 bytes 3269 } 3270 3271 // KeyPressEventNew constructs a KeyPressEvent value that implements xgb.Event from a byte slice. 3272 func KeyPressEventNew(buf []byte) xgb.Event { 3273 v := KeyPressEvent{} 3274 b := 1 // don't read event number 3275 3276 v.Detail = Keycode(buf[b]) 3277 b += 1 3278 3279 v.Sequence = xgb.Get16(buf[b:]) 3280 b += 2 3281 3282 v.Time = Timestamp(xgb.Get32(buf[b:])) 3283 b += 4 3284 3285 v.Root = Window(xgb.Get32(buf[b:])) 3286 b += 4 3287 3288 v.Event = Window(xgb.Get32(buf[b:])) 3289 b += 4 3290 3291 v.Child = Window(xgb.Get32(buf[b:])) 3292 b += 4 3293 3294 v.RootX = int16(xgb.Get16(buf[b:])) 3295 b += 2 3296 3297 v.RootY = int16(xgb.Get16(buf[b:])) 3298 b += 2 3299 3300 v.EventX = int16(xgb.Get16(buf[b:])) 3301 b += 2 3302 3303 v.EventY = int16(xgb.Get16(buf[b:])) 3304 b += 2 3305 3306 v.State = xgb.Get16(buf[b:]) 3307 b += 2 3308 3309 if buf[b] == 1 { 3310 v.SameScreen = true 3311 } else { 3312 v.SameScreen = false 3313 } 3314 b += 1 3315 3316 b += 1 // padding 3317 3318 return v 3319 } 3320 3321 // Bytes writes a KeyPressEvent value to a byte slice. 3322 func (v KeyPressEvent) Bytes() []byte { 3323 buf := make([]byte, 32) 3324 b := 0 3325 3326 // write event number 3327 buf[b] = 2 3328 b += 1 3329 3330 buf[b] = byte(v.Detail) 3331 b += 1 3332 3333 b += 2 // skip sequence number 3334 3335 xgb.Put32(buf[b:], uint32(v.Time)) 3336 b += 4 3337 3338 xgb.Put32(buf[b:], uint32(v.Root)) 3339 b += 4 3340 3341 xgb.Put32(buf[b:], uint32(v.Event)) 3342 b += 4 3343 3344 xgb.Put32(buf[b:], uint32(v.Child)) 3345 b += 4 3346 3347 xgb.Put16(buf[b:], uint16(v.RootX)) 3348 b += 2 3349 3350 xgb.Put16(buf[b:], uint16(v.RootY)) 3351 b += 2 3352 3353 xgb.Put16(buf[b:], uint16(v.EventX)) 3354 b += 2 3355 3356 xgb.Put16(buf[b:], uint16(v.EventY)) 3357 b += 2 3358 3359 xgb.Put16(buf[b:], v.State) 3360 b += 2 3361 3362 if v.SameScreen { 3363 buf[b] = 1 3364 } else { 3365 buf[b] = 0 3366 } 3367 b += 1 3368 3369 b += 1 // padding 3370 3371 return buf 3372 } 3373 3374 // SequenceId returns the sequence id attached to the KeyPress event. 3375 // Events without a sequence number (KeymapNotify) return 0. 3376 // This is mostly used internally. 3377 func (v KeyPressEvent) SequenceId() uint16 { 3378 return v.Sequence 3379 } 3380 3381 // String is a rudimentary string representation of KeyPressEvent. 3382 func (v KeyPressEvent) String() string { 3383 fieldVals := make([]string, 0, 12) 3384 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 3385 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 3386 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 3387 fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) 3388 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 3389 fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) 3390 fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) 3391 fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) 3392 fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) 3393 fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) 3394 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 3395 fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) 3396 return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3397 } 3398 3399 func init() { 3400 xgb.NewEventFuncs[2] = KeyPressEventNew 3401 } 3402 3403 // KeyRelease is the event number for a KeyReleaseEvent. 3404 const KeyRelease = 3 3405 3406 type KeyReleaseEvent KeyPressEvent 3407 3408 // KeyReleaseEventNew constructs a KeyReleaseEvent value that implements xgb.Event from a byte slice. 3409 func KeyReleaseEventNew(buf []byte) xgb.Event { 3410 return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) 3411 } 3412 3413 // Bytes writes a KeyReleaseEvent value to a byte slice. 3414 func (v KeyReleaseEvent) Bytes() []byte { 3415 return KeyPressEvent(v).Bytes() 3416 } 3417 3418 // SequenceId returns the sequence id attached to the KeyRelease event. 3419 // Events without a sequence number (KeymapNotify) return 0. 3420 // This is mostly used internally. 3421 func (v KeyReleaseEvent) SequenceId() uint16 { 3422 return v.Sequence 3423 } 3424 3425 func (v KeyReleaseEvent) String() string { 3426 fieldVals := make([]string, 0, 12) 3427 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 3428 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 3429 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 3430 fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) 3431 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 3432 fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) 3433 fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) 3434 fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) 3435 fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) 3436 fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) 3437 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 3438 fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) 3439 return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3440 } 3441 3442 func init() { 3443 xgb.NewEventFuncs[3] = KeyReleaseEventNew 3444 } 3445 3446 type Keycode byte 3447 3448 // KeymapNotify is the event number for a KeymapNotifyEvent. 3449 const KeymapNotify = 11 3450 3451 type KeymapNotifyEvent struct { 3452 Keys []byte // size: 32 3453 } 3454 3455 // KeymapNotifyEventNew constructs a KeymapNotifyEvent value that implements xgb.Event from a byte slice. 3456 func KeymapNotifyEventNew(buf []byte) xgb.Event { 3457 v := KeymapNotifyEvent{} 3458 b := 1 // don't read event number 3459 3460 v.Keys = make([]byte, 31) 3461 copy(v.Keys[:31], buf[b:]) 3462 b += int(31) 3463 3464 return v 3465 } 3466 3467 // Bytes writes a KeymapNotifyEvent value to a byte slice. 3468 func (v KeymapNotifyEvent) Bytes() []byte { 3469 buf := make([]byte, 32) 3470 b := 0 3471 3472 // write event number 3473 buf[b] = 11 3474 b += 1 3475 3476 copy(buf[b:], v.Keys[:31]) 3477 b += int(31) 3478 3479 return buf 3480 } 3481 3482 // SequenceId returns the sequence id attached to the KeymapNotify event. 3483 // Events without a sequence number (KeymapNotify) return 0. 3484 // This is mostly used internally. 3485 func (v KeymapNotifyEvent) SequenceId() uint16 { 3486 return uint16(0) 3487 } 3488 3489 // String is a rudimentary string representation of KeymapNotifyEvent. 3490 func (v KeymapNotifyEvent) String() string { 3491 fieldVals := make([]string, 0, 1) 3492 return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3493 } 3494 3495 func init() { 3496 xgb.NewEventFuncs[11] = KeymapNotifyEventNew 3497 } 3498 3499 type Keysym uint32 3500 3501 const ( 3502 KillAllTemporary = 0 3503 ) 3504 3505 // LeaveNotify is the event number for a LeaveNotifyEvent. 3506 const LeaveNotify = 8 3507 3508 type LeaveNotifyEvent EnterNotifyEvent 3509 3510 // LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. 3511 func LeaveNotifyEventNew(buf []byte) xgb.Event { 3512 return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) 3513 } 3514 3515 // Bytes writes a LeaveNotifyEvent value to a byte slice. 3516 func (v LeaveNotifyEvent) Bytes() []byte { 3517 return EnterNotifyEvent(v).Bytes() 3518 } 3519 3520 // SequenceId returns the sequence id attached to the LeaveNotify event. 3521 // Events without a sequence number (KeymapNotify) return 0. 3522 // This is mostly used internally. 3523 func (v LeaveNotifyEvent) SequenceId() uint16 { 3524 return v.Sequence 3525 } 3526 3527 func (v LeaveNotifyEvent) String() string { 3528 fieldVals := make([]string, 0, 12) 3529 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 3530 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 3531 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 3532 fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) 3533 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 3534 fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) 3535 fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) 3536 fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) 3537 fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) 3538 fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) 3539 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 3540 fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) 3541 fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) 3542 return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3543 } 3544 3545 func init() { 3546 xgb.NewEventFuncs[8] = LeaveNotifyEventNew 3547 } 3548 3549 const ( 3550 LedModeOff = 0 3551 LedModeOn = 1 3552 ) 3553 3554 // BadLength is the error number for a BadLength. 3555 const BadLength = 16 3556 3557 type LengthError RequestError 3558 3559 // LengthErrorNew constructs a LengthError value that implements xgb.Error from a byte slice. 3560 func LengthErrorNew(buf []byte) xgb.Error { 3561 v := LengthError(RequestErrorNew(buf).(RequestError)) 3562 v.NiceName = "Length" 3563 return v 3564 } 3565 3566 // SequenceId returns the sequence id attached to the BadLength error. 3567 // This is mostly used internally. 3568 func (err LengthError) SequenceId() uint16 { 3569 return err.Sequence 3570 } 3571 3572 // BadId returns the 'BadValue' number if one exists for the BadLength error. If no bad value exists, 0 is returned. 3573 func (err LengthError) BadId() uint32 { 3574 return err.BadValue 3575 } 3576 3577 // Error returns a rudimentary string representation of the BadLength error. 3578 func (err LengthError) Error() string { 3579 fieldVals := make([]string, 0, 4) 3580 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 3581 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 3582 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 3583 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 3584 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 3585 return "BadLength {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3586 } 3587 3588 func init() { 3589 xgb.NewErrorFuncs[16] = LengthErrorNew 3590 } 3591 3592 const ( 3593 LineStyleSolid = 0 3594 LineStyleOnOffDash = 1 3595 LineStyleDoubleDash = 2 3596 ) 3597 3598 const ( 3599 MapIndexShift = 0 3600 MapIndexLock = 1 3601 MapIndexControl = 2 3602 MapIndex1 = 3 3603 MapIndex2 = 4 3604 MapIndex3 = 5 3605 MapIndex4 = 6 3606 MapIndex5 = 7 3607 ) 3608 3609 // MapNotify is the event number for a MapNotifyEvent. 3610 const MapNotify = 19 3611 3612 type MapNotifyEvent struct { 3613 Sequence uint16 3614 // padding: 1 bytes 3615 Event Window 3616 Window Window 3617 OverrideRedirect bool 3618 // padding: 3 bytes 3619 } 3620 3621 // MapNotifyEventNew constructs a MapNotifyEvent value that implements xgb.Event from a byte slice. 3622 func MapNotifyEventNew(buf []byte) xgb.Event { 3623 v := MapNotifyEvent{} 3624 b := 1 // don't read event number 3625 3626 b += 1 // padding 3627 3628 v.Sequence = xgb.Get16(buf[b:]) 3629 b += 2 3630 3631 v.Event = Window(xgb.Get32(buf[b:])) 3632 b += 4 3633 3634 v.Window = Window(xgb.Get32(buf[b:])) 3635 b += 4 3636 3637 if buf[b] == 1 { 3638 v.OverrideRedirect = true 3639 } else { 3640 v.OverrideRedirect = false 3641 } 3642 b += 1 3643 3644 b += 3 // padding 3645 3646 return v 3647 } 3648 3649 // Bytes writes a MapNotifyEvent value to a byte slice. 3650 func (v MapNotifyEvent) Bytes() []byte { 3651 buf := make([]byte, 32) 3652 b := 0 3653 3654 // write event number 3655 buf[b] = 19 3656 b += 1 3657 3658 b += 1 // padding 3659 3660 b += 2 // skip sequence number 3661 3662 xgb.Put32(buf[b:], uint32(v.Event)) 3663 b += 4 3664 3665 xgb.Put32(buf[b:], uint32(v.Window)) 3666 b += 4 3667 3668 if v.OverrideRedirect { 3669 buf[b] = 1 3670 } else { 3671 buf[b] = 0 3672 } 3673 b += 1 3674 3675 b += 3 // padding 3676 3677 return buf 3678 } 3679 3680 // SequenceId returns the sequence id attached to the MapNotify event. 3681 // Events without a sequence number (KeymapNotify) return 0. 3682 // This is mostly used internally. 3683 func (v MapNotifyEvent) SequenceId() uint16 { 3684 return v.Sequence 3685 } 3686 3687 // String is a rudimentary string representation of MapNotifyEvent. 3688 func (v MapNotifyEvent) String() string { 3689 fieldVals := make([]string, 0, 5) 3690 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 3691 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 3692 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 3693 fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) 3694 return "MapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3695 } 3696 3697 func init() { 3698 xgb.NewEventFuncs[19] = MapNotifyEventNew 3699 } 3700 3701 // MapRequest is the event number for a MapRequestEvent. 3702 const MapRequest = 20 3703 3704 type MapRequestEvent struct { 3705 Sequence uint16 3706 // padding: 1 bytes 3707 Parent Window 3708 Window Window 3709 } 3710 3711 // MapRequestEventNew constructs a MapRequestEvent value that implements xgb.Event from a byte slice. 3712 func MapRequestEventNew(buf []byte) xgb.Event { 3713 v := MapRequestEvent{} 3714 b := 1 // don't read event number 3715 3716 b += 1 // padding 3717 3718 v.Sequence = xgb.Get16(buf[b:]) 3719 b += 2 3720 3721 v.Parent = Window(xgb.Get32(buf[b:])) 3722 b += 4 3723 3724 v.Window = Window(xgb.Get32(buf[b:])) 3725 b += 4 3726 3727 return v 3728 } 3729 3730 // Bytes writes a MapRequestEvent value to a byte slice. 3731 func (v MapRequestEvent) Bytes() []byte { 3732 buf := make([]byte, 32) 3733 b := 0 3734 3735 // write event number 3736 buf[b] = 20 3737 b += 1 3738 3739 b += 1 // padding 3740 3741 b += 2 // skip sequence number 3742 3743 xgb.Put32(buf[b:], uint32(v.Parent)) 3744 b += 4 3745 3746 xgb.Put32(buf[b:], uint32(v.Window)) 3747 b += 4 3748 3749 return buf 3750 } 3751 3752 // SequenceId returns the sequence id attached to the MapRequest event. 3753 // Events without a sequence number (KeymapNotify) return 0. 3754 // This is mostly used internally. 3755 func (v MapRequestEvent) SequenceId() uint16 { 3756 return v.Sequence 3757 } 3758 3759 // String is a rudimentary string representation of MapRequestEvent. 3760 func (v MapRequestEvent) String() string { 3761 fieldVals := make([]string, 0, 3) 3762 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 3763 fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) 3764 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 3765 return "MapRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3766 } 3767 3768 func init() { 3769 xgb.NewEventFuncs[20] = MapRequestEventNew 3770 } 3771 3772 const ( 3773 MapStateUnmapped = 0 3774 MapStateUnviewable = 1 3775 MapStateViewable = 2 3776 ) 3777 3778 const ( 3779 MappingModifier = 0 3780 MappingKeyboard = 1 3781 MappingPointer = 2 3782 ) 3783 3784 // MappingNotify is the event number for a MappingNotifyEvent. 3785 const MappingNotify = 34 3786 3787 type MappingNotifyEvent struct { 3788 Sequence uint16 3789 // padding: 1 bytes 3790 Request byte 3791 FirstKeycode Keycode 3792 Count byte 3793 // padding: 1 bytes 3794 } 3795 3796 // MappingNotifyEventNew constructs a MappingNotifyEvent value that implements xgb.Event from a byte slice. 3797 func MappingNotifyEventNew(buf []byte) xgb.Event { 3798 v := MappingNotifyEvent{} 3799 b := 1 // don't read event number 3800 3801 b += 1 // padding 3802 3803 v.Sequence = xgb.Get16(buf[b:]) 3804 b += 2 3805 3806 v.Request = buf[b] 3807 b += 1 3808 3809 v.FirstKeycode = Keycode(buf[b]) 3810 b += 1 3811 3812 v.Count = buf[b] 3813 b += 1 3814 3815 b += 1 // padding 3816 3817 return v 3818 } 3819 3820 // Bytes writes a MappingNotifyEvent value to a byte slice. 3821 func (v MappingNotifyEvent) Bytes() []byte { 3822 buf := make([]byte, 32) 3823 b := 0 3824 3825 // write event number 3826 buf[b] = 34 3827 b += 1 3828 3829 b += 1 // padding 3830 3831 b += 2 // skip sequence number 3832 3833 buf[b] = v.Request 3834 b += 1 3835 3836 buf[b] = byte(v.FirstKeycode) 3837 b += 1 3838 3839 buf[b] = v.Count 3840 b += 1 3841 3842 b += 1 // padding 3843 3844 return buf 3845 } 3846 3847 // SequenceId returns the sequence id attached to the MappingNotify event. 3848 // Events without a sequence number (KeymapNotify) return 0. 3849 // This is mostly used internally. 3850 func (v MappingNotifyEvent) SequenceId() uint16 { 3851 return v.Sequence 3852 } 3853 3854 // String is a rudimentary string representation of MappingNotifyEvent. 3855 func (v MappingNotifyEvent) String() string { 3856 fieldVals := make([]string, 0, 5) 3857 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 3858 fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) 3859 fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) 3860 fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) 3861 return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3862 } 3863 3864 func init() { 3865 xgb.NewEventFuncs[34] = MappingNotifyEventNew 3866 } 3867 3868 const ( 3869 MappingStatusSuccess = 0 3870 MappingStatusBusy = 1 3871 MappingStatusFailure = 2 3872 ) 3873 3874 // BadMatch is the error number for a BadMatch. 3875 const BadMatch = 8 3876 3877 type MatchError RequestError 3878 3879 // MatchErrorNew constructs a MatchError value that implements xgb.Error from a byte slice. 3880 func MatchErrorNew(buf []byte) xgb.Error { 3881 v := MatchError(RequestErrorNew(buf).(RequestError)) 3882 v.NiceName = "Match" 3883 return v 3884 } 3885 3886 // SequenceId returns the sequence id attached to the BadMatch error. 3887 // This is mostly used internally. 3888 func (err MatchError) SequenceId() uint16 { 3889 return err.Sequence 3890 } 3891 3892 // BadId returns the 'BadValue' number if one exists for the BadMatch error. If no bad value exists, 0 is returned. 3893 func (err MatchError) BadId() uint32 { 3894 return err.BadValue 3895 } 3896 3897 // Error returns a rudimentary string representation of the BadMatch error. 3898 func (err MatchError) Error() string { 3899 fieldVals := make([]string, 0, 4) 3900 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 3901 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 3902 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 3903 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 3904 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 3905 return "BadMatch {" + xgb.StringsJoin(fieldVals, ", ") + "}" 3906 } 3907 3908 func init() { 3909 xgb.NewErrorFuncs[8] = MatchErrorNew 3910 } 3911 3912 const ( 3913 ModMaskShift = 1 3914 ModMaskLock = 2 3915 ModMaskControl = 4 3916 ModMask1 = 8 3917 ModMask2 = 16 3918 ModMask3 = 32 3919 ModMask4 = 64 3920 ModMask5 = 128 3921 ModMaskAny = 32768 3922 ) 3923 3924 const ( 3925 MotionNormal = 0 3926 MotionHint = 1 3927 ) 3928 3929 // MotionNotify is the event number for a MotionNotifyEvent. 3930 const MotionNotify = 6 3931 3932 type MotionNotifyEvent struct { 3933 Sequence uint16 3934 Detail byte 3935 Time Timestamp 3936 Root Window 3937 Event Window 3938 Child Window 3939 RootX int16 3940 RootY int16 3941 EventX int16 3942 EventY int16 3943 State uint16 3944 SameScreen bool 3945 // padding: 1 bytes 3946 } 3947 3948 // MotionNotifyEventNew constructs a MotionNotifyEvent value that implements xgb.Event from a byte slice. 3949 func MotionNotifyEventNew(buf []byte) xgb.Event { 3950 v := MotionNotifyEvent{} 3951 b := 1 // don't read event number 3952 3953 v.Detail = buf[b] 3954 b += 1 3955 3956 v.Sequence = xgb.Get16(buf[b:]) 3957 b += 2 3958 3959 v.Time = Timestamp(xgb.Get32(buf[b:])) 3960 b += 4 3961 3962 v.Root = Window(xgb.Get32(buf[b:])) 3963 b += 4 3964 3965 v.Event = Window(xgb.Get32(buf[b:])) 3966 b += 4 3967 3968 v.Child = Window(xgb.Get32(buf[b:])) 3969 b += 4 3970 3971 v.RootX = int16(xgb.Get16(buf[b:])) 3972 b += 2 3973 3974 v.RootY = int16(xgb.Get16(buf[b:])) 3975 b += 2 3976 3977 v.EventX = int16(xgb.Get16(buf[b:])) 3978 b += 2 3979 3980 v.EventY = int16(xgb.Get16(buf[b:])) 3981 b += 2 3982 3983 v.State = xgb.Get16(buf[b:]) 3984 b += 2 3985 3986 if buf[b] == 1 { 3987 v.SameScreen = true 3988 } else { 3989 v.SameScreen = false 3990 } 3991 b += 1 3992 3993 b += 1 // padding 3994 3995 return v 3996 } 3997 3998 // Bytes writes a MotionNotifyEvent value to a byte slice. 3999 func (v MotionNotifyEvent) Bytes() []byte { 4000 buf := make([]byte, 32) 4001 b := 0 4002 4003 // write event number 4004 buf[b] = 6 4005 b += 1 4006 4007 buf[b] = v.Detail 4008 b += 1 4009 4010 b += 2 // skip sequence number 4011 4012 xgb.Put32(buf[b:], uint32(v.Time)) 4013 b += 4 4014 4015 xgb.Put32(buf[b:], uint32(v.Root)) 4016 b += 4 4017 4018 xgb.Put32(buf[b:], uint32(v.Event)) 4019 b += 4 4020 4021 xgb.Put32(buf[b:], uint32(v.Child)) 4022 b += 4 4023 4024 xgb.Put16(buf[b:], uint16(v.RootX)) 4025 b += 2 4026 4027 xgb.Put16(buf[b:], uint16(v.RootY)) 4028 b += 2 4029 4030 xgb.Put16(buf[b:], uint16(v.EventX)) 4031 b += 2 4032 4033 xgb.Put16(buf[b:], uint16(v.EventY)) 4034 b += 2 4035 4036 xgb.Put16(buf[b:], v.State) 4037 b += 2 4038 4039 if v.SameScreen { 4040 buf[b] = 1 4041 } else { 4042 buf[b] = 0 4043 } 4044 b += 1 4045 4046 b += 1 // padding 4047 4048 return buf 4049 } 4050 4051 // SequenceId returns the sequence id attached to the MotionNotify event. 4052 // Events without a sequence number (KeymapNotify) return 0. 4053 // This is mostly used internally. 4054 func (v MotionNotifyEvent) SequenceId() uint16 { 4055 return v.Sequence 4056 } 4057 4058 // String is a rudimentary string representation of MotionNotifyEvent. 4059 func (v MotionNotifyEvent) String() string { 4060 fieldVals := make([]string, 0, 12) 4061 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 4062 fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) 4063 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 4064 fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) 4065 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 4066 fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) 4067 fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) 4068 fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) 4069 fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) 4070 fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) 4071 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 4072 fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) 4073 return "MotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 4074 } 4075 4076 func init() { 4077 xgb.NewEventFuncs[6] = MotionNotifyEventNew 4078 } 4079 4080 // BadName is the error number for a BadName. 4081 const BadName = 15 4082 4083 type NameError RequestError 4084 4085 // NameErrorNew constructs a NameError value that implements xgb.Error from a byte slice. 4086 func NameErrorNew(buf []byte) xgb.Error { 4087 v := NameError(RequestErrorNew(buf).(RequestError)) 4088 v.NiceName = "Name" 4089 return v 4090 } 4091 4092 // SequenceId returns the sequence id attached to the BadName error. 4093 // This is mostly used internally. 4094 func (err NameError) SequenceId() uint16 { 4095 return err.Sequence 4096 } 4097 4098 // BadId returns the 'BadValue' number if one exists for the BadName error. If no bad value exists, 0 is returned. 4099 func (err NameError) BadId() uint32 { 4100 return err.BadValue 4101 } 4102 4103 // Error returns a rudimentary string representation of the BadName error. 4104 func (err NameError) Error() string { 4105 fieldVals := make([]string, 0, 4) 4106 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 4107 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 4108 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 4109 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 4110 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 4111 return "BadName {" + xgb.StringsJoin(fieldVals, ", ") + "}" 4112 } 4113 4114 func init() { 4115 xgb.NewErrorFuncs[15] = NameErrorNew 4116 } 4117 4118 // NoExposure is the event number for a NoExposureEvent. 4119 const NoExposure = 14 4120 4121 type NoExposureEvent struct { 4122 Sequence uint16 4123 // padding: 1 bytes 4124 Drawable Drawable 4125 MinorOpcode uint16 4126 MajorOpcode byte 4127 // padding: 1 bytes 4128 } 4129 4130 // NoExposureEventNew constructs a NoExposureEvent value that implements xgb.Event from a byte slice. 4131 func NoExposureEventNew(buf []byte) xgb.Event { 4132 v := NoExposureEvent{} 4133 b := 1 // don't read event number 4134 4135 b += 1 // padding 4136 4137 v.Sequence = xgb.Get16(buf[b:]) 4138 b += 2 4139 4140 v.Drawable = Drawable(xgb.Get32(buf[b:])) 4141 b += 4 4142 4143 v.MinorOpcode = xgb.Get16(buf[b:]) 4144 b += 2 4145 4146 v.MajorOpcode = buf[b] 4147 b += 1 4148 4149 b += 1 // padding 4150 4151 return v 4152 } 4153 4154 // Bytes writes a NoExposureEvent value to a byte slice. 4155 func (v NoExposureEvent) Bytes() []byte { 4156 buf := make([]byte, 32) 4157 b := 0 4158 4159 // write event number 4160 buf[b] = 14 4161 b += 1 4162 4163 b += 1 // padding 4164 4165 b += 2 // skip sequence number 4166 4167 xgb.Put32(buf[b:], uint32(v.Drawable)) 4168 b += 4 4169 4170 xgb.Put16(buf[b:], v.MinorOpcode) 4171 b += 2 4172 4173 buf[b] = v.MajorOpcode 4174 b += 1 4175 4176 b += 1 // padding 4177 4178 return buf 4179 } 4180 4181 // SequenceId returns the sequence id attached to the NoExposure event. 4182 // Events without a sequence number (KeymapNotify) return 0. 4183 // This is mostly used internally. 4184 func (v NoExposureEvent) SequenceId() uint16 { 4185 return v.Sequence 4186 } 4187 4188 // String is a rudimentary string representation of NoExposureEvent. 4189 func (v NoExposureEvent) String() string { 4190 fieldVals := make([]string, 0, 5) 4191 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 4192 fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) 4193 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) 4194 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) 4195 return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" 4196 } 4197 4198 func init() { 4199 xgb.NewEventFuncs[14] = NoExposureEventNew 4200 } 4201 4202 const ( 4203 NotifyDetailAncestor = 0 4204 NotifyDetailVirtual = 1 4205 NotifyDetailInferior = 2 4206 NotifyDetailNonlinear = 3 4207 NotifyDetailNonlinearVirtual = 4 4208 NotifyDetailPointer = 5 4209 NotifyDetailPointerRoot = 6 4210 NotifyDetailNone = 7 4211 ) 4212 4213 const ( 4214 NotifyModeNormal = 0 4215 NotifyModeGrab = 1 4216 NotifyModeUngrab = 2 4217 NotifyModeWhileGrabbed = 3 4218 ) 4219 4220 type Pixmap uint32 4221 4222 func NewPixmapId(c *xgb.Conn) (Pixmap, error) { 4223 id, err := c.NewId() 4224 if err != nil { 4225 return 0, err 4226 } 4227 return Pixmap(id), nil 4228 } 4229 4230 const ( 4231 PixmapNone = 0 4232 ) 4233 4234 // BadPixmap is the error number for a BadPixmap. 4235 const BadPixmap = 4 4236 4237 type PixmapError ValueError 4238 4239 // PixmapErrorNew constructs a PixmapError value that implements xgb.Error from a byte slice. 4240 func PixmapErrorNew(buf []byte) xgb.Error { 4241 v := PixmapError(ValueErrorNew(buf).(ValueError)) 4242 v.NiceName = "Pixmap" 4243 return v 4244 } 4245 4246 // SequenceId returns the sequence id attached to the BadPixmap error. 4247 // This is mostly used internally. 4248 func (err PixmapError) SequenceId() uint16 { 4249 return err.Sequence 4250 } 4251 4252 // BadId returns the 'BadValue' number if one exists for the BadPixmap error. If no bad value exists, 0 is returned. 4253 func (err PixmapError) BadId() uint32 { 4254 return err.BadValue 4255 } 4256 4257 // Error returns a rudimentary string representation of the BadPixmap error. 4258 func (err PixmapError) Error() string { 4259 fieldVals := make([]string, 0, 4) 4260 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 4261 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 4262 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 4263 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 4264 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 4265 return "BadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" 4266 } 4267 4268 func init() { 4269 xgb.NewErrorFuncs[4] = PixmapErrorNew 4270 } 4271 4272 const ( 4273 PlaceOnTop = 0 4274 PlaceOnBottom = 1 4275 ) 4276 4277 type Point struct { 4278 X int16 4279 Y int16 4280 } 4281 4282 // PointRead reads a byte slice into a Point value. 4283 func PointRead(buf []byte, v *Point) int { 4284 b := 0 4285 4286 v.X = int16(xgb.Get16(buf[b:])) 4287 b += 2 4288 4289 v.Y = int16(xgb.Get16(buf[b:])) 4290 b += 2 4291 4292 return b 4293 } 4294 4295 // PointReadList reads a byte slice into a list of Point values. 4296 func PointReadList(buf []byte, dest []Point) int { 4297 b := 0 4298 for i := 0; i < len(dest); i++ { 4299 dest[i] = Point{} 4300 b += PointRead(buf[b:], &dest[i]) 4301 } 4302 return xgb.Pad(b) 4303 } 4304 4305 // Bytes writes a Point value to a byte slice. 4306 func (v Point) Bytes() []byte { 4307 buf := make([]byte, 4) 4308 b := 0 4309 4310 xgb.Put16(buf[b:], uint16(v.X)) 4311 b += 2 4312 4313 xgb.Put16(buf[b:], uint16(v.Y)) 4314 b += 2 4315 4316 return buf[:b] 4317 } 4318 4319 // PointListBytes writes a list of Point values to a byte slice. 4320 func PointListBytes(buf []byte, list []Point) int { 4321 b := 0 4322 var structBytes []byte 4323 for _, item := range list { 4324 structBytes = item.Bytes() 4325 copy(buf[b:], structBytes) 4326 b += len(structBytes) 4327 } 4328 return xgb.Pad(b) 4329 } 4330 4331 const ( 4332 PolyShapeComplex = 0 4333 PolyShapeNonconvex = 1 4334 PolyShapeConvex = 2 4335 ) 4336 4337 const ( 4338 PropModeReplace = 0 4339 PropModePrepend = 1 4340 PropModeAppend = 2 4341 ) 4342 4343 const ( 4344 PropertyNewValue = 0 4345 PropertyDelete = 1 4346 ) 4347 4348 // PropertyNotify is the event number for a PropertyNotifyEvent. 4349 const PropertyNotify = 28 4350 4351 type PropertyNotifyEvent struct { 4352 Sequence uint16 4353 // padding: 1 bytes 4354 Window Window 4355 Atom Atom 4356 Time Timestamp 4357 State byte 4358 // padding: 3 bytes 4359 } 4360 4361 // PropertyNotifyEventNew constructs a PropertyNotifyEvent value that implements xgb.Event from a byte slice. 4362 func PropertyNotifyEventNew(buf []byte) xgb.Event { 4363 v := PropertyNotifyEvent{} 4364 b := 1 // don't read event number 4365 4366 b += 1 // padding 4367 4368 v.Sequence = xgb.Get16(buf[b:]) 4369 b += 2 4370 4371 v.Window = Window(xgb.Get32(buf[b:])) 4372 b += 4 4373 4374 v.Atom = Atom(xgb.Get32(buf[b:])) 4375 b += 4 4376 4377 v.Time = Timestamp(xgb.Get32(buf[b:])) 4378 b += 4 4379 4380 v.State = buf[b] 4381 b += 1 4382 4383 b += 3 // padding 4384 4385 return v 4386 } 4387 4388 // Bytes writes a PropertyNotifyEvent value to a byte slice. 4389 func (v PropertyNotifyEvent) Bytes() []byte { 4390 buf := make([]byte, 32) 4391 b := 0 4392 4393 // write event number 4394 buf[b] = 28 4395 b += 1 4396 4397 b += 1 // padding 4398 4399 b += 2 // skip sequence number 4400 4401 xgb.Put32(buf[b:], uint32(v.Window)) 4402 b += 4 4403 4404 xgb.Put32(buf[b:], uint32(v.Atom)) 4405 b += 4 4406 4407 xgb.Put32(buf[b:], uint32(v.Time)) 4408 b += 4 4409 4410 buf[b] = v.State 4411 b += 1 4412 4413 b += 3 // padding 4414 4415 return buf 4416 } 4417 4418 // SequenceId returns the sequence id attached to the PropertyNotify event. 4419 // Events without a sequence number (KeymapNotify) return 0. 4420 // This is mostly used internally. 4421 func (v PropertyNotifyEvent) SequenceId() uint16 { 4422 return v.Sequence 4423 } 4424 4425 // String is a rudimentary string representation of PropertyNotifyEvent. 4426 func (v PropertyNotifyEvent) String() string { 4427 fieldVals := make([]string, 0, 6) 4428 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 4429 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 4430 fieldVals = append(fieldVals, xgb.Sprintf("Atom: %d", v.Atom)) 4431 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 4432 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 4433 return "PropertyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 4434 } 4435 4436 func init() { 4437 xgb.NewEventFuncs[28] = PropertyNotifyEventNew 4438 } 4439 4440 const ( 4441 QueryShapeOfLargestCursor = 0 4442 QueryShapeOfFastestTile = 1 4443 QueryShapeOfFastestStipple = 2 4444 ) 4445 4446 type Rectangle struct { 4447 X int16 4448 Y int16 4449 Width uint16 4450 Height uint16 4451 } 4452 4453 // RectangleRead reads a byte slice into a Rectangle value. 4454 func RectangleRead(buf []byte, v *Rectangle) int { 4455 b := 0 4456 4457 v.X = int16(xgb.Get16(buf[b:])) 4458 b += 2 4459 4460 v.Y = int16(xgb.Get16(buf[b:])) 4461 b += 2 4462 4463 v.Width = xgb.Get16(buf[b:]) 4464 b += 2 4465 4466 v.Height = xgb.Get16(buf[b:]) 4467 b += 2 4468 4469 return b 4470 } 4471 4472 // RectangleReadList reads a byte slice into a list of Rectangle values. 4473 func RectangleReadList(buf []byte, dest []Rectangle) int { 4474 b := 0 4475 for i := 0; i < len(dest); i++ { 4476 dest[i] = Rectangle{} 4477 b += RectangleRead(buf[b:], &dest[i]) 4478 } 4479 return xgb.Pad(b) 4480 } 4481 4482 // Bytes writes a Rectangle value to a byte slice. 4483 func (v Rectangle) Bytes() []byte { 4484 buf := make([]byte, 8) 4485 b := 0 4486 4487 xgb.Put16(buf[b:], uint16(v.X)) 4488 b += 2 4489 4490 xgb.Put16(buf[b:], uint16(v.Y)) 4491 b += 2 4492 4493 xgb.Put16(buf[b:], v.Width) 4494 b += 2 4495 4496 xgb.Put16(buf[b:], v.Height) 4497 b += 2 4498 4499 return buf[:b] 4500 } 4501 4502 // RectangleListBytes writes a list of Rectangle values to a byte slice. 4503 func RectangleListBytes(buf []byte, list []Rectangle) int { 4504 b := 0 4505 var structBytes []byte 4506 for _, item := range list { 4507 structBytes = item.Bytes() 4508 copy(buf[b:], structBytes) 4509 b += len(structBytes) 4510 } 4511 return xgb.Pad(b) 4512 } 4513 4514 // ReparentNotify is the event number for a ReparentNotifyEvent. 4515 const ReparentNotify = 21 4516 4517 type ReparentNotifyEvent struct { 4518 Sequence uint16 4519 // padding: 1 bytes 4520 Event Window 4521 Window Window 4522 Parent Window 4523 X int16 4524 Y int16 4525 OverrideRedirect bool 4526 // padding: 3 bytes 4527 } 4528 4529 // ReparentNotifyEventNew constructs a ReparentNotifyEvent value that implements xgb.Event from a byte slice. 4530 func ReparentNotifyEventNew(buf []byte) xgb.Event { 4531 v := ReparentNotifyEvent{} 4532 b := 1 // don't read event number 4533 4534 b += 1 // padding 4535 4536 v.Sequence = xgb.Get16(buf[b:]) 4537 b += 2 4538 4539 v.Event = Window(xgb.Get32(buf[b:])) 4540 b += 4 4541 4542 v.Window = Window(xgb.Get32(buf[b:])) 4543 b += 4 4544 4545 v.Parent = Window(xgb.Get32(buf[b:])) 4546 b += 4 4547 4548 v.X = int16(xgb.Get16(buf[b:])) 4549 b += 2 4550 4551 v.Y = int16(xgb.Get16(buf[b:])) 4552 b += 2 4553 4554 if buf[b] == 1 { 4555 v.OverrideRedirect = true 4556 } else { 4557 v.OverrideRedirect = false 4558 } 4559 b += 1 4560 4561 b += 3 // padding 4562 4563 return v 4564 } 4565 4566 // Bytes writes a ReparentNotifyEvent value to a byte slice. 4567 func (v ReparentNotifyEvent) Bytes() []byte { 4568 buf := make([]byte, 32) 4569 b := 0 4570 4571 // write event number 4572 buf[b] = 21 4573 b += 1 4574 4575 b += 1 // padding 4576 4577 b += 2 // skip sequence number 4578 4579 xgb.Put32(buf[b:], uint32(v.Event)) 4580 b += 4 4581 4582 xgb.Put32(buf[b:], uint32(v.Window)) 4583 b += 4 4584 4585 xgb.Put32(buf[b:], uint32(v.Parent)) 4586 b += 4 4587 4588 xgb.Put16(buf[b:], uint16(v.X)) 4589 b += 2 4590 4591 xgb.Put16(buf[b:], uint16(v.Y)) 4592 b += 2 4593 4594 if v.OverrideRedirect { 4595 buf[b] = 1 4596 } else { 4597 buf[b] = 0 4598 } 4599 b += 1 4600 4601 b += 3 // padding 4602 4603 return buf 4604 } 4605 4606 // SequenceId returns the sequence id attached to the ReparentNotify event. 4607 // Events without a sequence number (KeymapNotify) return 0. 4608 // This is mostly used internally. 4609 func (v ReparentNotifyEvent) SequenceId() uint16 { 4610 return v.Sequence 4611 } 4612 4613 // String is a rudimentary string representation of ReparentNotifyEvent. 4614 func (v ReparentNotifyEvent) String() string { 4615 fieldVals := make([]string, 0, 8) 4616 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 4617 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 4618 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 4619 fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) 4620 fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) 4621 fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) 4622 fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) 4623 return "ReparentNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 4624 } 4625 4626 func init() { 4627 xgb.NewEventFuncs[21] = ReparentNotifyEventNew 4628 } 4629 4630 // BadRequest is the error number for a BadRequest. 4631 const BadRequest = 1 4632 4633 type RequestError struct { 4634 Sequence uint16 4635 NiceName string 4636 BadValue uint32 4637 MinorOpcode uint16 4638 MajorOpcode byte 4639 // padding: 1 bytes 4640 } 4641 4642 // RequestErrorNew constructs a RequestError value that implements xgb.Error from a byte slice. 4643 func RequestErrorNew(buf []byte) xgb.Error { 4644 v := RequestError{} 4645 v.NiceName = "Request" 4646 4647 b := 1 // skip error determinant 4648 b += 1 // don't read error number 4649 4650 v.Sequence = xgb.Get16(buf[b:]) 4651 b += 2 4652 4653 v.BadValue = xgb.Get32(buf[b:]) 4654 b += 4 4655 4656 v.MinorOpcode = xgb.Get16(buf[b:]) 4657 b += 2 4658 4659 v.MajorOpcode = buf[b] 4660 b += 1 4661 4662 b += 1 // padding 4663 4664 return v 4665 } 4666 4667 // SequenceId returns the sequence id attached to the BadRequest error. 4668 // This is mostly used internally. 4669 func (err RequestError) SequenceId() uint16 { 4670 return err.Sequence 4671 } 4672 4673 // BadId returns the 'BadValue' number if one exists for the BadRequest error. If no bad value exists, 0 is returned. 4674 func (err RequestError) BadId() uint32 { 4675 return err.BadValue 4676 } 4677 4678 // Error returns a rudimentary string representation of the BadRequest error. 4679 4680 func (err RequestError) Error() string { 4681 fieldVals := make([]string, 0, 4) 4682 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 4683 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 4684 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 4685 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 4686 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 4687 return "BadRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" 4688 } 4689 4690 func init() { 4691 xgb.NewErrorFuncs[1] = RequestErrorNew 4692 } 4693 4694 // ResizeRequest is the event number for a ResizeRequestEvent. 4695 const ResizeRequest = 25 4696 4697 type ResizeRequestEvent struct { 4698 Sequence uint16 4699 // padding: 1 bytes 4700 Window Window 4701 Width uint16 4702 Height uint16 4703 } 4704 4705 // ResizeRequestEventNew constructs a ResizeRequestEvent value that implements xgb.Event from a byte slice. 4706 func ResizeRequestEventNew(buf []byte) xgb.Event { 4707 v := ResizeRequestEvent{} 4708 b := 1 // don't read event number 4709 4710 b += 1 // padding 4711 4712 v.Sequence = xgb.Get16(buf[b:]) 4713 b += 2 4714 4715 v.Window = Window(xgb.Get32(buf[b:])) 4716 b += 4 4717 4718 v.Width = xgb.Get16(buf[b:]) 4719 b += 2 4720 4721 v.Height = xgb.Get16(buf[b:]) 4722 b += 2 4723 4724 return v 4725 } 4726 4727 // Bytes writes a ResizeRequestEvent value to a byte slice. 4728 func (v ResizeRequestEvent) Bytes() []byte { 4729 buf := make([]byte, 32) 4730 b := 0 4731 4732 // write event number 4733 buf[b] = 25 4734 b += 1 4735 4736 b += 1 // padding 4737 4738 b += 2 // skip sequence number 4739 4740 xgb.Put32(buf[b:], uint32(v.Window)) 4741 b += 4 4742 4743 xgb.Put16(buf[b:], v.Width) 4744 b += 2 4745 4746 xgb.Put16(buf[b:], v.Height) 4747 b += 2 4748 4749 return buf 4750 } 4751 4752 // SequenceId returns the sequence id attached to the ResizeRequest event. 4753 // Events without a sequence number (KeymapNotify) return 0. 4754 // This is mostly used internally. 4755 func (v ResizeRequestEvent) SequenceId() uint16 { 4756 return v.Sequence 4757 } 4758 4759 // String is a rudimentary string representation of ResizeRequestEvent. 4760 func (v ResizeRequestEvent) String() string { 4761 fieldVals := make([]string, 0, 4) 4762 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 4763 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 4764 fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) 4765 fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) 4766 return "ResizeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" 4767 } 4768 4769 func init() { 4770 xgb.NewEventFuncs[25] = ResizeRequestEventNew 4771 } 4772 4773 type Rgb struct { 4774 Red uint16 4775 Green uint16 4776 Blue uint16 4777 // padding: 2 bytes 4778 } 4779 4780 // RgbRead reads a byte slice into a Rgb value. 4781 func RgbRead(buf []byte, v *Rgb) int { 4782 b := 0 4783 4784 v.Red = xgb.Get16(buf[b:]) 4785 b += 2 4786 4787 v.Green = xgb.Get16(buf[b:]) 4788 b += 2 4789 4790 v.Blue = xgb.Get16(buf[b:]) 4791 b += 2 4792 4793 b += 2 // padding 4794 4795 return b 4796 } 4797 4798 // RgbReadList reads a byte slice into a list of Rgb values. 4799 func RgbReadList(buf []byte, dest []Rgb) int { 4800 b := 0 4801 for i := 0; i < len(dest); i++ { 4802 dest[i] = Rgb{} 4803 b += RgbRead(buf[b:], &dest[i]) 4804 } 4805 return xgb.Pad(b) 4806 } 4807 4808 // Bytes writes a Rgb value to a byte slice. 4809 func (v Rgb) Bytes() []byte { 4810 buf := make([]byte, 8) 4811 b := 0 4812 4813 xgb.Put16(buf[b:], v.Red) 4814 b += 2 4815 4816 xgb.Put16(buf[b:], v.Green) 4817 b += 2 4818 4819 xgb.Put16(buf[b:], v.Blue) 4820 b += 2 4821 4822 b += 2 // padding 4823 4824 return buf[:b] 4825 } 4826 4827 // RgbListBytes writes a list of Rgb values to a byte slice. 4828 func RgbListBytes(buf []byte, list []Rgb) int { 4829 b := 0 4830 var structBytes []byte 4831 for _, item := range list { 4832 structBytes = item.Bytes() 4833 copy(buf[b:], structBytes) 4834 b += len(structBytes) 4835 } 4836 return xgb.Pad(b) 4837 } 4838 4839 type ScreenInfo struct { 4840 Root Window 4841 DefaultColormap Colormap 4842 WhitePixel uint32 4843 BlackPixel uint32 4844 CurrentInputMasks uint32 4845 WidthInPixels uint16 4846 HeightInPixels uint16 4847 WidthInMillimeters uint16 4848 HeightInMillimeters uint16 4849 MinInstalledMaps uint16 4850 MaxInstalledMaps uint16 4851 RootVisual Visualid 4852 BackingStores byte 4853 SaveUnders bool 4854 RootDepth byte 4855 AllowedDepthsLen byte 4856 AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) 4857 } 4858 4859 // ScreenInfoRead reads a byte slice into a ScreenInfo value. 4860 func ScreenInfoRead(buf []byte, v *ScreenInfo) int { 4861 b := 0 4862 4863 v.Root = Window(xgb.Get32(buf[b:])) 4864 b += 4 4865 4866 v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) 4867 b += 4 4868 4869 v.WhitePixel = xgb.Get32(buf[b:]) 4870 b += 4 4871 4872 v.BlackPixel = xgb.Get32(buf[b:]) 4873 b += 4 4874 4875 v.CurrentInputMasks = xgb.Get32(buf[b:]) 4876 b += 4 4877 4878 v.WidthInPixels = xgb.Get16(buf[b:]) 4879 b += 2 4880 4881 v.HeightInPixels = xgb.Get16(buf[b:]) 4882 b += 2 4883 4884 v.WidthInMillimeters = xgb.Get16(buf[b:]) 4885 b += 2 4886 4887 v.HeightInMillimeters = xgb.Get16(buf[b:]) 4888 b += 2 4889 4890 v.MinInstalledMaps = xgb.Get16(buf[b:]) 4891 b += 2 4892 4893 v.MaxInstalledMaps = xgb.Get16(buf[b:]) 4894 b += 2 4895 4896 v.RootVisual = Visualid(xgb.Get32(buf[b:])) 4897 b += 4 4898 4899 v.BackingStores = buf[b] 4900 b += 1 4901 4902 if buf[b] == 1 { 4903 v.SaveUnders = true 4904 } else { 4905 v.SaveUnders = false 4906 } 4907 b += 1 4908 4909 v.RootDepth = buf[b] 4910 b += 1 4911 4912 v.AllowedDepthsLen = buf[b] 4913 b += 1 4914 4915 v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) 4916 b += DepthInfoReadList(buf[b:], v.AllowedDepths) 4917 4918 return b 4919 } 4920 4921 // ScreenInfoReadList reads a byte slice into a list of ScreenInfo values. 4922 func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { 4923 b := 0 4924 for i := 0; i < len(dest); i++ { 4925 dest[i] = ScreenInfo{} 4926 b += ScreenInfoRead(buf[b:], &dest[i]) 4927 } 4928 return xgb.Pad(b) 4929 } 4930 4931 // Bytes writes a ScreenInfo value to a byte slice. 4932 func (v ScreenInfo) Bytes() []byte { 4933 buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) 4934 b := 0 4935 4936 xgb.Put32(buf[b:], uint32(v.Root)) 4937 b += 4 4938 4939 xgb.Put32(buf[b:], uint32(v.DefaultColormap)) 4940 b += 4 4941 4942 xgb.Put32(buf[b:], v.WhitePixel) 4943 b += 4 4944 4945 xgb.Put32(buf[b:], v.BlackPixel) 4946 b += 4 4947 4948 xgb.Put32(buf[b:], v.CurrentInputMasks) 4949 b += 4 4950 4951 xgb.Put16(buf[b:], v.WidthInPixels) 4952 b += 2 4953 4954 xgb.Put16(buf[b:], v.HeightInPixels) 4955 b += 2 4956 4957 xgb.Put16(buf[b:], v.WidthInMillimeters) 4958 b += 2 4959 4960 xgb.Put16(buf[b:], v.HeightInMillimeters) 4961 b += 2 4962 4963 xgb.Put16(buf[b:], v.MinInstalledMaps) 4964 b += 2 4965 4966 xgb.Put16(buf[b:], v.MaxInstalledMaps) 4967 b += 2 4968 4969 xgb.Put32(buf[b:], uint32(v.RootVisual)) 4970 b += 4 4971 4972 buf[b] = v.BackingStores 4973 b += 1 4974 4975 if v.SaveUnders { 4976 buf[b] = 1 4977 } else { 4978 buf[b] = 0 4979 } 4980 b += 1 4981 4982 buf[b] = v.RootDepth 4983 b += 1 4984 4985 buf[b] = v.AllowedDepthsLen 4986 b += 1 4987 4988 b += DepthInfoListBytes(buf[b:], v.AllowedDepths) 4989 4990 return buf[:b] 4991 } 4992 4993 // ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. 4994 func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { 4995 b := 0 4996 var structBytes []byte 4997 for _, item := range list { 4998 structBytes = item.Bytes() 4999 copy(buf[b:], structBytes) 5000 b += len(structBytes) 5001 } 5002 return xgb.Pad(b) 5003 } 5004 5005 // ScreenInfoListSize computes the size (bytes) of a list of ScreenInfo values. 5006 func ScreenInfoListSize(list []ScreenInfo) int { 5007 size := 0 5008 for _, item := range list { 5009 size += (40 + DepthInfoListSize(item.AllowedDepths)) 5010 } 5011 return size 5012 } 5013 5014 const ( 5015 ScreenSaverReset = 0 5016 ScreenSaverActive = 1 5017 ) 5018 5019 type Segment struct { 5020 X1 int16 5021 Y1 int16 5022 X2 int16 5023 Y2 int16 5024 } 5025 5026 // SegmentRead reads a byte slice into a Segment value. 5027 func SegmentRead(buf []byte, v *Segment) int { 5028 b := 0 5029 5030 v.X1 = int16(xgb.Get16(buf[b:])) 5031 b += 2 5032 5033 v.Y1 = int16(xgb.Get16(buf[b:])) 5034 b += 2 5035 5036 v.X2 = int16(xgb.Get16(buf[b:])) 5037 b += 2 5038 5039 v.Y2 = int16(xgb.Get16(buf[b:])) 5040 b += 2 5041 5042 return b 5043 } 5044 5045 // SegmentReadList reads a byte slice into a list of Segment values. 5046 func SegmentReadList(buf []byte, dest []Segment) int { 5047 b := 0 5048 for i := 0; i < len(dest); i++ { 5049 dest[i] = Segment{} 5050 b += SegmentRead(buf[b:], &dest[i]) 5051 } 5052 return xgb.Pad(b) 5053 } 5054 5055 // Bytes writes a Segment value to a byte slice. 5056 func (v Segment) Bytes() []byte { 5057 buf := make([]byte, 8) 5058 b := 0 5059 5060 xgb.Put16(buf[b:], uint16(v.X1)) 5061 b += 2 5062 5063 xgb.Put16(buf[b:], uint16(v.Y1)) 5064 b += 2 5065 5066 xgb.Put16(buf[b:], uint16(v.X2)) 5067 b += 2 5068 5069 xgb.Put16(buf[b:], uint16(v.Y2)) 5070 b += 2 5071 5072 return buf[:b] 5073 } 5074 5075 // SegmentListBytes writes a list of Segment values to a byte slice. 5076 func SegmentListBytes(buf []byte, list []Segment) int { 5077 b := 0 5078 var structBytes []byte 5079 for _, item := range list { 5080 structBytes = item.Bytes() 5081 copy(buf[b:], structBytes) 5082 b += len(structBytes) 5083 } 5084 return xgb.Pad(b) 5085 } 5086 5087 // SelectionClear is the event number for a SelectionClearEvent. 5088 const SelectionClear = 29 5089 5090 type SelectionClearEvent struct { 5091 Sequence uint16 5092 // padding: 1 bytes 5093 Time Timestamp 5094 Owner Window 5095 Selection Atom 5096 } 5097 5098 // SelectionClearEventNew constructs a SelectionClearEvent value that implements xgb.Event from a byte slice. 5099 func SelectionClearEventNew(buf []byte) xgb.Event { 5100 v := SelectionClearEvent{} 5101 b := 1 // don't read event number 5102 5103 b += 1 // padding 5104 5105 v.Sequence = xgb.Get16(buf[b:]) 5106 b += 2 5107 5108 v.Time = Timestamp(xgb.Get32(buf[b:])) 5109 b += 4 5110 5111 v.Owner = Window(xgb.Get32(buf[b:])) 5112 b += 4 5113 5114 v.Selection = Atom(xgb.Get32(buf[b:])) 5115 b += 4 5116 5117 return v 5118 } 5119 5120 // Bytes writes a SelectionClearEvent value to a byte slice. 5121 func (v SelectionClearEvent) Bytes() []byte { 5122 buf := make([]byte, 32) 5123 b := 0 5124 5125 // write event number 5126 buf[b] = 29 5127 b += 1 5128 5129 b += 1 // padding 5130 5131 b += 2 // skip sequence number 5132 5133 xgb.Put32(buf[b:], uint32(v.Time)) 5134 b += 4 5135 5136 xgb.Put32(buf[b:], uint32(v.Owner)) 5137 b += 4 5138 5139 xgb.Put32(buf[b:], uint32(v.Selection)) 5140 b += 4 5141 5142 return buf 5143 } 5144 5145 // SequenceId returns the sequence id attached to the SelectionClear event. 5146 // Events without a sequence number (KeymapNotify) return 0. 5147 // This is mostly used internally. 5148 func (v SelectionClearEvent) SequenceId() uint16 { 5149 return v.Sequence 5150 } 5151 5152 // String is a rudimentary string representation of SelectionClearEvent. 5153 func (v SelectionClearEvent) String() string { 5154 fieldVals := make([]string, 0, 4) 5155 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 5156 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 5157 fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) 5158 fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) 5159 return "SelectionClear {" + xgb.StringsJoin(fieldVals, ", ") + "}" 5160 } 5161 5162 func init() { 5163 xgb.NewEventFuncs[29] = SelectionClearEventNew 5164 } 5165 5166 // SelectionNotify is the event number for a SelectionNotifyEvent. 5167 const SelectionNotify = 31 5168 5169 type SelectionNotifyEvent struct { 5170 Sequence uint16 5171 // padding: 1 bytes 5172 Time Timestamp 5173 Requestor Window 5174 Selection Atom 5175 Target Atom 5176 Property Atom 5177 } 5178 5179 // SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. 5180 func SelectionNotifyEventNew(buf []byte) xgb.Event { 5181 v := SelectionNotifyEvent{} 5182 b := 1 // don't read event number 5183 5184 b += 1 // padding 5185 5186 v.Sequence = xgb.Get16(buf[b:]) 5187 b += 2 5188 5189 v.Time = Timestamp(xgb.Get32(buf[b:])) 5190 b += 4 5191 5192 v.Requestor = Window(xgb.Get32(buf[b:])) 5193 b += 4 5194 5195 v.Selection = Atom(xgb.Get32(buf[b:])) 5196 b += 4 5197 5198 v.Target = Atom(xgb.Get32(buf[b:])) 5199 b += 4 5200 5201 v.Property = Atom(xgb.Get32(buf[b:])) 5202 b += 4 5203 5204 return v 5205 } 5206 5207 // Bytes writes a SelectionNotifyEvent value to a byte slice. 5208 func (v SelectionNotifyEvent) Bytes() []byte { 5209 buf := make([]byte, 32) 5210 b := 0 5211 5212 // write event number 5213 buf[b] = 31 5214 b += 1 5215 5216 b += 1 // padding 5217 5218 b += 2 // skip sequence number 5219 5220 xgb.Put32(buf[b:], uint32(v.Time)) 5221 b += 4 5222 5223 xgb.Put32(buf[b:], uint32(v.Requestor)) 5224 b += 4 5225 5226 xgb.Put32(buf[b:], uint32(v.Selection)) 5227 b += 4 5228 5229 xgb.Put32(buf[b:], uint32(v.Target)) 5230 b += 4 5231 5232 xgb.Put32(buf[b:], uint32(v.Property)) 5233 b += 4 5234 5235 return buf 5236 } 5237 5238 // SequenceId returns the sequence id attached to the SelectionNotify event. 5239 // Events without a sequence number (KeymapNotify) return 0. 5240 // This is mostly used internally. 5241 func (v SelectionNotifyEvent) SequenceId() uint16 { 5242 return v.Sequence 5243 } 5244 5245 // String is a rudimentary string representation of SelectionNotifyEvent. 5246 func (v SelectionNotifyEvent) String() string { 5247 fieldVals := make([]string, 0, 6) 5248 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 5249 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 5250 fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) 5251 fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) 5252 fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) 5253 fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) 5254 return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 5255 } 5256 5257 func init() { 5258 xgb.NewEventFuncs[31] = SelectionNotifyEventNew 5259 } 5260 5261 // SelectionRequest is the event number for a SelectionRequestEvent. 5262 const SelectionRequest = 30 5263 5264 type SelectionRequestEvent struct { 5265 Sequence uint16 5266 // padding: 1 bytes 5267 Time Timestamp 5268 Owner Window 5269 Requestor Window 5270 Selection Atom 5271 Target Atom 5272 Property Atom 5273 } 5274 5275 // SelectionRequestEventNew constructs a SelectionRequestEvent value that implements xgb.Event from a byte slice. 5276 func SelectionRequestEventNew(buf []byte) xgb.Event { 5277 v := SelectionRequestEvent{} 5278 b := 1 // don't read event number 5279 5280 b += 1 // padding 5281 5282 v.Sequence = xgb.Get16(buf[b:]) 5283 b += 2 5284 5285 v.Time = Timestamp(xgb.Get32(buf[b:])) 5286 b += 4 5287 5288 v.Owner = Window(xgb.Get32(buf[b:])) 5289 b += 4 5290 5291 v.Requestor = Window(xgb.Get32(buf[b:])) 5292 b += 4 5293 5294 v.Selection = Atom(xgb.Get32(buf[b:])) 5295 b += 4 5296 5297 v.Target = Atom(xgb.Get32(buf[b:])) 5298 b += 4 5299 5300 v.Property = Atom(xgb.Get32(buf[b:])) 5301 b += 4 5302 5303 return v 5304 } 5305 5306 // Bytes writes a SelectionRequestEvent value to a byte slice. 5307 func (v SelectionRequestEvent) Bytes() []byte { 5308 buf := make([]byte, 32) 5309 b := 0 5310 5311 // write event number 5312 buf[b] = 30 5313 b += 1 5314 5315 b += 1 // padding 5316 5317 b += 2 // skip sequence number 5318 5319 xgb.Put32(buf[b:], uint32(v.Time)) 5320 b += 4 5321 5322 xgb.Put32(buf[b:], uint32(v.Owner)) 5323 b += 4 5324 5325 xgb.Put32(buf[b:], uint32(v.Requestor)) 5326 b += 4 5327 5328 xgb.Put32(buf[b:], uint32(v.Selection)) 5329 b += 4 5330 5331 xgb.Put32(buf[b:], uint32(v.Target)) 5332 b += 4 5333 5334 xgb.Put32(buf[b:], uint32(v.Property)) 5335 b += 4 5336 5337 return buf 5338 } 5339 5340 // SequenceId returns the sequence id attached to the SelectionRequest event. 5341 // Events without a sequence number (KeymapNotify) return 0. 5342 // This is mostly used internally. 5343 func (v SelectionRequestEvent) SequenceId() uint16 { 5344 return v.Sequence 5345 } 5346 5347 // String is a rudimentary string representation of SelectionRequestEvent. 5348 func (v SelectionRequestEvent) String() string { 5349 fieldVals := make([]string, 0, 7) 5350 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 5351 fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) 5352 fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) 5353 fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) 5354 fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) 5355 fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) 5356 fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) 5357 return "SelectionRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" 5358 } 5359 5360 func init() { 5361 xgb.NewEventFuncs[30] = SelectionRequestEventNew 5362 } 5363 5364 const ( 5365 SendEventDestPointerWindow = 0 5366 SendEventDestItemFocus = 1 5367 ) 5368 5369 const ( 5370 SetModeInsert = 0 5371 SetModeDelete = 1 5372 ) 5373 5374 type SetupAuthenticate struct { 5375 Status byte 5376 // padding: 5 bytes 5377 Length uint16 5378 Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) 5379 } 5380 5381 // SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. 5382 func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { 5383 b := 0 5384 5385 v.Status = buf[b] 5386 b += 1 5387 5388 b += 5 // padding 5389 5390 v.Length = xgb.Get16(buf[b:]) 5391 b += 2 5392 5393 { 5394 byteString := make([]byte, (int(v.Length) * 4)) 5395 copy(byteString[:(int(v.Length)*4)], buf[b:]) 5396 v.Reason = string(byteString) 5397 b += int((int(v.Length) * 4)) 5398 } 5399 5400 return b 5401 } 5402 5403 // SetupAuthenticateReadList reads a byte slice into a list of SetupAuthenticate values. 5404 func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { 5405 b := 0 5406 for i := 0; i < len(dest); i++ { 5407 dest[i] = SetupAuthenticate{} 5408 b += SetupAuthenticateRead(buf[b:], &dest[i]) 5409 } 5410 return xgb.Pad(b) 5411 } 5412 5413 // Bytes writes a SetupAuthenticate value to a byte slice. 5414 func (v SetupAuthenticate) Bytes() []byte { 5415 buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) 5416 b := 0 5417 5418 buf[b] = v.Status 5419 b += 1 5420 5421 b += 5 // padding 5422 5423 xgb.Put16(buf[b:], v.Length) 5424 b += 2 5425 5426 copy(buf[b:], v.Reason[:(int(v.Length)*4)]) 5427 b += int((int(v.Length) * 4)) 5428 5429 return buf[:b] 5430 } 5431 5432 // SetupAuthenticateListBytes writes a list of SetupAuthenticate values to a byte slice. 5433 func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { 5434 b := 0 5435 var structBytes []byte 5436 for _, item := range list { 5437 structBytes = item.Bytes() 5438 copy(buf[b:], structBytes) 5439 b += len(structBytes) 5440 } 5441 return xgb.Pad(b) 5442 } 5443 5444 // SetupAuthenticateListSize computes the size (bytes) of a list of SetupAuthenticate values. 5445 func SetupAuthenticateListSize(list []SetupAuthenticate) int { 5446 size := 0 5447 for _, item := range list { 5448 size += (8 + xgb.Pad(((int(item.Length) * 4) * 1))) 5449 } 5450 return size 5451 } 5452 5453 type SetupFailed struct { 5454 Status byte 5455 ReasonLen byte 5456 ProtocolMajorVersion uint16 5457 ProtocolMinorVersion uint16 5458 Length uint16 5459 Reason string // size: xgb.Pad((int(ReasonLen) * 1)) 5460 } 5461 5462 // SetupFailedRead reads a byte slice into a SetupFailed value. 5463 func SetupFailedRead(buf []byte, v *SetupFailed) int { 5464 b := 0 5465 5466 v.Status = buf[b] 5467 b += 1 5468 5469 v.ReasonLen = buf[b] 5470 b += 1 5471 5472 v.ProtocolMajorVersion = xgb.Get16(buf[b:]) 5473 b += 2 5474 5475 v.ProtocolMinorVersion = xgb.Get16(buf[b:]) 5476 b += 2 5477 5478 v.Length = xgb.Get16(buf[b:]) 5479 b += 2 5480 5481 { 5482 byteString := make([]byte, v.ReasonLen) 5483 copy(byteString[:v.ReasonLen], buf[b:]) 5484 v.Reason = string(byteString) 5485 b += int(v.ReasonLen) 5486 } 5487 5488 return b 5489 } 5490 5491 // SetupFailedReadList reads a byte slice into a list of SetupFailed values. 5492 func SetupFailedReadList(buf []byte, dest []SetupFailed) int { 5493 b := 0 5494 for i := 0; i < len(dest); i++ { 5495 dest[i] = SetupFailed{} 5496 b += SetupFailedRead(buf[b:], &dest[i]) 5497 } 5498 return xgb.Pad(b) 5499 } 5500 5501 // Bytes writes a SetupFailed value to a byte slice. 5502 func (v SetupFailed) Bytes() []byte { 5503 buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) 5504 b := 0 5505 5506 buf[b] = v.Status 5507 b += 1 5508 5509 buf[b] = v.ReasonLen 5510 b += 1 5511 5512 xgb.Put16(buf[b:], v.ProtocolMajorVersion) 5513 b += 2 5514 5515 xgb.Put16(buf[b:], v.ProtocolMinorVersion) 5516 b += 2 5517 5518 xgb.Put16(buf[b:], v.Length) 5519 b += 2 5520 5521 copy(buf[b:], v.Reason[:v.ReasonLen]) 5522 b += int(v.ReasonLen) 5523 5524 return buf[:b] 5525 } 5526 5527 // SetupFailedListBytes writes a list of SetupFailed values to a byte slice. 5528 func SetupFailedListBytes(buf []byte, list []SetupFailed) int { 5529 b := 0 5530 var structBytes []byte 5531 for _, item := range list { 5532 structBytes = item.Bytes() 5533 copy(buf[b:], structBytes) 5534 b += len(structBytes) 5535 } 5536 return xgb.Pad(b) 5537 } 5538 5539 // SetupFailedListSize computes the size (bytes) of a list of SetupFailed values. 5540 func SetupFailedListSize(list []SetupFailed) int { 5541 size := 0 5542 for _, item := range list { 5543 size += (8 + xgb.Pad((int(item.ReasonLen) * 1))) 5544 } 5545 return size 5546 } 5547 5548 type SetupInfo struct { 5549 Status byte 5550 // padding: 1 bytes 5551 ProtocolMajorVersion uint16 5552 ProtocolMinorVersion uint16 5553 Length uint16 5554 ReleaseNumber uint32 5555 ResourceIdBase uint32 5556 ResourceIdMask uint32 5557 MotionBufferSize uint32 5558 VendorLen uint16 5559 MaximumRequestLength uint16 5560 RootsLen byte 5561 PixmapFormatsLen byte 5562 ImageByteOrder byte 5563 BitmapFormatBitOrder byte 5564 BitmapFormatScanlineUnit byte 5565 BitmapFormatScanlinePad byte 5566 MinKeycode Keycode 5567 MaxKeycode Keycode 5568 // padding: 4 bytes 5569 Vendor string // size: xgb.Pad((int(VendorLen) * 1)) 5570 // alignment gap to multiple of 4 5571 PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) 5572 // alignment gap to multiple of 4 5573 Roots []ScreenInfo // size: ScreenInfoListSize(Roots) 5574 } 5575 5576 // SetupInfoRead reads a byte slice into a SetupInfo value. 5577 func SetupInfoRead(buf []byte, v *SetupInfo) int { 5578 b := 0 5579 5580 v.Status = buf[b] 5581 b += 1 5582 5583 b += 1 // padding 5584 5585 v.ProtocolMajorVersion = xgb.Get16(buf[b:]) 5586 b += 2 5587 5588 v.ProtocolMinorVersion = xgb.Get16(buf[b:]) 5589 b += 2 5590 5591 v.Length = xgb.Get16(buf[b:]) 5592 b += 2 5593 5594 v.ReleaseNumber = xgb.Get32(buf[b:]) 5595 b += 4 5596 5597 v.ResourceIdBase = xgb.Get32(buf[b:]) 5598 b += 4 5599 5600 v.ResourceIdMask = xgb.Get32(buf[b:]) 5601 b += 4 5602 5603 v.MotionBufferSize = xgb.Get32(buf[b:]) 5604 b += 4 5605 5606 v.VendorLen = xgb.Get16(buf[b:]) 5607 b += 2 5608 5609 v.MaximumRequestLength = xgb.Get16(buf[b:]) 5610 b += 2 5611 5612 v.RootsLen = buf[b] 5613 b += 1 5614 5615 v.PixmapFormatsLen = buf[b] 5616 b += 1 5617 5618 v.ImageByteOrder = buf[b] 5619 b += 1 5620 5621 v.BitmapFormatBitOrder = buf[b] 5622 b += 1 5623 5624 v.BitmapFormatScanlineUnit = buf[b] 5625 b += 1 5626 5627 v.BitmapFormatScanlinePad = buf[b] 5628 b += 1 5629 5630 v.MinKeycode = Keycode(buf[b]) 5631 b += 1 5632 5633 v.MaxKeycode = Keycode(buf[b]) 5634 b += 1 5635 5636 b += 4 // padding 5637 5638 { 5639 byteString := make([]byte, v.VendorLen) 5640 copy(byteString[:v.VendorLen], buf[b:]) 5641 v.Vendor = string(byteString) 5642 b += int(v.VendorLen) 5643 } 5644 5645 b = (b + 3) & ^3 // alignment gap 5646 5647 v.PixmapFormats = make([]Format, v.PixmapFormatsLen) 5648 b += FormatReadList(buf[b:], v.PixmapFormats) 5649 5650 b = (b + 3) & ^3 // alignment gap 5651 5652 v.Roots = make([]ScreenInfo, v.RootsLen) 5653 b += ScreenInfoReadList(buf[b:], v.Roots) 5654 5655 return b 5656 } 5657 5658 // SetupInfoReadList reads a byte slice into a list of SetupInfo values. 5659 func SetupInfoReadList(buf []byte, dest []SetupInfo) int { 5660 b := 0 5661 for i := 0; i < len(dest); i++ { 5662 dest[i] = SetupInfo{} 5663 b += SetupInfoRead(buf[b:], &dest[i]) 5664 } 5665 return xgb.Pad(b) 5666 } 5667 5668 // Bytes writes a SetupInfo value to a byte slice. 5669 func (v SetupInfo) Bytes() []byte { 5670 buf := make([]byte, (((((40 + xgb.Pad((int(v.VendorLen) * 1))) + 4) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + 4) + ScreenInfoListSize(v.Roots))) 5671 b := 0 5672 5673 buf[b] = v.Status 5674 b += 1 5675 5676 b += 1 // padding 5677 5678 xgb.Put16(buf[b:], v.ProtocolMajorVersion) 5679 b += 2 5680 5681 xgb.Put16(buf[b:], v.ProtocolMinorVersion) 5682 b += 2 5683 5684 xgb.Put16(buf[b:], v.Length) 5685 b += 2 5686 5687 xgb.Put32(buf[b:], v.ReleaseNumber) 5688 b += 4 5689 5690 xgb.Put32(buf[b:], v.ResourceIdBase) 5691 b += 4 5692 5693 xgb.Put32(buf[b:], v.ResourceIdMask) 5694 b += 4 5695 5696 xgb.Put32(buf[b:], v.MotionBufferSize) 5697 b += 4 5698 5699 xgb.Put16(buf[b:], v.VendorLen) 5700 b += 2 5701 5702 xgb.Put16(buf[b:], v.MaximumRequestLength) 5703 b += 2 5704 5705 buf[b] = v.RootsLen 5706 b += 1 5707 5708 buf[b] = v.PixmapFormatsLen 5709 b += 1 5710 5711 buf[b] = v.ImageByteOrder 5712 b += 1 5713 5714 buf[b] = v.BitmapFormatBitOrder 5715 b += 1 5716 5717 buf[b] = v.BitmapFormatScanlineUnit 5718 b += 1 5719 5720 buf[b] = v.BitmapFormatScanlinePad 5721 b += 1 5722 5723 buf[b] = byte(v.MinKeycode) 5724 b += 1 5725 5726 buf[b] = byte(v.MaxKeycode) 5727 b += 1 5728 5729 b += 4 // padding 5730 5731 copy(buf[b:], v.Vendor[:v.VendorLen]) 5732 b += int(v.VendorLen) 5733 5734 b = (b + 3) & ^3 // alignment gap 5735 5736 b += FormatListBytes(buf[b:], v.PixmapFormats) 5737 5738 b = (b + 3) & ^3 // alignment gap 5739 5740 b += ScreenInfoListBytes(buf[b:], v.Roots) 5741 5742 return buf[:b] 5743 } 5744 5745 // SetupInfoListBytes writes a list of SetupInfo values to a byte slice. 5746 func SetupInfoListBytes(buf []byte, list []SetupInfo) int { 5747 b := 0 5748 var structBytes []byte 5749 for _, item := range list { 5750 structBytes = item.Bytes() 5751 copy(buf[b:], structBytes) 5752 b += len(structBytes) 5753 } 5754 return xgb.Pad(b) 5755 } 5756 5757 // SetupInfoListSize computes the size (bytes) of a list of SetupInfo values. 5758 func SetupInfoListSize(list []SetupInfo) int { 5759 size := 0 5760 for _, item := range list { 5761 size += (((((40 + xgb.Pad((int(item.VendorLen) * 1))) + 4) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + 4) + ScreenInfoListSize(item.Roots)) 5762 } 5763 return size 5764 } 5765 5766 type SetupRequest struct { 5767 ByteOrder byte 5768 // padding: 1 bytes 5769 ProtocolMajorVersion uint16 5770 ProtocolMinorVersion uint16 5771 AuthorizationProtocolNameLen uint16 5772 AuthorizationProtocolDataLen uint16 5773 // padding: 2 bytes 5774 AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) 5775 AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) 5776 } 5777 5778 // SetupRequestRead reads a byte slice into a SetupRequest value. 5779 func SetupRequestRead(buf []byte, v *SetupRequest) int { 5780 b := 0 5781 5782 v.ByteOrder = buf[b] 5783 b += 1 5784 5785 b += 1 // padding 5786 5787 v.ProtocolMajorVersion = xgb.Get16(buf[b:]) 5788 b += 2 5789 5790 v.ProtocolMinorVersion = xgb.Get16(buf[b:]) 5791 b += 2 5792 5793 v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) 5794 b += 2 5795 5796 v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) 5797 b += 2 5798 5799 b += 2 // padding 5800 5801 { 5802 byteString := make([]byte, v.AuthorizationProtocolNameLen) 5803 copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) 5804 v.AuthorizationProtocolName = string(byteString) 5805 b += int(v.AuthorizationProtocolNameLen) 5806 } 5807 5808 { 5809 byteString := make([]byte, v.AuthorizationProtocolDataLen) 5810 copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) 5811 v.AuthorizationProtocolData = string(byteString) 5812 b += int(v.AuthorizationProtocolDataLen) 5813 } 5814 5815 return b 5816 } 5817 5818 // SetupRequestReadList reads a byte slice into a list of SetupRequest values. 5819 func SetupRequestReadList(buf []byte, dest []SetupRequest) int { 5820 b := 0 5821 for i := 0; i < len(dest); i++ { 5822 dest[i] = SetupRequest{} 5823 b += SetupRequestRead(buf[b:], &dest[i]) 5824 } 5825 return xgb.Pad(b) 5826 } 5827 5828 // Bytes writes a SetupRequest value to a byte slice. 5829 func (v SetupRequest) Bytes() []byte { 5830 buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) 5831 b := 0 5832 5833 buf[b] = v.ByteOrder 5834 b += 1 5835 5836 b += 1 // padding 5837 5838 xgb.Put16(buf[b:], v.ProtocolMajorVersion) 5839 b += 2 5840 5841 xgb.Put16(buf[b:], v.ProtocolMinorVersion) 5842 b += 2 5843 5844 xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) 5845 b += 2 5846 5847 xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) 5848 b += 2 5849 5850 b += 2 // padding 5851 5852 copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) 5853 b += int(v.AuthorizationProtocolNameLen) 5854 5855 copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) 5856 b += int(v.AuthorizationProtocolDataLen) 5857 5858 return buf[:b] 5859 } 5860 5861 // SetupRequestListBytes writes a list of SetupRequest values to a byte slice. 5862 func SetupRequestListBytes(buf []byte, list []SetupRequest) int { 5863 b := 0 5864 var structBytes []byte 5865 for _, item := range list { 5866 structBytes = item.Bytes() 5867 copy(buf[b:], structBytes) 5868 b += len(structBytes) 5869 } 5870 return xgb.Pad(b) 5871 } 5872 5873 // SetupRequestListSize computes the size (bytes) of a list of SetupRequest values. 5874 func SetupRequestListSize(list []SetupRequest) int { 5875 size := 0 5876 for _, item := range list { 5877 size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) 5878 } 5879 return size 5880 } 5881 5882 const ( 5883 StackModeAbove = 0 5884 StackModeBelow = 1 5885 StackModeTopIf = 2 5886 StackModeBottomIf = 3 5887 StackModeOpposite = 4 5888 ) 5889 5890 type Str struct { 5891 NameLen byte 5892 Name string // size: xgb.Pad((int(NameLen) * 1)) 5893 } 5894 5895 // StrRead reads a byte slice into a Str value. 5896 func StrRead(buf []byte, v *Str) int { 5897 b := 0 5898 5899 v.NameLen = buf[b] 5900 b += 1 5901 5902 { 5903 byteString := make([]byte, v.NameLen) 5904 copy(byteString[:v.NameLen], buf[b:]) 5905 v.Name = string(byteString) 5906 b += int(v.NameLen) 5907 } 5908 5909 return b 5910 } 5911 5912 // StrReadList reads a byte slice into a list of Str values. 5913 func StrReadList(buf []byte, dest []Str) int { 5914 b := 0 5915 for i := 0; i < len(dest); i++ { 5916 dest[i] = Str{} 5917 b += StrRead(buf[b:], &dest[i]) 5918 } 5919 return xgb.Pad(b) 5920 } 5921 5922 // Bytes writes a Str value to a byte slice. 5923 func (v Str) Bytes() []byte { 5924 buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) 5925 b := 0 5926 5927 buf[b] = v.NameLen 5928 b += 1 5929 5930 copy(buf[b:], v.Name[:v.NameLen]) 5931 b += int(v.NameLen) 5932 5933 return buf[:b] 5934 } 5935 5936 // StrListBytes writes a list of Str values to a byte slice. 5937 func StrListBytes(buf []byte, list []Str) int { 5938 b := 0 5939 var structBytes []byte 5940 for _, item := range list { 5941 structBytes = item.Bytes() 5942 copy(buf[b:], structBytes) 5943 b += len(structBytes) 5944 } 5945 return xgb.Pad(b) 5946 } 5947 5948 // StrListSize computes the size (bytes) of a list of Str values. 5949 func StrListSize(list []Str) int { 5950 size := 0 5951 for _, item := range list { 5952 size += (1 + xgb.Pad((int(item.NameLen) * 1))) 5953 } 5954 return size 5955 } 5956 5957 const ( 5958 SubwindowModeClipByChildren = 0 5959 SubwindowModeIncludeInferiors = 1 5960 ) 5961 5962 const ( 5963 TimeCurrentTime = 0 5964 ) 5965 5966 type Timecoord struct { 5967 Time Timestamp 5968 X int16 5969 Y int16 5970 } 5971 5972 // TimecoordRead reads a byte slice into a Timecoord value. 5973 func TimecoordRead(buf []byte, v *Timecoord) int { 5974 b := 0 5975 5976 v.Time = Timestamp(xgb.Get32(buf[b:])) 5977 b += 4 5978 5979 v.X = int16(xgb.Get16(buf[b:])) 5980 b += 2 5981 5982 v.Y = int16(xgb.Get16(buf[b:])) 5983 b += 2 5984 5985 return b 5986 } 5987 5988 // TimecoordReadList reads a byte slice into a list of Timecoord values. 5989 func TimecoordReadList(buf []byte, dest []Timecoord) int { 5990 b := 0 5991 for i := 0; i < len(dest); i++ { 5992 dest[i] = Timecoord{} 5993 b += TimecoordRead(buf[b:], &dest[i]) 5994 } 5995 return xgb.Pad(b) 5996 } 5997 5998 // Bytes writes a Timecoord value to a byte slice. 5999 func (v Timecoord) Bytes() []byte { 6000 buf := make([]byte, 8) 6001 b := 0 6002 6003 xgb.Put32(buf[b:], uint32(v.Time)) 6004 b += 4 6005 6006 xgb.Put16(buf[b:], uint16(v.X)) 6007 b += 2 6008 6009 xgb.Put16(buf[b:], uint16(v.Y)) 6010 b += 2 6011 6012 return buf[:b] 6013 } 6014 6015 // TimecoordListBytes writes a list of Timecoord values to a byte slice. 6016 func TimecoordListBytes(buf []byte, list []Timecoord) int { 6017 b := 0 6018 var structBytes []byte 6019 for _, item := range list { 6020 structBytes = item.Bytes() 6021 copy(buf[b:], structBytes) 6022 b += len(structBytes) 6023 } 6024 return xgb.Pad(b) 6025 } 6026 6027 type Timestamp uint32 6028 6029 // UnmapNotify is the event number for a UnmapNotifyEvent. 6030 const UnmapNotify = 18 6031 6032 type UnmapNotifyEvent struct { 6033 Sequence uint16 6034 // padding: 1 bytes 6035 Event Window 6036 Window Window 6037 FromConfigure bool 6038 // padding: 3 bytes 6039 } 6040 6041 // UnmapNotifyEventNew constructs a UnmapNotifyEvent value that implements xgb.Event from a byte slice. 6042 func UnmapNotifyEventNew(buf []byte) xgb.Event { 6043 v := UnmapNotifyEvent{} 6044 b := 1 // don't read event number 6045 6046 b += 1 // padding 6047 6048 v.Sequence = xgb.Get16(buf[b:]) 6049 b += 2 6050 6051 v.Event = Window(xgb.Get32(buf[b:])) 6052 b += 4 6053 6054 v.Window = Window(xgb.Get32(buf[b:])) 6055 b += 4 6056 6057 if buf[b] == 1 { 6058 v.FromConfigure = true 6059 } else { 6060 v.FromConfigure = false 6061 } 6062 b += 1 6063 6064 b += 3 // padding 6065 6066 return v 6067 } 6068 6069 // Bytes writes a UnmapNotifyEvent value to a byte slice. 6070 func (v UnmapNotifyEvent) Bytes() []byte { 6071 buf := make([]byte, 32) 6072 b := 0 6073 6074 // write event number 6075 buf[b] = 18 6076 b += 1 6077 6078 b += 1 // padding 6079 6080 b += 2 // skip sequence number 6081 6082 xgb.Put32(buf[b:], uint32(v.Event)) 6083 b += 4 6084 6085 xgb.Put32(buf[b:], uint32(v.Window)) 6086 b += 4 6087 6088 if v.FromConfigure { 6089 buf[b] = 1 6090 } else { 6091 buf[b] = 0 6092 } 6093 b += 1 6094 6095 b += 3 // padding 6096 6097 return buf 6098 } 6099 6100 // SequenceId returns the sequence id attached to the UnmapNotify event. 6101 // Events without a sequence number (KeymapNotify) return 0. 6102 // This is mostly used internally. 6103 func (v UnmapNotifyEvent) SequenceId() uint16 { 6104 return v.Sequence 6105 } 6106 6107 // String is a rudimentary string representation of UnmapNotifyEvent. 6108 func (v UnmapNotifyEvent) String() string { 6109 fieldVals := make([]string, 0, 5) 6110 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 6111 fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) 6112 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 6113 fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) 6114 return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 6115 } 6116 6117 func init() { 6118 xgb.NewEventFuncs[18] = UnmapNotifyEventNew 6119 } 6120 6121 // BadValue is the error number for a BadValue. 6122 const BadValue = 2 6123 6124 type ValueError struct { 6125 Sequence uint16 6126 NiceName string 6127 BadValue uint32 6128 MinorOpcode uint16 6129 MajorOpcode byte 6130 // padding: 1 bytes 6131 } 6132 6133 // ValueErrorNew constructs a ValueError value that implements xgb.Error from a byte slice. 6134 func ValueErrorNew(buf []byte) xgb.Error { 6135 v := ValueError{} 6136 v.NiceName = "Value" 6137 6138 b := 1 // skip error determinant 6139 b += 1 // don't read error number 6140 6141 v.Sequence = xgb.Get16(buf[b:]) 6142 b += 2 6143 6144 v.BadValue = xgb.Get32(buf[b:]) 6145 b += 4 6146 6147 v.MinorOpcode = xgb.Get16(buf[b:]) 6148 b += 2 6149 6150 v.MajorOpcode = buf[b] 6151 b += 1 6152 6153 b += 1 // padding 6154 6155 return v 6156 } 6157 6158 // SequenceId returns the sequence id attached to the BadValue error. 6159 // This is mostly used internally. 6160 func (err ValueError) SequenceId() uint16 { 6161 return err.Sequence 6162 } 6163 6164 // BadId returns the 'BadValue' number if one exists for the BadValue error. If no bad value exists, 0 is returned. 6165 func (err ValueError) BadId() uint32 { 6166 return err.BadValue 6167 } 6168 6169 // Error returns a rudimentary string representation of the BadValue error. 6170 6171 func (err ValueError) Error() string { 6172 fieldVals := make([]string, 0, 4) 6173 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 6174 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 6175 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 6176 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 6177 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 6178 return "BadValue {" + xgb.StringsJoin(fieldVals, ", ") + "}" 6179 } 6180 6181 func init() { 6182 xgb.NewErrorFuncs[2] = ValueErrorNew 6183 } 6184 6185 const ( 6186 VisibilityUnobscured = 0 6187 VisibilityPartiallyObscured = 1 6188 VisibilityFullyObscured = 2 6189 ) 6190 6191 // VisibilityNotify is the event number for a VisibilityNotifyEvent. 6192 const VisibilityNotify = 15 6193 6194 type VisibilityNotifyEvent struct { 6195 Sequence uint16 6196 // padding: 1 bytes 6197 Window Window 6198 State byte 6199 // padding: 3 bytes 6200 } 6201 6202 // VisibilityNotifyEventNew constructs a VisibilityNotifyEvent value that implements xgb.Event from a byte slice. 6203 func VisibilityNotifyEventNew(buf []byte) xgb.Event { 6204 v := VisibilityNotifyEvent{} 6205 b := 1 // don't read event number 6206 6207 b += 1 // padding 6208 6209 v.Sequence = xgb.Get16(buf[b:]) 6210 b += 2 6211 6212 v.Window = Window(xgb.Get32(buf[b:])) 6213 b += 4 6214 6215 v.State = buf[b] 6216 b += 1 6217 6218 b += 3 // padding 6219 6220 return v 6221 } 6222 6223 // Bytes writes a VisibilityNotifyEvent value to a byte slice. 6224 func (v VisibilityNotifyEvent) Bytes() []byte { 6225 buf := make([]byte, 32) 6226 b := 0 6227 6228 // write event number 6229 buf[b] = 15 6230 b += 1 6231 6232 b += 1 // padding 6233 6234 b += 2 // skip sequence number 6235 6236 xgb.Put32(buf[b:], uint32(v.Window)) 6237 b += 4 6238 6239 buf[b] = v.State 6240 b += 1 6241 6242 b += 3 // padding 6243 6244 return buf 6245 } 6246 6247 // SequenceId returns the sequence id attached to the VisibilityNotify event. 6248 // Events without a sequence number (KeymapNotify) return 0. 6249 // This is mostly used internally. 6250 func (v VisibilityNotifyEvent) SequenceId() uint16 { 6251 return v.Sequence 6252 } 6253 6254 // String is a rudimentary string representation of VisibilityNotifyEvent. 6255 func (v VisibilityNotifyEvent) String() string { 6256 fieldVals := make([]string, 0, 4) 6257 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) 6258 fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) 6259 fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) 6260 return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" 6261 } 6262 6263 func init() { 6264 xgb.NewEventFuncs[15] = VisibilityNotifyEventNew 6265 } 6266 6267 const ( 6268 VisualClassStaticGray = 0 6269 VisualClassGrayScale = 1 6270 VisualClassStaticColor = 2 6271 VisualClassPseudoColor = 3 6272 VisualClassTrueColor = 4 6273 VisualClassDirectColor = 5 6274 ) 6275 6276 type VisualInfo struct { 6277 VisualId Visualid 6278 Class byte 6279 BitsPerRgbValue byte 6280 ColormapEntries uint16 6281 RedMask uint32 6282 GreenMask uint32 6283 BlueMask uint32 6284 // padding: 4 bytes 6285 } 6286 6287 // VisualInfoRead reads a byte slice into a VisualInfo value. 6288 func VisualInfoRead(buf []byte, v *VisualInfo) int { 6289 b := 0 6290 6291 v.VisualId = Visualid(xgb.Get32(buf[b:])) 6292 b += 4 6293 6294 v.Class = buf[b] 6295 b += 1 6296 6297 v.BitsPerRgbValue = buf[b] 6298 b += 1 6299 6300 v.ColormapEntries = xgb.Get16(buf[b:]) 6301 b += 2 6302 6303 v.RedMask = xgb.Get32(buf[b:]) 6304 b += 4 6305 6306 v.GreenMask = xgb.Get32(buf[b:]) 6307 b += 4 6308 6309 v.BlueMask = xgb.Get32(buf[b:]) 6310 b += 4 6311 6312 b += 4 // padding 6313 6314 return b 6315 } 6316 6317 // VisualInfoReadList reads a byte slice into a list of VisualInfo values. 6318 func VisualInfoReadList(buf []byte, dest []VisualInfo) int { 6319 b := 0 6320 for i := 0; i < len(dest); i++ { 6321 dest[i] = VisualInfo{} 6322 b += VisualInfoRead(buf[b:], &dest[i]) 6323 } 6324 return xgb.Pad(b) 6325 } 6326 6327 // Bytes writes a VisualInfo value to a byte slice. 6328 func (v VisualInfo) Bytes() []byte { 6329 buf := make([]byte, 24) 6330 b := 0 6331 6332 xgb.Put32(buf[b:], uint32(v.VisualId)) 6333 b += 4 6334 6335 buf[b] = v.Class 6336 b += 1 6337 6338 buf[b] = v.BitsPerRgbValue 6339 b += 1 6340 6341 xgb.Put16(buf[b:], v.ColormapEntries) 6342 b += 2 6343 6344 xgb.Put32(buf[b:], v.RedMask) 6345 b += 4 6346 6347 xgb.Put32(buf[b:], v.GreenMask) 6348 b += 4 6349 6350 xgb.Put32(buf[b:], v.BlueMask) 6351 b += 4 6352 6353 b += 4 // padding 6354 6355 return buf[:b] 6356 } 6357 6358 // VisualInfoListBytes writes a list of VisualInfo values to a byte slice. 6359 func VisualInfoListBytes(buf []byte, list []VisualInfo) int { 6360 b := 0 6361 var structBytes []byte 6362 for _, item := range list { 6363 structBytes = item.Bytes() 6364 copy(buf[b:], structBytes) 6365 b += len(structBytes) 6366 } 6367 return xgb.Pad(b) 6368 } 6369 6370 type Visualid uint32 6371 6372 type Window uint32 6373 6374 func NewWindowId(c *xgb.Conn) (Window, error) { 6375 id, err := c.NewId() 6376 if err != nil { 6377 return 0, err 6378 } 6379 return Window(id), nil 6380 } 6381 6382 // BadWindow is the error number for a BadWindow. 6383 const BadWindow = 3 6384 6385 type WindowError ValueError 6386 6387 // WindowErrorNew constructs a WindowError value that implements xgb.Error from a byte slice. 6388 func WindowErrorNew(buf []byte) xgb.Error { 6389 v := WindowError(ValueErrorNew(buf).(ValueError)) 6390 v.NiceName = "Window" 6391 return v 6392 } 6393 6394 // SequenceId returns the sequence id attached to the BadWindow error. 6395 // This is mostly used internally. 6396 func (err WindowError) SequenceId() uint16 { 6397 return err.Sequence 6398 } 6399 6400 // BadId returns the 'BadValue' number if one exists for the BadWindow error. If no bad value exists, 0 is returned. 6401 func (err WindowError) BadId() uint32 { 6402 return err.BadValue 6403 } 6404 6405 // Error returns a rudimentary string representation of the BadWindow error. 6406 func (err WindowError) Error() string { 6407 fieldVals := make([]string, 0, 4) 6408 fieldVals = append(fieldVals, "NiceName: "+err.NiceName) 6409 fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) 6410 fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) 6411 fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) 6412 fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) 6413 return "BadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" 6414 } 6415 6416 func init() { 6417 xgb.NewErrorFuncs[3] = WindowErrorNew 6418 } 6419 6420 const ( 6421 WindowNone = 0 6422 ) 6423 6424 const ( 6425 WindowClassCopyFromParent = 0 6426 WindowClassInputOutput = 1 6427 WindowClassInputOnly = 2 6428 ) 6429 6430 // Skipping definition for base type 'Bool' 6431 6432 // Skipping definition for base type 'Byte' 6433 6434 // Skipping definition for base type 'Card8' 6435 6436 // Skipping definition for base type 'Char' 6437 6438 // Skipping definition for base type 'Void' 6439 6440 // Skipping definition for base type 'Double' 6441 6442 // Skipping definition for base type 'Float' 6443 6444 // Skipping definition for base type 'Int16' 6445 6446 // Skipping definition for base type 'Int32' 6447 6448 // Skipping definition for base type 'Int8' 6449 6450 // Skipping definition for base type 'Card16' 6451 6452 // Skipping definition for base type 'Card32' 6453 6454 // AllocColorCookie is a cookie used only for AllocColor requests. 6455 type AllocColorCookie struct { 6456 *xgb.Cookie 6457 } 6458 6459 // AllocColor sends a checked request. 6460 // If an error occurs, it will be returned with the reply by calling AllocColorCookie.Reply() 6461 func AllocColor(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { 6462 cookie := c.NewCookie(true, true) 6463 c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) 6464 return AllocColorCookie{cookie} 6465 } 6466 6467 // AllocColorUnchecked sends an unchecked request. 6468 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 6469 func AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { 6470 cookie := c.NewCookie(false, true) 6471 c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) 6472 return AllocColorCookie{cookie} 6473 } 6474 6475 // AllocColorReply represents the data returned from a AllocColor request. 6476 type AllocColorReply struct { 6477 Sequence uint16 // sequence number of the request for this reply 6478 Length uint32 // number of bytes in this reply 6479 // padding: 1 bytes 6480 Red uint16 6481 Green uint16 6482 Blue uint16 6483 // padding: 2 bytes 6484 Pixel uint32 6485 } 6486 6487 // Reply blocks and returns the reply data for a AllocColor request. 6488 func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { 6489 buf, err := cook.Cookie.Reply() 6490 if err != nil { 6491 return nil, err 6492 } 6493 if buf == nil { 6494 return nil, nil 6495 } 6496 return allocColorReply(buf), nil 6497 } 6498 6499 // allocColorReply reads a byte slice into a AllocColorReply value. 6500 func allocColorReply(buf []byte) *AllocColorReply { 6501 v := new(AllocColorReply) 6502 b := 1 // skip reply determinant 6503 6504 b += 1 // padding 6505 6506 v.Sequence = xgb.Get16(buf[b:]) 6507 b += 2 6508 6509 v.Length = xgb.Get32(buf[b:]) // 4-byte units 6510 b += 4 6511 6512 v.Red = xgb.Get16(buf[b:]) 6513 b += 2 6514 6515 v.Green = xgb.Get16(buf[b:]) 6516 b += 2 6517 6518 v.Blue = xgb.Get16(buf[b:]) 6519 b += 2 6520 6521 b += 2 // padding 6522 6523 v.Pixel = xgb.Get32(buf[b:]) 6524 b += 4 6525 6526 return v 6527 } 6528 6529 // Write request to wire for AllocColor 6530 // allocColorRequest writes a AllocColor request to a byte slice. 6531 func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { 6532 size := 16 6533 b := 0 6534 buf := make([]byte, size) 6535 6536 buf[b] = 84 // request opcode 6537 b += 1 6538 6539 b += 1 // padding 6540 6541 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 6542 b += 2 6543 6544 xgb.Put32(buf[b:], uint32(Cmap)) 6545 b += 4 6546 6547 xgb.Put16(buf[b:], Red) 6548 b += 2 6549 6550 xgb.Put16(buf[b:], Green) 6551 b += 2 6552 6553 xgb.Put16(buf[b:], Blue) 6554 b += 2 6555 6556 b += 2 // padding 6557 6558 return buf 6559 } 6560 6561 // AllocColorCellsCookie is a cookie used only for AllocColorCells requests. 6562 type AllocColorCellsCookie struct { 6563 *xgb.Cookie 6564 } 6565 6566 // AllocColorCells sends a checked request. 6567 // If an error occurs, it will be returned with the reply by calling AllocColorCellsCookie.Reply() 6568 func AllocColorCells(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { 6569 cookie := c.NewCookie(true, true) 6570 c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) 6571 return AllocColorCellsCookie{cookie} 6572 } 6573 6574 // AllocColorCellsUnchecked sends an unchecked request. 6575 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 6576 func AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { 6577 cookie := c.NewCookie(false, true) 6578 c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) 6579 return AllocColorCellsCookie{cookie} 6580 } 6581 6582 // AllocColorCellsReply represents the data returned from a AllocColorCells request. 6583 type AllocColorCellsReply struct { 6584 Sequence uint16 // sequence number of the request for this reply 6585 Length uint32 // number of bytes in this reply 6586 // padding: 1 bytes 6587 PixelsLen uint16 6588 MasksLen uint16 6589 // padding: 20 bytes 6590 Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) 6591 // alignment gap to multiple of 4 6592 Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) 6593 } 6594 6595 // Reply blocks and returns the reply data for a AllocColorCells request. 6596 func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { 6597 buf, err := cook.Cookie.Reply() 6598 if err != nil { 6599 return nil, err 6600 } 6601 if buf == nil { 6602 return nil, nil 6603 } 6604 return allocColorCellsReply(buf), nil 6605 } 6606 6607 // allocColorCellsReply reads a byte slice into a AllocColorCellsReply value. 6608 func allocColorCellsReply(buf []byte) *AllocColorCellsReply { 6609 v := new(AllocColorCellsReply) 6610 b := 1 // skip reply determinant 6611 6612 b += 1 // padding 6613 6614 v.Sequence = xgb.Get16(buf[b:]) 6615 b += 2 6616 6617 v.Length = xgb.Get32(buf[b:]) // 4-byte units 6618 b += 4 6619 6620 v.PixelsLen = xgb.Get16(buf[b:]) 6621 b += 2 6622 6623 v.MasksLen = xgb.Get16(buf[b:]) 6624 b += 2 6625 6626 b += 20 // padding 6627 6628 v.Pixels = make([]uint32, v.PixelsLen) 6629 for i := 0; i < int(v.PixelsLen); i++ { 6630 v.Pixels[i] = xgb.Get32(buf[b:]) 6631 b += 4 6632 } 6633 6634 b = (b + 3) & ^3 // alignment gap 6635 6636 v.Masks = make([]uint32, v.MasksLen) 6637 for i := 0; i < int(v.MasksLen); i++ { 6638 v.Masks[i] = xgb.Get32(buf[b:]) 6639 b += 4 6640 } 6641 6642 return v 6643 } 6644 6645 // Write request to wire for AllocColorCells 6646 // allocColorCellsRequest writes a AllocColorCells request to a byte slice. 6647 func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { 6648 size := 12 6649 b := 0 6650 buf := make([]byte, size) 6651 6652 buf[b] = 86 // request opcode 6653 b += 1 6654 6655 if Contiguous { 6656 buf[b] = 1 6657 } else { 6658 buf[b] = 0 6659 } 6660 b += 1 6661 6662 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 6663 b += 2 6664 6665 xgb.Put32(buf[b:], uint32(Cmap)) 6666 b += 4 6667 6668 xgb.Put16(buf[b:], Colors) 6669 b += 2 6670 6671 xgb.Put16(buf[b:], Planes) 6672 b += 2 6673 6674 return buf 6675 } 6676 6677 // AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. 6678 type AllocColorPlanesCookie struct { 6679 *xgb.Cookie 6680 } 6681 6682 // AllocColorPlanes sends a checked request. 6683 // If an error occurs, it will be returned with the reply by calling AllocColorPlanesCookie.Reply() 6684 func AllocColorPlanes(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { 6685 cookie := c.NewCookie(true, true) 6686 c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) 6687 return AllocColorPlanesCookie{cookie} 6688 } 6689 6690 // AllocColorPlanesUnchecked sends an unchecked request. 6691 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 6692 func AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { 6693 cookie := c.NewCookie(false, true) 6694 c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) 6695 return AllocColorPlanesCookie{cookie} 6696 } 6697 6698 // AllocColorPlanesReply represents the data returned from a AllocColorPlanes request. 6699 type AllocColorPlanesReply struct { 6700 Sequence uint16 // sequence number of the request for this reply 6701 Length uint32 // number of bytes in this reply 6702 // padding: 1 bytes 6703 PixelsLen uint16 6704 // padding: 2 bytes 6705 RedMask uint32 6706 GreenMask uint32 6707 BlueMask uint32 6708 // padding: 8 bytes 6709 Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) 6710 } 6711 6712 // Reply blocks and returns the reply data for a AllocColorPlanes request. 6713 func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { 6714 buf, err := cook.Cookie.Reply() 6715 if err != nil { 6716 return nil, err 6717 } 6718 if buf == nil { 6719 return nil, nil 6720 } 6721 return allocColorPlanesReply(buf), nil 6722 } 6723 6724 // allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. 6725 func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { 6726 v := new(AllocColorPlanesReply) 6727 b := 1 // skip reply determinant 6728 6729 b += 1 // padding 6730 6731 v.Sequence = xgb.Get16(buf[b:]) 6732 b += 2 6733 6734 v.Length = xgb.Get32(buf[b:]) // 4-byte units 6735 b += 4 6736 6737 v.PixelsLen = xgb.Get16(buf[b:]) 6738 b += 2 6739 6740 b += 2 // padding 6741 6742 v.RedMask = xgb.Get32(buf[b:]) 6743 b += 4 6744 6745 v.GreenMask = xgb.Get32(buf[b:]) 6746 b += 4 6747 6748 v.BlueMask = xgb.Get32(buf[b:]) 6749 b += 4 6750 6751 b += 8 // padding 6752 6753 v.Pixels = make([]uint32, v.PixelsLen) 6754 for i := 0; i < int(v.PixelsLen); i++ { 6755 v.Pixels[i] = xgb.Get32(buf[b:]) 6756 b += 4 6757 } 6758 6759 return v 6760 } 6761 6762 // Write request to wire for AllocColorPlanes 6763 // allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice. 6764 func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { 6765 size := 16 6766 b := 0 6767 buf := make([]byte, size) 6768 6769 buf[b] = 87 // request opcode 6770 b += 1 6771 6772 if Contiguous { 6773 buf[b] = 1 6774 } else { 6775 buf[b] = 0 6776 } 6777 b += 1 6778 6779 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 6780 b += 2 6781 6782 xgb.Put32(buf[b:], uint32(Cmap)) 6783 b += 4 6784 6785 xgb.Put16(buf[b:], Colors) 6786 b += 2 6787 6788 xgb.Put16(buf[b:], Reds) 6789 b += 2 6790 6791 xgb.Put16(buf[b:], Greens) 6792 b += 2 6793 6794 xgb.Put16(buf[b:], Blues) 6795 b += 2 6796 6797 return buf 6798 } 6799 6800 // AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. 6801 type AllocNamedColorCookie struct { 6802 *xgb.Cookie 6803 } 6804 6805 // AllocNamedColor sends a checked request. 6806 // If an error occurs, it will be returned with the reply by calling AllocNamedColorCookie.Reply() 6807 func AllocNamedColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { 6808 cookie := c.NewCookie(true, true) 6809 c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) 6810 return AllocNamedColorCookie{cookie} 6811 } 6812 6813 // AllocNamedColorUnchecked sends an unchecked request. 6814 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 6815 func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { 6816 cookie := c.NewCookie(false, true) 6817 c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) 6818 return AllocNamedColorCookie{cookie} 6819 } 6820 6821 // AllocNamedColorReply represents the data returned from a AllocNamedColor request. 6822 type AllocNamedColorReply struct { 6823 Sequence uint16 // sequence number of the request for this reply 6824 Length uint32 // number of bytes in this reply 6825 // padding: 1 bytes 6826 Pixel uint32 6827 ExactRed uint16 6828 ExactGreen uint16 6829 ExactBlue uint16 6830 VisualRed uint16 6831 VisualGreen uint16 6832 VisualBlue uint16 6833 } 6834 6835 // Reply blocks and returns the reply data for a AllocNamedColor request. 6836 func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { 6837 buf, err := cook.Cookie.Reply() 6838 if err != nil { 6839 return nil, err 6840 } 6841 if buf == nil { 6842 return nil, nil 6843 } 6844 return allocNamedColorReply(buf), nil 6845 } 6846 6847 // allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. 6848 func allocNamedColorReply(buf []byte) *AllocNamedColorReply { 6849 v := new(AllocNamedColorReply) 6850 b := 1 // skip reply determinant 6851 6852 b += 1 // padding 6853 6854 v.Sequence = xgb.Get16(buf[b:]) 6855 b += 2 6856 6857 v.Length = xgb.Get32(buf[b:]) // 4-byte units 6858 b += 4 6859 6860 v.Pixel = xgb.Get32(buf[b:]) 6861 b += 4 6862 6863 v.ExactRed = xgb.Get16(buf[b:]) 6864 b += 2 6865 6866 v.ExactGreen = xgb.Get16(buf[b:]) 6867 b += 2 6868 6869 v.ExactBlue = xgb.Get16(buf[b:]) 6870 b += 2 6871 6872 v.VisualRed = xgb.Get16(buf[b:]) 6873 b += 2 6874 6875 v.VisualGreen = xgb.Get16(buf[b:]) 6876 b += 2 6877 6878 v.VisualBlue = xgb.Get16(buf[b:]) 6879 b += 2 6880 6881 return v 6882 } 6883 6884 // Write request to wire for AllocNamedColor 6885 // allocNamedColorRequest writes a AllocNamedColor request to a byte slice. 6886 func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { 6887 size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) 6888 b := 0 6889 buf := make([]byte, size) 6890 6891 buf[b] = 85 // request opcode 6892 b += 1 6893 6894 b += 1 // padding 6895 6896 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 6897 b += 2 6898 6899 xgb.Put32(buf[b:], uint32(Cmap)) 6900 b += 4 6901 6902 xgb.Put16(buf[b:], NameLen) 6903 b += 2 6904 6905 b += 2 // padding 6906 6907 copy(buf[b:], Name[:NameLen]) 6908 b += int(NameLen) 6909 6910 return buf 6911 } 6912 6913 // AllowEventsCookie is a cookie used only for AllowEvents requests. 6914 type AllowEventsCookie struct { 6915 *xgb.Cookie 6916 } 6917 6918 // AllowEvents sends an unchecked request. 6919 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 6920 func AllowEvents(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { 6921 cookie := c.NewCookie(false, false) 6922 c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) 6923 return AllowEventsCookie{cookie} 6924 } 6925 6926 // AllowEventsChecked sends a checked request. 6927 // If an error occurs, it can be retrieved using AllowEventsCookie.Check() 6928 func AllowEventsChecked(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { 6929 cookie := c.NewCookie(true, false) 6930 c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) 6931 return AllowEventsCookie{cookie} 6932 } 6933 6934 // Check returns an error if one occurred for checked requests that are not expecting a reply. 6935 // This cannot be called for requests expecting a reply, nor for unchecked requests. 6936 func (cook AllowEventsCookie) Check() error { 6937 return cook.Cookie.Check() 6938 } 6939 6940 // Write request to wire for AllowEvents 6941 // allowEventsRequest writes a AllowEvents request to a byte slice. 6942 func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { 6943 size := 8 6944 b := 0 6945 buf := make([]byte, size) 6946 6947 buf[b] = 35 // request opcode 6948 b += 1 6949 6950 buf[b] = Mode 6951 b += 1 6952 6953 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 6954 b += 2 6955 6956 xgb.Put32(buf[b:], uint32(Time)) 6957 b += 4 6958 6959 return buf 6960 } 6961 6962 // BellCookie is a cookie used only for Bell requests. 6963 type BellCookie struct { 6964 *xgb.Cookie 6965 } 6966 6967 // Bell sends an unchecked request. 6968 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 6969 func Bell(c *xgb.Conn, Percent int8) BellCookie { 6970 cookie := c.NewCookie(false, false) 6971 c.NewRequest(bellRequest(c, Percent), cookie) 6972 return BellCookie{cookie} 6973 } 6974 6975 // BellChecked sends a checked request. 6976 // If an error occurs, it can be retrieved using BellCookie.Check() 6977 func BellChecked(c *xgb.Conn, Percent int8) BellCookie { 6978 cookie := c.NewCookie(true, false) 6979 c.NewRequest(bellRequest(c, Percent), cookie) 6980 return BellCookie{cookie} 6981 } 6982 6983 // Check returns an error if one occurred for checked requests that are not expecting a reply. 6984 // This cannot be called for requests expecting a reply, nor for unchecked requests. 6985 func (cook BellCookie) Check() error { 6986 return cook.Cookie.Check() 6987 } 6988 6989 // Write request to wire for Bell 6990 // bellRequest writes a Bell request to a byte slice. 6991 func bellRequest(c *xgb.Conn, Percent int8) []byte { 6992 size := 4 6993 b := 0 6994 buf := make([]byte, size) 6995 6996 buf[b] = 104 // request opcode 6997 b += 1 6998 6999 buf[b] = byte(Percent) 7000 b += 1 7001 7002 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7003 b += 2 7004 7005 return buf 7006 } 7007 7008 // ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. 7009 type ChangeActivePointerGrabCookie struct { 7010 *xgb.Cookie 7011 } 7012 7013 // ChangeActivePointerGrab sends an unchecked request. 7014 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7015 func ChangeActivePointerGrab(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { 7016 cookie := c.NewCookie(false, false) 7017 c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) 7018 return ChangeActivePointerGrabCookie{cookie} 7019 } 7020 7021 // ChangeActivePointerGrabChecked sends a checked request. 7022 // If an error occurs, it can be retrieved using ChangeActivePointerGrabCookie.Check() 7023 func ChangeActivePointerGrabChecked(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { 7024 cookie := c.NewCookie(true, false) 7025 c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) 7026 return ChangeActivePointerGrabCookie{cookie} 7027 } 7028 7029 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7030 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7031 func (cook ChangeActivePointerGrabCookie) Check() error { 7032 return cook.Cookie.Check() 7033 } 7034 7035 // Write request to wire for ChangeActivePointerGrab 7036 // changeActivePointerGrabRequest writes a ChangeActivePointerGrab request to a byte slice. 7037 func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte { 7038 size := 16 7039 b := 0 7040 buf := make([]byte, size) 7041 7042 buf[b] = 30 // request opcode 7043 b += 1 7044 7045 b += 1 // padding 7046 7047 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7048 b += 2 7049 7050 xgb.Put32(buf[b:], uint32(Cursor)) 7051 b += 4 7052 7053 xgb.Put32(buf[b:], uint32(Time)) 7054 b += 4 7055 7056 xgb.Put16(buf[b:], EventMask) 7057 b += 2 7058 7059 b += 2 // padding 7060 7061 return buf 7062 } 7063 7064 // ChangeGCCookie is a cookie used only for ChangeGC requests. 7065 type ChangeGCCookie struct { 7066 *xgb.Cookie 7067 } 7068 7069 // ChangeGC sends an unchecked request. 7070 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7071 func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { 7072 cookie := c.NewCookie(false, false) 7073 c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) 7074 return ChangeGCCookie{cookie} 7075 } 7076 7077 // ChangeGCChecked sends a checked request. 7078 // If an error occurs, it can be retrieved using ChangeGCCookie.Check() 7079 func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { 7080 cookie := c.NewCookie(true, false) 7081 c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) 7082 return ChangeGCCookie{cookie} 7083 } 7084 7085 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7086 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7087 func (cook ChangeGCCookie) Check() error { 7088 return cook.Cookie.Check() 7089 } 7090 7091 // Write request to wire for ChangeGC 7092 // changeGCRequest writes a ChangeGC request to a byte slice. 7093 func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { 7094 size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) 7095 b := 0 7096 buf := make([]byte, size) 7097 7098 buf[b] = 56 // request opcode 7099 b += 1 7100 7101 b += 1 // padding 7102 7103 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7104 b += 2 7105 7106 xgb.Put32(buf[b:], uint32(Gc)) 7107 b += 4 7108 7109 xgb.Put32(buf[b:], ValueMask) 7110 b += 4 7111 for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { 7112 xgb.Put32(buf[b:], ValueList[i]) 7113 b += 4 7114 } 7115 b = xgb.Pad(b) 7116 7117 return buf 7118 } 7119 7120 // ChangeHostsCookie is a cookie used only for ChangeHosts requests. 7121 type ChangeHostsCookie struct { 7122 *xgb.Cookie 7123 } 7124 7125 // ChangeHosts sends an unchecked request. 7126 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7127 func ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { 7128 cookie := c.NewCookie(false, false) 7129 c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) 7130 return ChangeHostsCookie{cookie} 7131 } 7132 7133 // ChangeHostsChecked sends a checked request. 7134 // If an error occurs, it can be retrieved using ChangeHostsCookie.Check() 7135 func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { 7136 cookie := c.NewCookie(true, false) 7137 c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) 7138 return ChangeHostsCookie{cookie} 7139 } 7140 7141 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7142 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7143 func (cook ChangeHostsCookie) Check() error { 7144 return cook.Cookie.Check() 7145 } 7146 7147 // Write request to wire for ChangeHosts 7148 // changeHostsRequest writes a ChangeHosts request to a byte slice. 7149 func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { 7150 size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) 7151 b := 0 7152 buf := make([]byte, size) 7153 7154 buf[b] = 109 // request opcode 7155 b += 1 7156 7157 buf[b] = Mode 7158 b += 1 7159 7160 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7161 b += 2 7162 7163 buf[b] = Family 7164 b += 1 7165 7166 b += 1 // padding 7167 7168 xgb.Put16(buf[b:], AddressLen) 7169 b += 2 7170 7171 copy(buf[b:], Address[:AddressLen]) 7172 b += int(AddressLen) 7173 7174 return buf 7175 } 7176 7177 // ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. 7178 type ChangeKeyboardControlCookie struct { 7179 *xgb.Cookie 7180 } 7181 7182 // ChangeKeyboardControl sends an unchecked request. 7183 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7184 func ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { 7185 cookie := c.NewCookie(false, false) 7186 c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) 7187 return ChangeKeyboardControlCookie{cookie} 7188 } 7189 7190 // ChangeKeyboardControlChecked sends a checked request. 7191 // If an error occurs, it can be retrieved using ChangeKeyboardControlCookie.Check() 7192 func ChangeKeyboardControlChecked(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { 7193 cookie := c.NewCookie(true, false) 7194 c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) 7195 return ChangeKeyboardControlCookie{cookie} 7196 } 7197 7198 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7199 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7200 func (cook ChangeKeyboardControlCookie) Check() error { 7201 return cook.Cookie.Check() 7202 } 7203 7204 // Write request to wire for ChangeKeyboardControl 7205 // changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice. 7206 func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { 7207 size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) 7208 b := 0 7209 buf := make([]byte, size) 7210 7211 buf[b] = 102 // request opcode 7212 b += 1 7213 7214 b += 1 // padding 7215 7216 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7217 b += 2 7218 7219 xgb.Put32(buf[b:], ValueMask) 7220 b += 4 7221 for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { 7222 xgb.Put32(buf[b:], ValueList[i]) 7223 b += 4 7224 } 7225 b = xgb.Pad(b) 7226 7227 return buf 7228 } 7229 7230 // ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. 7231 type ChangeKeyboardMappingCookie struct { 7232 *xgb.Cookie 7233 } 7234 7235 // ChangeKeyboardMapping sends an unchecked request. 7236 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7237 func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { 7238 cookie := c.NewCookie(false, false) 7239 c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) 7240 return ChangeKeyboardMappingCookie{cookie} 7241 } 7242 7243 // ChangeKeyboardMappingChecked sends a checked request. 7244 // If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check() 7245 func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { 7246 cookie := c.NewCookie(true, false) 7247 c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) 7248 return ChangeKeyboardMappingCookie{cookie} 7249 } 7250 7251 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7252 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7253 func (cook ChangeKeyboardMappingCookie) Check() error { 7254 return cook.Cookie.Check() 7255 } 7256 7257 // Write request to wire for ChangeKeyboardMapping 7258 // changeKeyboardMappingRequest writes a ChangeKeyboardMapping request to a byte slice. 7259 func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { 7260 size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) 7261 b := 0 7262 buf := make([]byte, size) 7263 7264 buf[b] = 100 // request opcode 7265 b += 1 7266 7267 buf[b] = KeycodeCount 7268 b += 1 7269 7270 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7271 b += 2 7272 7273 buf[b] = byte(FirstKeycode) 7274 b += 1 7275 7276 buf[b] = KeysymsPerKeycode 7277 b += 1 7278 7279 b += 2 // padding 7280 7281 for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { 7282 xgb.Put32(buf[b:], uint32(Keysyms[i])) 7283 b += 4 7284 } 7285 7286 return buf 7287 } 7288 7289 // ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. 7290 type ChangePointerControlCookie struct { 7291 *xgb.Cookie 7292 } 7293 7294 // ChangePointerControl sends an unchecked request. 7295 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7296 func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { 7297 cookie := c.NewCookie(false, false) 7298 c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) 7299 return ChangePointerControlCookie{cookie} 7300 } 7301 7302 // ChangePointerControlChecked sends a checked request. 7303 // If an error occurs, it can be retrieved using ChangePointerControlCookie.Check() 7304 func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { 7305 cookie := c.NewCookie(true, false) 7306 c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) 7307 return ChangePointerControlCookie{cookie} 7308 } 7309 7310 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7311 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7312 func (cook ChangePointerControlCookie) Check() error { 7313 return cook.Cookie.Check() 7314 } 7315 7316 // Write request to wire for ChangePointerControl 7317 // changePointerControlRequest writes a ChangePointerControl request to a byte slice. 7318 func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { 7319 size := 12 7320 b := 0 7321 buf := make([]byte, size) 7322 7323 buf[b] = 105 // request opcode 7324 b += 1 7325 7326 b += 1 // padding 7327 7328 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7329 b += 2 7330 7331 xgb.Put16(buf[b:], uint16(AccelerationNumerator)) 7332 b += 2 7333 7334 xgb.Put16(buf[b:], uint16(AccelerationDenominator)) 7335 b += 2 7336 7337 xgb.Put16(buf[b:], uint16(Threshold)) 7338 b += 2 7339 7340 if DoAcceleration { 7341 buf[b] = 1 7342 } else { 7343 buf[b] = 0 7344 } 7345 b += 1 7346 7347 if DoThreshold { 7348 buf[b] = 1 7349 } else { 7350 buf[b] = 0 7351 } 7352 b += 1 7353 7354 return buf 7355 } 7356 7357 // ChangePropertyCookie is a cookie used only for ChangeProperty requests. 7358 type ChangePropertyCookie struct { 7359 *xgb.Cookie 7360 } 7361 7362 // ChangeProperty sends an unchecked request. 7363 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7364 func ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { 7365 cookie := c.NewCookie(false, false) 7366 c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) 7367 return ChangePropertyCookie{cookie} 7368 } 7369 7370 // ChangePropertyChecked sends a checked request. 7371 // If an error occurs, it can be retrieved using ChangePropertyCookie.Check() 7372 func ChangePropertyChecked(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { 7373 cookie := c.NewCookie(true, false) 7374 c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) 7375 return ChangePropertyCookie{cookie} 7376 } 7377 7378 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7379 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7380 func (cook ChangePropertyCookie) Check() error { 7381 return cook.Cookie.Check() 7382 } 7383 7384 // Write request to wire for ChangeProperty 7385 // changePropertyRequest writes a ChangeProperty request to a byte slice. 7386 func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { 7387 size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) 7388 b := 0 7389 buf := make([]byte, size) 7390 7391 buf[b] = 18 // request opcode 7392 b += 1 7393 7394 buf[b] = Mode 7395 b += 1 7396 7397 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7398 b += 2 7399 7400 xgb.Put32(buf[b:], uint32(Window)) 7401 b += 4 7402 7403 xgb.Put32(buf[b:], uint32(Property)) 7404 b += 4 7405 7406 xgb.Put32(buf[b:], uint32(Type)) 7407 b += 4 7408 7409 buf[b] = Format 7410 b += 1 7411 7412 b += 3 // padding 7413 7414 xgb.Put32(buf[b:], DataLen) 7415 b += 4 7416 7417 copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) 7418 b += int(((int(DataLen) * int(Format)) / 8)) 7419 7420 return buf 7421 } 7422 7423 // ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. 7424 type ChangeSaveSetCookie struct { 7425 *xgb.Cookie 7426 } 7427 7428 // ChangeSaveSet sends an unchecked request. 7429 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7430 func ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { 7431 cookie := c.NewCookie(false, false) 7432 c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) 7433 return ChangeSaveSetCookie{cookie} 7434 } 7435 7436 // ChangeSaveSetChecked sends a checked request. 7437 // If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check() 7438 func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { 7439 cookie := c.NewCookie(true, false) 7440 c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) 7441 return ChangeSaveSetCookie{cookie} 7442 } 7443 7444 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7445 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7446 func (cook ChangeSaveSetCookie) Check() error { 7447 return cook.Cookie.Check() 7448 } 7449 7450 // Write request to wire for ChangeSaveSet 7451 // changeSaveSetRequest writes a ChangeSaveSet request to a byte slice. 7452 func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { 7453 size := 8 7454 b := 0 7455 buf := make([]byte, size) 7456 7457 buf[b] = 6 // request opcode 7458 b += 1 7459 7460 buf[b] = Mode 7461 b += 1 7462 7463 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7464 b += 2 7465 7466 xgb.Put32(buf[b:], uint32(Window)) 7467 b += 4 7468 7469 return buf 7470 } 7471 7472 // ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. 7473 type ChangeWindowAttributesCookie struct { 7474 *xgb.Cookie 7475 } 7476 7477 // ChangeWindowAttributes sends an unchecked request. 7478 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7479 func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { 7480 cookie := c.NewCookie(false, false) 7481 c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) 7482 return ChangeWindowAttributesCookie{cookie} 7483 } 7484 7485 // ChangeWindowAttributesChecked sends a checked request. 7486 // If an error occurs, it can be retrieved using ChangeWindowAttributesCookie.Check() 7487 func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { 7488 cookie := c.NewCookie(true, false) 7489 c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) 7490 return ChangeWindowAttributesCookie{cookie} 7491 } 7492 7493 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7494 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7495 func (cook ChangeWindowAttributesCookie) Check() error { 7496 return cook.Cookie.Check() 7497 } 7498 7499 // Write request to wire for ChangeWindowAttributes 7500 // changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice. 7501 func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { 7502 size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) 7503 b := 0 7504 buf := make([]byte, size) 7505 7506 buf[b] = 2 // request opcode 7507 b += 1 7508 7509 b += 1 // padding 7510 7511 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7512 b += 2 7513 7514 xgb.Put32(buf[b:], uint32(Window)) 7515 b += 4 7516 7517 xgb.Put32(buf[b:], ValueMask) 7518 b += 4 7519 for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { 7520 xgb.Put32(buf[b:], ValueList[i]) 7521 b += 4 7522 } 7523 b = xgb.Pad(b) 7524 7525 return buf 7526 } 7527 7528 // CirculateWindowCookie is a cookie used only for CirculateWindow requests. 7529 type CirculateWindowCookie struct { 7530 *xgb.Cookie 7531 } 7532 7533 // CirculateWindow sends an unchecked request. 7534 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7535 func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { 7536 cookie := c.NewCookie(false, false) 7537 c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) 7538 return CirculateWindowCookie{cookie} 7539 } 7540 7541 // CirculateWindowChecked sends a checked request. 7542 // If an error occurs, it can be retrieved using CirculateWindowCookie.Check() 7543 func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { 7544 cookie := c.NewCookie(true, false) 7545 c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) 7546 return CirculateWindowCookie{cookie} 7547 } 7548 7549 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7550 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7551 func (cook CirculateWindowCookie) Check() error { 7552 return cook.Cookie.Check() 7553 } 7554 7555 // Write request to wire for CirculateWindow 7556 // circulateWindowRequest writes a CirculateWindow request to a byte slice. 7557 func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { 7558 size := 8 7559 b := 0 7560 buf := make([]byte, size) 7561 7562 buf[b] = 13 // request opcode 7563 b += 1 7564 7565 buf[b] = Direction 7566 b += 1 7567 7568 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7569 b += 2 7570 7571 xgb.Put32(buf[b:], uint32(Window)) 7572 b += 4 7573 7574 return buf 7575 } 7576 7577 // ClearAreaCookie is a cookie used only for ClearArea requests. 7578 type ClearAreaCookie struct { 7579 *xgb.Cookie 7580 } 7581 7582 // ClearArea sends an unchecked request. 7583 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7584 func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { 7585 cookie := c.NewCookie(false, false) 7586 c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) 7587 return ClearAreaCookie{cookie} 7588 } 7589 7590 // ClearAreaChecked sends a checked request. 7591 // If an error occurs, it can be retrieved using ClearAreaCookie.Check() 7592 func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { 7593 cookie := c.NewCookie(true, false) 7594 c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) 7595 return ClearAreaCookie{cookie} 7596 } 7597 7598 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7599 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7600 func (cook ClearAreaCookie) Check() error { 7601 return cook.Cookie.Check() 7602 } 7603 7604 // Write request to wire for ClearArea 7605 // clearAreaRequest writes a ClearArea request to a byte slice. 7606 func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { 7607 size := 16 7608 b := 0 7609 buf := make([]byte, size) 7610 7611 buf[b] = 61 // request opcode 7612 b += 1 7613 7614 if Exposures { 7615 buf[b] = 1 7616 } else { 7617 buf[b] = 0 7618 } 7619 b += 1 7620 7621 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7622 b += 2 7623 7624 xgb.Put32(buf[b:], uint32(Window)) 7625 b += 4 7626 7627 xgb.Put16(buf[b:], uint16(X)) 7628 b += 2 7629 7630 xgb.Put16(buf[b:], uint16(Y)) 7631 b += 2 7632 7633 xgb.Put16(buf[b:], Width) 7634 b += 2 7635 7636 xgb.Put16(buf[b:], Height) 7637 b += 2 7638 7639 return buf 7640 } 7641 7642 // CloseFontCookie is a cookie used only for CloseFont requests. 7643 type CloseFontCookie struct { 7644 *xgb.Cookie 7645 } 7646 7647 // CloseFont sends an unchecked request. 7648 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7649 func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { 7650 cookie := c.NewCookie(false, false) 7651 c.NewRequest(closeFontRequest(c, Font), cookie) 7652 return CloseFontCookie{cookie} 7653 } 7654 7655 // CloseFontChecked sends a checked request. 7656 // If an error occurs, it can be retrieved using CloseFontCookie.Check() 7657 func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie { 7658 cookie := c.NewCookie(true, false) 7659 c.NewRequest(closeFontRequest(c, Font), cookie) 7660 return CloseFontCookie{cookie} 7661 } 7662 7663 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7664 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7665 func (cook CloseFontCookie) Check() error { 7666 return cook.Cookie.Check() 7667 } 7668 7669 // Write request to wire for CloseFont 7670 // closeFontRequest writes a CloseFont request to a byte slice. 7671 func closeFontRequest(c *xgb.Conn, Font Font) []byte { 7672 size := 8 7673 b := 0 7674 buf := make([]byte, size) 7675 7676 buf[b] = 46 // request opcode 7677 b += 1 7678 7679 b += 1 // padding 7680 7681 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7682 b += 2 7683 7684 xgb.Put32(buf[b:], uint32(Font)) 7685 b += 4 7686 7687 return buf 7688 } 7689 7690 // ConfigureWindowCookie is a cookie used only for ConfigureWindow requests. 7691 type ConfigureWindowCookie struct { 7692 *xgb.Cookie 7693 } 7694 7695 // ConfigureWindow sends an unchecked request. 7696 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7697 func ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { 7698 cookie := c.NewCookie(false, false) 7699 c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) 7700 return ConfigureWindowCookie{cookie} 7701 } 7702 7703 // ConfigureWindowChecked sends a checked request. 7704 // If an error occurs, it can be retrieved using ConfigureWindowCookie.Check() 7705 func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { 7706 cookie := c.NewCookie(true, false) 7707 c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) 7708 return ConfigureWindowCookie{cookie} 7709 } 7710 7711 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7712 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7713 func (cook ConfigureWindowCookie) Check() error { 7714 return cook.Cookie.Check() 7715 } 7716 7717 // Write request to wire for ConfigureWindow 7718 // configureWindowRequest writes a ConfigureWindow request to a byte slice. 7719 func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { 7720 size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) 7721 b := 0 7722 buf := make([]byte, size) 7723 7724 buf[b] = 12 // request opcode 7725 b += 1 7726 7727 b += 1 // padding 7728 7729 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7730 b += 2 7731 7732 xgb.Put32(buf[b:], uint32(Window)) 7733 b += 4 7734 7735 xgb.Put16(buf[b:], ValueMask) 7736 b += 2 7737 7738 b += 2 // padding 7739 7740 for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { 7741 xgb.Put32(buf[b:], ValueList[i]) 7742 b += 4 7743 } 7744 b = xgb.Pad(b) 7745 7746 return buf 7747 } 7748 7749 // ConvertSelectionCookie is a cookie used only for ConvertSelection requests. 7750 type ConvertSelectionCookie struct { 7751 *xgb.Cookie 7752 } 7753 7754 // ConvertSelection sends an unchecked request. 7755 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7756 func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { 7757 cookie := c.NewCookie(false, false) 7758 c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) 7759 return ConvertSelectionCookie{cookie} 7760 } 7761 7762 // ConvertSelectionChecked sends a checked request. 7763 // If an error occurs, it can be retrieved using ConvertSelectionCookie.Check() 7764 func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { 7765 cookie := c.NewCookie(true, false) 7766 c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) 7767 return ConvertSelectionCookie{cookie} 7768 } 7769 7770 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7771 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7772 func (cook ConvertSelectionCookie) Check() error { 7773 return cook.Cookie.Check() 7774 } 7775 7776 // Write request to wire for ConvertSelection 7777 // convertSelectionRequest writes a ConvertSelection request to a byte slice. 7778 func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { 7779 size := 24 7780 b := 0 7781 buf := make([]byte, size) 7782 7783 buf[b] = 24 // request opcode 7784 b += 1 7785 7786 b += 1 // padding 7787 7788 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7789 b += 2 7790 7791 xgb.Put32(buf[b:], uint32(Requestor)) 7792 b += 4 7793 7794 xgb.Put32(buf[b:], uint32(Selection)) 7795 b += 4 7796 7797 xgb.Put32(buf[b:], uint32(Target)) 7798 b += 4 7799 7800 xgb.Put32(buf[b:], uint32(Property)) 7801 b += 4 7802 7803 xgb.Put32(buf[b:], uint32(Time)) 7804 b += 4 7805 7806 return buf 7807 } 7808 7809 // CopyAreaCookie is a cookie used only for CopyArea requests. 7810 type CopyAreaCookie struct { 7811 *xgb.Cookie 7812 } 7813 7814 // CopyArea sends an unchecked request. 7815 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7816 func CopyArea(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { 7817 cookie := c.NewCookie(false, false) 7818 c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) 7819 return CopyAreaCookie{cookie} 7820 } 7821 7822 // CopyAreaChecked sends a checked request. 7823 // If an error occurs, it can be retrieved using CopyAreaCookie.Check() 7824 func CopyAreaChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { 7825 cookie := c.NewCookie(true, false) 7826 c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) 7827 return CopyAreaCookie{cookie} 7828 } 7829 7830 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7831 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7832 func (cook CopyAreaCookie) Check() error { 7833 return cook.Cookie.Check() 7834 } 7835 7836 // Write request to wire for CopyArea 7837 // copyAreaRequest writes a CopyArea request to a byte slice. 7838 func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { 7839 size := 28 7840 b := 0 7841 buf := make([]byte, size) 7842 7843 buf[b] = 62 // request opcode 7844 b += 1 7845 7846 b += 1 // padding 7847 7848 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7849 b += 2 7850 7851 xgb.Put32(buf[b:], uint32(SrcDrawable)) 7852 b += 4 7853 7854 xgb.Put32(buf[b:], uint32(DstDrawable)) 7855 b += 4 7856 7857 xgb.Put32(buf[b:], uint32(Gc)) 7858 b += 4 7859 7860 xgb.Put16(buf[b:], uint16(SrcX)) 7861 b += 2 7862 7863 xgb.Put16(buf[b:], uint16(SrcY)) 7864 b += 2 7865 7866 xgb.Put16(buf[b:], uint16(DstX)) 7867 b += 2 7868 7869 xgb.Put16(buf[b:], uint16(DstY)) 7870 b += 2 7871 7872 xgb.Put16(buf[b:], Width) 7873 b += 2 7874 7875 xgb.Put16(buf[b:], Height) 7876 b += 2 7877 7878 return buf 7879 } 7880 7881 // CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. 7882 type CopyColormapAndFreeCookie struct { 7883 *xgb.Cookie 7884 } 7885 7886 // CopyColormapAndFree sends an unchecked request. 7887 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7888 func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { 7889 cookie := c.NewCookie(false, false) 7890 c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) 7891 return CopyColormapAndFreeCookie{cookie} 7892 } 7893 7894 // CopyColormapAndFreeChecked sends a checked request. 7895 // If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check() 7896 func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { 7897 cookie := c.NewCookie(true, false) 7898 c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) 7899 return CopyColormapAndFreeCookie{cookie} 7900 } 7901 7902 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7903 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7904 func (cook CopyColormapAndFreeCookie) Check() error { 7905 return cook.Cookie.Check() 7906 } 7907 7908 // Write request to wire for CopyColormapAndFree 7909 // copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice. 7910 func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { 7911 size := 12 7912 b := 0 7913 buf := make([]byte, size) 7914 7915 buf[b] = 80 // request opcode 7916 b += 1 7917 7918 b += 1 // padding 7919 7920 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7921 b += 2 7922 7923 xgb.Put32(buf[b:], uint32(Mid)) 7924 b += 4 7925 7926 xgb.Put32(buf[b:], uint32(SrcCmap)) 7927 b += 4 7928 7929 return buf 7930 } 7931 7932 // CopyGCCookie is a cookie used only for CopyGC requests. 7933 type CopyGCCookie struct { 7934 *xgb.Cookie 7935 } 7936 7937 // CopyGC sends an unchecked request. 7938 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7939 func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { 7940 cookie := c.NewCookie(false, false) 7941 c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) 7942 return CopyGCCookie{cookie} 7943 } 7944 7945 // CopyGCChecked sends a checked request. 7946 // If an error occurs, it can be retrieved using CopyGCCookie.Check() 7947 func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { 7948 cookie := c.NewCookie(true, false) 7949 c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) 7950 return CopyGCCookie{cookie} 7951 } 7952 7953 // Check returns an error if one occurred for checked requests that are not expecting a reply. 7954 // This cannot be called for requests expecting a reply, nor for unchecked requests. 7955 func (cook CopyGCCookie) Check() error { 7956 return cook.Cookie.Check() 7957 } 7958 7959 // Write request to wire for CopyGC 7960 // copyGCRequest writes a CopyGC request to a byte slice. 7961 func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { 7962 size := 16 7963 b := 0 7964 buf := make([]byte, size) 7965 7966 buf[b] = 57 // request opcode 7967 b += 1 7968 7969 b += 1 // padding 7970 7971 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 7972 b += 2 7973 7974 xgb.Put32(buf[b:], uint32(SrcGc)) 7975 b += 4 7976 7977 xgb.Put32(buf[b:], uint32(DstGc)) 7978 b += 4 7979 7980 xgb.Put32(buf[b:], ValueMask) 7981 b += 4 7982 7983 return buf 7984 } 7985 7986 // CopyPlaneCookie is a cookie used only for CopyPlane requests. 7987 type CopyPlaneCookie struct { 7988 *xgb.Cookie 7989 } 7990 7991 // CopyPlane sends an unchecked request. 7992 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 7993 func CopyPlane(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { 7994 cookie := c.NewCookie(false, false) 7995 c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) 7996 return CopyPlaneCookie{cookie} 7997 } 7998 7999 // CopyPlaneChecked sends a checked request. 8000 // If an error occurs, it can be retrieved using CopyPlaneCookie.Check() 8001 func CopyPlaneChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { 8002 cookie := c.NewCookie(true, false) 8003 c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) 8004 return CopyPlaneCookie{cookie} 8005 } 8006 8007 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8008 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8009 func (cook CopyPlaneCookie) Check() error { 8010 return cook.Cookie.Check() 8011 } 8012 8013 // Write request to wire for CopyPlane 8014 // copyPlaneRequest writes a CopyPlane request to a byte slice. 8015 func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { 8016 size := 32 8017 b := 0 8018 buf := make([]byte, size) 8019 8020 buf[b] = 63 // request opcode 8021 b += 1 8022 8023 b += 1 // padding 8024 8025 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8026 b += 2 8027 8028 xgb.Put32(buf[b:], uint32(SrcDrawable)) 8029 b += 4 8030 8031 xgb.Put32(buf[b:], uint32(DstDrawable)) 8032 b += 4 8033 8034 xgb.Put32(buf[b:], uint32(Gc)) 8035 b += 4 8036 8037 xgb.Put16(buf[b:], uint16(SrcX)) 8038 b += 2 8039 8040 xgb.Put16(buf[b:], uint16(SrcY)) 8041 b += 2 8042 8043 xgb.Put16(buf[b:], uint16(DstX)) 8044 b += 2 8045 8046 xgb.Put16(buf[b:], uint16(DstY)) 8047 b += 2 8048 8049 xgb.Put16(buf[b:], Width) 8050 b += 2 8051 8052 xgb.Put16(buf[b:], Height) 8053 b += 2 8054 8055 xgb.Put32(buf[b:], BitPlane) 8056 b += 4 8057 8058 return buf 8059 } 8060 8061 // CreateColormapCookie is a cookie used only for CreateColormap requests. 8062 type CreateColormapCookie struct { 8063 *xgb.Cookie 8064 } 8065 8066 // CreateColormap sends an unchecked request. 8067 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8068 func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { 8069 cookie := c.NewCookie(false, false) 8070 c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) 8071 return CreateColormapCookie{cookie} 8072 } 8073 8074 // CreateColormapChecked sends a checked request. 8075 // If an error occurs, it can be retrieved using CreateColormapCookie.Check() 8076 func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { 8077 cookie := c.NewCookie(true, false) 8078 c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) 8079 return CreateColormapCookie{cookie} 8080 } 8081 8082 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8083 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8084 func (cook CreateColormapCookie) Check() error { 8085 return cook.Cookie.Check() 8086 } 8087 8088 // Write request to wire for CreateColormap 8089 // createColormapRequest writes a CreateColormap request to a byte slice. 8090 func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { 8091 size := 16 8092 b := 0 8093 buf := make([]byte, size) 8094 8095 buf[b] = 78 // request opcode 8096 b += 1 8097 8098 buf[b] = Alloc 8099 b += 1 8100 8101 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8102 b += 2 8103 8104 xgb.Put32(buf[b:], uint32(Mid)) 8105 b += 4 8106 8107 xgb.Put32(buf[b:], uint32(Window)) 8108 b += 4 8109 8110 xgb.Put32(buf[b:], uint32(Visual)) 8111 b += 4 8112 8113 return buf 8114 } 8115 8116 // CreateCursorCookie is a cookie used only for CreateCursor requests. 8117 type CreateCursorCookie struct { 8118 *xgb.Cookie 8119 } 8120 8121 // CreateCursor sends an unchecked request. 8122 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8123 func CreateCursor(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { 8124 cookie := c.NewCookie(false, false) 8125 c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) 8126 return CreateCursorCookie{cookie} 8127 } 8128 8129 // CreateCursorChecked sends a checked request. 8130 // If an error occurs, it can be retrieved using CreateCursorCookie.Check() 8131 func CreateCursorChecked(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { 8132 cookie := c.NewCookie(true, false) 8133 c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) 8134 return CreateCursorCookie{cookie} 8135 } 8136 8137 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8138 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8139 func (cook CreateCursorCookie) Check() error { 8140 return cook.Cookie.Check() 8141 } 8142 8143 // Write request to wire for CreateCursor 8144 // createCursorRequest writes a CreateCursor request to a byte slice. 8145 func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) []byte { 8146 size := 32 8147 b := 0 8148 buf := make([]byte, size) 8149 8150 buf[b] = 93 // request opcode 8151 b += 1 8152 8153 b += 1 // padding 8154 8155 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8156 b += 2 8157 8158 xgb.Put32(buf[b:], uint32(Cid)) 8159 b += 4 8160 8161 xgb.Put32(buf[b:], uint32(Source)) 8162 b += 4 8163 8164 xgb.Put32(buf[b:], uint32(Mask)) 8165 b += 4 8166 8167 xgb.Put16(buf[b:], ForeRed) 8168 b += 2 8169 8170 xgb.Put16(buf[b:], ForeGreen) 8171 b += 2 8172 8173 xgb.Put16(buf[b:], ForeBlue) 8174 b += 2 8175 8176 xgb.Put16(buf[b:], BackRed) 8177 b += 2 8178 8179 xgb.Put16(buf[b:], BackGreen) 8180 b += 2 8181 8182 xgb.Put16(buf[b:], BackBlue) 8183 b += 2 8184 8185 xgb.Put16(buf[b:], X) 8186 b += 2 8187 8188 xgb.Put16(buf[b:], Y) 8189 b += 2 8190 8191 return buf 8192 } 8193 8194 // CreateGCCookie is a cookie used only for CreateGC requests. 8195 type CreateGCCookie struct { 8196 *xgb.Cookie 8197 } 8198 8199 // CreateGC sends an unchecked request. 8200 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8201 func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { 8202 cookie := c.NewCookie(false, false) 8203 c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) 8204 return CreateGCCookie{cookie} 8205 } 8206 8207 // CreateGCChecked sends a checked request. 8208 // If an error occurs, it can be retrieved using CreateGCCookie.Check() 8209 func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { 8210 cookie := c.NewCookie(true, false) 8211 c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) 8212 return CreateGCCookie{cookie} 8213 } 8214 8215 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8216 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8217 func (cook CreateGCCookie) Check() error { 8218 return cook.Cookie.Check() 8219 } 8220 8221 // Write request to wire for CreateGC 8222 // createGCRequest writes a CreateGC request to a byte slice. 8223 func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { 8224 size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) 8225 b := 0 8226 buf := make([]byte, size) 8227 8228 buf[b] = 55 // request opcode 8229 b += 1 8230 8231 b += 1 // padding 8232 8233 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8234 b += 2 8235 8236 xgb.Put32(buf[b:], uint32(Cid)) 8237 b += 4 8238 8239 xgb.Put32(buf[b:], uint32(Drawable)) 8240 b += 4 8241 8242 xgb.Put32(buf[b:], ValueMask) 8243 b += 4 8244 for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { 8245 xgb.Put32(buf[b:], ValueList[i]) 8246 b += 4 8247 } 8248 b = xgb.Pad(b) 8249 8250 return buf 8251 } 8252 8253 // CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. 8254 type CreateGlyphCursorCookie struct { 8255 *xgb.Cookie 8256 } 8257 8258 // CreateGlyphCursor sends an unchecked request. 8259 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8260 func CreateGlyphCursor(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { 8261 cookie := c.NewCookie(false, false) 8262 c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) 8263 return CreateGlyphCursorCookie{cookie} 8264 } 8265 8266 // CreateGlyphCursorChecked sends a checked request. 8267 // If an error occurs, it can be retrieved using CreateGlyphCursorCookie.Check() 8268 func CreateGlyphCursorChecked(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { 8269 cookie := c.NewCookie(true, false) 8270 c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) 8271 return CreateGlyphCursorCookie{cookie} 8272 } 8273 8274 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8275 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8276 func (cook CreateGlyphCursorCookie) Check() error { 8277 return cook.Cookie.Check() 8278 } 8279 8280 // Write request to wire for CreateGlyphCursor 8281 // createGlyphCursorRequest writes a CreateGlyphCursor request to a byte slice. 8282 func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { 8283 size := 32 8284 b := 0 8285 buf := make([]byte, size) 8286 8287 buf[b] = 94 // request opcode 8288 b += 1 8289 8290 b += 1 // padding 8291 8292 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8293 b += 2 8294 8295 xgb.Put32(buf[b:], uint32(Cid)) 8296 b += 4 8297 8298 xgb.Put32(buf[b:], uint32(SourceFont)) 8299 b += 4 8300 8301 xgb.Put32(buf[b:], uint32(MaskFont)) 8302 b += 4 8303 8304 xgb.Put16(buf[b:], SourceChar) 8305 b += 2 8306 8307 xgb.Put16(buf[b:], MaskChar) 8308 b += 2 8309 8310 xgb.Put16(buf[b:], ForeRed) 8311 b += 2 8312 8313 xgb.Put16(buf[b:], ForeGreen) 8314 b += 2 8315 8316 xgb.Put16(buf[b:], ForeBlue) 8317 b += 2 8318 8319 xgb.Put16(buf[b:], BackRed) 8320 b += 2 8321 8322 xgb.Put16(buf[b:], BackGreen) 8323 b += 2 8324 8325 xgb.Put16(buf[b:], BackBlue) 8326 b += 2 8327 8328 return buf 8329 } 8330 8331 // CreatePixmapCookie is a cookie used only for CreatePixmap requests. 8332 type CreatePixmapCookie struct { 8333 *xgb.Cookie 8334 } 8335 8336 // CreatePixmap sends an unchecked request. 8337 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8338 func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { 8339 cookie := c.NewCookie(false, false) 8340 c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) 8341 return CreatePixmapCookie{cookie} 8342 } 8343 8344 // CreatePixmapChecked sends a checked request. 8345 // If an error occurs, it can be retrieved using CreatePixmapCookie.Check() 8346 func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { 8347 cookie := c.NewCookie(true, false) 8348 c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) 8349 return CreatePixmapCookie{cookie} 8350 } 8351 8352 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8353 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8354 func (cook CreatePixmapCookie) Check() error { 8355 return cook.Cookie.Check() 8356 } 8357 8358 // Write request to wire for CreatePixmap 8359 // createPixmapRequest writes a CreatePixmap request to a byte slice. 8360 func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { 8361 size := 16 8362 b := 0 8363 buf := make([]byte, size) 8364 8365 buf[b] = 53 // request opcode 8366 b += 1 8367 8368 buf[b] = Depth 8369 b += 1 8370 8371 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8372 b += 2 8373 8374 xgb.Put32(buf[b:], uint32(Pid)) 8375 b += 4 8376 8377 xgb.Put32(buf[b:], uint32(Drawable)) 8378 b += 4 8379 8380 xgb.Put16(buf[b:], Width) 8381 b += 2 8382 8383 xgb.Put16(buf[b:], Height) 8384 b += 2 8385 8386 return buf 8387 } 8388 8389 // CreateWindowCookie is a cookie used only for CreateWindow requests. 8390 type CreateWindowCookie struct { 8391 *xgb.Cookie 8392 } 8393 8394 // CreateWindow sends an unchecked request. 8395 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8396 func CreateWindow(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { 8397 cookie := c.NewCookie(false, false) 8398 c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) 8399 return CreateWindowCookie{cookie} 8400 } 8401 8402 // CreateWindowChecked sends a checked request. 8403 // If an error occurs, it can be retrieved using CreateWindowCookie.Check() 8404 func CreateWindowChecked(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { 8405 cookie := c.NewCookie(true, false) 8406 c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) 8407 return CreateWindowCookie{cookie} 8408 } 8409 8410 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8411 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8412 func (cook CreateWindowCookie) Check() error { 8413 return cook.Cookie.Check() 8414 } 8415 8416 // Write request to wire for CreateWindow 8417 // createWindowRequest writes a CreateWindow request to a byte slice. 8418 func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { 8419 size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) 8420 b := 0 8421 buf := make([]byte, size) 8422 8423 buf[b] = 1 // request opcode 8424 b += 1 8425 8426 buf[b] = Depth 8427 b += 1 8428 8429 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8430 b += 2 8431 8432 xgb.Put32(buf[b:], uint32(Wid)) 8433 b += 4 8434 8435 xgb.Put32(buf[b:], uint32(Parent)) 8436 b += 4 8437 8438 xgb.Put16(buf[b:], uint16(X)) 8439 b += 2 8440 8441 xgb.Put16(buf[b:], uint16(Y)) 8442 b += 2 8443 8444 xgb.Put16(buf[b:], Width) 8445 b += 2 8446 8447 xgb.Put16(buf[b:], Height) 8448 b += 2 8449 8450 xgb.Put16(buf[b:], BorderWidth) 8451 b += 2 8452 8453 xgb.Put16(buf[b:], Class) 8454 b += 2 8455 8456 xgb.Put32(buf[b:], uint32(Visual)) 8457 b += 4 8458 8459 xgb.Put32(buf[b:], ValueMask) 8460 b += 4 8461 for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { 8462 xgb.Put32(buf[b:], ValueList[i]) 8463 b += 4 8464 } 8465 b = xgb.Pad(b) 8466 8467 return buf 8468 } 8469 8470 // DeletePropertyCookie is a cookie used only for DeleteProperty requests. 8471 type DeletePropertyCookie struct { 8472 *xgb.Cookie 8473 } 8474 8475 // DeleteProperty sends an unchecked request. 8476 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8477 func DeleteProperty(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { 8478 cookie := c.NewCookie(false, false) 8479 c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) 8480 return DeletePropertyCookie{cookie} 8481 } 8482 8483 // DeletePropertyChecked sends a checked request. 8484 // If an error occurs, it can be retrieved using DeletePropertyCookie.Check() 8485 func DeletePropertyChecked(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { 8486 cookie := c.NewCookie(true, false) 8487 c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) 8488 return DeletePropertyCookie{cookie} 8489 } 8490 8491 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8492 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8493 func (cook DeletePropertyCookie) Check() error { 8494 return cook.Cookie.Check() 8495 } 8496 8497 // Write request to wire for DeleteProperty 8498 // deletePropertyRequest writes a DeleteProperty request to a byte slice. 8499 func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { 8500 size := 12 8501 b := 0 8502 buf := make([]byte, size) 8503 8504 buf[b] = 19 // request opcode 8505 b += 1 8506 8507 b += 1 // padding 8508 8509 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8510 b += 2 8511 8512 xgb.Put32(buf[b:], uint32(Window)) 8513 b += 4 8514 8515 xgb.Put32(buf[b:], uint32(Property)) 8516 b += 4 8517 8518 return buf 8519 } 8520 8521 // DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. 8522 type DestroySubwindowsCookie struct { 8523 *xgb.Cookie 8524 } 8525 8526 // DestroySubwindows sends an unchecked request. 8527 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8528 func DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { 8529 cookie := c.NewCookie(false, false) 8530 c.NewRequest(destroySubwindowsRequest(c, Window), cookie) 8531 return DestroySubwindowsCookie{cookie} 8532 } 8533 8534 // DestroySubwindowsChecked sends a checked request. 8535 // If an error occurs, it can be retrieved using DestroySubwindowsCookie.Check() 8536 func DestroySubwindowsChecked(c *xgb.Conn, Window Window) DestroySubwindowsCookie { 8537 cookie := c.NewCookie(true, false) 8538 c.NewRequest(destroySubwindowsRequest(c, Window), cookie) 8539 return DestroySubwindowsCookie{cookie} 8540 } 8541 8542 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8543 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8544 func (cook DestroySubwindowsCookie) Check() error { 8545 return cook.Cookie.Check() 8546 } 8547 8548 // Write request to wire for DestroySubwindows 8549 // destroySubwindowsRequest writes a DestroySubwindows request to a byte slice. 8550 func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { 8551 size := 8 8552 b := 0 8553 buf := make([]byte, size) 8554 8555 buf[b] = 5 // request opcode 8556 b += 1 8557 8558 b += 1 // padding 8559 8560 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8561 b += 2 8562 8563 xgb.Put32(buf[b:], uint32(Window)) 8564 b += 4 8565 8566 return buf 8567 } 8568 8569 // DestroyWindowCookie is a cookie used only for DestroyWindow requests. 8570 type DestroyWindowCookie struct { 8571 *xgb.Cookie 8572 } 8573 8574 // DestroyWindow sends an unchecked request. 8575 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8576 func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { 8577 cookie := c.NewCookie(false, false) 8578 c.NewRequest(destroyWindowRequest(c, Window), cookie) 8579 return DestroyWindowCookie{cookie} 8580 } 8581 8582 // DestroyWindowChecked sends a checked request. 8583 // If an error occurs, it can be retrieved using DestroyWindowCookie.Check() 8584 func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie { 8585 cookie := c.NewCookie(true, false) 8586 c.NewRequest(destroyWindowRequest(c, Window), cookie) 8587 return DestroyWindowCookie{cookie} 8588 } 8589 8590 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8591 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8592 func (cook DestroyWindowCookie) Check() error { 8593 return cook.Cookie.Check() 8594 } 8595 8596 // Write request to wire for DestroyWindow 8597 // destroyWindowRequest writes a DestroyWindow request to a byte slice. 8598 func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { 8599 size := 8 8600 b := 0 8601 buf := make([]byte, size) 8602 8603 buf[b] = 4 // request opcode 8604 b += 1 8605 8606 b += 1 // padding 8607 8608 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8609 b += 2 8610 8611 xgb.Put32(buf[b:], uint32(Window)) 8612 b += 4 8613 8614 return buf 8615 } 8616 8617 // FillPolyCookie is a cookie used only for FillPoly requests. 8618 type FillPolyCookie struct { 8619 *xgb.Cookie 8620 } 8621 8622 // FillPoly sends an unchecked request. 8623 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8624 func FillPoly(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { 8625 cookie := c.NewCookie(false, false) 8626 c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) 8627 return FillPolyCookie{cookie} 8628 } 8629 8630 // FillPolyChecked sends a checked request. 8631 // If an error occurs, it can be retrieved using FillPolyCookie.Check() 8632 func FillPolyChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { 8633 cookie := c.NewCookie(true, false) 8634 c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) 8635 return FillPolyCookie{cookie} 8636 } 8637 8638 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8639 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8640 func (cook FillPolyCookie) Check() error { 8641 return cook.Cookie.Check() 8642 } 8643 8644 // Write request to wire for FillPoly 8645 // fillPolyRequest writes a FillPoly request to a byte slice. 8646 func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { 8647 size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) 8648 b := 0 8649 buf := make([]byte, size) 8650 8651 buf[b] = 69 // request opcode 8652 b += 1 8653 8654 b += 1 // padding 8655 8656 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8657 b += 2 8658 8659 xgb.Put32(buf[b:], uint32(Drawable)) 8660 b += 4 8661 8662 xgb.Put32(buf[b:], uint32(Gc)) 8663 b += 4 8664 8665 buf[b] = Shape 8666 b += 1 8667 8668 buf[b] = CoordinateMode 8669 b += 1 8670 8671 b += 2 // padding 8672 8673 b += PointListBytes(buf[b:], Points) 8674 8675 return buf 8676 } 8677 8678 // ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. 8679 type ForceScreenSaverCookie struct { 8680 *xgb.Cookie 8681 } 8682 8683 // ForceScreenSaver sends an unchecked request. 8684 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8685 func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { 8686 cookie := c.NewCookie(false, false) 8687 c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) 8688 return ForceScreenSaverCookie{cookie} 8689 } 8690 8691 // ForceScreenSaverChecked sends a checked request. 8692 // If an error occurs, it can be retrieved using ForceScreenSaverCookie.Check() 8693 func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { 8694 cookie := c.NewCookie(true, false) 8695 c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) 8696 return ForceScreenSaverCookie{cookie} 8697 } 8698 8699 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8700 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8701 func (cook ForceScreenSaverCookie) Check() error { 8702 return cook.Cookie.Check() 8703 } 8704 8705 // Write request to wire for ForceScreenSaver 8706 // forceScreenSaverRequest writes a ForceScreenSaver request to a byte slice. 8707 func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { 8708 size := 4 8709 b := 0 8710 buf := make([]byte, size) 8711 8712 buf[b] = 115 // request opcode 8713 b += 1 8714 8715 buf[b] = Mode 8716 b += 1 8717 8718 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8719 b += 2 8720 8721 return buf 8722 } 8723 8724 // FreeColormapCookie is a cookie used only for FreeColormap requests. 8725 type FreeColormapCookie struct { 8726 *xgb.Cookie 8727 } 8728 8729 // FreeColormap sends an unchecked request. 8730 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8731 func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { 8732 cookie := c.NewCookie(false, false) 8733 c.NewRequest(freeColormapRequest(c, Cmap), cookie) 8734 return FreeColormapCookie{cookie} 8735 } 8736 8737 // FreeColormapChecked sends a checked request. 8738 // If an error occurs, it can be retrieved using FreeColormapCookie.Check() 8739 func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { 8740 cookie := c.NewCookie(true, false) 8741 c.NewRequest(freeColormapRequest(c, Cmap), cookie) 8742 return FreeColormapCookie{cookie} 8743 } 8744 8745 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8746 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8747 func (cook FreeColormapCookie) Check() error { 8748 return cook.Cookie.Check() 8749 } 8750 8751 // Write request to wire for FreeColormap 8752 // freeColormapRequest writes a FreeColormap request to a byte slice. 8753 func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { 8754 size := 8 8755 b := 0 8756 buf := make([]byte, size) 8757 8758 buf[b] = 79 // request opcode 8759 b += 1 8760 8761 b += 1 // padding 8762 8763 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8764 b += 2 8765 8766 xgb.Put32(buf[b:], uint32(Cmap)) 8767 b += 4 8768 8769 return buf 8770 } 8771 8772 // FreeColorsCookie is a cookie used only for FreeColors requests. 8773 type FreeColorsCookie struct { 8774 *xgb.Cookie 8775 } 8776 8777 // FreeColors sends an unchecked request. 8778 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8779 func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { 8780 cookie := c.NewCookie(false, false) 8781 c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) 8782 return FreeColorsCookie{cookie} 8783 } 8784 8785 // FreeColorsChecked sends a checked request. 8786 // If an error occurs, it can be retrieved using FreeColorsCookie.Check() 8787 func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { 8788 cookie := c.NewCookie(true, false) 8789 c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) 8790 return FreeColorsCookie{cookie} 8791 } 8792 8793 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8794 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8795 func (cook FreeColorsCookie) Check() error { 8796 return cook.Cookie.Check() 8797 } 8798 8799 // Write request to wire for FreeColors 8800 // freeColorsRequest writes a FreeColors request to a byte slice. 8801 func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { 8802 size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) 8803 b := 0 8804 buf := make([]byte, size) 8805 8806 buf[b] = 88 // request opcode 8807 b += 1 8808 8809 b += 1 // padding 8810 8811 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8812 b += 2 8813 8814 xgb.Put32(buf[b:], uint32(Cmap)) 8815 b += 4 8816 8817 xgb.Put32(buf[b:], PlaneMask) 8818 b += 4 8819 8820 for i := 0; i < int(len(Pixels)); i++ { 8821 xgb.Put32(buf[b:], Pixels[i]) 8822 b += 4 8823 } 8824 8825 return buf 8826 } 8827 8828 // FreeCursorCookie is a cookie used only for FreeCursor requests. 8829 type FreeCursorCookie struct { 8830 *xgb.Cookie 8831 } 8832 8833 // FreeCursor sends an unchecked request. 8834 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8835 func FreeCursor(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { 8836 cookie := c.NewCookie(false, false) 8837 c.NewRequest(freeCursorRequest(c, Cursor), cookie) 8838 return FreeCursorCookie{cookie} 8839 } 8840 8841 // FreeCursorChecked sends a checked request. 8842 // If an error occurs, it can be retrieved using FreeCursorCookie.Check() 8843 func FreeCursorChecked(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { 8844 cookie := c.NewCookie(true, false) 8845 c.NewRequest(freeCursorRequest(c, Cursor), cookie) 8846 return FreeCursorCookie{cookie} 8847 } 8848 8849 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8850 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8851 func (cook FreeCursorCookie) Check() error { 8852 return cook.Cookie.Check() 8853 } 8854 8855 // Write request to wire for FreeCursor 8856 // freeCursorRequest writes a FreeCursor request to a byte slice. 8857 func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { 8858 size := 8 8859 b := 0 8860 buf := make([]byte, size) 8861 8862 buf[b] = 95 // request opcode 8863 b += 1 8864 8865 b += 1 // padding 8866 8867 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8868 b += 2 8869 8870 xgb.Put32(buf[b:], uint32(Cursor)) 8871 b += 4 8872 8873 return buf 8874 } 8875 8876 // FreeGCCookie is a cookie used only for FreeGC requests. 8877 type FreeGCCookie struct { 8878 *xgb.Cookie 8879 } 8880 8881 // FreeGC sends an unchecked request. 8882 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8883 func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { 8884 cookie := c.NewCookie(false, false) 8885 c.NewRequest(freeGCRequest(c, Gc), cookie) 8886 return FreeGCCookie{cookie} 8887 } 8888 8889 // FreeGCChecked sends a checked request. 8890 // If an error occurs, it can be retrieved using FreeGCCookie.Check() 8891 func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie { 8892 cookie := c.NewCookie(true, false) 8893 c.NewRequest(freeGCRequest(c, Gc), cookie) 8894 return FreeGCCookie{cookie} 8895 } 8896 8897 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8898 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8899 func (cook FreeGCCookie) Check() error { 8900 return cook.Cookie.Check() 8901 } 8902 8903 // Write request to wire for FreeGC 8904 // freeGCRequest writes a FreeGC request to a byte slice. 8905 func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { 8906 size := 8 8907 b := 0 8908 buf := make([]byte, size) 8909 8910 buf[b] = 60 // request opcode 8911 b += 1 8912 8913 b += 1 // padding 8914 8915 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8916 b += 2 8917 8918 xgb.Put32(buf[b:], uint32(Gc)) 8919 b += 4 8920 8921 return buf 8922 } 8923 8924 // FreePixmapCookie is a cookie used only for FreePixmap requests. 8925 type FreePixmapCookie struct { 8926 *xgb.Cookie 8927 } 8928 8929 // FreePixmap sends an unchecked request. 8930 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8931 func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { 8932 cookie := c.NewCookie(false, false) 8933 c.NewRequest(freePixmapRequest(c, Pixmap), cookie) 8934 return FreePixmapCookie{cookie} 8935 } 8936 8937 // FreePixmapChecked sends a checked request. 8938 // If an error occurs, it can be retrieved using FreePixmapCookie.Check() 8939 func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { 8940 cookie := c.NewCookie(true, false) 8941 c.NewRequest(freePixmapRequest(c, Pixmap), cookie) 8942 return FreePixmapCookie{cookie} 8943 } 8944 8945 // Check returns an error if one occurred for checked requests that are not expecting a reply. 8946 // This cannot be called for requests expecting a reply, nor for unchecked requests. 8947 func (cook FreePixmapCookie) Check() error { 8948 return cook.Cookie.Check() 8949 } 8950 8951 // Write request to wire for FreePixmap 8952 // freePixmapRequest writes a FreePixmap request to a byte slice. 8953 func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { 8954 size := 8 8955 b := 0 8956 buf := make([]byte, size) 8957 8958 buf[b] = 54 // request opcode 8959 b += 1 8960 8961 b += 1 // padding 8962 8963 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 8964 b += 2 8965 8966 xgb.Put32(buf[b:], uint32(Pixmap)) 8967 b += 4 8968 8969 return buf 8970 } 8971 8972 // GetAtomNameCookie is a cookie used only for GetAtomName requests. 8973 type GetAtomNameCookie struct { 8974 *xgb.Cookie 8975 } 8976 8977 // GetAtomName sends a checked request. 8978 // If an error occurs, it will be returned with the reply by calling GetAtomNameCookie.Reply() 8979 func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie { 8980 cookie := c.NewCookie(true, true) 8981 c.NewRequest(getAtomNameRequest(c, Atom), cookie) 8982 return GetAtomNameCookie{cookie} 8983 } 8984 8985 // GetAtomNameUnchecked sends an unchecked request. 8986 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 8987 func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie { 8988 cookie := c.NewCookie(false, true) 8989 c.NewRequest(getAtomNameRequest(c, Atom), cookie) 8990 return GetAtomNameCookie{cookie} 8991 } 8992 8993 // GetAtomNameReply represents the data returned from a GetAtomName request. 8994 type GetAtomNameReply struct { 8995 Sequence uint16 // sequence number of the request for this reply 8996 Length uint32 // number of bytes in this reply 8997 // padding: 1 bytes 8998 NameLen uint16 8999 // padding: 22 bytes 9000 Name string // size: xgb.Pad((int(NameLen) * 1)) 9001 } 9002 9003 // Reply blocks and returns the reply data for a GetAtomName request. 9004 func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { 9005 buf, err := cook.Cookie.Reply() 9006 if err != nil { 9007 return nil, err 9008 } 9009 if buf == nil { 9010 return nil, nil 9011 } 9012 return getAtomNameReply(buf), nil 9013 } 9014 9015 // getAtomNameReply reads a byte slice into a GetAtomNameReply value. 9016 func getAtomNameReply(buf []byte) *GetAtomNameReply { 9017 v := new(GetAtomNameReply) 9018 b := 1 // skip reply determinant 9019 9020 b += 1 // padding 9021 9022 v.Sequence = xgb.Get16(buf[b:]) 9023 b += 2 9024 9025 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9026 b += 4 9027 9028 v.NameLen = xgb.Get16(buf[b:]) 9029 b += 2 9030 9031 b += 22 // padding 9032 9033 { 9034 byteString := make([]byte, v.NameLen) 9035 copy(byteString[:v.NameLen], buf[b:]) 9036 v.Name = string(byteString) 9037 b += int(v.NameLen) 9038 } 9039 9040 return v 9041 } 9042 9043 // Write request to wire for GetAtomName 9044 // getAtomNameRequest writes a GetAtomName request to a byte slice. 9045 func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { 9046 size := 8 9047 b := 0 9048 buf := make([]byte, size) 9049 9050 buf[b] = 17 // request opcode 9051 b += 1 9052 9053 b += 1 // padding 9054 9055 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9056 b += 2 9057 9058 xgb.Put32(buf[b:], uint32(Atom)) 9059 b += 4 9060 9061 return buf 9062 } 9063 9064 // GetFontPathCookie is a cookie used only for GetFontPath requests. 9065 type GetFontPathCookie struct { 9066 *xgb.Cookie 9067 } 9068 9069 // GetFontPath sends a checked request. 9070 // If an error occurs, it will be returned with the reply by calling GetFontPathCookie.Reply() 9071 func GetFontPath(c *xgb.Conn) GetFontPathCookie { 9072 cookie := c.NewCookie(true, true) 9073 c.NewRequest(getFontPathRequest(c), cookie) 9074 return GetFontPathCookie{cookie} 9075 } 9076 9077 // GetFontPathUnchecked sends an unchecked request. 9078 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9079 func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { 9080 cookie := c.NewCookie(false, true) 9081 c.NewRequest(getFontPathRequest(c), cookie) 9082 return GetFontPathCookie{cookie} 9083 } 9084 9085 // GetFontPathReply represents the data returned from a GetFontPath request. 9086 type GetFontPathReply struct { 9087 Sequence uint16 // sequence number of the request for this reply 9088 Length uint32 // number of bytes in this reply 9089 // padding: 1 bytes 9090 PathLen uint16 9091 // padding: 22 bytes 9092 Path []Str // size: StrListSize(Path) 9093 } 9094 9095 // Reply blocks and returns the reply data for a GetFontPath request. 9096 func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { 9097 buf, err := cook.Cookie.Reply() 9098 if err != nil { 9099 return nil, err 9100 } 9101 if buf == nil { 9102 return nil, nil 9103 } 9104 return getFontPathReply(buf), nil 9105 } 9106 9107 // getFontPathReply reads a byte slice into a GetFontPathReply value. 9108 func getFontPathReply(buf []byte) *GetFontPathReply { 9109 v := new(GetFontPathReply) 9110 b := 1 // skip reply determinant 9111 9112 b += 1 // padding 9113 9114 v.Sequence = xgb.Get16(buf[b:]) 9115 b += 2 9116 9117 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9118 b += 4 9119 9120 v.PathLen = xgb.Get16(buf[b:]) 9121 b += 2 9122 9123 b += 22 // padding 9124 9125 v.Path = make([]Str, v.PathLen) 9126 b += StrReadList(buf[b:], v.Path) 9127 9128 return v 9129 } 9130 9131 // Write request to wire for GetFontPath 9132 // getFontPathRequest writes a GetFontPath request to a byte slice. 9133 func getFontPathRequest(c *xgb.Conn) []byte { 9134 size := 4 9135 b := 0 9136 buf := make([]byte, size) 9137 9138 buf[b] = 52 // request opcode 9139 b += 1 9140 9141 b += 1 // padding 9142 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9143 b += 2 9144 9145 return buf 9146 } 9147 9148 // GetGeometryCookie is a cookie used only for GetGeometry requests. 9149 type GetGeometryCookie struct { 9150 *xgb.Cookie 9151 } 9152 9153 // GetGeometry sends a checked request. 9154 // If an error occurs, it will be returned with the reply by calling GetGeometryCookie.Reply() 9155 func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { 9156 cookie := c.NewCookie(true, true) 9157 c.NewRequest(getGeometryRequest(c, Drawable), cookie) 9158 return GetGeometryCookie{cookie} 9159 } 9160 9161 // GetGeometryUnchecked sends an unchecked request. 9162 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9163 func GetGeometryUnchecked(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { 9164 cookie := c.NewCookie(false, true) 9165 c.NewRequest(getGeometryRequest(c, Drawable), cookie) 9166 return GetGeometryCookie{cookie} 9167 } 9168 9169 // GetGeometryReply represents the data returned from a GetGeometry request. 9170 type GetGeometryReply struct { 9171 Sequence uint16 // sequence number of the request for this reply 9172 Length uint32 // number of bytes in this reply 9173 Depth byte 9174 Root Window 9175 X int16 9176 Y int16 9177 Width uint16 9178 Height uint16 9179 BorderWidth uint16 9180 // padding: 2 bytes 9181 } 9182 9183 // Reply blocks and returns the reply data for a GetGeometry request. 9184 func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { 9185 buf, err := cook.Cookie.Reply() 9186 if err != nil { 9187 return nil, err 9188 } 9189 if buf == nil { 9190 return nil, nil 9191 } 9192 return getGeometryReply(buf), nil 9193 } 9194 9195 // getGeometryReply reads a byte slice into a GetGeometryReply value. 9196 func getGeometryReply(buf []byte) *GetGeometryReply { 9197 v := new(GetGeometryReply) 9198 b := 1 // skip reply determinant 9199 9200 v.Depth = buf[b] 9201 b += 1 9202 9203 v.Sequence = xgb.Get16(buf[b:]) 9204 b += 2 9205 9206 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9207 b += 4 9208 9209 v.Root = Window(xgb.Get32(buf[b:])) 9210 b += 4 9211 9212 v.X = int16(xgb.Get16(buf[b:])) 9213 b += 2 9214 9215 v.Y = int16(xgb.Get16(buf[b:])) 9216 b += 2 9217 9218 v.Width = xgb.Get16(buf[b:]) 9219 b += 2 9220 9221 v.Height = xgb.Get16(buf[b:]) 9222 b += 2 9223 9224 v.BorderWidth = xgb.Get16(buf[b:]) 9225 b += 2 9226 9227 b += 2 // padding 9228 9229 return v 9230 } 9231 9232 // Write request to wire for GetGeometry 9233 // getGeometryRequest writes a GetGeometry request to a byte slice. 9234 func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { 9235 size := 8 9236 b := 0 9237 buf := make([]byte, size) 9238 9239 buf[b] = 14 // request opcode 9240 b += 1 9241 9242 b += 1 // padding 9243 9244 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9245 b += 2 9246 9247 xgb.Put32(buf[b:], uint32(Drawable)) 9248 b += 4 9249 9250 return buf 9251 } 9252 9253 // GetImageCookie is a cookie used only for GetImage requests. 9254 type GetImageCookie struct { 9255 *xgb.Cookie 9256 } 9257 9258 // GetImage sends a checked request. 9259 // If an error occurs, it will be returned with the reply by calling GetImageCookie.Reply() 9260 func GetImage(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { 9261 cookie := c.NewCookie(true, true) 9262 c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) 9263 return GetImageCookie{cookie} 9264 } 9265 9266 // GetImageUnchecked sends an unchecked request. 9267 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9268 func GetImageUnchecked(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { 9269 cookie := c.NewCookie(false, true) 9270 c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) 9271 return GetImageCookie{cookie} 9272 } 9273 9274 // GetImageReply represents the data returned from a GetImage request. 9275 type GetImageReply struct { 9276 Sequence uint16 // sequence number of the request for this reply 9277 Length uint32 // number of bytes in this reply 9278 Depth byte 9279 Visual Visualid 9280 // padding: 20 bytes 9281 Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) 9282 } 9283 9284 // Reply blocks and returns the reply data for a GetImage request. 9285 func (cook GetImageCookie) Reply() (*GetImageReply, error) { 9286 buf, err := cook.Cookie.Reply() 9287 if err != nil { 9288 return nil, err 9289 } 9290 if buf == nil { 9291 return nil, nil 9292 } 9293 return getImageReply(buf), nil 9294 } 9295 9296 // getImageReply reads a byte slice into a GetImageReply value. 9297 func getImageReply(buf []byte) *GetImageReply { 9298 v := new(GetImageReply) 9299 b := 1 // skip reply determinant 9300 9301 v.Depth = buf[b] 9302 b += 1 9303 9304 v.Sequence = xgb.Get16(buf[b:]) 9305 b += 2 9306 9307 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9308 b += 4 9309 9310 v.Visual = Visualid(xgb.Get32(buf[b:])) 9311 b += 4 9312 9313 b += 20 // padding 9314 9315 v.Data = make([]byte, (int(v.Length) * 4)) 9316 copy(v.Data[:(int(v.Length)*4)], buf[b:]) 9317 b += int((int(v.Length) * 4)) 9318 9319 return v 9320 } 9321 9322 // Write request to wire for GetImage 9323 // getImageRequest writes a GetImage request to a byte slice. 9324 func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { 9325 size := 20 9326 b := 0 9327 buf := make([]byte, size) 9328 9329 buf[b] = 73 // request opcode 9330 b += 1 9331 9332 buf[b] = Format 9333 b += 1 9334 9335 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9336 b += 2 9337 9338 xgb.Put32(buf[b:], uint32(Drawable)) 9339 b += 4 9340 9341 xgb.Put16(buf[b:], uint16(X)) 9342 b += 2 9343 9344 xgb.Put16(buf[b:], uint16(Y)) 9345 b += 2 9346 9347 xgb.Put16(buf[b:], Width) 9348 b += 2 9349 9350 xgb.Put16(buf[b:], Height) 9351 b += 2 9352 9353 xgb.Put32(buf[b:], PlaneMask) 9354 b += 4 9355 9356 return buf 9357 } 9358 9359 // GetInputFocusCookie is a cookie used only for GetInputFocus requests. 9360 type GetInputFocusCookie struct { 9361 *xgb.Cookie 9362 } 9363 9364 // GetInputFocus sends a checked request. 9365 // If an error occurs, it will be returned with the reply by calling GetInputFocusCookie.Reply() 9366 func GetInputFocus(c *xgb.Conn) GetInputFocusCookie { 9367 cookie := c.NewCookie(true, true) 9368 c.NewRequest(getInputFocusRequest(c), cookie) 9369 return GetInputFocusCookie{cookie} 9370 } 9371 9372 // GetInputFocusUnchecked sends an unchecked request. 9373 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9374 func GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { 9375 cookie := c.NewCookie(false, true) 9376 c.NewRequest(getInputFocusRequest(c), cookie) 9377 return GetInputFocusCookie{cookie} 9378 } 9379 9380 // GetInputFocusReply represents the data returned from a GetInputFocus request. 9381 type GetInputFocusReply struct { 9382 Sequence uint16 // sequence number of the request for this reply 9383 Length uint32 // number of bytes in this reply 9384 RevertTo byte 9385 Focus Window 9386 } 9387 9388 // Reply blocks and returns the reply data for a GetInputFocus request. 9389 func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { 9390 buf, err := cook.Cookie.Reply() 9391 if err != nil { 9392 return nil, err 9393 } 9394 if buf == nil { 9395 return nil, nil 9396 } 9397 return getInputFocusReply(buf), nil 9398 } 9399 9400 // getInputFocusReply reads a byte slice into a GetInputFocusReply value. 9401 func getInputFocusReply(buf []byte) *GetInputFocusReply { 9402 v := new(GetInputFocusReply) 9403 b := 1 // skip reply determinant 9404 9405 v.RevertTo = buf[b] 9406 b += 1 9407 9408 v.Sequence = xgb.Get16(buf[b:]) 9409 b += 2 9410 9411 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9412 b += 4 9413 9414 v.Focus = Window(xgb.Get32(buf[b:])) 9415 b += 4 9416 9417 return v 9418 } 9419 9420 // Write request to wire for GetInputFocus 9421 // getInputFocusRequest writes a GetInputFocus request to a byte slice. 9422 func getInputFocusRequest(c *xgb.Conn) []byte { 9423 size := 4 9424 b := 0 9425 buf := make([]byte, size) 9426 9427 buf[b] = 43 // request opcode 9428 b += 1 9429 9430 b += 1 // padding 9431 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9432 b += 2 9433 9434 return buf 9435 } 9436 9437 // GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. 9438 type GetKeyboardControlCookie struct { 9439 *xgb.Cookie 9440 } 9441 9442 // GetKeyboardControl sends a checked request. 9443 // If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply() 9444 func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { 9445 cookie := c.NewCookie(true, true) 9446 c.NewRequest(getKeyboardControlRequest(c), cookie) 9447 return GetKeyboardControlCookie{cookie} 9448 } 9449 9450 // GetKeyboardControlUnchecked sends an unchecked request. 9451 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9452 func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { 9453 cookie := c.NewCookie(false, true) 9454 c.NewRequest(getKeyboardControlRequest(c), cookie) 9455 return GetKeyboardControlCookie{cookie} 9456 } 9457 9458 // GetKeyboardControlReply represents the data returned from a GetKeyboardControl request. 9459 type GetKeyboardControlReply struct { 9460 Sequence uint16 // sequence number of the request for this reply 9461 Length uint32 // number of bytes in this reply 9462 GlobalAutoRepeat byte 9463 LedMask uint32 9464 KeyClickPercent byte 9465 BellPercent byte 9466 BellPitch uint16 9467 BellDuration uint16 9468 // padding: 2 bytes 9469 AutoRepeats []byte // size: 32 9470 } 9471 9472 // Reply blocks and returns the reply data for a GetKeyboardControl request. 9473 func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { 9474 buf, err := cook.Cookie.Reply() 9475 if err != nil { 9476 return nil, err 9477 } 9478 if buf == nil { 9479 return nil, nil 9480 } 9481 return getKeyboardControlReply(buf), nil 9482 } 9483 9484 // getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. 9485 func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { 9486 v := new(GetKeyboardControlReply) 9487 b := 1 // skip reply determinant 9488 9489 v.GlobalAutoRepeat = buf[b] 9490 b += 1 9491 9492 v.Sequence = xgb.Get16(buf[b:]) 9493 b += 2 9494 9495 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9496 b += 4 9497 9498 v.LedMask = xgb.Get32(buf[b:]) 9499 b += 4 9500 9501 v.KeyClickPercent = buf[b] 9502 b += 1 9503 9504 v.BellPercent = buf[b] 9505 b += 1 9506 9507 v.BellPitch = xgb.Get16(buf[b:]) 9508 b += 2 9509 9510 v.BellDuration = xgb.Get16(buf[b:]) 9511 b += 2 9512 9513 b += 2 // padding 9514 9515 v.AutoRepeats = make([]byte, 32) 9516 copy(v.AutoRepeats[:32], buf[b:]) 9517 b += int(32) 9518 9519 return v 9520 } 9521 9522 // Write request to wire for GetKeyboardControl 9523 // getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice. 9524 func getKeyboardControlRequest(c *xgb.Conn) []byte { 9525 size := 4 9526 b := 0 9527 buf := make([]byte, size) 9528 9529 buf[b] = 103 // request opcode 9530 b += 1 9531 9532 b += 1 // padding 9533 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9534 b += 2 9535 9536 return buf 9537 } 9538 9539 // GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. 9540 type GetKeyboardMappingCookie struct { 9541 *xgb.Cookie 9542 } 9543 9544 // GetKeyboardMapping sends a checked request. 9545 // If an error occurs, it will be returned with the reply by calling GetKeyboardMappingCookie.Reply() 9546 func GetKeyboardMapping(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { 9547 cookie := c.NewCookie(true, true) 9548 c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) 9549 return GetKeyboardMappingCookie{cookie} 9550 } 9551 9552 // GetKeyboardMappingUnchecked sends an unchecked request. 9553 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9554 func GetKeyboardMappingUnchecked(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { 9555 cookie := c.NewCookie(false, true) 9556 c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) 9557 return GetKeyboardMappingCookie{cookie} 9558 } 9559 9560 // GetKeyboardMappingReply represents the data returned from a GetKeyboardMapping request. 9561 type GetKeyboardMappingReply struct { 9562 Sequence uint16 // sequence number of the request for this reply 9563 Length uint32 // number of bytes in this reply 9564 KeysymsPerKeycode byte 9565 // padding: 24 bytes 9566 Keysyms []Keysym // size: xgb.Pad((int(Length) * 4)) 9567 } 9568 9569 // Reply blocks and returns the reply data for a GetKeyboardMapping request. 9570 func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { 9571 buf, err := cook.Cookie.Reply() 9572 if err != nil { 9573 return nil, err 9574 } 9575 if buf == nil { 9576 return nil, nil 9577 } 9578 return getKeyboardMappingReply(buf), nil 9579 } 9580 9581 // getKeyboardMappingReply reads a byte slice into a GetKeyboardMappingReply value. 9582 func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { 9583 v := new(GetKeyboardMappingReply) 9584 b := 1 // skip reply determinant 9585 9586 v.KeysymsPerKeycode = buf[b] 9587 b += 1 9588 9589 v.Sequence = xgb.Get16(buf[b:]) 9590 b += 2 9591 9592 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9593 b += 4 9594 9595 b += 24 // padding 9596 9597 v.Keysyms = make([]Keysym, v.Length) 9598 for i := 0; i < int(v.Length); i++ { 9599 v.Keysyms[i] = Keysym(xgb.Get32(buf[b:])) 9600 b += 4 9601 } 9602 9603 return v 9604 } 9605 9606 // Write request to wire for GetKeyboardMapping 9607 // getKeyboardMappingRequest writes a GetKeyboardMapping request to a byte slice. 9608 func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte { 9609 size := 8 9610 b := 0 9611 buf := make([]byte, size) 9612 9613 buf[b] = 101 // request opcode 9614 b += 1 9615 9616 b += 1 // padding 9617 9618 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9619 b += 2 9620 9621 buf[b] = byte(FirstKeycode) 9622 b += 1 9623 9624 buf[b] = Count 9625 b += 1 9626 9627 return buf 9628 } 9629 9630 // GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. 9631 type GetModifierMappingCookie struct { 9632 *xgb.Cookie 9633 } 9634 9635 // GetModifierMapping sends a checked request. 9636 // If an error occurs, it will be returned with the reply by calling GetModifierMappingCookie.Reply() 9637 func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie { 9638 cookie := c.NewCookie(true, true) 9639 c.NewRequest(getModifierMappingRequest(c), cookie) 9640 return GetModifierMappingCookie{cookie} 9641 } 9642 9643 // GetModifierMappingUnchecked sends an unchecked request. 9644 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9645 func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { 9646 cookie := c.NewCookie(false, true) 9647 c.NewRequest(getModifierMappingRequest(c), cookie) 9648 return GetModifierMappingCookie{cookie} 9649 } 9650 9651 // GetModifierMappingReply represents the data returned from a GetModifierMapping request. 9652 type GetModifierMappingReply struct { 9653 Sequence uint16 // sequence number of the request for this reply 9654 Length uint32 // number of bytes in this reply 9655 KeycodesPerModifier byte 9656 // padding: 24 bytes 9657 Keycodes []Keycode // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) 9658 } 9659 9660 // Reply blocks and returns the reply data for a GetModifierMapping request. 9661 func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { 9662 buf, err := cook.Cookie.Reply() 9663 if err != nil { 9664 return nil, err 9665 } 9666 if buf == nil { 9667 return nil, nil 9668 } 9669 return getModifierMappingReply(buf), nil 9670 } 9671 9672 // getModifierMappingReply reads a byte slice into a GetModifierMappingReply value. 9673 func getModifierMappingReply(buf []byte) *GetModifierMappingReply { 9674 v := new(GetModifierMappingReply) 9675 b := 1 // skip reply determinant 9676 9677 v.KeycodesPerModifier = buf[b] 9678 b += 1 9679 9680 v.Sequence = xgb.Get16(buf[b:]) 9681 b += 2 9682 9683 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9684 b += 4 9685 9686 b += 24 // padding 9687 9688 v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) 9689 for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { 9690 v.Keycodes[i] = Keycode(buf[b]) 9691 b += 1 9692 } 9693 9694 return v 9695 } 9696 9697 // Write request to wire for GetModifierMapping 9698 // getModifierMappingRequest writes a GetModifierMapping request to a byte slice. 9699 func getModifierMappingRequest(c *xgb.Conn) []byte { 9700 size := 4 9701 b := 0 9702 buf := make([]byte, size) 9703 9704 buf[b] = 119 // request opcode 9705 b += 1 9706 9707 b += 1 // padding 9708 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9709 b += 2 9710 9711 return buf 9712 } 9713 9714 // GetMotionEventsCookie is a cookie used only for GetMotionEvents requests. 9715 type GetMotionEventsCookie struct { 9716 *xgb.Cookie 9717 } 9718 9719 // GetMotionEvents sends a checked request. 9720 // If an error occurs, it will be returned with the reply by calling GetMotionEventsCookie.Reply() 9721 func GetMotionEvents(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { 9722 cookie := c.NewCookie(true, true) 9723 c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) 9724 return GetMotionEventsCookie{cookie} 9725 } 9726 9727 // GetMotionEventsUnchecked sends an unchecked request. 9728 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9729 func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { 9730 cookie := c.NewCookie(false, true) 9731 c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) 9732 return GetMotionEventsCookie{cookie} 9733 } 9734 9735 // GetMotionEventsReply represents the data returned from a GetMotionEvents request. 9736 type GetMotionEventsReply struct { 9737 Sequence uint16 // sequence number of the request for this reply 9738 Length uint32 // number of bytes in this reply 9739 // padding: 1 bytes 9740 EventsLen uint32 9741 // padding: 20 bytes 9742 Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8)) 9743 } 9744 9745 // Reply blocks and returns the reply data for a GetMotionEvents request. 9746 func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { 9747 buf, err := cook.Cookie.Reply() 9748 if err != nil { 9749 return nil, err 9750 } 9751 if buf == nil { 9752 return nil, nil 9753 } 9754 return getMotionEventsReply(buf), nil 9755 } 9756 9757 // getMotionEventsReply reads a byte slice into a GetMotionEventsReply value. 9758 func getMotionEventsReply(buf []byte) *GetMotionEventsReply { 9759 v := new(GetMotionEventsReply) 9760 b := 1 // skip reply determinant 9761 9762 b += 1 // padding 9763 9764 v.Sequence = xgb.Get16(buf[b:]) 9765 b += 2 9766 9767 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9768 b += 4 9769 9770 v.EventsLen = xgb.Get32(buf[b:]) 9771 b += 4 9772 9773 b += 20 // padding 9774 9775 v.Events = make([]Timecoord, v.EventsLen) 9776 b += TimecoordReadList(buf[b:], v.Events) 9777 9778 return v 9779 } 9780 9781 // Write request to wire for GetMotionEvents 9782 // getMotionEventsRequest writes a GetMotionEvents request to a byte slice. 9783 func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) []byte { 9784 size := 16 9785 b := 0 9786 buf := make([]byte, size) 9787 9788 buf[b] = 39 // request opcode 9789 b += 1 9790 9791 b += 1 // padding 9792 9793 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9794 b += 2 9795 9796 xgb.Put32(buf[b:], uint32(Window)) 9797 b += 4 9798 9799 xgb.Put32(buf[b:], uint32(Start)) 9800 b += 4 9801 9802 xgb.Put32(buf[b:], uint32(Stop)) 9803 b += 4 9804 9805 return buf 9806 } 9807 9808 // GetPointerControlCookie is a cookie used only for GetPointerControl requests. 9809 type GetPointerControlCookie struct { 9810 *xgb.Cookie 9811 } 9812 9813 // GetPointerControl sends a checked request. 9814 // If an error occurs, it will be returned with the reply by calling GetPointerControlCookie.Reply() 9815 func GetPointerControl(c *xgb.Conn) GetPointerControlCookie { 9816 cookie := c.NewCookie(true, true) 9817 c.NewRequest(getPointerControlRequest(c), cookie) 9818 return GetPointerControlCookie{cookie} 9819 } 9820 9821 // GetPointerControlUnchecked sends an unchecked request. 9822 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9823 func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { 9824 cookie := c.NewCookie(false, true) 9825 c.NewRequest(getPointerControlRequest(c), cookie) 9826 return GetPointerControlCookie{cookie} 9827 } 9828 9829 // GetPointerControlReply represents the data returned from a GetPointerControl request. 9830 type GetPointerControlReply struct { 9831 Sequence uint16 // sequence number of the request for this reply 9832 Length uint32 // number of bytes in this reply 9833 // padding: 1 bytes 9834 AccelerationNumerator uint16 9835 AccelerationDenominator uint16 9836 Threshold uint16 9837 // padding: 18 bytes 9838 } 9839 9840 // Reply blocks and returns the reply data for a GetPointerControl request. 9841 func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { 9842 buf, err := cook.Cookie.Reply() 9843 if err != nil { 9844 return nil, err 9845 } 9846 if buf == nil { 9847 return nil, nil 9848 } 9849 return getPointerControlReply(buf), nil 9850 } 9851 9852 // getPointerControlReply reads a byte slice into a GetPointerControlReply value. 9853 func getPointerControlReply(buf []byte) *GetPointerControlReply { 9854 v := new(GetPointerControlReply) 9855 b := 1 // skip reply determinant 9856 9857 b += 1 // padding 9858 9859 v.Sequence = xgb.Get16(buf[b:]) 9860 b += 2 9861 9862 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9863 b += 4 9864 9865 v.AccelerationNumerator = xgb.Get16(buf[b:]) 9866 b += 2 9867 9868 v.AccelerationDenominator = xgb.Get16(buf[b:]) 9869 b += 2 9870 9871 v.Threshold = xgb.Get16(buf[b:]) 9872 b += 2 9873 9874 b += 18 // padding 9875 9876 return v 9877 } 9878 9879 // Write request to wire for GetPointerControl 9880 // getPointerControlRequest writes a GetPointerControl request to a byte slice. 9881 func getPointerControlRequest(c *xgb.Conn) []byte { 9882 size := 4 9883 b := 0 9884 buf := make([]byte, size) 9885 9886 buf[b] = 106 // request opcode 9887 b += 1 9888 9889 b += 1 // padding 9890 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9891 b += 2 9892 9893 return buf 9894 } 9895 9896 // GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. 9897 type GetPointerMappingCookie struct { 9898 *xgb.Cookie 9899 } 9900 9901 // GetPointerMapping sends a checked request. 9902 // If an error occurs, it will be returned with the reply by calling GetPointerMappingCookie.Reply() 9903 func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie { 9904 cookie := c.NewCookie(true, true) 9905 c.NewRequest(getPointerMappingRequest(c), cookie) 9906 return GetPointerMappingCookie{cookie} 9907 } 9908 9909 // GetPointerMappingUnchecked sends an unchecked request. 9910 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9911 func GetPointerMappingUnchecked(c *xgb.Conn) GetPointerMappingCookie { 9912 cookie := c.NewCookie(false, true) 9913 c.NewRequest(getPointerMappingRequest(c), cookie) 9914 return GetPointerMappingCookie{cookie} 9915 } 9916 9917 // GetPointerMappingReply represents the data returned from a GetPointerMapping request. 9918 type GetPointerMappingReply struct { 9919 Sequence uint16 // sequence number of the request for this reply 9920 Length uint32 // number of bytes in this reply 9921 MapLen byte 9922 // padding: 24 bytes 9923 Map []byte // size: xgb.Pad((int(MapLen) * 1)) 9924 } 9925 9926 // Reply blocks and returns the reply data for a GetPointerMapping request. 9927 func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { 9928 buf, err := cook.Cookie.Reply() 9929 if err != nil { 9930 return nil, err 9931 } 9932 if buf == nil { 9933 return nil, nil 9934 } 9935 return getPointerMappingReply(buf), nil 9936 } 9937 9938 // getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. 9939 func getPointerMappingReply(buf []byte) *GetPointerMappingReply { 9940 v := new(GetPointerMappingReply) 9941 b := 1 // skip reply determinant 9942 9943 v.MapLen = buf[b] 9944 b += 1 9945 9946 v.Sequence = xgb.Get16(buf[b:]) 9947 b += 2 9948 9949 v.Length = xgb.Get32(buf[b:]) // 4-byte units 9950 b += 4 9951 9952 b += 24 // padding 9953 9954 v.Map = make([]byte, v.MapLen) 9955 copy(v.Map[:v.MapLen], buf[b:]) 9956 b += int(v.MapLen) 9957 9958 return v 9959 } 9960 9961 // Write request to wire for GetPointerMapping 9962 // getPointerMappingRequest writes a GetPointerMapping request to a byte slice. 9963 func getPointerMappingRequest(c *xgb.Conn) []byte { 9964 size := 4 9965 b := 0 9966 buf := make([]byte, size) 9967 9968 buf[b] = 117 // request opcode 9969 b += 1 9970 9971 b += 1 // padding 9972 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 9973 b += 2 9974 9975 return buf 9976 } 9977 9978 // GetPropertyCookie is a cookie used only for GetProperty requests. 9979 type GetPropertyCookie struct { 9980 *xgb.Cookie 9981 } 9982 9983 // GetProperty sends a checked request. 9984 // If an error occurs, it will be returned with the reply by calling GetPropertyCookie.Reply() 9985 func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { 9986 cookie := c.NewCookie(true, true) 9987 c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) 9988 return GetPropertyCookie{cookie} 9989 } 9990 9991 // GetPropertyUnchecked sends an unchecked request. 9992 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 9993 func GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { 9994 cookie := c.NewCookie(false, true) 9995 c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) 9996 return GetPropertyCookie{cookie} 9997 } 9998 9999 // GetPropertyReply represents the data returned from a GetProperty request. 10000 type GetPropertyReply struct { 10001 Sequence uint16 // sequence number of the request for this reply 10002 Length uint32 // number of bytes in this reply 10003 Format byte 10004 Type Atom 10005 BytesAfter uint32 10006 ValueLen uint32 10007 // padding: 12 bytes 10008 Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1)) 10009 } 10010 10011 // Reply blocks and returns the reply data for a GetProperty request. 10012 func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { 10013 buf, err := cook.Cookie.Reply() 10014 if err != nil { 10015 return nil, err 10016 } 10017 if buf == nil { 10018 return nil, nil 10019 } 10020 return getPropertyReply(buf), nil 10021 } 10022 10023 // getPropertyReply reads a byte slice into a GetPropertyReply value. 10024 func getPropertyReply(buf []byte) *GetPropertyReply { 10025 v := new(GetPropertyReply) 10026 b := 1 // skip reply determinant 10027 10028 v.Format = buf[b] 10029 b += 1 10030 10031 v.Sequence = xgb.Get16(buf[b:]) 10032 b += 2 10033 10034 v.Length = xgb.Get32(buf[b:]) // 4-byte units 10035 b += 4 10036 10037 v.Type = Atom(xgb.Get32(buf[b:])) 10038 b += 4 10039 10040 v.BytesAfter = xgb.Get32(buf[b:]) 10041 b += 4 10042 10043 v.ValueLen = xgb.Get32(buf[b:]) 10044 b += 4 10045 10046 b += 12 // padding 10047 10048 v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) 10049 copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) 10050 b += int((int(v.ValueLen) * (int(v.Format) / 8))) 10051 10052 return v 10053 } 10054 10055 // Write request to wire for GetProperty 10056 // getPropertyRequest writes a GetProperty request to a byte slice. 10057 func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { 10058 size := 24 10059 b := 0 10060 buf := make([]byte, size) 10061 10062 buf[b] = 20 // request opcode 10063 b += 1 10064 10065 if Delete { 10066 buf[b] = 1 10067 } else { 10068 buf[b] = 0 10069 } 10070 b += 1 10071 10072 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10073 b += 2 10074 10075 xgb.Put32(buf[b:], uint32(Window)) 10076 b += 4 10077 10078 xgb.Put32(buf[b:], uint32(Property)) 10079 b += 4 10080 10081 xgb.Put32(buf[b:], uint32(Type)) 10082 b += 4 10083 10084 xgb.Put32(buf[b:], LongOffset) 10085 b += 4 10086 10087 xgb.Put32(buf[b:], LongLength) 10088 b += 4 10089 10090 return buf 10091 } 10092 10093 // GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. 10094 type GetScreenSaverCookie struct { 10095 *xgb.Cookie 10096 } 10097 10098 // GetScreenSaver sends a checked request. 10099 // If an error occurs, it will be returned with the reply by calling GetScreenSaverCookie.Reply() 10100 func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie { 10101 cookie := c.NewCookie(true, true) 10102 c.NewRequest(getScreenSaverRequest(c), cookie) 10103 return GetScreenSaverCookie{cookie} 10104 } 10105 10106 // GetScreenSaverUnchecked sends an unchecked request. 10107 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10108 func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { 10109 cookie := c.NewCookie(false, true) 10110 c.NewRequest(getScreenSaverRequest(c), cookie) 10111 return GetScreenSaverCookie{cookie} 10112 } 10113 10114 // GetScreenSaverReply represents the data returned from a GetScreenSaver request. 10115 type GetScreenSaverReply struct { 10116 Sequence uint16 // sequence number of the request for this reply 10117 Length uint32 // number of bytes in this reply 10118 // padding: 1 bytes 10119 Timeout uint16 10120 Interval uint16 10121 PreferBlanking byte 10122 AllowExposures byte 10123 // padding: 18 bytes 10124 } 10125 10126 // Reply blocks and returns the reply data for a GetScreenSaver request. 10127 func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { 10128 buf, err := cook.Cookie.Reply() 10129 if err != nil { 10130 return nil, err 10131 } 10132 if buf == nil { 10133 return nil, nil 10134 } 10135 return getScreenSaverReply(buf), nil 10136 } 10137 10138 // getScreenSaverReply reads a byte slice into a GetScreenSaverReply value. 10139 func getScreenSaverReply(buf []byte) *GetScreenSaverReply { 10140 v := new(GetScreenSaverReply) 10141 b := 1 // skip reply determinant 10142 10143 b += 1 // padding 10144 10145 v.Sequence = xgb.Get16(buf[b:]) 10146 b += 2 10147 10148 v.Length = xgb.Get32(buf[b:]) // 4-byte units 10149 b += 4 10150 10151 v.Timeout = xgb.Get16(buf[b:]) 10152 b += 2 10153 10154 v.Interval = xgb.Get16(buf[b:]) 10155 b += 2 10156 10157 v.PreferBlanking = buf[b] 10158 b += 1 10159 10160 v.AllowExposures = buf[b] 10161 b += 1 10162 10163 b += 18 // padding 10164 10165 return v 10166 } 10167 10168 // Write request to wire for GetScreenSaver 10169 // getScreenSaverRequest writes a GetScreenSaver request to a byte slice. 10170 func getScreenSaverRequest(c *xgb.Conn) []byte { 10171 size := 4 10172 b := 0 10173 buf := make([]byte, size) 10174 10175 buf[b] = 108 // request opcode 10176 b += 1 10177 10178 b += 1 // padding 10179 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10180 b += 2 10181 10182 return buf 10183 } 10184 10185 // GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. 10186 type GetSelectionOwnerCookie struct { 10187 *xgb.Cookie 10188 } 10189 10190 // GetSelectionOwner sends a checked request. 10191 // If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply() 10192 func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { 10193 cookie := c.NewCookie(true, true) 10194 c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) 10195 return GetSelectionOwnerCookie{cookie} 10196 } 10197 10198 // GetSelectionOwnerUnchecked sends an unchecked request. 10199 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10200 func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { 10201 cookie := c.NewCookie(false, true) 10202 c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) 10203 return GetSelectionOwnerCookie{cookie} 10204 } 10205 10206 // GetSelectionOwnerReply represents the data returned from a GetSelectionOwner request. 10207 type GetSelectionOwnerReply struct { 10208 Sequence uint16 // sequence number of the request for this reply 10209 Length uint32 // number of bytes in this reply 10210 // padding: 1 bytes 10211 Owner Window 10212 } 10213 10214 // Reply blocks and returns the reply data for a GetSelectionOwner request. 10215 func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { 10216 buf, err := cook.Cookie.Reply() 10217 if err != nil { 10218 return nil, err 10219 } 10220 if buf == nil { 10221 return nil, nil 10222 } 10223 return getSelectionOwnerReply(buf), nil 10224 } 10225 10226 // getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. 10227 func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { 10228 v := new(GetSelectionOwnerReply) 10229 b := 1 // skip reply determinant 10230 10231 b += 1 // padding 10232 10233 v.Sequence = xgb.Get16(buf[b:]) 10234 b += 2 10235 10236 v.Length = xgb.Get32(buf[b:]) // 4-byte units 10237 b += 4 10238 10239 v.Owner = Window(xgb.Get32(buf[b:])) 10240 b += 4 10241 10242 return v 10243 } 10244 10245 // Write request to wire for GetSelectionOwner 10246 // getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice. 10247 func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { 10248 size := 8 10249 b := 0 10250 buf := make([]byte, size) 10251 10252 buf[b] = 23 // request opcode 10253 b += 1 10254 10255 b += 1 // padding 10256 10257 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10258 b += 2 10259 10260 xgb.Put32(buf[b:], uint32(Selection)) 10261 b += 4 10262 10263 return buf 10264 } 10265 10266 // GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. 10267 type GetWindowAttributesCookie struct { 10268 *xgb.Cookie 10269 } 10270 10271 // GetWindowAttributes sends a checked request. 10272 // If an error occurs, it will be returned with the reply by calling GetWindowAttributesCookie.Reply() 10273 func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie { 10274 cookie := c.NewCookie(true, true) 10275 c.NewRequest(getWindowAttributesRequest(c, Window), cookie) 10276 return GetWindowAttributesCookie{cookie} 10277 } 10278 10279 // GetWindowAttributesUnchecked sends an unchecked request. 10280 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10281 func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { 10282 cookie := c.NewCookie(false, true) 10283 c.NewRequest(getWindowAttributesRequest(c, Window), cookie) 10284 return GetWindowAttributesCookie{cookie} 10285 } 10286 10287 // GetWindowAttributesReply represents the data returned from a GetWindowAttributes request. 10288 type GetWindowAttributesReply struct { 10289 Sequence uint16 // sequence number of the request for this reply 10290 Length uint32 // number of bytes in this reply 10291 BackingStore byte 10292 Visual Visualid 10293 Class uint16 10294 BitGravity byte 10295 WinGravity byte 10296 BackingPlanes uint32 10297 BackingPixel uint32 10298 SaveUnder bool 10299 MapIsInstalled bool 10300 MapState byte 10301 OverrideRedirect bool 10302 Colormap Colormap 10303 AllEventMasks uint32 10304 YourEventMask uint32 10305 DoNotPropagateMask uint16 10306 // padding: 2 bytes 10307 } 10308 10309 // Reply blocks and returns the reply data for a GetWindowAttributes request. 10310 func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { 10311 buf, err := cook.Cookie.Reply() 10312 if err != nil { 10313 return nil, err 10314 } 10315 if buf == nil { 10316 return nil, nil 10317 } 10318 return getWindowAttributesReply(buf), nil 10319 } 10320 10321 // getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value. 10322 func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { 10323 v := new(GetWindowAttributesReply) 10324 b := 1 // skip reply determinant 10325 10326 v.BackingStore = buf[b] 10327 b += 1 10328 10329 v.Sequence = xgb.Get16(buf[b:]) 10330 b += 2 10331 10332 v.Length = xgb.Get32(buf[b:]) // 4-byte units 10333 b += 4 10334 10335 v.Visual = Visualid(xgb.Get32(buf[b:])) 10336 b += 4 10337 10338 v.Class = xgb.Get16(buf[b:]) 10339 b += 2 10340 10341 v.BitGravity = buf[b] 10342 b += 1 10343 10344 v.WinGravity = buf[b] 10345 b += 1 10346 10347 v.BackingPlanes = xgb.Get32(buf[b:]) 10348 b += 4 10349 10350 v.BackingPixel = xgb.Get32(buf[b:]) 10351 b += 4 10352 10353 if buf[b] == 1 { 10354 v.SaveUnder = true 10355 } else { 10356 v.SaveUnder = false 10357 } 10358 b += 1 10359 10360 if buf[b] == 1 { 10361 v.MapIsInstalled = true 10362 } else { 10363 v.MapIsInstalled = false 10364 } 10365 b += 1 10366 10367 v.MapState = buf[b] 10368 b += 1 10369 10370 if buf[b] == 1 { 10371 v.OverrideRedirect = true 10372 } else { 10373 v.OverrideRedirect = false 10374 } 10375 b += 1 10376 10377 v.Colormap = Colormap(xgb.Get32(buf[b:])) 10378 b += 4 10379 10380 v.AllEventMasks = xgb.Get32(buf[b:]) 10381 b += 4 10382 10383 v.YourEventMask = xgb.Get32(buf[b:]) 10384 b += 4 10385 10386 v.DoNotPropagateMask = xgb.Get16(buf[b:]) 10387 b += 2 10388 10389 b += 2 // padding 10390 10391 return v 10392 } 10393 10394 // Write request to wire for GetWindowAttributes 10395 // getWindowAttributesRequest writes a GetWindowAttributes request to a byte slice. 10396 func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { 10397 size := 8 10398 b := 0 10399 buf := make([]byte, size) 10400 10401 buf[b] = 3 // request opcode 10402 b += 1 10403 10404 b += 1 // padding 10405 10406 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10407 b += 2 10408 10409 xgb.Put32(buf[b:], uint32(Window)) 10410 b += 4 10411 10412 return buf 10413 } 10414 10415 // GrabButtonCookie is a cookie used only for GrabButton requests. 10416 type GrabButtonCookie struct { 10417 *xgb.Cookie 10418 } 10419 10420 // GrabButton sends an unchecked request. 10421 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10422 func GrabButton(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { 10423 cookie := c.NewCookie(false, false) 10424 c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) 10425 return GrabButtonCookie{cookie} 10426 } 10427 10428 // GrabButtonChecked sends a checked request. 10429 // If an error occurs, it can be retrieved using GrabButtonCookie.Check() 10430 func GrabButtonChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { 10431 cookie := c.NewCookie(true, false) 10432 c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) 10433 return GrabButtonCookie{cookie} 10434 } 10435 10436 // Check returns an error if one occurred for checked requests that are not expecting a reply. 10437 // This cannot be called for requests expecting a reply, nor for unchecked requests. 10438 func (cook GrabButtonCookie) Check() error { 10439 return cook.Cookie.Check() 10440 } 10441 10442 // Write request to wire for GrabButton 10443 // grabButtonRequest writes a GrabButton request to a byte slice. 10444 func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { 10445 size := 24 10446 b := 0 10447 buf := make([]byte, size) 10448 10449 buf[b] = 28 // request opcode 10450 b += 1 10451 10452 if OwnerEvents { 10453 buf[b] = 1 10454 } else { 10455 buf[b] = 0 10456 } 10457 b += 1 10458 10459 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10460 b += 2 10461 10462 xgb.Put32(buf[b:], uint32(GrabWindow)) 10463 b += 4 10464 10465 xgb.Put16(buf[b:], EventMask) 10466 b += 2 10467 10468 buf[b] = PointerMode 10469 b += 1 10470 10471 buf[b] = KeyboardMode 10472 b += 1 10473 10474 xgb.Put32(buf[b:], uint32(ConfineTo)) 10475 b += 4 10476 10477 xgb.Put32(buf[b:], uint32(Cursor)) 10478 b += 4 10479 10480 buf[b] = Button 10481 b += 1 10482 10483 b += 1 // padding 10484 10485 xgb.Put16(buf[b:], Modifiers) 10486 b += 2 10487 10488 return buf 10489 } 10490 10491 // GrabKeyCookie is a cookie used only for GrabKey requests. 10492 type GrabKeyCookie struct { 10493 *xgb.Cookie 10494 } 10495 10496 // GrabKey sends an unchecked request. 10497 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10498 func GrabKey(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { 10499 cookie := c.NewCookie(false, false) 10500 c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) 10501 return GrabKeyCookie{cookie} 10502 } 10503 10504 // GrabKeyChecked sends a checked request. 10505 // If an error occurs, it can be retrieved using GrabKeyCookie.Check() 10506 func GrabKeyChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { 10507 cookie := c.NewCookie(true, false) 10508 c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) 10509 return GrabKeyCookie{cookie} 10510 } 10511 10512 // Check returns an error if one occurred for checked requests that are not expecting a reply. 10513 // This cannot be called for requests expecting a reply, nor for unchecked requests. 10514 func (cook GrabKeyCookie) Check() error { 10515 return cook.Cookie.Check() 10516 } 10517 10518 // Write request to wire for GrabKey 10519 // grabKeyRequest writes a GrabKey request to a byte slice. 10520 func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { 10521 size := 16 10522 b := 0 10523 buf := make([]byte, size) 10524 10525 buf[b] = 33 // request opcode 10526 b += 1 10527 10528 if OwnerEvents { 10529 buf[b] = 1 10530 } else { 10531 buf[b] = 0 10532 } 10533 b += 1 10534 10535 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10536 b += 2 10537 10538 xgb.Put32(buf[b:], uint32(GrabWindow)) 10539 b += 4 10540 10541 xgb.Put16(buf[b:], Modifiers) 10542 b += 2 10543 10544 buf[b] = byte(Key) 10545 b += 1 10546 10547 buf[b] = PointerMode 10548 b += 1 10549 10550 buf[b] = KeyboardMode 10551 b += 1 10552 10553 b += 3 // padding 10554 10555 return buf 10556 } 10557 10558 // GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. 10559 type GrabKeyboardCookie struct { 10560 *xgb.Cookie 10561 } 10562 10563 // GrabKeyboard sends a checked request. 10564 // If an error occurs, it will be returned with the reply by calling GrabKeyboardCookie.Reply() 10565 func GrabKeyboard(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { 10566 cookie := c.NewCookie(true, true) 10567 c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) 10568 return GrabKeyboardCookie{cookie} 10569 } 10570 10571 // GrabKeyboardUnchecked sends an unchecked request. 10572 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10573 func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { 10574 cookie := c.NewCookie(false, true) 10575 c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) 10576 return GrabKeyboardCookie{cookie} 10577 } 10578 10579 // GrabKeyboardReply represents the data returned from a GrabKeyboard request. 10580 type GrabKeyboardReply struct { 10581 Sequence uint16 // sequence number of the request for this reply 10582 Length uint32 // number of bytes in this reply 10583 Status byte 10584 } 10585 10586 // Reply blocks and returns the reply data for a GrabKeyboard request. 10587 func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { 10588 buf, err := cook.Cookie.Reply() 10589 if err != nil { 10590 return nil, err 10591 } 10592 if buf == nil { 10593 return nil, nil 10594 } 10595 return grabKeyboardReply(buf), nil 10596 } 10597 10598 // grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. 10599 func grabKeyboardReply(buf []byte) *GrabKeyboardReply { 10600 v := new(GrabKeyboardReply) 10601 b := 1 // skip reply determinant 10602 10603 v.Status = buf[b] 10604 b += 1 10605 10606 v.Sequence = xgb.Get16(buf[b:]) 10607 b += 2 10608 10609 v.Length = xgb.Get32(buf[b:]) // 4-byte units 10610 b += 4 10611 10612 return v 10613 } 10614 10615 // Write request to wire for GrabKeyboard 10616 // grabKeyboardRequest writes a GrabKeyboard request to a byte slice. 10617 func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { 10618 size := 16 10619 b := 0 10620 buf := make([]byte, size) 10621 10622 buf[b] = 31 // request opcode 10623 b += 1 10624 10625 if OwnerEvents { 10626 buf[b] = 1 10627 } else { 10628 buf[b] = 0 10629 } 10630 b += 1 10631 10632 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10633 b += 2 10634 10635 xgb.Put32(buf[b:], uint32(GrabWindow)) 10636 b += 4 10637 10638 xgb.Put32(buf[b:], uint32(Time)) 10639 b += 4 10640 10641 buf[b] = PointerMode 10642 b += 1 10643 10644 buf[b] = KeyboardMode 10645 b += 1 10646 10647 b += 2 // padding 10648 10649 return buf 10650 } 10651 10652 // GrabPointerCookie is a cookie used only for GrabPointer requests. 10653 type GrabPointerCookie struct { 10654 *xgb.Cookie 10655 } 10656 10657 // GrabPointer sends a checked request. 10658 // If an error occurs, it will be returned with the reply by calling GrabPointerCookie.Reply() 10659 func GrabPointer(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { 10660 cookie := c.NewCookie(true, true) 10661 c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) 10662 return GrabPointerCookie{cookie} 10663 } 10664 10665 // GrabPointerUnchecked sends an unchecked request. 10666 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10667 func GrabPointerUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { 10668 cookie := c.NewCookie(false, true) 10669 c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) 10670 return GrabPointerCookie{cookie} 10671 } 10672 10673 // GrabPointerReply represents the data returned from a GrabPointer request. 10674 type GrabPointerReply struct { 10675 Sequence uint16 // sequence number of the request for this reply 10676 Length uint32 // number of bytes in this reply 10677 Status byte 10678 } 10679 10680 // Reply blocks and returns the reply data for a GrabPointer request. 10681 func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { 10682 buf, err := cook.Cookie.Reply() 10683 if err != nil { 10684 return nil, err 10685 } 10686 if buf == nil { 10687 return nil, nil 10688 } 10689 return grabPointerReply(buf), nil 10690 } 10691 10692 // grabPointerReply reads a byte slice into a GrabPointerReply value. 10693 func grabPointerReply(buf []byte) *GrabPointerReply { 10694 v := new(GrabPointerReply) 10695 b := 1 // skip reply determinant 10696 10697 v.Status = buf[b] 10698 b += 1 10699 10700 v.Sequence = xgb.Get16(buf[b:]) 10701 b += 2 10702 10703 v.Length = xgb.Get32(buf[b:]) // 4-byte units 10704 b += 4 10705 10706 return v 10707 } 10708 10709 // Write request to wire for GrabPointer 10710 // grabPointerRequest writes a GrabPointer request to a byte slice. 10711 func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { 10712 size := 24 10713 b := 0 10714 buf := make([]byte, size) 10715 10716 buf[b] = 26 // request opcode 10717 b += 1 10718 10719 if OwnerEvents { 10720 buf[b] = 1 10721 } else { 10722 buf[b] = 0 10723 } 10724 b += 1 10725 10726 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10727 b += 2 10728 10729 xgb.Put32(buf[b:], uint32(GrabWindow)) 10730 b += 4 10731 10732 xgb.Put16(buf[b:], EventMask) 10733 b += 2 10734 10735 buf[b] = PointerMode 10736 b += 1 10737 10738 buf[b] = KeyboardMode 10739 b += 1 10740 10741 xgb.Put32(buf[b:], uint32(ConfineTo)) 10742 b += 4 10743 10744 xgb.Put32(buf[b:], uint32(Cursor)) 10745 b += 4 10746 10747 xgb.Put32(buf[b:], uint32(Time)) 10748 b += 4 10749 10750 return buf 10751 } 10752 10753 // GrabServerCookie is a cookie used only for GrabServer requests. 10754 type GrabServerCookie struct { 10755 *xgb.Cookie 10756 } 10757 10758 // GrabServer sends an unchecked request. 10759 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10760 func GrabServer(c *xgb.Conn) GrabServerCookie { 10761 cookie := c.NewCookie(false, false) 10762 c.NewRequest(grabServerRequest(c), cookie) 10763 return GrabServerCookie{cookie} 10764 } 10765 10766 // GrabServerChecked sends a checked request. 10767 // If an error occurs, it can be retrieved using GrabServerCookie.Check() 10768 func GrabServerChecked(c *xgb.Conn) GrabServerCookie { 10769 cookie := c.NewCookie(true, false) 10770 c.NewRequest(grabServerRequest(c), cookie) 10771 return GrabServerCookie{cookie} 10772 } 10773 10774 // Check returns an error if one occurred for checked requests that are not expecting a reply. 10775 // This cannot be called for requests expecting a reply, nor for unchecked requests. 10776 func (cook GrabServerCookie) Check() error { 10777 return cook.Cookie.Check() 10778 } 10779 10780 // Write request to wire for GrabServer 10781 // grabServerRequest writes a GrabServer request to a byte slice. 10782 func grabServerRequest(c *xgb.Conn) []byte { 10783 size := 4 10784 b := 0 10785 buf := make([]byte, size) 10786 10787 buf[b] = 36 // request opcode 10788 b += 1 10789 10790 b += 1 // padding 10791 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10792 b += 2 10793 10794 return buf 10795 } 10796 10797 // ImageText16Cookie is a cookie used only for ImageText16 requests. 10798 type ImageText16Cookie struct { 10799 *xgb.Cookie 10800 } 10801 10802 // ImageText16 sends an unchecked request. 10803 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10804 func ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { 10805 cookie := c.NewCookie(false, false) 10806 c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) 10807 return ImageText16Cookie{cookie} 10808 } 10809 10810 // ImageText16Checked sends a checked request. 10811 // If an error occurs, it can be retrieved using ImageText16Cookie.Check() 10812 func ImageText16Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { 10813 cookie := c.NewCookie(true, false) 10814 c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) 10815 return ImageText16Cookie{cookie} 10816 } 10817 10818 // Check returns an error if one occurred for checked requests that are not expecting a reply. 10819 // This cannot be called for requests expecting a reply, nor for unchecked requests. 10820 func (cook ImageText16Cookie) Check() error { 10821 return cook.Cookie.Check() 10822 } 10823 10824 // Write request to wire for ImageText16 10825 // imageText16Request writes a ImageText16 request to a byte slice. 10826 func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { 10827 size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) 10828 b := 0 10829 buf := make([]byte, size) 10830 10831 buf[b] = 77 // request opcode 10832 b += 1 10833 10834 buf[b] = StringLen 10835 b += 1 10836 10837 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10838 b += 2 10839 10840 xgb.Put32(buf[b:], uint32(Drawable)) 10841 b += 4 10842 10843 xgb.Put32(buf[b:], uint32(Gc)) 10844 b += 4 10845 10846 xgb.Put16(buf[b:], uint16(X)) 10847 b += 2 10848 10849 xgb.Put16(buf[b:], uint16(Y)) 10850 b += 2 10851 10852 b += Char2bListBytes(buf[b:], String) 10853 10854 return buf 10855 } 10856 10857 // ImageText8Cookie is a cookie used only for ImageText8 requests. 10858 type ImageText8Cookie struct { 10859 *xgb.Cookie 10860 } 10861 10862 // ImageText8 sends an unchecked request. 10863 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10864 func ImageText8(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { 10865 cookie := c.NewCookie(false, false) 10866 c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) 10867 return ImageText8Cookie{cookie} 10868 } 10869 10870 // ImageText8Checked sends a checked request. 10871 // If an error occurs, it can be retrieved using ImageText8Cookie.Check() 10872 func ImageText8Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { 10873 cookie := c.NewCookie(true, false) 10874 c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) 10875 return ImageText8Cookie{cookie} 10876 } 10877 10878 // Check returns an error if one occurred for checked requests that are not expecting a reply. 10879 // This cannot be called for requests expecting a reply, nor for unchecked requests. 10880 func (cook ImageText8Cookie) Check() error { 10881 return cook.Cookie.Check() 10882 } 10883 10884 // Write request to wire for ImageText8 10885 // imageText8Request writes a ImageText8 request to a byte slice. 10886 func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { 10887 size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) 10888 b := 0 10889 buf := make([]byte, size) 10890 10891 buf[b] = 76 // request opcode 10892 b += 1 10893 10894 buf[b] = StringLen 10895 b += 1 10896 10897 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10898 b += 2 10899 10900 xgb.Put32(buf[b:], uint32(Drawable)) 10901 b += 4 10902 10903 xgb.Put32(buf[b:], uint32(Gc)) 10904 b += 4 10905 10906 xgb.Put16(buf[b:], uint16(X)) 10907 b += 2 10908 10909 xgb.Put16(buf[b:], uint16(Y)) 10910 b += 2 10911 10912 copy(buf[b:], String[:StringLen]) 10913 b += int(StringLen) 10914 10915 return buf 10916 } 10917 10918 // InstallColormapCookie is a cookie used only for InstallColormap requests. 10919 type InstallColormapCookie struct { 10920 *xgb.Cookie 10921 } 10922 10923 // InstallColormap sends an unchecked request. 10924 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10925 func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { 10926 cookie := c.NewCookie(false, false) 10927 c.NewRequest(installColormapRequest(c, Cmap), cookie) 10928 return InstallColormapCookie{cookie} 10929 } 10930 10931 // InstallColormapChecked sends a checked request. 10932 // If an error occurs, it can be retrieved using InstallColormapCookie.Check() 10933 func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { 10934 cookie := c.NewCookie(true, false) 10935 c.NewRequest(installColormapRequest(c, Cmap), cookie) 10936 return InstallColormapCookie{cookie} 10937 } 10938 10939 // Check returns an error if one occurred for checked requests that are not expecting a reply. 10940 // This cannot be called for requests expecting a reply, nor for unchecked requests. 10941 func (cook InstallColormapCookie) Check() error { 10942 return cook.Cookie.Check() 10943 } 10944 10945 // Write request to wire for InstallColormap 10946 // installColormapRequest writes a InstallColormap request to a byte slice. 10947 func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { 10948 size := 8 10949 b := 0 10950 buf := make([]byte, size) 10951 10952 buf[b] = 81 // request opcode 10953 b += 1 10954 10955 b += 1 // padding 10956 10957 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 10958 b += 2 10959 10960 xgb.Put32(buf[b:], uint32(Cmap)) 10961 b += 4 10962 10963 return buf 10964 } 10965 10966 // InternAtomCookie is a cookie used only for InternAtom requests. 10967 type InternAtomCookie struct { 10968 *xgb.Cookie 10969 } 10970 10971 // InternAtom sends a checked request. 10972 // If an error occurs, it will be returned with the reply by calling InternAtomCookie.Reply() 10973 func InternAtom(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { 10974 cookie := c.NewCookie(true, true) 10975 c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) 10976 return InternAtomCookie{cookie} 10977 } 10978 10979 // InternAtomUnchecked sends an unchecked request. 10980 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 10981 func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { 10982 cookie := c.NewCookie(false, true) 10983 c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) 10984 return InternAtomCookie{cookie} 10985 } 10986 10987 // InternAtomReply represents the data returned from a InternAtom request. 10988 type InternAtomReply struct { 10989 Sequence uint16 // sequence number of the request for this reply 10990 Length uint32 // number of bytes in this reply 10991 // padding: 1 bytes 10992 Atom Atom 10993 } 10994 10995 // Reply blocks and returns the reply data for a InternAtom request. 10996 func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { 10997 buf, err := cook.Cookie.Reply() 10998 if err != nil { 10999 return nil, err 11000 } 11001 if buf == nil { 11002 return nil, nil 11003 } 11004 return internAtomReply(buf), nil 11005 } 11006 11007 // internAtomReply reads a byte slice into a InternAtomReply value. 11008 func internAtomReply(buf []byte) *InternAtomReply { 11009 v := new(InternAtomReply) 11010 b := 1 // skip reply determinant 11011 11012 b += 1 // padding 11013 11014 v.Sequence = xgb.Get16(buf[b:]) 11015 b += 2 11016 11017 v.Length = xgb.Get32(buf[b:]) // 4-byte units 11018 b += 4 11019 11020 v.Atom = Atom(xgb.Get32(buf[b:])) 11021 b += 4 11022 11023 return v 11024 } 11025 11026 // Write request to wire for InternAtom 11027 // internAtomRequest writes a InternAtom request to a byte slice. 11028 func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) []byte { 11029 size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) 11030 b := 0 11031 buf := make([]byte, size) 11032 11033 buf[b] = 16 // request opcode 11034 b += 1 11035 11036 if OnlyIfExists { 11037 buf[b] = 1 11038 } else { 11039 buf[b] = 0 11040 } 11041 b += 1 11042 11043 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11044 b += 2 11045 11046 xgb.Put16(buf[b:], NameLen) 11047 b += 2 11048 11049 b += 2 // padding 11050 11051 copy(buf[b:], Name[:NameLen]) 11052 b += int(NameLen) 11053 11054 return buf 11055 } 11056 11057 // KillClientCookie is a cookie used only for KillClient requests. 11058 type KillClientCookie struct { 11059 *xgb.Cookie 11060 } 11061 11062 // KillClient sends an unchecked request. 11063 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11064 func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { 11065 cookie := c.NewCookie(false, false) 11066 c.NewRequest(killClientRequest(c, Resource), cookie) 11067 return KillClientCookie{cookie} 11068 } 11069 11070 // KillClientChecked sends a checked request. 11071 // If an error occurs, it can be retrieved using KillClientCookie.Check() 11072 func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { 11073 cookie := c.NewCookie(true, false) 11074 c.NewRequest(killClientRequest(c, Resource), cookie) 11075 return KillClientCookie{cookie} 11076 } 11077 11078 // Check returns an error if one occurred for checked requests that are not expecting a reply. 11079 // This cannot be called for requests expecting a reply, nor for unchecked requests. 11080 func (cook KillClientCookie) Check() error { 11081 return cook.Cookie.Check() 11082 } 11083 11084 // Write request to wire for KillClient 11085 // killClientRequest writes a KillClient request to a byte slice. 11086 func killClientRequest(c *xgb.Conn, Resource uint32) []byte { 11087 size := 8 11088 b := 0 11089 buf := make([]byte, size) 11090 11091 buf[b] = 113 // request opcode 11092 b += 1 11093 11094 b += 1 // padding 11095 11096 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11097 b += 2 11098 11099 xgb.Put32(buf[b:], Resource) 11100 b += 4 11101 11102 return buf 11103 } 11104 11105 // ListExtensionsCookie is a cookie used only for ListExtensions requests. 11106 type ListExtensionsCookie struct { 11107 *xgb.Cookie 11108 } 11109 11110 // ListExtensions sends a checked request. 11111 // If an error occurs, it will be returned with the reply by calling ListExtensionsCookie.Reply() 11112 func ListExtensions(c *xgb.Conn) ListExtensionsCookie { 11113 cookie := c.NewCookie(true, true) 11114 c.NewRequest(listExtensionsRequest(c), cookie) 11115 return ListExtensionsCookie{cookie} 11116 } 11117 11118 // ListExtensionsUnchecked sends an unchecked request. 11119 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11120 func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { 11121 cookie := c.NewCookie(false, true) 11122 c.NewRequest(listExtensionsRequest(c), cookie) 11123 return ListExtensionsCookie{cookie} 11124 } 11125 11126 // ListExtensionsReply represents the data returned from a ListExtensions request. 11127 type ListExtensionsReply struct { 11128 Sequence uint16 // sequence number of the request for this reply 11129 Length uint32 // number of bytes in this reply 11130 NamesLen byte 11131 // padding: 24 bytes 11132 Names []Str // size: StrListSize(Names) 11133 } 11134 11135 // Reply blocks and returns the reply data for a ListExtensions request. 11136 func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { 11137 buf, err := cook.Cookie.Reply() 11138 if err != nil { 11139 return nil, err 11140 } 11141 if buf == nil { 11142 return nil, nil 11143 } 11144 return listExtensionsReply(buf), nil 11145 } 11146 11147 // listExtensionsReply reads a byte slice into a ListExtensionsReply value. 11148 func listExtensionsReply(buf []byte) *ListExtensionsReply { 11149 v := new(ListExtensionsReply) 11150 b := 1 // skip reply determinant 11151 11152 v.NamesLen = buf[b] 11153 b += 1 11154 11155 v.Sequence = xgb.Get16(buf[b:]) 11156 b += 2 11157 11158 v.Length = xgb.Get32(buf[b:]) // 4-byte units 11159 b += 4 11160 11161 b += 24 // padding 11162 11163 v.Names = make([]Str, v.NamesLen) 11164 b += StrReadList(buf[b:], v.Names) 11165 11166 return v 11167 } 11168 11169 // Write request to wire for ListExtensions 11170 // listExtensionsRequest writes a ListExtensions request to a byte slice. 11171 func listExtensionsRequest(c *xgb.Conn) []byte { 11172 size := 4 11173 b := 0 11174 buf := make([]byte, size) 11175 11176 buf[b] = 99 // request opcode 11177 b += 1 11178 11179 b += 1 // padding 11180 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11181 b += 2 11182 11183 return buf 11184 } 11185 11186 // ListFontsCookie is a cookie used only for ListFonts requests. 11187 type ListFontsCookie struct { 11188 *xgb.Cookie 11189 } 11190 11191 // ListFonts sends a checked request. 11192 // If an error occurs, it will be returned with the reply by calling ListFontsCookie.Reply() 11193 func ListFonts(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { 11194 cookie := c.NewCookie(true, true) 11195 c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) 11196 return ListFontsCookie{cookie} 11197 } 11198 11199 // ListFontsUnchecked sends an unchecked request. 11200 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11201 func ListFontsUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { 11202 cookie := c.NewCookie(false, true) 11203 c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) 11204 return ListFontsCookie{cookie} 11205 } 11206 11207 // ListFontsReply represents the data returned from a ListFonts request. 11208 type ListFontsReply struct { 11209 Sequence uint16 // sequence number of the request for this reply 11210 Length uint32 // number of bytes in this reply 11211 // padding: 1 bytes 11212 NamesLen uint16 11213 // padding: 22 bytes 11214 Names []Str // size: StrListSize(Names) 11215 } 11216 11217 // Reply blocks and returns the reply data for a ListFonts request. 11218 func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { 11219 buf, err := cook.Cookie.Reply() 11220 if err != nil { 11221 return nil, err 11222 } 11223 if buf == nil { 11224 return nil, nil 11225 } 11226 return listFontsReply(buf), nil 11227 } 11228 11229 // listFontsReply reads a byte slice into a ListFontsReply value. 11230 func listFontsReply(buf []byte) *ListFontsReply { 11231 v := new(ListFontsReply) 11232 b := 1 // skip reply determinant 11233 11234 b += 1 // padding 11235 11236 v.Sequence = xgb.Get16(buf[b:]) 11237 b += 2 11238 11239 v.Length = xgb.Get32(buf[b:]) // 4-byte units 11240 b += 4 11241 11242 v.NamesLen = xgb.Get16(buf[b:]) 11243 b += 2 11244 11245 b += 22 // padding 11246 11247 v.Names = make([]Str, v.NamesLen) 11248 b += StrReadList(buf[b:], v.Names) 11249 11250 return v 11251 } 11252 11253 // Write request to wire for ListFonts 11254 // listFontsRequest writes a ListFonts request to a byte slice. 11255 func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { 11256 size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) 11257 b := 0 11258 buf := make([]byte, size) 11259 11260 buf[b] = 49 // request opcode 11261 b += 1 11262 11263 b += 1 // padding 11264 11265 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11266 b += 2 11267 11268 xgb.Put16(buf[b:], MaxNames) 11269 b += 2 11270 11271 xgb.Put16(buf[b:], PatternLen) 11272 b += 2 11273 11274 copy(buf[b:], Pattern[:PatternLen]) 11275 b += int(PatternLen) 11276 11277 return buf 11278 } 11279 11280 // ListFontsWithInfoCookie is a cookie used only for ListFontsWithInfo requests. 11281 type ListFontsWithInfoCookie struct { 11282 *xgb.Cookie 11283 } 11284 11285 // ListFontsWithInfo sends a checked request. 11286 // If an error occurs, it will be returned with the reply by calling ListFontsWithInfoCookie.Reply() 11287 func ListFontsWithInfo(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { 11288 cookie := c.NewCookie(true, true) 11289 c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) 11290 return ListFontsWithInfoCookie{cookie} 11291 } 11292 11293 // ListFontsWithInfoUnchecked sends an unchecked request. 11294 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11295 func ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { 11296 cookie := c.NewCookie(false, true) 11297 c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) 11298 return ListFontsWithInfoCookie{cookie} 11299 } 11300 11301 // ListFontsWithInfoReply represents the data returned from a ListFontsWithInfo request. 11302 type ListFontsWithInfoReply struct { 11303 Sequence uint16 // sequence number of the request for this reply 11304 Length uint32 // number of bytes in this reply 11305 NameLen byte 11306 MinBounds Charinfo 11307 // padding: 4 bytes 11308 MaxBounds Charinfo 11309 // padding: 4 bytes 11310 MinCharOrByte2 uint16 11311 MaxCharOrByte2 uint16 11312 DefaultChar uint16 11313 PropertiesLen uint16 11314 DrawDirection byte 11315 MinByte1 byte 11316 MaxByte1 byte 11317 AllCharsExist bool 11318 FontAscent int16 11319 FontDescent int16 11320 RepliesHint uint32 11321 Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) 11322 Name string // size: xgb.Pad((int(NameLen) * 1)) 11323 } 11324 11325 // Reply blocks and returns the reply data for a ListFontsWithInfo request. 11326 func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { 11327 buf, err := cook.Cookie.Reply() 11328 if err != nil { 11329 return nil, err 11330 } 11331 if buf == nil { 11332 return nil, nil 11333 } 11334 return listFontsWithInfoReply(buf), nil 11335 } 11336 11337 // listFontsWithInfoReply reads a byte slice into a ListFontsWithInfoReply value. 11338 func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { 11339 v := new(ListFontsWithInfoReply) 11340 b := 1 // skip reply determinant 11341 11342 v.NameLen = buf[b] 11343 b += 1 11344 11345 v.Sequence = xgb.Get16(buf[b:]) 11346 b += 2 11347 11348 v.Length = xgb.Get32(buf[b:]) // 4-byte units 11349 b += 4 11350 11351 v.MinBounds = Charinfo{} 11352 b += CharinfoRead(buf[b:], &v.MinBounds) 11353 11354 b += 4 // padding 11355 11356 v.MaxBounds = Charinfo{} 11357 b += CharinfoRead(buf[b:], &v.MaxBounds) 11358 11359 b += 4 // padding 11360 11361 v.MinCharOrByte2 = xgb.Get16(buf[b:]) 11362 b += 2 11363 11364 v.MaxCharOrByte2 = xgb.Get16(buf[b:]) 11365 b += 2 11366 11367 v.DefaultChar = xgb.Get16(buf[b:]) 11368 b += 2 11369 11370 v.PropertiesLen = xgb.Get16(buf[b:]) 11371 b += 2 11372 11373 v.DrawDirection = buf[b] 11374 b += 1 11375 11376 v.MinByte1 = buf[b] 11377 b += 1 11378 11379 v.MaxByte1 = buf[b] 11380 b += 1 11381 11382 if buf[b] == 1 { 11383 v.AllCharsExist = true 11384 } else { 11385 v.AllCharsExist = false 11386 } 11387 b += 1 11388 11389 v.FontAscent = int16(xgb.Get16(buf[b:])) 11390 b += 2 11391 11392 v.FontDescent = int16(xgb.Get16(buf[b:])) 11393 b += 2 11394 11395 v.RepliesHint = xgb.Get32(buf[b:]) 11396 b += 4 11397 11398 v.Properties = make([]Fontprop, v.PropertiesLen) 11399 b += FontpropReadList(buf[b:], v.Properties) 11400 11401 { 11402 byteString := make([]byte, v.NameLen) 11403 copy(byteString[:v.NameLen], buf[b:]) 11404 v.Name = string(byteString) 11405 b += int(v.NameLen) 11406 } 11407 11408 return v 11409 } 11410 11411 // Write request to wire for ListFontsWithInfo 11412 // listFontsWithInfoRequest writes a ListFontsWithInfo request to a byte slice. 11413 func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { 11414 size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) 11415 b := 0 11416 buf := make([]byte, size) 11417 11418 buf[b] = 50 // request opcode 11419 b += 1 11420 11421 b += 1 // padding 11422 11423 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11424 b += 2 11425 11426 xgb.Put16(buf[b:], MaxNames) 11427 b += 2 11428 11429 xgb.Put16(buf[b:], PatternLen) 11430 b += 2 11431 11432 copy(buf[b:], Pattern[:PatternLen]) 11433 b += int(PatternLen) 11434 11435 return buf 11436 } 11437 11438 // ListHostsCookie is a cookie used only for ListHosts requests. 11439 type ListHostsCookie struct { 11440 *xgb.Cookie 11441 } 11442 11443 // ListHosts sends a checked request. 11444 // If an error occurs, it will be returned with the reply by calling ListHostsCookie.Reply() 11445 func ListHosts(c *xgb.Conn) ListHostsCookie { 11446 cookie := c.NewCookie(true, true) 11447 c.NewRequest(listHostsRequest(c), cookie) 11448 return ListHostsCookie{cookie} 11449 } 11450 11451 // ListHostsUnchecked sends an unchecked request. 11452 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11453 func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { 11454 cookie := c.NewCookie(false, true) 11455 c.NewRequest(listHostsRequest(c), cookie) 11456 return ListHostsCookie{cookie} 11457 } 11458 11459 // ListHostsReply represents the data returned from a ListHosts request. 11460 type ListHostsReply struct { 11461 Sequence uint16 // sequence number of the request for this reply 11462 Length uint32 // number of bytes in this reply 11463 Mode byte 11464 HostsLen uint16 11465 // padding: 22 bytes 11466 Hosts []Host // size: HostListSize(Hosts) 11467 } 11468 11469 // Reply blocks and returns the reply data for a ListHosts request. 11470 func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { 11471 buf, err := cook.Cookie.Reply() 11472 if err != nil { 11473 return nil, err 11474 } 11475 if buf == nil { 11476 return nil, nil 11477 } 11478 return listHostsReply(buf), nil 11479 } 11480 11481 // listHostsReply reads a byte slice into a ListHostsReply value. 11482 func listHostsReply(buf []byte) *ListHostsReply { 11483 v := new(ListHostsReply) 11484 b := 1 // skip reply determinant 11485 11486 v.Mode = buf[b] 11487 b += 1 11488 11489 v.Sequence = xgb.Get16(buf[b:]) 11490 b += 2 11491 11492 v.Length = xgb.Get32(buf[b:]) // 4-byte units 11493 b += 4 11494 11495 v.HostsLen = xgb.Get16(buf[b:]) 11496 b += 2 11497 11498 b += 22 // padding 11499 11500 v.Hosts = make([]Host, v.HostsLen) 11501 b += HostReadList(buf[b:], v.Hosts) 11502 11503 return v 11504 } 11505 11506 // Write request to wire for ListHosts 11507 // listHostsRequest writes a ListHosts request to a byte slice. 11508 func listHostsRequest(c *xgb.Conn) []byte { 11509 size := 4 11510 b := 0 11511 buf := make([]byte, size) 11512 11513 buf[b] = 110 // request opcode 11514 b += 1 11515 11516 b += 1 // padding 11517 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11518 b += 2 11519 11520 return buf 11521 } 11522 11523 // ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. 11524 type ListInstalledColormapsCookie struct { 11525 *xgb.Cookie 11526 } 11527 11528 // ListInstalledColormaps sends a checked request. 11529 // If an error occurs, it will be returned with the reply by calling ListInstalledColormapsCookie.Reply() 11530 func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { 11531 cookie := c.NewCookie(true, true) 11532 c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) 11533 return ListInstalledColormapsCookie{cookie} 11534 } 11535 11536 // ListInstalledColormapsUnchecked sends an unchecked request. 11537 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11538 func ListInstalledColormapsUnchecked(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { 11539 cookie := c.NewCookie(false, true) 11540 c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) 11541 return ListInstalledColormapsCookie{cookie} 11542 } 11543 11544 // ListInstalledColormapsReply represents the data returned from a ListInstalledColormaps request. 11545 type ListInstalledColormapsReply struct { 11546 Sequence uint16 // sequence number of the request for this reply 11547 Length uint32 // number of bytes in this reply 11548 // padding: 1 bytes 11549 CmapsLen uint16 11550 // padding: 22 bytes 11551 Cmaps []Colormap // size: xgb.Pad((int(CmapsLen) * 4)) 11552 } 11553 11554 // Reply blocks and returns the reply data for a ListInstalledColormaps request. 11555 func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { 11556 buf, err := cook.Cookie.Reply() 11557 if err != nil { 11558 return nil, err 11559 } 11560 if buf == nil { 11561 return nil, nil 11562 } 11563 return listInstalledColormapsReply(buf), nil 11564 } 11565 11566 // listInstalledColormapsReply reads a byte slice into a ListInstalledColormapsReply value. 11567 func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { 11568 v := new(ListInstalledColormapsReply) 11569 b := 1 // skip reply determinant 11570 11571 b += 1 // padding 11572 11573 v.Sequence = xgb.Get16(buf[b:]) 11574 b += 2 11575 11576 v.Length = xgb.Get32(buf[b:]) // 4-byte units 11577 b += 4 11578 11579 v.CmapsLen = xgb.Get16(buf[b:]) 11580 b += 2 11581 11582 b += 22 // padding 11583 11584 v.Cmaps = make([]Colormap, v.CmapsLen) 11585 for i := 0; i < int(v.CmapsLen); i++ { 11586 v.Cmaps[i] = Colormap(xgb.Get32(buf[b:])) 11587 b += 4 11588 } 11589 11590 return v 11591 } 11592 11593 // Write request to wire for ListInstalledColormaps 11594 // listInstalledColormapsRequest writes a ListInstalledColormaps request to a byte slice. 11595 func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { 11596 size := 8 11597 b := 0 11598 buf := make([]byte, size) 11599 11600 buf[b] = 83 // request opcode 11601 b += 1 11602 11603 b += 1 // padding 11604 11605 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11606 b += 2 11607 11608 xgb.Put32(buf[b:], uint32(Window)) 11609 b += 4 11610 11611 return buf 11612 } 11613 11614 // ListPropertiesCookie is a cookie used only for ListProperties requests. 11615 type ListPropertiesCookie struct { 11616 *xgb.Cookie 11617 } 11618 11619 // ListProperties sends a checked request. 11620 // If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() 11621 func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie { 11622 cookie := c.NewCookie(true, true) 11623 c.NewRequest(listPropertiesRequest(c, Window), cookie) 11624 return ListPropertiesCookie{cookie} 11625 } 11626 11627 // ListPropertiesUnchecked sends an unchecked request. 11628 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11629 func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { 11630 cookie := c.NewCookie(false, true) 11631 c.NewRequest(listPropertiesRequest(c, Window), cookie) 11632 return ListPropertiesCookie{cookie} 11633 } 11634 11635 // ListPropertiesReply represents the data returned from a ListProperties request. 11636 type ListPropertiesReply struct { 11637 Sequence uint16 // sequence number of the request for this reply 11638 Length uint32 // number of bytes in this reply 11639 // padding: 1 bytes 11640 AtomsLen uint16 11641 // padding: 22 bytes 11642 Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) 11643 } 11644 11645 // Reply blocks and returns the reply data for a ListProperties request. 11646 func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { 11647 buf, err := cook.Cookie.Reply() 11648 if err != nil { 11649 return nil, err 11650 } 11651 if buf == nil { 11652 return nil, nil 11653 } 11654 return listPropertiesReply(buf), nil 11655 } 11656 11657 // listPropertiesReply reads a byte slice into a ListPropertiesReply value. 11658 func listPropertiesReply(buf []byte) *ListPropertiesReply { 11659 v := new(ListPropertiesReply) 11660 b := 1 // skip reply determinant 11661 11662 b += 1 // padding 11663 11664 v.Sequence = xgb.Get16(buf[b:]) 11665 b += 2 11666 11667 v.Length = xgb.Get32(buf[b:]) // 4-byte units 11668 b += 4 11669 11670 v.AtomsLen = xgb.Get16(buf[b:]) 11671 b += 2 11672 11673 b += 22 // padding 11674 11675 v.Atoms = make([]Atom, v.AtomsLen) 11676 for i := 0; i < int(v.AtomsLen); i++ { 11677 v.Atoms[i] = Atom(xgb.Get32(buf[b:])) 11678 b += 4 11679 } 11680 11681 return v 11682 } 11683 11684 // Write request to wire for ListProperties 11685 // listPropertiesRequest writes a ListProperties request to a byte slice. 11686 func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { 11687 size := 8 11688 b := 0 11689 buf := make([]byte, size) 11690 11691 buf[b] = 21 // request opcode 11692 b += 1 11693 11694 b += 1 // padding 11695 11696 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11697 b += 2 11698 11699 xgb.Put32(buf[b:], uint32(Window)) 11700 b += 4 11701 11702 return buf 11703 } 11704 11705 // LookupColorCookie is a cookie used only for LookupColor requests. 11706 type LookupColorCookie struct { 11707 *xgb.Cookie 11708 } 11709 11710 // LookupColor sends a checked request. 11711 // If an error occurs, it will be returned with the reply by calling LookupColorCookie.Reply() 11712 func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { 11713 cookie := c.NewCookie(true, true) 11714 c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) 11715 return LookupColorCookie{cookie} 11716 } 11717 11718 // LookupColorUnchecked sends an unchecked request. 11719 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11720 func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { 11721 cookie := c.NewCookie(false, true) 11722 c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) 11723 return LookupColorCookie{cookie} 11724 } 11725 11726 // LookupColorReply represents the data returned from a LookupColor request. 11727 type LookupColorReply struct { 11728 Sequence uint16 // sequence number of the request for this reply 11729 Length uint32 // number of bytes in this reply 11730 // padding: 1 bytes 11731 ExactRed uint16 11732 ExactGreen uint16 11733 ExactBlue uint16 11734 VisualRed uint16 11735 VisualGreen uint16 11736 VisualBlue uint16 11737 } 11738 11739 // Reply blocks and returns the reply data for a LookupColor request. 11740 func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { 11741 buf, err := cook.Cookie.Reply() 11742 if err != nil { 11743 return nil, err 11744 } 11745 if buf == nil { 11746 return nil, nil 11747 } 11748 return lookupColorReply(buf), nil 11749 } 11750 11751 // lookupColorReply reads a byte slice into a LookupColorReply value. 11752 func lookupColorReply(buf []byte) *LookupColorReply { 11753 v := new(LookupColorReply) 11754 b := 1 // skip reply determinant 11755 11756 b += 1 // padding 11757 11758 v.Sequence = xgb.Get16(buf[b:]) 11759 b += 2 11760 11761 v.Length = xgb.Get32(buf[b:]) // 4-byte units 11762 b += 4 11763 11764 v.ExactRed = xgb.Get16(buf[b:]) 11765 b += 2 11766 11767 v.ExactGreen = xgb.Get16(buf[b:]) 11768 b += 2 11769 11770 v.ExactBlue = xgb.Get16(buf[b:]) 11771 b += 2 11772 11773 v.VisualRed = xgb.Get16(buf[b:]) 11774 b += 2 11775 11776 v.VisualGreen = xgb.Get16(buf[b:]) 11777 b += 2 11778 11779 v.VisualBlue = xgb.Get16(buf[b:]) 11780 b += 2 11781 11782 return v 11783 } 11784 11785 // Write request to wire for LookupColor 11786 // lookupColorRequest writes a LookupColor request to a byte slice. 11787 func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { 11788 size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) 11789 b := 0 11790 buf := make([]byte, size) 11791 11792 buf[b] = 92 // request opcode 11793 b += 1 11794 11795 b += 1 // padding 11796 11797 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11798 b += 2 11799 11800 xgb.Put32(buf[b:], uint32(Cmap)) 11801 b += 4 11802 11803 xgb.Put16(buf[b:], NameLen) 11804 b += 2 11805 11806 b += 2 // padding 11807 11808 copy(buf[b:], Name[:NameLen]) 11809 b += int(NameLen) 11810 11811 return buf 11812 } 11813 11814 // MapSubwindowsCookie is a cookie used only for MapSubwindows requests. 11815 type MapSubwindowsCookie struct { 11816 *xgb.Cookie 11817 } 11818 11819 // MapSubwindows sends an unchecked request. 11820 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11821 func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { 11822 cookie := c.NewCookie(false, false) 11823 c.NewRequest(mapSubwindowsRequest(c, Window), cookie) 11824 return MapSubwindowsCookie{cookie} 11825 } 11826 11827 // MapSubwindowsChecked sends a checked request. 11828 // If an error occurs, it can be retrieved using MapSubwindowsCookie.Check() 11829 func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie { 11830 cookie := c.NewCookie(true, false) 11831 c.NewRequest(mapSubwindowsRequest(c, Window), cookie) 11832 return MapSubwindowsCookie{cookie} 11833 } 11834 11835 // Check returns an error if one occurred for checked requests that are not expecting a reply. 11836 // This cannot be called for requests expecting a reply, nor for unchecked requests. 11837 func (cook MapSubwindowsCookie) Check() error { 11838 return cook.Cookie.Check() 11839 } 11840 11841 // Write request to wire for MapSubwindows 11842 // mapSubwindowsRequest writes a MapSubwindows request to a byte slice. 11843 func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { 11844 size := 8 11845 b := 0 11846 buf := make([]byte, size) 11847 11848 buf[b] = 9 // request opcode 11849 b += 1 11850 11851 b += 1 // padding 11852 11853 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11854 b += 2 11855 11856 xgb.Put32(buf[b:], uint32(Window)) 11857 b += 4 11858 11859 return buf 11860 } 11861 11862 // MapWindowCookie is a cookie used only for MapWindow requests. 11863 type MapWindowCookie struct { 11864 *xgb.Cookie 11865 } 11866 11867 // MapWindow sends an unchecked request. 11868 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11869 func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { 11870 cookie := c.NewCookie(false, false) 11871 c.NewRequest(mapWindowRequest(c, Window), cookie) 11872 return MapWindowCookie{cookie} 11873 } 11874 11875 // MapWindowChecked sends a checked request. 11876 // If an error occurs, it can be retrieved using MapWindowCookie.Check() 11877 func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie { 11878 cookie := c.NewCookie(true, false) 11879 c.NewRequest(mapWindowRequest(c, Window), cookie) 11880 return MapWindowCookie{cookie} 11881 } 11882 11883 // Check returns an error if one occurred for checked requests that are not expecting a reply. 11884 // This cannot be called for requests expecting a reply, nor for unchecked requests. 11885 func (cook MapWindowCookie) Check() error { 11886 return cook.Cookie.Check() 11887 } 11888 11889 // Write request to wire for MapWindow 11890 // mapWindowRequest writes a MapWindow request to a byte slice. 11891 func mapWindowRequest(c *xgb.Conn, Window Window) []byte { 11892 size := 8 11893 b := 0 11894 buf := make([]byte, size) 11895 11896 buf[b] = 8 // request opcode 11897 b += 1 11898 11899 b += 1 // padding 11900 11901 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11902 b += 2 11903 11904 xgb.Put32(buf[b:], uint32(Window)) 11905 b += 4 11906 11907 return buf 11908 } 11909 11910 // NoOperationCookie is a cookie used only for NoOperation requests. 11911 type NoOperationCookie struct { 11912 *xgb.Cookie 11913 } 11914 11915 // NoOperation sends an unchecked request. 11916 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11917 func NoOperation(c *xgb.Conn) NoOperationCookie { 11918 cookie := c.NewCookie(false, false) 11919 c.NewRequest(noOperationRequest(c), cookie) 11920 return NoOperationCookie{cookie} 11921 } 11922 11923 // NoOperationChecked sends a checked request. 11924 // If an error occurs, it can be retrieved using NoOperationCookie.Check() 11925 func NoOperationChecked(c *xgb.Conn) NoOperationCookie { 11926 cookie := c.NewCookie(true, false) 11927 c.NewRequest(noOperationRequest(c), cookie) 11928 return NoOperationCookie{cookie} 11929 } 11930 11931 // Check returns an error if one occurred for checked requests that are not expecting a reply. 11932 // This cannot be called for requests expecting a reply, nor for unchecked requests. 11933 func (cook NoOperationCookie) Check() error { 11934 return cook.Cookie.Check() 11935 } 11936 11937 // Write request to wire for NoOperation 11938 // noOperationRequest writes a NoOperation request to a byte slice. 11939 func noOperationRequest(c *xgb.Conn) []byte { 11940 size := 4 11941 b := 0 11942 buf := make([]byte, size) 11943 11944 buf[b] = 127 // request opcode 11945 b += 1 11946 11947 b += 1 // padding 11948 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11949 b += 2 11950 11951 return buf 11952 } 11953 11954 // OpenFontCookie is a cookie used only for OpenFont requests. 11955 type OpenFontCookie struct { 11956 *xgb.Cookie 11957 } 11958 11959 // OpenFont sends an unchecked request. 11960 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 11961 func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { 11962 cookie := c.NewCookie(false, false) 11963 c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) 11964 return OpenFontCookie{cookie} 11965 } 11966 11967 // OpenFontChecked sends a checked request. 11968 // If an error occurs, it can be retrieved using OpenFontCookie.Check() 11969 func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { 11970 cookie := c.NewCookie(true, false) 11971 c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) 11972 return OpenFontCookie{cookie} 11973 } 11974 11975 // Check returns an error if one occurred for checked requests that are not expecting a reply. 11976 // This cannot be called for requests expecting a reply, nor for unchecked requests. 11977 func (cook OpenFontCookie) Check() error { 11978 return cook.Cookie.Check() 11979 } 11980 11981 // Write request to wire for OpenFont 11982 // openFontRequest writes a OpenFont request to a byte slice. 11983 func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte { 11984 size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) 11985 b := 0 11986 buf := make([]byte, size) 11987 11988 buf[b] = 45 // request opcode 11989 b += 1 11990 11991 b += 1 // padding 11992 11993 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 11994 b += 2 11995 11996 xgb.Put32(buf[b:], uint32(Fid)) 11997 b += 4 11998 11999 xgb.Put16(buf[b:], NameLen) 12000 b += 2 12001 12002 b += 2 // padding 12003 12004 copy(buf[b:], Name[:NameLen]) 12005 b += int(NameLen) 12006 12007 return buf 12008 } 12009 12010 // PolyArcCookie is a cookie used only for PolyArc requests. 12011 type PolyArcCookie struct { 12012 *xgb.Cookie 12013 } 12014 12015 // PolyArc sends an unchecked request. 12016 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12017 func PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { 12018 cookie := c.NewCookie(false, false) 12019 c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) 12020 return PolyArcCookie{cookie} 12021 } 12022 12023 // PolyArcChecked sends a checked request. 12024 // If an error occurs, it can be retrieved using PolyArcCookie.Check() 12025 func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { 12026 cookie := c.NewCookie(true, false) 12027 c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) 12028 return PolyArcCookie{cookie} 12029 } 12030 12031 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12032 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12033 func (cook PolyArcCookie) Check() error { 12034 return cook.Cookie.Check() 12035 } 12036 12037 // Write request to wire for PolyArc 12038 // polyArcRequest writes a PolyArc request to a byte slice. 12039 func polyArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { 12040 size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) 12041 b := 0 12042 buf := make([]byte, size) 12043 12044 buf[b] = 68 // request opcode 12045 b += 1 12046 12047 b += 1 // padding 12048 12049 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12050 b += 2 12051 12052 xgb.Put32(buf[b:], uint32(Drawable)) 12053 b += 4 12054 12055 xgb.Put32(buf[b:], uint32(Gc)) 12056 b += 4 12057 12058 b += ArcListBytes(buf[b:], Arcs) 12059 12060 return buf 12061 } 12062 12063 // PolyFillArcCookie is a cookie used only for PolyFillArc requests. 12064 type PolyFillArcCookie struct { 12065 *xgb.Cookie 12066 } 12067 12068 // PolyFillArc sends an unchecked request. 12069 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12070 func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { 12071 cookie := c.NewCookie(false, false) 12072 c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) 12073 return PolyFillArcCookie{cookie} 12074 } 12075 12076 // PolyFillArcChecked sends a checked request. 12077 // If an error occurs, it can be retrieved using PolyFillArcCookie.Check() 12078 func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { 12079 cookie := c.NewCookie(true, false) 12080 c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) 12081 return PolyFillArcCookie{cookie} 12082 } 12083 12084 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12085 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12086 func (cook PolyFillArcCookie) Check() error { 12087 return cook.Cookie.Check() 12088 } 12089 12090 // Write request to wire for PolyFillArc 12091 // polyFillArcRequest writes a PolyFillArc request to a byte slice. 12092 func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { 12093 size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) 12094 b := 0 12095 buf := make([]byte, size) 12096 12097 buf[b] = 71 // request opcode 12098 b += 1 12099 12100 b += 1 // padding 12101 12102 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12103 b += 2 12104 12105 xgb.Put32(buf[b:], uint32(Drawable)) 12106 b += 4 12107 12108 xgb.Put32(buf[b:], uint32(Gc)) 12109 b += 4 12110 12111 b += ArcListBytes(buf[b:], Arcs) 12112 12113 return buf 12114 } 12115 12116 // PolyFillRectangleCookie is a cookie used only for PolyFillRectangle requests. 12117 type PolyFillRectangleCookie struct { 12118 *xgb.Cookie 12119 } 12120 12121 // PolyFillRectangle sends an unchecked request. 12122 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12123 func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { 12124 cookie := c.NewCookie(false, false) 12125 c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) 12126 return PolyFillRectangleCookie{cookie} 12127 } 12128 12129 // PolyFillRectangleChecked sends a checked request. 12130 // If an error occurs, it can be retrieved using PolyFillRectangleCookie.Check() 12131 func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { 12132 cookie := c.NewCookie(true, false) 12133 c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) 12134 return PolyFillRectangleCookie{cookie} 12135 } 12136 12137 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12138 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12139 func (cook PolyFillRectangleCookie) Check() error { 12140 return cook.Cookie.Check() 12141 } 12142 12143 // Write request to wire for PolyFillRectangle 12144 // polyFillRectangleRequest writes a PolyFillRectangle request to a byte slice. 12145 func polyFillRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { 12146 size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) 12147 b := 0 12148 buf := make([]byte, size) 12149 12150 buf[b] = 70 // request opcode 12151 b += 1 12152 12153 b += 1 // padding 12154 12155 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12156 b += 2 12157 12158 xgb.Put32(buf[b:], uint32(Drawable)) 12159 b += 4 12160 12161 xgb.Put32(buf[b:], uint32(Gc)) 12162 b += 4 12163 12164 b += RectangleListBytes(buf[b:], Rectangles) 12165 12166 return buf 12167 } 12168 12169 // PolyLineCookie is a cookie used only for PolyLine requests. 12170 type PolyLineCookie struct { 12171 *xgb.Cookie 12172 } 12173 12174 // PolyLine sends an unchecked request. 12175 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12176 func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { 12177 cookie := c.NewCookie(false, false) 12178 c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) 12179 return PolyLineCookie{cookie} 12180 } 12181 12182 // PolyLineChecked sends a checked request. 12183 // If an error occurs, it can be retrieved using PolyLineCookie.Check() 12184 func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { 12185 cookie := c.NewCookie(true, false) 12186 c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) 12187 return PolyLineCookie{cookie} 12188 } 12189 12190 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12191 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12192 func (cook PolyLineCookie) Check() error { 12193 return cook.Cookie.Check() 12194 } 12195 12196 // Write request to wire for PolyLine 12197 // polyLineRequest writes a PolyLine request to a byte slice. 12198 func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { 12199 size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) 12200 b := 0 12201 buf := make([]byte, size) 12202 12203 buf[b] = 65 // request opcode 12204 b += 1 12205 12206 buf[b] = CoordinateMode 12207 b += 1 12208 12209 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12210 b += 2 12211 12212 xgb.Put32(buf[b:], uint32(Drawable)) 12213 b += 4 12214 12215 xgb.Put32(buf[b:], uint32(Gc)) 12216 b += 4 12217 12218 b += PointListBytes(buf[b:], Points) 12219 12220 return buf 12221 } 12222 12223 // PolyPointCookie is a cookie used only for PolyPoint requests. 12224 type PolyPointCookie struct { 12225 *xgb.Cookie 12226 } 12227 12228 // PolyPoint sends an unchecked request. 12229 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12230 func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { 12231 cookie := c.NewCookie(false, false) 12232 c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) 12233 return PolyPointCookie{cookie} 12234 } 12235 12236 // PolyPointChecked sends a checked request. 12237 // If an error occurs, it can be retrieved using PolyPointCookie.Check() 12238 func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { 12239 cookie := c.NewCookie(true, false) 12240 c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) 12241 return PolyPointCookie{cookie} 12242 } 12243 12244 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12245 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12246 func (cook PolyPointCookie) Check() error { 12247 return cook.Cookie.Check() 12248 } 12249 12250 // Write request to wire for PolyPoint 12251 // polyPointRequest writes a PolyPoint request to a byte slice. 12252 func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { 12253 size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) 12254 b := 0 12255 buf := make([]byte, size) 12256 12257 buf[b] = 64 // request opcode 12258 b += 1 12259 12260 buf[b] = CoordinateMode 12261 b += 1 12262 12263 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12264 b += 2 12265 12266 xgb.Put32(buf[b:], uint32(Drawable)) 12267 b += 4 12268 12269 xgb.Put32(buf[b:], uint32(Gc)) 12270 b += 4 12271 12272 b += PointListBytes(buf[b:], Points) 12273 12274 return buf 12275 } 12276 12277 // PolyRectangleCookie is a cookie used only for PolyRectangle requests. 12278 type PolyRectangleCookie struct { 12279 *xgb.Cookie 12280 } 12281 12282 // PolyRectangle sends an unchecked request. 12283 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12284 func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { 12285 cookie := c.NewCookie(false, false) 12286 c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) 12287 return PolyRectangleCookie{cookie} 12288 } 12289 12290 // PolyRectangleChecked sends a checked request. 12291 // If an error occurs, it can be retrieved using PolyRectangleCookie.Check() 12292 func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { 12293 cookie := c.NewCookie(true, false) 12294 c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) 12295 return PolyRectangleCookie{cookie} 12296 } 12297 12298 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12299 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12300 func (cook PolyRectangleCookie) Check() error { 12301 return cook.Cookie.Check() 12302 } 12303 12304 // Write request to wire for PolyRectangle 12305 // polyRectangleRequest writes a PolyRectangle request to a byte slice. 12306 func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { 12307 size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) 12308 b := 0 12309 buf := make([]byte, size) 12310 12311 buf[b] = 67 // request opcode 12312 b += 1 12313 12314 b += 1 // padding 12315 12316 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12317 b += 2 12318 12319 xgb.Put32(buf[b:], uint32(Drawable)) 12320 b += 4 12321 12322 xgb.Put32(buf[b:], uint32(Gc)) 12323 b += 4 12324 12325 b += RectangleListBytes(buf[b:], Rectangles) 12326 12327 return buf 12328 } 12329 12330 // PolySegmentCookie is a cookie used only for PolySegment requests. 12331 type PolySegmentCookie struct { 12332 *xgb.Cookie 12333 } 12334 12335 // PolySegment sends an unchecked request. 12336 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12337 func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { 12338 cookie := c.NewCookie(false, false) 12339 c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) 12340 return PolySegmentCookie{cookie} 12341 } 12342 12343 // PolySegmentChecked sends a checked request. 12344 // If an error occurs, it can be retrieved using PolySegmentCookie.Check() 12345 func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { 12346 cookie := c.NewCookie(true, false) 12347 c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) 12348 return PolySegmentCookie{cookie} 12349 } 12350 12351 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12352 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12353 func (cook PolySegmentCookie) Check() error { 12354 return cook.Cookie.Check() 12355 } 12356 12357 // Write request to wire for PolySegment 12358 // polySegmentRequest writes a PolySegment request to a byte slice. 12359 func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { 12360 size := xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) 12361 b := 0 12362 buf := make([]byte, size) 12363 12364 buf[b] = 66 // request opcode 12365 b += 1 12366 12367 b += 1 // padding 12368 12369 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12370 b += 2 12371 12372 xgb.Put32(buf[b:], uint32(Drawable)) 12373 b += 4 12374 12375 xgb.Put32(buf[b:], uint32(Gc)) 12376 b += 4 12377 12378 b += SegmentListBytes(buf[b:], Segments) 12379 12380 return buf 12381 } 12382 12383 // PolyText16Cookie is a cookie used only for PolyText16 requests. 12384 type PolyText16Cookie struct { 12385 *xgb.Cookie 12386 } 12387 12388 // PolyText16 sends an unchecked request. 12389 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12390 func PolyText16(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { 12391 cookie := c.NewCookie(false, false) 12392 c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) 12393 return PolyText16Cookie{cookie} 12394 } 12395 12396 // PolyText16Checked sends a checked request. 12397 // If an error occurs, it can be retrieved using PolyText16Cookie.Check() 12398 func PolyText16Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { 12399 cookie := c.NewCookie(true, false) 12400 c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) 12401 return PolyText16Cookie{cookie} 12402 } 12403 12404 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12405 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12406 func (cook PolyText16Cookie) Check() error { 12407 return cook.Cookie.Check() 12408 } 12409 12410 // Write request to wire for PolyText16 12411 // polyText16Request writes a PolyText16 request to a byte slice. 12412 func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { 12413 size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) 12414 b := 0 12415 buf := make([]byte, size) 12416 12417 buf[b] = 75 // request opcode 12418 b += 1 12419 12420 b += 1 // padding 12421 12422 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12423 b += 2 12424 12425 xgb.Put32(buf[b:], uint32(Drawable)) 12426 b += 4 12427 12428 xgb.Put32(buf[b:], uint32(Gc)) 12429 b += 4 12430 12431 xgb.Put16(buf[b:], uint16(X)) 12432 b += 2 12433 12434 xgb.Put16(buf[b:], uint16(Y)) 12435 b += 2 12436 12437 copy(buf[b:], Items[:len(Items)]) 12438 b += int(len(Items)) 12439 12440 return buf 12441 } 12442 12443 // PolyText8Cookie is a cookie used only for PolyText8 requests. 12444 type PolyText8Cookie struct { 12445 *xgb.Cookie 12446 } 12447 12448 // PolyText8 sends an unchecked request. 12449 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12450 func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { 12451 cookie := c.NewCookie(false, false) 12452 c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) 12453 return PolyText8Cookie{cookie} 12454 } 12455 12456 // PolyText8Checked sends a checked request. 12457 // If an error occurs, it can be retrieved using PolyText8Cookie.Check() 12458 func PolyText8Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { 12459 cookie := c.NewCookie(true, false) 12460 c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) 12461 return PolyText8Cookie{cookie} 12462 } 12463 12464 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12465 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12466 func (cook PolyText8Cookie) Check() error { 12467 return cook.Cookie.Check() 12468 } 12469 12470 // Write request to wire for PolyText8 12471 // polyText8Request writes a PolyText8 request to a byte slice. 12472 func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { 12473 size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) 12474 b := 0 12475 buf := make([]byte, size) 12476 12477 buf[b] = 74 // request opcode 12478 b += 1 12479 12480 b += 1 // padding 12481 12482 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12483 b += 2 12484 12485 xgb.Put32(buf[b:], uint32(Drawable)) 12486 b += 4 12487 12488 xgb.Put32(buf[b:], uint32(Gc)) 12489 b += 4 12490 12491 xgb.Put16(buf[b:], uint16(X)) 12492 b += 2 12493 12494 xgb.Put16(buf[b:], uint16(Y)) 12495 b += 2 12496 12497 copy(buf[b:], Items[:len(Items)]) 12498 b += int(len(Items)) 12499 12500 return buf 12501 } 12502 12503 // PutImageCookie is a cookie used only for PutImage requests. 12504 type PutImageCookie struct { 12505 *xgb.Cookie 12506 } 12507 12508 // PutImage sends an unchecked request. 12509 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12510 func PutImage(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { 12511 cookie := c.NewCookie(false, false) 12512 c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) 12513 return PutImageCookie{cookie} 12514 } 12515 12516 // PutImageChecked sends a checked request. 12517 // If an error occurs, it can be retrieved using PutImageCookie.Check() 12518 func PutImageChecked(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { 12519 cookie := c.NewCookie(true, false) 12520 c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) 12521 return PutImageCookie{cookie} 12522 } 12523 12524 // Check returns an error if one occurred for checked requests that are not expecting a reply. 12525 // This cannot be called for requests expecting a reply, nor for unchecked requests. 12526 func (cook PutImageCookie) Check() error { 12527 return cook.Cookie.Check() 12528 } 12529 12530 // Write request to wire for PutImage 12531 // putImageRequest writes a PutImage request to a byte slice. 12532 func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) []byte { 12533 size := xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) 12534 b := 0 12535 buf := make([]byte, size) 12536 12537 buf[b] = 72 // request opcode 12538 b += 1 12539 12540 buf[b] = Format 12541 b += 1 12542 12543 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12544 b += 2 12545 12546 xgb.Put32(buf[b:], uint32(Drawable)) 12547 b += 4 12548 12549 xgb.Put32(buf[b:], uint32(Gc)) 12550 b += 4 12551 12552 xgb.Put16(buf[b:], Width) 12553 b += 2 12554 12555 xgb.Put16(buf[b:], Height) 12556 b += 2 12557 12558 xgb.Put16(buf[b:], uint16(DstX)) 12559 b += 2 12560 12561 xgb.Put16(buf[b:], uint16(DstY)) 12562 b += 2 12563 12564 buf[b] = LeftPad 12565 b += 1 12566 12567 buf[b] = Depth 12568 b += 1 12569 12570 b += 2 // padding 12571 12572 copy(buf[b:], Data[:len(Data)]) 12573 b += int(len(Data)) 12574 12575 return buf 12576 } 12577 12578 // QueryBestSizeCookie is a cookie used only for QueryBestSize requests. 12579 type QueryBestSizeCookie struct { 12580 *xgb.Cookie 12581 } 12582 12583 // QueryBestSize sends a checked request. 12584 // If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() 12585 func QueryBestSize(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { 12586 cookie := c.NewCookie(true, true) 12587 c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) 12588 return QueryBestSizeCookie{cookie} 12589 } 12590 12591 // QueryBestSizeUnchecked sends an unchecked request. 12592 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12593 func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { 12594 cookie := c.NewCookie(false, true) 12595 c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) 12596 return QueryBestSizeCookie{cookie} 12597 } 12598 12599 // QueryBestSizeReply represents the data returned from a QueryBestSize request. 12600 type QueryBestSizeReply struct { 12601 Sequence uint16 // sequence number of the request for this reply 12602 Length uint32 // number of bytes in this reply 12603 // padding: 1 bytes 12604 Width uint16 12605 Height uint16 12606 } 12607 12608 // Reply blocks and returns the reply data for a QueryBestSize request. 12609 func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { 12610 buf, err := cook.Cookie.Reply() 12611 if err != nil { 12612 return nil, err 12613 } 12614 if buf == nil { 12615 return nil, nil 12616 } 12617 return queryBestSizeReply(buf), nil 12618 } 12619 12620 // queryBestSizeReply reads a byte slice into a QueryBestSizeReply value. 12621 func queryBestSizeReply(buf []byte) *QueryBestSizeReply { 12622 v := new(QueryBestSizeReply) 12623 b := 1 // skip reply determinant 12624 12625 b += 1 // padding 12626 12627 v.Sequence = xgb.Get16(buf[b:]) 12628 b += 2 12629 12630 v.Length = xgb.Get32(buf[b:]) // 4-byte units 12631 b += 4 12632 12633 v.Width = xgb.Get16(buf[b:]) 12634 b += 2 12635 12636 v.Height = xgb.Get16(buf[b:]) 12637 b += 2 12638 12639 return v 12640 } 12641 12642 // Write request to wire for QueryBestSize 12643 // queryBestSizeRequest writes a QueryBestSize request to a byte slice. 12644 func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { 12645 size := 12 12646 b := 0 12647 buf := make([]byte, size) 12648 12649 buf[b] = 97 // request opcode 12650 b += 1 12651 12652 buf[b] = Class 12653 b += 1 12654 12655 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12656 b += 2 12657 12658 xgb.Put32(buf[b:], uint32(Drawable)) 12659 b += 4 12660 12661 xgb.Put16(buf[b:], Width) 12662 b += 2 12663 12664 xgb.Put16(buf[b:], Height) 12665 b += 2 12666 12667 return buf 12668 } 12669 12670 // QueryColorsCookie is a cookie used only for QueryColors requests. 12671 type QueryColorsCookie struct { 12672 *xgb.Cookie 12673 } 12674 12675 // QueryColors sends a checked request. 12676 // If an error occurs, it will be returned with the reply by calling QueryColorsCookie.Reply() 12677 func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { 12678 cookie := c.NewCookie(true, true) 12679 c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) 12680 return QueryColorsCookie{cookie} 12681 } 12682 12683 // QueryColorsUnchecked sends an unchecked request. 12684 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12685 func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { 12686 cookie := c.NewCookie(false, true) 12687 c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) 12688 return QueryColorsCookie{cookie} 12689 } 12690 12691 // QueryColorsReply represents the data returned from a QueryColors request. 12692 type QueryColorsReply struct { 12693 Sequence uint16 // sequence number of the request for this reply 12694 Length uint32 // number of bytes in this reply 12695 // padding: 1 bytes 12696 ColorsLen uint16 12697 // padding: 22 bytes 12698 Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) 12699 } 12700 12701 // Reply blocks and returns the reply data for a QueryColors request. 12702 func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { 12703 buf, err := cook.Cookie.Reply() 12704 if err != nil { 12705 return nil, err 12706 } 12707 if buf == nil { 12708 return nil, nil 12709 } 12710 return queryColorsReply(buf), nil 12711 } 12712 12713 // queryColorsReply reads a byte slice into a QueryColorsReply value. 12714 func queryColorsReply(buf []byte) *QueryColorsReply { 12715 v := new(QueryColorsReply) 12716 b := 1 // skip reply determinant 12717 12718 b += 1 // padding 12719 12720 v.Sequence = xgb.Get16(buf[b:]) 12721 b += 2 12722 12723 v.Length = xgb.Get32(buf[b:]) // 4-byte units 12724 b += 4 12725 12726 v.ColorsLen = xgb.Get16(buf[b:]) 12727 b += 2 12728 12729 b += 22 // padding 12730 12731 v.Colors = make([]Rgb, v.ColorsLen) 12732 b += RgbReadList(buf[b:], v.Colors) 12733 12734 return v 12735 } 12736 12737 // Write request to wire for QueryColors 12738 // queryColorsRequest writes a QueryColors request to a byte slice. 12739 func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { 12740 size := xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) 12741 b := 0 12742 buf := make([]byte, size) 12743 12744 buf[b] = 91 // request opcode 12745 b += 1 12746 12747 b += 1 // padding 12748 12749 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12750 b += 2 12751 12752 xgb.Put32(buf[b:], uint32(Cmap)) 12753 b += 4 12754 12755 for i := 0; i < int(len(Pixels)); i++ { 12756 xgb.Put32(buf[b:], Pixels[i]) 12757 b += 4 12758 } 12759 12760 return buf 12761 } 12762 12763 // QueryExtensionCookie is a cookie used only for QueryExtension requests. 12764 type QueryExtensionCookie struct { 12765 *xgb.Cookie 12766 } 12767 12768 // QueryExtension sends a checked request. 12769 // If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() 12770 func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { 12771 cookie := c.NewCookie(true, true) 12772 c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) 12773 return QueryExtensionCookie{cookie} 12774 } 12775 12776 // QueryExtensionUnchecked sends an unchecked request. 12777 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12778 func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { 12779 cookie := c.NewCookie(false, true) 12780 c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) 12781 return QueryExtensionCookie{cookie} 12782 } 12783 12784 // QueryExtensionReply represents the data returned from a QueryExtension request. 12785 type QueryExtensionReply struct { 12786 Sequence uint16 // sequence number of the request for this reply 12787 Length uint32 // number of bytes in this reply 12788 // padding: 1 bytes 12789 Present bool 12790 MajorOpcode byte 12791 FirstEvent byte 12792 FirstError byte 12793 } 12794 12795 // Reply blocks and returns the reply data for a QueryExtension request. 12796 func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { 12797 buf, err := cook.Cookie.Reply() 12798 if err != nil { 12799 return nil, err 12800 } 12801 if buf == nil { 12802 return nil, nil 12803 } 12804 return queryExtensionReply(buf), nil 12805 } 12806 12807 // queryExtensionReply reads a byte slice into a QueryExtensionReply value. 12808 func queryExtensionReply(buf []byte) *QueryExtensionReply { 12809 v := new(QueryExtensionReply) 12810 b := 1 // skip reply determinant 12811 12812 b += 1 // padding 12813 12814 v.Sequence = xgb.Get16(buf[b:]) 12815 b += 2 12816 12817 v.Length = xgb.Get32(buf[b:]) // 4-byte units 12818 b += 4 12819 12820 if buf[b] == 1 { 12821 v.Present = true 12822 } else { 12823 v.Present = false 12824 } 12825 b += 1 12826 12827 v.MajorOpcode = buf[b] 12828 b += 1 12829 12830 v.FirstEvent = buf[b] 12831 b += 1 12832 12833 v.FirstError = buf[b] 12834 b += 1 12835 12836 return v 12837 } 12838 12839 // Write request to wire for QueryExtension 12840 // queryExtensionRequest writes a QueryExtension request to a byte slice. 12841 func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { 12842 size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) 12843 b := 0 12844 buf := make([]byte, size) 12845 12846 buf[b] = 98 // request opcode 12847 b += 1 12848 12849 b += 1 // padding 12850 12851 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 12852 b += 2 12853 12854 xgb.Put16(buf[b:], NameLen) 12855 b += 2 12856 12857 b += 2 // padding 12858 12859 copy(buf[b:], Name[:NameLen]) 12860 b += int(NameLen) 12861 12862 return buf 12863 } 12864 12865 // QueryFontCookie is a cookie used only for QueryFont requests. 12866 type QueryFontCookie struct { 12867 *xgb.Cookie 12868 } 12869 12870 // QueryFont sends a checked request. 12871 // If an error occurs, it will be returned with the reply by calling QueryFontCookie.Reply() 12872 func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie { 12873 cookie := c.NewCookie(true, true) 12874 c.NewRequest(queryFontRequest(c, Font), cookie) 12875 return QueryFontCookie{cookie} 12876 } 12877 12878 // QueryFontUnchecked sends an unchecked request. 12879 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 12880 func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { 12881 cookie := c.NewCookie(false, true) 12882 c.NewRequest(queryFontRequest(c, Font), cookie) 12883 return QueryFontCookie{cookie} 12884 } 12885 12886 // QueryFontReply represents the data returned from a QueryFont request. 12887 type QueryFontReply struct { 12888 Sequence uint16 // sequence number of the request for this reply 12889 Length uint32 // number of bytes in this reply 12890 // padding: 1 bytes 12891 MinBounds Charinfo 12892 // padding: 4 bytes 12893 MaxBounds Charinfo 12894 // padding: 4 bytes 12895 MinCharOrByte2 uint16 12896 MaxCharOrByte2 uint16 12897 DefaultChar uint16 12898 PropertiesLen uint16 12899 DrawDirection byte 12900 MinByte1 byte 12901 MaxByte1 byte 12902 AllCharsExist bool 12903 FontAscent int16 12904 FontDescent int16 12905 CharInfosLen uint32 12906 Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) 12907 // alignment gap to multiple of 4 12908 CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) 12909 } 12910 12911 // Reply blocks and returns the reply data for a QueryFont request. 12912 func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { 12913 buf, err := cook.Cookie.Reply() 12914 if err != nil { 12915 return nil, err 12916 } 12917 if buf == nil { 12918 return nil, nil 12919 } 12920 return queryFontReply(buf), nil 12921 } 12922 12923 // queryFontReply reads a byte slice into a QueryFontReply value. 12924 func queryFontReply(buf []byte) *QueryFontReply { 12925 v := new(QueryFontReply) 12926 b := 1 // skip reply determinant 12927 12928 b += 1 // padding 12929 12930 v.Sequence = xgb.Get16(buf[b:]) 12931 b += 2 12932 12933 v.Length = xgb.Get32(buf[b:]) // 4-byte units 12934 b += 4 12935 12936 v.MinBounds = Charinfo{} 12937 b += CharinfoRead(buf[b:], &v.MinBounds) 12938 12939 b += 4 // padding 12940 12941 v.MaxBounds = Charinfo{} 12942 b += CharinfoRead(buf[b:], &v.MaxBounds) 12943 12944 b += 4 // padding 12945 12946 v.MinCharOrByte2 = xgb.Get16(buf[b:]) 12947 b += 2 12948 12949 v.MaxCharOrByte2 = xgb.Get16(buf[b:]) 12950 b += 2 12951 12952 v.DefaultChar = xgb.Get16(buf[b:]) 12953 b += 2 12954 12955 v.PropertiesLen = xgb.Get16(buf[b:]) 12956 b += 2 12957 12958 v.DrawDirection = buf[b] 12959 b += 1 12960 12961 v.MinByte1 = buf[b] 12962 b += 1 12963 12964 v.MaxByte1 = buf[b] 12965 b += 1 12966 12967 if buf[b] == 1 { 12968 v.AllCharsExist = true 12969 } else { 12970 v.AllCharsExist = false 12971 } 12972 b += 1 12973 12974 v.FontAscent = int16(xgb.Get16(buf[b:])) 12975 b += 2 12976 12977 v.FontDescent = int16(xgb.Get16(buf[b:])) 12978 b += 2 12979 12980 v.CharInfosLen = xgb.Get32(buf[b:]) 12981 b += 4 12982 12983 v.Properties = make([]Fontprop, v.PropertiesLen) 12984 b += FontpropReadList(buf[b:], v.Properties) 12985 12986 b = (b + 3) & ^3 // alignment gap 12987 12988 v.CharInfos = make([]Charinfo, v.CharInfosLen) 12989 b += CharinfoReadList(buf[b:], v.CharInfos) 12990 12991 return v 12992 } 12993 12994 // Write request to wire for QueryFont 12995 // queryFontRequest writes a QueryFont request to a byte slice. 12996 func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { 12997 size := 8 12998 b := 0 12999 buf := make([]byte, size) 13000 13001 buf[b] = 47 // request opcode 13002 b += 1 13003 13004 b += 1 // padding 13005 13006 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13007 b += 2 13008 13009 xgb.Put32(buf[b:], uint32(Font)) 13010 b += 4 13011 13012 return buf 13013 } 13014 13015 // QueryKeymapCookie is a cookie used only for QueryKeymap requests. 13016 type QueryKeymapCookie struct { 13017 *xgb.Cookie 13018 } 13019 13020 // QueryKeymap sends a checked request. 13021 // If an error occurs, it will be returned with the reply by calling QueryKeymapCookie.Reply() 13022 func QueryKeymap(c *xgb.Conn) QueryKeymapCookie { 13023 cookie := c.NewCookie(true, true) 13024 c.NewRequest(queryKeymapRequest(c), cookie) 13025 return QueryKeymapCookie{cookie} 13026 } 13027 13028 // QueryKeymapUnchecked sends an unchecked request. 13029 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13030 func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { 13031 cookie := c.NewCookie(false, true) 13032 c.NewRequest(queryKeymapRequest(c), cookie) 13033 return QueryKeymapCookie{cookie} 13034 } 13035 13036 // QueryKeymapReply represents the data returned from a QueryKeymap request. 13037 type QueryKeymapReply struct { 13038 Sequence uint16 // sequence number of the request for this reply 13039 Length uint32 // number of bytes in this reply 13040 // padding: 1 bytes 13041 Keys []byte // size: 32 13042 } 13043 13044 // Reply blocks and returns the reply data for a QueryKeymap request. 13045 func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { 13046 buf, err := cook.Cookie.Reply() 13047 if err != nil { 13048 return nil, err 13049 } 13050 if buf == nil { 13051 return nil, nil 13052 } 13053 return queryKeymapReply(buf), nil 13054 } 13055 13056 // queryKeymapReply reads a byte slice into a QueryKeymapReply value. 13057 func queryKeymapReply(buf []byte) *QueryKeymapReply { 13058 v := new(QueryKeymapReply) 13059 b := 1 // skip reply determinant 13060 13061 b += 1 // padding 13062 13063 v.Sequence = xgb.Get16(buf[b:]) 13064 b += 2 13065 13066 v.Length = xgb.Get32(buf[b:]) // 4-byte units 13067 b += 4 13068 13069 v.Keys = make([]byte, 32) 13070 copy(v.Keys[:32], buf[b:]) 13071 b += int(32) 13072 13073 return v 13074 } 13075 13076 // Write request to wire for QueryKeymap 13077 // queryKeymapRequest writes a QueryKeymap request to a byte slice. 13078 func queryKeymapRequest(c *xgb.Conn) []byte { 13079 size := 4 13080 b := 0 13081 buf := make([]byte, size) 13082 13083 buf[b] = 44 // request opcode 13084 b += 1 13085 13086 b += 1 // padding 13087 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13088 b += 2 13089 13090 return buf 13091 } 13092 13093 // QueryPointerCookie is a cookie used only for QueryPointer requests. 13094 type QueryPointerCookie struct { 13095 *xgb.Cookie 13096 } 13097 13098 // QueryPointer sends a checked request. 13099 // If an error occurs, it will be returned with the reply by calling QueryPointerCookie.Reply() 13100 func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie { 13101 cookie := c.NewCookie(true, true) 13102 c.NewRequest(queryPointerRequest(c, Window), cookie) 13103 return QueryPointerCookie{cookie} 13104 } 13105 13106 // QueryPointerUnchecked sends an unchecked request. 13107 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13108 func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { 13109 cookie := c.NewCookie(false, true) 13110 c.NewRequest(queryPointerRequest(c, Window), cookie) 13111 return QueryPointerCookie{cookie} 13112 } 13113 13114 // QueryPointerReply represents the data returned from a QueryPointer request. 13115 type QueryPointerReply struct { 13116 Sequence uint16 // sequence number of the request for this reply 13117 Length uint32 // number of bytes in this reply 13118 SameScreen bool 13119 Root Window 13120 Child Window 13121 RootX int16 13122 RootY int16 13123 WinX int16 13124 WinY int16 13125 Mask uint16 13126 // padding: 2 bytes 13127 } 13128 13129 // Reply blocks and returns the reply data for a QueryPointer request. 13130 func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { 13131 buf, err := cook.Cookie.Reply() 13132 if err != nil { 13133 return nil, err 13134 } 13135 if buf == nil { 13136 return nil, nil 13137 } 13138 return queryPointerReply(buf), nil 13139 } 13140 13141 // queryPointerReply reads a byte slice into a QueryPointerReply value. 13142 func queryPointerReply(buf []byte) *QueryPointerReply { 13143 v := new(QueryPointerReply) 13144 b := 1 // skip reply determinant 13145 13146 if buf[b] == 1 { 13147 v.SameScreen = true 13148 } else { 13149 v.SameScreen = false 13150 } 13151 b += 1 13152 13153 v.Sequence = xgb.Get16(buf[b:]) 13154 b += 2 13155 13156 v.Length = xgb.Get32(buf[b:]) // 4-byte units 13157 b += 4 13158 13159 v.Root = Window(xgb.Get32(buf[b:])) 13160 b += 4 13161 13162 v.Child = Window(xgb.Get32(buf[b:])) 13163 b += 4 13164 13165 v.RootX = int16(xgb.Get16(buf[b:])) 13166 b += 2 13167 13168 v.RootY = int16(xgb.Get16(buf[b:])) 13169 b += 2 13170 13171 v.WinX = int16(xgb.Get16(buf[b:])) 13172 b += 2 13173 13174 v.WinY = int16(xgb.Get16(buf[b:])) 13175 b += 2 13176 13177 v.Mask = xgb.Get16(buf[b:]) 13178 b += 2 13179 13180 b += 2 // padding 13181 13182 return v 13183 } 13184 13185 // Write request to wire for QueryPointer 13186 // queryPointerRequest writes a QueryPointer request to a byte slice. 13187 func queryPointerRequest(c *xgb.Conn, Window Window) []byte { 13188 size := 8 13189 b := 0 13190 buf := make([]byte, size) 13191 13192 buf[b] = 38 // request opcode 13193 b += 1 13194 13195 b += 1 // padding 13196 13197 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13198 b += 2 13199 13200 xgb.Put32(buf[b:], uint32(Window)) 13201 b += 4 13202 13203 return buf 13204 } 13205 13206 // QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. 13207 type QueryTextExtentsCookie struct { 13208 *xgb.Cookie 13209 } 13210 13211 // QueryTextExtents sends a checked request. 13212 // If an error occurs, it will be returned with the reply by calling QueryTextExtentsCookie.Reply() 13213 func QueryTextExtents(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { 13214 cookie := c.NewCookie(true, true) 13215 c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) 13216 return QueryTextExtentsCookie{cookie} 13217 } 13218 13219 // QueryTextExtentsUnchecked sends an unchecked request. 13220 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13221 func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { 13222 cookie := c.NewCookie(false, true) 13223 c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) 13224 return QueryTextExtentsCookie{cookie} 13225 } 13226 13227 // QueryTextExtentsReply represents the data returned from a QueryTextExtents request. 13228 type QueryTextExtentsReply struct { 13229 Sequence uint16 // sequence number of the request for this reply 13230 Length uint32 // number of bytes in this reply 13231 DrawDirection byte 13232 FontAscent int16 13233 FontDescent int16 13234 OverallAscent int16 13235 OverallDescent int16 13236 OverallWidth int32 13237 OverallLeft int32 13238 OverallRight int32 13239 } 13240 13241 // Reply blocks and returns the reply data for a QueryTextExtents request. 13242 func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { 13243 buf, err := cook.Cookie.Reply() 13244 if err != nil { 13245 return nil, err 13246 } 13247 if buf == nil { 13248 return nil, nil 13249 } 13250 return queryTextExtentsReply(buf), nil 13251 } 13252 13253 // queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. 13254 func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { 13255 v := new(QueryTextExtentsReply) 13256 b := 1 // skip reply determinant 13257 13258 v.DrawDirection = buf[b] 13259 b += 1 13260 13261 v.Sequence = xgb.Get16(buf[b:]) 13262 b += 2 13263 13264 v.Length = xgb.Get32(buf[b:]) // 4-byte units 13265 b += 4 13266 13267 v.FontAscent = int16(xgb.Get16(buf[b:])) 13268 b += 2 13269 13270 v.FontDescent = int16(xgb.Get16(buf[b:])) 13271 b += 2 13272 13273 v.OverallAscent = int16(xgb.Get16(buf[b:])) 13274 b += 2 13275 13276 v.OverallDescent = int16(xgb.Get16(buf[b:])) 13277 b += 2 13278 13279 v.OverallWidth = int32(xgb.Get32(buf[b:])) 13280 b += 4 13281 13282 v.OverallLeft = int32(xgb.Get32(buf[b:])) 13283 b += 4 13284 13285 v.OverallRight = int32(xgb.Get32(buf[b:])) 13286 b += 4 13287 13288 return v 13289 } 13290 13291 // Write request to wire for QueryTextExtents 13292 // queryTextExtentsRequest writes a QueryTextExtents request to a byte slice. 13293 func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { 13294 size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) 13295 b := 0 13296 buf := make([]byte, size) 13297 13298 buf[b] = 48 // request opcode 13299 b += 1 13300 13301 buf[b] = byte((int(StringLen) & 1)) 13302 b += 1 13303 13304 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13305 b += 2 13306 13307 xgb.Put32(buf[b:], uint32(Font)) 13308 b += 4 13309 13310 b += Char2bListBytes(buf[b:], String) 13311 13312 // skip writing local field: StringLen (2) :: uint16 13313 13314 return buf 13315 } 13316 13317 // QueryTreeCookie is a cookie used only for QueryTree requests. 13318 type QueryTreeCookie struct { 13319 *xgb.Cookie 13320 } 13321 13322 // QueryTree sends a checked request. 13323 // If an error occurs, it will be returned with the reply by calling QueryTreeCookie.Reply() 13324 func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie { 13325 cookie := c.NewCookie(true, true) 13326 c.NewRequest(queryTreeRequest(c, Window), cookie) 13327 return QueryTreeCookie{cookie} 13328 } 13329 13330 // QueryTreeUnchecked sends an unchecked request. 13331 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13332 func QueryTreeUnchecked(c *xgb.Conn, Window Window) QueryTreeCookie { 13333 cookie := c.NewCookie(false, true) 13334 c.NewRequest(queryTreeRequest(c, Window), cookie) 13335 return QueryTreeCookie{cookie} 13336 } 13337 13338 // QueryTreeReply represents the data returned from a QueryTree request. 13339 type QueryTreeReply struct { 13340 Sequence uint16 // sequence number of the request for this reply 13341 Length uint32 // number of bytes in this reply 13342 // padding: 1 bytes 13343 Root Window 13344 Parent Window 13345 ChildrenLen uint16 13346 // padding: 14 bytes 13347 Children []Window // size: xgb.Pad((int(ChildrenLen) * 4)) 13348 } 13349 13350 // Reply blocks and returns the reply data for a QueryTree request. 13351 func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { 13352 buf, err := cook.Cookie.Reply() 13353 if err != nil { 13354 return nil, err 13355 } 13356 if buf == nil { 13357 return nil, nil 13358 } 13359 return queryTreeReply(buf), nil 13360 } 13361 13362 // queryTreeReply reads a byte slice into a QueryTreeReply value. 13363 func queryTreeReply(buf []byte) *QueryTreeReply { 13364 v := new(QueryTreeReply) 13365 b := 1 // skip reply determinant 13366 13367 b += 1 // padding 13368 13369 v.Sequence = xgb.Get16(buf[b:]) 13370 b += 2 13371 13372 v.Length = xgb.Get32(buf[b:]) // 4-byte units 13373 b += 4 13374 13375 v.Root = Window(xgb.Get32(buf[b:])) 13376 b += 4 13377 13378 v.Parent = Window(xgb.Get32(buf[b:])) 13379 b += 4 13380 13381 v.ChildrenLen = xgb.Get16(buf[b:]) 13382 b += 2 13383 13384 b += 14 // padding 13385 13386 v.Children = make([]Window, v.ChildrenLen) 13387 for i := 0; i < int(v.ChildrenLen); i++ { 13388 v.Children[i] = Window(xgb.Get32(buf[b:])) 13389 b += 4 13390 } 13391 13392 return v 13393 } 13394 13395 // Write request to wire for QueryTree 13396 // queryTreeRequest writes a QueryTree request to a byte slice. 13397 func queryTreeRequest(c *xgb.Conn, Window Window) []byte { 13398 size := 8 13399 b := 0 13400 buf := make([]byte, size) 13401 13402 buf[b] = 15 // request opcode 13403 b += 1 13404 13405 b += 1 // padding 13406 13407 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13408 b += 2 13409 13410 xgb.Put32(buf[b:], uint32(Window)) 13411 b += 4 13412 13413 return buf 13414 } 13415 13416 // RecolorCursorCookie is a cookie used only for RecolorCursor requests. 13417 type RecolorCursorCookie struct { 13418 *xgb.Cookie 13419 } 13420 13421 // RecolorCursor sends an unchecked request. 13422 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13423 func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { 13424 cookie := c.NewCookie(false, false) 13425 c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) 13426 return RecolorCursorCookie{cookie} 13427 } 13428 13429 // RecolorCursorChecked sends a checked request. 13430 // If an error occurs, it can be retrieved using RecolorCursorCookie.Check() 13431 func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { 13432 cookie := c.NewCookie(true, false) 13433 c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) 13434 return RecolorCursorCookie{cookie} 13435 } 13436 13437 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13438 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13439 func (cook RecolorCursorCookie) Check() error { 13440 return cook.Cookie.Check() 13441 } 13442 13443 // Write request to wire for RecolorCursor 13444 // recolorCursorRequest writes a RecolorCursor request to a byte slice. 13445 func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { 13446 size := 20 13447 b := 0 13448 buf := make([]byte, size) 13449 13450 buf[b] = 96 // request opcode 13451 b += 1 13452 13453 b += 1 // padding 13454 13455 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13456 b += 2 13457 13458 xgb.Put32(buf[b:], uint32(Cursor)) 13459 b += 4 13460 13461 xgb.Put16(buf[b:], ForeRed) 13462 b += 2 13463 13464 xgb.Put16(buf[b:], ForeGreen) 13465 b += 2 13466 13467 xgb.Put16(buf[b:], ForeBlue) 13468 b += 2 13469 13470 xgb.Put16(buf[b:], BackRed) 13471 b += 2 13472 13473 xgb.Put16(buf[b:], BackGreen) 13474 b += 2 13475 13476 xgb.Put16(buf[b:], BackBlue) 13477 b += 2 13478 13479 return buf 13480 } 13481 13482 // ReparentWindowCookie is a cookie used only for ReparentWindow requests. 13483 type ReparentWindowCookie struct { 13484 *xgb.Cookie 13485 } 13486 13487 // ReparentWindow sends an unchecked request. 13488 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13489 func ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { 13490 cookie := c.NewCookie(false, false) 13491 c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) 13492 return ReparentWindowCookie{cookie} 13493 } 13494 13495 // ReparentWindowChecked sends a checked request. 13496 // If an error occurs, it can be retrieved using ReparentWindowCookie.Check() 13497 func ReparentWindowChecked(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { 13498 cookie := c.NewCookie(true, false) 13499 c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) 13500 return ReparentWindowCookie{cookie} 13501 } 13502 13503 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13504 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13505 func (cook ReparentWindowCookie) Check() error { 13506 return cook.Cookie.Check() 13507 } 13508 13509 // Write request to wire for ReparentWindow 13510 // reparentWindowRequest writes a ReparentWindow request to a byte slice. 13511 func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) []byte { 13512 size := 16 13513 b := 0 13514 buf := make([]byte, size) 13515 13516 buf[b] = 7 // request opcode 13517 b += 1 13518 13519 b += 1 // padding 13520 13521 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13522 b += 2 13523 13524 xgb.Put32(buf[b:], uint32(Window)) 13525 b += 4 13526 13527 xgb.Put32(buf[b:], uint32(Parent)) 13528 b += 4 13529 13530 xgb.Put16(buf[b:], uint16(X)) 13531 b += 2 13532 13533 xgb.Put16(buf[b:], uint16(Y)) 13534 b += 2 13535 13536 return buf 13537 } 13538 13539 // RotatePropertiesCookie is a cookie used only for RotateProperties requests. 13540 type RotatePropertiesCookie struct { 13541 *xgb.Cookie 13542 } 13543 13544 // RotateProperties sends an unchecked request. 13545 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13546 func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { 13547 cookie := c.NewCookie(false, false) 13548 c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) 13549 return RotatePropertiesCookie{cookie} 13550 } 13551 13552 // RotatePropertiesChecked sends a checked request. 13553 // If an error occurs, it can be retrieved using RotatePropertiesCookie.Check() 13554 func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { 13555 cookie := c.NewCookie(true, false) 13556 c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) 13557 return RotatePropertiesCookie{cookie} 13558 } 13559 13560 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13561 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13562 func (cook RotatePropertiesCookie) Check() error { 13563 return cook.Cookie.Check() 13564 } 13565 13566 // Write request to wire for RotateProperties 13567 // rotatePropertiesRequest writes a RotateProperties request to a byte slice. 13568 func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { 13569 size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) 13570 b := 0 13571 buf := make([]byte, size) 13572 13573 buf[b] = 114 // request opcode 13574 b += 1 13575 13576 b += 1 // padding 13577 13578 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13579 b += 2 13580 13581 xgb.Put32(buf[b:], uint32(Window)) 13582 b += 4 13583 13584 xgb.Put16(buf[b:], AtomsLen) 13585 b += 2 13586 13587 xgb.Put16(buf[b:], uint16(Delta)) 13588 b += 2 13589 13590 for i := 0; i < int(AtomsLen); i++ { 13591 xgb.Put32(buf[b:], uint32(Atoms[i])) 13592 b += 4 13593 } 13594 13595 return buf 13596 } 13597 13598 // SendEventCookie is a cookie used only for SendEvent requests. 13599 type SendEventCookie struct { 13600 *xgb.Cookie 13601 } 13602 13603 // SendEvent sends an unchecked request. 13604 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13605 func SendEvent(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { 13606 cookie := c.NewCookie(false, false) 13607 c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) 13608 return SendEventCookie{cookie} 13609 } 13610 13611 // SendEventChecked sends a checked request. 13612 // If an error occurs, it can be retrieved using SendEventCookie.Check() 13613 func SendEventChecked(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { 13614 cookie := c.NewCookie(true, false) 13615 c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) 13616 return SendEventCookie{cookie} 13617 } 13618 13619 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13620 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13621 func (cook SendEventCookie) Check() error { 13622 return cook.Cookie.Check() 13623 } 13624 13625 // Write request to wire for SendEvent 13626 // sendEventRequest writes a SendEvent request to a byte slice. 13627 func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte { 13628 size := 44 13629 b := 0 13630 buf := make([]byte, size) 13631 13632 buf[b] = 25 // request opcode 13633 b += 1 13634 13635 if Propagate { 13636 buf[b] = 1 13637 } else { 13638 buf[b] = 0 13639 } 13640 b += 1 13641 13642 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13643 b += 2 13644 13645 xgb.Put32(buf[b:], uint32(Destination)) 13646 b += 4 13647 13648 xgb.Put32(buf[b:], EventMask) 13649 b += 4 13650 13651 copy(buf[b:], Event[:32]) 13652 b += int(32) 13653 13654 return buf 13655 } 13656 13657 // SetAccessControlCookie is a cookie used only for SetAccessControl requests. 13658 type SetAccessControlCookie struct { 13659 *xgb.Cookie 13660 } 13661 13662 // SetAccessControl sends an unchecked request. 13663 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13664 func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie { 13665 cookie := c.NewCookie(false, false) 13666 c.NewRequest(setAccessControlRequest(c, Mode), cookie) 13667 return SetAccessControlCookie{cookie} 13668 } 13669 13670 // SetAccessControlChecked sends a checked request. 13671 // If an error occurs, it can be retrieved using SetAccessControlCookie.Check() 13672 func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie { 13673 cookie := c.NewCookie(true, false) 13674 c.NewRequest(setAccessControlRequest(c, Mode), cookie) 13675 return SetAccessControlCookie{cookie} 13676 } 13677 13678 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13679 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13680 func (cook SetAccessControlCookie) Check() error { 13681 return cook.Cookie.Check() 13682 } 13683 13684 // Write request to wire for SetAccessControl 13685 // setAccessControlRequest writes a SetAccessControl request to a byte slice. 13686 func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { 13687 size := 4 13688 b := 0 13689 buf := make([]byte, size) 13690 13691 buf[b] = 111 // request opcode 13692 b += 1 13693 13694 buf[b] = Mode 13695 b += 1 13696 13697 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13698 b += 2 13699 13700 return buf 13701 } 13702 13703 // SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. 13704 type SetClipRectanglesCookie struct { 13705 *xgb.Cookie 13706 } 13707 13708 // SetClipRectangles sends an unchecked request. 13709 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13710 func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { 13711 cookie := c.NewCookie(false, false) 13712 c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) 13713 return SetClipRectanglesCookie{cookie} 13714 } 13715 13716 // SetClipRectanglesChecked sends a checked request. 13717 // If an error occurs, it can be retrieved using SetClipRectanglesCookie.Check() 13718 func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { 13719 cookie := c.NewCookie(true, false) 13720 c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) 13721 return SetClipRectanglesCookie{cookie} 13722 } 13723 13724 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13725 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13726 func (cook SetClipRectanglesCookie) Check() error { 13727 return cook.Cookie.Check() 13728 } 13729 13730 // Write request to wire for SetClipRectangles 13731 // setClipRectanglesRequest writes a SetClipRectangles request to a byte slice. 13732 func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { 13733 size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) 13734 b := 0 13735 buf := make([]byte, size) 13736 13737 buf[b] = 59 // request opcode 13738 b += 1 13739 13740 buf[b] = Ordering 13741 b += 1 13742 13743 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13744 b += 2 13745 13746 xgb.Put32(buf[b:], uint32(Gc)) 13747 b += 4 13748 13749 xgb.Put16(buf[b:], uint16(ClipXOrigin)) 13750 b += 2 13751 13752 xgb.Put16(buf[b:], uint16(ClipYOrigin)) 13753 b += 2 13754 13755 b += RectangleListBytes(buf[b:], Rectangles) 13756 13757 return buf 13758 } 13759 13760 // SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. 13761 type SetCloseDownModeCookie struct { 13762 *xgb.Cookie 13763 } 13764 13765 // SetCloseDownMode sends an unchecked request. 13766 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13767 func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { 13768 cookie := c.NewCookie(false, false) 13769 c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) 13770 return SetCloseDownModeCookie{cookie} 13771 } 13772 13773 // SetCloseDownModeChecked sends a checked request. 13774 // If an error occurs, it can be retrieved using SetCloseDownModeCookie.Check() 13775 func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { 13776 cookie := c.NewCookie(true, false) 13777 c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) 13778 return SetCloseDownModeCookie{cookie} 13779 } 13780 13781 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13782 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13783 func (cook SetCloseDownModeCookie) Check() error { 13784 return cook.Cookie.Check() 13785 } 13786 13787 // Write request to wire for SetCloseDownMode 13788 // setCloseDownModeRequest writes a SetCloseDownMode request to a byte slice. 13789 func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { 13790 size := 4 13791 b := 0 13792 buf := make([]byte, size) 13793 13794 buf[b] = 112 // request opcode 13795 b += 1 13796 13797 buf[b] = Mode 13798 b += 1 13799 13800 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13801 b += 2 13802 13803 return buf 13804 } 13805 13806 // SetDashesCookie is a cookie used only for SetDashes requests. 13807 type SetDashesCookie struct { 13808 *xgb.Cookie 13809 } 13810 13811 // SetDashes sends an unchecked request. 13812 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13813 func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { 13814 cookie := c.NewCookie(false, false) 13815 c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) 13816 return SetDashesCookie{cookie} 13817 } 13818 13819 // SetDashesChecked sends a checked request. 13820 // If an error occurs, it can be retrieved using SetDashesCookie.Check() 13821 func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { 13822 cookie := c.NewCookie(true, false) 13823 c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) 13824 return SetDashesCookie{cookie} 13825 } 13826 13827 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13828 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13829 func (cook SetDashesCookie) Check() error { 13830 return cook.Cookie.Check() 13831 } 13832 13833 // Write request to wire for SetDashes 13834 // setDashesRequest writes a SetDashes request to a byte slice. 13835 func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { 13836 size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) 13837 b := 0 13838 buf := make([]byte, size) 13839 13840 buf[b] = 58 // request opcode 13841 b += 1 13842 13843 b += 1 // padding 13844 13845 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13846 b += 2 13847 13848 xgb.Put32(buf[b:], uint32(Gc)) 13849 b += 4 13850 13851 xgb.Put16(buf[b:], DashOffset) 13852 b += 2 13853 13854 xgb.Put16(buf[b:], DashesLen) 13855 b += 2 13856 13857 copy(buf[b:], Dashes[:DashesLen]) 13858 b += int(DashesLen) 13859 13860 return buf 13861 } 13862 13863 // SetFontPathCookie is a cookie used only for SetFontPath requests. 13864 type SetFontPathCookie struct { 13865 *xgb.Cookie 13866 } 13867 13868 // SetFontPath sends an unchecked request. 13869 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13870 func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { 13871 cookie := c.NewCookie(false, false) 13872 c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) 13873 return SetFontPathCookie{cookie} 13874 } 13875 13876 // SetFontPathChecked sends a checked request. 13877 // If an error occurs, it can be retrieved using SetFontPathCookie.Check() 13878 func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { 13879 cookie := c.NewCookie(true, false) 13880 c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) 13881 return SetFontPathCookie{cookie} 13882 } 13883 13884 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13885 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13886 func (cook SetFontPathCookie) Check() error { 13887 return cook.Cookie.Check() 13888 } 13889 13890 // Write request to wire for SetFontPath 13891 // setFontPathRequest writes a SetFontPath request to a byte slice. 13892 func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { 13893 size := xgb.Pad((8 + StrListSize(Font))) 13894 b := 0 13895 buf := make([]byte, size) 13896 13897 buf[b] = 51 // request opcode 13898 b += 1 13899 13900 b += 1 // padding 13901 13902 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13903 b += 2 13904 13905 xgb.Put16(buf[b:], FontQty) 13906 b += 2 13907 13908 b += 2 // padding 13909 13910 b += StrListBytes(buf[b:], Font) 13911 13912 return buf 13913 } 13914 13915 // SetInputFocusCookie is a cookie used only for SetInputFocus requests. 13916 type SetInputFocusCookie struct { 13917 *xgb.Cookie 13918 } 13919 13920 // SetInputFocus sends an unchecked request. 13921 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13922 func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { 13923 cookie := c.NewCookie(false, false) 13924 c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) 13925 return SetInputFocusCookie{cookie} 13926 } 13927 13928 // SetInputFocusChecked sends a checked request. 13929 // If an error occurs, it can be retrieved using SetInputFocusCookie.Check() 13930 func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { 13931 cookie := c.NewCookie(true, false) 13932 c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) 13933 return SetInputFocusCookie{cookie} 13934 } 13935 13936 // Check returns an error if one occurred for checked requests that are not expecting a reply. 13937 // This cannot be called for requests expecting a reply, nor for unchecked requests. 13938 func (cook SetInputFocusCookie) Check() error { 13939 return cook.Cookie.Check() 13940 } 13941 13942 // Write request to wire for SetInputFocus 13943 // setInputFocusRequest writes a SetInputFocus request to a byte slice. 13944 func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte { 13945 size := 12 13946 b := 0 13947 buf := make([]byte, size) 13948 13949 buf[b] = 42 // request opcode 13950 b += 1 13951 13952 buf[b] = RevertTo 13953 b += 1 13954 13955 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 13956 b += 2 13957 13958 xgb.Put32(buf[b:], uint32(Focus)) 13959 b += 4 13960 13961 xgb.Put32(buf[b:], uint32(Time)) 13962 b += 4 13963 13964 return buf 13965 } 13966 13967 // SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. 13968 type SetModifierMappingCookie struct { 13969 *xgb.Cookie 13970 } 13971 13972 // SetModifierMapping sends a checked request. 13973 // If an error occurs, it will be returned with the reply by calling SetModifierMappingCookie.Reply() 13974 func SetModifierMapping(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { 13975 cookie := c.NewCookie(true, true) 13976 c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) 13977 return SetModifierMappingCookie{cookie} 13978 } 13979 13980 // SetModifierMappingUnchecked sends an unchecked request. 13981 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 13982 func SetModifierMappingUnchecked(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { 13983 cookie := c.NewCookie(false, true) 13984 c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) 13985 return SetModifierMappingCookie{cookie} 13986 } 13987 13988 // SetModifierMappingReply represents the data returned from a SetModifierMapping request. 13989 type SetModifierMappingReply struct { 13990 Sequence uint16 // sequence number of the request for this reply 13991 Length uint32 // number of bytes in this reply 13992 Status byte 13993 } 13994 13995 // Reply blocks and returns the reply data for a SetModifierMapping request. 13996 func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { 13997 buf, err := cook.Cookie.Reply() 13998 if err != nil { 13999 return nil, err 14000 } 14001 if buf == nil { 14002 return nil, nil 14003 } 14004 return setModifierMappingReply(buf), nil 14005 } 14006 14007 // setModifierMappingReply reads a byte slice into a SetModifierMappingReply value. 14008 func setModifierMappingReply(buf []byte) *SetModifierMappingReply { 14009 v := new(SetModifierMappingReply) 14010 b := 1 // skip reply determinant 14011 14012 v.Status = buf[b] 14013 b += 1 14014 14015 v.Sequence = xgb.Get16(buf[b:]) 14016 b += 2 14017 14018 v.Length = xgb.Get32(buf[b:]) // 4-byte units 14019 b += 4 14020 14021 return v 14022 } 14023 14024 // Write request to wire for SetModifierMapping 14025 // setModifierMappingRequest writes a SetModifierMapping request to a byte slice. 14026 func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) []byte { 14027 size := xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) 14028 b := 0 14029 buf := make([]byte, size) 14030 14031 buf[b] = 118 // request opcode 14032 b += 1 14033 14034 buf[b] = KeycodesPerModifier 14035 b += 1 14036 14037 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14038 b += 2 14039 14040 for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { 14041 buf[b] = byte(Keycodes[i]) 14042 b += 1 14043 } 14044 14045 return buf 14046 } 14047 14048 // SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. 14049 type SetPointerMappingCookie struct { 14050 *xgb.Cookie 14051 } 14052 14053 // SetPointerMapping sends a checked request. 14054 // If an error occurs, it will be returned with the reply by calling SetPointerMappingCookie.Reply() 14055 func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { 14056 cookie := c.NewCookie(true, true) 14057 c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) 14058 return SetPointerMappingCookie{cookie} 14059 } 14060 14061 // SetPointerMappingUnchecked sends an unchecked request. 14062 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14063 func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { 14064 cookie := c.NewCookie(false, true) 14065 c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) 14066 return SetPointerMappingCookie{cookie} 14067 } 14068 14069 // SetPointerMappingReply represents the data returned from a SetPointerMapping request. 14070 type SetPointerMappingReply struct { 14071 Sequence uint16 // sequence number of the request for this reply 14072 Length uint32 // number of bytes in this reply 14073 Status byte 14074 } 14075 14076 // Reply blocks and returns the reply data for a SetPointerMapping request. 14077 func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { 14078 buf, err := cook.Cookie.Reply() 14079 if err != nil { 14080 return nil, err 14081 } 14082 if buf == nil { 14083 return nil, nil 14084 } 14085 return setPointerMappingReply(buf), nil 14086 } 14087 14088 // setPointerMappingReply reads a byte slice into a SetPointerMappingReply value. 14089 func setPointerMappingReply(buf []byte) *SetPointerMappingReply { 14090 v := new(SetPointerMappingReply) 14091 b := 1 // skip reply determinant 14092 14093 v.Status = buf[b] 14094 b += 1 14095 14096 v.Sequence = xgb.Get16(buf[b:]) 14097 b += 2 14098 14099 v.Length = xgb.Get32(buf[b:]) // 4-byte units 14100 b += 4 14101 14102 return v 14103 } 14104 14105 // Write request to wire for SetPointerMapping 14106 // setPointerMappingRequest writes a SetPointerMapping request to a byte slice. 14107 func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { 14108 size := xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) 14109 b := 0 14110 buf := make([]byte, size) 14111 14112 buf[b] = 116 // request opcode 14113 b += 1 14114 14115 buf[b] = MapLen 14116 b += 1 14117 14118 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14119 b += 2 14120 14121 copy(buf[b:], Map[:MapLen]) 14122 b += int(MapLen) 14123 14124 return buf 14125 } 14126 14127 // SetScreenSaverCookie is a cookie used only for SetScreenSaver requests. 14128 type SetScreenSaverCookie struct { 14129 *xgb.Cookie 14130 } 14131 14132 // SetScreenSaver sends an unchecked request. 14133 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14134 func SetScreenSaver(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { 14135 cookie := c.NewCookie(false, false) 14136 c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) 14137 return SetScreenSaverCookie{cookie} 14138 } 14139 14140 // SetScreenSaverChecked sends a checked request. 14141 // If an error occurs, it can be retrieved using SetScreenSaverCookie.Check() 14142 func SetScreenSaverChecked(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { 14143 cookie := c.NewCookie(true, false) 14144 c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) 14145 return SetScreenSaverCookie{cookie} 14146 } 14147 14148 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14149 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14150 func (cook SetScreenSaverCookie) Check() error { 14151 return cook.Cookie.Check() 14152 } 14153 14154 // Write request to wire for SetScreenSaver 14155 // setScreenSaverRequest writes a SetScreenSaver request to a byte slice. 14156 func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) []byte { 14157 size := 12 14158 b := 0 14159 buf := make([]byte, size) 14160 14161 buf[b] = 107 // request opcode 14162 b += 1 14163 14164 b += 1 // padding 14165 14166 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14167 b += 2 14168 14169 xgb.Put16(buf[b:], uint16(Timeout)) 14170 b += 2 14171 14172 xgb.Put16(buf[b:], uint16(Interval)) 14173 b += 2 14174 14175 buf[b] = PreferBlanking 14176 b += 1 14177 14178 buf[b] = AllowExposures 14179 b += 1 14180 14181 return buf 14182 } 14183 14184 // SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests. 14185 type SetSelectionOwnerCookie struct { 14186 *xgb.Cookie 14187 } 14188 14189 // SetSelectionOwner sends an unchecked request. 14190 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14191 func SetSelectionOwner(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { 14192 cookie := c.NewCookie(false, false) 14193 c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) 14194 return SetSelectionOwnerCookie{cookie} 14195 } 14196 14197 // SetSelectionOwnerChecked sends a checked request. 14198 // If an error occurs, it can be retrieved using SetSelectionOwnerCookie.Check() 14199 func SetSelectionOwnerChecked(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { 14200 cookie := c.NewCookie(true, false) 14201 c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) 14202 return SetSelectionOwnerCookie{cookie} 14203 } 14204 14205 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14206 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14207 func (cook SetSelectionOwnerCookie) Check() error { 14208 return cook.Cookie.Check() 14209 } 14210 14211 // Write request to wire for SetSelectionOwner 14212 // setSelectionOwnerRequest writes a SetSelectionOwner request to a byte slice. 14213 func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) []byte { 14214 size := 16 14215 b := 0 14216 buf := make([]byte, size) 14217 14218 buf[b] = 22 // request opcode 14219 b += 1 14220 14221 b += 1 // padding 14222 14223 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14224 b += 2 14225 14226 xgb.Put32(buf[b:], uint32(Owner)) 14227 b += 4 14228 14229 xgb.Put32(buf[b:], uint32(Selection)) 14230 b += 4 14231 14232 xgb.Put32(buf[b:], uint32(Time)) 14233 b += 4 14234 14235 return buf 14236 } 14237 14238 // StoreColorsCookie is a cookie used only for StoreColors requests. 14239 type StoreColorsCookie struct { 14240 *xgb.Cookie 14241 } 14242 14243 // StoreColors sends an unchecked request. 14244 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14245 func StoreColors(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { 14246 cookie := c.NewCookie(false, false) 14247 c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) 14248 return StoreColorsCookie{cookie} 14249 } 14250 14251 // StoreColorsChecked sends a checked request. 14252 // If an error occurs, it can be retrieved using StoreColorsCookie.Check() 14253 func StoreColorsChecked(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { 14254 cookie := c.NewCookie(true, false) 14255 c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) 14256 return StoreColorsCookie{cookie} 14257 } 14258 14259 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14260 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14261 func (cook StoreColorsCookie) Check() error { 14262 return cook.Cookie.Check() 14263 } 14264 14265 // Write request to wire for StoreColors 14266 // storeColorsRequest writes a StoreColors request to a byte slice. 14267 func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { 14268 size := xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) 14269 b := 0 14270 buf := make([]byte, size) 14271 14272 buf[b] = 89 // request opcode 14273 b += 1 14274 14275 b += 1 // padding 14276 14277 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14278 b += 2 14279 14280 xgb.Put32(buf[b:], uint32(Cmap)) 14281 b += 4 14282 14283 b += ColoritemListBytes(buf[b:], Items) 14284 14285 return buf 14286 } 14287 14288 // StoreNamedColorCookie is a cookie used only for StoreNamedColor requests. 14289 type StoreNamedColorCookie struct { 14290 *xgb.Cookie 14291 } 14292 14293 // StoreNamedColor sends an unchecked request. 14294 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14295 func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { 14296 cookie := c.NewCookie(false, false) 14297 c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) 14298 return StoreNamedColorCookie{cookie} 14299 } 14300 14301 // StoreNamedColorChecked sends a checked request. 14302 // If an error occurs, it can be retrieved using StoreNamedColorCookie.Check() 14303 func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { 14304 cookie := c.NewCookie(true, false) 14305 c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) 14306 return StoreNamedColorCookie{cookie} 14307 } 14308 14309 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14310 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14311 func (cook StoreNamedColorCookie) Check() error { 14312 return cook.Cookie.Check() 14313 } 14314 14315 // Write request to wire for StoreNamedColor 14316 // storeNamedColorRequest writes a StoreNamedColor request to a byte slice. 14317 func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { 14318 size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) 14319 b := 0 14320 buf := make([]byte, size) 14321 14322 buf[b] = 90 // request opcode 14323 b += 1 14324 14325 buf[b] = Flags 14326 b += 1 14327 14328 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14329 b += 2 14330 14331 xgb.Put32(buf[b:], uint32(Cmap)) 14332 b += 4 14333 14334 xgb.Put32(buf[b:], Pixel) 14335 b += 4 14336 14337 xgb.Put16(buf[b:], NameLen) 14338 b += 2 14339 14340 b += 2 // padding 14341 14342 copy(buf[b:], Name[:NameLen]) 14343 b += int(NameLen) 14344 14345 return buf 14346 } 14347 14348 // TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. 14349 type TranslateCoordinatesCookie struct { 14350 *xgb.Cookie 14351 } 14352 14353 // TranslateCoordinates sends a checked request. 14354 // If an error occurs, it will be returned with the reply by calling TranslateCoordinatesCookie.Reply() 14355 func TranslateCoordinates(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { 14356 cookie := c.NewCookie(true, true) 14357 c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) 14358 return TranslateCoordinatesCookie{cookie} 14359 } 14360 14361 // TranslateCoordinatesUnchecked sends an unchecked request. 14362 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14363 func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { 14364 cookie := c.NewCookie(false, true) 14365 c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) 14366 return TranslateCoordinatesCookie{cookie} 14367 } 14368 14369 // TranslateCoordinatesReply represents the data returned from a TranslateCoordinates request. 14370 type TranslateCoordinatesReply struct { 14371 Sequence uint16 // sequence number of the request for this reply 14372 Length uint32 // number of bytes in this reply 14373 SameScreen bool 14374 Child Window 14375 DstX int16 14376 DstY int16 14377 } 14378 14379 // Reply blocks and returns the reply data for a TranslateCoordinates request. 14380 func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { 14381 buf, err := cook.Cookie.Reply() 14382 if err != nil { 14383 return nil, err 14384 } 14385 if buf == nil { 14386 return nil, nil 14387 } 14388 return translateCoordinatesReply(buf), nil 14389 } 14390 14391 // translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value. 14392 func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { 14393 v := new(TranslateCoordinatesReply) 14394 b := 1 // skip reply determinant 14395 14396 if buf[b] == 1 { 14397 v.SameScreen = true 14398 } else { 14399 v.SameScreen = false 14400 } 14401 b += 1 14402 14403 v.Sequence = xgb.Get16(buf[b:]) 14404 b += 2 14405 14406 v.Length = xgb.Get32(buf[b:]) // 4-byte units 14407 b += 4 14408 14409 v.Child = Window(xgb.Get32(buf[b:])) 14410 b += 4 14411 14412 v.DstX = int16(xgb.Get16(buf[b:])) 14413 b += 2 14414 14415 v.DstY = int16(xgb.Get16(buf[b:])) 14416 b += 2 14417 14418 return v 14419 } 14420 14421 // Write request to wire for TranslateCoordinates 14422 // translateCoordinatesRequest writes a TranslateCoordinates request to a byte slice. 14423 func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { 14424 size := 16 14425 b := 0 14426 buf := make([]byte, size) 14427 14428 buf[b] = 40 // request opcode 14429 b += 1 14430 14431 b += 1 // padding 14432 14433 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14434 b += 2 14435 14436 xgb.Put32(buf[b:], uint32(SrcWindow)) 14437 b += 4 14438 14439 xgb.Put32(buf[b:], uint32(DstWindow)) 14440 b += 4 14441 14442 xgb.Put16(buf[b:], uint16(SrcX)) 14443 b += 2 14444 14445 xgb.Put16(buf[b:], uint16(SrcY)) 14446 b += 2 14447 14448 return buf 14449 } 14450 14451 // UngrabButtonCookie is a cookie used only for UngrabButton requests. 14452 type UngrabButtonCookie struct { 14453 *xgb.Cookie 14454 } 14455 14456 // UngrabButton sends an unchecked request. 14457 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14458 func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { 14459 cookie := c.NewCookie(false, false) 14460 c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) 14461 return UngrabButtonCookie{cookie} 14462 } 14463 14464 // UngrabButtonChecked sends a checked request. 14465 // If an error occurs, it can be retrieved using UngrabButtonCookie.Check() 14466 func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { 14467 cookie := c.NewCookie(true, false) 14468 c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) 14469 return UngrabButtonCookie{cookie} 14470 } 14471 14472 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14473 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14474 func (cook UngrabButtonCookie) Check() error { 14475 return cook.Cookie.Check() 14476 } 14477 14478 // Write request to wire for UngrabButton 14479 // ungrabButtonRequest writes a UngrabButton request to a byte slice. 14480 func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte { 14481 size := 12 14482 b := 0 14483 buf := make([]byte, size) 14484 14485 buf[b] = 29 // request opcode 14486 b += 1 14487 14488 buf[b] = Button 14489 b += 1 14490 14491 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14492 b += 2 14493 14494 xgb.Put32(buf[b:], uint32(GrabWindow)) 14495 b += 4 14496 14497 xgb.Put16(buf[b:], Modifiers) 14498 b += 2 14499 14500 b += 2 // padding 14501 14502 return buf 14503 } 14504 14505 // UngrabKeyCookie is a cookie used only for UngrabKey requests. 14506 type UngrabKeyCookie struct { 14507 *xgb.Cookie 14508 } 14509 14510 // UngrabKey sends an unchecked request. 14511 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14512 func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { 14513 cookie := c.NewCookie(false, false) 14514 c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) 14515 return UngrabKeyCookie{cookie} 14516 } 14517 14518 // UngrabKeyChecked sends a checked request. 14519 // If an error occurs, it can be retrieved using UngrabKeyCookie.Check() 14520 func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { 14521 cookie := c.NewCookie(true, false) 14522 c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) 14523 return UngrabKeyCookie{cookie} 14524 } 14525 14526 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14527 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14528 func (cook UngrabKeyCookie) Check() error { 14529 return cook.Cookie.Check() 14530 } 14531 14532 // Write request to wire for UngrabKey 14533 // ungrabKeyRequest writes a UngrabKey request to a byte slice. 14534 func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte { 14535 size := 12 14536 b := 0 14537 buf := make([]byte, size) 14538 14539 buf[b] = 34 // request opcode 14540 b += 1 14541 14542 buf[b] = byte(Key) 14543 b += 1 14544 14545 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14546 b += 2 14547 14548 xgb.Put32(buf[b:], uint32(GrabWindow)) 14549 b += 4 14550 14551 xgb.Put16(buf[b:], Modifiers) 14552 b += 2 14553 14554 b += 2 // padding 14555 14556 return buf 14557 } 14558 14559 // UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. 14560 type UngrabKeyboardCookie struct { 14561 *xgb.Cookie 14562 } 14563 14564 // UngrabKeyboard sends an unchecked request. 14565 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14566 func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { 14567 cookie := c.NewCookie(false, false) 14568 c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) 14569 return UngrabKeyboardCookie{cookie} 14570 } 14571 14572 // UngrabKeyboardChecked sends a checked request. 14573 // If an error occurs, it can be retrieved using UngrabKeyboardCookie.Check() 14574 func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { 14575 cookie := c.NewCookie(true, false) 14576 c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) 14577 return UngrabKeyboardCookie{cookie} 14578 } 14579 14580 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14581 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14582 func (cook UngrabKeyboardCookie) Check() error { 14583 return cook.Cookie.Check() 14584 } 14585 14586 // Write request to wire for UngrabKeyboard 14587 // ungrabKeyboardRequest writes a UngrabKeyboard request to a byte slice. 14588 func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { 14589 size := 8 14590 b := 0 14591 buf := make([]byte, size) 14592 14593 buf[b] = 32 // request opcode 14594 b += 1 14595 14596 b += 1 // padding 14597 14598 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14599 b += 2 14600 14601 xgb.Put32(buf[b:], uint32(Time)) 14602 b += 4 14603 14604 return buf 14605 } 14606 14607 // UngrabPointerCookie is a cookie used only for UngrabPointer requests. 14608 type UngrabPointerCookie struct { 14609 *xgb.Cookie 14610 } 14611 14612 // UngrabPointer sends an unchecked request. 14613 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14614 func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { 14615 cookie := c.NewCookie(false, false) 14616 c.NewRequest(ungrabPointerRequest(c, Time), cookie) 14617 return UngrabPointerCookie{cookie} 14618 } 14619 14620 // UngrabPointerChecked sends a checked request. 14621 // If an error occurs, it can be retrieved using UngrabPointerCookie.Check() 14622 func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { 14623 cookie := c.NewCookie(true, false) 14624 c.NewRequest(ungrabPointerRequest(c, Time), cookie) 14625 return UngrabPointerCookie{cookie} 14626 } 14627 14628 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14629 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14630 func (cook UngrabPointerCookie) Check() error { 14631 return cook.Cookie.Check() 14632 } 14633 14634 // Write request to wire for UngrabPointer 14635 // ungrabPointerRequest writes a UngrabPointer request to a byte slice. 14636 func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { 14637 size := 8 14638 b := 0 14639 buf := make([]byte, size) 14640 14641 buf[b] = 27 // request opcode 14642 b += 1 14643 14644 b += 1 // padding 14645 14646 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14647 b += 2 14648 14649 xgb.Put32(buf[b:], uint32(Time)) 14650 b += 4 14651 14652 return buf 14653 } 14654 14655 // UngrabServerCookie is a cookie used only for UngrabServer requests. 14656 type UngrabServerCookie struct { 14657 *xgb.Cookie 14658 } 14659 14660 // UngrabServer sends an unchecked request. 14661 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14662 func UngrabServer(c *xgb.Conn) UngrabServerCookie { 14663 cookie := c.NewCookie(false, false) 14664 c.NewRequest(ungrabServerRequest(c), cookie) 14665 return UngrabServerCookie{cookie} 14666 } 14667 14668 // UngrabServerChecked sends a checked request. 14669 // If an error occurs, it can be retrieved using UngrabServerCookie.Check() 14670 func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { 14671 cookie := c.NewCookie(true, false) 14672 c.NewRequest(ungrabServerRequest(c), cookie) 14673 return UngrabServerCookie{cookie} 14674 } 14675 14676 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14677 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14678 func (cook UngrabServerCookie) Check() error { 14679 return cook.Cookie.Check() 14680 } 14681 14682 // Write request to wire for UngrabServer 14683 // ungrabServerRequest writes a UngrabServer request to a byte slice. 14684 func ungrabServerRequest(c *xgb.Conn) []byte { 14685 size := 4 14686 b := 0 14687 buf := make([]byte, size) 14688 14689 buf[b] = 37 // request opcode 14690 b += 1 14691 14692 b += 1 // padding 14693 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14694 b += 2 14695 14696 return buf 14697 } 14698 14699 // UninstallColormapCookie is a cookie used only for UninstallColormap requests. 14700 type UninstallColormapCookie struct { 14701 *xgb.Cookie 14702 } 14703 14704 // UninstallColormap sends an unchecked request. 14705 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14706 func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { 14707 cookie := c.NewCookie(false, false) 14708 c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) 14709 return UninstallColormapCookie{cookie} 14710 } 14711 14712 // UninstallColormapChecked sends a checked request. 14713 // If an error occurs, it can be retrieved using UninstallColormapCookie.Check() 14714 func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { 14715 cookie := c.NewCookie(true, false) 14716 c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) 14717 return UninstallColormapCookie{cookie} 14718 } 14719 14720 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14721 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14722 func (cook UninstallColormapCookie) Check() error { 14723 return cook.Cookie.Check() 14724 } 14725 14726 // Write request to wire for UninstallColormap 14727 // uninstallColormapRequest writes a UninstallColormap request to a byte slice. 14728 func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { 14729 size := 8 14730 b := 0 14731 buf := make([]byte, size) 14732 14733 buf[b] = 82 // request opcode 14734 b += 1 14735 14736 b += 1 // padding 14737 14738 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14739 b += 2 14740 14741 xgb.Put32(buf[b:], uint32(Cmap)) 14742 b += 4 14743 14744 return buf 14745 } 14746 14747 // UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. 14748 type UnmapSubwindowsCookie struct { 14749 *xgb.Cookie 14750 } 14751 14752 // UnmapSubwindows sends an unchecked request. 14753 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14754 func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { 14755 cookie := c.NewCookie(false, false) 14756 c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) 14757 return UnmapSubwindowsCookie{cookie} 14758 } 14759 14760 // UnmapSubwindowsChecked sends a checked request. 14761 // If an error occurs, it can be retrieved using UnmapSubwindowsCookie.Check() 14762 func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { 14763 cookie := c.NewCookie(true, false) 14764 c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) 14765 return UnmapSubwindowsCookie{cookie} 14766 } 14767 14768 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14769 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14770 func (cook UnmapSubwindowsCookie) Check() error { 14771 return cook.Cookie.Check() 14772 } 14773 14774 // Write request to wire for UnmapSubwindows 14775 // unmapSubwindowsRequest writes a UnmapSubwindows request to a byte slice. 14776 func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { 14777 size := 8 14778 b := 0 14779 buf := make([]byte, size) 14780 14781 buf[b] = 11 // request opcode 14782 b += 1 14783 14784 b += 1 // padding 14785 14786 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14787 b += 2 14788 14789 xgb.Put32(buf[b:], uint32(Window)) 14790 b += 4 14791 14792 return buf 14793 } 14794 14795 // UnmapWindowCookie is a cookie used only for UnmapWindow requests. 14796 type UnmapWindowCookie struct { 14797 *xgb.Cookie 14798 } 14799 14800 // UnmapWindow sends an unchecked request. 14801 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14802 func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { 14803 cookie := c.NewCookie(false, false) 14804 c.NewRequest(unmapWindowRequest(c, Window), cookie) 14805 return UnmapWindowCookie{cookie} 14806 } 14807 14808 // UnmapWindowChecked sends a checked request. 14809 // If an error occurs, it can be retrieved using UnmapWindowCookie.Check() 14810 func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { 14811 cookie := c.NewCookie(true, false) 14812 c.NewRequest(unmapWindowRequest(c, Window), cookie) 14813 return UnmapWindowCookie{cookie} 14814 } 14815 14816 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14817 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14818 func (cook UnmapWindowCookie) Check() error { 14819 return cook.Cookie.Check() 14820 } 14821 14822 // Write request to wire for UnmapWindow 14823 // unmapWindowRequest writes a UnmapWindow request to a byte slice. 14824 func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { 14825 size := 8 14826 b := 0 14827 buf := make([]byte, size) 14828 14829 buf[b] = 10 // request opcode 14830 b += 1 14831 14832 b += 1 // padding 14833 14834 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14835 b += 2 14836 14837 xgb.Put32(buf[b:], uint32(Window)) 14838 b += 4 14839 14840 return buf 14841 } 14842 14843 // WarpPointerCookie is a cookie used only for WarpPointer requests. 14844 type WarpPointerCookie struct { 14845 *xgb.Cookie 14846 } 14847 14848 // WarpPointer sends an unchecked request. 14849 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. 14850 func WarpPointer(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { 14851 cookie := c.NewCookie(false, false) 14852 c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) 14853 return WarpPointerCookie{cookie} 14854 } 14855 14856 // WarpPointerChecked sends a checked request. 14857 // If an error occurs, it can be retrieved using WarpPointerCookie.Check() 14858 func WarpPointerChecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { 14859 cookie := c.NewCookie(true, false) 14860 c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) 14861 return WarpPointerCookie{cookie} 14862 } 14863 14864 // Check returns an error if one occurred for checked requests that are not expecting a reply. 14865 // This cannot be called for requests expecting a reply, nor for unchecked requests. 14866 func (cook WarpPointerCookie) Check() error { 14867 return cook.Cookie.Check() 14868 } 14869 14870 // Write request to wire for WarpPointer 14871 // warpPointerRequest writes a WarpPointer request to a byte slice. 14872 func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { 14873 size := 24 14874 b := 0 14875 buf := make([]byte, size) 14876 14877 buf[b] = 41 // request opcode 14878 b += 1 14879 14880 b += 1 // padding 14881 14882 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units 14883 b += 2 14884 14885 xgb.Put32(buf[b:], uint32(SrcWindow)) 14886 b += 4 14887 14888 xgb.Put32(buf[b:], uint32(DstWindow)) 14889 b += 4 14890 14891 xgb.Put16(buf[b:], uint16(SrcX)) 14892 b += 2 14893 14894 xgb.Put16(buf[b:], uint16(SrcY)) 14895 b += 2 14896 14897 xgb.Put16(buf[b:], SrcWidth) 14898 b += 2 14899 14900 xgb.Put16(buf[b:], SrcHeight) 14901 b += 2 14902 14903 xgb.Put16(buf[b:], uint16(DstX)) 14904 b += 2 14905 14906 xgb.Put16(buf[b:], uint16(DstY)) 14907 b += 2 14908 14909 return buf 14910 }