From 0685fb57e14104ee4ad9f70ec94f787a9a22c028 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:43:26 -0400 Subject: Update to latest xproto XML. --- nexgb/xproto/xproto.go | 17714 +++++++++++++++++++++++------------------------ 1 file changed, 8857 insertions(+), 8857 deletions(-) (limited to 'nexgb/xproto') diff --git a/nexgb/xproto/xproto.go b/nexgb/xproto/xproto.go index 7527db5..f162b19 100644 --- a/nexgb/xproto/xproto.go +++ b/nexgb/xproto/xproto.go @@ -2,7 +2,7 @@ package xproto /* - This file was generated by xproto.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xproto.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -23,179 +23,211 @@ func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo { return &s.Roots[c.DefaultScreen] } -// Skipping definition for base type 'Byte' +// BadAccess is the error number for a BadAccess. +const BadAccess = 10 -// Skipping definition for base type 'Int8' +type AccessError RequestError -// Skipping definition for base type 'Card16' +// AccessErrorNew constructs a AccessError value that implements xgb.Error from a byte slice. +func AccessErrorNew(buf []byte) xgb.Error { + v := AccessError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Access" + return v +} -// Skipping definition for base type 'Char' +// SequenceId returns the sequence id attached to the BadAccess error. +// This is mostly used internally. +func (err AccessError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Card32' +// BadId returns the 'BadValue' number if one exists for the BadAccess error. If no bad value exists, 0 is returned. +func (err AccessError) BadId() uint32 { + return err.BadValue +} -// Skipping definition for base type 'Double' +// Error returns a rudimentary string representation of the BadAccess error. +func (err AccessError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAccess {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -// Skipping definition for base type 'Bool' +func init() { + xgb.NewErrorFuncs[10] = AccessErrorNew +} -// Skipping definition for base type 'Float' +const ( + AccessControlDisable = 0 + AccessControlEnable = 1 +) -// Skipping definition for base type 'Card8' +// BadAlloc is the error number for a BadAlloc. +const BadAlloc = 11 -// Skipping definition for base type 'Int16' +type AllocError RequestError -// Skipping definition for base type 'Int32' +// AllocErrorNew constructs a AllocError value that implements xgb.Error from a byte slice. +func AllocErrorNew(buf []byte) xgb.Error { + v := AllocError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Alloc" + return v +} -// Skipping definition for base type 'Void' +// SequenceId returns the sequence id attached to the BadAlloc error. +// This is mostly used internally. +func (err AllocError) SequenceId() uint16 { + return err.Sequence +} -const ( - VisualClassStaticGray = 0 - VisualClassGrayScale = 1 - VisualClassStaticColor = 2 - VisualClassPseudoColor = 3 - VisualClassTrueColor = 4 - VisualClassDirectColor = 5 -) +// BadId returns the 'BadValue' number if one exists for the BadAlloc error. If no bad value exists, 0 is returned. +func (err AllocError) BadId() uint32 { + return err.BadValue +} -const ( - EventMaskNoEvent = 0 - EventMaskKeyPress = 1 - EventMaskKeyRelease = 2 - EventMaskButtonPress = 4 - EventMaskButtonRelease = 8 - EventMaskEnterWindow = 16 - EventMaskLeaveWindow = 32 - EventMaskPointerMotion = 64 - EventMaskPointerMotionHint = 128 - EventMaskButton1Motion = 256 - EventMaskButton2Motion = 512 - EventMaskButton3Motion = 1024 - EventMaskButton4Motion = 2048 - EventMaskButton5Motion = 4096 - EventMaskButtonMotion = 8192 - EventMaskKeymapState = 16384 - EventMaskExposure = 32768 - EventMaskVisibilityChange = 65536 - EventMaskStructureNotify = 131072 - EventMaskResizeRedirect = 262144 - EventMaskSubstructureNotify = 524288 - EventMaskSubstructureRedirect = 1048576 - EventMaskFocusChange = 2097152 - EventMaskPropertyChange = 4194304 - EventMaskColorMapChange = 8388608 - EventMaskOwnerGrabButton = 16777216 -) +// Error returns a rudimentary string representation of the BadAlloc error. +func (err AllocError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAlloc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -const ( - BackingStoreNotUseful = 0 - BackingStoreWhenMapped = 1 - BackingStoreAlways = 2 -) +func init() { + xgb.NewErrorFuncs[11] = AllocErrorNew +} const ( - ImageOrderLSBFirst = 0 - ImageOrderMSBFirst = 1 + AllowAsyncPointer = 0 + AllowSyncPointer = 1 + AllowReplayPointer = 2 + AllowAsyncKeyboard = 3 + AllowSyncKeyboard = 4 + AllowReplayKeyboard = 5 + AllowAsyncBoth = 6 + AllowSyncBoth = 7 ) -const ( - ModMaskShift = 1 - ModMaskLock = 2 - ModMaskControl = 4 - ModMask1 = 8 - ModMask2 = 16 - ModMask3 = 32 - ModMask4 = 64 - ModMask5 = 128 - ModMaskAny = 32768 -) +type Arc struct { + X int16 + Y int16 + Width uint16 + Height uint16 + Angle1 int16 + Angle2 int16 +} -const ( - KeyButMaskShift = 1 - KeyButMaskLock = 2 - KeyButMaskControl = 4 - KeyButMaskMod1 = 8 - KeyButMaskMod2 = 16 - KeyButMaskMod3 = 32 - KeyButMaskMod4 = 64 - KeyButMaskMod5 = 128 - KeyButMaskButton1 = 256 - KeyButMaskButton2 = 512 - KeyButMaskButton3 = 1024 - KeyButMaskButton4 = 2048 - KeyButMaskButton5 = 4096 -) +// ArcRead reads a byte slice into a Arc value. +func ArcRead(buf []byte, v *Arc) int { + b := 0 -const ( - WindowNone = 0 -) + v.X = int16(xgb.Get16(buf[b:])) + b += 2 -const ( - ButtonMask1 = 256 - ButtonMask2 = 512 - ButtonMask3 = 1024 - ButtonMask4 = 2048 - ButtonMask5 = 4096 - ButtonMaskAny = 32768 -) + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 -const ( - MotionNormal = 0 - MotionHint = 1 -) + v.Width = xgb.Get16(buf[b:]) + b += 2 -const ( - NotifyDetailAncestor = 0 - NotifyDetailVirtual = 1 - NotifyDetailInferior = 2 - NotifyDetailNonlinear = 3 - NotifyDetailNonlinearVirtual = 4 - NotifyDetailPointer = 5 - NotifyDetailPointerRoot = 6 - NotifyDetailNone = 7 -) + v.Height = xgb.Get16(buf[b:]) + b += 2 -const ( - NotifyModeNormal = 0 - NotifyModeGrab = 1 - NotifyModeUngrab = 2 - NotifyModeWhileGrabbed = 3 -) + v.Angle1 = int16(xgb.Get16(buf[b:])) + b += 2 -const ( - VisibilityUnobscured = 0 - VisibilityPartiallyObscured = 1 - VisibilityFullyObscured = 2 -) + v.Angle2 = int16(xgb.Get16(buf[b:])) + b += 2 -const ( - PlaceOnTop = 0 - PlaceOnBottom = 1 -) + return b +} -const ( - PropertyNewValue = 0 - PropertyDelete = 1 -) +// ArcReadList reads a byte slice into a list of Arc values. +func ArcReadList(buf []byte, dest []Arc) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Arc{} + b += ArcRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} -const ( - TimeCurrentTime = 0 -) +// Bytes writes a Arc value to a byte slice. +func (v Arc) Bytes() []byte { + buf := make([]byte, 12) + b := 0 -const ( - AtomNone = 0 - AtomAny = 0 - AtomPrimary = 1 - AtomSecondary = 2 - AtomArc = 3 - AtomAtom = 4 - AtomBitmap = 5 - AtomCardinal = 6 - AtomColormap = 7 - AtomCursor = 8 - AtomCutBuffer0 = 9 - AtomCutBuffer1 = 10 - AtomCutBuffer2 = 11 - AtomCutBuffer3 = 12 - AtomCutBuffer4 = 13 + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Angle1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Angle2)) + b += 2 + + return buf +} + +// ArcListBytes writes a list of Arc values to a byte slice. +func ArcListBytes(buf []byte, list []Arc) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + ArcModeChord = 0 + ArcModePieSlice = 1 +) + +type Atom uint32 + +func NewAtomId(c *xgb.Conn) (Atom, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Atom(id), nil +} + +const ( + AtomNone = 0 + AtomAny = 0 + AtomPrimary = 1 + AtomSecondary = 2 + AtomArc = 3 + AtomAtom = 4 + AtomBitmap = 5 + AtomCardinal = 6 + AtomColormap = 7 + AtomCursor = 8 + AtomCutBuffer0 = 9 + AtomCutBuffer1 = 10 + AtomCutBuffer2 = 11 + AtomCutBuffer3 = 12 + AtomCutBuffer4 = 13 AtomCutBuffer5 = 14 AtomCutBuffer6 = 15 AtomCutBuffer7 = 16 @@ -253,130 +285,68 @@ const ( AtomWmTransientFor = 68 ) -const ( - ColormapStateUninstalled = 0 - ColormapStateInstalled = 1 -) - -const ( - ColormapNone = 0 -) - -const ( - MappingModifier = 0 - MappingKeyboard = 1 - MappingPointer = 2 -) - -const ( - WindowClassCopyFromParent = 0 - WindowClassInputOutput = 1 - WindowClassInputOnly = 2 -) - -const ( - CwBackPixmap = 1 - CwBackPixel = 2 - CwBorderPixmap = 4 - CwBorderPixel = 8 - CwBitGravity = 16 - CwWinGravity = 32 - CwBackingStore = 64 - CwBackingPlanes = 128 - CwBackingPixel = 256 - CwOverrideRedirect = 512 - CwSaveUnder = 1024 - CwEventMask = 2048 - CwDontPropagate = 4096 - CwColormap = 8192 - CwCursor = 16384 -) - -const ( - BackPixmapNone = 0 - BackPixmapParentRelative = 1 -) - -const ( - GravityBitForget = 0 - GravityWinUnmap = 0 - GravityNorthWest = 1 - GravityNorth = 2 - GravityNorthEast = 3 - GravityWest = 4 - GravityCenter = 5 - GravityEast = 6 - GravitySouthWest = 7 - GravitySouth = 8 - GravitySouthEast = 9 - GravityStatic = 10 -) +// BadAtom is the error number for a BadAtom. +const BadAtom = 5 -const ( - MapStateUnmapped = 0 - MapStateUnviewable = 1 - MapStateViewable = 2 -) +type AtomError ValueError -const ( - SetModeInsert = 0 - SetModeDelete = 1 -) +// AtomErrorNew constructs a AtomError value that implements xgb.Error from a byte slice. +func AtomErrorNew(buf []byte) xgb.Error { + v := AtomError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Atom" + return v +} -const ( - ConfigWindowX = 1 - ConfigWindowY = 2 - ConfigWindowWidth = 4 - ConfigWindowHeight = 8 - ConfigWindowBorderWidth = 16 - ConfigWindowSibling = 32 - ConfigWindowStackMode = 64 -) +// SequenceId returns the sequence id attached to the BadAtom error. +// This is mostly used internally. +func (err AtomError) SequenceId() uint16 { + return err.Sequence +} -const ( - StackModeAbove = 0 - StackModeBelow = 1 - StackModeTopIf = 2 - StackModeBottomIf = 3 - StackModeOpposite = 4 -) +// BadId returns the 'BadValue' number if one exists for the BadAtom error. If no bad value exists, 0 is returned. +func (err AtomError) BadId() uint32 { + return err.BadValue +} -const ( - CirculateRaiseLowest = 0 - CirculateLowerHighest = 1 -) +// Error returns a rudimentary string representation of the BadAtom error. +func (err AtomError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAtom {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -const ( - PropModeReplace = 0 - PropModePrepend = 1 - PropModeAppend = 2 -) +func init() { + xgb.NewErrorFuncs[5] = AtomErrorNew +} const ( - GetPropertyTypeAny = 0 + AutoRepeatModeOff = 0 + AutoRepeatModeOn = 1 + AutoRepeatModeDefault = 2 ) const ( - SendEventDestPointerWindow = 0 - SendEventDestItemFocus = 1 + BackPixmapNone = 0 + BackPixmapParentRelative = 1 ) const ( - GrabModeSync = 0 - GrabModeAsync = 1 + BackingStoreNotUseful = 0 + BackingStoreWhenMapped = 1 + BackingStoreAlways = 2 ) const ( - GrabStatusSuccess = 0 - GrabStatusAlreadyGrabbed = 1 - GrabStatusInvalidTime = 2 - GrabStatusNotViewable = 3 - GrabStatusFrozen = 4 + BlankingNotPreferred = 0 + BlankingPreferred = 1 + BlankingDefault = 2 ) -const ( - CursorNone = 0 -) +type Button byte const ( ButtonIndexAny = 0 @@ -388,665 +358,845 @@ const ( ) const ( - GrabAny = 0 + ButtonMask1 = 256 + ButtonMask2 = 512 + ButtonMask3 = 1024 + ButtonMask4 = 2048 + ButtonMask5 = 4096 + ButtonMaskAny = 32768 ) -const ( - AllowAsyncPointer = 0 - AllowSyncPointer = 1 - AllowReplayPointer = 2 - AllowAsyncKeyboard = 3 - AllowSyncKeyboard = 4 - AllowReplayKeyboard = 5 - AllowAsyncBoth = 6 - AllowSyncBoth = 7 -) +// ButtonPress is the event number for a ButtonPressEvent. +const ButtonPress = 4 -const ( - InputFocusNone = 0 - InputFocusPointerRoot = 1 - InputFocusParent = 2 - InputFocusFollowKeyboard = 3 -) +type ButtonPressEvent struct { + Sequence uint16 + Detail Button + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} -const ( - FontDrawLeftToRight = 0 - FontDrawRightToLeft = 1 -) +// ButtonPressEventNew constructs a ButtonPressEvent value that implements xgb.Event from a byte slice. +func ButtonPressEventNew(buf []byte) xgb.Event { + v := ButtonPressEvent{} + b := 1 // don't read event number -const ( - GcFunction = 1 - GcPlaneMask = 2 - GcForeground = 4 - GcBackground = 8 - GcLineWidth = 16 - GcLineStyle = 32 - GcCapStyle = 64 - GcJoinStyle = 128 - GcFillStyle = 256 - GcFillRule = 512 - GcTile = 1024 - GcStipple = 2048 - GcTileStippleOriginX = 4096 - GcTileStippleOriginY = 8192 - GcFont = 16384 - GcSubwindowMode = 32768 - GcGraphicsExposures = 65536 - GcClipOriginX = 131072 - GcClipOriginY = 262144 - GcClipMask = 524288 - GcDashOffset = 1048576 - GcDashList = 2097152 - GcArcMode = 4194304 -) + v.Detail = Button(buf[b]) + b += 1 -const ( - GxClear = 0 - GxAnd = 1 - GxAndReverse = 2 - GxCopy = 3 - GxAndInverted = 4 - GxNoop = 5 - GxXor = 6 - GxOr = 7 - GxNor = 8 - GxEquiv = 9 - GxInvert = 10 - GxOrReverse = 11 - GxCopyInverted = 12 - GxOrInverted = 13 - GxNand = 14 - GxSet = 15 -) + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Bytes writes a ButtonPressEvent value to a byte slice. +func (v ButtonPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 4 + b += 1 + + buf[b] = byte(v.Detail) + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the ButtonPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ButtonPressEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of ButtonPressEvent. +func (v ButtonPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "ButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[4] = ButtonPressEventNew +} + +// ButtonRelease is the event number for a ButtonReleaseEvent. +const ButtonRelease = 5 + +type ButtonReleaseEvent ButtonPressEvent + +// ButtonReleaseEventNew constructs a ButtonReleaseEvent value that implements xgb.Event from a byte slice. +func ButtonReleaseEventNew(buf []byte) xgb.Event { + return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) +} + +// Bytes writes a ButtonReleaseEvent value to a byte slice. +func (v ButtonReleaseEvent) Bytes() []byte { + return ButtonPressEvent(v).Bytes() +} + +// SequenceId returns the sequence id attached to the ButtonRelease event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ButtonReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ButtonReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "ButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[5] = ButtonReleaseEventNew +} const ( - LineStyleSolid = 0 - LineStyleOnOffDash = 1 - LineStyleDoubleDash = 2 + CapStyleNotLast = 0 + CapStyleButt = 1 + CapStyleRound = 2 + CapStyleProjecting = 3 ) -const ( - CapStyleNotLast = 0 - CapStyleButt = 1 - CapStyleRound = 2 - CapStyleProjecting = 3 -) +type Char2b struct { + Byte1 byte + Byte2 byte +} + +// Char2bRead reads a byte slice into a Char2b value. +func Char2bRead(buf []byte, v *Char2b) int { + b := 0 + + v.Byte1 = buf[b] + b += 1 + + v.Byte2 = buf[b] + b += 1 + + return b +} + +// Char2bReadList reads a byte slice into a list of Char2b values. +func Char2bReadList(buf []byte, dest []Char2b) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Char2b{} + b += Char2bRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Char2b value to a byte slice. +func (v Char2b) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.Byte1 + b += 1 + + buf[b] = v.Byte2 + b += 1 + + return buf +} + +// Char2bListBytes writes a list of Char2b values to a byte slice. +func Char2bListBytes(buf []byte, list []Char2b) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +type Charinfo struct { + LeftSideBearing int16 + RightSideBearing int16 + CharacterWidth int16 + Ascent int16 + Descent int16 + Attributes uint16 +} + +// CharinfoRead reads a byte slice into a Charinfo value. +func CharinfoRead(buf []byte, v *Charinfo) int { + b := 0 + + v.LeftSideBearing = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RightSideBearing = int16(xgb.Get16(buf[b:])) + b += 2 + + v.CharacterWidth = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Ascent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Descent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Attributes = xgb.Get16(buf[b:]) + b += 2 -const ( - JoinStyleMiter = 0 - JoinStyleRound = 1 - JoinStyleBevel = 2 -) + return b +} -const ( - FillStyleSolid = 0 - FillStyleTiled = 1 - FillStyleStippled = 2 - FillStyleOpaqueStippled = 3 -) +// CharinfoReadList reads a byte slice into a list of Charinfo values. +func CharinfoReadList(buf []byte, dest []Charinfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Charinfo{} + b += CharinfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} -const ( - FillRuleEvenOdd = 0 - FillRuleWinding = 1 -) +// Bytes writes a Charinfo value to a byte slice. +func (v Charinfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 -const ( - SubwindowModeClipByChildren = 0 - SubwindowModeIncludeInferiors = 1 -) + xgb.Put16(buf[b:], uint16(v.LeftSideBearing)) + b += 2 -const ( - ArcModeChord = 0 - ArcModePieSlice = 1 -) + xgb.Put16(buf[b:], uint16(v.RightSideBearing)) + b += 2 -const ( - ClipOrderingUnsorted = 0 - ClipOrderingYSorted = 1 - ClipOrderingYXSorted = 2 - ClipOrderingYXBanded = 3 -) + xgb.Put16(buf[b:], uint16(v.CharacterWidth)) + b += 2 -const ( - CoordModeOrigin = 0 - CoordModePrevious = 1 -) + xgb.Put16(buf[b:], uint16(v.Ascent)) + b += 2 -const ( - PolyShapeComplex = 0 - PolyShapeNonconvex = 1 - PolyShapeConvex = 2 -) + xgb.Put16(buf[b:], uint16(v.Descent)) + b += 2 -const ( - ImageFormatXYBitmap = 0 - ImageFormatXYPixmap = 1 - ImageFormatZPixmap = 2 -) + xgb.Put16(buf[b:], v.Attributes) + b += 2 -const ( - ColormapAllocNone = 0 - ColormapAllocAll = 1 -) + return buf +} -const ( - ColorFlagRed = 1 - ColorFlagGreen = 2 - ColorFlagBlue = 4 -) +// CharinfoListBytes writes a list of Charinfo values to a byte slice. +func CharinfoListBytes(buf []byte, list []Charinfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} const ( - PixmapNone = 0 + CirculateRaiseLowest = 0 + CirculateLowerHighest = 1 ) -const ( - FontNone = 0 -) +// CirculateNotify is the event number for a CirculateNotifyEvent. +const CirculateNotify = 26 -const ( - QueryShapeOfLargestCursor = 0 - QueryShapeOfFastestTile = 1 - QueryShapeOfFastestStipple = 2 -) +type CirculateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + // padding: 4 bytes + Place byte + // padding: 3 bytes +} -const ( - KbKeyClickPercent = 1 - KbBellPercent = 2 - KbBellPitch = 4 - KbBellDuration = 8 - KbLed = 16 - KbLedMode = 32 - KbKey = 64 - KbAutoRepeatMode = 128 -) +// CirculateNotifyEventNew constructs a CirculateNotifyEvent value that implements xgb.Event from a byte slice. +func CirculateNotifyEventNew(buf []byte) xgb.Event { + v := CirculateNotifyEvent{} + b := 1 // don't read event number -const ( - LedModeOff = 0 - LedModeOn = 1 -) + b += 1 // padding -const ( - AutoRepeatModeOff = 0 - AutoRepeatModeOn = 1 - AutoRepeatModeDefault = 2 -) + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -const ( - BlankingNotPreferred = 0 - BlankingPreferred = 1 - BlankingDefault = 2 -) + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 -const ( - ExposuresNotAllowed = 0 - ExposuresAllowed = 1 - ExposuresDefault = 2 -) + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 -const ( - HostModeInsert = 0 - HostModeDelete = 1 -) + b += 4 // padding -const ( - FamilyInternet = 0 - FamilyDECnet = 1 - FamilyChaos = 2 - FamilyServerInterpreted = 5 - FamilyInternet6 = 6 -) + v.Place = buf[b] + b += 1 -const ( - AccessControlDisable = 0 - AccessControlEnable = 1 -) + b += 3 // padding -const ( - CloseDownDestroyAll = 0 - CloseDownRetainPermanent = 1 - CloseDownRetainTemporary = 2 -) + return v +} -const ( - KillAllTemporary = 0 -) +// Bytes writes a CirculateNotifyEvent value to a byte slice. +func (v CirculateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 -const ( - ScreenSaverReset = 0 - ScreenSaverActive = 1 -) + // write event number + buf[b] = 26 + b += 1 -const ( - MappingStatusSuccess = 0 - MappingStatusBusy = 1 - MappingStatusFailure = 2 -) + b += 1 // padding -const ( - MapIndexShift = 0 - MapIndexLock = 1 - MapIndexControl = 2 - MapIndex1 = 3 - MapIndex2 = 4 - MapIndex3 = 5 - MapIndex4 = 6 - MapIndex5 = 7 -) + b += 2 // skip sequence number -type Window uint32 + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 -func NewWindowId(c *xgb.Conn) (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil -} + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 -type Pixmap uint32 + b += 4 // padding -func NewPixmapId(c *xgb.Conn) (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil -} + buf[b] = v.Place + b += 1 -type Cursor uint32 + b += 3 // padding -func NewCursorId(c *xgb.Conn) (Cursor, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Cursor(id), nil + return buf +} + +// SequenceId returns the sequence id attached to the CirculateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CirculateNotifyEvent) SequenceId() uint16 { + return v.Sequence } -type Font uint32 - -func NewFontId(c *xgb.Conn) (Font, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Font(id), nil +// String is a rudimentary string representation of CirculateNotifyEvent. +func (v CirculateNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) + return "CirculateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type Gcontext uint32 - -func NewGcontextId(c *xgb.Conn) (Gcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Gcontext(id), nil +func init() { + xgb.NewEventFuncs[26] = CirculateNotifyEventNew } -type Colormap uint32 +// CirculateRequest is the event number for a CirculateRequestEvent. +const CirculateRequest = 27 -func NewColormapId(c *xgb.Conn) (Colormap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Colormap(id), nil +type CirculateRequestEvent CirculateNotifyEvent + +// CirculateRequestEventNew constructs a CirculateRequestEvent value that implements xgb.Event from a byte slice. +func CirculateRequestEventNew(buf []byte) xgb.Event { + return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) } -type Atom uint32 +// Bytes writes a CirculateRequestEvent value to a byte slice. +func (v CirculateRequestEvent) Bytes() []byte { + return CirculateNotifyEvent(v).Bytes() +} -func NewAtomId(c *xgb.Conn) (Atom, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Atom(id), nil +// SequenceId returns the sequence id attached to the CirculateRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CirculateRequestEvent) SequenceId() uint16 { + return v.Sequence } -type Drawable uint32 +func (v CirculateRequestEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) + return "CirculateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} -func NewDrawableId(c *xgb.Conn) (Drawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Drawable(id), nil +func init() { + xgb.NewEventFuncs[27] = CirculateRequestEventNew } -type Fontable uint32 +// ClientMessage is the event number for a ClientMessageEvent. +const ClientMessage = 33 -func NewFontableId(c *xgb.Conn) (Fontable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fontable(id), nil +type ClientMessageEvent struct { + Sequence uint16 + Format byte + Window Window + Type Atom + Data ClientMessageDataUnion } -type Visualid uint32 +// ClientMessageEventNew constructs a ClientMessageEvent value that implements xgb.Event from a byte slice. +func ClientMessageEventNew(buf []byte) xgb.Event { + v := ClientMessageEvent{} + b := 1 // don't read event number -type Timestamp uint32 + v.Format = buf[b] + b += 1 -type Keysym uint32 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -type Keycode byte + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 -type Button byte + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 -type Char2b struct { - Byte1 byte - Byte2 byte + v.Data = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(buf[b:], &v.Data) + + return v } -// Char2bRead reads a byte slice into a Char2b value. -func Char2bRead(buf []byte, v *Char2b) int { +// Bytes writes a ClientMessageEvent value to a byte slice. +func (v ClientMessageEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.Byte1 = buf[b] + // write event number + buf[b] = 33 b += 1 - v.Byte2 = buf[b] + buf[b] = v.Format b += 1 - return b -} - -// Char2bReadList reads a byte slice into a list of Char2b values. -func Char2bReadList(buf []byte, dest []Char2b) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Char2b{} - b += Char2bRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} + b += 2 // skip sequence number -// Bytes writes a Char2b value to a byte slice. -func (v Char2b) Bytes() []byte { - buf := make([]byte, 2) - b := 0 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - buf[b] = v.Byte1 - b += 1 + xgb.Put32(buf[b:], uint32(v.Type)) + b += 4 - buf[b] = v.Byte2 - b += 1 + { + unionBytes := v.Data.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } return buf } -// Char2bListBytes writes a list of Char2b values to a byte slice. -func Char2bListBytes(buf []byte, list []Char2b) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the ClientMessage event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ClientMessageEvent) SequenceId() uint16 { + return v.Sequence } -type Point struct { - X int16 - Y int16 +// String is a rudimentary string representation of ClientMessageEvent. +func (v ClientMessageEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Format: %d", v.Format)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Type: %d", v.Type)) + return "ClientMessage {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// PointRead reads a byte slice into a Point value. -func PointRead(buf []byte, v *Point) int { - b := 0 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - return b +func init() { + xgb.NewEventFuncs[33] = ClientMessageEventNew } -// PointReadList reads a byte slice into a list of Point values. -func PointReadList(buf []byte, dest []Point) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Point{} - b += PointRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// ClientMessageDataUnion is a represention of the ClientMessageDataUnion union type. +// Note that to *create* a Union, you should *never* create +// this struct directly (unless you know what you're doing). +// Instead use one of the following constructors for 'ClientMessageDataUnion': +// ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion +// ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion +// ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion +type ClientMessageDataUnion struct { + Data8 []byte // size: 20 + Data16 []uint16 // size: 20 + Data32 []uint32 // size: 20 } -// Bytes writes a Point value to a byte slice. -func (v Point) Bytes() []byte { - buf := make([]byte, 4) - b := 0 +// ClientMessageDataUnionData8New constructs a new ClientMessageDataUnion union type with the Data8 field. +func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + copy(buf[b:], Data8[:20]) + b += xgb.Pad(int(20)) - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 + // Create the Union type + v := ClientMessageDataUnion{} - return buf -} + // Now copy buf into all fields -// PointListBytes writes a list of Point values to a byte slice. -func PointListBytes(buf []byte, list []Point) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 } - return b -} + b = xgb.Pad(b) -type Rectangle struct { - X int16 - Y int16 - Width uint16 - Height uint16 + return v } -// RectangleRead reads a byte slice into a Rectangle value. -func RectangleRead(buf []byte, v *Rectangle) int { - b := 0 +// ClientMessageDataUnionData16New constructs a new ClientMessageDataUnion union type with the Data16 field. +func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) - v.X = int16(xgb.Get16(buf[b:])) - b += 2 + for i := 0; i < int(10); i++ { + xgb.Put16(buf[b:], Data16[i]) + b += 2 + } + b = xgb.Pad(b) - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + // Create the Union type + v := ClientMessageDataUnion{} - v.Width = xgb.Get16(buf[b:]) - b += 2 + // Now copy buf into all fields - v.Height = xgb.Get16(buf[b:]) - b += 2 + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) - return b -} + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) -// RectangleReadList reads a byte slice into a list of Rectangle values. -func RectangleReadList(buf []byte, dest []Rectangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rectangle{} - b += RectangleRead(buf[b:], &dest[i]) + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 } - return xgb.Pad(b) + b = xgb.Pad(b) + + return v } -// Bytes writes a Rectangle value to a byte slice. -func (v Rectangle) Bytes() []byte { - buf := make([]byte, 8) - b := 0 +// ClientMessageDataUnionData32New constructs a new ClientMessageDataUnion union type with the Data32 field. +func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + for i := 0; i < int(5); i++ { + xgb.Put32(buf[b:], Data32[i]) + b += 4 + } + b = xgb.Pad(b) - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 + // Create the Union type + v := ClientMessageDataUnion{} - xgb.Put16(buf[b:], v.Width) - b += 2 + // Now copy buf into all fields - xgb.Put16(buf[b:], v.Height) - b += 2 + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) - return buf -} + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) -// RectangleListBytes writes a list of Rectangle values to a byte slice. -func RectangleListBytes(buf []byte, list []Rectangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 } - return b -} + b = xgb.Pad(b) -type Arc struct { - X int16 - Y int16 - Width uint16 - Height uint16 - Angle1 int16 - Angle2 int16 + return v } -// ArcRead reads a byte slice into a Arc value. -func ArcRead(buf []byte, v *Arc) int { - b := 0 - - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 +// ClientMessageDataUnionRead reads a byte slice into a ClientMessageDataUnion value. +func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { + var b int - v.Height = xgb.Get16(buf[b:]) - b += 2 + b = 0 // re-read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) - v.Angle1 = int16(xgb.Get16(buf[b:])) - b += 2 + b = 0 // re-read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) - v.Angle2 = int16(xgb.Get16(buf[b:])) - b += 2 + b = 0 // re-read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) - return b + return 20 } -// ArcReadList reads a byte slice into a list of Arc values. -func ArcReadList(buf []byte, dest []Arc) int { +// ClientMessageDataUnionReadList reads a byte slice into a list of ClientMessageDataUnion values. +func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Arc{} - b += ArcRead(buf[b:], &dest[i]) + dest[i] = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Arc value to a byte slice. -func (v Arc) Bytes() []byte { - buf := make([]byte, 12) +// Bytes writes a ClientMessageDataUnion value to a byte slice. +// Each field in a union must contain the same data. +// So simply pick the first field and write that to the wire. +func (v ClientMessageDataUnion) Bytes() []byte { + buf := make([]byte, 20) b := 0 - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Angle1)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Angle2)) - b += 2 - + copy(buf[b:], v.Data8[:20]) + b += xgb.Pad(int(20)) return buf } -// ArcListBytes writes a list of Arc values to a byte slice. -func ArcListBytes(buf []byte, list []Arc) int { +// ClientMessageDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. +func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { b := 0 - var structBytes []byte + var unionBytes []byte for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) } return b } -type Format struct { - Depth byte - BitsPerPixel byte - ScanlinePad byte - // padding: 5 bytes +const ( + ClipOrderingUnsorted = 0 + ClipOrderingYSorted = 1 + ClipOrderingYXSorted = 2 + ClipOrderingYXBanded = 3 +) + +const ( + CloseDownDestroyAll = 0 + CloseDownRetainPermanent = 1 + CloseDownRetainTemporary = 2 +) + +const ( + ColorFlagRed = 1 + ColorFlagGreen = 2 + ColorFlagBlue = 4 +) + +type Coloritem struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Flags byte + // padding: 1 bytes } -// FormatRead reads a byte slice into a Format value. -func FormatRead(buf []byte, v *Format) int { +// ColoritemRead reads a byte slice into a Coloritem value. +func ColoritemRead(buf []byte, v *Coloritem) int { b := 0 - v.Depth = buf[b] - b += 1 + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 - v.BitsPerPixel = buf[b] - b += 1 + v.Blue = xgb.Get16(buf[b:]) + b += 2 - v.ScanlinePad = buf[b] + v.Flags = buf[b] b += 1 - b += 5 // padding + b += 1 // padding return b } -// FormatReadList reads a byte slice into a list of Format values. -func FormatReadList(buf []byte, dest []Format) int { +// ColoritemReadList reads a byte slice into a list of Coloritem values. +func ColoritemReadList(buf []byte, dest []Coloritem) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Format{} - b += FormatRead(buf[b:], &dest[i]) + dest[i] = Coloritem{} + b += ColoritemRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Format value to a byte slice. -func (v Format) Bytes() []byte { - buf := make([]byte, 8) +// Bytes writes a Coloritem value to a byte slice. +func (v Coloritem) Bytes() []byte { + buf := make([]byte, 12) b := 0 - buf[b] = v.Depth - b += 1 + xgb.Put32(buf[b:], v.Pixel) + b += 4 - buf[b] = v.BitsPerPixel - b += 1 + xgb.Put16(buf[b:], v.Red) + b += 2 - buf[b] = v.ScanlinePad + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + buf[b] = v.Flags b += 1 - b += 5 // padding + b += 1 // padding return buf } -// FormatListBytes writes a list of Format values to a byte slice. -func FormatListBytes(buf []byte, list []Format) int { +// ColoritemListBytes writes a list of Coloritem values to a byte slice. +func ColoritemListBytes(buf []byte, list []Coloritem) int { b := 0 var structBytes []byte for _, item := range list { @@ -1057,625 +1207,715 @@ func FormatListBytes(buf []byte, list []Format) int { return b } -type VisualInfo struct { - VisualId Visualid - Class byte - BitsPerRgbValue byte - ColormapEntries uint16 - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 4 bytes +type Colormap uint32 + +func NewColormapId(c *xgb.Conn) (Colormap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Colormap(id), nil } -// VisualInfoRead reads a byte slice into a VisualInfo value. -func VisualInfoRead(buf []byte, v *VisualInfo) int { - b := 0 +// BadColormap is the error number for a BadColormap. +const BadColormap = 12 - v.VisualId = Visualid(xgb.Get32(buf[b:])) - b += 4 +type ColormapError ValueError - v.Class = buf[b] - b += 1 +// ColormapErrorNew constructs a ColormapError value that implements xgb.Error from a byte slice. +func ColormapErrorNew(buf []byte) xgb.Error { + v := ColormapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Colormap" + return v +} - v.BitsPerRgbValue = buf[b] - b += 1 +// SequenceId returns the sequence id attached to the BadColormap error. +// This is mostly used internally. +func (err ColormapError) SequenceId() uint16 { + return err.Sequence +} - v.ColormapEntries = xgb.Get16(buf[b:]) +// BadId returns the 'BadValue' number if one exists for the BadColormap error. If no bad value exists, 0 is returned. +func (err ColormapError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadColormap error. +func (err ColormapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadColormap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[12] = ColormapErrorNew +} + +const ( + ColormapNone = 0 +) + +const ( + ColormapAllocNone = 0 + ColormapAllocAll = 1 +) + +// ColormapNotify is the event number for a ColormapNotifyEvent. +const ColormapNotify = 32 + +type ColormapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Colormap Colormap + New bool + State byte + // padding: 2 bytes +} + +// ColormapNotifyEventNew constructs a ColormapNotifyEvent value that implements xgb.Event from a byte slice. +func ColormapNotifyEventNew(buf []byte) xgb.Event { + v := ColormapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.RedMask = xgb.Get32(buf[b:]) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.GreenMask = xgb.Get32(buf[b:]) + v.Colormap = Colormap(xgb.Get32(buf[b:])) b += 4 - v.BlueMask = xgb.Get32(buf[b:]) - b += 4 + if buf[b] == 1 { + v.New = true + } else { + v.New = false + } + b += 1 - b += 4 // padding + v.State = buf[b] + b += 1 - return b -} + b += 2 // padding -// VisualInfoReadList reads a byte slice into a list of VisualInfo values. -func VisualInfoReadList(buf []byte, dest []VisualInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = VisualInfo{} - b += VisualInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return v } -// Bytes writes a VisualInfo value to a byte slice. -func (v VisualInfo) Bytes() []byte { - buf := make([]byte, 24) +// Bytes writes a ColormapNotifyEvent value to a byte slice. +func (v ColormapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - xgb.Put32(buf[b:], uint32(v.VisualId)) + // write event number + buf[b] = 32 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - buf[b] = v.Class + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + if v.New { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - buf[b] = v.BitsPerRgbValue + buf[b] = v.State b += 1 - xgb.Put16(buf[b:], v.ColormapEntries) + b += 2 // padding + + return buf +} + +// SequenceId returns the sequence id attached to the ColormapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ColormapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +// String is a rudimentary string representation of ColormapNotifyEvent. +func (v ColormapNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Colormap: %d", v.Colormap)) + fieldVals = append(fieldVals, xgb.Sprintf("New: %t", v.New)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "ColormapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[32] = ColormapNotifyEventNew +} + +const ( + ColormapStateUninstalled = 0 + ColormapStateInstalled = 1 +) + +const ( + ConfigWindowX = 1 + ConfigWindowY = 2 + ConfigWindowWidth = 4 + ConfigWindowHeight = 8 + ConfigWindowBorderWidth = 16 + ConfigWindowSibling = 32 + ConfigWindowStackMode = 64 +) + +// ConfigureNotify is the event number for a ConfigureNotifyEvent. +const ConfigureNotify = 22 + +type ConfigureNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + AboveSibling Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// ConfigureNotifyEventNew constructs a ConfigureNotifyEvent value that implements xgb.Event from a byte slice. +func ConfigureNotifyEventNew(buf []byte) xgb.Event { + v := ConfigureNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], v.RedMask) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.GreenMask) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.BlueMask) + v.AboveSibling = Window(xgb.Get32(buf[b:])) b += 4 - b += 4 // padding + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - return buf -} + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 -// VisualInfoListBytes writes a list of VisualInfo values to a byte slice. -func VisualInfoListBytes(buf []byte, list []VisualInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false } - return b -} + b += 1 -type DepthInfo struct { - Depth byte - // padding: 1 bytes - VisualsLen uint16 - // padding: 4 bytes - Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) + b += 1 // padding + + return v } -// DepthInfoRead reads a byte slice into a DepthInfo value. -func DepthInfoRead(buf []byte, v *DepthInfo) int { +// Bytes writes a ConfigureNotifyEvent value to a byte slice. +func (v ConfigureNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.Depth = buf[b] + // write event number + buf[b] = 22 b += 1 b += 1 // padding - v.VisualsLen = xgb.Get16(buf[b:]) - b += 2 + b += 2 // skip sequence number - b += 4 // padding + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 - v.Visuals = make([]VisualInfo, v.VisualsLen) - b += VisualInfoReadList(buf[b:], v.Visuals) + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - return b -} + xgb.Put32(buf[b:], uint32(v.AboveSibling)) + b += 4 -// DepthInfoReadList reads a byte slice into a list of DepthInfo values. -func DepthInfoReadList(buf []byte, dest []DepthInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DepthInfo{} - b += DepthInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 -// Bytes writes a DepthInfo value to a byte slice. -func (v DepthInfo) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) - b := 0 + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 - buf[b] = v.Depth - b += 1 + xgb.Put16(buf[b:], v.Width) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], v.Height) + b += 2 - xgb.Put16(buf[b:], v.VisualsLen) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - b += 4 // padding + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 - b += VisualInfoListBytes(buf[b:], v.Visuals) + b += 1 // padding return buf } -// DepthInfoListBytes writes a list of DepthInfo values to a byte slice. -func DepthInfoListBytes(buf []byte, list []DepthInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the ConfigureNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ConfigureNotifyEvent) SequenceId() uint16 { + return v.Sequence } -// DepthInfoListSize computes the size (bytes) of a list of DepthInfo values. -func DepthInfoListSize(list []DepthInfo) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) - } - return size +// String is a rudimentary string representation of ConfigureNotifyEvent. +func (v ConfigureNotifyEvent) String() string { + fieldVals := make([]string, 0, 11) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("AboveSibling: %d", v.AboveSibling)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "ConfigureNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type ScreenInfo struct { - Root Window - DefaultColormap Colormap - WhitePixel uint32 - BlackPixel uint32 - CurrentInputMasks uint32 - WidthInPixels uint16 - HeightInPixels uint16 - WidthInMillimeters uint16 - HeightInMillimeters uint16 - MinInstalledMaps uint16 - MaxInstalledMaps uint16 - RootVisual Visualid - BackingStores byte - SaveUnders bool - RootDepth byte - AllowedDepthsLen byte - AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) +func init() { + xgb.NewEventFuncs[22] = ConfigureNotifyEventNew } -// ScreenInfoRead reads a byte slice into a ScreenInfo value. -func ScreenInfoRead(buf []byte, v *ScreenInfo) int { - b := 0 +// ConfigureRequest is the event number for a ConfigureRequestEvent. +const ConfigureRequest = 23 - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 +type ConfigureRequestEvent struct { + Sequence uint16 + StackMode byte + Parent Window + Window Window + Sibling Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + ValueMask uint16 +} - v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) - b += 4 +// ConfigureRequestEventNew constructs a ConfigureRequestEvent value that implements xgb.Event from a byte slice. +func ConfigureRequestEventNew(buf []byte) xgb.Event { + v := ConfigureRequestEvent{} + b := 1 // don't read event number - v.WhitePixel = xgb.Get32(buf[b:]) + v.StackMode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) b += 4 - v.BlackPixel = xgb.Get32(buf[b:]) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.CurrentInputMasks = xgb.Get32(buf[b:]) + v.Sibling = Window(xgb.Get32(buf[b:])) b += 4 - v.WidthInPixels = xgb.Get16(buf[b:]) + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.HeightInPixels = xgb.Get16(buf[b:]) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.WidthInMillimeters = xgb.Get16(buf[b:]) + v.Width = xgb.Get16(buf[b:]) b += 2 - v.HeightInMillimeters = xgb.Get16(buf[b:]) + v.Height = xgb.Get16(buf[b:]) b += 2 - v.MinInstalledMaps = xgb.Get16(buf[b:]) + v.BorderWidth = xgb.Get16(buf[b:]) b += 2 - v.MaxInstalledMaps = xgb.Get16(buf[b:]) + v.ValueMask = xgb.Get16(buf[b:]) b += 2 - v.RootVisual = Visualid(xgb.Get32(buf[b:])) - b += 4 - - v.BackingStores = buf[b] - b += 1 - - if buf[b] == 1 { - v.SaveUnders = true - } else { - v.SaveUnders = false - } - b += 1 - - v.RootDepth = buf[b] - b += 1 - - v.AllowedDepthsLen = buf[b] - b += 1 - - v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) - b += DepthInfoReadList(buf[b:], v.AllowedDepths) - - return b + return v } -// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values. -func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { +// Bytes writes a ConfigureRequestEvent value to a byte slice. +func (v ConfigureRequestEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ScreenInfo{} - b += ScreenInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} -// Bytes writes a ScreenInfo value to a byte slice. -func (v ScreenInfo) Bytes() []byte { - buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) - b := 0 + // write event number + buf[b] = 23 + b += 1 - xgb.Put32(buf[b:], uint32(v.Root)) - b += 4 + buf[b] = v.StackMode + b += 1 - xgb.Put32(buf[b:], uint32(v.DefaultColormap)) - b += 4 + b += 2 // skip sequence number - xgb.Put32(buf[b:], v.WhitePixel) + xgb.Put32(buf[b:], uint32(v.Parent)) b += 4 - xgb.Put32(buf[b:], v.BlackPixel) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put32(buf[b:], v.CurrentInputMasks) + xgb.Put32(buf[b:], uint32(v.Sibling)) b += 4 - xgb.Put16(buf[b:], v.WidthInPixels) + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - xgb.Put16(buf[b:], v.HeightInPixels) + xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - xgb.Put16(buf[b:], v.WidthInMillimeters) + xgb.Put16(buf[b:], v.Width) b += 2 - xgb.Put16(buf[b:], v.HeightInMillimeters) + xgb.Put16(buf[b:], v.Height) b += 2 - xgb.Put16(buf[b:], v.MinInstalledMaps) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - xgb.Put16(buf[b:], v.MaxInstalledMaps) + xgb.Put16(buf[b:], v.ValueMask) b += 2 - xgb.Put32(buf[b:], uint32(v.RootVisual)) - b += 4 - - buf[b] = v.BackingStores - b += 1 - - if v.SaveUnders { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.RootDepth - b += 1 - - buf[b] = v.AllowedDepthsLen - b += 1 - - b += DepthInfoListBytes(buf[b:], v.AllowedDepths) - return buf } -// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. -func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the ConfigureRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ConfigureRequestEvent) SequenceId() uint16 { + return v.Sequence } -// ScreenInfoListSize computes the size (bytes) of a list of ScreenInfo values. -func ScreenInfoListSize(list []ScreenInfo) int { - size := 0 - for _, item := range list { - size += (40 + DepthInfoListSize(item.AllowedDepths)) - } - return size +// String is a rudimentary string representation of ConfigureRequestEvent. +func (v ConfigureRequestEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("StackMode: %d", v.StackMode)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Sibling: %d", v.Sibling)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("ValueMask: %d", v.ValueMask)) + return "ConfigureRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type SetupRequest struct { - ByteOrder byte - // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - AuthorizationProtocolNameLen uint16 - AuthorizationProtocolDataLen uint16 - // padding: 2 bytes - AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) - AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) +func init() { + xgb.NewEventFuncs[23] = ConfigureRequestEventNew } -// SetupRequestRead reads a byte slice into a SetupRequest value. -func SetupRequestRead(buf []byte, v *SetupRequest) int { - b := 0 +const ( + CoordModeOrigin = 0 + CoordModePrevious = 1 +) - v.ByteOrder = buf[b] - b += 1 +// CreateNotify is the event number for a CreateNotifyEvent. +const CreateNotify = 16 + +type CreateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// CreateNotifyEventNew constructs a CreateNotifyEvent value that implements xgb.Event from a byte slice. +func CreateNotifyEventNew(buf []byte) xgb.Event { + v := CreateNotifyEvent{} + b := 1 // don't read event number b += 1 // padding - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) + v.Width = xgb.Get16(buf[b:]) b += 2 - b += 2 // padding + v.Height = xgb.Get16(buf[b:]) + b += 2 - { - byteString := make([]byte, v.AuthorizationProtocolNameLen) - copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) - v.AuthorizationProtocolName = string(byteString) - b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - } + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 - { - byteString := make([]byte, v.AuthorizationProtocolDataLen) - copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) - v.AuthorizationProtocolData = string(byteString) - b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false } + b += 1 - return b -} + b += 1 // padding -// SetupRequestReadList reads a byte slice into a list of SetupRequest values. -func SetupRequestReadList(buf []byte, dest []SetupRequest) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupRequest{} - b += SetupRequestRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return v } -// Bytes writes a SetupRequest value to a byte slice. -func (v SetupRequest) Bytes() []byte { - buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) +// Bytes writes a CreateNotifyEvent value to a byte slice. +func (v CreateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - buf[b] = v.ByteOrder + // write event number + buf[b] = 16 b += 1 b += 1 // padding - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 + b += 2 // skip sequence number - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 - xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) - b += 2 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - b += 2 // padding - - copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) - b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - - copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) - b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) - - return buf -} - -// SetupRequestListBytes writes a list of SetupRequest values to a byte slice. -func SetupRequestListBytes(buf []byte, list []SetupRequest) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// SetupRequestListSize computes the size (bytes) of a list of SetupRequest values. -func SetupRequestListSize(list []SetupRequest) int { - size := 0 - for _, item := range list { - size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) - } - return size -} - -type SetupFailed struct { - Status byte - ReasonLen byte - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - Reason string // size: xgb.Pad((int(ReasonLen) * 1)) -} - -// SetupFailedRead reads a byte slice into a SetupFailed value. -func SetupFailedRead(buf []byte, v *SetupFailed) int { - b := 0 - - v.Status = buf[b] - b += 1 - - v.ReasonLen = buf[b] - b += 1 + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Width) b += 2 - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Height) b += 2 - v.Length = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.BorderWidth) b += 2 - { - byteString := make([]byte, v.ReasonLen) - copy(byteString[:v.ReasonLen], buf[b:]) - v.Reason = string(byteString) - b += xgb.Pad(int(v.ReasonLen)) + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 } + b += 1 - return b + b += 1 // padding + + return buf } -// SetupFailedReadList reads a byte slice into a list of SetupFailed values. -func SetupFailedReadList(buf []byte, dest []SetupFailed) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupFailed{} - b += SetupFailedRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the CreateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v CreateNotifyEvent) SequenceId() uint16 { + return v.Sequence } -// Bytes writes a SetupFailed value to a byte slice. -func (v SetupFailed) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) - b := 0 +// String is a rudimentary string representation of CreateNotifyEvent. +func (v CreateNotifyEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - buf[b] = v.Status - b += 1 +func init() { + xgb.NewEventFuncs[16] = CreateNotifyEventNew +} - buf[b] = v.ReasonLen - b += 1 +type Cursor uint32 - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 +func NewCursorId(c *xgb.Conn) (Cursor, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Cursor(id), nil +} - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 +// BadCursor is the error number for a BadCursor. +const BadCursor = 6 - xgb.Put16(buf[b:], v.Length) - b += 2 +type CursorError ValueError - copy(buf[b:], v.Reason[:v.ReasonLen]) - b += xgb.Pad(int(v.ReasonLen)) +// CursorErrorNew constructs a CursorError value that implements xgb.Error from a byte slice. +func CursorErrorNew(buf []byte) xgb.Error { + v := CursorError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Cursor" + return v +} - return buf +// SequenceId returns the sequence id attached to the BadCursor error. +// This is mostly used internally. +func (err CursorError) SequenceId() uint16 { + return err.Sequence } -// SetupFailedListBytes writes a list of SetupFailed values to a byte slice. -func SetupFailedListBytes(buf []byte, list []SetupFailed) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// BadId returns the 'BadValue' number if one exists for the BadCursor error. If no bad value exists, 0 is returned. +func (err CursorError) BadId() uint32 { + return err.BadValue } -// SetupFailedListSize computes the size (bytes) of a list of SetupFailed values. -func SetupFailedListSize(list []SetupFailed) int { - size := 0 - for _, item := range list { - size += (8 + xgb.Pad((int(item.ReasonLen) * 1))) - } - return size +// Error returns a rudimentary string representation of the BadCursor error. +func (err CursorError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCursor {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type SetupAuthenticate struct { - Status byte - // padding: 5 bytes - Length uint16 - Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) +func init() { + xgb.NewErrorFuncs[6] = CursorErrorNew } -// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. -func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { +const ( + CursorNone = 0 +) + +const ( + CwBackPixmap = 1 + CwBackPixel = 2 + CwBorderPixmap = 4 + CwBorderPixel = 8 + CwBitGravity = 16 + CwWinGravity = 32 + CwBackingStore = 64 + CwBackingPlanes = 128 + CwBackingPixel = 256 + CwOverrideRedirect = 512 + CwSaveUnder = 1024 + CwEventMask = 2048 + CwDontPropagate = 4096 + CwColormap = 8192 + CwCursor = 16384 +) + +type DepthInfo struct { + Depth byte + // padding: 1 bytes + VisualsLen uint16 + // padding: 4 bytes + Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) +} + +// DepthInfoRead reads a byte slice into a DepthInfo value. +func DepthInfoRead(buf []byte, v *DepthInfo) int { b := 0 - v.Status = buf[b] + v.Depth = buf[b] b += 1 - b += 5 // padding + b += 1 // padding - v.Length = xgb.Get16(buf[b:]) + v.VisualsLen = xgb.Get16(buf[b:]) b += 2 - { - byteString := make([]byte, (int(v.Length) * 4)) - copy(byteString[:(int(v.Length)*4)], buf[b:]) - v.Reason = string(byteString) - b += xgb.Pad(int((int(v.Length) * 4))) - } + b += 4 // padding + + v.Visuals = make([]VisualInfo, v.VisualsLen) + b += VisualInfoReadList(buf[b:], v.Visuals) return b } -// SetupAuthenticateReadList reads a byte slice into a list of SetupAuthenticate values. -func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { +// DepthInfoReadList reads a byte slice into a list of DepthInfo values. +func DepthInfoReadList(buf []byte, dest []DepthInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = SetupAuthenticate{} - b += SetupAuthenticateRead(buf[b:], &dest[i]) + dest[i] = DepthInfo{} + b += DepthInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a SetupAuthenticate value to a byte slice. -func (v SetupAuthenticate) Bytes() []byte { - buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) +// Bytes writes a DepthInfo value to a byte slice. +func (v DepthInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) b := 0 - buf[b] = v.Status + buf[b] = v.Depth b += 1 - b += 5 // padding + b += 1 // padding - xgb.Put16(buf[b:], v.Length) + xgb.Put16(buf[b:], v.VisualsLen) b += 2 - copy(buf[b:], v.Reason[:(int(v.Length)*4)]) - b += xgb.Pad(int((int(v.Length) * 4))) + b += 4 // padding + + b += VisualInfoListBytes(buf[b:], v.Visuals) return buf } -// SetupAuthenticateListBytes writes a list of SetupAuthenticate values to a byte slice. -func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { +// DepthInfoListBytes writes a list of DepthInfo values to a byte slice. +func DepthInfoListBytes(buf []byte, list []DepthInfo) int { b := 0 var structBytes []byte for _, item := range list { @@ -1686,625 +1926,668 @@ func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { return b } -// SetupAuthenticateListSize computes the size (bytes) of a list of SetupAuthenticate values. -func SetupAuthenticateListSize(list []SetupAuthenticate) int { +// DepthInfoListSize computes the size (bytes) of a list of DepthInfo values. +func DepthInfoListSize(list []DepthInfo) int { size := 0 for _, item := range list { - size += (8 + xgb.Pad(((int(item.Length) * 4) * 1))) + size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) } return size } -type SetupInfo struct { - Status byte +// DestroyNotify is the event number for a DestroyNotifyEvent. +const DestroyNotify = 17 + +type DestroyNotifyEvent struct { + Sequence uint16 // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - ReleaseNumber uint32 - ResourceIdBase uint32 - ResourceIdMask uint32 - MotionBufferSize uint32 - VendorLen uint16 - MaximumRequestLength uint16 - RootsLen byte - PixmapFormatsLen byte - ImageByteOrder byte - BitmapFormatBitOrder byte - BitmapFormatScanlineUnit byte - BitmapFormatScanlinePad byte - MinKeycode Keycode - MaxKeycode Keycode - // padding: 4 bytes - Vendor string // size: xgb.Pad((int(VendorLen) * 1)) - PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) - Roots []ScreenInfo // size: ScreenInfoListSize(Roots) + Event Window + Window Window } -// SetupInfoRead reads a byte slice into a SetupInfo value. -func SetupInfoRead(buf []byte, v *SetupInfo) int { - b := 0 - - v.Status = buf[b] - b += 1 +// DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. +func DestroyNotifyEventNew(buf []byte) xgb.Event { + v := DestroyNotifyEvent{} + b := 1 // don't read event number b += 1 // padding - v.ProtocolMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.ReleaseNumber = xgb.Get32(buf[b:]) - b += 4 - - v.ResourceIdBase = xgb.Get32(buf[b:]) - b += 4 - - v.ResourceIdMask = xgb.Get32(buf[b:]) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.MotionBufferSize = xgb.Get32(buf[b:]) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.VendorLen = xgb.Get16(buf[b:]) - b += 2 + return v +} - v.MaximumRequestLength = xgb.Get16(buf[b:]) - b += 2 +// Bytes writes a DestroyNotifyEvent value to a byte slice. +func (v DestroyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 - v.RootsLen = buf[b] + // write event number + buf[b] = 17 b += 1 - v.PixmapFormatsLen = buf[b] - b += 1 + b += 1 // padding - v.ImageByteOrder = buf[b] - b += 1 + b += 2 // skip sequence number - v.BitmapFormatBitOrder = buf[b] - b += 1 + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 - v.BitmapFormatScanlineUnit = buf[b] - b += 1 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - v.BitmapFormatScanlinePad = buf[b] - b += 1 + return buf +} - v.MinKeycode = Keycode(buf[b]) - b += 1 +// SequenceId returns the sequence id attached to the DestroyNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v DestroyNotifyEvent) SequenceId() uint16 { + return v.Sequence +} - v.MaxKeycode = Keycode(buf[b]) - b += 1 +// String is a rudimentary string representation of DestroyNotifyEvent. +func (v DestroyNotifyEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - b += 4 // padding +func init() { + xgb.NewEventFuncs[17] = DestroyNotifyEventNew +} - { - byteString := make([]byte, v.VendorLen) - copy(byteString[:v.VendorLen], buf[b:]) - v.Vendor = string(byteString) - b += xgb.Pad(int(v.VendorLen)) +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err } + return Drawable(id), nil +} - v.PixmapFormats = make([]Format, v.PixmapFormatsLen) - b += FormatReadList(buf[b:], v.PixmapFormats) +// BadDrawable is the error number for a BadDrawable. +const BadDrawable = 9 - v.Roots = make([]ScreenInfo, v.RootsLen) - b += ScreenInfoReadList(buf[b:], v.Roots) +type DrawableError ValueError - return b +// DrawableErrorNew constructs a DrawableError value that implements xgb.Error from a byte slice. +func DrawableErrorNew(buf []byte) xgb.Error { + v := DrawableError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Drawable" + return v } -// SetupInfoReadList reads a byte slice into a list of SetupInfo values. -func SetupInfoReadList(buf []byte, dest []SetupInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupInfo{} - b += SetupInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the BadDrawable error. +// This is mostly used internally. +func (err DrawableError) SequenceId() uint16 { + return err.Sequence } -// Bytes writes a SetupInfo value to a byte slice. -func (v SetupInfo) Bytes() []byte { - buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) - b := 0 +// BadId returns the 'BadValue' number if one exists for the BadDrawable error. If no bad value exists, 0 is returned. +func (err DrawableError) BadId() uint32 { + return err.BadValue +} - buf[b] = v.Status - b += 1 +// Error returns a rudimentary string representation of the BadDrawable error. +func (err DrawableError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - b += 1 // padding +func init() { + xgb.NewErrorFuncs[9] = DrawableErrorNew +} - xgb.Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 +// EnterNotify is the event number for a EnterNotifyEvent. +const EnterNotify = 7 - xgb.Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 +type EnterNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + Mode byte + SameScreenFocus byte +} - xgb.Put16(buf[b:], v.Length) +// EnterNotifyEventNew constructs a EnterNotifyEvent value that implements xgb.Event from a byte slice. +func EnterNotifyEventNew(buf []byte) xgb.Event { + v := EnterNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], v.ReleaseNumber) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.ResourceIdBase) + v.Root = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.ResourceIdMask) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], v.MotionBufferSize) + v.Child = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put16(buf[b:], v.VendorLen) + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], v.MaximumRequestLength) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - buf[b] = v.RootsLen - b += 1 - - buf[b] = v.PixmapFormatsLen - b += 1 - - buf[b] = v.ImageByteOrder - b += 1 - - buf[b] = v.BitmapFormatBitOrder - b += 1 + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 - buf[b] = v.BitmapFormatScanlineUnit - b += 1 + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 - buf[b] = v.BitmapFormatScanlinePad - b += 1 + v.State = xgb.Get16(buf[b:]) + b += 2 - buf[b] = byte(v.MinKeycode) + v.Mode = buf[b] b += 1 - buf[b] = byte(v.MaxKeycode) + v.SameScreenFocus = buf[b] b += 1 - b += 4 // padding - - copy(buf[b:], v.Vendor[:v.VendorLen]) - b += xgb.Pad(int(v.VendorLen)) - - b += FormatListBytes(buf[b:], v.PixmapFormats) - - b += ScreenInfoListBytes(buf[b:], v.Roots) - - return buf + return v } -// SetupInfoListBytes writes a list of SetupInfo values to a byte slice. -func SetupInfoListBytes(buf []byte, list []SetupInfo) int { +// Bytes writes a EnterNotifyEvent value to a byte slice. +func (v EnterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} -// SetupInfoListSize computes the size (bytes) of a list of SetupInfo values. -func SetupInfoListSize(list []SetupInfo) int { - size := 0 - for _, item := range list { - size += (((40 + xgb.Pad((int(item.VendorLen) * 1))) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) - } - return size -} + // write event number + buf[b] = 7 + b += 1 -type Timecoord struct { - Time Timestamp - X int16 - Y int16 -} + buf[b] = v.Detail + b += 1 -// TimecoordRead reads a byte slice into a Timecoord value. -func TimecoordRead(buf []byte, v *Timecoord) int { - b := 0 + b += 2 // skip sequence number - v.Time = Timestamp(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 - return b -} + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 -// TimecoordReadList reads a byte slice into a list of Timecoord values. -func TimecoordReadList(buf []byte, dest []Timecoord) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Timecoord{} - b += TimecoordRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 -// Bytes writes a Timecoord value to a byte slice. -func (v Timecoord) Bytes() []byte { - buf := make([]byte, 8) - b := 0 + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 - xgb.Put16(buf[b:], uint16(v.X)) + xgb.Put16(buf[b:], uint16(v.EventX)) b += 2 - xgb.Put16(buf[b:], uint16(v.Y)) + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) b += 2 + buf[b] = v.Mode + b += 1 + + buf[b] = v.SameScreenFocus + b += 1 + return buf } -// TimecoordListBytes writes a list of Timecoord values to a byte slice. -func TimecoordListBytes(buf []byte, list []Timecoord) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the EnterNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v EnterNotifyEvent) SequenceId() uint16 { + return v.Sequence } -type Fontprop struct { - Name Atom - Value uint32 +// String is a rudimentary string representation of EnterNotifyEvent. +func (v EnterNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) + return "EnterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// FontpropRead reads a byte slice into a Fontprop value. -func FontpropRead(buf []byte, v *Fontprop) int { - b := 0 +func init() { + xgb.NewEventFuncs[7] = EnterNotifyEventNew +} - v.Name = Atom(xgb.Get32(buf[b:])) - b += 4 +const ( + EventMaskNoEvent = 0 + EventMaskKeyPress = 1 + EventMaskKeyRelease = 2 + EventMaskButtonPress = 4 + EventMaskButtonRelease = 8 + EventMaskEnterWindow = 16 + EventMaskLeaveWindow = 32 + EventMaskPointerMotion = 64 + EventMaskPointerMotionHint = 128 + EventMaskButton1Motion = 256 + EventMaskButton2Motion = 512 + EventMaskButton3Motion = 1024 + EventMaskButton4Motion = 2048 + EventMaskButton5Motion = 4096 + EventMaskButtonMotion = 8192 + EventMaskKeymapState = 16384 + EventMaskExposure = 32768 + EventMaskVisibilityChange = 65536 + EventMaskStructureNotify = 131072 + EventMaskResizeRedirect = 262144 + EventMaskSubstructureNotify = 524288 + EventMaskSubstructureRedirect = 1048576 + EventMaskFocusChange = 2097152 + EventMaskPropertyChange = 4194304 + EventMaskColorMapChange = 8388608 + EventMaskOwnerGrabButton = 16777216 +) - v.Value = xgb.Get32(buf[b:]) - b += 4 +// Expose is the event number for a ExposeEvent. +const Expose = 12 - return b +type ExposeEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 2 bytes } -// FontpropReadList reads a byte slice into a list of Fontprop values. -func FontpropReadList(buf []byte, dest []Fontprop) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Fontprop{} - b += FontpropRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} +// ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. +func ExposeEventNew(buf []byte) xgb.Event { + v := ExposeEvent{} + b := 1 // don't read event number -// Bytes writes a Fontprop value to a byte slice. -func (v Fontprop) Bytes() []byte { - buf := make([]byte, 8) - b := 0 + b += 1 // padding - xgb.Put32(buf[b:], uint32(v.Name)) - b += 4 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], v.Value) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - return buf -} + v.X = xgb.Get16(buf[b:]) + b += 2 -// FontpropListBytes writes a list of Fontprop values to a byte slice. -func FontpropListBytes(buf []byte, list []Fontprop) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} + v.Y = xgb.Get16(buf[b:]) + b += 2 -type Charinfo struct { - LeftSideBearing int16 - RightSideBearing int16 - CharacterWidth int16 - Ascent int16 - Descent int16 - Attributes uint16 + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v } -// CharinfoRead reads a byte slice into a Charinfo value. -func CharinfoRead(buf []byte, v *Charinfo) int { +// Bytes writes a ExposeEvent value to a byte slice. +func (v ExposeEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.LeftSideBearing = int16(xgb.Get16(buf[b:])) - b += 2 + // write event number + buf[b] = 12 + b += 1 - v.RightSideBearing = int16(xgb.Get16(buf[b:])) + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], v.X) b += 2 - v.CharacterWidth = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], v.Y) b += 2 - v.Ascent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], v.Width) b += 2 - v.Descent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], v.Height) b += 2 - v.Attributes = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Count) b += 2 - return b + b += 2 // padding + + return buf } -// CharinfoReadList reads a byte slice into a list of Charinfo values. -func CharinfoReadList(buf []byte, dest []Charinfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Charinfo{} - b += CharinfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the Expose event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v ExposeEvent) SequenceId() uint16 { + return v.Sequence } -// Bytes writes a Charinfo value to a byte slice. -func (v Charinfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 +// String is a rudimentary string representation of ExposeEvent. +func (v ExposeEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - xgb.Put16(buf[b:], uint16(v.LeftSideBearing)) - b += 2 +func init() { + xgb.NewEventFuncs[12] = ExposeEventNew +} + +const ( + ExposuresNotAllowed = 0 + ExposuresAllowed = 1 + ExposuresDefault = 2 +) + +const ( + FamilyInternet = 0 + FamilyDECnet = 1 + FamilyChaos = 2 + FamilyServerInterpreted = 5 + FamilyInternet6 = 6 +) + +const ( + FillRuleEvenOdd = 0 + FillRuleWinding = 1 +) + +const ( + FillStyleSolid = 0 + FillStyleTiled = 1 + FillStyleStippled = 2 + FillStyleOpaqueStippled = 3 +) + +// FocusIn is the event number for a FocusInEvent. +const FocusIn = 9 - xgb.Put16(buf[b:], uint16(v.RightSideBearing)) - b += 2 +type FocusInEvent struct { + Sequence uint16 + Detail byte + Event Window + Mode byte + // padding: 3 bytes +} - xgb.Put16(buf[b:], uint16(v.CharacterWidth)) - b += 2 +// FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. +func FocusInEventNew(buf []byte) xgb.Event { + v := FocusInEvent{} + b := 1 // don't read event number - xgb.Put16(buf[b:], uint16(v.Ascent)) - b += 2 + v.Detail = buf[b] + b += 1 - xgb.Put16(buf[b:], uint16(v.Descent)) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], v.Attributes) - b += 2 + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 - return buf -} + v.Mode = buf[b] + b += 1 -// CharinfoListBytes writes a list of Charinfo values to a byte slice. -func CharinfoListBytes(buf []byte, list []Charinfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} + b += 3 // padding -type Str struct { - NameLen byte - Name string // size: xgb.Pad((int(NameLen) * 1)) + return v } -// StrRead reads a byte slice into a Str value. -func StrRead(buf []byte, v *Str) int { +// Bytes writes a FocusInEvent value to a byte slice. +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) b := 0 - v.NameLen = buf[b] + // write event number + buf[b] = 9 b += 1 - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) - } - - return b -} + buf[b] = v.Detail + b += 1 -// StrReadList reads a byte slice into a list of Str values. -func StrReadList(buf []byte, dest []Str) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Str{} - b += StrRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} + b += 2 // skip sequence number -// Bytes writes a Str value to a byte slice. -func (v Str) Bytes() []byte { - buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) - b := 0 + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 - buf[b] = v.NameLen + buf[b] = v.Mode b += 1 - copy(buf[b:], v.Name[:v.NameLen]) - b += xgb.Pad(int(v.NameLen)) + b += 3 // padding return buf } -// StrListBytes writes a list of Str values to a byte slice. -func StrListBytes(buf []byte, list []Str) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b +// SequenceId returns the sequence id attached to the FocusIn event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v FocusInEvent) SequenceId() uint16 { + return v.Sequence } -// StrListSize computes the size (bytes) of a list of Str values. -func StrListSize(list []Str) int { - size := 0 - for _, item := range list { - size += (1 + xgb.Pad((int(item.NameLen) * 1))) - } - return size +// String is a rudimentary string representation of FocusInEvent. +func (v FocusInEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -type Segment struct { - X1 int16 - Y1 int16 - X2 int16 - Y2 int16 +func init() { + xgb.NewEventFuncs[9] = FocusInEventNew } -// SegmentRead reads a byte slice into a Segment value. -func SegmentRead(buf []byte, v *Segment) int { - b := 0 +// FocusOut is the event number for a FocusOutEvent. +const FocusOut = 10 - v.X1 = int16(xgb.Get16(buf[b:])) - b += 2 +type FocusOutEvent FocusInEvent - v.Y1 = int16(xgb.Get16(buf[b:])) - b += 2 +// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. +func FocusOutEventNew(buf []byte) xgb.Event { + return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) +} - v.X2 = int16(xgb.Get16(buf[b:])) - b += 2 +// Bytes writes a FocusOutEvent value to a byte slice. +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} - v.Y2 = int16(xgb.Get16(buf[b:])) - b += 2 +// SequenceId returns the sequence id attached to the FocusOut event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v FocusOutEvent) SequenceId() uint16 { + return v.Sequence +} - return b +func (v FocusOutEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// SegmentReadList reads a byte slice into a list of Segment values. -func SegmentReadList(buf []byte, dest []Segment) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Segment{} - b += SegmentRead(buf[b:], &dest[i]) +func init() { + xgb.NewEventFuncs[10] = FocusOutEventNew +} + +type Font uint32 + +func NewFontId(c *xgb.Conn) (Font, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return xgb.Pad(b) + return Font(id), nil } -// Bytes writes a Segment value to a byte slice. -func (v Segment) Bytes() []byte { - buf := make([]byte, 8) - b := 0 +const ( + FontNone = 0 +) - xgb.Put16(buf[b:], uint16(v.X1)) - b += 2 +// BadFont is the error number for a BadFont. +const BadFont = 7 - xgb.Put16(buf[b:], uint16(v.Y1)) - b += 2 +type FontError ValueError - xgb.Put16(buf[b:], uint16(v.X2)) - b += 2 +// FontErrorNew constructs a FontError value that implements xgb.Error from a byte slice. +func FontErrorNew(buf []byte) xgb.Error { + v := FontError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Font" + return v +} - xgb.Put16(buf[b:], uint16(v.Y2)) - b += 2 +// SequenceId returns the sequence id attached to the BadFont error. +// This is mostly used internally. +func (err FontError) SequenceId() uint16 { + return err.Sequence +} - return buf +// BadId returns the 'BadValue' number if one exists for the BadFont error. If no bad value exists, 0 is returned. +func (err FontError) BadId() uint32 { + return err.BadValue } -// SegmentListBytes writes a list of Segment values to a byte slice. -func SegmentListBytes(buf []byte, list []Segment) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) +// Error returns a rudimentary string representation of the BadFont error. +func (err FontError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadFont {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[7] = FontErrorNew +} + +const ( + FontDrawLeftToRight = 0 + FontDrawRightToLeft = 1 +) + +type Fontable uint32 + +func NewFontableId(c *xgb.Conn) (Fontable, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return b + return Fontable(id), nil } -type Coloritem struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Flags byte - // padding: 1 bytes +type Fontprop struct { + Name Atom + Value uint32 } -// ColoritemRead reads a byte slice into a Coloritem value. -func ColoritemRead(buf []byte, v *Coloritem) int { +// FontpropRead reads a byte slice into a Fontprop value. +func FontpropRead(buf []byte, v *Fontprop) int { b := 0 - v.Pixel = xgb.Get32(buf[b:]) + v.Name = Atom(xgb.Get32(buf[b:])) b += 4 - v.Red = xgb.Get16(buf[b:]) - b += 2 - - v.Green = xgb.Get16(buf[b:]) - b += 2 - - v.Blue = xgb.Get16(buf[b:]) - b += 2 - - v.Flags = buf[b] - b += 1 - - b += 1 // padding + v.Value = xgb.Get32(buf[b:]) + b += 4 return b } -// ColoritemReadList reads a byte slice into a list of Coloritem values. -func ColoritemReadList(buf []byte, dest []Coloritem) int { +// FontpropReadList reads a byte slice into a list of Fontprop values. +func FontpropReadList(buf []byte, dest []Fontprop) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Coloritem{} - b += ColoritemRead(buf[b:], &dest[i]) + dest[i] = Fontprop{} + b += FontpropRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Coloritem value to a byte slice. -func (v Coloritem) Bytes() []byte { - buf := make([]byte, 12) +// Bytes writes a Fontprop value to a byte slice. +func (v Fontprop) Bytes() []byte { + buf := make([]byte, 8) b := 0 - xgb.Put32(buf[b:], v.Pixel) + xgb.Put32(buf[b:], uint32(v.Name)) b += 4 - xgb.Put16(buf[b:], v.Red) - b += 2 - - xgb.Put16(buf[b:], v.Green) - b += 2 - - xgb.Put16(buf[b:], v.Blue) - b += 2 - - buf[b] = v.Flags - b += 1 - - b += 1 // padding + xgb.Put32(buf[b:], v.Value) + b += 4 return buf } -// ColoritemListBytes writes a list of Coloritem values to a byte slice. -func ColoritemListBytes(buf []byte, list []Coloritem) int { +// FontpropListBytes writes a list of Fontprop values to a byte slice. +func FontpropListBytes(buf []byte, list []Fontprop) int { b := 0 var structBytes []byte for _, item := range list { @@ -2315,62 +2598,62 @@ func ColoritemListBytes(buf []byte, list []Coloritem) int { return b } -type Rgb struct { - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes +type Format struct { + Depth byte + BitsPerPixel byte + ScanlinePad byte + // padding: 5 bytes } -// RgbRead reads a byte slice into a Rgb value. -func RgbRead(buf []byte, v *Rgb) int { +// FormatRead reads a byte slice into a Format value. +func FormatRead(buf []byte, v *Format) int { b := 0 - v.Red = xgb.Get16(buf[b:]) - b += 2 + v.Depth = buf[b] + b += 1 - v.Green = xgb.Get16(buf[b:]) - b += 2 + v.BitsPerPixel = buf[b] + b += 1 - v.Blue = xgb.Get16(buf[b:]) - b += 2 + v.ScanlinePad = buf[b] + b += 1 - b += 2 // padding + b += 5 // padding return b } -// RgbReadList reads a byte slice into a list of Rgb values. -func RgbReadList(buf []byte, dest []Rgb) int { +// FormatReadList reads a byte slice into a list of Format values. +func FormatReadList(buf []byte, dest []Format) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = Rgb{} - b += RgbRead(buf[b:], &dest[i]) + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a Rgb value to a byte slice. -func (v Rgb) Bytes() []byte { +// Bytes writes a Format value to a byte slice. +func (v Format) Bytes() []byte { buf := make([]byte, 8) b := 0 - xgb.Put16(buf[b:], v.Red) - b += 2 + buf[b] = v.Depth + b += 1 - xgb.Put16(buf[b:], v.Green) - b += 2 + buf[b] = v.BitsPerPixel + b += 1 - xgb.Put16(buf[b:], v.Blue) - b += 2 + buf[b] = v.ScanlinePad + b += 1 - b += 2 // padding + b += 5 // padding return buf } -// RgbListBytes writes a list of Rgb values to a byte slice. -func RgbListBytes(buf []byte, list []Rgb) int { +// FormatListBytes writes a list of Format values to a byte slice. +func FormatListBytes(buf []byte, list []Format) int { b := 0 var structBytes []byte for _, item := range list { @@ -2381,431 +2664,560 @@ func RgbListBytes(buf []byte, list []Rgb) int { return b } -type Host struct { - Family byte - // padding: 1 bytes - AddressLen uint16 - Address []byte // size: xgb.Pad((int(AddressLen) * 1)) -} - -// HostRead reads a byte slice into a Host value. -func HostRead(buf []byte, v *Host) int { - b := 0 - - v.Family = buf[b] - b += 1 - - b += 1 // padding - - v.AddressLen = xgb.Get16(buf[b:]) - b += 2 +// BadGContext is the error number for a BadGContext. +const BadGContext = 13 - v.Address = make([]byte, v.AddressLen) - copy(v.Address[:v.AddressLen], buf[b:]) - b += xgb.Pad(int(v.AddressLen)) +type GContextError ValueError - return b +// GContextErrorNew constructs a GContextError value that implements xgb.Error from a byte slice. +func GContextErrorNew(buf []byte) xgb.Error { + v := GContextError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "GContext" + return v } -// HostReadList reads a byte slice into a list of Host values. -func HostReadList(buf []byte, dest []Host) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Host{} - b += HostRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the BadGContext error. +// This is mostly used internally. +func (err GContextError) SequenceId() uint16 { + return err.Sequence } -// Bytes writes a Host value to a byte slice. -func (v Host) Bytes() []byte { - buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) - b := 0 - - buf[b] = v.Family - b += 1 +// BadId returns the 'BadValue' number if one exists for the BadGContext error. If no bad value exists, 0 is returned. +func (err GContextError) BadId() uint32 { + return err.BadValue +} - b += 1 // padding +// Error returns a rudimentary string representation of the BadGContext error. +func (err GContextError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - xgb.Put16(buf[b:], v.AddressLen) - b += 2 +func init() { + xgb.NewErrorFuncs[13] = GContextErrorNew +} - copy(buf[b:], v.Address[:v.AddressLen]) - b += xgb.Pad(int(v.AddressLen)) +const ( + GcFunction = 1 + GcPlaneMask = 2 + GcForeground = 4 + GcBackground = 8 + GcLineWidth = 16 + GcLineStyle = 32 + GcCapStyle = 64 + GcJoinStyle = 128 + GcFillStyle = 256 + GcFillRule = 512 + GcTile = 1024 + GcStipple = 2048 + GcTileStippleOriginX = 4096 + GcTileStippleOriginY = 8192 + GcFont = 16384 + GcSubwindowMode = 32768 + GcGraphicsExposures = 65536 + GcClipOriginX = 131072 + GcClipOriginY = 262144 + GcClipMask = 524288 + GcDashOffset = 1048576 + GcDashList = 2097152 + GcArcMode = 4194304 +) - return buf -} +type Gcontext uint32 -// HostListBytes writes a list of Host values to a byte slice. -func HostListBytes(buf []byte, list []Host) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) +func NewGcontextId(c *xgb.Conn) (Gcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return b + return Gcontext(id), nil } -// HostListSize computes the size (bytes) of a list of Host values. -func HostListSize(list []Host) int { - size := 0 - for _, item := range list { - size += (4 + xgb.Pad((int(item.AddressLen) * 1))) - } - return size -} +const ( + GetPropertyTypeAny = 0 +) -// ClientMessageDataUnion is a represention of the ClientMessageDataUnion union type. -// Note that to *create* a Union, you should *never* create -// this struct directly (unless you know what you're doing). -// Instead use one of the following constructors for 'ClientMessageDataUnion': -// ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion -// ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion -// ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion -type ClientMessageDataUnion struct { - Data8 []byte // size: 20 - Data16 []uint16 // size: 20 - Data32 []uint32 // size: 20 -} +const ( + GrabAny = 0 +) + +const ( + GrabModeSync = 0 + GrabModeAsync = 1 +) -// ClientMessageDataUnionData8New constructs a new ClientMessageDataUnion union type with the Data8 field. -func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) +const ( + GrabStatusSuccess = 0 + GrabStatusAlreadyGrabbed = 1 + GrabStatusInvalidTime = 2 + GrabStatusNotViewable = 3 + GrabStatusFrozen = 4 +) - copy(buf[b:], Data8[:20]) - b += xgb.Pad(int(20)) +// GraphicsExposure is the event number for a GraphicsExposureEvent. +const GraphicsExposure = 13 - // Create the Union type - v := ClientMessageDataUnion{} +type GraphicsExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Drawable + X uint16 + Y uint16 + Width uint16 + Height uint16 + MinorOpcode uint16 + Count uint16 + MajorOpcode byte + // padding: 3 bytes +} - // Now copy buf into all fields +// GraphicsExposureEventNew constructs a GraphicsExposureEvent value that implements xgb.Event from a byte slice. +func GraphicsExposureEventNew(buf []byte) xgb.Event { + v := GraphicsExposureEvent{} + b := 1 // don't read event number - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + b += 1 // padding - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 - return v -} + v.X = xgb.Get16(buf[b:]) + b += 2 -// ClientMessageDataUnionData16New constructs a new ClientMessageDataUnion union type with the Data16 field. -func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) + v.Y = xgb.Get16(buf[b:]) + b += 2 - for i := 0; i < int(10); i++ { - xgb.Put16(buf[b:], Data16[i]) - b += 2 - } - b = xgb.Pad(b) + v.Width = xgb.Get16(buf[b:]) + b += 2 - // Create the Union type - v := ClientMessageDataUnion{} + v.Height = xgb.Get16(buf[b:]) + b += 2 - // Now copy buf into all fields + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + v.Count = xgb.Get16(buf[b:]) + b += 2 - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + v.MajorOpcode = buf[b] + b += 1 - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + b += 3 // padding return v } -// ClientMessageDataUnionData32New constructs a new ClientMessageDataUnion union type with the Data32 field. -func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) +// Bytes writes a GraphicsExposureEvent value to a byte slice. +func (v GraphicsExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 - for i := 0; i < int(5); i++ { - xgb.Put32(buf[b:], Data32[i]) - b += 4 - } - b = xgb.Pad(b) + // write event number + buf[b] = 13 + b += 1 - // Create the Union type - v := ClientMessageDataUnion{} + b += 1 // padding - // Now copy buf into all fields + b += 2 // skip sequence number - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.X) + b += 2 - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.Y) + b += 2 - return v -} + xgb.Put16(buf[b:], v.Width) + b += 2 -// ClientMessageDataUnionRead reads a byte slice into a ClientMessageDataUnion value. -func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { - var b int + xgb.Put16(buf[b:], v.Height) + b += 2 - b = 0 // re-read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 - b = 0 // re-read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) + xgb.Put16(buf[b:], v.Count) + b += 2 - b = 0 // re-read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + buf[b] = v.MajorOpcode + b += 1 - return 20 -} + b += 3 // padding -// ClientMessageDataUnionReadList reads a byte slice into a list of ClientMessageDataUnion values. -func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ClientMessageDataUnion{} - b += ClientMessageDataUnionRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) + return buf } -// Bytes writes a ClientMessageDataUnion value to a byte slice. -// Each field in a union must contain the same data. -// So simply pick the first field and write that to the wire. -func (v ClientMessageDataUnion) Bytes() []byte { - buf := make([]byte, 20) - b := 0 +// SequenceId returns the sequence id attached to the GraphicsExposure event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v GraphicsExposureEvent) SequenceId() uint16 { + return v.Sequence +} - copy(buf[b:], v.Data8[:20]) - b += xgb.Pad(int(20)) - return buf +// String is a rudimentary string representation of GraphicsExposureEvent. +func (v GraphicsExposureEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "GraphicsExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" } -// ClientMessageDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. -func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { - b := 0 - var unionBytes []byte - for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) - } - return b +func init() { + xgb.NewEventFuncs[13] = GraphicsExposureEventNew } -// KeyPress is the event number for a KeyPressEvent. -const KeyPress = 2 +const ( + GravityBitForget = 0 + GravityWinUnmap = 0 + GravityNorthWest = 1 + GravityNorth = 2 + GravityNorthEast = 3 + GravityWest = 4 + GravityCenter = 5 + GravityEast = 6 + GravitySouthWest = 7 + GravitySouth = 8 + GravitySouthEast = 9 + GravityStatic = 10 +) + +// GravityNotify is the event number for a GravityNotifyEvent. +const GravityNotify = 24 -type KeyPressEvent struct { - Sequence uint16 - Detail Keycode - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool +type GravityNotifyEvent struct { + Sequence uint16 // padding: 1 bytes + Event Window + Window Window + X int16 + Y int16 } -// KeyPressEventNew constructs a KeyPressEvent value that implements xgb.Event from a byte slice. -func KeyPressEventNew(buf []byte) xgb.Event { - v := KeyPressEvent{} +// GravityNotifyEventNew constructs a GravityNotifyEvent value that implements xgb.Event from a byte slice. +func GravityNotifyEventNew(buf []byte) xgb.Event { + v := GravityNotifyEvent{} b := 1 // don't read event number - v.Detail = Keycode(buf[b]) - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 - v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.Child = Window(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.RootX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.RootY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.EventX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.EventY = int16(xgb.Get16(buf[b:])) + v.X = int16(xgb.Get16(buf[b:])) b += 2 - v.State = xgb.Get16(buf[b:]) + v.Y = int16(xgb.Get16(buf[b:])) b += 2 - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding - return v } -// Bytes writes a KeyPressEvent value to a byte slice. -func (v KeyPressEvent) Bytes() []byte { +// Bytes writes a GravityNotifyEvent value to a byte slice. +func (v GravityNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 2 + buf[b] = 24 b += 1 - buf[b] = byte(v.Detail) - b += 1 + b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Root)) - b += 4 - xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put32(buf[b:], uint32(v.Child)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put16(buf[b:], uint16(v.RootX)) + xgb.Put16(buf[b:], uint16(v.X)) b += 2 - xgb.Put16(buf[b:], uint16(v.RootY)) + xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - xgb.Put16(buf[b:], uint16(v.EventX)) - b += 2 + return buf +} - xgb.Put16(buf[b:], uint16(v.EventY)) - b += 2 +// SequenceId returns the sequence id attached to the GravityNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v GravityNotifyEvent) SequenceId() uint16 { + return v.Sequence +} - xgb.Put16(buf[b:], v.State) +// String is a rudimentary string representation of GravityNotifyEvent. +func (v GravityNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + return "GravityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[24] = GravityNotifyEventNew +} + +const ( + GxClear = 0 + GxAnd = 1 + GxAndReverse = 2 + GxCopy = 3 + GxAndInverted = 4 + GxNoop = 5 + GxXor = 6 + GxOr = 7 + GxNor = 8 + GxEquiv = 9 + GxInvert = 10 + GxOrReverse = 11 + GxCopyInverted = 12 + GxOrInverted = 13 + GxNand = 14 + GxSet = 15 +) + +type Host struct { + Family byte + // padding: 1 bytes + AddressLen uint16 + Address []byte // size: xgb.Pad((int(AddressLen) * 1)) +} + +// HostRead reads a byte slice into a Host value. +func HostRead(buf []byte, v *Host) int { + b := 0 + + v.Family = buf[b] + b += 1 + + b += 1 // padding + + v.AddressLen = xgb.Get16(buf[b:]) b += 2 - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 + v.Address = make([]byte, v.AddressLen) + copy(v.Address[:v.AddressLen], buf[b:]) + b += xgb.Pad(int(v.AddressLen)) + + return b +} + +// HostReadList reads a byte slice into a list of Host values. +func HostReadList(buf []byte, dest []Host) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Host{} + b += HostRead(buf[b:], &dest[i]) } + return xgb.Pad(b) +} + +// Bytes writes a Host value to a byte slice. +func (v Host) Bytes() []byte { + buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) + b := 0 + + buf[b] = v.Family b += 1 - b += 1 // padding + b += 1 // padding + + xgb.Put16(buf[b:], v.AddressLen) + b += 2 + + copy(buf[b:], v.Address[:v.AddressLen]) + b += xgb.Pad(int(v.AddressLen)) + + return buf +} + +// HostListBytes writes a list of Host values to a byte slice. +func HostListBytes(buf []byte, list []Host) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// HostListSize computes the size (bytes) of a list of Host values. +func HostListSize(list []Host) int { + size := 0 + for _, item := range list { + size += (4 + xgb.Pad((int(item.AddressLen) * 1))) + } + return size +} + +const ( + HostModeInsert = 0 + HostModeDelete = 1 +) + +// BadIDChoice is the error number for a BadIDChoice. +const BadIDChoice = 14 + +type IDChoiceError ValueError + +// IDChoiceErrorNew constructs a IDChoiceError value that implements xgb.Error from a byte slice. +func IDChoiceErrorNew(buf []byte) xgb.Error { + v := IDChoiceError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "IDChoice" + return v +} + +// SequenceId returns the sequence id attached to the BadIDChoice error. +// This is mostly used internally. +func (err IDChoiceError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadIDChoice error. If no bad value exists, 0 is returned. +func (err IDChoiceError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadIDChoice error. +func (err IDChoiceError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadIDChoice {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[14] = IDChoiceErrorNew +} + +const ( + ImageFormatXYBitmap = 0 + ImageFormatXYPixmap = 1 + ImageFormatZPixmap = 2 +) + +const ( + ImageOrderLSBFirst = 0 + ImageOrderMSBFirst = 1 +) + +// BadImplementation is the error number for a BadImplementation. +const BadImplementation = 17 - return buf +type ImplementationError RequestError + +// ImplementationErrorNew constructs a ImplementationError value that implements xgb.Error from a byte slice. +func ImplementationErrorNew(buf []byte) xgb.Error { + v := ImplementationError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Implementation" + return v } -// SequenceId returns the sequence id attached to the KeyPress event. -// Events without a sequence number (KeymapNotify) return 0. +// SequenceId returns the sequence id attached to the BadImplementation error. // This is mostly used internally. -func (v KeyPressEvent) SequenceId() uint16 { - return v.Sequence +func (err ImplementationError) SequenceId() uint16 { + return err.Sequence } -// String is a rudimentary string representation of KeyPressEvent. -func (v KeyPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// BadId returns the 'BadValue' number if one exists for the BadImplementation error. If no bad value exists, 0 is returned. +func (err ImplementationError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadImplementation error. +func (err ImplementationError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[2] = KeyPressEventNew + xgb.NewErrorFuncs[17] = ImplementationErrorNew } -// ButtonPress is the event number for a ButtonPressEvent. -const ButtonPress = 4 +const ( + InputFocusNone = 0 + InputFocusPointerRoot = 1 + InputFocusParent = 2 + InputFocusFollowKeyboard = 3 +) -type ButtonPressEvent struct { +const ( + JoinStyleMiter = 0 + JoinStyleRound = 1 + JoinStyleBevel = 2 +) + +const ( + KbKeyClickPercent = 1 + KbBellPercent = 2 + KbBellPitch = 4 + KbBellDuration = 8 + KbLed = 16 + KbLedMode = 32 + KbKey = 64 + KbAutoRepeatMode = 128 +) + +const ( + KeyButMaskShift = 1 + KeyButMaskLock = 2 + KeyButMaskControl = 4 + KeyButMaskMod1 = 8 + KeyButMaskMod2 = 16 + KeyButMaskMod3 = 32 + KeyButMaskMod4 = 64 + KeyButMaskMod5 = 128 + KeyButMaskButton1 = 256 + KeyButMaskButton2 = 512 + KeyButMaskButton3 = 1024 + KeyButMaskButton4 = 2048 + KeyButMaskButton5 = 4096 +) + +// KeyPress is the event number for a KeyPressEvent. +const KeyPress = 2 + +type KeyPressEvent struct { Sequence uint16 - Detail Button + Detail Keycode Time Timestamp Root Window Event Window @@ -2819,12 +3231,12 @@ type ButtonPressEvent struct { // padding: 1 bytes } -// ButtonPressEventNew constructs a ButtonPressEvent value that implements xgb.Event from a byte slice. -func ButtonPressEventNew(buf []byte) xgb.Event { - v := ButtonPressEvent{} +// KeyPressEventNew constructs a KeyPressEvent value that implements xgb.Event from a byte slice. +func KeyPressEventNew(buf []byte) xgb.Event { + v := KeyPressEvent{} b := 1 // don't read event number - v.Detail = Button(buf[b]) + v.Detail = Keycode(buf[b]) b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -2869,13 +3281,13 @@ func ButtonPressEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a ButtonPressEvent value to a byte slice. -func (v ButtonPressEvent) Bytes() []byte { +// Bytes writes a KeyPressEvent value to a byte slice. +func (v KeyPressEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 4 + buf[b] = 2 b += 1 buf[b] = byte(v.Detail) @@ -2922,15 +3334,15 @@ func (v ButtonPressEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the ButtonPress event. +// SequenceId returns the sequence id attached to the KeyPress event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ButtonPressEvent) SequenceId() uint16 { +func (v KeyPressEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ButtonPressEvent. -func (v ButtonPressEvent) String() string { +// String is a rudimentary string representation of KeyPressEvent. +func (v KeyPressEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) @@ -2944,144 +3356,36 @@ func (v ButtonPressEvent) String() string { fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "ButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[4] = ButtonPressEventNew -} - -// MotionNotify is the event number for a MotionNotifyEvent. -const MotionNotify = 6 - -type MotionNotifyEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - // padding: 1 bytes + xgb.NewEventFuncs[2] = KeyPressEventNew } -// MotionNotifyEventNew constructs a MotionNotifyEvent value that implements xgb.Event from a byte slice. -func MotionNotifyEventNew(buf []byte) xgb.Event { - v := MotionNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Child = Window(xgb.Get32(buf[b:])) - b += 4 - - v.RootX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.RootY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.EventX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.EventY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.State = xgb.Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 +// KeyRelease is the event number for a KeyReleaseEvent. +const KeyRelease = 3 - b += 1 // padding +type KeyReleaseEvent KeyPressEvent - return v +// KeyReleaseEventNew constructs a KeyReleaseEvent value that implements xgb.Event from a byte slice. +func KeyReleaseEventNew(buf []byte) xgb.Event { + return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) } -// Bytes writes a MotionNotifyEvent value to a byte slice. -func (v MotionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 6 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Root)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Child)) - b += 4 - - xgb.Put16(buf[b:], uint16(v.RootX)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.RootY)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.EventX)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.EventY)) - b += 2 - - xgb.Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf +// Bytes writes a KeyReleaseEvent value to a byte slice. +func (v KeyReleaseEvent) Bytes() []byte { + return KeyPressEvent(v).Bytes() } -// SequenceId returns the sequence id attached to the MotionNotify event. +// SequenceId returns the sequence id attached to the KeyRelease event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v MotionNotifyEvent) SequenceId() uint16 { +func (v KeyReleaseEvent) SequenceId() uint16 { return v.Sequence } - -// String is a rudimentary string representation of MotionNotifyEvent. -func (v MotionNotifyEvent) String() string { + +func (v KeyReleaseEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) @@ -3095,138 +3399,95 @@ func (v MotionNotifyEvent) String() string { fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "MotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[6] = MotionNotifyEventNew + xgb.NewEventFuncs[3] = KeyReleaseEventNew } -// EnterNotify is the event number for a EnterNotifyEvent. -const EnterNotify = 7 +type Keycode byte -type EnterNotifyEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - Mode byte - SameScreenFocus byte +// KeymapNotify is the event number for a KeymapNotifyEvent. +const KeymapNotify = 11 + +type KeymapNotifyEvent struct { + Keys []byte // size: 32 } -// EnterNotifyEventNew constructs a EnterNotifyEvent value that implements xgb.Event from a byte slice. -func EnterNotifyEventNew(buf []byte) xgb.Event { - v := EnterNotifyEvent{} +// KeymapNotifyEventNew constructs a KeymapNotifyEvent value that implements xgb.Event from a byte slice. +func KeymapNotifyEventNew(buf []byte) xgb.Event { + v := KeymapNotifyEvent{} b := 1 // don't read event number - v.Detail = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Child = Window(xgb.Get32(buf[b:])) - b += 4 - - v.RootX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.RootY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.EventX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.EventY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.State = xgb.Get16(buf[b:]) - b += 2 - - v.Mode = buf[b] - b += 1 - - v.SameScreenFocus = buf[b] - b += 1 + v.Keys = make([]byte, 31) + copy(v.Keys[:31], buf[b:]) + b += xgb.Pad(int(31)) return v } -// Bytes writes a EnterNotifyEvent value to a byte slice. -func (v EnterNotifyEvent) Bytes() []byte { +// Bytes writes a KeymapNotifyEvent value to a byte slice. +func (v KeymapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 7 - b += 1 - - buf[b] = v.Detail + buf[b] = 11 b += 1 - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Root)) - b += 4 + copy(buf[b:], v.Keys[:31]) + b += xgb.Pad(int(31)) - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 + return buf +} - xgb.Put32(buf[b:], uint32(v.Child)) - b += 4 +// SequenceId returns the sequence id attached to the KeymapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v KeymapNotifyEvent) SequenceId() uint16 { + return uint16(0) +} - xgb.Put16(buf[b:], uint16(v.RootX)) - b += 2 +// String is a rudimentary string representation of KeymapNotifyEvent. +func (v KeymapNotifyEvent) String() string { + fieldVals := make([]string, 0, 1) + return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - xgb.Put16(buf[b:], uint16(v.RootY)) - b += 2 +func init() { + xgb.NewEventFuncs[11] = KeymapNotifyEventNew +} - xgb.Put16(buf[b:], uint16(v.EventX)) - b += 2 +type Keysym uint32 - xgb.Put16(buf[b:], uint16(v.EventY)) - b += 2 +const ( + KillAllTemporary = 0 +) - xgb.Put16(buf[b:], v.State) - b += 2 +// LeaveNotify is the event number for a LeaveNotifyEvent. +const LeaveNotify = 8 - buf[b] = v.Mode - b += 1 +type LeaveNotifyEvent EnterNotifyEvent - buf[b] = v.SameScreenFocus - b += 1 +// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. +func LeaveNotifyEventNew(buf []byte) xgb.Event { + return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) +} - return buf +// Bytes writes a LeaveNotifyEvent value to a byte slice. +func (v LeaveNotifyEvent) Bytes() []byte { + return EnterNotifyEvent(v).Bytes() } -// SequenceId returns the sequence id attached to the EnterNotify event. +// SequenceId returns the sequence id attached to the LeaveNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v EnterNotifyEvent) SequenceId() uint16 { +func (v LeaveNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of EnterNotifyEvent. -func (v EnterNotifyEvent) String() string { +func (v LeaveNotifyEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) @@ -3241,31 +3502,91 @@ func (v EnterNotifyEvent) String() string { fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) - return "EnterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[7] = EnterNotifyEventNew + xgb.NewEventFuncs[8] = LeaveNotifyEventNew } -// FocusIn is the event number for a FocusInEvent. -const FocusIn = 9 +const ( + LedModeOff = 0 + LedModeOn = 1 +) -type FocusInEvent struct { +// BadLength is the error number for a BadLength. +const BadLength = 16 + +type LengthError RequestError + +// LengthErrorNew constructs a LengthError value that implements xgb.Error from a byte slice. +func LengthErrorNew(buf []byte) xgb.Error { + v := LengthError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Length" + return v +} + +// SequenceId returns the sequence id attached to the BadLength error. +// This is mostly used internally. +func (err LengthError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadLength error. If no bad value exists, 0 is returned. +func (err LengthError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadLength error. +func (err LengthError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadLength {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[16] = LengthErrorNew +} + +const ( + LineStyleSolid = 0 + LineStyleOnOffDash = 1 + LineStyleDoubleDash = 2 +) + +const ( + MapIndexShift = 0 + MapIndexLock = 1 + MapIndexControl = 2 + MapIndex1 = 3 + MapIndex2 = 4 + MapIndex3 = 5 + MapIndex4 = 6 + MapIndex5 = 7 +) + +// MapNotify is the event number for a MapNotifyEvent. +const MapNotify = 19 + +type MapNotifyEvent struct { Sequence uint16 - Detail byte - Event Window - Mode byte + // padding: 1 bytes + Event Window + Window Window + OverrideRedirect bool // padding: 3 bytes } -// FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. -func FocusInEventNew(buf []byte) xgb.Event { - v := FocusInEvent{} +// MapNotifyEventNew constructs a MapNotifyEvent value that implements xgb.Event from a byte slice. +func MapNotifyEventNew(buf []byte) xgb.Event { + v := MapNotifyEvent{} b := 1 // don't read event number - v.Detail = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -3273,7 +3594,14 @@ func FocusInEventNew(buf []byte) xgb.Event { v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.Mode = buf[b] + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } b += 1 b += 3 // padding @@ -3281,24 +3609,30 @@ func FocusInEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a FocusInEvent value to a byte slice. -func (v FocusInEvent) Bytes() []byte { +// Bytes writes a MapNotifyEvent value to a byte slice. +func (v MapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 9 + buf[b] = 19 b += 1 - buf[b] = v.Detail - b += 1 + b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - buf[b] = v.Mode + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 b += 3 // padding @@ -3306,96 +3640,125 @@ func (v FocusInEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the FocusIn event. +// SequenceId returns the sequence id attached to the MapNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v FocusInEvent) SequenceId() uint16 { +func (v MapNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of FocusInEvent. -func (v FocusInEvent) String() string { - fieldVals := make([]string, 0, 4) +// String is a rudimentary string representation of MapNotifyEvent. +func (v MapNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) - return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "MapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[9] = FocusInEventNew + xgb.NewEventFuncs[19] = MapNotifyEventNew } -// KeymapNotify is the event number for a KeymapNotifyEvent. -const KeymapNotify = 11 +// MapRequest is the event number for a MapRequestEvent. +const MapRequest = 20 -type KeymapNotifyEvent struct { - Keys []byte // size: 32 +type MapRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window } -// KeymapNotifyEventNew constructs a KeymapNotifyEvent value that implements xgb.Event from a byte slice. -func KeymapNotifyEventNew(buf []byte) xgb.Event { - v := KeymapNotifyEvent{} +// MapRequestEventNew constructs a MapRequestEvent value that implements xgb.Event from a byte slice. +func MapRequestEventNew(buf []byte) xgb.Event { + v := MapRequestEvent{} b := 1 // don't read event number - v.Keys = make([]byte, 31) - copy(v.Keys[:31], buf[b:]) - b += xgb.Pad(int(31)) + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 return v } -// Bytes writes a KeymapNotifyEvent value to a byte slice. -func (v KeymapNotifyEvent) Bytes() []byte { +// Bytes writes a MapRequestEvent value to a byte slice. +func (v MapRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 11 + buf[b] = 20 b += 1 - copy(buf[b:], v.Keys[:31]) - b += xgb.Pad(int(31)) + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the KeymapNotify event. +// SequenceId returns the sequence id attached to the MapRequest event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v KeymapNotifyEvent) SequenceId() uint16 { - return uint16(0) +func (v MapRequestEvent) SequenceId() uint16 { + return v.Sequence } -// String is a rudimentary string representation of KeymapNotifyEvent. -func (v KeymapNotifyEvent) String() string { - fieldVals := make([]string, 0, 1) - return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// String is a rudimentary string representation of MapRequestEvent. +func (v MapRequestEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "MapRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[11] = KeymapNotifyEventNew + xgb.NewEventFuncs[20] = MapRequestEventNew } -// Expose is the event number for a ExposeEvent. -const Expose = 12 +const ( + MapStateUnmapped = 0 + MapStateUnviewable = 1 + MapStateViewable = 2 +) -type ExposeEvent struct { +const ( + MappingModifier = 0 + MappingKeyboard = 1 + MappingPointer = 2 +) + +// MappingNotify is the event number for a MappingNotifyEvent. +const MappingNotify = 34 + +type MappingNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Window Window - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 - // padding: 2 bytes + Request byte + FirstKeycode Keycode + Count byte + // padding: 1 bytes } -// ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. -func ExposeEventNew(buf []byte) xgb.Event { - v := ExposeEvent{} +// MappingNotifyEventNew constructs a MappingNotifyEvent value that implements xgb.Event from a byte slice. +func MappingNotifyEventNew(buf []byte) xgb.Event { + v := MappingNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -3403,311 +3766,333 @@ func ExposeEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - v.X = xgb.Get16(buf[b:]) - b += 2 - - v.Y = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 + v.Request = buf[b] + b += 1 - v.Height = xgb.Get16(buf[b:]) - b += 2 + v.FirstKeycode = Keycode(buf[b]) + b += 1 - v.Count = xgb.Get16(buf[b:]) - b += 2 + v.Count = buf[b] + b += 1 - b += 2 // padding + b += 1 // padding return v } -// Bytes writes a ExposeEvent value to a byte slice. -func (v ExposeEvent) Bytes() []byte { +// Bytes writes a MappingNotifyEvent value to a byte slice. +func (v MappingNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 12 + buf[b] = 34 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - xgb.Put16(buf[b:], v.X) - b += 2 - - xgb.Put16(buf[b:], v.Y) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 + buf[b] = v.Request + b += 1 - xgb.Put16(buf[b:], v.Height) - b += 2 + buf[b] = byte(v.FirstKeycode) + b += 1 - xgb.Put16(buf[b:], v.Count) - b += 2 + buf[b] = v.Count + b += 1 - b += 2 // padding + b += 1 // padding return buf } -// SequenceId returns the sequence id attached to the Expose event. +// SequenceId returns the sequence id attached to the MappingNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ExposeEvent) SequenceId() uint16 { +func (v MappingNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ExposeEvent. -func (v ExposeEvent) String() string { - fieldVals := make([]string, 0, 8) +// String is a rudimentary string representation of MappingNotifyEvent. +func (v MappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" + return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[12] = ExposeEventNew + xgb.NewEventFuncs[34] = MappingNotifyEventNew +} + +const ( + MappingStatusSuccess = 0 + MappingStatusBusy = 1 + MappingStatusFailure = 2 +) + +// BadMatch is the error number for a BadMatch. +const BadMatch = 8 + +type MatchError RequestError + +// MatchErrorNew constructs a MatchError value that implements xgb.Error from a byte slice. +func MatchErrorNew(buf []byte) xgb.Error { + v := MatchError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Match" + return v +} + +// SequenceId returns the sequence id attached to the BadMatch error. +// This is mostly used internally. +func (err MatchError) SequenceId() uint16 { + return err.Sequence } -// GraphicsExposure is the event number for a GraphicsExposureEvent. -const GraphicsExposure = 13 +// BadId returns the 'BadValue' number if one exists for the BadMatch error. If no bad value exists, 0 is returned. +func (err MatchError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadMatch error. +func (err MatchError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadMatch {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[8] = MatchErrorNew +} + +const ( + ModMaskShift = 1 + ModMaskLock = 2 + ModMaskControl = 4 + ModMask1 = 8 + ModMask2 = 16 + ModMask3 = 32 + ModMask4 = 64 + ModMask5 = 128 + ModMaskAny = 32768 +) + +const ( + MotionNormal = 0 + MotionHint = 1 +) -type GraphicsExposureEvent struct { - Sequence uint16 +// MotionNotify is the event number for a MotionNotifyEvent. +const MotionNotify = 6 + +type MotionNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool // padding: 1 bytes - Drawable Drawable - X uint16 - Y uint16 - Width uint16 - Height uint16 - MinorOpcode uint16 - Count uint16 - MajorOpcode byte - // padding: 3 bytes } -// GraphicsExposureEventNew constructs a GraphicsExposureEvent value that implements xgb.Event from a byte slice. -func GraphicsExposureEventNew(buf []byte) xgb.Event { - v := GraphicsExposureEvent{} +// MotionNotifyEventNew constructs a MotionNotifyEvent value that implements xgb.Event from a byte slice. +func MotionNotifyEventNew(buf []byte) xgb.Event { + v := MotionNotifyEvent{} b := 1 // don't read event number - b += 1 // padding + v.Detail = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Drawable = Drawable(xgb.Get32(buf[b:])) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.X = xgb.Get16(buf[b:]) - b += 2 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - v.Y = xgb.Get16(buf[b:]) + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - v.Width = xgb.Get16(buf[b:]) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - v.Height = xgb.Get16(buf[b:]) + v.EventX = int16(xgb.Get16(buf[b:])) b += 2 - v.MinorOpcode = xgb.Get16(buf[b:]) + v.EventY = int16(xgb.Get16(buf[b:])) b += 2 - v.Count = xgb.Get16(buf[b:]) + v.State = xgb.Get16(buf[b:]) b += 2 - v.MajorOpcode = buf[b] + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } b += 1 - b += 3 // padding + b += 1 // padding return v } -// Bytes writes a GraphicsExposureEvent value to a byte slice. -func (v GraphicsExposureEvent) Bytes() []byte { +// Bytes writes a MotionNotifyEvent value to a byte slice. +func (v MotionNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 13 + buf[b] = 6 b += 1 - b += 1 // padding + buf[b] = v.Detail + b += 1 b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Drawable)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put16(buf[b:], v.X) - b += 2 + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 - xgb.Put16(buf[b:], v.Y) + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) b += 2 - xgb.Put16(buf[b:], v.Width) + xgb.Put16(buf[b:], uint16(v.RootY)) b += 2 - xgb.Put16(buf[b:], v.Height) + xgb.Put16(buf[b:], uint16(v.EventX)) b += 2 - xgb.Put16(buf[b:], v.MinorOpcode) + xgb.Put16(buf[b:], uint16(v.EventY)) b += 2 - xgb.Put16(buf[b:], v.Count) + xgb.Put16(buf[b:], v.State) b += 2 - buf[b] = v.MajorOpcode + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - b += 3 // padding + b += 1 // padding return buf } -// SequenceId returns the sequence id attached to the GraphicsExposure event. +// SequenceId returns the sequence id attached to the MotionNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v GraphicsExposureEvent) SequenceId() uint16 { +func (v MotionNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of GraphicsExposureEvent. -func (v GraphicsExposureEvent) String() string { - fieldVals := make([]string, 0, 10) +// String is a rudimentary string representation of MotionNotifyEvent. +func (v MotionNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "GraphicsExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "MotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[13] = GraphicsExposureEventNew -} - -// NoExposure is the event number for a NoExposureEvent. -const NoExposure = 14 - -type NoExposureEvent struct { - Sequence uint16 - // padding: 1 bytes - Drawable Drawable - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes + xgb.NewEventFuncs[6] = MotionNotifyEventNew } -// NoExposureEventNew constructs a NoExposureEvent value that implements xgb.Event from a byte slice. -func NoExposureEventNew(buf []byte) xgb.Event { - v := NoExposureEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(xgb.Get32(buf[b:])) - b += 4 - - v.MinorOpcode = xgb.Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 +// BadName is the error number for a BadName. +const BadName = 15 - b += 1 // padding +type NameError RequestError +// NameErrorNew constructs a NameError value that implements xgb.Error from a byte slice. +func NameErrorNew(buf []byte) xgb.Error { + v := NameError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Name" return v } -// Bytes writes a NoExposureEvent value to a byte slice. -func (v NoExposureEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 14 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - xgb.Put16(buf[b:], v.MinorOpcode) - b += 2 - - buf[b] = v.MajorOpcode - b += 1 - - b += 1 // padding - - return buf +// SequenceId returns the sequence id attached to the BadName error. +// This is mostly used internally. +func (err NameError) SequenceId() uint16 { + return err.Sequence } -// SequenceId returns the sequence id attached to the NoExposure event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v NoExposureEvent) SequenceId() uint16 { - return v.Sequence +// BadId returns the 'BadValue' number if one exists for the BadName error. If no bad value exists, 0 is returned. +func (err NameError) BadId() uint32 { + return err.BadValue } -// String is a rudimentary string representation of NoExposureEvent. -func (v NoExposureEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// Error returns a rudimentary string representation of the BadName error. +func (err NameError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadName {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[14] = NoExposureEventNew + xgb.NewErrorFuncs[15] = NameErrorNew } -// VisibilityNotify is the event number for a VisibilityNotifyEvent. -const VisibilityNotify = 15 +// NoExposure is the event number for a NoExposureEvent. +const NoExposure = 14 -type VisibilityNotifyEvent struct { +type NoExposureEvent struct { Sequence uint16 // padding: 1 bytes - Window Window - State byte - // padding: 3 bytes -} - -// VisibilityNotifyEventNew constructs a VisibilityNotifyEvent value that implements xgb.Event from a byte slice. -func VisibilityNotifyEventNew(buf []byte) xgb.Event { - v := VisibilityNotifyEvent{} + Drawable Drawable + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// NoExposureEventNew constructs a NoExposureEvent value that implements xgb.Event from a byte slice. +func NoExposureEventNew(buf []byte) xgb.Event { + v := NoExposureEvent{} b := 1 // don't read event number b += 1 // padding @@ -3715,139 +4100,175 @@ func VisibilityNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) + v.Drawable = Drawable(xgb.Get32(buf[b:])) b += 4 - v.State = buf[b] + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] b += 1 - b += 3 // padding + b += 1 // padding return v } -// Bytes writes a VisibilityNotifyEvent value to a byte slice. -func (v VisibilityNotifyEvent) Bytes() []byte { +// Bytes writes a NoExposureEvent value to a byte slice. +func (v NoExposureEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 15 + buf[b] = 14 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Drawable)) b += 4 - buf[b] = v.State + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + buf[b] = v.MajorOpcode b += 1 - b += 3 // padding + b += 1 // padding return buf } -// SequenceId returns the sequence id attached to the VisibilityNotify event. +// SequenceId returns the sequence id attached to the NoExposure event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v VisibilityNotifyEvent) SequenceId() uint16 { +func (v NoExposureEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of VisibilityNotifyEvent. -func (v VisibilityNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) +// String is a rudimentary string representation of NoExposureEvent. +func (v NoExposureEvent) String() string { + fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[15] = VisibilityNotifyEventNew + xgb.NewEventFuncs[14] = NoExposureEventNew } -// CreateNotify is the event number for a CreateNotifyEvent. -const CreateNotify = 16 - -type CreateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - OverrideRedirect bool - // padding: 1 bytes -} +const ( + NotifyDetailAncestor = 0 + NotifyDetailVirtual = 1 + NotifyDetailInferior = 2 + NotifyDetailNonlinear = 3 + NotifyDetailNonlinearVirtual = 4 + NotifyDetailPointer = 5 + NotifyDetailPointerRoot = 6 + NotifyDetailNone = 7 +) -// CreateNotifyEventNew constructs a CreateNotifyEvent value that implements xgb.Event from a byte slice. -func CreateNotifyEventNew(buf []byte) xgb.Event { - v := CreateNotifyEvent{} - b := 1 // don't read event number +const ( + NotifyModeNormal = 0 + NotifyModeGrab = 1 + NotifyModeUngrab = 2 + NotifyModeWhileGrabbed = 3 +) - b += 1 // padding +type Pixmap uint32 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil +} - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 +// BadPixmap is the error number for a BadPixmap. +const BadPixmap = 4 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 +type PixmapError ValueError - v.X = int16(xgb.Get16(buf[b:])) - b += 2 +// PixmapErrorNew constructs a PixmapError value that implements xgb.Error from a byte slice. +func PixmapErrorNew(buf []byte) xgb.Error { + v := PixmapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Pixmap" + return v +} - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 +// SequenceId returns the sequence id attached to the BadPixmap error. +// This is mostly used internally. +func (err PixmapError) SequenceId() uint16 { + return err.Sequence +} - v.Width = xgb.Get16(buf[b:]) - b += 2 +// BadId returns the 'BadValue' number if one exists for the BadPixmap error. If no bad value exists, 0 is returned. +func (err PixmapError) BadId() uint32 { + return err.BadValue +} - v.Height = xgb.Get16(buf[b:]) - b += 2 +// Error returns a rudimentary string representation of the BadPixmap error. +func (err PixmapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} - v.BorderWidth = xgb.Get16(buf[b:]) - b += 2 +func init() { + xgb.NewErrorFuncs[4] = PixmapErrorNew +} - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 +const ( + PixmapNone = 0 +) - b += 1 // padding +const ( + PlaceOnTop = 0 + PlaceOnBottom = 1 +) - return v +type Point struct { + X int16 + Y int16 } -// Bytes writes a CreateNotifyEvent value to a byte slice. -func (v CreateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// PointRead reads a byte slice into a Point value. +func PointRead(buf []byte, v *Point) int { b := 0 - // write event number - buf[b] = 16 - b += 1 + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - b += 1 // padding + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - b += 2 // skip sequence number + return b +} - xgb.Put32(buf[b:], uint32(v.Parent)) - b += 4 +// PointReadList reads a byte slice into a list of Point values. +func PointReadList(buf []byte, dest []Point) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Point{} + b += PointRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 +// Bytes writes a Point value to a byte slice. +func (v Point) Bytes() []byte { + buf := make([]byte, 4) + b := 0 xgb.Put16(buf[b:], uint16(v.X)) b += 2 @@ -3855,66 +4276,54 @@ func (v CreateNotifyEvent) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], v.BorderWidth) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - return buf } -// SequenceId returns the sequence id attached to the CreateNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v CreateNotifyEvent) SequenceId() uint16 { - return v.Sequence +// PointListBytes writes a list of Point values to a byte slice. +func PointListBytes(buf []byte, list []Point) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of CreateNotifyEvent. -func (v CreateNotifyEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +const ( + PolyShapeComplex = 0 + PolyShapeNonconvex = 1 + PolyShapeConvex = 2 +) -func init() { - xgb.NewEventFuncs[16] = CreateNotifyEventNew -} +const ( + PropModeReplace = 0 + PropModePrepend = 1 + PropModeAppend = 2 +) + +const ( + PropertyNewValue = 0 + PropertyDelete = 1 +) -// DestroyNotify is the event number for a DestroyNotifyEvent. -const DestroyNotify = 17 +// PropertyNotify is the event number for a PropertyNotifyEvent. +const PropertyNotify = 28 -type DestroyNotifyEvent struct { +type PropertyNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Event Window Window Window + Atom Atom + Time Timestamp + State byte + // padding: 3 bytes } -// DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. -func DestroyNotifyEventNew(buf []byte) xgb.Event { - v := DestroyNotifyEvent{} +// PropertyNotifyEventNew constructs a PropertyNotifyEvent value that implements xgb.Event from a byte slice. +func PropertyNotifyEventNew(buf []byte) xgb.Event { + v := PropertyNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -3922,72 +4331,167 @@ func DestroyNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 + v.State = buf[b] + b += 1 + + b += 3 // padding + return v } -// Bytes writes a DestroyNotifyEvent value to a byte slice. -func (v DestroyNotifyEvent) Bytes() []byte { +// Bytes writes a PropertyNotifyEvent value to a byte slice. +func (v PropertyNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 17 + buf[b] = 28 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Atom)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 + buf[b] = v.State + b += 1 + + b += 3 // padding + return buf } -// SequenceId returns the sequence id attached to the DestroyNotify event. +// SequenceId returns the sequence id attached to the PropertyNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v DestroyNotifyEvent) SequenceId() uint16 { +func (v PropertyNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of DestroyNotifyEvent. -func (v DestroyNotifyEvent) String() string { - fieldVals := make([]string, 0, 3) +// String is a rudimentary string representation of PropertyNotifyEvent. +func (v PropertyNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Atom: %d", v.Atom)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "PropertyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[17] = DestroyNotifyEventNew + xgb.NewEventFuncs[28] = PropertyNotifyEventNew } -// UnmapNotify is the event number for a UnmapNotifyEvent. -const UnmapNotify = 18 +const ( + QueryShapeOfLargestCursor = 0 + QueryShapeOfFastestTile = 1 + QueryShapeOfFastestStipple = 2 +) -type UnmapNotifyEvent struct { +type Rectangle struct { + X int16 + Y int16 + Width uint16 + Height uint16 +} + +// RectangleRead reads a byte slice into a Rectangle value. +func RectangleRead(buf []byte, v *Rectangle) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// RectangleReadList reads a byte slice into a list of Rectangle values. +func RectangleReadList(buf []byte, dest []Rectangle) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rectangle{} + b += RectangleRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Rectangle value to a byte slice. +func (v Rectangle) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +// RectangleListBytes writes a list of Rectangle values to a byte slice. +func RectangleListBytes(buf []byte, list []Rectangle) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// ReparentNotify is the event number for a ReparentNotifyEvent. +const ReparentNotify = 21 + +type ReparentNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - FromConfigure bool + Event Window + Window Window + Parent Window + X int16 + Y int16 + OverrideRedirect bool // padding: 3 bytes } -// UnmapNotifyEventNew constructs a UnmapNotifyEvent value that implements xgb.Event from a byte slice. -func UnmapNotifyEventNew(buf []byte) xgb.Event { - v := UnmapNotifyEvent{} +// ReparentNotifyEventNew constructs a ReparentNotifyEvent value that implements xgb.Event from a byte slice. +func ReparentNotifyEventNew(buf []byte) xgb.Event { + v := ReparentNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -4001,10 +4505,19 @@ func UnmapNotifyEventNew(buf []byte) xgb.Event { v.Window = Window(xgb.Get32(buf[b:])) b += 4 + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + if buf[b] == 1 { - v.FromConfigure = true + v.OverrideRedirect = true } else { - v.FromConfigure = false + v.OverrideRedirect = false } b += 1 @@ -4013,13 +4526,13 @@ func UnmapNotifyEventNew(buf []byte) xgb.Event { return v } -// Bytes writes a UnmapNotifyEvent value to a byte slice. -func (v UnmapNotifyEvent) Bytes() []byte { +// Bytes writes a ReparentNotifyEvent value to a byte slice. +func (v ReparentNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 18 + buf[b] = 21 b += 1 b += 1 // padding @@ -4032,7 +4545,16 @@ func (v UnmapNotifyEvent) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - if v.FromConfigure { + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + if v.OverrideRedirect { buf[b] = 1 } else { buf[b] = 0 @@ -4044,42 +4566,108 @@ func (v UnmapNotifyEvent) Bytes() []byte { return buf } -// SequenceId returns the sequence id attached to the UnmapNotify event. +// SequenceId returns the sequence id attached to the ReparentNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v UnmapNotifyEvent) SequenceId() uint16 { +func (v ReparentNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of UnmapNotifyEvent. -func (v UnmapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) +// String is a rudimentary string representation of ReparentNotifyEvent. +func (v ReparentNotifyEvent) String() string { + fieldVals := make([]string, 0, 8) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) - return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "ReparentNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[21] = ReparentNotifyEventNew +} + +// BadRequest is the error number for a BadRequest. +const BadRequest = 1 + +type RequestError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// RequestErrorNew constructs a RequestError value that implements xgb.Error from a byte slice. +func RequestErrorNew(buf []byte) xgb.Error { + v := RequestError{} + v.NiceName = "Request" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// SequenceId returns the sequence id attached to the BadRequest error. +// This is mostly used internally. +func (err RequestError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadRequest error. If no bad value exists, 0 is returned. +func (err RequestError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadRequest error. + +func (err RequestError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[18] = UnmapNotifyEventNew + xgb.NewErrorFuncs[1] = RequestErrorNew } -// MapNotify is the event number for a MapNotifyEvent. -const MapNotify = 19 +// ResizeRequest is the event number for a ResizeRequestEvent. +const ResizeRequest = 25 -type MapNotifyEvent struct { +type ResizeRequestEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - OverrideRedirect bool - // padding: 3 bytes + Window Window + Width uint16 + Height uint16 } -// MapNotifyEventNew constructs a MapNotifyEvent value that implements xgb.Event from a byte slice. -func MapNotifyEventNew(buf []byte) xgb.Event { - v := MapNotifyEvent{} +// ResizeRequestEventNew constructs a ResizeRequestEvent value that implements xgb.Event from a byte slice. +func ResizeRequestEventNew(buf []byte) xgb.Event { + v := ResizeRequestEvent{} b := 1 // don't read event number b += 1 // padding @@ -4087,548 +4675,569 @@ func MapNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - v.Window = Window(xgb.Get32(buf[b:])) b += 4 - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - b += 3 // padding + v.Height = xgb.Get16(buf[b:]) + b += 2 return v } -// Bytes writes a MapNotifyEvent value to a byte slice. -func (v MapNotifyEvent) Bytes() []byte { +// Bytes writes a ResizeRequestEvent value to a byte slice. +func (v ResizeRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 19 + buf[b] = 25 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + xgb.Put16(buf[b:], v.Width) + b += 2 - b += 3 // padding + xgb.Put16(buf[b:], v.Height) + b += 2 return buf } -// SequenceId returns the sequence id attached to the MapNotify event. +// SequenceId returns the sequence id attached to the ResizeRequest event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v MapNotifyEvent) SequenceId() uint16 { +func (v ResizeRequestEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of MapNotifyEvent. -func (v MapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) +// String is a rudimentary string representation of ResizeRequestEvent. +func (v ResizeRequestEvent) String() string { + fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "MapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + return "ResizeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[19] = MapNotifyEventNew + xgb.NewEventFuncs[25] = ResizeRequestEventNew } -// MapRequest is the event number for a MapRequestEvent. -const MapRequest = 20 - -type MapRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window +type Rgb struct { + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes } -// MapRequestEventNew constructs a MapRequestEvent value that implements xgb.Event from a byte slice. -func MapRequestEventNew(buf []byte) xgb.Event { - v := MapRequestEvent{} - b := 1 // don't read event number +// RgbRead reads a byte slice into a Rgb value. +func RgbRead(buf []byte, v *Rgb) int { + b := 0 - b += 1 // padding + v.Red = xgb.Get16(buf[b:]) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Green = xgb.Get16(buf[b:]) b += 2 - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 + v.Blue = xgb.Get16(buf[b:]) + b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 + b += 2 // padding - return v + return b } -// Bytes writes a MapRequestEvent value to a byte slice. -func (v MapRequestEvent) Bytes() []byte { - buf := make([]byte, 32) +// RgbReadList reads a byte slice into a list of Rgb values. +func RgbReadList(buf []byte, dest []Rgb) int { b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rgb{} + b += RgbRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - // write event number - buf[b] = 20 - b += 1 +// Bytes writes a Rgb value to a byte slice. +func (v Rgb) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - b += 1 // padding + xgb.Put16(buf[b:], v.Red) + b += 2 - b += 2 // skip sequence number + xgb.Put16(buf[b:], v.Green) + b += 2 - xgb.Put32(buf[b:], uint32(v.Parent)) - b += 4 + xgb.Put16(buf[b:], v.Blue) + b += 2 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + b += 2 // padding return buf } -// SequenceId returns the sequence id attached to the MapRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v MapRequestEvent) SequenceId() uint16 { - return v.Sequence +// RgbListBytes writes a list of Rgb values to a byte slice. +func RgbListBytes(buf []byte, list []Rgb) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of MapRequestEvent. -func (v MapRequestEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - return "MapRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +type ScreenInfo struct { + Root Window + DefaultColormap Colormap + WhitePixel uint32 + BlackPixel uint32 + CurrentInputMasks uint32 + WidthInPixels uint16 + HeightInPixels uint16 + WidthInMillimeters uint16 + HeightInMillimeters uint16 + MinInstalledMaps uint16 + MaxInstalledMaps uint16 + RootVisual Visualid + BackingStores byte + SaveUnders bool + RootDepth byte + AllowedDepthsLen byte + AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) } -func init() { - xgb.NewEventFuncs[20] = MapRequestEventNew -} +// ScreenInfoRead reads a byte slice into a ScreenInfo value. +func ScreenInfoRead(buf []byte, v *ScreenInfo) int { + b := 0 -// ReparentNotify is the event number for a ReparentNotifyEvent. -const ReparentNotify = 21 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 -type ReparentNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - Parent Window - X int16 - Y int16 - OverrideRedirect bool - // padding: 3 bytes -} + v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) + b += 4 -// ReparentNotifyEventNew constructs a ReparentNotifyEvent value that implements xgb.Event from a byte slice. -func ReparentNotifyEventNew(buf []byte) xgb.Event { - v := ReparentNotifyEvent{} - b := 1 // don't read event number + v.WhitePixel = xgb.Get32(buf[b:]) + b += 4 - b += 1 // padding + v.BlackPixel = xgb.Get32(buf[b:]) + b += 4 - v.Sequence = xgb.Get16(buf[b:]) + v.CurrentInputMasks = xgb.Get32(buf[b:]) + b += 4 + + v.WidthInPixels = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 + v.HeightInPixels = xgb.Get16(buf[b:]) + b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 + v.WidthInMillimeters = xgb.Get16(buf[b:]) + b += 2 - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 + v.HeightInMillimeters = xgb.Get16(buf[b:]) + b += 2 - v.X = int16(xgb.Get16(buf[b:])) + v.MinInstalledMaps = xgb.Get16(buf[b:]) b += 2 - v.Y = int16(xgb.Get16(buf[b:])) + v.MaxInstalledMaps = xgb.Get16(buf[b:]) b += 2 + v.RootVisual = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.BackingStores = buf[b] + b += 1 + if buf[b] == 1 { - v.OverrideRedirect = true + v.SaveUnders = true } else { - v.OverrideRedirect = false + v.SaveUnders = false } b += 1 - b += 3 // padding + v.RootDepth = buf[b] + b += 1 - return v + v.AllowedDepthsLen = buf[b] + b += 1 + + v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) + b += DepthInfoReadList(buf[b:], v.AllowedDepths) + + return b } -// Bytes writes a ReparentNotifyEvent value to a byte slice. -func (v ReparentNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values. +func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenInfo{} + b += ScreenInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - // write event number - buf[b] = 21 - b += 1 +// Bytes writes a ScreenInfo value to a byte slice. +func (v ScreenInfo) Bytes() []byte { + buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) + b := 0 - b += 1 // padding + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 - b += 2 // skip sequence number + xgb.Put32(buf[b:], uint32(v.DefaultColormap)) + b += 4 - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], v.WhitePixel) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], v.BlackPixel) b += 4 - xgb.Put32(buf[b:], uint32(v.Parent)) + xgb.Put32(buf[b:], v.CurrentInputMasks) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) + xgb.Put16(buf[b:], v.WidthInPixels) b += 2 - xgb.Put16(buf[b:], uint16(v.Y)) + xgb.Put16(buf[b:], v.HeightInPixels) b += 2 - if v.OverrideRedirect { + xgb.Put16(buf[b:], v.WidthInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.HeightInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.MinInstalledMaps) + b += 2 + + xgb.Put16(buf[b:], v.MaxInstalledMaps) + b += 2 + + xgb.Put32(buf[b:], uint32(v.RootVisual)) + b += 4 + + buf[b] = v.BackingStores + b += 1 + + if v.SaveUnders { buf[b] = 1 } else { buf[b] = 0 } b += 1 - b += 3 // padding + buf[b] = v.RootDepth + b += 1 + + buf[b] = v.AllowedDepthsLen + b += 1 + + b += DepthInfoListBytes(buf[b:], v.AllowedDepths) return buf } -// SequenceId returns the sequence id attached to the ReparentNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ReparentNotifyEvent) SequenceId() uint16 { - return v.Sequence +// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. +func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of ReparentNotifyEvent. -func (v ReparentNotifyEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ReparentNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ScreenInfoListSize computes the size (bytes) of a list of ScreenInfo values. +func ScreenInfoListSize(list []ScreenInfo) int { + size := 0 + for _, item := range list { + size += (40 + DepthInfoListSize(item.AllowedDepths)) + } + return size } -func init() { - xgb.NewEventFuncs[21] = ReparentNotifyEventNew +const ( + ScreenSaverReset = 0 + ScreenSaverActive = 1 +) + +type Segment struct { + X1 int16 + Y1 int16 + X2 int16 + Y2 int16 } -// ConfigureNotify is the event number for a ConfigureNotifyEvent. -const ConfigureNotify = 22 +// SegmentRead reads a byte slice into a Segment value. +func SegmentRead(buf []byte, v *Segment) int { + b := 0 -type ConfigureNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - AboveSibling Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - OverrideRedirect bool - // padding: 1 bytes -} + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 -// ConfigureNotifyEventNew constructs a ConfigureNotifyEvent value that implements xgb.Event from a byte slice. -func ConfigureNotifyEventNew(buf []byte) xgb.Event { - v := ConfigureNotifyEvent{} - b := 1 // don't read event number + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 - b += 1 // padding + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Y2 = int16(xgb.Get16(buf[b:])) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 + return b +} - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 +// SegmentReadList reads a byte slice into a list of Segment values. +func SegmentReadList(buf []byte, dest []Segment) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Segment{} + b += SegmentRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - v.AboveSibling = Window(xgb.Get32(buf[b:])) - b += 4 +// Bytes writes a Segment value to a byte slice. +func (v Segment) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - v.X = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(v.X1)) b += 2 - v.Y = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(v.Y1)) b += 2 - v.Width = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(v.X2)) b += 2 - v.Height = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(v.Y2)) b += 2 - v.BorderWidth = xgb.Get16(buf[b:]) - b += 2 + return buf +} - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false +// SegmentListBytes writes a list of Segment values to a byte slice. +func SegmentListBytes(buf []byte, list []Segment) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } - b += 1 + return b +} - b += 1 // padding +// SelectionClear is the event number for a SelectionClearEvent. +const SelectionClear = 29 - return v +type SelectionClearEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Owner Window + Selection Atom } -// Bytes writes a ConfigureNotifyEvent value to a byte slice. -func (v ConfigureNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 22 - b += 1 +// SelectionClearEventNew constructs a SelectionClearEvent value that implements xgb.Event from a byte slice. +func SelectionClearEventNew(buf []byte) xgb.Event { + v := SelectionClearEvent{} + b := 1 // don't read event number b += 1 // padding - b += 2 // skip sequence number + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(v.Event)) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + v.Owner = Window(xgb.Get32(buf[b:])) b += 4 - xgb.Put32(buf[b:], uint32(v.AboveSibling)) + v.Selection = Atom(xgb.Get32(buf[b:])) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + return v +} - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 +// Bytes writes a SelectionClearEvent value to a byte slice. +func (v SelectionClearEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 - xgb.Put16(buf[b:], v.Width) - b += 2 + // write event number + buf[b] = 29 + b += 1 - xgb.Put16(buf[b:], v.Height) - b += 2 + b += 1 // padding - xgb.Put16(buf[b:], v.BorderWidth) - b += 2 + b += 2 // skip sequence number - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 - b += 1 // padding + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the ConfigureNotify event. +// SequenceId returns the sequence id attached to the SelectionClear event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ConfigureNotifyEvent) SequenceId() uint16 { +func (v SelectionClearEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ConfigureNotifyEvent. -func (v ConfigureNotifyEvent) String() string { - fieldVals := make([]string, 0, 11) +// String is a rudimentary string representation of SelectionClearEvent. +func (v SelectionClearEvent) String() string { + fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("AboveSibling: %d", v.AboveSibling)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ConfigureNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + return "SelectionClear {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[22] = ConfigureNotifyEventNew + xgb.NewEventFuncs[29] = SelectionClearEventNew } -// ConfigureRequest is the event number for a ConfigureRequestEvent. -const ConfigureRequest = 23 +// SelectionNotify is the event number for a SelectionNotifyEvent. +const SelectionNotify = 31 -type ConfigureRequestEvent struct { - Sequence uint16 - StackMode byte - Parent Window - Window Window - Sibling Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - ValueMask uint16 +type SelectionNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Requestor Window + Selection Atom + Target Atom + Property Atom } -// ConfigureRequestEventNew constructs a ConfigureRequestEvent value that implements xgb.Event from a byte slice. -func ConfigureRequestEventNew(buf []byte) xgb.Event { - v := ConfigureRequestEvent{} +// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. +func SelectionNotifyEventNew(buf []byte) xgb.Event { + v := SelectionNotifyEvent{} b := 1 // don't read event number - v.StackMode = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Parent = Window(xgb.Get32(buf[b:])) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + v.Requestor = Window(xgb.Get32(buf[b:])) b += 4 - v.Sibling = Window(xgb.Get32(buf[b:])) + v.Selection = Atom(xgb.Get32(buf[b:])) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - v.BorderWidth = xgb.Get16(buf[b:]) - b += 2 + v.Target = Atom(xgb.Get32(buf[b:])) + b += 4 - v.ValueMask = xgb.Get16(buf[b:]) - b += 2 + v.Property = Atom(xgb.Get32(buf[b:])) + b += 4 return v } -// Bytes writes a ConfigureRequestEvent value to a byte slice. -func (v ConfigureRequestEvent) Bytes() []byte { +// Bytes writes a SelectionNotifyEvent value to a byte slice. +func (v SelectionNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 23 + buf[b] = 31 b += 1 - buf[b] = v.StackMode - b += 1 + b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Parent)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Requestor)) b += 4 - xgb.Put32(buf[b:], uint32(v.Sibling)) + xgb.Put32(buf[b:], uint32(v.Selection)) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 - - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 - - xgb.Put16(buf[b:], v.Width) - b += 2 - - xgb.Put16(buf[b:], v.Height) - b += 2 - - xgb.Put16(buf[b:], v.BorderWidth) - b += 2 + xgb.Put32(buf[b:], uint32(v.Target)) + b += 4 - xgb.Put16(buf[b:], v.ValueMask) - b += 2 + xgb.Put32(buf[b:], uint32(v.Property)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the ConfigureRequest event. +// SequenceId returns the sequence id attached to the SelectionNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ConfigureRequestEvent) SequenceId() uint16 { +func (v SelectionNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ConfigureRequestEvent. -func (v ConfigureRequestEvent) String() string { - fieldVals := make([]string, 0, 10) +// String is a rudimentary string representation of SelectionNotifyEvent. +func (v SelectionNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("StackMode: %d", v.StackMode)) - fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Sibling: %d", v.Sibling)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, xgb.Sprintf("ValueMask: %d", v.ValueMask)) - return "ConfigureRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) + fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) + return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[23] = ConfigureRequestEventNew + xgb.NewEventFuncs[31] = SelectionNotifyEventNew } -// GravityNotify is the event number for a GravityNotifyEvent. -const GravityNotify = 24 +// SelectionRequest is the event number for a SelectionRequestEvent. +const SelectionRequest = 30 -type GravityNotifyEvent struct { +type SelectionRequestEvent struct { Sequence uint16 // padding: 1 bytes - Event Window - Window Window - X int16 - Y int16 + Time Timestamp + Owner Window + Requestor Window + Selection Atom + Target Atom + Property Atom } -// GravityNotifyEventNew constructs a GravityNotifyEvent value that implements xgb.Event from a byte slice. -func GravityNotifyEventNew(buf []byte) xgb.Event { - v := GravityNotifyEvent{} +// SelectionRequestEventNew constructs a SelectionRequestEvent value that implements xgb.Event from a byte slice. +func SelectionRequestEventNew(buf []byte) xgb.Event { + v := SelectionRequestEvent{} b := 1 // don't read event number b += 1 // padding @@ -4636,624 +5245,755 @@ func GravityNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) + v.Time = Timestamp(xgb.Get32(buf[b:])) b += 4 - v.Window = Window(xgb.Get32(buf[b:])) + v.Owner = Window(xgb.Get32(buf[b:])) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 + v.Requestor = Window(xgb.Get32(buf[b:])) + b += 4 - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + v.Selection = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Target = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Property = Atom(xgb.Get32(buf[b:])) + b += 4 return v } -// Bytes writes a GravityNotifyEvent value to a byte slice. -func (v GravityNotifyEvent) Bytes() []byte { +// Bytes writes a SelectionRequestEvent value to a byte slice. +func (v SelectionRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 24 + buf[b] = 30 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Event)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Owner)) b += 4 - xgb.Put16(buf[b:], uint16(v.X)) - b += 2 + xgb.Put32(buf[b:], uint32(v.Requestor)) + b += 4 - xgb.Put16(buf[b:], uint16(v.Y)) - b += 2 + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Property)) + b += 4 return buf } -// SequenceId returns the sequence id attached to the GravityNotify event. +// SequenceId returns the sequence id attached to the SelectionRequest event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v GravityNotifyEvent) SequenceId() uint16 { +func (v SelectionRequestEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of GravityNotifyEvent. -func (v GravityNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) +// String is a rudimentary string representation of SelectionRequestEvent. +func (v SelectionRequestEvent) String() string { + fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) - return "GravityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) + fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) + return "SelectionRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[24] = GravityNotifyEventNew -} - -// ResizeRequest is the event number for a ResizeRequestEvent. -const ResizeRequest = 25 - -type ResizeRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Width uint16 - Height uint16 + xgb.NewEventFuncs[30] = SelectionRequestEventNew } -// ResizeRequestEventNew constructs a ResizeRequestEvent value that implements xgb.Event from a byte slice. -func ResizeRequestEventNew(buf []byte) xgb.Event { - v := ResizeRequestEvent{} - b := 1 // don't read event number +const ( + SendEventDestPointerWindow = 0 + SendEventDestItemFocus = 1 +) - b += 1 // padding +const ( + SetModeInsert = 0 + SetModeDelete = 1 +) - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +type SetupAuthenticate struct { + Status byte + // padding: 5 bytes + Length uint16 + Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) +} - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 +// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. +func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { + b := 0 - v.Width = xgb.Get16(buf[b:]) - b += 2 + v.Status = buf[b] + b += 1 - v.Height = xgb.Get16(buf[b:]) + b += 5 // padding + + v.Length = xgb.Get16(buf[b:]) b += 2 - return v + { + byteString := make([]byte, (int(v.Length) * 4)) + copy(byteString[:(int(v.Length)*4)], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int((int(v.Length) * 4))) + } + + return b } -// Bytes writes a ResizeRequestEvent value to a byte slice. -func (v ResizeRequestEvent) Bytes() []byte { - buf := make([]byte, 32) +// SetupAuthenticateReadList reads a byte slice into a list of SetupAuthenticate values. +func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupAuthenticate{} + b += SetupAuthenticateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - // write event number - buf[b] = 25 - b += 1 - - b += 1 // padding +// Bytes writes a SetupAuthenticate value to a byte slice. +func (v SetupAuthenticate) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) + b := 0 - b += 2 // skip sequence number + buf[b] = v.Status + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + b += 5 // padding - xgb.Put16(buf[b:], v.Width) + xgb.Put16(buf[b:], v.Length) b += 2 - xgb.Put16(buf[b:], v.Height) - b += 2 + copy(buf[b:], v.Reason[:(int(v.Length)*4)]) + b += xgb.Pad(int((int(v.Length) * 4))) return buf } -// SequenceId returns the sequence id attached to the ResizeRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ResizeRequestEvent) SequenceId() uint16 { - return v.Sequence +// SetupAuthenticateListBytes writes a list of SetupAuthenticate values to a byte slice. +func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of ResizeRequestEvent. -func (v ResizeRequestEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) - return "ResizeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// SetupAuthenticateListSize computes the size (bytes) of a list of SetupAuthenticate values. +func SetupAuthenticateListSize(list []SetupAuthenticate) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad(((int(item.Length) * 4) * 1))) + } + return size } -func init() { - xgb.NewEventFuncs[25] = ResizeRequestEventNew +type SetupFailed struct { + Status byte + ReasonLen byte + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + Reason string // size: xgb.Pad((int(ReasonLen) * 1)) } -// CirculateNotify is the event number for a CirculateNotifyEvent. -const CirculateNotify = 26 - -type CirculateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - // padding: 4 bytes - Place byte - // padding: 3 bytes -} +// SetupFailedRead reads a byte slice into a SetupFailed value. +func SetupFailedRead(buf []byte, v *SetupFailed) int { + b := 0 -// CirculateNotifyEventNew constructs a CirculateNotifyEvent value that implements xgb.Event from a byte slice. -func CirculateNotifyEventNew(buf []byte) xgb.Event { - v := CirculateNotifyEvent{} - b := 1 // don't read event number + v.Status = buf[b] + b += 1 - b += 1 // padding + v.ReasonLen = buf[b] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) b += 2 - v.Event = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 - b += 4 // padding + v.Length = xgb.Get16(buf[b:]) + b += 2 - v.Place = buf[b] - b += 1 + { + byteString := make([]byte, v.ReasonLen) + copy(byteString[:v.ReasonLen], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int(v.ReasonLen)) + } - b += 3 // padding + return b +} - return v +// SetupFailedReadList reads a byte slice into a list of SetupFailed values. +func SetupFailedReadList(buf []byte, dest []SetupFailed) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupFailed{} + b += SetupFailedRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// Bytes writes a CirculateNotifyEvent value to a byte slice. -func (v CirculateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// Bytes writes a SetupFailed value to a byte slice. +func (v SetupFailed) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) b := 0 - // write event number - buf[b] = 26 + buf[b] = v.Status b += 1 - b += 1 // padding - - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Event)) - b += 4 + buf[b] = v.ReasonLen + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 - b += 4 // padding + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 - buf[b] = v.Place - b += 1 + xgb.Put16(buf[b:], v.Length) + b += 2 - b += 3 // padding + copy(buf[b:], v.Reason[:v.ReasonLen]) + b += xgb.Pad(int(v.ReasonLen)) return buf } -// SequenceId returns the sequence id attached to the CirculateNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v CirculateNotifyEvent) SequenceId() uint16 { - return v.Sequence +// SetupFailedListBytes writes a list of SetupFailed values to a byte slice. +func SetupFailedListBytes(buf []byte, list []SetupFailed) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of CirculateNotifyEvent. -func (v CirculateNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) - return "CirculateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// SetupFailedListSize computes the size (bytes) of a list of SetupFailed values. +func SetupFailedListSize(list []SetupFailed) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.ReasonLen) * 1))) + } + return size +} + +type SetupInfo struct { + Status byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + ReleaseNumber uint32 + ResourceIdBase uint32 + ResourceIdMask uint32 + MotionBufferSize uint32 + VendorLen uint16 + MaximumRequestLength uint16 + RootsLen byte + PixmapFormatsLen byte + ImageByteOrder byte + BitmapFormatBitOrder byte + BitmapFormatScanlineUnit byte + BitmapFormatScanlinePad byte + MinKeycode Keycode + MaxKeycode Keycode + // padding: 4 bytes + Vendor string // size: xgb.Pad((int(VendorLen) * 1)) + PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) + Roots []ScreenInfo // size: ScreenInfoListSize(Roots) } -func init() { - xgb.NewEventFuncs[26] = CirculateNotifyEventNew -} +// SetupInfoRead reads a byte slice into a SetupInfo value. +func SetupInfoRead(buf []byte, v *SetupInfo) int { + b := 0 -// PropertyNotify is the event number for a PropertyNotifyEvent. -const PropertyNotify = 28 + v.Status = buf[b] + b += 1 -type PropertyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Atom Atom - Time Timestamp - State byte - // padding: 3 bytes -} + b += 1 // padding -// PropertyNotifyEventNew constructs a PropertyNotifyEvent value that implements xgb.Event from a byte slice. -func PropertyNotifyEventNew(buf []byte) xgb.Event { - v := PropertyNotifyEvent{} - b := 1 // don't read event number + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 - b += 1 // padding + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Length = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) + v.ReleaseNumber = xgb.Get32(buf[b:]) b += 4 - v.Atom = Atom(xgb.Get32(buf[b:])) + v.ResourceIdBase = xgb.Get32(buf[b:]) b += 4 - v.Time = Timestamp(xgb.Get32(buf[b:])) + v.ResourceIdMask = xgb.Get32(buf[b:]) b += 4 - v.State = buf[b] - b += 1 + v.MotionBufferSize = xgb.Get32(buf[b:]) + b += 4 - b += 3 // padding + v.VendorLen = xgb.Get16(buf[b:]) + b += 2 - return v -} + v.MaximumRequestLength = xgb.Get16(buf[b:]) + b += 2 -// Bytes writes a PropertyNotifyEvent value to a byte slice. -func (v PropertyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 + v.RootsLen = buf[b] + b += 1 - // write event number - buf[b] = 28 + v.PixmapFormatsLen = buf[b] b += 1 - b += 1 // padding + v.ImageByteOrder = buf[b] + b += 1 - b += 2 // skip sequence number + v.BitmapFormatBitOrder = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 + v.BitmapFormatScanlineUnit = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Atom)) - b += 4 + v.BitmapFormatScanlinePad = buf[b] + b += 1 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + v.MinKeycode = Keycode(buf[b]) + b += 1 - buf[b] = v.State + v.MaxKeycode = Keycode(buf[b]) b += 1 - b += 3 // padding + b += 4 // padding - return buf -} + { + byteString := make([]byte, v.VendorLen) + copy(byteString[:v.VendorLen], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLen)) + } -// SequenceId returns the sequence id attached to the PropertyNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v PropertyNotifyEvent) SequenceId() uint16 { - return v.Sequence -} + v.PixmapFormats = make([]Format, v.PixmapFormatsLen) + b += FormatReadList(buf[b:], v.PixmapFormats) -// String is a rudimentary string representation of PropertyNotifyEvent. -func (v PropertyNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Atom: %d", v.Atom)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "PropertyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.Roots = make([]ScreenInfo, v.RootsLen) + b += ScreenInfoReadList(buf[b:], v.Roots) -func init() { - xgb.NewEventFuncs[28] = PropertyNotifyEventNew + return b } -// SelectionClear is the event number for a SelectionClearEvent. -const SelectionClear = 29 - -type SelectionClearEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Owner Window - Selection Atom +// SetupInfoReadList reads a byte slice into a list of SetupInfo values. +func SetupInfoReadList(buf []byte, dest []SetupInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupInfo{} + b += SetupInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// SelectionClearEventNew constructs a SelectionClearEvent value that implements xgb.Event from a byte slice. -func SelectionClearEventNew(buf []byte) xgb.Event { - v := SelectionClearEvent{} - b := 1 // don't read event number +// Bytes writes a SetupInfo value to a byte slice. +func (v SetupInfo) Bytes() []byte { + buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) + b := 0 + + buf[b] = v.Status + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.ProtocolMajorVersion) b += 2 - v.Time = Timestamp(xgb.Get32(buf[b:])) + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + xgb.Put32(buf[b:], v.ReleaseNumber) b += 4 - v.Owner = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], v.ResourceIdBase) b += 4 - v.Selection = Atom(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], v.ResourceIdMask) b += 4 - return v -} + xgb.Put32(buf[b:], v.MotionBufferSize) + b += 4 -// Bytes writes a SelectionClearEvent value to a byte slice. -func (v SelectionClearEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 + xgb.Put16(buf[b:], v.VendorLen) + b += 2 - // write event number - buf[b] = 29 + xgb.Put16(buf[b:], v.MaximumRequestLength) + b += 2 + + buf[b] = v.RootsLen b += 1 - b += 1 // padding + buf[b] = v.PixmapFormatsLen + b += 1 - b += 2 // skip sequence number + buf[b] = v.ImageByteOrder + b += 1 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + buf[b] = v.BitmapFormatBitOrder + b += 1 - xgb.Put32(buf[b:], uint32(v.Owner)) - b += 4 + buf[b] = v.BitmapFormatScanlineUnit + b += 1 - xgb.Put32(buf[b:], uint32(v.Selection)) - b += 4 + buf[b] = v.BitmapFormatScanlinePad + b += 1 - return buf -} + buf[b] = byte(v.MinKeycode) + b += 1 -// SequenceId returns the sequence id attached to the SelectionClear event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v SelectionClearEvent) SequenceId() uint16 { - return v.Sequence -} + buf[b] = byte(v.MaxKeycode) + b += 1 -// String is a rudimentary string representation of SelectionClearEvent. -func (v SelectionClearEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) - fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) - return "SelectionClear {" + xgb.StringsJoin(fieldVals, ", ") + "}" + b += 4 // padding + + copy(buf[b:], v.Vendor[:v.VendorLen]) + b += xgb.Pad(int(v.VendorLen)) + + b += FormatListBytes(buf[b:], v.PixmapFormats) + + b += ScreenInfoListBytes(buf[b:], v.Roots) + + return buf } -func init() { - xgb.NewEventFuncs[29] = SelectionClearEventNew +// SetupInfoListBytes writes a list of SetupInfo values to a byte slice. +func SetupInfoListBytes(buf []byte, list []SetupInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// SelectionRequest is the event number for a SelectionRequestEvent. -const SelectionRequest = 30 +// SetupInfoListSize computes the size (bytes) of a list of SetupInfo values. +func SetupInfoListSize(list []SetupInfo) int { + size := 0 + for _, item := range list { + size += (((40 + xgb.Pad((int(item.VendorLen) * 1))) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) + } + return size +} -type SelectionRequestEvent struct { - Sequence uint16 +type SetupRequest struct { + ByteOrder byte // padding: 1 bytes - Time Timestamp - Owner Window - Requestor Window - Selection Atom - Target Atom - Property Atom + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + AuthorizationProtocolNameLen uint16 + AuthorizationProtocolDataLen uint16 + // padding: 2 bytes + AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) + AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) } -// SelectionRequestEventNew constructs a SelectionRequestEvent value that implements xgb.Event from a byte slice. -func SelectionRequestEventNew(buf []byte) xgb.Event { - v := SelectionRequestEvent{} - b := 1 // don't read event number +// SetupRequestRead reads a byte slice into a SetupRequest value. +func SetupRequestRead(buf []byte, v *SetupRequest) int { + b := 0 + + v.ByteOrder = buf[b] + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) b += 2 - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 - v.Owner = Window(xgb.Get32(buf[b:])) - b += 4 + v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) + b += 2 - v.Requestor = Window(xgb.Get32(buf[b:])) - b += 4 + v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) + b += 2 - v.Selection = Atom(xgb.Get32(buf[b:])) - b += 4 + b += 2 // padding - v.Target = Atom(xgb.Get32(buf[b:])) - b += 4 + { + byteString := make([]byte, v.AuthorizationProtocolNameLen) + copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) + v.AuthorizationProtocolName = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + } - v.Property = Atom(xgb.Get32(buf[b:])) - b += 4 + { + byteString := make([]byte, v.AuthorizationProtocolDataLen) + copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) + v.AuthorizationProtocolData = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + } - return v + return b } -// Bytes writes a SelectionRequestEvent value to a byte slice. -func (v SelectionRequestEvent) Bytes() []byte { - buf := make([]byte, 32) +// SetupRequestReadList reads a byte slice into a list of SetupRequest values. +func SetupRequestReadList(buf []byte, dest []SetupRequest) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupRequest{} + b += SetupRequestRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a SetupRequest value to a byte slice. +func (v SetupRequest) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) b := 0 - // write event number - buf[b] = 30 + buf[b] = v.ByteOrder b += 1 b += 1 // padding - b += 2 // skip sequence number + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 - xgb.Put32(buf[b:], uint32(v.Owner)) - b += 4 + xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) + b += 2 - xgb.Put32(buf[b:], uint32(v.Requestor)) - b += 4 + xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) + b += 2 - xgb.Put32(buf[b:], uint32(v.Selection)) - b += 4 + b += 2 // padding - xgb.Put32(buf[b:], uint32(v.Target)) - b += 4 + copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) - xgb.Put32(buf[b:], uint32(v.Property)) - b += 4 + copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) return buf } -// SequenceId returns the sequence id attached to the SelectionRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v SelectionRequestEvent) SequenceId() uint16 { - return v.Sequence +// SetupRequestListBytes writes a list of SetupRequest values to a byte slice. +func SetupRequestListBytes(buf []byte, list []SetupRequest) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of SelectionRequestEvent. -func (v SelectionRequestEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) - fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) - fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) - fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) - fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) - return "SelectionRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// SetupRequestListSize computes the size (bytes) of a list of SetupRequest values. +func SetupRequestListSize(list []SetupRequest) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) + } + return size } -func init() { - xgb.NewEventFuncs[30] = SelectionRequestEventNew +const ( + StackModeAbove = 0 + StackModeBelow = 1 + StackModeTopIf = 2 + StackModeBottomIf = 3 + StackModeOpposite = 4 +) + +type Str struct { + NameLen byte + Name string // size: xgb.Pad((int(NameLen) * 1)) } -// SelectionNotify is the event number for a SelectionNotifyEvent. -const SelectionNotify = 31 +// StrRead reads a byte slice into a Str value. +func StrRead(buf []byte, v *Str) int { + b := 0 -type SelectionNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Requestor Window - Selection Atom - Target Atom - Property Atom + v.NameLen = buf[b] + b += 1 + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return b } -// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. -func SelectionNotifyEventNew(buf []byte) xgb.Event { - v := SelectionNotifyEvent{} - b := 1 // don't read event number +// StrReadList reads a byte slice into a list of Str values. +func StrReadList(buf []byte, dest []Str) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Str{} + b += StrRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - b += 1 // padding +// Bytes writes a Str value to a byte slice. +func (v Str) Bytes() []byte { + buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) + b := 0 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + buf[b] = v.NameLen + b += 1 - v.Time = Timestamp(xgb.Get32(buf[b:])) - b += 4 + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) - v.Requestor = Window(xgb.Get32(buf[b:])) - b += 4 + return buf +} - v.Selection = Atom(xgb.Get32(buf[b:])) - b += 4 +// StrListBytes writes a list of Str values to a byte slice. +func StrListBytes(buf []byte, list []Str) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} - v.Target = Atom(xgb.Get32(buf[b:])) - b += 4 +// StrListSize computes the size (bytes) of a list of Str values. +func StrListSize(list []Str) int { + size := 0 + for _, item := range list { + size += (1 + xgb.Pad((int(item.NameLen) * 1))) + } + return size +} - v.Property = Atom(xgb.Get32(buf[b:])) - b += 4 +const ( + SubwindowModeClipByChildren = 0 + SubwindowModeIncludeInferiors = 1 +) - return v +const ( + TimeCurrentTime = 0 +) + +type Timecoord struct { + Time Timestamp + X int16 + Y int16 } -// Bytes writes a SelectionNotifyEvent value to a byte slice. -func (v SelectionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// TimecoordRead reads a byte slice into a Timecoord value. +func TimecoordRead(buf []byte, v *Timecoord) int { b := 0 - // write event number - buf[b] = 31 - b += 1 + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 - b += 1 // padding + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - b += 2 // skip sequence number + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - xgb.Put32(buf[b:], uint32(v.Time)) - b += 4 + return b +} + +// TimecoordReadList reads a byte slice into a list of Timecoord values. +func TimecoordReadList(buf []byte, dest []Timecoord) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Timecoord{} + b += TimecoordRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} - xgb.Put32(buf[b:], uint32(v.Requestor)) - b += 4 +// Bytes writes a Timecoord value to a byte slice. +func (v Timecoord) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - xgb.Put32(buf[b:], uint32(v.Selection)) + xgb.Put32(buf[b:], uint32(v.Time)) b += 4 - xgb.Put32(buf[b:], uint32(v.Target)) - b += 4 + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 - xgb.Put32(buf[b:], uint32(v.Property)) - b += 4 + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 return buf } -// SequenceId returns the sequence id attached to the SelectionNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v SelectionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -// String is a rudimentary string representation of SelectionNotifyEvent. -func (v SelectionNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) - fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) - fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) - fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) - return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// TimecoordListBytes writes a list of Timecoord values to a byte slice. +func TimecoordListBytes(buf []byte, list []Timecoord) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -func init() { - xgb.NewEventFuncs[31] = SelectionNotifyEventNew -} +type Timestamp uint32 -// ColormapNotify is the event number for a ColormapNotifyEvent. -const ColormapNotify = 32 +// UnmapNotify is the event number for a UnmapNotifyEvent. +const UnmapNotify = 18 -type ColormapNotifyEvent struct { +type UnmapNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Window Window - Colormap Colormap - New bool - State byte - // padding: 2 bytes + Event Window + Window Window + FromConfigure bool + // padding: 3 bytes } -// ColormapNotifyEventNew constructs a ColormapNotifyEvent value that implements xgb.Event from a byte slice. -func ColormapNotifyEventNew(buf []byte) xgb.Event { - v := ColormapNotifyEvent{} +// UnmapNotifyEventNew constructs a UnmapNotifyEvent value that implements xgb.Event from a byte slice. +func UnmapNotifyEventNew(buf []byte) xgb.Event { + v := UnmapNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -5261,182 +6001,160 @@ func ColormapNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) + v.Event = Window(xgb.Get32(buf[b:])) b += 4 - v.Colormap = Colormap(xgb.Get32(buf[b:])) + v.Window = Window(xgb.Get32(buf[b:])) b += 4 if buf[b] == 1 { - v.New = true + v.FromConfigure = true } else { - v.New = false + v.FromConfigure = false } b += 1 - v.State = buf[b] - b += 1 - - b += 2 // padding + b += 3 // padding return v } -// Bytes writes a ColormapNotifyEvent value to a byte slice. -func (v ColormapNotifyEvent) Bytes() []byte { +// Bytes writes a UnmapNotifyEvent value to a byte slice. +func (v UnmapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 32 + buf[b] = 18 b += 1 b += 1 // padding b += 2 // skip sequence number - xgb.Put32(buf[b:], uint32(v.Window)) + xgb.Put32(buf[b:], uint32(v.Event)) b += 4 - xgb.Put32(buf[b:], uint32(v.Colormap)) + xgb.Put32(buf[b:], uint32(v.Window)) b += 4 - if v.New { + if v.FromConfigure { buf[b] = 1 } else { buf[b] = 0 } b += 1 - buf[b] = v.State - b += 1 - - b += 2 // padding + b += 3 // padding return buf } -// SequenceId returns the sequence id attached to the ColormapNotify event. +// SequenceId returns the sequence id attached to the UnmapNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v ColormapNotifyEvent) SequenceId() uint16 { +func (v UnmapNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of ColormapNotifyEvent. -func (v ColormapNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) +// String is a rudimentary string representation of UnmapNotifyEvent. +func (v UnmapNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Colormap: %d", v.Colormap)) - fieldVals = append(fieldVals, xgb.Sprintf("New: %t", v.New)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - return "ColormapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) + return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[32] = ColormapNotifyEventNew + xgb.NewEventFuncs[18] = UnmapNotifyEventNew } -// ClientMessage is the event number for a ClientMessageEvent. -const ClientMessage = 33 +// BadValue is the error number for a BadValue. +const BadValue = 2 -type ClientMessageEvent struct { - Sequence uint16 - Format byte - Window Window - Type Atom - Data ClientMessageDataUnion +type ValueError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes } -// ClientMessageEventNew constructs a ClientMessageEvent value that implements xgb.Event from a byte slice. -func ClientMessageEventNew(buf []byte) xgb.Event { - v := ClientMessageEvent{} - b := 1 // don't read event number +// ValueErrorNew constructs a ValueError value that implements xgb.Error from a byte slice. +func ValueErrorNew(buf []byte) xgb.Error { + v := ValueError{} + v.NiceName = "Value" - v.Format = buf[b] - b += 1 + b := 1 // skip error determinant + b += 1 // don't read error number v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Window = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Type = Atom(xgb.Get32(buf[b:])) + v.BadValue = xgb.Get32(buf[b:]) b += 4 - v.Data = ClientMessageDataUnion{} - b += ClientMessageDataUnionRead(buf[b:], &v.Data) - - return v -} - -// Bytes writes a ClientMessageEvent value to a byte slice. -func (v ClientMessageEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 33 - b += 1 + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 - buf[b] = v.Format + v.MajorOpcode = buf[b] b += 1 - b += 2 // skip sequence number - - xgb.Put32(buf[b:], uint32(v.Window)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Type)) - b += 4 - - { - unionBytes := v.Data.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) - } + b += 1 // padding - return buf + return v } -// SequenceId returns the sequence id attached to the ClientMessage event. -// Events without a sequence number (KeymapNotify) return 0. +// SequenceId returns the sequence id attached to the BadValue error. // This is mostly used internally. -func (v ClientMessageEvent) SequenceId() uint16 { - return v.Sequence +func (err ValueError) SequenceId() uint16 { + return err.Sequence } -// String is a rudimentary string representation of ClientMessageEvent. -func (v ClientMessageEvent) String() string { +// BadId returns the 'BadValue' number if one exists for the BadValue error. If no bad value exists, 0 is returned. +func (err ValueError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadValue error. + +func (err ValueError) Error() string { fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Format: %d", v.Format)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Type: %d", v.Type)) - return "ClientMessage {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadValue {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[33] = ClientMessageEventNew + xgb.NewErrorFuncs[2] = ValueErrorNew } -// MappingNotify is the event number for a MappingNotifyEvent. -const MappingNotify = 34 +const ( + VisibilityUnobscured = 0 + VisibilityPartiallyObscured = 1 + VisibilityFullyObscured = 2 +) -type MappingNotifyEvent struct { +// VisibilityNotify is the event number for a VisibilityNotifyEvent. +const VisibilityNotify = 15 + +type VisibilityNotifyEvent struct { Sequence uint16 // padding: 1 bytes - Request byte - FirstKeycode Keycode - Count byte - // padding: 1 bytes + Window Window + State byte + // padding: 3 bytes } -// MappingNotifyEventNew constructs a MappingNotifyEvent value that implements xgb.Event from a byte slice. -func MappingNotifyEventNew(buf []byte) xgb.Event { - v := MappingNotifyEvent{} +// VisibilityNotifyEventNew constructs a VisibilityNotifyEvent value that implements xgb.Event from a byte slice. +func VisibilityNotifyEventNew(buf []byte) xgb.Event { + v := VisibilityNotifyEvent{} b := 1 // don't read event number b += 1 // padding @@ -5444,1035 +6162,1012 @@ func MappingNotifyEventNew(buf []byte) xgb.Event { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Request = buf[b] - b += 1 - - v.FirstKeycode = Keycode(buf[b]) - b += 1 + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 - v.Count = buf[b] + v.State = buf[b] b += 1 - b += 1 // padding + b += 3 // padding return v } -// Bytes writes a MappingNotifyEvent value to a byte slice. -func (v MappingNotifyEvent) Bytes() []byte { +// Bytes writes a VisibilityNotifyEvent value to a byte slice. +func (v VisibilityNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number - buf[b] = 34 + buf[b] = 15 b += 1 b += 1 // padding b += 2 // skip sequence number - buf[b] = v.Request - b += 1 - - buf[b] = byte(v.FirstKeycode) - b += 1 + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 - buf[b] = v.Count + buf[b] = v.State b += 1 - b += 1 // padding + b += 3 // padding return buf } -// SequenceId returns the sequence id attached to the MappingNotify event. +// SequenceId returns the sequence id attached to the VisibilityNotify event. // Events without a sequence number (KeymapNotify) return 0. // This is mostly used internally. -func (v MappingNotifyEvent) SequenceId() uint16 { +func (v VisibilityNotifyEvent) SequenceId() uint16 { return v.Sequence } -// String is a rudimentary string representation of MappingNotifyEvent. -func (v MappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) +// String is a rudimentary string representation of VisibilityNotifyEvent. +func (v VisibilityNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) - fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) - fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) - return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[34] = MappingNotifyEventNew + xgb.NewEventFuncs[15] = VisibilityNotifyEventNew } -// KeyRelease is the event number for a KeyReleaseEvent. -const KeyRelease = 3 - -type KeyReleaseEvent KeyPressEvent +const ( + VisualClassStaticGray = 0 + VisualClassGrayScale = 1 + VisualClassStaticColor = 2 + VisualClassPseudoColor = 3 + VisualClassTrueColor = 4 + VisualClassDirectColor = 5 +) -// KeyReleaseEventNew constructs a KeyReleaseEvent value that implements xgb.Event from a byte slice. -func KeyReleaseEventNew(buf []byte) xgb.Event { - return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) +type VisualInfo struct { + VisualId Visualid + Class byte + BitsPerRgbValue byte + ColormapEntries uint16 + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 4 bytes } -// Bytes writes a KeyReleaseEvent value to a byte slice. -func (v KeyReleaseEvent) Bytes() []byte { - return KeyPressEvent(v).Bytes() -} +// VisualInfoRead reads a byte slice into a VisualInfo value. +func VisualInfoRead(buf []byte, v *VisualInfo) int { + b := 0 -// SequenceId returns the sequence id attached to the KeyRelease event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v KeyReleaseEvent) SequenceId() uint16 { - return v.Sequence -} + v.VisualId = Visualid(xgb.Get32(buf[b:])) + b += 4 -func (v KeyReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.Class = buf[b] + b += 1 -func init() { - xgb.NewEventFuncs[3] = KeyReleaseEventNew -} + v.BitsPerRgbValue = buf[b] + b += 1 -// ButtonRelease is the event number for a ButtonReleaseEvent. -const ButtonRelease = 5 + v.ColormapEntries = xgb.Get16(buf[b:]) + b += 2 -type ButtonReleaseEvent ButtonPressEvent + v.RedMask = xgb.Get32(buf[b:]) + b += 4 -// ButtonReleaseEventNew constructs a ButtonReleaseEvent value that implements xgb.Event from a byte slice. -func ButtonReleaseEventNew(buf []byte) xgb.Event { - return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) -} + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 -// Bytes writes a ButtonReleaseEvent value to a byte slice. -func (v ButtonReleaseEvent) Bytes() []byte { - return ButtonPressEvent(v).Bytes() + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + return b } -// SequenceId returns the sequence id attached to the ButtonRelease event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v ButtonReleaseEvent) SequenceId() uint16 { - return v.Sequence +// VisualInfoReadList reads a byte slice into a list of VisualInfo values. +func VisualInfoReadList(buf []byte, dest []VisualInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = VisualInfo{} + b += VisualInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -func (v ButtonReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) - return "ButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// Bytes writes a VisualInfo value to a byte slice. +func (v VisualInfo) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + xgb.Put32(buf[b:], uint32(v.VisualId)) + b += 4 + + buf[b] = v.Class + b += 1 + + buf[b] = v.BitsPerRgbValue + b += 1 + + xgb.Put16(buf[b:], v.ColormapEntries) + b += 2 + + xgb.Put32(buf[b:], v.RedMask) + b += 4 + + xgb.Put32(buf[b:], v.GreenMask) + b += 4 + + xgb.Put32(buf[b:], v.BlueMask) + b += 4 + + b += 4 // padding + + return buf } -func init() { - xgb.NewEventFuncs[5] = ButtonReleaseEventNew +// VisualInfoListBytes writes a list of VisualInfo values to a byte slice. +func VisualInfoListBytes(buf []byte, list []VisualInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// LeaveNotify is the event number for a LeaveNotifyEvent. -const LeaveNotify = 8 +type Visualid uint32 -type LeaveNotifyEvent EnterNotifyEvent +type Window uint32 -// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. -func LeaveNotifyEventNew(buf []byte) xgb.Event { - return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil } -// Bytes writes a LeaveNotifyEvent value to a byte slice. -func (v LeaveNotifyEvent) Bytes() []byte { - return EnterNotifyEvent(v).Bytes() +const ( + WindowNone = 0 +) + +// BadWindow is the error number for a BadWindow. +const BadWindow = 3 + +type WindowError ValueError + +// WindowErrorNew constructs a WindowError value that implements xgb.Error from a byte slice. +func WindowErrorNew(buf []byte) xgb.Error { + v := WindowError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Window" + return v } -// SequenceId returns the sequence id attached to the LeaveNotify event. -// Events without a sequence number (KeymapNotify) return 0. +// SequenceId returns the sequence id attached to the BadWindow error. // This is mostly used internally. -func (v LeaveNotifyEvent) SequenceId() uint16 { - return v.Sequence +func (err WindowError) SequenceId() uint16 { + return err.Sequence } -func (v LeaveNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) - return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// BadId returns the 'BadValue' number if one exists for the BadWindow error. If no bad value exists, 0 is returned. +func (err WindowError) BadId() uint32 { + return err.BadValue +} + +// Error returns a rudimentary string representation of the BadWindow error. +func (err WindowError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewEventFuncs[8] = LeaveNotifyEventNew + xgb.NewErrorFuncs[3] = WindowErrorNew } -// FocusOut is the event number for a FocusOutEvent. -const FocusOut = 10 +const ( + WindowClassCopyFromParent = 0 + WindowClassInputOutput = 1 + WindowClassInputOnly = 2 +) -type FocusOutEvent FocusInEvent +// Skipping definition for base type 'Bool' -// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. -func FocusOutEventNew(buf []byte) xgb.Event { - return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) -} +// Skipping definition for base type 'Byte' -// Bytes writes a FocusOutEvent value to a byte slice. -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() -} +// Skipping definition for base type 'Card8' -// SequenceId returns the sequence id attached to the FocusOut event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v FocusOutEvent) SequenceId() uint16 { - return v.Sequence -} +// Skipping definition for base type 'Char' -func (v FocusOutEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) - return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Skipping definition for base type 'Void' -func init() { - xgb.NewEventFuncs[10] = FocusOutEventNew -} +// Skipping definition for base type 'Double' -// CirculateRequest is the event number for a CirculateRequestEvent. -const CirculateRequest = 27 +// Skipping definition for base type 'Float' -type CirculateRequestEvent CirculateNotifyEvent +// Skipping definition for base type 'Int16' -// CirculateRequestEventNew constructs a CirculateRequestEvent value that implements xgb.Event from a byte slice. -func CirculateRequestEventNew(buf []byte) xgb.Event { - return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) -} +// Skipping definition for base type 'Int32' -// Bytes writes a CirculateRequestEvent value to a byte slice. -func (v CirculateRequestEvent) Bytes() []byte { - return CirculateNotifyEvent(v).Bytes() -} +// Skipping definition for base type 'Int8' -// SequenceId returns the sequence id attached to the CirculateRequest event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v CirculateRequestEvent) SequenceId() uint16 { - return v.Sequence -} +// Skipping definition for base type 'Card16' -func (v CirculateRequestEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) - return "CirculateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// Skipping definition for base type 'Card32' + +// AllocColorCookie is a cookie used only for AllocColor requests. +type AllocColorCookie struct { + *xgb.Cookie } -func init() { - xgb.NewEventFuncs[27] = CirculateRequestEventNew +// AllocColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorCookie.Reply() +func AllocColor(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) + return AllocColorCookie{cookie} } -// BadRequest is the error number for a BadRequest. -const BadRequest = 1 +// AllocColorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) + return AllocColorCookie{cookie} +} -type RequestError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte +// AllocColorReply represents the data returned from a AllocColor request. +type AllocColorReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes + Pixel uint32 } -// RequestErrorNew constructs a RequestError value that implements xgb.Error from a byte slice. -func RequestErrorNew(buf []byte) xgb.Error { - v := RequestError{} - v.NiceName = "Request" +// Reply blocks and returns the reply data for a AllocColor request. +func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorReply(buf), nil +} - b := 1 // skip error determinant - b += 1 // don't read error number +// allocColorReply reads a byte slice into a AllocColorReply value. +func allocColorReply(buf []byte) *AllocColorReply { + v := new(AllocColorReply) + b := 1 // skip reply determinant + + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.BadValue = xgb.Get32(buf[b:]) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MinorOpcode = xgb.Get16(buf[b:]) + v.Red = xgb.Get16(buf[b:]) b += 2 - v.MajorOpcode = buf[b] - b += 1 + v.Green = xgb.Get16(buf[b:]) + b += 2 - b += 1 // padding + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 return v } -// SequenceId returns the sequence id attached to the BadRequest error. -// This is mostly used internally. -func (err RequestError) SequenceId() uint16 { - return err.Sequence -} +// Write request to wire for AllocColor +// allocColorRequest writes a AllocColor request to a byte slice. +func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) -// BadId returns the 'BadValue' number if one exists for the BadRequest error. If no bad value exists, 0 is returned. -func (err RequestError) BadId() uint32 { - return err.BadValue -} + buf[b] = 84 // request opcode + b += 1 -// Error returns a rudimentary string representation of the BadRequest error. + b += 1 // padding -func (err RequestError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Red) + b += 2 + + xgb.Put16(buf[b:], Green) + b += 2 + + xgb.Put16(buf[b:], Blue) + b += 2 + + b += 2 // padding + + return buf } -func init() { - xgb.NewErrorFuncs[1] = RequestErrorNew +// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. +type AllocColorCellsCookie struct { + *xgb.Cookie } -// BadValue is the error number for a BadValue. -const BadValue = 2 +// AllocColorCells sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorCellsCookie.Reply() +func AllocColorCells(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) + return AllocColorCellsCookie{cookie} +} -type ValueError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte +// AllocColorCellsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) + return AllocColorCellsCookie{cookie} +} + +// AllocColorCellsReply represents the data returned from a AllocColorCells request. +type AllocColorCellsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes + PixelsLen uint16 + MasksLen uint16 + // padding: 20 bytes + Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) + Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) } -// ValueErrorNew constructs a ValueError value that implements xgb.Error from a byte slice. -func ValueErrorNew(buf []byte) xgb.Error { - v := ValueError{} - v.NiceName = "Value" +// Reply blocks and returns the reply data for a AllocColorCells request. +func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorCellsReply(buf), nil +} - b := 1 // skip error determinant - b += 1 // don't read error number +// allocColorCellsReply reads a byte slice into a AllocColorCellsReply value. +func allocColorCellsReply(buf []byte) *AllocColorCellsReply { + v := new(AllocColorCellsReply) + b := 1 // skip reply determinant + + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.BadValue = xgb.Get32(buf[b:]) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MinorOpcode = xgb.Get16(buf[b:]) + v.PixelsLen = xgb.Get16(buf[b:]) b += 2 - v.MajorOpcode = buf[b] - b += 1 + v.MasksLen = xgb.Get16(buf[b:]) + b += 2 - b += 1 // padding + b += 20 // padding - return v -} + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) -// SequenceId returns the sequence id attached to the BadValue error. -// This is mostly used internally. -func (err ValueError) SequenceId() uint16 { - return err.Sequence -} + v.Masks = make([]uint32, v.MasksLen) + for i := 0; i < int(v.MasksLen); i++ { + v.Masks[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) -// BadId returns the 'BadValue' number if one exists for the BadValue error. If no bad value exists, 0 is returned. -func (err ValueError) BadId() uint32 { - return err.BadValue + return v } -// Error returns a rudimentary string representation of the BadValue error. +// Write request to wire for AllocColorCells +// allocColorCellsRequest writes a AllocColorCells request to a byte slice. +func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) -func (err ValueError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadValue {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + buf[b] = 86 // request opcode + b += 1 -func init() { - xgb.NewErrorFuncs[2] = ValueErrorNew -} + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 -// BadWindow is the error number for a BadWindow. -const BadWindow = 3 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -type WindowError ValueError + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 -// WindowErrorNew constructs a WindowError value that implements xgb.Error from a byte slice. -func WindowErrorNew(buf []byte) xgb.Error { - v := WindowError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Window" - return v -} + xgb.Put16(buf[b:], Colors) + b += 2 -// SequenceId returns the sequence id attached to the BadWindow error. -// This is mostly used internally. -func (err WindowError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], Planes) + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadWindow error. If no bad value exists, 0 is returned. -func (err WindowError) BadId() uint32 { - return err.BadValue + return buf } -// Error returns a rudimentary string representation of the BadWindow error. -func (err WindowError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. +type AllocColorPlanesCookie struct { + *xgb.Cookie } -func init() { - xgb.NewErrorFuncs[3] = WindowErrorNew +// AllocColorPlanes sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorPlanesCookie.Reply() +func AllocColorPlanes(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) + return AllocColorPlanesCookie{cookie} } -// BadPixmap is the error number for a BadPixmap. -const BadPixmap = 4 - -type PixmapError ValueError - -// PixmapErrorNew constructs a PixmapError value that implements xgb.Error from a byte slice. -func PixmapErrorNew(buf []byte) xgb.Error { - v := PixmapError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Pixmap" - return v +// AllocColorPlanesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) + return AllocColorPlanesCookie{cookie} } -// SequenceId returns the sequence id attached to the BadPixmap error. -// This is mostly used internally. -func (err PixmapError) SequenceId() uint16 { - return err.Sequence +// AllocColorPlanesReply represents the data returned from a AllocColorPlanes request. +type AllocColorPlanesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + PixelsLen uint16 + // padding: 2 bytes + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 8 bytes + Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) } -// BadId returns the 'BadValue' number if one exists for the BadPixmap error. If no bad value exists, 0 is returned. -func (err PixmapError) BadId() uint32 { - return err.BadValue +// Reply blocks and returns the reply data for a AllocColorPlanes request. +func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorPlanesReply(buf), nil } -// Error returns a rudimentary string representation of the BadPixmap error. -func (err PixmapError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. +func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { + v := new(AllocColorPlanesReply) + b := 1 // skip reply determinant -func init() { - xgb.NewErrorFuncs[4] = PixmapErrorNew -} + b += 1 // padding -// BadAtom is the error number for a BadAtom. -const BadAtom = 5 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -type AtomError ValueError + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// AtomErrorNew constructs a AtomError value that implements xgb.Error from a byte slice. -func AtomErrorNew(buf []byte) xgb.Error { - v := AtomError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Atom" - return v -} + v.PixelsLen = xgb.Get16(buf[b:]) + b += 2 -// SequenceId returns the sequence id attached to the BadAtom error. -// This is mostly used internally. -func (err AtomError) SequenceId() uint16 { - return err.Sequence -} + b += 2 // padding -// BadId returns the 'BadValue' number if one exists for the BadAtom error. If no bad value exists, 0 is returned. -func (err AtomError) BadId() uint32 { - return err.BadValue -} + v.RedMask = xgb.Get32(buf[b:]) + b += 4 -// Error returns a rudimentary string representation of the BadAtom error. -func (err AtomError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAtom {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 -func init() { - xgb.NewErrorFuncs[5] = AtomErrorNew -} + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 -// BadCursor is the error number for a BadCursor. -const BadCursor = 6 + b += 8 // padding -type CursorError ValueError + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) -// CursorErrorNew constructs a CursorError value that implements xgb.Error from a byte slice. -func CursorErrorNew(buf []byte) xgb.Error { - v := CursorError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Cursor" return v } -// SequenceId returns the sequence id attached to the BadCursor error. -// This is mostly used internally. -func (err CursorError) SequenceId() uint16 { - return err.Sequence -} - -// BadId returns the 'BadValue' number if one exists for the BadCursor error. If no bad value exists, 0 is returned. -func (err CursorError) BadId() uint32 { - return err.BadValue -} +// Write request to wire for AllocColorPlanes +// allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice. +func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) -// Error returns a rudimentary string representation of the BadCursor error. -func (err CursorError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadCursor {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + buf[b] = 87 // request opcode + b += 1 -func init() { - xgb.NewErrorFuncs[6] = CursorErrorNew -} + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 -// BadFont is the error number for a BadFont. -const BadFont = 7 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -type FontError ValueError + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 -// FontErrorNew constructs a FontError value that implements xgb.Error from a byte slice. -func FontErrorNew(buf []byte) xgb.Error { - v := FontError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Font" - return v -} + xgb.Put16(buf[b:], Colors) + b += 2 -// SequenceId returns the sequence id attached to the BadFont error. -// This is mostly used internally. -func (err FontError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], Reds) + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadFont error. If no bad value exists, 0 is returned. -func (err FontError) BadId() uint32 { - return err.BadValue -} + xgb.Put16(buf[b:], Greens) + b += 2 -// Error returns a rudimentary string representation of the BadFont error. -func (err FontError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadFont {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put16(buf[b:], Blues) + b += 2 -func init() { - xgb.NewErrorFuncs[7] = FontErrorNew + return buf } -// BadMatch is the error number for a BadMatch. -const BadMatch = 8 - -type MatchError RequestError - -// MatchErrorNew constructs a MatchError value that implements xgb.Error from a byte slice. -func MatchErrorNew(buf []byte) xgb.Error { - v := MatchError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Match" - return v +// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. +type AllocNamedColorCookie struct { + *xgb.Cookie } -// SequenceId returns the sequence id attached to the BadMatch error. -// This is mostly used internally. -func (err MatchError) SequenceId() uint16 { - return err.Sequence +// AllocNamedColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocNamedColorCookie.Reply() +func AllocNamedColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) + return AllocNamedColorCookie{cookie} } -// BadId returns the 'BadValue' number if one exists for the BadMatch error. If no bad value exists, 0 is returned. -func (err MatchError) BadId() uint32 { - return err.BadValue +// AllocNamedColorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) + return AllocNamedColorCookie{cookie} } -// Error returns a rudimentary string representation of the BadMatch error. -func (err MatchError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadMatch {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// AllocNamedColorReply represents the data returned from a AllocNamedColor request. +type AllocNamedColorReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Pixel uint32 + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 } -func init() { - xgb.NewErrorFuncs[8] = MatchErrorNew +// Reply blocks and returns the reply data for a AllocNamedColor request. +func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocNamedColorReply(buf), nil } -// BadDrawable is the error number for a BadDrawable. -const BadDrawable = 9 +// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. +func allocNamedColorReply(buf []byte) *AllocNamedColorReply { + v := new(AllocNamedColorReply) + b := 1 // skip reply determinant -type DrawableError ValueError + b += 1 // padding -// DrawableErrorNew constructs a DrawableError value that implements xgb.Error from a byte slice. -func DrawableErrorNew(buf []byte) xgb.Error { - v := DrawableError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Drawable" - return v -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// SequenceId returns the sequence id attached to the BadDrawable error. -// This is mostly used internally. -func (err DrawableError) SequenceId() uint16 { - return err.Sequence -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// BadId returns the 'BadValue' number if one exists for the BadDrawable error. If no bad value exists, 0 is returned. -func (err DrawableError) BadId() uint32 { - return err.BadValue -} + v.Pixel = xgb.Get32(buf[b:]) + b += 4 -// Error returns a rudimentary string representation of the BadDrawable error. -func (err DrawableError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + v.ExactRed = xgb.Get16(buf[b:]) + b += 2 -func init() { - xgb.NewErrorFuncs[9] = DrawableErrorNew -} + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 -// BadAccess is the error number for a BadAccess. -const BadAccess = 10 + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 -type AccessError RequestError + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 -// AccessErrorNew constructs a AccessError value that implements xgb.Error from a byte slice. -func AccessErrorNew(buf []byte) xgb.Error { - v := AccessError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Access" - return v -} + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 -// SequenceId returns the sequence id attached to the BadAccess error. -// This is mostly used internally. -func (err AccessError) SequenceId() uint16 { - return err.Sequence -} + v.VisualBlue = xgb.Get16(buf[b:]) + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadAccess error. If no bad value exists, 0 is returned. -func (err AccessError) BadId() uint32 { - return err.BadValue + return v } -// Error returns a rudimentary string representation of the BadAccess error. -func (err AccessError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAccess {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Write request to wire for AllocNamedColor +// allocNamedColorRequest writes a AllocNamedColor request to a byte slice. +func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) -func init() { - xgb.NewErrorFuncs[10] = AccessErrorNew -} + buf[b] = 85 // request opcode + b += 1 -// BadAlloc is the error number for a BadAlloc. -const BadAlloc = 11 + b += 1 // padding -type AllocError RequestError + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// AllocErrorNew constructs a AllocError value that implements xgb.Error from a byte slice. -func AllocErrorNew(buf []byte) xgb.Error { - v := AllocError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Alloc" - return v -} + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 -// SequenceId returns the sequence id attached to the BadAlloc error. -// This is mostly used internally. -func (err AllocError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], NameLen) + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadAlloc error. If no bad value exists, 0 is returned. -func (err AllocError) BadId() uint32 { - return err.BadValue -} + b += 2 // padding -// Error returns a rudimentary string representation of the BadAlloc error. -func (err AllocError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAlloc {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) -func init() { - xgb.NewErrorFuncs[11] = AllocErrorNew + return buf } -// BadColormap is the error number for a BadColormap. -const BadColormap = 12 - -type ColormapError ValueError - -// ColormapErrorNew constructs a ColormapError value that implements xgb.Error from a byte slice. -func ColormapErrorNew(buf []byte) xgb.Error { - v := ColormapError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "Colormap" - return v +// AllowEventsCookie is a cookie used only for AllowEvents requests. +type AllowEventsCookie struct { + *xgb.Cookie } -// SequenceId returns the sequence id attached to the BadColormap error. -// This is mostly used internally. -func (err ColormapError) SequenceId() uint16 { - return err.Sequence +// AllowEvents sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func AllowEvents(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) + return AllowEventsCookie{cookie} } -// BadId returns the 'BadValue' number if one exists for the BadColormap error. If no bad value exists, 0 is returned. -func (err ColormapError) BadId() uint32 { - return err.BadValue +// AllowEventsChecked sends a checked request. +// If an error occurs, it can be retrieved using AllowEventsCookie.Check() +func AllowEventsChecked(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) + return AllowEventsCookie{cookie} } -// Error returns a rudimentary string representation of the BadColormap error. -func (err ColormapError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadColormap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook AllowEventsCookie) Check() error { + return cook.Cookie.Check() } -func init() { - xgb.NewErrorFuncs[12] = ColormapErrorNew -} +// Write request to wire for AllowEvents +// allowEventsRequest writes a AllowEvents request to a byte slice. +func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) -// BadGContext is the error number for a BadGContext. -const BadGContext = 13 + buf[b] = 35 // request opcode + b += 1 -type GContextError ValueError + buf[b] = Mode + b += 1 -// GContextErrorNew constructs a GContextError value that implements xgb.Error from a byte slice. -func GContextErrorNew(buf []byte) xgb.Error { - v := GContextError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "GContext" - return v + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf } -// SequenceId returns the sequence id attached to the BadGContext error. -// This is mostly used internally. -func (err GContextError) SequenceId() uint16 { - return err.Sequence +// BellCookie is a cookie used only for Bell requests. +type BellCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadGContext error. If no bad value exists, 0 is returned. -func (err GContextError) BadId() uint32 { - return err.BadValue +// Bell sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func Bell(c *xgb.Conn, Percent int8) BellCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(bellRequest(c, Percent), cookie) + return BellCookie{cookie} } -// Error returns a rudimentary string representation of the BadGContext error. -func (err GContextError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// BellChecked sends a checked request. +// If an error occurs, it can be retrieved using BellCookie.Check() +func BellChecked(c *xgb.Conn, Percent int8) BellCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(bellRequest(c, Percent), cookie) + return BellCookie{cookie} } -func init() { - xgb.NewErrorFuncs[13] = GContextErrorNew +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook BellCookie) Check() error { + return cook.Cookie.Check() } -// BadIDChoice is the error number for a BadIDChoice. -const BadIDChoice = 14 +// Write request to wire for Bell +// bellRequest writes a Bell request to a byte slice. +func bellRequest(c *xgb.Conn, Percent int8) []byte { + size := 4 + b := 0 + buf := make([]byte, size) -type IDChoiceError ValueError + buf[b] = 104 // request opcode + b += 1 -// IDChoiceErrorNew constructs a IDChoiceError value that implements xgb.Error from a byte slice. -func IDChoiceErrorNew(buf []byte) xgb.Error { - v := IDChoiceError(ValueErrorNew(buf).(ValueError)) - v.NiceName = "IDChoice" - return v -} + buf[b] = byte(Percent) + b += 1 -// SequenceId returns the sequence id attached to the BadIDChoice error. -// This is mostly used internally. -func (err IDChoiceError) SequenceId() uint16 { - return err.Sequence + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf } -// BadId returns the 'BadValue' number if one exists for the BadIDChoice error. If no bad value exists, 0 is returned. -func (err IDChoiceError) BadId() uint32 { - return err.BadValue +// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. +type ChangeActivePointerGrabCookie struct { + *xgb.Cookie } -// Error returns a rudimentary string representation of the BadIDChoice error. -func (err IDChoiceError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadIDChoice {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ChangeActivePointerGrab sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeActivePointerGrab(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) + return ChangeActivePointerGrabCookie{cookie} } -func init() { - xgb.NewErrorFuncs[14] = IDChoiceErrorNew +// ChangeActivePointerGrabChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeActivePointerGrabCookie.Check() +func ChangeActivePointerGrabChecked(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) + return ChangeActivePointerGrabCookie{cookie} } -// BadName is the error number for a BadName. -const BadName = 15 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangeActivePointerGrabCookie) Check() error { + return cook.Cookie.Check() +} -type NameError RequestError +// Write request to wire for ChangeActivePointerGrab +// changeActivePointerGrabRequest writes a ChangeActivePointerGrab request to a byte slice. +func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) -// NameErrorNew constructs a NameError value that implements xgb.Error from a byte slice. -func NameErrorNew(buf []byte) xgb.Error { - v := NameError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Name" - return v -} + buf[b] = 30 // request opcode + b += 1 -// SequenceId returns the sequence id attached to the BadName error. -// This is mostly used internally. -func (err NameError) SequenceId() uint16 { - return err.Sequence -} + b += 1 // padding -// BadId returns the 'BadValue' number if one exists for the BadName error. If no bad value exists, 0 is returned. -func (err NameError) BadId() uint32 { - return err.BadValue -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// Error returns a rudimentary string representation of the BadName error. -func (err NameError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadName {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 -func init() { - xgb.NewErrorFuncs[15] = NameErrorNew -} + xgb.Put32(buf[b:], uint32(Time)) + b += 4 -// BadLength is the error number for a BadLength. -const BadLength = 16 + xgb.Put16(buf[b:], EventMask) + b += 2 -type LengthError RequestError + b += 2 // padding -// LengthErrorNew constructs a LengthError value that implements xgb.Error from a byte slice. -func LengthErrorNew(buf []byte) xgb.Error { - v := LengthError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Length" - return v + return buf } -// SequenceId returns the sequence id attached to the BadLength error. -// This is mostly used internally. -func (err LengthError) SequenceId() uint16 { - return err.Sequence +// ChangeGCCookie is a cookie used only for ChangeGC requests. +type ChangeGCCookie struct { + *xgb.Cookie } -// BadId returns the 'BadValue' number if one exists for the BadLength error. If no bad value exists, 0 is returned. -func (err LengthError) BadId() uint32 { - return err.BadValue +// ChangeGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) + return ChangeGCCookie{cookie} } -// Error returns a rudimentary string representation of the BadLength error. -func (err LengthError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadLength {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ChangeGCChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeGCCookie.Check() +func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) + return ChangeGCCookie{cookie} } -func init() { - xgb.NewErrorFuncs[16] = LengthErrorNew +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangeGCCookie) Check() error { + return cook.Cookie.Check() } -// BadImplementation is the error number for a BadImplementation. -const BadImplementation = 17 +// Write request to wire for ChangeGC +// changeGCRequest writes a ChangeGC request to a byte slice. +func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) -type ImplementationError RequestError + buf[b] = 56 // request opcode + b += 1 -// ImplementationErrorNew constructs a ImplementationError value that implements xgb.Error from a byte slice. -func ImplementationErrorNew(buf []byte) xgb.Error { - v := ImplementationError(RequestErrorNew(buf).(RequestError)) - v.NiceName = "Implementation" - return v -} + b += 1 // padding -// SequenceId returns the sequence id attached to the BadImplementation error. -// This is mostly used internally. -func (err ImplementationError) SequenceId() uint16 { - return err.Sequence -} + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 -// BadId returns the 'BadValue' number if one exists for the BadImplementation error. If no bad value exists, 0 is returned. -func (err ImplementationError) BadId() uint32 { - return err.BadValue -} + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 -// Error returns a rudimentary string representation of the BadImplementation error. -func (err ImplementationError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) -func init() { - xgb.NewErrorFuncs[17] = ImplementationErrorNew + return buf } -// CreateWindowCookie is a cookie used only for CreateWindow requests. -type CreateWindowCookie struct { +// ChangeHostsCookie is a cookie used only for ChangeHosts requests. +type ChangeHostsCookie struct { *xgb.Cookie } -// CreateWindow sends an unchecked request. +// ChangeHosts sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -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 { +func ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { cookie := c.NewCookie(false, false) - c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} } -// CreateWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateWindowCookie.Check() -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 { +// ChangeHostsChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeHostsCookie.Check() +func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { cookie := c.NewCookie(true, false) - c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateWindowCookie) Check() error { +func (cook ChangeHostsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateWindow -// createWindowRequest writes a CreateWindow request to a byte slice. -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 { - size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for ChangeHosts +// changeHostsRequest writes a ChangeHosts request to a byte slice. +func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 1 // request opcode + buf[b] = 109 // request opcode b += 1 - buf[b] = Depth + buf[b] = Mode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Wid)) - b += 4 + buf[b] = Family + b += 1 - xgb.Put32(buf[b:], uint32(Parent)) - b += 4 + b += 1 // padding - xgb.Put16(buf[b:], uint16(X)) + xgb.Put16(buf[b:], AddressLen) b += 2 - xgb.Put16(buf[b:], uint16(Y)) - b += 2 + copy(buf[b:], Address[:AddressLen]) + b += xgb.Pad(int(AddressLen)) - xgb.Put16(buf[b:], Width) - b += 2 + return buf +} - xgb.Put16(buf[b:], Height) - b += 2 +// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. +type ChangeKeyboardControlCookie struct { + *xgb.Cookie +} - xgb.Put16(buf[b:], BorderWidth) - b += 2 +// ChangeKeyboardControl sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) + return ChangeKeyboardControlCookie{cookie} +} - xgb.Put16(buf[b:], Class) - b += 2 +// ChangeKeyboardControlChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeKeyboardControlCookie.Check() +func ChangeKeyboardControlChecked(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) + return ChangeKeyboardControlCookie{cookie} +} - xgb.Put32(buf[b:], uint32(Visual)) - b += 4 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangeKeyboardControlCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeKeyboardControl +// changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice. +func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 102 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 xgb.Put32(buf[b:], ValueMask) b += 4 @@ -6485,55 +7180,59 @@ func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X i return buf } -// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. -type ChangeWindowAttributesCookie struct { +// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. +type ChangeKeyboardMappingCookie struct { *xgb.Cookie } -// ChangeWindowAttributes sends an unchecked request. +// ChangeKeyboardMapping sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { +func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} } -// ChangeWindowAttributesChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeWindowAttributesCookie.Check() -func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { +// ChangeKeyboardMappingChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check() +func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeWindowAttributesCookie) Check() error { +func (cook ChangeKeyboardMappingCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeWindowAttributes -// changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice. -func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for ChangeKeyboardMapping +// changeKeyboardMappingRequest writes a ChangeKeyboardMapping request to a byte slice. +func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { + size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 2 // request opcode + buf[b] = 100 // request opcode b += 1 - b += 1 // padding + buf[b] = KeycodeCount + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 + buf[b] = byte(FirstKeycode) + b += 1 - xgb.Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) + buf[b] = KeysymsPerKeycode + b += 1 + + b += 2 // padding + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + xgb.Put32(buf[b:], uint32(Keysyms[i])) b += 4 } b = xgb.Pad(b) @@ -6541,145 +7240,113 @@ func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, return buf } -// GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. -type GetWindowAttributesCookie struct { +// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. +type ChangePointerControlCookie struct { *xgb.Cookie } -// GetWindowAttributes sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetWindowAttributesCookie.Reply() -func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getWindowAttributesRequest(c, Window), cookie) - return GetWindowAttributesCookie{cookie} -} - -// GetWindowAttributesUnchecked sends an unchecked request. +// ChangePointerControl sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getWindowAttributesRequest(c, Window), cookie) - return GetWindowAttributesCookie{cookie} -} - -// GetWindowAttributesReply represents the data returned from a GetWindowAttributes request. -type GetWindowAttributesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - BackingStore byte - Visual Visualid - Class uint16 - BitGravity byte - WinGravity byte - BackingPlanes uint32 - BackingPixel uint32 - SaveUnder bool - MapIsInstalled bool - MapState byte - OverrideRedirect bool - Colormap Colormap - AllEventMasks uint32 - YourEventMask uint32 - DoNotPropagateMask uint16 - // padding: 2 bytes +func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{cookie} } -// Reply blocks and returns the reply data for a GetWindowAttributes request. -func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getWindowAttributesReply(buf), nil +// ChangePointerControlChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangePointerControlCookie.Check() +func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{cookie} } -// getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value. -func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { - v := new(GetWindowAttributesReply) - b := 1 // skip reply determinant - - v.BackingStore = buf[b] - b += 1 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangePointerControlCookie) Check() error { + return cook.Cookie.Check() +} - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Write request to wire for ChangePointerControl +// changePointerControlRequest writes a ChangePointerControl request to a byte slice. +func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + buf[b] = 105 // request opcode + b += 1 - v.Visual = Visualid(xgb.Get32(buf[b:])) - b += 4 + b += 1 // padding - v.Class = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.BitGravity = buf[b] - b += 1 - - v.WinGravity = buf[b] - b += 1 - - v.BackingPlanes = xgb.Get32(buf[b:]) - b += 4 + xgb.Put16(buf[b:], uint16(AccelerationNumerator)) + b += 2 - v.BackingPixel = xgb.Get32(buf[b:]) - b += 4 + xgb.Put16(buf[b:], uint16(AccelerationDenominator)) + b += 2 - if buf[b] == 1 { - v.SaveUnder = true - } else { - v.SaveUnder = false - } - b += 1 + xgb.Put16(buf[b:], uint16(Threshold)) + b += 2 - if buf[b] == 1 { - v.MapIsInstalled = true + if DoAcceleration { + buf[b] = 1 } else { - v.MapIsInstalled = false + buf[b] = 0 } b += 1 - v.MapState = buf[b] - b += 1 - - if buf[b] == 1 { - v.OverrideRedirect = true + if DoThreshold { + buf[b] = 1 } else { - v.OverrideRedirect = false + buf[b] = 0 } b += 1 - v.Colormap = Colormap(xgb.Get32(buf[b:])) - b += 4 - - v.AllEventMasks = xgb.Get32(buf[b:]) - b += 4 + return buf +} - v.YourEventMask = xgb.Get32(buf[b:]) - b += 4 +// ChangePropertyCookie is a cookie used only for ChangeProperty requests. +type ChangePropertyCookie struct { + *xgb.Cookie +} - v.DoNotPropagateMask = xgb.Get16(buf[b:]) - b += 2 +// ChangeProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{cookie} +} - b += 2 // padding +// ChangePropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangePropertyCookie.Check() +func ChangePropertyChecked(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{cookie} +} - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ChangePropertyCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetWindowAttributes -// getWindowAttributesRequest writes a GetWindowAttributes request to a byte slice. -func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for ChangeProperty +// changePropertyRequest writes a ChangeProperty request to a byte slice. +func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 3 // request opcode + buf[b] = 18 // request opcode b += 1 - b += 1 // padding + buf[b] = Mode + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -6687,47 +7354,65 @@ func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], DataLen) + b += 4 + + copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) + b += xgb.Pad(int(((int(DataLen) * int(Format)) / 8))) + return buf } -// DestroyWindowCookie is a cookie used only for DestroyWindow requests. -type DestroyWindowCookie struct { +// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. +type ChangeSaveSetCookie struct { *xgb.Cookie } -// DestroyWindow sends an unchecked request. +// ChangeSaveSet sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { +func ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { cookie := c.NewCookie(false, false) - c.NewRequest(destroyWindowRequest(c, Window), cookie) - return DestroyWindowCookie{cookie} + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} } -// DestroyWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyWindowCookie.Check() -func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie { +// ChangeSaveSetChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check() +func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { cookie := c.NewCookie(true, false) - c.NewRequest(destroyWindowRequest(c, Window), cookie) - return DestroyWindowCookie{cookie} + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroyWindowCookie) Check() error { +func (cook ChangeSaveSetCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyWindow -// destroyWindowRequest writes a DestroyWindow request to a byte slice. -func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { +// Write request to wire for ChangeSaveSet +// changeSaveSetRequest writes a ChangeSaveSet request to a byte slice. +func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 4 // request opcode + buf[b] = 6 // request opcode b += 1 - b += 1 // padding + buf[b] = Mode + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -6738,41 +7423,41 @@ func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { return buf } -// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. -type DestroySubwindowsCookie struct { +// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. +type ChangeWindowAttributesCookie struct { *xgb.Cookie } -// DestroySubwindows sends an unchecked request. +// ChangeWindowAttributes sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { +func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(destroySubwindowsRequest(c, Window), cookie) - return DestroySubwindowsCookie{cookie} + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{cookie} } -// DestroySubwindowsChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroySubwindowsCookie.Check() -func DestroySubwindowsChecked(c *xgb.Conn, Window Window) DestroySubwindowsCookie { +// ChangeWindowAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeWindowAttributesCookie.Check() +func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { cookie := c.NewCookie(true, false) - c.NewRequest(destroySubwindowsRequest(c, Window), cookie) - return DestroySubwindowsCookie{cookie} + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroySubwindowsCookie) Check() error { +func (cook ChangeWindowAttributesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroySubwindows -// destroySubwindowsRequest writes a DestroySubwindows request to a byte slice. -func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for ChangeWindowAttributes +// changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice. +func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 5 // request opcode + buf[b] = 2 // request opcode b += 1 b += 1 // padding @@ -6783,47 +7468,55 @@ func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. -type ChangeSaveSetCookie struct { +// CirculateWindowCookie is a cookie used only for CirculateWindow requests. +type CirculateWindowCookie struct { *xgb.Cookie } -// ChangeSaveSet sends an unchecked request. +// CirculateWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { +func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) - return ChangeSaveSetCookie{cookie} + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{cookie} } -// ChangeSaveSetChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check() -func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { +// CirculateWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CirculateWindowCookie.Check() +func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) - return ChangeSaveSetCookie{cookie} + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeSaveSetCookie) Check() error { +func (cook CirculateWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeSaveSet -// changeSaveSetRequest writes a ChangeSaveSet request to a byte slice. -func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { +// Write request to wire for CirculateWindow +// circulateWindowRequest writes a CirculateWindow request to a byte slice. +func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 6 // request opcode + buf[b] = 13 // request opcode b += 1 - buf[b] = Mode + buf[b] = Direction b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -6835,44 +7528,49 @@ func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { return buf } -// ReparentWindowCookie is a cookie used only for ReparentWindow requests. -type ReparentWindowCookie struct { +// ClearAreaCookie is a cookie used only for ClearArea requests. +type ClearAreaCookie struct { *xgb.Cookie } -// ReparentWindow sends an unchecked request. +// ClearArea sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} +func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} } -// ReparentWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using ReparentWindowCookie.Check() -func ReparentWindowChecked(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { +// ClearAreaChecked sends a checked request. +// If an error occurs, it can be retrieved using ClearAreaCookie.Check() +func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { cookie := c.NewCookie(true, false) - c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ReparentWindowCookie) Check() error { +func (cook ClearAreaCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ReparentWindow -// reparentWindowRequest writes a ReparentWindow request to a byte slice. -func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) []byte { +// Write request to wire for ClearArea +// clearAreaRequest writes a ClearArea request to a byte slice. +func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { size := 16 b := 0 buf := make([]byte, size) - buf[b] = 7 // request opcode + buf[b] = 61 // request opcode b += 1 - b += 1 // padding + if Exposures { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -6880,53 +7578,56 @@ func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Parent)) - b += 4 - xgb.Put16(buf[b:], uint16(X)) b += 2 xgb.Put16(buf[b:], uint16(Y)) b += 2 + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + return buf } -// MapWindowCookie is a cookie used only for MapWindow requests. -type MapWindowCookie struct { +// CloseFontCookie is a cookie used only for CloseFont requests. +type CloseFontCookie struct { *xgb.Cookie } -// MapWindow sends an unchecked request. +// CloseFont sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { +func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { cookie := c.NewCookie(false, false) - c.NewRequest(mapWindowRequest(c, Window), cookie) - return MapWindowCookie{cookie} + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{cookie} } -// MapWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using MapWindowCookie.Check() -func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie { +// CloseFontChecked sends a checked request. +// If an error occurs, it can be retrieved using CloseFontCookie.Check() +func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie { cookie := c.NewCookie(true, false) - c.NewRequest(mapWindowRequest(c, Window), cookie) - return MapWindowCookie{cookie} + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook MapWindowCookie) Check() error { +func (cook CloseFontCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for MapWindow -// mapWindowRequest writes a MapWindow request to a byte slice. -func mapWindowRequest(c *xgb.Conn, Window Window) []byte { +// Write request to wire for CloseFont +// closeFontRequest writes a CloseFont request to a byte slice. +func closeFontRequest(c *xgb.Conn, Font Font) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 8 // request opcode + buf[b] = 46 // request opcode b += 1 b += 1 // padding @@ -6934,47 +7635,47 @@ func mapWindowRequest(c *xgb.Conn, Window Window) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Font)) b += 4 return buf } -// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. -type MapSubwindowsCookie struct { +// ConfigureWindowCookie is a cookie used only for ConfigureWindow requests. +type ConfigureWindowCookie struct { *xgb.Cookie } -// MapSubwindows sends an unchecked request. +// ConfigureWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { +func ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { cookie := c.NewCookie(false, false) - c.NewRequest(mapSubwindowsRequest(c, Window), cookie) - return MapSubwindowsCookie{cookie} + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{cookie} } -// MapSubwindowsChecked sends a checked request. -// If an error occurs, it can be retrieved using MapSubwindowsCookie.Check() -func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie { +// ConfigureWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using ConfigureWindowCookie.Check() +func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { cookie := c.NewCookie(true, false) - c.NewRequest(mapSubwindowsRequest(c, Window), cookie) - return MapSubwindowsCookie{cookie} + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook MapSubwindowsCookie) Check() error { +func (cook ConfigureWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for MapSubwindows -// mapSubwindowsRequest writes a MapSubwindows request to a byte slice. -func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for ConfigureWindow +// configureWindowRequest writes a ConfigureWindow request to a byte slice. +func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { + size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 9 // request opcode + buf[b] = 12 // request opcode b += 1 b += 1 // padding @@ -6985,44 +7686,55 @@ func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put16(buf[b:], ValueMask) + b += 2 + + b += 2 // padding + + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + return buf } -// UnmapWindowCookie is a cookie used only for UnmapWindow requests. -type UnmapWindowCookie struct { +// ConvertSelectionCookie is a cookie used only for ConvertSelection requests. +type ConvertSelectionCookie struct { *xgb.Cookie } -// UnmapWindow sends an unchecked request. +// ConvertSelection sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { +func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { cookie := c.NewCookie(false, false) - c.NewRequest(unmapWindowRequest(c, Window), cookie) - return UnmapWindowCookie{cookie} + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{cookie} } -// UnmapWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using UnmapWindowCookie.Check() -func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { +// ConvertSelectionChecked sends a checked request. +// If an error occurs, it can be retrieved using ConvertSelectionCookie.Check() +func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { cookie := c.NewCookie(true, false) - c.NewRequest(unmapWindowRequest(c, Window), cookie) - return UnmapWindowCookie{cookie} + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UnmapWindowCookie) Check() error { +func (cook ConvertSelectionCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UnmapWindow -// unmapWindowRequest writes a UnmapWindow request to a byte slice. -func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for ConvertSelection +// convertSelectionRequest writes a ConvertSelection request to a byte slice. +func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { + size := 24 b := 0 buf := make([]byte, size) - buf[b] = 10 // request opcode + buf[b] = 24 // request opcode b += 1 b += 1 // padding @@ -7030,47 +7742,59 @@ func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Requestor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) b += 4 return buf } -// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. -type UnmapSubwindowsCookie struct { +// CopyAreaCookie is a cookie used only for CopyArea requests. +type CopyAreaCookie struct { *xgb.Cookie } -// UnmapSubwindows sends an unchecked request. +// CopyArea sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { +func CopyArea(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { cookie := c.NewCookie(false, false) - c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) - return UnmapSubwindowsCookie{cookie} + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{cookie} } -// UnmapSubwindowsChecked sends a checked request. -// If an error occurs, it can be retrieved using UnmapSubwindowsCookie.Check() -func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { +// CopyAreaChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyAreaCookie.Check() +func CopyAreaChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { cookie := c.NewCookie(true, false) - c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) - return UnmapSubwindowsCookie{cookie} + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UnmapSubwindowsCookie) Check() error { +func (cook CopyAreaCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UnmapSubwindows -// unmapSubwindowsRequest writes a UnmapSubwindows request to a byte slice. -func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for CopyArea +// copyAreaRequest writes a CopyArea request to a byte slice. +func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { + size := 28 b := 0 buf := make([]byte, size) - buf[b] = 11 // request opcode + buf[b] = 62 // request opcode b += 1 b += 1 // padding @@ -7078,47 +7802,71 @@ func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(SrcDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + return buf } -// ConfigureWindowCookie is a cookie used only for ConfigureWindow requests. -type ConfigureWindowCookie struct { +// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. +type CopyColormapAndFreeCookie struct { *xgb.Cookie } -// ConfigureWindow sends an unchecked request. +// CopyColormapAndFree sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { +func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { cookie := c.NewCookie(false, false) - c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{cookie} + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} } -// ConfigureWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using ConfigureWindowCookie.Check() -func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { +// CopyColormapAndFreeChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check() +func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { cookie := c.NewCookie(true, false) - c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{cookie} + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ConfigureWindowCookie) Check() error { +func (cook CopyColormapAndFreeCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ConfigureWindow -// configureWindowRequest writes a ConfigureWindow request to a byte slice. -func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { - size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for CopyColormapAndFree +// copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice. +func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 12 // request opcode + buf[b] = 80 // request opcode b += 1 b += 1 // padding @@ -7126,522 +7874,549 @@ func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueL xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Mid)) b += 4 - xgb.Put16(buf[b:], ValueMask) - b += 2 - - b += 2 // padding - - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(SrcCmap)) + b += 4 return buf } -// CirculateWindowCookie is a cookie used only for CirculateWindow requests. -type CirculateWindowCookie struct { +// CopyGCCookie is a cookie used only for CopyGC requests. +type CopyGCCookie struct { *xgb.Cookie } -// CirculateWindow sends an unchecked request. +// CopyGC sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { +func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { cookie := c.NewCookie(false, false) - c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) - return CirculateWindowCookie{cookie} + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} } -// CirculateWindowChecked sends a checked request. -// If an error occurs, it can be retrieved using CirculateWindowCookie.Check() -func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { +// CopyGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyGCCookie.Check() +func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { cookie := c.NewCookie(true, false) - c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) - return CirculateWindowCookie{cookie} + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CirculateWindowCookie) Check() error { +func (cook CopyGCCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CirculateWindow -// circulateWindowRequest writes a CirculateWindow request to a byte slice. -func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { - size := 8 +// Write request to wire for CopyGC +// copyGCRequest writes a CopyGC request to a byte slice. +func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 13 // request opcode + buf[b] = 57 // request opcode b += 1 - buf[b] = Direction - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(SrcGc)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstGc)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) b += 4 return buf } -// GetGeometryCookie is a cookie used only for GetGeometry requests. -type GetGeometryCookie struct { +// CopyPlaneCookie is a cookie used only for CopyPlane requests. +type CopyPlaneCookie struct { *xgb.Cookie } -// GetGeometry sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetGeometryCookie.Reply() -func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getGeometryRequest(c, Drawable), cookie) - return GetGeometryCookie{cookie} -} - -// GetGeometryUnchecked sends an unchecked request. +// CopyPlane sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetGeometryUnchecked(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getGeometryRequest(c, Drawable), cookie) - return GetGeometryCookie{cookie} +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 { + cookie := c.NewCookie(false, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} } -// GetGeometryReply represents the data returned from a GetGeometry request. -type GetGeometryReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Depth byte - Root Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - // padding: 2 bytes +// CopyPlaneChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyPlaneCookie.Check() +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 { + cookie := c.NewCookie(true, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} } -// Reply blocks and returns the reply data for a GetGeometry request. -func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getGeometryReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CopyPlaneCookie) Check() error { + return cook.Cookie.Check() } -// getGeometryReply reads a byte slice into a GetGeometryReply value. -func getGeometryReply(buf []byte) *GetGeometryReply { - v := new(GetGeometryReply) - b := 1 // skip reply determinant +// Write request to wire for CopyPlane +// copyPlaneRequest writes a CopyPlane request to a byte slice. +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 { + size := 32 + b := 0 + buf := make([]byte, size) - v.Depth = buf[b] + buf[b] = 63 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(SrcDrawable)) b += 4 - v.Root = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(DstDrawable)) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - v.Y = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 - v.Width = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - v.Height = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(DstX)) b += 2 - v.BorderWidth = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(DstY)) b += 2 - b += 2 // padding - - return v -} - -// Write request to wire for GetGeometry -// getGeometryRequest writes a GetGeometry request to a byte slice. -func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 14 // request opcode - b += 1 - - b += 1 // padding + xgb.Put16(buf[b:], Width) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Height) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], BitPlane) b += 4 return buf } -// QueryTreeCookie is a cookie used only for QueryTree requests. -type QueryTreeCookie struct { +// CreateColormapCookie is a cookie used only for CreateColormap requests. +type CreateColormapCookie struct { *xgb.Cookie } -// QueryTree sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryTreeCookie.Reply() -func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(queryTreeRequest(c, Window), cookie) - return QueryTreeCookie{cookie} -} - -// QueryTreeUnchecked sends an unchecked request. +// CreateColormap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryTreeUnchecked(c *xgb.Conn, Window Window) QueryTreeCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryTreeRequest(c, Window), cookie) - return QueryTreeCookie{cookie} -} - -// QueryTreeReply represents the data returned from a QueryTree request. -type QueryTreeReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Root Window - Parent Window - ChildrenLen uint16 - // padding: 14 bytes - Children []Window // size: xgb.Pad((int(ChildrenLen) * 4)) +func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} } -// Reply blocks and returns the reply data for a QueryTree request. -func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryTreeReply(buf), nil +// CreateColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateColormapCookie.Check() +func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} } -// queryTreeReply reads a byte slice into a QueryTreeReply value. -func queryTreeReply(buf []byte) *QueryTreeReply { - v := new(QueryTreeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Parent = Window(xgb.Get32(buf[b:])) - b += 4 - - v.ChildrenLen = xgb.Get16(buf[b:]) - b += 2 - - b += 14 // padding - - v.Children = make([]Window, v.ChildrenLen) - for i := 0; i < int(v.ChildrenLen); i++ { - v.Children[i] = Window(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateColormapCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryTree -// queryTreeRequest writes a QueryTree request to a byte slice. -func queryTreeRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for CreateColormap +// createColormapRequest writes a CreateColormap request to a byte slice. +func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 15 // request opcode + buf[b] = 78 // request opcode b += 1 - b += 1 // padding + buf[b] = Alloc + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Mid)) + b += 4 + xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + return buf } -// InternAtomCookie is a cookie used only for InternAtom requests. -type InternAtomCookie struct { +// CreateCursorCookie is a cookie used only for CreateCursor requests. +type CreateCursorCookie struct { *xgb.Cookie } -// InternAtom sends a checked request. -// If an error occurs, it will be returned with the reply by calling InternAtomCookie.Reply() -func InternAtom(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) - return InternAtomCookie{cookie} -} - -// InternAtomUnchecked sends an unchecked request. +// CreateCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) - return InternAtomCookie{cookie} +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 { + cookie := c.NewCookie(false, false) + c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) + return CreateCursorCookie{cookie} } -// InternAtomReply represents the data returned from a InternAtom request. -type InternAtomReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Atom Atom +// CreateCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCursorCookie.Check() +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 { + cookie := c.NewCookie(true, false) + c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) + return CreateCursorCookie{cookie} } -// Reply blocks and returns the reply data for a InternAtom request. -func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return internAtomReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateCursorCookie) Check() error { + return cook.Cookie.Check() } -// internAtomReply reads a byte slice into a InternAtomReply value. -func internAtomReply(buf []byte) *InternAtomReply { - v := new(InternAtomReply) - b := 1 // skip reply determinant +// Write request to wire for CreateCursor +// createCursorRequest writes a CreateCursor request to a byte slice. +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 { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 93 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Cid)) b += 4 - v.Atom = Atom(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Source)) b += 4 - return v + xgb.Put32(buf[b:], uint32(Mask)) + b += 4 + + xgb.Put16(buf[b:], ForeRed) + b += 2 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + xgb.Put16(buf[b:], X) + b += 2 + + xgb.Put16(buf[b:], Y) + b += 2 + + return buf } -// Write request to wire for InternAtom -// internAtomRequest writes a InternAtom request to a byte slice. -func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +// CreateGCCookie is a cookie used only for CreateGC requests. +type CreateGCCookie struct { + *xgb.Cookie +} + +// CreateGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +// CreateGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGCCookie.Check() +func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGC +// createGCRequest writes a CreateGC request to a byte slice. +func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 16 // request opcode + buf[b] = 55 // request opcode b += 1 - if OnlyIfExists { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], NameLen) - b += 2 + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 - b += 2 // padding + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// GetAtomNameCookie is a cookie used only for GetAtomName requests. -type GetAtomNameCookie struct { +// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. +type CreateGlyphCursorCookie struct { *xgb.Cookie } -// GetAtomName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetAtomNameCookie.Reply() -func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getAtomNameRequest(c, Atom), cookie) - return GetAtomNameCookie{cookie} -} - -// GetAtomNameUnchecked sends an unchecked request. +// CreateGlyphCursor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getAtomNameRequest(c, Atom), cookie) - return GetAtomNameCookie{cookie} +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 { + cookie := c.NewCookie(false, false) + c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return CreateGlyphCursorCookie{cookie} } -// GetAtomNameReply represents the data returned from a GetAtomName request. -type GetAtomNameReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NameLen uint16 - // padding: 22 bytes - Name string // size: xgb.Pad((int(NameLen) * 1)) +// CreateGlyphCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGlyphCursorCookie.Check() +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 { + cookie := c.NewCookie(true, false) + c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return CreateGlyphCursorCookie{cookie} } -// Reply blocks and returns the reply data for a GetAtomName request. -func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getAtomNameReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreateGlyphCursorCookie) Check() error { + return cook.Cookie.Check() } -// getAtomNameReply reads a byte slice into a GetAtomNameReply value. -func getAtomNameReply(buf []byte) *GetAtomNameReply { - v := new(GetAtomNameReply) - b := 1 // skip reply determinant +// Write request to wire for CreateGlyphCursor +// createGlyphCursorRequest writes a CreateGlyphCursor request to a byte slice. +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 { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 94 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(SourceFont)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFont)) + b += 4 + + xgb.Put16(buf[b:], SourceChar) + b += 2 + + xgb.Put16(buf[b:], MaskChar) + b += 2 + + xgb.Put16(buf[b:], ForeRed) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], ForeGreen) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], ForeBlue) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + xgb.Put16(buf[b:], BackRed) + b += 2 - v.NameLen = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], BackGreen) b += 2 - b += 22 // padding + xgb.Put16(buf[b:], BackBlue) + b += 2 - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) - } + return buf +} - return v +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. +type CreatePixmapCookie struct { + *xgb.Cookie } -// Write request to wire for GetAtomName -// getAtomNameRequest writes a GetAtomName request to a byte slice. -func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { - size := 8 +// CreatePixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +// CreatePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() +func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CreatePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePixmap +// createPixmapRequest writes a CreatePixmap request to a byte slice. +func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 17 // request opcode + buf[b] = 53 // request opcode b += 1 - b += 1 // padding + buf[b] = Depth + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Atom)) + xgb.Put32(buf[b:], uint32(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + return buf } -// ChangePropertyCookie is a cookie used only for ChangeProperty requests. -type ChangePropertyCookie struct { +// CreateWindowCookie is a cookie used only for CreateWindow requests. +type CreateWindowCookie struct { *xgb.Cookie } -// ChangeProperty sends an unchecked request. +// CreateWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { +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 { cookie := c.NewCookie(false, false) - c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} + c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) + return CreateWindowCookie{cookie} } -// ChangePropertyChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangePropertyCookie.Check() -func ChangePropertyChecked(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { +// CreateWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateWindowCookie.Check() +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 { cookie := c.NewCookie(true, false) - c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} + c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) + return CreateWindowCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangePropertyCookie) Check() error { +func (cook CreateWindowCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeProperty -// changePropertyRequest writes a ChangeProperty request to a byte slice. -func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { - size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) +// Write request to wire for CreateWindow +// createWindowRequest writes a CreateWindow request to a byte slice. +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 { + size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) - buf[b] = 18 // request opcode + buf[b] = 1 // request opcode b += 1 - buf[b] = Mode + buf[b] = Depth b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Wid)) b += 4 - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Parent)) b += 4 - xgb.Put32(buf[b:], uint32(Type)) - b += 4 + xgb.Put16(buf[b:], uint16(X)) + b += 2 - buf[b] = Format - b += 1 + xgb.Put16(buf[b:], uint16(Y)) + b += 2 - b += 3 // padding + xgb.Put16(buf[b:], Width) + b += 2 - xgb.Put32(buf[b:], DataLen) + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], BorderWidth) + b += 2 + + xgb.Put16(buf[b:], Class) + b += 2 + + xgb.Put32(buf[b:], uint32(Visual)) b += 4 - copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) - b += xgb.Pad(int(((int(DataLen) * int(Format)) / 8))) + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) return buf } @@ -7697,248 +8472,244 @@ func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { return buf } -// GetPropertyCookie is a cookie used only for GetProperty requests. -type GetPropertyCookie struct { +// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. +type DestroySubwindowsCookie struct { *xgb.Cookie } -// GetProperty sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyCookie.Reply() -func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} +// DestroySubwindows sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} } -// GetPropertyUnchecked sends an unchecked request. +// DestroySubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroySubwindowsCookie.Check() +func DestroySubwindowsChecked(c *xgb.Conn, Window Window) DestroySubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DestroySubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroySubwindows +// destroySubwindowsRequest writes a DestroySubwindows request to a byte slice. +func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 5 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// DestroyWindowCookie is a cookie used only for DestroyWindow requests. +type DestroyWindowCookie struct { + *xgb.Cookie +} + +// DestroyWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} +func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} } -// GetPropertyReply represents the data returned from a GetProperty request. -type GetPropertyReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Format byte - Type Atom - BytesAfter uint32 - ValueLen uint32 - // padding: 12 bytes - Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1)) +// DestroyWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyWindowCookie.Check() +func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} } -// Reply blocks and returns the reply data for a GetProperty request. -func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPropertyReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DestroyWindowCookie) Check() error { + return cook.Cookie.Check() } -// getPropertyReply reads a byte slice into a GetPropertyReply value. -func getPropertyReply(buf []byte) *GetPropertyReply { - v := new(GetPropertyReply) - b := 1 // skip reply determinant +// Write request to wire for DestroyWindow +// destroyWindowRequest writes a DestroyWindow request to a byte slice. +func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) - v.Format = buf[b] + buf[b] = 4 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + b += 1 // padding - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 - v.Type = Atom(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - v.BytesAfter = xgb.Get32(buf[b:]) - b += 4 + return buf +} - v.ValueLen = xgb.Get32(buf[b:]) - b += 4 +// FillPolyCookie is a cookie used only for FillPoly requests. +type FillPolyCookie struct { + *xgb.Cookie +} - b += 12 // padding +// FillPoly sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FillPoly(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{cookie} +} - v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) - copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) - b += xgb.Pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) +// FillPolyChecked sends a checked request. +// If an error occurs, it can be retrieved using FillPolyCookie.Check() +func FillPolyChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{cookie} +} - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FillPolyCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetProperty -// getPropertyRequest writes a GetProperty request to a byte slice. -func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { - size := 24 +// Write request to wire for FillPoly +// fillPolyRequest writes a FillPoly request to a byte slice. +func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 20 // request opcode + buf[b] = 69 // request opcode b += 1 - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put32(buf[b:], uint32(Type)) - b += 4 + buf[b] = Shape + b += 1 - xgb.Put32(buf[b:], LongOffset) - b += 4 + buf[b] = CoordinateMode + b += 1 - xgb.Put32(buf[b:], LongLength) - b += 4 + b += 2 // padding + + b += PointListBytes(buf[b:], Points) return buf } -// ListPropertiesCookie is a cookie used only for ListProperties requests. -type ListPropertiesCookie struct { +// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. +type ForceScreenSaverCookie struct { *xgb.Cookie } -// ListProperties sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() -func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} -} - -// ListPropertiesUnchecked sends an unchecked request. +// ForceScreenSaver sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} -} - -// ListPropertiesReply represents the data returned from a ListProperties request. -type ListPropertiesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - AtomsLen uint16 - // padding: 22 bytes - Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) +func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} } -// Reply blocks and returns the reply data for a ListProperties request. -func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listPropertiesReply(buf), nil +// ForceScreenSaverChecked sends a checked request. +// If an error occurs, it can be retrieved using ForceScreenSaverCookie.Check() +func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} } -// listPropertiesReply reads a byte slice into a ListPropertiesReply value. -func listPropertiesReply(buf []byte) *ListPropertiesReply { - v := new(ListPropertiesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.AtomsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Atoms = make([]Atom, v.AtomsLen) - for i := 0; i < int(v.AtomsLen); i++ { - v.Atoms[i] = Atom(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ForceScreenSaverCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for ListProperties -// listPropertiesRequest writes a ListProperties request to a byte slice. -func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for ForceScreenSaver +// forceScreenSaverRequest writes a ForceScreenSaver request to a byte slice. +func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 21 // request opcode + buf[b] = 115 // request opcode b += 1 - b += 1 // padding + buf[b] = Mode + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - return buf } -// SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests. -type SetSelectionOwnerCookie struct { +// FreeColormapCookie is a cookie used only for FreeColormap requests. +type FreeColormapCookie struct { *xgb.Cookie } -// SetSelectionOwner sends an unchecked request. +// FreeColormap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetSelectionOwner(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { +func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} } -// SetSelectionOwnerChecked sends a checked request. -// If an error occurs, it can be retrieved using SetSelectionOwnerCookie.Check() -func SetSelectionOwnerChecked(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { +// FreeColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeColormapCookie.Check() +func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetSelectionOwnerCookie) Check() error { +func (cook FreeColormapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetSelectionOwner -// setSelectionOwnerRequest writes a SetSelectionOwner request to a byte slice. -func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) []byte { - size := 16 +// Write request to wire for FreeColormap +// freeColormapRequest writes a FreeColormap request to a byte slice. +func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 22 // request opcode + buf[b] = 79 // request opcode b += 1 b += 1 // padding @@ -7946,86 +8717,104 @@ func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Ti xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Owner)) - b += 4 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 return buf } -// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. -type GetSelectionOwnerCookie struct { +// FreeColorsCookie is a cookie used only for FreeColors requests. +type FreeColorsCookie struct { *xgb.Cookie } -// GetSelectionOwner sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply() -func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -// GetSelectionOwnerUnchecked sends an unchecked request. +// FreeColors sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -// GetSelectionOwnerReply represents the data returned from a GetSelectionOwner request. -type GetSelectionOwnerReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Owner Window +func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} } -// Reply blocks and returns the reply data for a GetSelectionOwner request. -func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSelectionOwnerReply(buf), nil +// FreeColorsChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeColorsCookie.Check() +func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} } -// getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. -func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { - v := new(GetSelectionOwnerReply) - b := 1 // skip reply determinant +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FreeColorsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeColors +// freeColorsRequest writes a FreeColors request to a byte slice. +func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 88 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 - v.Owner = Window(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], PlaneMask) b += 4 - return v + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf } -// Write request to wire for GetSelectionOwner -// getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice. -func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { +// FreeCursorCookie is a cookie used only for FreeCursor requests. +type FreeCursorCookie struct { + *xgb.Cookie +} + +// FreeCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func FreeCursor(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeCursorRequest(c, Cursor), cookie) + return FreeCursorCookie{cookie} +} + +// FreeCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeCursorCookie.Check() +func FreeCursorChecked(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeCursorRequest(c, Cursor), cookie) + return FreeCursorCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook FreeCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeCursor +// freeCursorRequest writes a FreeCursor request to a byte slice. +func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 23 // request opcode + buf[b] = 95 // request opcode b += 1 b += 1 // padding @@ -8033,47 +8822,47 @@ func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Selection)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 return buf } -// ConvertSelectionCookie is a cookie used only for ConvertSelection requests. -type ConvertSelectionCookie struct { +// FreeGCCookie is a cookie used only for FreeGC requests. +type FreeGCCookie struct { *xgb.Cookie } -// ConvertSelection sends an unchecked request. +// FreeGC sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { +func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { cookie := c.NewCookie(false, false) - c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{cookie} + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{cookie} } -// ConvertSelectionChecked sends a checked request. -// If an error occurs, it can be retrieved using ConvertSelectionCookie.Check() -func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { +// FreeGCChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGCCookie.Check() +func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie { cookie := c.NewCookie(true, false) - c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{cookie} + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ConvertSelectionCookie) Check() error { +func (cook FreeGCCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ConvertSelection -// convertSelectionRequest writes a ConvertSelection request to a byte slice. -func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { - size := 24 +// Write request to wire for FreeGC +// freeGCRequest writes a FreeGC request to a byte slice. +func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 24 // request opcode + buf[b] = 60 // request opcode b += 1 b += 1 // padding @@ -8081,113 +8870,93 @@ func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Targ xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Requestor)) - b += 4 - - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 - - xgb.Put32(buf[b:], uint32(Target)) - b += 4 - - xgb.Put32(buf[b:], uint32(Property)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 return buf } -// SendEventCookie is a cookie used only for SendEvent requests. -type SendEventCookie struct { +// FreePixmapCookie is a cookie used only for FreePixmap requests. +type FreePixmapCookie struct { *xgb.Cookie } -// SendEvent sends an unchecked request. +// FreePixmap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SendEvent(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { +func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { cookie := c.NewCookie(false, false) - c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) - return SendEventCookie{cookie} + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} } -// SendEventChecked sends a checked request. -// If an error occurs, it can be retrieved using SendEventCookie.Check() -func SendEventChecked(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { +// FreePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using FreePixmapCookie.Check() +func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { cookie := c.NewCookie(true, false) - c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) - return SendEventCookie{cookie} + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SendEventCookie) Check() error { +func (cook FreePixmapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SendEvent -// sendEventRequest writes a SendEvent request to a byte slice. -func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte { - size := 44 +// Write request to wire for FreePixmap +// freePixmapRequest writes a FreePixmap request to a byte slice. +func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 25 // request opcode + buf[b] = 54 // request opcode b += 1 - if Propagate { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Destination)) - b += 4 - - xgb.Put32(buf[b:], EventMask) + xgb.Put32(buf[b:], uint32(Pixmap)) b += 4 - copy(buf[b:], Event[:32]) - b += xgb.Pad(int(32)) - return buf } -// GrabPointerCookie is a cookie used only for GrabPointer requests. -type GrabPointerCookie struct { +// GetAtomNameCookie is a cookie used only for GetAtomName requests. +type GetAtomNameCookie struct { *xgb.Cookie } -// GrabPointer sends a checked request. -// If an error occurs, it will be returned with the reply by calling GrabPointerCookie.Reply() -func GrabPointer(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { +// GetAtomName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetAtomNameCookie.Reply() +func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie { cookie := c.NewCookie(true, true) - c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) - return GrabPointerCookie{cookie} + c.NewRequest(getAtomNameRequest(c, Atom), cookie) + return GetAtomNameCookie{cookie} } -// GrabPointerUnchecked sends an unchecked request. +// GetAtomNameUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabPointerUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { +func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie { cookie := c.NewCookie(false, true) - c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) - return GrabPointerCookie{cookie} + c.NewRequest(getAtomNameRequest(c, Atom), cookie) + return GetAtomNameCookie{cookie} } -// GrabPointerReply represents the data returned from a GrabPointer request. -type GrabPointerReply struct { +// GetAtomNameReply represents the data returned from a GetAtomName request. +type GetAtomNameReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - Status byte + // padding: 1 bytes + NameLen uint16 + // padding: 22 bytes + Name string // size: xgb.Pad((int(NameLen) * 1)) } -// Reply blocks and returns the reply data for a GrabPointer request. -func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { +// Reply blocks and returns the reply data for a GetAtomName request. +func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8195,105 +8964,45 @@ func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { if buf == nil { return nil, nil } - return grabPointerReply(buf), nil -} - -// grabPointerReply reads a byte slice into a GrabPointerReply value. -func grabPointerReply(buf []byte) *GrabPointerReply { - v := new(GrabPointerReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - return v + return getAtomNameReply(buf), nil } -// Write request to wire for GrabPointer -// grabPointerRequest writes a GrabPointer request to a byte slice. -func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 26 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], EventMask) - b += 2 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 +// getAtomNameReply reads a byte slice into a GetAtomNameReply value. +func getAtomNameReply(buf []byte) *GetAtomNameReply { + v := new(GetAtomNameReply) + b := 1 // skip reply determinant - xgb.Put32(buf[b:], uint32(ConfineTo)) - b += 4 + b += 1 // padding - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 - xgb.Put32(buf[b:], uint32(Time)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} - -// UngrabPointerCookie is a cookie used only for UngrabPointer requests. -type UngrabPointerCookie struct { - *xgb.Cookie -} + v.NameLen = xgb.Get16(buf[b:]) + b += 2 -// UngrabPointer sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabPointerRequest(c, Time), cookie) - return UngrabPointerCookie{cookie} -} + b += 22 // padding -// UngrabPointerChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabPointerCookie.Check() -func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabPointerRequest(c, Time), cookie) - return UngrabPointerCookie{cookie} -} + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UngrabPointerCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for UngrabPointer -// ungrabPointerRequest writes a UngrabPointer request to a byte slice. -func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { +// Write request to wire for GetAtomName +// getAtomNameRequest writes a GetAtomName request to a byte slice. +func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 27 // request opcode + buf[b] = 17 // request opcode b += 1 b += 1 // padding @@ -8301,177 +9010,188 @@ func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Atom)) b += 4 return buf } -// GrabButtonCookie is a cookie used only for GrabButton requests. -type GrabButtonCookie struct { +// GetFontPathCookie is a cookie used only for GetFontPath requests. +type GetFontPathCookie struct { *xgb.Cookie } -// GrabButton sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabButton(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) - return GrabButtonCookie{cookie} +// GetFontPath sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFontPathCookie.Reply() +func GetFontPath(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} } -// GrabButtonChecked sends a checked request. -// If an error occurs, it can be retrieved using GrabButtonCookie.Check() -func GrabButtonChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) - return GrabButtonCookie{cookie} +// GetFontPathUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook GrabButtonCookie) Check() error { - return cook.Cookie.Check() +// GetFontPathReply represents the data returned from a GetFontPath request. +type GetFontPathReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + PathLen uint16 + // padding: 22 bytes + Path []Str // size: StrListSize(Path) } -// Write request to wire for GrabButton -// grabButtonRequest writes a GrabButton request to a byte slice. -func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetFontPath request. +func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFontPathReply(buf), nil +} - buf[b] = 28 // request opcode - b += 1 +// getFontPathReply reads a byte slice into a GetFontPathReply value. +func getFontPathReply(buf []byte) *GetFontPathReply { + v := new(GetFontPathReply) + b := 1 // skip reply determinant - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], EventMask) + v.PathLen = xgb.Get16(buf[b:]) b += 2 - buf[b] = PointerMode - b += 1 + b += 22 // padding - buf[b] = KeyboardMode - b += 1 + v.Path = make([]Str, v.PathLen) + b += StrReadList(buf[b:], v.Path) - xgb.Put32(buf[b:], uint32(ConfineTo)) - b += 4 + return v +} - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 +// Write request to wire for GetFontPath +// getFontPathRequest writes a GetFontPath request to a byte slice. +func getFontPathRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) - buf[b] = Button + buf[b] = 52 // request opcode b += 1 - b += 1 // padding - - xgb.Put16(buf[b:], Modifiers) + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 return buf } -// UngrabButtonCookie is a cookie used only for UngrabButton requests. -type UngrabButtonCookie struct { +// GetGeometryCookie is a cookie used only for GetGeometry requests. +type GetGeometryCookie struct { *xgb.Cookie } -// UngrabButton sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) - return UngrabButtonCookie{cookie} +// GetGeometry sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGeometryCookie.Reply() +func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGeometryRequest(c, Drawable), cookie) + return GetGeometryCookie{cookie} } -// UngrabButtonChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabButtonCookie.Check() -func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) - return UngrabButtonCookie{cookie} +// GetGeometryUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetGeometryUnchecked(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGeometryRequest(c, Drawable), cookie) + return GetGeometryCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UngrabButtonCookie) Check() error { - return cook.Cookie.Check() +// GetGeometryReply represents the data returned from a GetGeometry request. +type GetGeometryReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Depth byte + Root Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + // padding: 2 bytes } -// Write request to wire for UngrabButton -// ungrabButtonRequest writes a UngrabButton request to a byte slice. -func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetGeometry request. +func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGeometryReply(buf), nil +} - buf[b] = 29 // request opcode - b += 1 +// getGeometryReply reads a byte slice into a GetGeometryReply value. +func getGeometryReply(buf []byte) *GetGeometryReply { + v := new(GetGeometryReply) + b := 1 // skip reply determinant - buf[b] = Button + v.Depth = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], Modifiers) - b += 2 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - b += 2 // padding + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - return buf -} + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 -// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. -type ChangeActivePointerGrabCookie struct { - *xgb.Cookie -} + v.Width = xgb.Get16(buf[b:]) + b += 2 -// ChangeActivePointerGrab sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeActivePointerGrab(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) - return ChangeActivePointerGrabCookie{cookie} -} + v.Height = xgb.Get16(buf[b:]) + b += 2 -// ChangeActivePointerGrabChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeActivePointerGrabCookie.Check() -func ChangeActivePointerGrabChecked(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) - return ChangeActivePointerGrabCookie{cookie} -} + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeActivePointerGrabCookie) Check() error { - return cook.Cookie.Check() + b += 2 // padding + + return v } -// Write request to wire for ChangeActivePointerGrab -// changeActivePointerGrabRequest writes a ChangeActivePointerGrab request to a byte slice. -func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte { - size := 16 +// Write request to wire for GetGeometry +// getGeometryRequest writes a GetGeometry request to a byte slice. +func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 30 // request opcode + buf[b] = 14 // request opcode b += 1 b += 1 // padding @@ -8479,50 +9199,45 @@ func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cursor)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], EventMask) - b += 2 - - b += 2 // padding - return buf } -// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. -type GrabKeyboardCookie struct { +// GetImageCookie is a cookie used only for GetImage requests. +type GetImageCookie struct { *xgb.Cookie } -// GrabKeyboard sends a checked request. -// If an error occurs, it will be returned with the reply by calling GrabKeyboardCookie.Reply() -func GrabKeyboard(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { +// GetImage sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetImageCookie.Reply() +func GetImage(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { cookie := c.NewCookie(true, true) - c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} } -// GrabKeyboardUnchecked sends an unchecked request. +// GetImageUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { +func GetImageUnchecked(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { cookie := c.NewCookie(false, true) - c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} } -// GrabKeyboardReply represents the data returned from a GrabKeyboard request. -type GrabKeyboardReply struct { +// GetImageReply represents the data returned from a GetImage request. +type GetImageReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - Status byte + Depth byte + Visual Visualid + // padding: 20 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Reply blocks and returns the reply data for a GrabKeyboard request. -func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { +// Reply blocks and returns the reply data for a GetImage request. +func (cook GetImageCookie) Reply() (*GetImageReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8530,15 +9245,15 @@ func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { if buf == nil { return nil, nil } - return grabKeyboardReply(buf), nil + return getImageReply(buf), nil } -// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. -func grabKeyboardReply(buf []byte) *GrabKeyboardReply { - v := new(GrabKeyboardReply) +// getImageReply reads a byte slice into a GetImageReply value. +func getImageReply(buf []byte) *GetImageReply { + v := new(GetImageReply) b := 1 // skip reply determinant - v.Status = buf[b] + v.Depth = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -8547,299 +9262,226 @@ func grabKeyboardReply(buf []byte) *GrabKeyboardReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 + v.Visual = Visualid(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + return v } -// Write request to wire for GrabKeyboard -// grabKeyboardRequest writes a GrabKeyboard request to a byte slice. -func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { - size := 16 +// Write request to wire for GetImage +// getImageRequest writes a GetImage request to a byte slice. +func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { + size := 20 b := 0 buf := make([]byte, size) - buf[b] = 31 // request opcode + buf[b] = 73 // request opcode b += 1 - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } + buf[b] = Format b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - b += 2 // padding - - return buf -} - -// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. -type UngrabKeyboardCookie struct { - *xgb.Cookie -} - -// UngrabKeyboard sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) - return UngrabKeyboardCookie{cookie} -} - -// UngrabKeyboardChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabKeyboardCookie.Check() -func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) - return UngrabKeyboardCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UngrabKeyboardCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for UngrabKeyboard -// ungrabKeyboardRequest writes a UngrabKeyboard request to a byte slice. -func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], uint16(X)) + b += 2 - buf[b] = 32 // request opcode - b += 1 + xgb.Put16(buf[b:], uint16(Y)) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], Width) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Height) b += 2 - xgb.Put32(buf[b:], uint32(Time)) + xgb.Put32(buf[b:], PlaneMask) b += 4 return buf } -// GrabKeyCookie is a cookie used only for GrabKey requests. -type GrabKeyCookie struct { +// GetInputFocusCookie is a cookie used only for GetInputFocus requests. +type GetInputFocusCookie struct { *xgb.Cookie } -// GrabKey sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabKey(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) - return GrabKeyCookie{cookie} +// GetInputFocus sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetInputFocusCookie.Reply() +func GetInputFocus(c *xgb.Conn) GetInputFocusCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{cookie} } -// GrabKeyChecked sends a checked request. -// If an error occurs, it can be retrieved using GrabKeyCookie.Check() -func GrabKeyChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) - return GrabKeyCookie{cookie} +// GetInputFocusUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook GrabKeyCookie) Check() error { - return cook.Cookie.Check() +// GetInputFocusReply represents the data returned from a GetInputFocus request. +type GetInputFocusReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + RevertTo byte + Focus Window } -// Write request to wire for GrabKey -// grabKeyRequest writes a GrabKey request to a byte slice. -func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 33 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 +// Reply blocks and returns the reply data for a GetInputFocus request. +func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = byte(Key) - b += 1 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 + if buf == nil { + return nil, nil + } + return getInputFocusReply(buf), nil +} - b += 3 // padding +// getInputFocusReply reads a byte slice into a GetInputFocusReply value. +func getInputFocusReply(buf []byte) *GetInputFocusReply { + v := new(GetInputFocusReply) + b := 1 // skip reply determinant - return buf -} + v.RevertTo = buf[b] + b += 1 -// UngrabKeyCookie is a cookie used only for UngrabKey requests. -type UngrabKeyCookie struct { - *xgb.Cookie -} + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// UngrabKey sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) - return UngrabKeyCookie{cookie} -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// UngrabKeyChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabKeyCookie.Check() -func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) - return UngrabKeyCookie{cookie} -} + v.Focus = Window(xgb.Get32(buf[b:])) + b += 4 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UngrabKeyCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for UngrabKey -// ungrabKeyRequest writes a UngrabKey request to a byte slice. -func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte { - size := 12 +// Write request to wire for GetInputFocus +// getInputFocusRequest writes a GetInputFocus request to a byte slice. +func getInputFocusRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 34 // request opcode - b += 1 - - buf[b] = byte(Key) + buf[b] = 43 // request opcode b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - xgb.Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - return buf } -// AllowEventsCookie is a cookie used only for AllowEvents requests. -type AllowEventsCookie struct { +// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. +type GetKeyboardControlCookie struct { *xgb.Cookie } -// AllowEvents sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllowEvents(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) - return AllowEventsCookie{cookie} +// GetKeyboardControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply() +func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} } -// AllowEventsChecked sends a checked request. -// If an error occurs, it can be retrieved using AllowEventsCookie.Check() -func AllowEventsChecked(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) - return AllowEventsCookie{cookie} +// GetKeyboardControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook AllowEventsCookie) Check() error { - return cook.Cookie.Check() +// GetKeyboardControlReply represents the data returned from a GetKeyboardControl request. +type GetKeyboardControlReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + GlobalAutoRepeat byte + LedMask uint32 + KeyClickPercent byte + BellPercent byte + BellPitch uint16 + BellDuration uint16 + // padding: 2 bytes + AutoRepeats []byte // size: 32 } -// Write request to wire for AllowEvents -// allowEventsRequest writes a AllowEvents request to a byte slice. -func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetKeyboardControl request. +func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getKeyboardControlReply(buf), nil +} - buf[b] = 35 // request opcode - b += 1 +// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. +func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { + v := new(GetKeyboardControlReply) + b := 1 // skip reply determinant - buf[b] = Mode + v.GlobalAutoRepeat = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Time)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - return buf -} + v.LedMask = xgb.Get32(buf[b:]) + b += 4 -// GrabServerCookie is a cookie used only for GrabServer requests. -type GrabServerCookie struct { - *xgb.Cookie -} + v.KeyClickPercent = buf[b] + b += 1 -// GrabServer sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GrabServer(c *xgb.Conn) GrabServerCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(grabServerRequest(c), cookie) - return GrabServerCookie{cookie} -} + v.BellPercent = buf[b] + b += 1 -// GrabServerChecked sends a checked request. -// If an error occurs, it can be retrieved using GrabServerCookie.Check() -func GrabServerChecked(c *xgb.Conn) GrabServerCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(grabServerRequest(c), cookie) - return GrabServerCookie{cookie} -} + v.BellPitch = xgb.Get16(buf[b:]) + b += 2 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook GrabServerCookie) Check() error { - return cook.Cookie.Check() + v.BellDuration = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return v } -// Write request to wire for GrabServer -// grabServerRequest writes a GrabServer request to a byte slice. -func grabServerRequest(c *xgb.Conn) []byte { +// Write request to wire for GetKeyboardControl +// getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice. +func getKeyboardControlRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 36 // request opcode + buf[b] = 103 // request opcode b += 1 b += 1 // padding @@ -8849,88 +9491,130 @@ func grabServerRequest(c *xgb.Conn) []byte { return buf } -// UngrabServerCookie is a cookie used only for UngrabServer requests. -type UngrabServerCookie struct { +// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. +type GetKeyboardMappingCookie struct { *xgb.Cookie } -// UngrabServer sends an unchecked request. +// GetKeyboardMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetKeyboardMappingCookie.Reply() +func GetKeyboardMapping(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) + return GetKeyboardMappingCookie{cookie} +} + +// GetKeyboardMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabServer(c *xgb.Conn) UngrabServerCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabServerRequest(c), cookie) - return UngrabServerCookie{cookie} +func GetKeyboardMappingUnchecked(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) + return GetKeyboardMappingCookie{cookie} } -// UngrabServerChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabServerCookie.Check() -func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabServerRequest(c), cookie) - return UngrabServerCookie{cookie} +// GetKeyboardMappingReply represents the data returned from a GetKeyboardMapping request. +type GetKeyboardMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + KeysymsPerKeycode byte + // padding: 24 bytes + Keysyms []Keysym // size: xgb.Pad((int(Length) * 4)) } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UngrabServerCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a GetKeyboardMapping request. +func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getKeyboardMappingReply(buf), nil } -// Write request to wire for UngrabServer -// ungrabServerRequest writes a UngrabServer request to a byte slice. -func ungrabServerRequest(c *xgb.Conn) []byte { - size := 4 +// getKeyboardMappingReply reads a byte slice into a GetKeyboardMappingReply value. +func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { + v := new(GetKeyboardMappingReply) + b := 1 // skip reply determinant + + v.KeysymsPerKeycode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Keysyms = make([]Keysym, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Keysyms[i] = Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetKeyboardMapping +// getKeyboardMappingRequest writes a GetKeyboardMapping request to a byte slice. +func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 37 // request opcode + buf[b] = 101 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + return buf } -// QueryPointerCookie is a cookie used only for QueryPointer requests. -type QueryPointerCookie struct { +// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. +type GetModifierMappingCookie struct { *xgb.Cookie } -// QueryPointer sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryPointerCookie.Reply() -func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie { +// GetModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetModifierMappingCookie.Reply() +func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryPointerRequest(c, Window), cookie) - return QueryPointerCookie{cookie} + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} } -// QueryPointerUnchecked sends an unchecked request. +// GetModifierMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { +func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryPointerRequest(c, Window), cookie) - return QueryPointerCookie{cookie} + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} } -// QueryPointerReply represents the data returned from a QueryPointer request. -type QueryPointerReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - SameScreen bool - Root Window - Child Window - RootX int16 - RootY int16 - WinX int16 - WinY int16 - Mask uint16 - // padding: 2 bytes +// GetModifierMappingReply represents the data returned from a GetModifierMapping request. +type GetModifierMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + KeycodesPerModifier byte + // padding: 24 bytes + Keycodes []Keycode // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) } -// Reply blocks and returns the reply data for a QueryPointer request. -func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { +// Reply blocks and returns the reply data for a GetModifierMapping request. +func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -8938,19 +9622,15 @@ func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { if buf == nil { return nil, nil } - return queryPointerReply(buf), nil + return getModifierMappingReply(buf), nil } -// queryPointerReply reads a byte slice into a QueryPointerReply value. -func queryPointerReply(buf []byte) *QueryPointerReply { - v := new(QueryPointerReply) +// getModifierMappingReply reads a byte slice into a GetModifierMappingReply value. +func getModifierMappingReply(buf []byte) *GetModifierMappingReply { + v := new(GetModifierMappingReply) b := 1 // skip reply determinant - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } + v.KeycodesPerModifier = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -8959,50 +9639,32 @@ func queryPointerReply(buf []byte) *QueryPointerReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Root = Window(xgb.Get32(buf[b:])) - b += 4 - - v.Child = Window(xgb.Get32(buf[b:])) - b += 4 - - v.RootX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.RootY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.WinX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.WinY = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Mask = xgb.Get16(buf[b:]) - b += 2 + b += 24 // padding - b += 2 // padding + v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) + for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { + v.Keycodes[i] = Keycode(buf[b]) + b += 1 + } + b = xgb.Pad(b) return v } -// Write request to wire for QueryPointer -// queryPointerRequest writes a QueryPointer request to a byte slice. -func queryPointerRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for GetModifierMapping +// getModifierMappingRequest writes a GetModifierMapping request to a byte slice. +func getModifierMappingRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 38 // request opcode + buf[b] = 119 // request opcode b += 1 - b += 1 // padding - + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - return buf } @@ -9100,261 +9762,211 @@ func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Ti return buf } -// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. -type TranslateCoordinatesCookie struct { +// GetPointerControlCookie is a cookie used only for GetPointerControl requests. +type GetPointerControlCookie struct { *xgb.Cookie } -// TranslateCoordinates sends a checked request. -// If an error occurs, it will be returned with the reply by calling TranslateCoordinatesCookie.Reply() -func TranslateCoordinates(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { +// GetPointerControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPointerControlCookie.Reply() +func GetPointerControl(c *xgb.Conn) GetPointerControlCookie { cookie := c.NewCookie(true, true) - c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} } -// TranslateCoordinatesUnchecked sends an unchecked request. +// GetPointerControlUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { +func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { cookie := c.NewCookie(false, true) - c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} } -// TranslateCoordinatesReply represents the data returned from a TranslateCoordinates request. -type TranslateCoordinatesReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - SameScreen bool - Child Window - DstX int16 - DstY int16 +// GetPointerControlReply represents the data returned from a GetPointerControl request. +type GetPointerControlReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + AccelerationNumerator uint16 + AccelerationDenominator uint16 + Threshold uint16 + // padding: 18 bytes } -// Reply blocks and returns the reply data for a TranslateCoordinates request. -func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { +// Reply blocks and returns the reply data for a GetPointerControl request. +func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { buf, err := cook.Cookie.Reply() if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return translateCoordinatesReply(buf), nil -} - -// translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value. -func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { - v := new(TranslateCoordinatesReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Child = Window(xgb.Get32(buf[b:])) - b += 4 - - v.DstX = int16(xgb.Get16(buf[b:])) - b += 2 - - v.DstY = int16(xgb.Get16(buf[b:])) - b += 2 - - return v -} - -// Write request to wire for TranslateCoordinates -// translateCoordinatesRequest writes a TranslateCoordinates request to a byte slice. -func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 40 // request opcode - b += 1 - - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(SrcWindow)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstWindow)) - b += 4 - - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - - return buf -} - -// WarpPointerCookie is a cookie used only for WarpPointer requests. -type WarpPointerCookie struct { - *xgb.Cookie -} - -// WarpPointer sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func WarpPointer(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{cookie} -} - -// WarpPointerChecked sends a checked request. -// If an error occurs, it can be retrieved using WarpPointerCookie.Check() -func WarpPointerChecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook WarpPointerCookie) Check() error { - return cook.Cookie.Check() + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerControlReply(buf), nil } -// Write request to wire for WarpPointer -// warpPointerRequest writes a WarpPointer request to a byte slice. -func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 41 // request opcode - b += 1 +// getPointerControlReply reads a byte slice into a GetPointerControlReply value. +func getPointerControlReply(buf []byte) *GetPointerControlReply { + v := new(GetPointerControlReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(SrcWindow)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstWindow)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], uint16(SrcX)) + v.AccelerationNumerator = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(SrcY)) + v.AccelerationDenominator = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], SrcWidth) + v.Threshold = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], SrcHeight) - b += 2 + b += 18 // padding - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 + return v +} - xgb.Put16(buf[b:], uint16(DstY)) +// Write request to wire for GetPointerControl +// getPointerControlRequest writes a GetPointerControl request to a byte slice. +func getPointerControlRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 106 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 return buf } -// SetInputFocusCookie is a cookie used only for SetInputFocus requests. -type SetInputFocusCookie struct { +// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. +type GetPointerMappingCookie struct { *xgb.Cookie } -// SetInputFocus sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} +// GetPointerMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPointerMappingCookie.Reply() +func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPointerMappingRequest(c), cookie) + return GetPointerMappingCookie{cookie} } -// SetInputFocusChecked sends a checked request. -// If an error occurs, it can be retrieved using SetInputFocusCookie.Check() -func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} +// GetPointerMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPointerMappingUnchecked(c *xgb.Conn) GetPointerMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPointerMappingRequest(c), cookie) + return GetPointerMappingCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetInputFocusCookie) Check() error { - return cook.Cookie.Check() +// GetPointerMappingReply represents the data returned from a GetPointerMapping request. +type GetPointerMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + MapLen byte + // padding: 24 bytes + Map []byte // size: xgb.Pad((int(MapLen) * 1)) } -// Write request to wire for SetInputFocus -// setInputFocusRequest writes a SetInputFocus request to a byte slice. -func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetPointerMapping request. +func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerMappingReply(buf), nil +} - buf[b] = 42 // request opcode - b += 1 +// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. +func getPointerMappingReply(buf []byte) *GetPointerMappingReply { + v := new(GetPointerMappingReply) + b := 1 // skip reply determinant - buf[b] = RevertTo + v.MapLen = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Focus)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Time)) - b += 4 + b += 24 // padding + + v.Map = make([]byte, v.MapLen) + copy(v.Map[:v.MapLen], buf[b:]) + b += xgb.Pad(int(v.MapLen)) + + return v +} + +// Write request to wire for GetPointerMapping +// getPointerMappingRequest writes a GetPointerMapping request to a byte slice. +func getPointerMappingRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 117 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 return buf } -// GetInputFocusCookie is a cookie used only for GetInputFocus requests. -type GetInputFocusCookie struct { +// GetPropertyCookie is a cookie used only for GetProperty requests. +type GetPropertyCookie struct { *xgb.Cookie } -// GetInputFocus sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetInputFocusCookie.Reply() -func GetInputFocus(c *xgb.Conn) GetInputFocusCookie { +// GetProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyCookie.Reply() +func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getInputFocusRequest(c), cookie) - return GetInputFocusCookie{cookie} + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} } -// GetInputFocusUnchecked sends an unchecked request. +// GetPropertyUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { +func GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getInputFocusRequest(c), cookie) - return GetInputFocusCookie{cookie} + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} } -// GetInputFocusReply represents the data returned from a GetInputFocus request. -type GetInputFocusReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - RevertTo byte - Focus Window +// GetPropertyReply represents the data returned from a GetProperty request. +type GetPropertyReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Format byte + Type Atom + BytesAfter uint32 + ValueLen uint32 + // padding: 12 bytes + Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1)) } -// Reply blocks and returns the reply data for a GetInputFocus request. -func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { +// Reply blocks and returns the reply data for a GetProperty request. +func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9362,15 +9974,15 @@ func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { if buf == nil { return nil, nil } - return getInputFocusReply(buf), nil + return getPropertyReply(buf), nil } -// getInputFocusReply reads a byte slice into a GetInputFocusReply value. -func getInputFocusReply(buf []byte) *GetInputFocusReply { - v := new(GetInputFocusReply) +// getPropertyReply reads a byte slice into a GetPropertyReply value. +func getPropertyReply(buf []byte) *GetPropertyReply { + v := new(GetPropertyReply) b := 1 // skip reply determinant - v.RevertTo = buf[b] + v.Format = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -9379,60 +9991,97 @@ func getInputFocusReply(buf []byte) *GetInputFocusReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Focus = Window(xgb.Get32(buf[b:])) + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.BytesAfter = xgb.Get32(buf[b:]) + b += 4 + + v.ValueLen = xgb.Get32(buf[b:]) b += 4 + b += 12 // padding + + v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) + copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) + b += xgb.Pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) + return v } -// Write request to wire for GetInputFocus -// getInputFocusRequest writes a GetInputFocus request to a byte slice. -func getInputFocusRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GetProperty +// getPropertyRequest writes a GetProperty request to a byte slice. +func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { + size := 24 b := 0 buf := make([]byte, size) - buf[b] = 43 // request opcode + buf[b] = 20 // request opcode + b += 1 + + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + xgb.Put32(buf[b:], LongOffset) + b += 4 + + xgb.Put32(buf[b:], LongLength) + b += 4 + return buf } -// QueryKeymapCookie is a cookie used only for QueryKeymap requests. -type QueryKeymapCookie struct { +// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. +type GetScreenSaverCookie struct { *xgb.Cookie } -// QueryKeymap sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryKeymapCookie.Reply() -func QueryKeymap(c *xgb.Conn) QueryKeymapCookie { +// GetScreenSaver sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenSaverCookie.Reply() +func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryKeymapRequest(c), cookie) - return QueryKeymapCookie{cookie} + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} } -// QueryKeymapUnchecked sends an unchecked request. +// GetScreenSaverUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { +func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryKeymapRequest(c), cookie) - return QueryKeymapCookie{cookie} + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} } -// QueryKeymapReply represents the data returned from a QueryKeymap request. -type QueryKeymapReply struct { +// GetScreenSaverReply represents the data returned from a GetScreenSaver request. +type GetScreenSaverReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Keys []byte // size: 32 + Timeout uint16 + Interval uint16 + PreferBlanking byte + AllowExposures byte + // padding: 18 bytes } -// Reply blocks and returns the reply data for a QueryKeymap request. -func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { +// Reply blocks and returns the reply data for a GetScreenSaver request. +func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9440,12 +10089,12 @@ func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { if buf == nil { return nil, nil } - return queryKeymapReply(buf), nil + return getScreenSaverReply(buf), nil } -// queryKeymapReply reads a byte slice into a QueryKeymapReply value. -func queryKeymapReply(buf []byte) *QueryKeymapReply { - v := new(QueryKeymapReply) +// getScreenSaverReply reads a byte slice into a GetScreenSaverReply value. +func getScreenSaverReply(buf []byte) *GetScreenSaverReply { + v := new(GetScreenSaverReply) b := 1 // skip reply determinant b += 1 // padding @@ -9456,21 +10105,31 @@ func queryKeymapReply(buf []byte) *QueryKeymapReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += xgb.Pad(int(32)) + v.Timeout = xgb.Get16(buf[b:]) + b += 2 + + v.Interval = xgb.Get16(buf[b:]) + b += 2 + + v.PreferBlanking = buf[b] + b += 1 + + v.AllowExposures = buf[b] + b += 1 + + b += 18 // padding return v } -// Write request to wire for QueryKeymap -// queryKeymapRequest writes a QueryKeymap request to a byte slice. -func queryKeymapRequest(c *xgb.Conn) []byte { +// Write request to wire for GetScreenSaver +// getScreenSaverRequest writes a GetScreenSaver request to a byte slice. +func getScreenSaverRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 44 // request opcode + buf[b] = 108 // request opcode b += 1 b += 1 // padding @@ -9480,97 +10139,74 @@ func queryKeymapRequest(c *xgb.Conn) []byte { return buf } -// OpenFontCookie is a cookie used only for OpenFont requests. -type OpenFontCookie struct { +// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. +type GetSelectionOwnerCookie struct { *xgb.Cookie } -// OpenFont sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) - return OpenFontCookie{cookie} +// GetSelectionOwner sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply() +func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} } -// OpenFontChecked sends a checked request. -// If an error occurs, it can be retrieved using OpenFontCookie.Check() -func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) - return OpenFontCookie{cookie} +// GetSelectionOwnerUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook OpenFontCookie) Check() error { - return cook.Cookie.Check() +// GetSelectionOwnerReply represents the data returned from a GetSelectionOwner request. +type GetSelectionOwnerReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Owner Window } -// Write request to wire for OpenFont -// openFontRequest writes a OpenFont request to a byte slice. -func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetSelectionOwner request. +func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionOwnerReply(buf), nil +} - buf[b] = 45 // request opcode - b += 1 +// getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. +func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { + v := new(GetSelectionOwnerReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Fid)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - - return buf -} - -// CloseFontCookie is a cookie used only for CloseFont requests. -type CloseFontCookie struct { - *xgb.Cookie -} - -// CloseFont sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(closeFontRequest(c, Font), cookie) - return CloseFontCookie{cookie} -} - -// CloseFontChecked sends a checked request. -// If an error occurs, it can be retrieved using CloseFontCookie.Check() -func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(closeFontRequest(c, Font), cookie) - return CloseFontCookie{cookie} -} + v.Owner = Window(xgb.Get32(buf[b:])) + b += 4 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CloseFontCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for CloseFont -// closeFontRequest writes a CloseFont request to a byte slice. -func closeFontRequest(c *xgb.Conn, Font Font) []byte { +// Write request to wire for GetSelectionOwner +// getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice. +func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 46 // request opcode + buf[b] = 23 // request opcode b += 1 b += 1 // padding @@ -9578,59 +10214,57 @@ func closeFontRequest(c *xgb.Conn, Font Font) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Font)) + xgb.Put32(buf[b:], uint32(Selection)) b += 4 return buf } -// QueryFontCookie is a cookie used only for QueryFont requests. -type QueryFontCookie struct { +// GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. +type GetWindowAttributesCookie struct { *xgb.Cookie } -// QueryFont sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryFontCookie.Reply() -func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie { +// GetWindowAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowAttributesCookie.Reply() +func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryFontRequest(c, Font), cookie) - return QueryFontCookie{cookie} + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} } -// QueryFontUnchecked sends an unchecked request. +// GetWindowAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { +func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryFontRequest(c, Font), cookie) - return QueryFontCookie{cookie} + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} } -// QueryFontReply represents the data returned from a QueryFont request. -type QueryFontReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MinBounds Charinfo - // padding: 4 bytes - MaxBounds Charinfo - // padding: 4 bytes - MinCharOrByte2 uint16 - MaxCharOrByte2 uint16 - DefaultChar uint16 - PropertiesLen uint16 - DrawDirection byte - MinByte1 byte - MaxByte1 byte - AllCharsExist bool - FontAscent int16 - FontDescent int16 - CharInfosLen uint32 - Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) - CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) +// GetWindowAttributesReply represents the data returned from a GetWindowAttributes request. +type GetWindowAttributesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + BackingStore byte + Visual Visualid + Class uint16 + BitGravity byte + WinGravity byte + BackingPlanes uint32 + BackingPixel uint32 + SaveUnder bool + MapIsInstalled bool + MapState byte + OverrideRedirect bool + Colormap Colormap + AllEventMasks uint32 + YourEventMask uint32 + DoNotPropagateMask uint16 + // padding: 2 bytes } -// Reply blocks and returns the reply data for a QueryFont request. -func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { +// Reply blocks and returns the reply data for a GetWindowAttributes request. +func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9638,86 +10272,90 @@ func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { if buf == nil { return nil, nil } - return queryFontReply(buf), nil + return getWindowAttributesReply(buf), nil } -// queryFontReply reads a byte slice into a QueryFontReply value. -func queryFontReply(buf []byte) *QueryFontReply { - v := new(QueryFontReply) +// getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value. +func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { + v := new(GetWindowAttributesReply) b := 1 // skip reply determinant - b += 1 // padding + v.BackingStore = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.MinBounds = Charinfo{} - b += CharinfoRead(buf[b:], &v.MinBounds) - - b += 4 // padding - - v.MaxBounds = Charinfo{} - b += CharinfoRead(buf[b:], &v.MaxBounds) + b += 4 - b += 4 // padding + v.Visual = Visualid(xgb.Get32(buf[b:])) + b += 4 - v.MinCharOrByte2 = xgb.Get16(buf[b:]) + v.Class = xgb.Get16(buf[b:]) b += 2 - v.MaxCharOrByte2 = xgb.Get16(buf[b:]) - b += 2 + v.BitGravity = buf[b] + b += 1 - v.DefaultChar = xgb.Get16(buf[b:]) - b += 2 + v.WinGravity = buf[b] + b += 1 - v.PropertiesLen = xgb.Get16(buf[b:]) - b += 2 + v.BackingPlanes = xgb.Get32(buf[b:]) + b += 4 - v.DrawDirection = buf[b] + v.BackingPixel = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.SaveUnder = true + } else { + v.SaveUnder = false + } b += 1 - v.MinByte1 = buf[b] + if buf[b] == 1 { + v.MapIsInstalled = true + } else { + v.MapIsInstalled = false + } b += 1 - v.MaxByte1 = buf[b] + v.MapState = buf[b] b += 1 if buf[b] == 1 { - v.AllCharsExist = true + v.OverrideRedirect = true } else { - v.AllCharsExist = false + v.OverrideRedirect = false } b += 1 - v.FontAscent = int16(xgb.Get16(buf[b:])) - b += 2 + v.Colormap = Colormap(xgb.Get32(buf[b:])) + b += 4 - v.FontDescent = int16(xgb.Get16(buf[b:])) - b += 2 + v.AllEventMasks = xgb.Get32(buf[b:]) + b += 4 - v.CharInfosLen = xgb.Get32(buf[b:]) + v.YourEventMask = xgb.Get32(buf[b:]) b += 4 - v.Properties = make([]Fontprop, v.PropertiesLen) - b += FontpropReadList(buf[b:], v.Properties) + v.DoNotPropagateMask = xgb.Get16(buf[b:]) + b += 2 - v.CharInfos = make([]Charinfo, v.CharInfosLen) - b += CharinfoReadList(buf[b:], v.CharInfos) + b += 2 // padding return v } -// Write request to wire for QueryFont -// queryFontRequest writes a QueryFont request to a byte slice. -func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { +// Write request to wire for GetWindowAttributes +// getWindowAttributesRequest writes a GetWindowAttributes request to a byte slice. +func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 47 // request opcode + buf[b] = 3 // request opcode b += 1 b += 1 // padding @@ -9725,264 +10363,185 @@ func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Font)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. -type QueryTextExtentsCookie struct { +// GrabButtonCookie is a cookie used only for GrabButton requests. +type GrabButtonCookie struct { *xgb.Cookie } -// QueryTextExtents sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryTextExtentsCookie.Reply() -func QueryTextExtents(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} -} - -// QueryTextExtentsUnchecked sends an unchecked request. +// GrabButton sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} +func GrabButton(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{cookie} } -// QueryTextExtentsReply represents the data returned from a QueryTextExtents request. -type QueryTextExtentsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - DrawDirection byte - FontAscent int16 - FontDescent int16 - OverallAscent int16 - OverallDescent int16 - OverallWidth int32 - OverallLeft int32 - OverallRight int32 +// GrabButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabButtonCookie.Check() +func GrabButtonChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{cookie} } -// Reply blocks and returns the reply data for a QueryTextExtents request. -func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryTextExtentsReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook GrabButtonCookie) Check() error { + return cook.Cookie.Check() } -// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. -func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { - v := new(QueryTextExtentsReply) - b := 1 // skip reply determinant +// Write request to wire for GrabButton +// grabButtonRequest writes a GrabButton request to a byte slice. +func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { + size := 24 + b := 0 + buf := make([]byte, size) - v.DrawDirection = buf[b] + buf[b] = 28 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 - v.FontAscent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.FontDescent = int16(xgb.Get16(buf[b:])) - b += 2 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 - v.OverallAscent = int16(xgb.Get16(buf[b:])) + xgb.Put16(buf[b:], EventMask) b += 2 - v.OverallDescent = int16(xgb.Get16(buf[b:])) - b += 2 + buf[b] = PointerMode + b += 1 - v.OverallWidth = int32(xgb.Get32(buf[b:])) - b += 4 + buf[b] = KeyboardMode + b += 1 - v.OverallLeft = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(ConfineTo)) b += 4 - v.OverallRight = int32(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 - return v -} - -// Write request to wire for QueryTextExtents -// queryTextExtentsRequest writes a QueryTextExtents request to a byte slice. -func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { - size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 48 // request opcode + buf[b] = Button b += 1 - buf[b] = byte((int(StringLen) & 1)) - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], Modifiers) b += 2 - xgb.Put32(buf[b:], uint32(Font)) - b += 4 - - b += Char2bListBytes(buf[b:], String) - - // skip writing local field: StringLen (2) :: uint16 - return buf } -// ListFontsCookie is a cookie used only for ListFonts requests. -type ListFontsCookie struct { +// GrabKeyCookie is a cookie used only for GrabKey requests. +type GrabKeyCookie struct { *xgb.Cookie } -// ListFonts sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListFontsCookie.Reply() -func ListFonts(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) - return ListFontsCookie{cookie} -} - -// ListFontsUnchecked sends an unchecked request. +// GrabKey sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListFontsUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) - return ListFontsCookie{cookie} -} - -// ListFontsReply represents the data returned from a ListFonts request. -type ListFontsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NamesLen uint16 - // padding: 22 bytes - Names []Str // size: StrListSize(Names) -} - -// Reply blocks and returns the reply data for a ListFonts request. -func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listFontsReply(buf), nil +func GrabKey(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{cookie} } -// listFontsReply reads a byte slice into a ListFontsReply value. -func listFontsReply(buf []byte) *ListFontsReply { - v := new(ListFontsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NamesLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Names = make([]Str, v.NamesLen) - b += StrReadList(buf[b:], v.Names) +// GrabKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabKeyCookie.Check() +func GrabKeyChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{cookie} +} - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook GrabKeyCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for ListFonts -// listFontsRequest writes a ListFonts request to a byte slice. -func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +// Write request to wire for GrabKey +// grabKeyRequest writes a GrabKey request to a byte slice. +func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 49 // request opcode + buf[b] = 33 // request opcode b += 1 - b += 1 // padding + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], MaxNames) - b += 2 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 - xgb.Put16(buf[b:], PatternLen) + xgb.Put16(buf[b:], Modifiers) b += 2 - copy(buf[b:], Pattern[:PatternLen]) - b += xgb.Pad(int(PatternLen)) + buf[b] = byte(Key) + b += 1 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 3 // padding return buf } -// ListFontsWithInfoCookie is a cookie used only for ListFontsWithInfo requests. -type ListFontsWithInfoCookie struct { +// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. +type GrabKeyboardCookie struct { *xgb.Cookie } -// ListFontsWithInfo sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListFontsWithInfoCookie.Reply() -func ListFontsWithInfo(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { +// GrabKeyboard sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabKeyboardCookie.Reply() +func GrabKeyboard(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { cookie := c.NewCookie(true, true) - c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) - return ListFontsWithInfoCookie{cookie} + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} } -// ListFontsWithInfoUnchecked sends an unchecked request. +// GrabKeyboardUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { +func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { cookie := c.NewCookie(false, true) - c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) - return ListFontsWithInfoCookie{cookie} + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} } -// ListFontsWithInfoReply represents the data returned from a ListFontsWithInfo request. -type ListFontsWithInfoReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - NameLen byte - MinBounds Charinfo - // padding: 4 bytes - MaxBounds Charinfo - // padding: 4 bytes - MinCharOrByte2 uint16 - MaxCharOrByte2 uint16 - DefaultChar uint16 - PropertiesLen uint16 - DrawDirection byte - MinByte1 byte - MaxByte1 byte - AllCharsExist bool - FontAscent int16 - FontDescent int16 - RepliesHint uint32 - Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) - Name string // size: xgb.Pad((int(NameLen) * 1)) +// GrabKeyboardReply represents the data returned from a GrabKeyboard request. +type GrabKeyboardReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte } -// Reply blocks and returns the reply data for a ListFontsWithInfo request. -func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { +// Reply blocks and returns the reply data for a GrabKeyboard request. +func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -9990,15 +10549,15 @@ func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { if buf == nil { return nil, nil } - return listFontsWithInfoReply(buf), nil + return grabKeyboardReply(buf), nil } -// listFontsWithInfoReply reads a byte slice into a ListFontsWithInfoReply value. -func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { - v := new(ListFontsWithInfoReply) +// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. +func grabKeyboardReply(buf []byte) *GrabKeyboardReply { + v := new(GrabKeyboardReply) b := 1 // skip reply determinant - v.NameLen = buf[b] + v.Status = buf[b] b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -10007,178 +10566,76 @@ func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MinBounds = Charinfo{} - b += CharinfoRead(buf[b:], &v.MinBounds) - - b += 4 // padding - - v.MaxBounds = Charinfo{} - b += CharinfoRead(buf[b:], &v.MaxBounds) - - b += 4 // padding - - v.MinCharOrByte2 = xgb.Get16(buf[b:]) - b += 2 - - v.MaxCharOrByte2 = xgb.Get16(buf[b:]) - b += 2 - - v.DefaultChar = xgb.Get16(buf[b:]) - b += 2 - - v.PropertiesLen = xgb.Get16(buf[b:]) - b += 2 - - v.DrawDirection = buf[b] - b += 1 - - v.MinByte1 = buf[b] - b += 1 - - v.MaxByte1 = buf[b] - b += 1 - - if buf[b] == 1 { - v.AllCharsExist = true - } else { - v.AllCharsExist = false - } - b += 1 - - v.FontAscent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.FontDescent = int16(xgb.Get16(buf[b:])) - b += 2 - - v.RepliesHint = xgb.Get32(buf[b:]) - b += 4 - - v.Properties = make([]Fontprop, v.PropertiesLen) - b += FontpropReadList(buf[b:], v.Properties) - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.NameLen)) - } - return v } -// Write request to wire for ListFontsWithInfo -// listFontsWithInfoRequest writes a ListFontsWithInfo request to a byte slice. -func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +// Write request to wire for GrabKeyboard +// grabKeyboardRequest writes a GrabKeyboard request to a byte slice. +func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 50 // request opcode + buf[b] = 31 // request opcode b += 1 - b += 1 // padding + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], MaxNames) - b += 2 - - xgb.Put16(buf[b:], PatternLen) - b += 2 - - copy(buf[b:], Pattern[:PatternLen]) - b += xgb.Pad(int(PatternLen)) - - return buf -} - -// SetFontPathCookie is a cookie used only for SetFontPath requests. -type SetFontPathCookie struct { - *xgb.Cookie -} - -// SetFontPath sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -// SetFontPathChecked sends a checked request. -// If an error occurs, it can be retrieved using SetFontPathCookie.Check() -func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetFontPathCookie) Check() error { - return cook.Cookie.Check() -} + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 -// Write request to wire for SetFontPath -// setFontPathRequest writes a SetFontPath request to a byte slice. -func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { - size := xgb.Pad((8 + StrListSize(Font))) - b := 0 - buf := make([]byte, size) + xgb.Put32(buf[b:], uint32(Time)) + b += 4 - buf[b] = 51 // request opcode + buf[b] = PointerMode b += 1 - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put16(buf[b:], FontQty) - b += 2 + buf[b] = KeyboardMode + b += 1 b += 2 // padding - b += StrListBytes(buf[b:], Font) - return buf } -// GetFontPathCookie is a cookie used only for GetFontPath requests. -type GetFontPathCookie struct { +// GrabPointerCookie is a cookie used only for GrabPointer requests. +type GrabPointerCookie struct { *xgb.Cookie } -// GetFontPath sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetFontPathCookie.Reply() -func GetFontPath(c *xgb.Conn) GetFontPathCookie { +// GrabPointer sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabPointerCookie.Reply() +func GrabPointer(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getFontPathRequest(c), cookie) - return GetFontPathCookie{cookie} + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} } -// GetFontPathUnchecked sends an unchecked request. +// GrabPointerUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { +func GrabPointerUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getFontPathRequest(c), cookie) - return GetFontPathCookie{cookie} + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} } -// GetFontPathReply represents the data returned from a GetFontPath request. -type GetFontPathReply struct { +// GrabPointerReply represents the data returned from a GrabPointer request. +type GrabPointerReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - // padding: 1 bytes - PathLen uint16 - // padding: 22 bytes - Path []Str // size: StrListSize(Path) + Status byte } -// Reply blocks and returns the reply data for a GetFontPath request. -func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { +// Reply blocks and returns the reply data for a GrabPointer request. +func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -10186,15 +10643,16 @@ func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { if buf == nil { return nil, nil } - return getFontPathReply(buf), nil + return grabPointerReply(buf), nil } -// getFontPathReply reads a byte slice into a GetFontPathReply value. -func getFontPathReply(buf []byte) *GetFontPathReply { - v := new(GetFontPathReply) +// grabPointerReply reads a byte slice into a GrabPointerReply value. +func grabPointerReply(buf []byte) *GrabPointerReply { + v := new(GrabPointerReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -10202,290 +10660,253 @@ func getFontPathReply(buf []byte) *GetFontPathReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PathLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Path = make([]Str, v.PathLen) - b += StrReadList(buf[b:], v.Path) - return v } -// Write request to wire for GetFontPath -// getFontPathRequest writes a GetFontPath request to a byte slice. -func getFontPathRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GrabPointer +// grabPointerRequest writes a GrabPointer request to a byte slice. +func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { + size := 24 b := 0 buf := make([]byte, size) - buf[b] = 52 // request opcode + buf[b] = 26 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } b += 1 - b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return buf -} - -// CreatePixmapCookie is a cookie used only for CreatePixmap requests. -type CreatePixmapCookie struct { - *xgb.Cookie -} - -// CreatePixmap sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) - return CreatePixmapCookie{cookie} -} - -// CreatePixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() -func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) - return CreatePixmapCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreatePixmapCookie) Check() error { - return cook.Cookie.Check() -} + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 -// Write request to wire for CreatePixmap -// createPixmapRequest writes a CreatePixmap request to a byte slice. -func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) + xgb.Put16(buf[b:], EventMask) + b += 2 - buf[b] = 53 // request opcode + buf[b] = PointerMode b += 1 - buf[b] = Depth + buf[b] = KeyboardMode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Pid)) + xgb.Put32(buf[b:], uint32(ConfineTo)) b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Cursor)) b += 4 - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 return buf } -// FreePixmapCookie is a cookie used only for FreePixmap requests. -type FreePixmapCookie struct { +// GrabServerCookie is a cookie used only for GrabServer requests. +type GrabServerCookie struct { *xgb.Cookie } -// FreePixmap sends an unchecked request. +// GrabServer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { +func GrabServer(c *xgb.Conn) GrabServerCookie { cookie := c.NewCookie(false, false) - c.NewRequest(freePixmapRequest(c, Pixmap), cookie) - return FreePixmapCookie{cookie} + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{cookie} } -// FreePixmapChecked sends a checked request. -// If an error occurs, it can be retrieved using FreePixmapCookie.Check() -func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { +// GrabServerChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabServerCookie.Check() +func GrabServerChecked(c *xgb.Conn) GrabServerCookie { cookie := c.NewCookie(true, false) - c.NewRequest(freePixmapRequest(c, Pixmap), cookie) - return FreePixmapCookie{cookie} + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreePixmapCookie) Check() error { +func (cook GrabServerCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for FreePixmap -// freePixmapRequest writes a FreePixmap request to a byte slice. -func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { - size := 8 +// Write request to wire for GrabServer +// grabServerRequest writes a GrabServer request to a byte slice. +func grabServerRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 54 // request opcode + buf[b] = 36 // request opcode b += 1 - b += 1 // padding - + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Pixmap)) - b += 4 - return buf } -// CreateGCCookie is a cookie used only for CreateGC requests. -type CreateGCCookie struct { +// ImageText16Cookie is a cookie used only for ImageText16 requests. +type ImageText16Cookie struct { *xgb.Cookie } -// CreateGC sends an unchecked request. +// ImageText16 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { +func ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { cookie := c.NewCookie(false, false) - c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{cookie} } -// CreateGCChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateGCCookie.Check() -func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { +// ImageText16Checked sends a checked request. +// If an error occurs, it can be retrieved using ImageText16Cookie.Check() +func ImageText16Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { cookie := c.NewCookie(true, false) - c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateGCCookie) Check() error { +func (cook ImageText16Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateGC -// createGCRequest writes a CreateGC request to a byte slice. -func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for ImageText16 +// imageText16Request writes a ImageText16 request to a byte slice. +func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) b := 0 buf := make([]byte, size) - buf[b] = 55 // request opcode + buf[b] = 77 // request opcode b += 1 - b += 1 // padding + buf[b] = StringLen + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cid)) - b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + b += Char2bListBytes(buf[b:], String) return buf } -// ChangeGCCookie is a cookie used only for ChangeGC requests. -type ChangeGCCookie struct { +// ImageText8Cookie is a cookie used only for ImageText8 requests. +type ImageText8Cookie struct { *xgb.Cookie } -// ChangeGC sends an unchecked request. +// ImageText8 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { +func ImageText8(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{cookie} } -// ChangeGCChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeGCCookie.Check() -func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { +// ImageText8Checked sends a checked request. +// If an error occurs, it can be retrieved using ImageText8Cookie.Check() +func ImageText8Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeGCCookie) Check() error { +func (cook ImageText8Cookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeGC -// changeGCRequest writes a ChangeGC request to a byte slice. -func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for ImageText8 +// imageText8Request writes a ImageText8 request to a byte slice. +func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 56 // request opcode + buf[b] = 76 // request opcode b += 1 - b += 1 // padding + buf[b] = StringLen + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], String[:StringLen]) + b += xgb.Pad(int(StringLen)) return buf } -// CopyGCCookie is a cookie used only for CopyGC requests. -type CopyGCCookie struct { +// InstallColormapCookie is a cookie used only for InstallColormap requests. +type InstallColormapCookie struct { *xgb.Cookie } -// CopyGC sends an unchecked request. +// InstallColormap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { +func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { cookie := c.NewCookie(false, false) - c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} } -// CopyGCChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyGCCookie.Check() -func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { +// InstallColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using InstallColormapCookie.Check() +func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { cookie := c.NewCookie(true, false) - c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyGCCookie) Check() error { +func (cook InstallColormapCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CopyGC -// copyGCRequest writes a CopyGC request to a byte slice. -func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { - size := 16 +// Write request to wire for InstallColormap +// installColormapRequest writes a InstallColormap request to a byte slice. +func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 57 // request opcode + buf[b] = 81 // request opcode b += 1 b += 1 // padding @@ -10493,280 +10914,307 @@ func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(SrcGc)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstGc)) - b += 4 - - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 return buf } -// SetDashesCookie is a cookie used only for SetDashes requests. -type SetDashesCookie struct { +// InternAtomCookie is a cookie used only for InternAtom requests. +type InternAtomCookie struct { *xgb.Cookie } -// SetDashes sends an unchecked request. +// InternAtom sends a checked request. +// If an error occurs, it will be returned with the reply by calling InternAtomCookie.Reply() +func InternAtom(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} +} + +// InternAtomUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) - return SetDashesCookie{cookie} +func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} } -// SetDashesChecked sends a checked request. -// If an error occurs, it can be retrieved using SetDashesCookie.Check() -func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) - return SetDashesCookie{cookie} +// InternAtomReply represents the data returned from a InternAtom request. +type InternAtomReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Atom Atom } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetDashesCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a InternAtom request. +func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return internAtomReply(buf), nil } -// Write request to wire for SetDashes -// setDashesRequest writes a SetDashes request to a byte slice. -func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { - size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) +// internAtomReply reads a byte slice into a InternAtomReply value. +func internAtomReply(buf []byte) *InternAtomReply { + v := new(InternAtomReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for InternAtom +// internAtomRequest writes a InternAtom request to a byte slice. +func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 58 // request opcode + buf[b] = 16 // request opcode b += 1 - b += 1 // padding + if OnlyIfExists { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], DashOffset) + xgb.Put16(buf[b:], NameLen) b += 2 - xgb.Put16(buf[b:], DashesLen) - b += 2 + b += 2 // padding - copy(buf[b:], Dashes[:DashesLen]) - b += xgb.Pad(int(DashesLen)) + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. -type SetClipRectanglesCookie struct { +// KillClientCookie is a cookie used only for KillClient requests. +type KillClientCookie struct { *xgb.Cookie } -// SetClipRectangles sends an unchecked request. +// KillClient sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { +func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{cookie} } -// SetClipRectanglesChecked sends a checked request. -// If an error occurs, it can be retrieved using SetClipRectanglesCookie.Check() -func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { +// KillClientChecked sends a checked request. +// If an error occurs, it can be retrieved using KillClientCookie.Check() +func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { cookie := c.NewCookie(true, false) - c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetClipRectanglesCookie) Check() error { +func (cook KillClientCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetClipRectangles -// setClipRectanglesRequest writes a SetClipRectangles request to a byte slice. -func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +// Write request to wire for KillClient +// killClientRequest writes a KillClient request to a byte slice. +func killClientRequest(c *xgb.Conn, Resource uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 59 // request opcode + buf[b] = 113 // request opcode b += 1 - buf[b] = Ordering - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], Resource) b += 4 - xgb.Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - xgb.Put16(buf[b:], uint16(ClipYOrigin)) - b += 2 - - b += RectangleListBytes(buf[b:], Rectangles) - return buf } -// FreeGCCookie is a cookie used only for FreeGC requests. -type FreeGCCookie struct { +// ListExtensionsCookie is a cookie used only for ListExtensions requests. +type ListExtensionsCookie struct { *xgb.Cookie } -// FreeGC sends an unchecked request. +// ListExtensions sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListExtensionsCookie.Reply() +func ListExtensions(c *xgb.Conn) ListExtensionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} +} + +// ListExtensionsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freeGCRequest(c, Gc), cookie) - return FreeGCCookie{cookie} +func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} } -// FreeGCChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeGCCookie.Check() -func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freeGCRequest(c, Gc), cookie) - return FreeGCCookie{cookie} +// ListExtensionsReply represents the data returned from a ListExtensions request. +type ListExtensionsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + NamesLen byte + // padding: 24 bytes + Names []Str // size: StrListSize(Names) +} + +// Reply blocks and returns the reply data for a ListExtensions request. +func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listExtensionsReply(buf), nil } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreeGCCookie) Check() error { - return cook.Cookie.Check() +// listExtensionsReply reads a byte slice into a ListExtensionsReply value. +func listExtensionsReply(buf []byte) *ListExtensionsReply { + v := new(ListExtensionsReply) + b := 1 // skip reply determinant + + v.NamesLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) + + return v } -// Write request to wire for FreeGC -// freeGCRequest writes a FreeGC request to a byte slice. -func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { - size := 8 +// Write request to wire for ListExtensions +// listExtensionsRequest writes a ListExtensions request to a byte slice. +func listExtensionsRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 60 // request opcode + buf[b] = 99 // request opcode b += 1 - b += 1 // padding - + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - return buf } -// ClearAreaCookie is a cookie used only for ClearArea requests. -type ClearAreaCookie struct { +// ListFontsCookie is a cookie used only for ListFonts requests. +type ListFontsCookie struct { *xgb.Cookie } -// ClearArea sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} +// ListFonts sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListFontsCookie.Reply() +func ListFonts(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsCookie{cookie} } -// ClearAreaChecked sends a checked request. -// If an error occurs, it can be retrieved using ClearAreaCookie.Check() -func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} +// ListFontsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListFontsUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ClearAreaCookie) Check() error { - return cook.Cookie.Check() +// ListFontsReply represents the data returned from a ListFonts request. +type ListFontsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NamesLen uint16 + // padding: 22 bytes + Names []Str // size: StrListSize(Names) } -// Write request to wire for ClearArea -// clearAreaRequest writes a ClearArea request to a byte slice. -func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 61 // request opcode - b += 1 - - if Exposures { - buf[b] = 1 - } else { - buf[b] = 0 +// Reply blocks and returns the reply data for a ListFonts request. +func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err } - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + if buf == nil { + return nil, nil + } + return listFontsReply(buf), nil +} - xgb.Put32(buf[b:], uint32(Window)) - b += 4 +// listFontsReply reads a byte slice into a ListFontsReply value. +func listFontsReply(buf []byte) *ListFontsReply { + v := new(ListFontsReply) + b := 1 // skip reply determinant - xgb.Put16(buf[b:], uint16(X)) - b += 2 + b += 1 // padding - xgb.Put16(buf[b:], uint16(Y)) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Width) - b += 2 + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 - xgb.Put16(buf[b:], Height) + v.NamesLen = xgb.Get16(buf[b:]) b += 2 - return buf -} - -// CopyAreaCookie is a cookie used only for CopyArea requests. -type CopyAreaCookie struct { - *xgb.Cookie -} - -// CopyArea sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyArea(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) - return CopyAreaCookie{cookie} -} + b += 22 // padding -// CopyAreaChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyAreaCookie.Check() -func CopyAreaChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) - return CopyAreaCookie{cookie} -} + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyAreaCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for CopyArea -// copyAreaRequest writes a CopyArea request to a byte slice. -func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { - size := 28 +// Write request to wire for ListFonts +// listFontsRequest writes a ListFonts request to a byte slice. +func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 62 // request opcode + buf[b] = 49 // request opcode b += 1 b += 1 // padding @@ -10774,307 +11222,340 @@ func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(SrcDrawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(DstDrawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 - - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 - - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 - - xgb.Put16(buf[b:], uint16(DstY)) + xgb.Put16(buf[b:], MaxNames) b += 2 - xgb.Put16(buf[b:], Width) + xgb.Put16(buf[b:], PatternLen) b += 2 - xgb.Put16(buf[b:], Height) - b += 2 + copy(buf[b:], Pattern[:PatternLen]) + b += xgb.Pad(int(PatternLen)) return buf } -// CopyPlaneCookie is a cookie used only for CopyPlane requests. -type CopyPlaneCookie struct { +// ListFontsWithInfoCookie is a cookie used only for ListFontsWithInfo requests. +type ListFontsWithInfoCookie struct { *xgb.Cookie } -// CopyPlane sends an unchecked request. +// ListFontsWithInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListFontsWithInfoCookie.Reply() +func ListFontsWithInfo(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsWithInfoCookie{cookie} +} + +// ListFontsWithInfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -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 { - cookie := c.NewCookie(false, false) - c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} +func ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsWithInfoCookie{cookie} } -// CopyPlaneChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyPlaneCookie.Check() -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 { - cookie := c.NewCookie(true, false) - c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} +// ListFontsWithInfoReply represents the data returned from a ListFontsWithInfo request. +type ListFontsWithInfoReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + NameLen byte + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + RepliesHint uint32 + Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) + Name string // size: xgb.Pad((int(NameLen) * 1)) } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyPlaneCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a ListFontsWithInfo request. +func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listFontsWithInfoReply(buf), nil } -// Write request to wire for CopyPlane -// copyPlaneRequest writes a CopyPlane request to a byte slice. -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 { - size := 32 - b := 0 - buf := make([]byte, size) +// listFontsWithInfoReply reads a byte slice into a ListFontsWithInfoReply value. +func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { + v := new(ListFontsWithInfoReply) + b := 1 // skip reply determinant - buf[b] = 63 // request opcode + v.NameLen = buf[b] b += 1 - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(SrcDrawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(DstDrawable)) - b += 4 + v.MinBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MinBounds) - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + b += 4 // padding - xgb.Put16(buf[b:], uint16(SrcX)) + v.MaxBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(SrcY)) + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(DstX)) + v.DefaultChar = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], uint16(DstY)) + v.PropertiesLen = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], Width) + v.DrawDirection = buf[b] + b += 1 + + v.MinByte1 = buf[b] + b += 1 + + v.MaxByte1 = buf[b] + b += 1 + + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } + b += 1 + + v.FontAscent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], Height) + v.FontDescent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put32(buf[b:], BitPlane) + v.RepliesHint = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// PolyPointCookie is a cookie used only for PolyPoint requests. -type PolyPointCookie struct { - *xgb.Cookie -} - -// PolyPoint sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} -} + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) -// PolyPointChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyPointCookie.Check() -func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} -} + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyPointCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for PolyPoint -// polyPointRequest writes a PolyPoint request to a byte slice. -func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +// Write request to wire for ListFontsWithInfo +// listFontsWithInfoRequest writes a ListFontsWithInfo request to a byte slice. +func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 64 // request opcode + buf[b] = 50 // request opcode b += 1 - buf[b] = CoordinateMode - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 + xgb.Put16(buf[b:], MaxNames) + b += 2 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + xgb.Put16(buf[b:], PatternLen) + b += 2 - b += PointListBytes(buf[b:], Points) + copy(buf[b:], Pattern[:PatternLen]) + b += xgb.Pad(int(PatternLen)) return buf } -// PolyLineCookie is a cookie used only for PolyLine requests. -type PolyLineCookie struct { +// ListHostsCookie is a cookie used only for ListHosts requests. +type ListHostsCookie struct { *xgb.Cookie } -// PolyLine sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} +// ListHosts sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListHostsCookie.Reply() +func ListHosts(c *xgb.Conn) ListHostsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} } -// PolyLineChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyLineCookie.Check() -func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} +// ListHostsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyLineCookie) Check() error { - return cook.Cookie.Check() +// ListHostsReply represents the data returned from a ListHosts request. +type ListHostsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Mode byte + HostsLen uint16 + // padding: 22 bytes + Hosts []Host // size: HostListSize(Hosts) } -// Write request to wire for PolyLine -// polyLineRequest writes a PolyLine request to a byte slice. -func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a ListHosts request. +func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listHostsReply(buf), nil +} - buf[b] = 65 // request opcode - b += 1 +// listHostsReply reads a byte slice into a ListHostsReply value. +func listHostsReply(buf []byte) *ListHostsReply { + v := new(ListHostsReply) + b := 1 // skip reply determinant - buf[b] = CoordinateMode + v.Mode = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + v.HostsLen = xgb.Get16(buf[b:]) + b += 2 - b += PointListBytes(buf[b:], Points) + b += 22 // padding + + v.Hosts = make([]Host, v.HostsLen) + b += HostReadList(buf[b:], v.Hosts) + + return v +} + +// Write request to wire for ListHosts +// listHostsRequest writes a ListHosts request to a byte slice. +func listHostsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 110 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 return buf } -// PolySegmentCookie is a cookie used only for PolySegment requests. -type PolySegmentCookie struct { +// ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. +type ListInstalledColormapsCookie struct { *xgb.Cookie } -// PolySegment sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} +// ListInstalledColormaps sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListInstalledColormapsCookie.Reply() +func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{cookie} } -// PolySegmentChecked sends a checked request. -// If an error occurs, it can be retrieved using PolySegmentCookie.Check() -func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} +// ListInstalledColormapsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListInstalledColormapsUnchecked(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolySegmentCookie) Check() error { - return cook.Cookie.Check() +// ListInstalledColormapsReply represents the data returned from a ListInstalledColormaps request. +type ListInstalledColormapsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + CmapsLen uint16 + // padding: 22 bytes + Cmaps []Colormap // size: xgb.Pad((int(CmapsLen) * 4)) } -// Write request to wire for PolySegment -// polySegmentRequest writes a PolySegment request to a byte slice. -func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 66 // request opcode - b += 1 +// Reply blocks and returns the reply data for a ListInstalledColormaps request. +func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listInstalledColormapsReply(buf), nil +} + +// listInstalledColormapsReply reads a byte slice into a ListInstalledColormapsReply value. +func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { + v := new(ListInstalledColormapsReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += SegmentListBytes(buf[b:], Segments) - - return buf -} - -// PolyRectangleCookie is a cookie used only for PolyRectangle requests. -type PolyRectangleCookie struct { - *xgb.Cookie -} + v.CmapsLen = xgb.Get16(buf[b:]) + b += 2 -// PolyRectangle sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} -} + b += 22 // padding -// PolyRectangleChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyRectangleCookie.Check() -func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} -} + v.Cmaps = make([]Colormap, v.CmapsLen) + for i := 0; i < int(v.CmapsLen); i++ { + v.Cmaps[i] = Colormap(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyRectangleCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for PolyRectangle -// polyRectangleRequest writes a PolyRectangle request to a byte slice. -func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +// Write request to wire for ListInstalledColormaps +// listInstalledColormapsRequest writes a ListInstalledColormaps request to a byte slice. +func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 67 // request opcode + buf[b] = 83 // request opcode b += 1 b += 1 // padding @@ -11082,105 +11563,91 @@ func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangle xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - b += RectangleListBytes(buf[b:], Rectangles) - return buf } -// PolyArcCookie is a cookie used only for PolyArc requests. -type PolyArcCookie struct { +// ListPropertiesCookie is a cookie used only for ListProperties requests. +type ListPropertiesCookie struct { *xgb.Cookie } -// PolyArc sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyArcCookie{cookie} +// ListProperties sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() +func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// PolyArcChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyArcCookie.Check() -func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyArcCookie{cookie} +// ListPropertiesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyArcCookie) Check() error { - return cook.Cookie.Check() +// ListPropertiesReply represents the data returned from a ListProperties request. +type ListPropertiesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + AtomsLen uint16 + // padding: 22 bytes + Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) } -// Write request to wire for PolyArc -// polyArcRequest writes a PolyArc request to a byte slice. -func polyArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a ListProperties request. +func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listPropertiesReply(buf), nil +} - buf[b] = 68 // request opcode - b += 1 +// listPropertiesReply reads a byte slice into a ListPropertiesReply value. +func listPropertiesReply(buf []byte) *ListPropertiesReply { + v := new(ListPropertiesReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - b += ArcListBytes(buf[b:], Arcs) - - return buf -} - -// FillPolyCookie is a cookie used only for FillPoly requests. -type FillPolyCookie struct { - *xgb.Cookie -} + v.AtomsLen = xgb.Get16(buf[b:]) + b += 2 -// FillPoly sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FillPoly(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} -} + b += 22 // padding -// FillPolyChecked sends a checked request. -// If an error occurs, it can be retrieved using FillPolyCookie.Check() -func FillPolyChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} -} + v.Atoms = make([]Atom, v.AtomsLen) + for i := 0; i < int(v.AtomsLen); i++ { + v.Atoms[i] = Atom(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FillPolyCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for FillPoly -// fillPolyRequest writes a FillPoly request to a byte slice. -func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) +// Write request to wire for ListProperties +// listPropertiesRequest writes a ListProperties request to a byte slice. +func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 69 // request opcode + buf[b] = 21 // request opcode b += 1 b += 1 // padding @@ -11188,113 +11655,100 @@ func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, Co xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - buf[b] = Shape - b += 1 - - buf[b] = CoordinateMode - b += 1 - - b += 2 // padding - - b += PointListBytes(buf[b:], Points) - return buf } -// PolyFillRectangleCookie is a cookie used only for PolyFillRectangle requests. -type PolyFillRectangleCookie struct { +// LookupColorCookie is a cookie used only for LookupColor requests. +type LookupColorCookie struct { *xgb.Cookie } -// PolyFillRectangle sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{cookie} +// LookupColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling LookupColorCookie.Reply() +func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} } -// PolyFillRectangleChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyFillRectangleCookie.Check() -func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{cookie} +// LookupColorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyFillRectangleCookie) Check() error { - return cook.Cookie.Check() +// LookupColorReply represents the data returned from a LookupColor request. +type LookupColorReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 } -// Write request to wire for PolyFillRectangle -// polyFillRectangleRequest writes a PolyFillRectangle request to a byte slice. -func polyFillRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a LookupColor request. +func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return lookupColorReply(buf), nil +} - buf[b] = 70 // request opcode - b += 1 +// lookupColorReply reads a byte slice into a LookupColorReply value. +func lookupColorReply(buf []byte) *LookupColorReply { + v := new(LookupColorReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + v.ExactRed = xgb.Get16(buf[b:]) + b += 2 - b += RectangleListBytes(buf[b:], Rectangles) + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 -// PolyFillArcCookie is a cookie used only for PolyFillArc requests. -type PolyFillArcCookie struct { - *xgb.Cookie -} + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 -// PolyFillArc sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 -// PolyFillArcChecked sends a checked request. -// If an error occurs, it can be retrieved using PolyFillArcCookie.Check() -func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} + v.VisualBlue = xgb.Get16(buf[b:]) + b += 2 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyFillArcCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for PolyFillArc -// polyFillArcRequest writes a PolyFillArc request to a byte slice. -func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) +// Write request to wire for LookupColor +// lookupColorRequest writes a LookupColor request to a byte slice. +func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 71 // request opcode + buf[b] = 92 // request opcode b += 1 b += 1 // padding @@ -11302,293 +11756,195 @@ func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Cmap)) b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + xgb.Put16(buf[b:], NameLen) + b += 2 - b += ArcListBytes(buf[b:], Arcs) + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { +// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. +type MapSubwindowsCookie struct { *xgb.Cookie } -// PutImage sends an unchecked request. +// MapSubwindows sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -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 { +func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { cookie := c.NewCookie(false, false) - c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{cookie} + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{cookie} } -// PutImageChecked sends a checked request. -// If an error occurs, it can be retrieved using PutImageCookie.Check() -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 { +// MapSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using MapSubwindowsCookie.Check() +func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie { cookie := c.NewCookie(true, false) - c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{cookie} + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PutImageCookie) Check() error { +func (cook MapSubwindowsCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PutImage -// putImageRequest writes a PutImage request to a byte slice. -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 { - size := xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) +// Write request to wire for MapSubwindows +// mapSubwindowsRequest writes a MapSubwindows request to a byte slice. +func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 72 // request opcode + buf[b] = 9 // request opcode b += 1 - buf[b] = Format - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - xgb.Put16(buf[b:], uint16(DstX)) - b += 2 - - xgb.Put16(buf[b:], uint16(DstY)) - b += 2 - - buf[b] = LeftPad - b += 1 - - buf[b] = Depth - b += 1 - - b += 2 // padding - - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) - return buf } -// GetImageCookie is a cookie used only for GetImage requests. -type GetImageCookie struct { +// MapWindowCookie is a cookie used only for MapWindow requests. +type MapWindowCookie struct { *xgb.Cookie } -// GetImage sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetImageCookie.Reply() -func GetImage(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) - return GetImageCookie{cookie} -} - -// GetImageUnchecked sends an unchecked request. +// MapWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetImageUnchecked(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) - return GetImageCookie{cookie} -} - -// GetImageReply represents the data returned from a GetImage request. -type GetImageReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Depth byte - Visual Visualid - // padding: 20 bytes - Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{cookie} } -// Reply blocks and returns the reply data for a GetImage request. -func (cook GetImageCookie) Reply() (*GetImageReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getImageReply(buf), nil +// MapWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using MapWindowCookie.Check() +func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{cookie} } -// getImageReply reads a byte slice into a GetImageReply value. -func getImageReply(buf []byte) *GetImageReply { - v := new(GetImageReply) - b := 1 // skip reply determinant - - v.Depth = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Visual = Visualid(xgb.Get32(buf[b:])) - b += 4 - - b += 20 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += xgb.Pad(int((int(v.Length) * 4))) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook MapWindowCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetImage -// getImageRequest writes a GetImage request to a byte slice. -func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { - size := 20 +// Write request to wire for MapWindow +// mapWindowRequest writes a MapWindow request to a byte slice. +func mapWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 73 // request opcode + buf[b] = 8 // request opcode b += 1 - buf[b] = Format - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - xgb.Put16(buf[b:], Width) - b += 2 - - xgb.Put16(buf[b:], Height) - b += 2 - - xgb.Put32(buf[b:], PlaneMask) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// PolyText8Cookie is a cookie used only for PolyText8 requests. -type PolyText8Cookie struct { +// NoOperationCookie is a cookie used only for NoOperation requests. +type NoOperationCookie struct { *xgb.Cookie } -// PolyText8 sends an unchecked request. +// NoOperation sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { +func NoOperation(c *xgb.Conn) NoOperationCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} } -// PolyText8Checked sends a checked request. -// If an error occurs, it can be retrieved using PolyText8Cookie.Check() -func PolyText8Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { +// NoOperationChecked sends a checked request. +// If an error occurs, it can be retrieved using NoOperationCookie.Check() +func NoOperationChecked(c *xgb.Conn) NoOperationCookie { cookie := c.NewCookie(true, false) - c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyText8Cookie) Check() error { +func (cook NoOperationCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolyText8 -// polyText8Request writes a PolyText8 request to a byte slice. -func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +// Write request to wire for NoOperation +// noOperationRequest writes a NoOperation request to a byte slice. +func noOperationRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 74 // request opcode + buf[b] = 127 // request opcode b += 1 - b += 1 // padding - + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], Items[:len(Items)]) - b += xgb.Pad(int(len(Items))) - return buf } -// PolyText16Cookie is a cookie used only for PolyText16 requests. -type PolyText16Cookie struct { +// OpenFontCookie is a cookie used only for OpenFont requests. +type OpenFontCookie struct { *xgb.Cookie } -// PolyText16 sends an unchecked request. +// OpenFont sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PolyText16(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { +func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { cookie := c.NewCookie(false, false) - c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{cookie} + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{cookie} } -// PolyText16Checked sends a checked request. -// If an error occurs, it can be retrieved using PolyText16Cookie.Check() -func PolyText16Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { +// OpenFontChecked sends a checked request. +// If an error occurs, it can be retrieved using OpenFontCookie.Check() +func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { cookie := c.NewCookie(true, false) - c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{cookie} + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PolyText16Cookie) Check() error { +func (cook OpenFontCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PolyText16 -// polyText16Request writes a PolyText16 request to a byte slice. -func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { - size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +// Write request to wire for OpenFont +// openFontRequest writes a OpenFont request to a byte slice. +func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 75 // request opcode + buf[b] = 45 // request opcode b += 1 b += 1 // padding @@ -11596,63 +11952,58 @@ func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y i xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) + xgb.Put32(buf[b:], uint32(Fid)) b += 4 - xgb.Put16(buf[b:], uint16(X)) + xgb.Put16(buf[b:], NameLen) b += 2 - xgb.Put16(buf[b:], uint16(Y)) - b += 2 + b += 2 // padding - copy(buf[b:], Items[:len(Items)]) - b += xgb.Pad(int(len(Items))) + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// ImageText8Cookie is a cookie used only for ImageText8 requests. -type ImageText8Cookie struct { +// PolyArcCookie is a cookie used only for PolyArc requests. +type PolyArcCookie struct { *xgb.Cookie } -// ImageText8 sends an unchecked request. +// PolyArc sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ImageText8(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { +func PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { cookie := c.NewCookie(false, false) - c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} + c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyArcCookie{cookie} } -// ImageText8Checked sends a checked request. -// If an error occurs, it can be retrieved using ImageText8Cookie.Check() -func ImageText8Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { +// PolyArcChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyArcCookie.Check() +func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { cookie := c.NewCookie(true, false) - c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} + c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyArcCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ImageText8Cookie) Check() error { +func (cook PolyArcCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ImageText8 -// imageText8Request writes a ImageText8 request to a byte slice. -func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { - size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) +// Write request to wire for PolyArc +// polyArcRequest writes a PolyArc request to a byte slice. +func polyArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) b := 0 buf := make([]byte, size) - buf[b] = 76 // request opcode + buf[b] = 68 // request opcode b += 1 - buf[b] = StringLen - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -11663,57 +12014,49 @@ func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gconte xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], String[:StringLen]) - b += xgb.Pad(int(StringLen)) + b += ArcListBytes(buf[b:], Arcs) return buf } -// ImageText16Cookie is a cookie used only for ImageText16 requests. -type ImageText16Cookie struct { +// PolyFillArcCookie is a cookie used only for PolyFillArc requests. +type PolyFillArcCookie struct { *xgb.Cookie } -// ImageText16 sends an unchecked request. +// PolyFillArc sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { +func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { cookie := c.NewCookie(false, false) - c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{cookie} } -// ImageText16Checked sends a checked request. -// If an error occurs, it can be retrieved using ImageText16Cookie.Check() -func ImageText16Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { +// PolyFillArcChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyFillArcCookie.Check() +func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { cookie := c.NewCookie(true, false) - c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ImageText16Cookie) Check() error { +func (cook PolyFillArcCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ImageText16 -// imageText16Request writes a ImageText16 request to a byte slice. -func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { - size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) +// Write request to wire for PolyFillArc +// polyFillArcRequest writes a PolyFillArc request to a byte slice. +func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) b := 0 buf := make([]byte, size) - buf[b] = 77 // request opcode + buf[b] = 71 // request opcode b += 1 - buf[b] = StringLen - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -11724,206 +12067,207 @@ func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcont xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - b += Char2bListBytes(buf[b:], String) + b += ArcListBytes(buf[b:], Arcs) return buf } -// CreateColormapCookie is a cookie used only for CreateColormap requests. -type CreateColormapCookie struct { +// PolyFillRectangleCookie is a cookie used only for PolyFillRectangle requests. +type PolyFillRectangleCookie struct { *xgb.Cookie } -// CreateColormap sends an unchecked request. +// PolyFillRectangle sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { +func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { cookie := c.NewCookie(false, false) - c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} + c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{cookie} } -// CreateColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateColormapCookie.Check() -func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { +// PolyFillRectangleChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyFillRectangleCookie.Check() +func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { cookie := c.NewCookie(true, false) - c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} + c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateColormapCookie) Check() error { +func (cook PolyFillRectangleCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CreateColormap -// createColormapRequest writes a CreateColormap request to a byte slice. -func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { - size := 16 +// Write request to wire for PolyFillRectangle +// polyFillRectangleRequest writes a PolyFillRectangle request to a byte slice. +func polyFillRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) - buf[b] = 78 // request opcode + buf[b] = 70 // request opcode b += 1 - buf[b] = Alloc - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Mid)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put32(buf[b:], uint32(Visual)) - b += 4 + b += RectangleListBytes(buf[b:], Rectangles) return buf } -// FreeColormapCookie is a cookie used only for FreeColormap requests. -type FreeColormapCookie struct { +// PolyLineCookie is a cookie used only for PolyLine requests. +type PolyLineCookie struct { *xgb.Cookie } -// FreeColormap sends an unchecked request. +// PolyLine sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { +func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { cookie := c.NewCookie(false, false) - c.NewRequest(freeColormapRequest(c, Cmap), cookie) - return FreeColormapCookie{cookie} + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{cookie} } -// FreeColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeColormapCookie.Check() -func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { +// PolyLineChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyLineCookie.Check() +func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { cookie := c.NewCookie(true, false) - c.NewRequest(freeColormapRequest(c, Cmap), cookie) - return FreeColormapCookie{cookie} + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreeColormapCookie) Check() error { +func (cook PolyLineCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for FreeColormap -// freeColormapRequest writes a FreeColormap request to a byte slice. -func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 +// Write request to wire for PolyLine +// polyLineRequest writes a PolyLine request to a byte slice. +func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 79 // request opcode + buf[b] = 65 // request opcode b += 1 - b += 1 // padding + buf[b] = CoordinateMode + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += PointListBytes(buf[b:], Points) + return buf } -// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. -type CopyColormapAndFreeCookie struct { +// PolyPointCookie is a cookie used only for PolyPoint requests. +type PolyPointCookie struct { *xgb.Cookie } -// CopyColormapAndFree sends an unchecked request. +// PolyPoint sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { +func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { cookie := c.NewCookie(false, false) - c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{cookie} } -// CopyColormapAndFreeChecked sends a checked request. -// If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check() -func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { +// PolyPointChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyPointCookie.Check() +func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { cookie := c.NewCookie(true, false) - c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CopyColormapAndFreeCookie) Check() error { +func (cook PolyPointCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for CopyColormapAndFree -// copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice. -func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { - size := 12 +// Write request to wire for PolyPoint +// polyPointRequest writes a PolyPoint request to a byte slice. +func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 80 // request opcode + buf[b] = 64 // request opcode b += 1 - b += 1 // padding + buf[b] = CoordinateMode + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Mid)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(SrcCmap)) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += PointListBytes(buf[b:], Points) + return buf } -// InstallColormapCookie is a cookie used only for InstallColormap requests. -type InstallColormapCookie struct { +// PolyRectangleCookie is a cookie used only for PolyRectangle requests. +type PolyRectangleCookie struct { *xgb.Cookie } -// InstallColormap sends an unchecked request. +// PolyRectangle sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { +func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { cookie := c.NewCookie(false, false) - c.NewRequest(installColormapRequest(c, Cmap), cookie) - return InstallColormapCookie{cookie} + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} } -// InstallColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using InstallColormapCookie.Check() -func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { +// PolyRectangleChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyRectangleCookie.Check() +func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { cookie := c.NewCookie(true, false) - c.NewRequest(installColormapRequest(c, Cmap), cookie) - return InstallColormapCookie{cookie} + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook InstallColormapCookie) Check() error { +func (cook PolyRectangleCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for InstallColormap -// installColormapRequest writes a InstallColormap request to a byte slice. -func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 +// Write request to wire for PolyRectangle +// polyRectangleRequest writes a PolyRectangle request to a byte slice. +func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) - buf[b] = 81 // request opcode + buf[b] = 67 // request opcode b += 1 b += 1 // padding @@ -11931,47 +12275,52 @@ func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += RectangleListBytes(buf[b:], Rectangles) + return buf } -// UninstallColormapCookie is a cookie used only for UninstallColormap requests. -type UninstallColormapCookie struct { +// PolySegmentCookie is a cookie used only for PolySegment requests. +type PolySegmentCookie struct { *xgb.Cookie } -// UninstallColormap sends an unchecked request. +// PolySegment sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { +func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { cookie := c.NewCookie(false, false) - c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) - return UninstallColormapCookie{cookie} + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{cookie} } -// UninstallColormapChecked sends a checked request. -// If an error occurs, it can be retrieved using UninstallColormapCookie.Check() -func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { +// PolySegmentChecked sends a checked request. +// If an error occurs, it can be retrieved using PolySegmentCookie.Check() +func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { cookie := c.NewCookie(true, false) - c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) - return UninstallColormapCookie{cookie} + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UninstallColormapCookie) Check() error { +func (cook PolySegmentCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UninstallColormap -// uninstallColormapRequest writes a UninstallColormap request to a byte slice. -func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { - size := 8 +// Write request to wire for PolySegment +// polySegmentRequest writes a PolySegment request to a byte slice. +func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) b := 0 buf := make([]byte, size) - buf[b] = 82 // request opcode + buf[b] = 66 // request opcode b += 1 b += 1 // padding @@ -11979,91 +12328,52 @@ func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + b += SegmentListBytes(buf[b:], Segments) + return buf } -// ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. -type ListInstalledColormapsCookie struct { +// PolyText16Cookie is a cookie used only for PolyText16 requests. +type PolyText16Cookie struct { *xgb.Cookie } -// ListInstalledColormaps sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListInstalledColormapsCookie.Reply() -func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) - return ListInstalledColormapsCookie{cookie} -} - -// ListInstalledColormapsUnchecked sends an unchecked request. +// PolyText16 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListInstalledColormapsUnchecked(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) - return ListInstalledColormapsCookie{cookie} -} - -// ListInstalledColormapsReply represents the data returned from a ListInstalledColormaps request. -type ListInstalledColormapsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - CmapsLen uint16 - // padding: 22 bytes - Cmaps []Colormap // size: xgb.Pad((int(CmapsLen) * 4)) +func PolyText16(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} } -// Reply blocks and returns the reply data for a ListInstalledColormaps request. -func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listInstalledColormapsReply(buf), nil +// PolyText16Checked sends a checked request. +// If an error occurs, it can be retrieved using PolyText16Cookie.Check() +func PolyText16Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} } -// listInstalledColormapsReply reads a byte slice into a ListInstalledColormapsReply value. -func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { - v := new(ListInstalledColormapsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.CmapsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Cmaps = make([]Colormap, v.CmapsLen) - for i := 0; i < int(v.CmapsLen); i++ { - v.Cmaps[i] = Colormap(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PolyText16Cookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for ListInstalledColormaps -// listInstalledColormapsRequest writes a ListInstalledColormaps request to a byte slice. -func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { - size := 8 +// Write request to wire for PolyText16 +// polyText16Request writes a PolyText16 request to a byte slice. +func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 83 // request opcode + buf[b] = 75 // request opcode b += 1 b += 1 // padding @@ -12071,156 +12381,191 @@ func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) b += 4 + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) + return buf } -// AllocColorCookie is a cookie used only for AllocColor requests. -type AllocColorCookie struct { +// PolyText8Cookie is a cookie used only for PolyText8 requests. +type PolyText8Cookie struct { *xgb.Cookie } -// AllocColor sends a checked request. -// If an error occurs, it will be returned with the reply by calling AllocColorCookie.Reply() -func AllocColor(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} -} - -// AllocColorUnchecked sends an unchecked request. +// PolyText8 sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} +func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} } -// AllocColorReply represents the data returned from a AllocColor request. -type AllocColorReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes - Pixel uint32 +// PolyText8Checked sends a checked request. +// If an error occurs, it can be retrieved using PolyText8Cookie.Check() +func PolyText8Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} } -// Reply blocks and returns the reply data for a AllocColor request. -func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocColorReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PolyText8Cookie) Check() error { + return cook.Cookie.Check() } -// allocColorReply reads a byte slice into a AllocColorReply value. -func allocColorReply(buf []byte) *AllocColorReply { - v := new(AllocColorReply) - b := 1 // skip reply determinant +// Write request to wire for PolyText8 +// polyText8Request writes a PolyText8 request to a byte slice. +func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 74 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - v.Red = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - v.Green = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(X)) b += 2 - v.Blue = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(Y)) b += 2 - b += 2 // padding + copy(buf[b:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) - v.Pixel = xgb.Get32(buf[b:]) - b += 4 + return buf +} - return v +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { + *xgb.Cookie } -// Write request to wire for AllocColor -// allocColorRequest writes a AllocColor request to a byte slice. -func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { - size := 16 +// PutImage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +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 { + cookie := c.NewCookie(false, false) + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{cookie} +} + +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() +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 { + cookie := c.NewCookie(true, false) + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook PutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. +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 { + size := xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 84 // request opcode + buf[b] = 72 // request opcode b += 1 - b += 1 // padding + buf[b] = Format + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], Red) + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], Width) b += 2 - xgb.Put16(buf[b:], Green) + xgb.Put16(buf[b:], Height) b += 2 - xgb.Put16(buf[b:], Blue) + xgb.Put16(buf[b:], uint16(DstX)) b += 2 + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + buf[b] = LeftPad + b += 1 + + buf[b] = Depth + b += 1 + b += 2 // padding + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + return buf } -// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. -type AllocNamedColorCookie struct { +// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. +type QueryBestSizeCookie struct { *xgb.Cookie } -// AllocNamedColor sends a checked request. -// If an error occurs, it will be returned with the reply by calling AllocNamedColorCookie.Reply() -func AllocNamedColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { +// QueryBestSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() +func QueryBestSize(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { cookie := c.NewCookie(true, true) - c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} } -// AllocNamedColorUnchecked sends an unchecked request. +// QueryBestSizeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { +func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} } -// AllocNamedColorReply represents the data returned from a AllocNamedColor request. -type AllocNamedColorReply struct { +// QueryBestSizeReply represents the data returned from a QueryBestSize request. +type QueryBestSizeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Pixel uint32 - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 + Width uint16 + Height uint16 } -// Reply blocks and returns the reply data for a AllocNamedColor request. -func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { +// Reply blocks and returns the reply data for a QueryBestSize request. +func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12228,12 +12573,12 @@ func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { if buf == nil { return nil, nil } - return allocNamedColorReply(buf), nil + return queryBestSizeReply(buf), nil } -// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. -func allocNamedColorReply(buf []byte) *AllocNamedColorReply { - v := new(AllocNamedColorReply) +// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value. +func queryBestSizeReply(buf []byte) *QueryBestSizeReply { + v := new(QueryBestSizeReply) b := 1 // skip reply determinant b += 1 // padding @@ -12244,94 +12589,76 @@ func allocNamedColorReply(buf []byte) *AllocNamedColorReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Pixel = xgb.Get32(buf[b:]) - b += 4 - - v.ExactRed = xgb.Get16(buf[b:]) - b += 2 - - v.ExactGreen = xgb.Get16(buf[b:]) - b += 2 - - v.ExactBlue = xgb.Get16(buf[b:]) - b += 2 - - v.VisualRed = xgb.Get16(buf[b:]) - b += 2 - - v.VisualGreen = xgb.Get16(buf[b:]) + v.Width = xgb.Get16(buf[b:]) b += 2 - v.VisualBlue = xgb.Get16(buf[b:]) + v.Height = xgb.Get16(buf[b:]) b += 2 return v } -// Write request to wire for AllocNamedColor -// allocNamedColorRequest writes a AllocNamedColor request to a byte slice. -func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for QueryBestSize +// queryBestSizeRequest writes a QueryBestSize request to a byte slice. +func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 85 // request opcode + buf[b] = 97 // request opcode b += 1 - b += 1 // padding + buf[b] = Class + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put16(buf[b:], NameLen) + xgb.Put16(buf[b:], Width) b += 2 - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + xgb.Put16(buf[b:], Height) + b += 2 return buf } -// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. -type AllocColorCellsCookie struct { +// QueryColorsCookie is a cookie used only for QueryColors requests. +type QueryColorsCookie struct { *xgb.Cookie } -// AllocColorCells sends a checked request. -// If an error occurs, it will be returned with the reply by calling AllocColorCellsCookie.Reply() -func AllocColorCells(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { +// QueryColors sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryColorsCookie.Reply() +func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { cookie := c.NewCookie(true, true) - c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} } -// AllocColorCellsUnchecked sends an unchecked request. +// QueryColorsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { +func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} } -// AllocColorCellsReply represents the data returned from a AllocColorCells request. -type AllocColorCellsReply struct { +// QueryColorsReply represents the data returned from a QueryColors request. +type QueryColorsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - PixelsLen uint16 - MasksLen uint16 - // padding: 20 bytes - Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) - Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) + ColorsLen uint16 + // padding: 22 bytes + Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) } -// Reply blocks and returns the reply data for a AllocColorCells request. -func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { +// Reply blocks and returns the reply data for a QueryColors request. +func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12339,12 +12666,12 @@ func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { if buf == nil { return nil, nil } - return allocColorCellsReply(buf), nil + return queryColorsReply(buf), nil } -// allocColorCellsReply reads a byte slice into a AllocColorCellsReply value. -func allocColorCellsReply(buf []byte) *AllocColorCellsReply { - v := new(AllocColorCellsReply) +// queryColorsReply reads a byte slice into a QueryColorsReply value. +func queryColorsReply(buf []byte) *QueryColorsReply { + v := new(QueryColorsReply) b := 1 // skip reply determinant b += 1 // padding @@ -12355,47 +12682,28 @@ func allocColorCellsReply(buf []byte) *AllocColorCellsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PixelsLen = xgb.Get16(buf[b:]) - b += 2 - - v.MasksLen = xgb.Get16(buf[b:]) + v.ColorsLen = xgb.Get16(buf[b:]) b += 2 - b += 20 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + b += 22 // padding - v.Masks = make([]uint32, v.MasksLen) - for i := 0; i < int(v.MasksLen); i++ { - v.Masks[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Colors = make([]Rgb, v.ColorsLen) + b += RgbReadList(buf[b:], v.Colors) return v } -// Write request to wire for AllocColorCells -// allocColorCellsRequest writes a AllocColorCells request to a byte slice. -func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { - size := 12 +// Write request to wire for QueryColors +// queryColorsRequest writes a QueryColors request to a byte slice. +func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) b := 0 buf := make([]byte, size) - buf[b] = 86 // request opcode + buf[b] = 91 // request opcode b += 1 - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 @@ -12403,52 +12711,49 @@ func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors xgb.Put32(buf[b:], uint32(Cmap)) b += 4 - xgb.Put16(buf[b:], Colors) - b += 2 - - xgb.Put16(buf[b:], Planes) - b += 2 + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) return buf } -// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. -type AllocColorPlanesCookie struct { +// QueryExtensionCookie is a cookie used only for QueryExtension requests. +type QueryExtensionCookie struct { *xgb.Cookie } -// AllocColorPlanes sends a checked request. -// If an error occurs, it will be returned with the reply by calling AllocColorPlanesCookie.Reply() -func AllocColorPlanes(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { +// QueryExtension sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() +func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { cookie := c.NewCookie(true, true) - c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} } -// AllocColorPlanesUnchecked sends an unchecked request. +// QueryExtensionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { +func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { cookie := c.NewCookie(false, true) - c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} } -// AllocColorPlanesReply represents the data returned from a AllocColorPlanes request. -type AllocColorPlanesReply struct { +// QueryExtensionReply represents the data returned from a QueryExtension request. +type QueryExtensionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - PixelsLen uint16 - // padding: 2 bytes - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 8 bytes - Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) + Present bool + MajorOpcode byte + FirstEvent byte + FirstError byte } -// Reply blocks and returns the reply data for a AllocColorPlanes request. -func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { +// Reply blocks and returns the reply data for a QueryExtension request. +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12456,12 +12761,12 @@ func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { if buf == nil { return nil, nil } - return allocColorPlanesReply(buf), nil + return queryExtensionReply(buf), nil } -// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. -func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { - v := new(AllocColorPlanesReply) +// queryExtensionReply reads a byte slice into a QueryExtensionReply value. +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) b := 1 // skip reply determinant b += 1 // padding @@ -12472,270 +12777,229 @@ func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PixelsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.RedMask = xgb.Get32(buf[b:]) - b += 4 - - v.GreenMask = xgb.Get32(buf[b:]) - b += 4 + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } + b += 1 - v.BlueMask = xgb.Get32(buf[b:]) - b += 4 + v.MajorOpcode = buf[b] + b += 1 - b += 8 // padding + v.FirstEvent = buf[b] + b += 1 - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.FirstError = buf[b] + b += 1 return v } -// Write request to wire for AllocColorPlanes -// allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice. -func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { - size := 16 +// Write request to wire for QueryExtension +// queryExtensionRequest writes a QueryExtension request to a byte slice. +func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 87 // request opcode + buf[b] = 98 // request opcode b += 1 - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put16(buf[b:], Colors) - b += 2 - - xgb.Put16(buf[b:], Reds) + xgb.Put16(buf[b:], NameLen) b += 2 - xgb.Put16(buf[b:], Greens) - b += 2 + b += 2 // padding - xgb.Put16(buf[b:], Blues) - b += 2 + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// FreeColorsCookie is a cookie used only for FreeColors requests. -type FreeColorsCookie struct { +// QueryFontCookie is a cookie used only for QueryFont requests. +type QueryFontCookie struct { *xgb.Cookie } -// FreeColors sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{cookie} +// QueryFont sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryFontCookie.Reply() +func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{cookie} } -// FreeColorsChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeColorsCookie.Check() -func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{cookie} +// QueryFontUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreeColorsCookie) Check() error { - return cook.Cookie.Check() +// QueryFontReply represents the data returned from a QueryFont request. +type QueryFontReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + CharInfosLen uint32 + Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) + CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) } -// Write request to wire for FreeColors -// freeColorsRequest writes a FreeColors request to a byte slice. -func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a QueryFont request. +func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFontReply(buf), nil +} - buf[b] = 88 // request opcode - b += 1 +// queryFontReply reads a byte slice into a QueryFontReply value. +func queryFontReply(buf []byte) *QueryFontReply { + v := new(QueryFontReply) + b := 1 // skip reply determinant b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], PlaneMask) - b += 4 + v.MinBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MinBounds) + + b += 4 // padding + + v.MaxBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MaxBounds) + + b += 4 // padding - for i := 0; i < int(len(Pixels)); i++ { - xgb.Put32(buf[b:], Pixels[i]) - b += 4 - } - b = xgb.Pad(b) + v.MinCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 -// StoreColorsCookie is a cookie used only for StoreColors requests. -type StoreColorsCookie struct { - *xgb.Cookie -} + v.DefaultChar = xgb.Get16(buf[b:]) + b += 2 -// StoreColors sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func StoreColors(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} + v.PropertiesLen = xgb.Get16(buf[b:]) + b += 2 -// StoreColorsChecked sends a checked request. -// If an error occurs, it can be retrieved using StoreColorsCookie.Check() -func StoreColorsChecked(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} + v.DrawDirection = buf[b] + b += 1 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook StoreColorsCookie) Check() error { - return cook.Cookie.Check() -} + v.MinByte1 = buf[b] + b += 1 -// Write request to wire for StoreColors -// storeColorsRequest writes a StoreColors request to a byte slice. -func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) - b := 0 - buf := make([]byte, size) + v.MaxByte1 = buf[b] + b += 1 - buf[b] = 89 // request opcode + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } b += 1 - b += 1 // padding + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.FontDescent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + v.CharInfosLen = xgb.Get32(buf[b:]) b += 4 - b += ColoritemListBytes(buf[b:], Items) - - return buf -} - -// StoreNamedColorCookie is a cookie used only for StoreNamedColor requests. -type StoreNamedColorCookie struct { - *xgb.Cookie -} - -// StoreNamedColor sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) - return StoreNamedColorCookie{cookie} -} + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) -// StoreNamedColorChecked sends a checked request. -// If an error occurs, it can be retrieved using StoreNamedColorCookie.Check() -func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) - return StoreNamedColorCookie{cookie} -} + v.CharInfos = make([]Charinfo, v.CharInfosLen) + b += CharinfoReadList(buf[b:], v.CharInfos) -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook StoreNamedColorCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for StoreNamedColor -// storeNamedColorRequest writes a StoreNamedColor request to a byte slice. -func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { - size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for QueryFont +// queryFontRequest writes a QueryFont request to a byte slice. +func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 90 // request opcode + buf[b] = 47 // request opcode b += 1 - buf[b] = Flags - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - xgb.Put32(buf[b:], Pixel) + xgb.Put32(buf[b:], uint32(Font)) b += 4 - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - return buf } -// QueryColorsCookie is a cookie used only for QueryColors requests. -type QueryColorsCookie struct { +// QueryKeymapCookie is a cookie used only for QueryKeymap requests. +type QueryKeymapCookie struct { *xgb.Cookie } -// QueryColors sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryColorsCookie.Reply() -func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { +// QueryKeymap sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryKeymapCookie.Reply() +func QueryKeymap(c *xgb.Conn) QueryKeymapCookie { cookie := c.NewCookie(true, true) - c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} } -// QueryColorsUnchecked sends an unchecked request. +// QueryKeymapUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { +func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { cookie := c.NewCookie(false, true) - c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} } -// QueryColorsReply represents the data returned from a QueryColors request. -type QueryColorsReply struct { +// QueryKeymapReply represents the data returned from a QueryKeymap request. +type QueryKeymapReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ColorsLen uint16 - // padding: 22 bytes - Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) + Keys []byte // size: 32 } -// Reply blocks and returns the reply data for a QueryColors request. -func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { +// Reply blocks and returns the reply data for a QueryKeymap request. +func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12743,12 +13007,12 @@ func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { if buf == nil { return nil, nil } - return queryColorsReply(buf), nil + return queryKeymapReply(buf), nil } -// queryColorsReply reads a byte slice into a QueryColorsReply value. -func queryColorsReply(buf []byte) *QueryColorsReply { - v := new(QueryColorsReply) +// queryKeymapReply reads a byte slice into a QueryKeymapReply value. +func queryKeymapReply(buf []byte) *QueryKeymapReply { + v := new(QueryKeymapReply) b := 1 // skip reply determinant b += 1 // padding @@ -12759,80 +13023,68 @@ func queryColorsReply(buf []byte) *QueryColorsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ColorsLen = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Colors = make([]Rgb, v.ColorsLen) - b += RgbReadList(buf[b:], v.Colors) + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) return v } -// Write request to wire for QueryColors -// queryColorsRequest writes a QueryColors request to a byte slice. -func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { - size := xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) +// Write request to wire for QueryKeymap +// queryKeymapRequest writes a QueryKeymap request to a byte slice. +func queryKeymapRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 91 // request opcode + buf[b] = 44 // request opcode b += 1 - b += 1 // padding - + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) - b += 4 - - for i := 0; i < int(len(Pixels)); i++ { - xgb.Put32(buf[b:], Pixels[i]) - b += 4 - } - b = xgb.Pad(b) - return buf } -// LookupColorCookie is a cookie used only for LookupColor requests. -type LookupColorCookie struct { +// QueryPointerCookie is a cookie used only for QueryPointer requests. +type QueryPointerCookie struct { *xgb.Cookie } -// LookupColor sends a checked request. -// If an error occurs, it will be returned with the reply by calling LookupColorCookie.Reply() -func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { +// QueryPointer sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPointerCookie.Reply() +func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie { cookie := c.NewCookie(true, true) - c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} } -// LookupColorUnchecked sends an unchecked request. +// QueryPointerUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { +func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { cookie := c.NewCookie(false, true) - c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} } -// LookupColorReply represents the data returned from a LookupColor request. -type LookupColorReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 +// QueryPointerReply represents the data returned from a QueryPointer request. +type QueryPointerReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + SameScreen bool + Root Window + Child Window + RootX int16 + RootY int16 + WinX int16 + WinY int16 + Mask uint16 + // padding: 2 bytes } -// Reply blocks and returns the reply data for a LookupColor request. -func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { +// Reply blocks and returns the reply data for a QueryPointer request. +func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -12840,15 +13092,20 @@ func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { if buf == nil { return nil, nil } - return lookupColorReply(buf), nil + return queryPointerReply(buf), nil } -// lookupColorReply reads a byte slice into a LookupColorReply value. -func lookupColorReply(buf []byte) *LookupColorReply { - v := new(LookupColorReply) +// queryPointerReply reads a byte slice into a QueryPointerReply value. +func queryPointerReply(buf []byte) *QueryPointerReply { + v := new(QueryPointerReply) b := 1 // skip reply determinant - b += 1 // padding + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -12856,35 +13113,40 @@ func lookupColorReply(buf []byte) *LookupColorReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ExactRed = xgb.Get16(buf[b:]) - b += 2 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - v.ExactGreen = xgb.Get16(buf[b:]) + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) b += 2 - v.ExactBlue = xgb.Get16(buf[b:]) + v.RootY = int16(xgb.Get16(buf[b:])) b += 2 - v.VisualRed = xgb.Get16(buf[b:]) + v.WinX = int16(xgb.Get16(buf[b:])) b += 2 - v.VisualGreen = xgb.Get16(buf[b:]) + v.WinY = int16(xgb.Get16(buf[b:])) b += 2 - v.VisualBlue = xgb.Get16(buf[b:]) + v.Mask = xgb.Get16(buf[b:]) b += 2 + b += 2 // padding + return v } -// Write request to wire for LookupColor -// lookupColorRequest writes a LookupColor request to a byte slice. -func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for QueryPointer +// queryPointerRequest writes a QueryPointer request to a byte slice. +func queryPointerRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 92 // request opcode + buf[b] = 38 // request opcode b += 1 b += 1 // padding @@ -12892,211 +13154,210 @@ func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cmap)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) - return buf } -// CreateCursorCookie is a cookie used only for CreateCursor requests. -type CreateCursorCookie struct { +// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. +type QueryTextExtentsCookie struct { *xgb.Cookie } -// CreateCursor sends an unchecked request. +// QueryTextExtents sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryTextExtentsCookie.Reply() +func QueryTextExtents(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} +} + +// QueryTextExtentsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -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 { - cookie := c.NewCookie(false, false) - c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} +func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} } -// CreateCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateCursorCookie.Check() -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 { - cookie := c.NewCookie(true, false) - c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} +// QueryTextExtentsReply represents the data returned from a QueryTextExtents request. +type QueryTextExtentsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + DrawDirection byte + FontAscent int16 + FontDescent int16 + OverallAscent int16 + OverallDescent int16 + OverallWidth int32 + OverallLeft int32 + OverallRight int32 } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateCursorCookie) Check() error { - return cook.Cookie.Check() +// Reply blocks and returns the reply data for a QueryTextExtents request. +func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryTextExtentsReply(buf), nil } -// Write request to wire for CreateCursor -// createCursorRequest writes a CreateCursor request to a byte slice. -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 { - size := 32 - b := 0 - buf := make([]byte, size) +// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. +func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { + v := new(QueryTextExtentsReply) + b := 1 // skip reply determinant - buf[b] = 93 // request opcode + v.DrawDirection = buf[b] b += 1 - b += 1 // padding - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Cid)) - b += 4 - - xgb.Put32(buf[b:], uint32(Source)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mask)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], ForeRed) - b += 2 - - xgb.Put16(buf[b:], ForeGreen) - b += 2 - - xgb.Put16(buf[b:], ForeBlue) - b += 2 - - xgb.Put16(buf[b:], BackRed) - b += 2 - - xgb.Put16(buf[b:], BackGreen) + v.FontAscent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], BackBlue) + v.FontDescent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], X) + v.OverallAscent = int16(xgb.Get16(buf[b:])) b += 2 - xgb.Put16(buf[b:], Y) + v.OverallDescent = int16(xgb.Get16(buf[b:])) b += 2 - return buf -} - -// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. -type CreateGlyphCursorCookie struct { - *xgb.Cookie -} + v.OverallWidth = int32(xgb.Get32(buf[b:])) + b += 4 -// CreateGlyphCursor sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -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 { - cookie := c.NewCookie(false, false) - c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} -} + v.OverallLeft = int32(xgb.Get32(buf[b:])) + b += 4 -// CreateGlyphCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using CreateGlyphCursorCookie.Check() -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 { - cookie := c.NewCookie(true, false) - c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} -} + v.OverallRight = int32(xgb.Get32(buf[b:])) + b += 4 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook CreateGlyphCursorCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for CreateGlyphCursor -// createGlyphCursorRequest writes a CreateGlyphCursor request to a byte slice. -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 { - size := 32 +// Write request to wire for QueryTextExtents +// queryTextExtentsRequest writes a QueryTextExtents request to a byte slice. +func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { + size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) b := 0 buf := make([]byte, size) - buf[b] = 94 // request opcode + buf[b] = 48 // request opcode b += 1 - b += 1 // padding + buf[b] = byte((int(StringLen) & 1)) + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cid)) + xgb.Put32(buf[b:], uint32(Font)) b += 4 - xgb.Put32(buf[b:], uint32(SourceFont)) - b += 4 + b += Char2bListBytes(buf[b:], String) - xgb.Put32(buf[b:], uint32(MaskFont)) - b += 4 + // skip writing local field: StringLen (2) :: uint16 - xgb.Put16(buf[b:], SourceChar) - b += 2 + return buf +} - xgb.Put16(buf[b:], MaskChar) - b += 2 +// QueryTreeCookie is a cookie used only for QueryTree requests. +type QueryTreeCookie struct { + *xgb.Cookie +} - xgb.Put16(buf[b:], ForeRed) - b += 2 +// QueryTree sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryTreeCookie.Reply() +func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryTreeRequest(c, Window), cookie) + return QueryTreeCookie{cookie} +} - xgb.Put16(buf[b:], ForeGreen) - b += 2 +// QueryTreeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryTreeUnchecked(c *xgb.Conn, Window Window) QueryTreeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryTreeRequest(c, Window), cookie) + return QueryTreeCookie{cookie} +} + +// QueryTreeReply represents the data returned from a QueryTree request. +type QueryTreeReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + Root Window + Parent Window + ChildrenLen uint16 + // padding: 14 bytes + Children []Window // size: xgb.Pad((int(ChildrenLen) * 4)) +} + +// Reply blocks and returns the reply data for a QueryTree request. +func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryTreeReply(buf), nil +} + +// queryTreeReply reads a byte slice into a QueryTreeReply value. +func queryTreeReply(buf []byte) *QueryTreeReply { + v := new(QueryTreeReply) + b := 1 // skip reply determinant - xgb.Put16(buf[b:], ForeBlue) - b += 2 + b += 1 // padding - xgb.Put16(buf[b:], BackRed) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put16(buf[b:], BackGreen) - b += 2 + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 - xgb.Put16(buf[b:], BackBlue) - b += 2 + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 - return buf -} + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 -// FreeCursorCookie is a cookie used only for FreeCursor requests. -type FreeCursorCookie struct { - *xgb.Cookie -} + v.ChildrenLen = xgb.Get16(buf[b:]) + b += 2 -// FreeCursor sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeCursor(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(freeCursorRequest(c, Cursor), cookie) - return FreeCursorCookie{cookie} -} + b += 14 // padding -// FreeCursorChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeCursorCookie.Check() -func FreeCursorChecked(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(freeCursorRequest(c, Cursor), cookie) - return FreeCursorCookie{cookie} -} + v.Children = make([]Window, v.ChildrenLen) + for i := 0; i < int(v.ChildrenLen); i++ { + v.Children[i] = Window(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreeCursorCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for FreeCursor -// freeCursorRequest writes a FreeCursor request to a byte slice. -func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { +// Write request to wire for QueryTree +// queryTreeRequest writes a QueryTree request to a byte slice. +func queryTreeRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 buf := make([]byte, size) - buf[b] = 95 // request opcode + buf[b] = 15 // request opcode b += 1 b += 1 // padding @@ -13104,7 +13365,7 @@ func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Cursor)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf @@ -13176,468 +13437,366 @@ func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen return buf } -// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. -type QueryBestSizeCookie struct { +// ReparentWindowCookie is a cookie used only for ReparentWindow requests. +type ReparentWindowCookie struct { *xgb.Cookie } -// QueryBestSize sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() -func QueryBestSize(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) - return QueryBestSizeCookie{cookie} -} - -// QueryBestSizeUnchecked sends an unchecked request. +// ReparentWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) - return QueryBestSizeCookie{cookie} -} - -// QueryBestSizeReply represents the data returned from a QueryBestSize request. -type QueryBestSizeReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Width uint16 - Height uint16 +func ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{cookie} } -// Reply blocks and returns the reply data for a QueryBestSize request. -func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryBestSizeReply(buf), nil +// ReparentWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using ReparentWindowCookie.Check() +func ReparentWindowChecked(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{cookie} } -// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value. -func queryBestSizeReply(buf []byte) *QueryBestSizeReply { - v := new(QueryBestSizeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook ReparentWindowCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryBestSize -// queryBestSizeRequest writes a QueryBestSize request to a byte slice. -func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 12 +// Write request to wire for ReparentWindow +// reparentWindowRequest writes a ReparentWindow request to a byte slice. +func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 97 // request opcode + buf[b] = 7 // request opcode b += 1 - buf[b] = Class - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], Width) + xgb.Put32(buf[b:], uint32(Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) b += 2 - xgb.Put16(buf[b:], Height) + xgb.Put16(buf[b:], uint16(Y)) b += 2 return buf } -// QueryExtensionCookie is a cookie used only for QueryExtension requests. -type QueryExtensionCookie struct { +// RotatePropertiesCookie is a cookie used only for RotateProperties requests. +type RotatePropertiesCookie struct { *xgb.Cookie } -// QueryExtension sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() -func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) - return QueryExtensionCookie{cookie} -} - -// QueryExtensionUnchecked sends an unchecked request. +// RotateProperties sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) - return QueryExtensionCookie{cookie} +func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} } -// QueryExtensionReply represents the data returned from a QueryExtension request. -type QueryExtensionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Present bool - MajorOpcode byte - FirstEvent byte - FirstError byte +// RotatePropertiesChecked sends a checked request. +// If an error occurs, it can be retrieved using RotatePropertiesCookie.Check() +func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} } -// Reply blocks and returns the reply data for a QueryExtension request. -func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryExtensionReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook RotatePropertiesCookie) Check() error { + return cook.Cookie.Check() } -// queryExtensionReply reads a byte slice into a QueryExtensionReply value. -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) - b := 1 // skip reply determinant +// Write request to wire for RotateProperties +// rotatePropertiesRequest writes a RotateProperties request to a byte slice. +func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { + size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 114 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Window)) b += 4 - if buf[b] == 1 { - v.Present = true - } else { - v.Present = false + xgb.Put16(buf[b:], AtomsLen) + b += 2 + + xgb.Put16(buf[b:], uint16(Delta)) + b += 2 + + for i := 0; i < int(AtomsLen); i++ { + xgb.Put32(buf[b:], uint32(Atoms[i])) + b += 4 } - b += 1 + b = xgb.Pad(b) - v.MajorOpcode = buf[b] - b += 1 + return buf +} - v.FirstEvent = buf[b] - b += 1 +// SendEventCookie is a cookie used only for SendEvent requests. +type SendEventCookie struct { + *xgb.Cookie +} - v.FirstError = buf[b] - b += 1 +// SendEvent sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SendEvent(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{cookie} +} + +// SendEventChecked sends a checked request. +// If an error occurs, it can be retrieved using SendEventCookie.Check() +func SendEventChecked(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{cookie} +} - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SendEventCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryExtension -// queryExtensionRequest writes a QueryExtension request to a byte slice. -func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +// Write request to wire for SendEvent +// sendEventRequest writes a SendEvent request to a byte slice. +func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte { + size := 44 b := 0 buf := make([]byte, size) - buf[b] = 98 // request opcode + buf[b] = 25 // request opcode b += 1 - b += 1 // padding + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], NameLen) - b += 2 + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 - b += 2 // padding + xgb.Put32(buf[b:], EventMask) + b += 4 - copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + copy(buf[b:], Event[:32]) + b += xgb.Pad(int(32)) return buf } -// ListExtensionsCookie is a cookie used only for ListExtensions requests. -type ListExtensionsCookie struct { +// SetAccessControlCookie is a cookie used only for SetAccessControl requests. +type SetAccessControlCookie struct { *xgb.Cookie } -// ListExtensions sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListExtensionsCookie.Reply() -func ListExtensions(c *xgb.Conn) ListExtensionsCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(listExtensionsRequest(c), cookie) - return ListExtensionsCookie{cookie} -} - -// ListExtensionsUnchecked sends an unchecked request. +// SetAccessControl sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(listExtensionsRequest(c), cookie) - return ListExtensionsCookie{cookie} -} - -// ListExtensionsReply represents the data returned from a ListExtensions request. -type ListExtensionsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - NamesLen byte - // padding: 24 bytes - Names []Str // size: StrListSize(Names) +func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setAccessControlRequest(c, Mode), cookie) + return SetAccessControlCookie{cookie} } -// Reply blocks and returns the reply data for a ListExtensions request. -func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listExtensionsReply(buf), nil +// SetAccessControlChecked sends a checked request. +// If an error occurs, it can be retrieved using SetAccessControlCookie.Check() +func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setAccessControlRequest(c, Mode), cookie) + return SetAccessControlCookie{cookie} } -// listExtensionsReply reads a byte slice into a ListExtensionsReply value. -func listExtensionsReply(buf []byte) *ListExtensionsReply { - v := new(ListExtensionsReply) - b := 1 // skip reply determinant - - v.NamesLen = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Names = make([]Str, v.NamesLen) - b += StrReadList(buf[b:], v.Names) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetAccessControlCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for ListExtensions -// listExtensionsRequest writes a ListExtensions request to a byte slice. -func listExtensionsRequest(c *xgb.Conn) []byte { +// Write request to wire for SetAccessControl +// setAccessControlRequest writes a SetAccessControl request to a byte slice. +func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { size := 4 b := 0 buf := make([]byte, size) - buf[b] = 99 // request opcode + buf[b] = 111 // request opcode + b += 1 + + buf[b] = Mode b += 1 - b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 return buf } -// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. -type ChangeKeyboardMappingCookie struct { +// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. +type SetClipRectanglesCookie struct { *xgb.Cookie } -// ChangeKeyboardMapping sends an unchecked request. +// SetClipRectangles sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { +func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} } -// ChangeKeyboardMappingChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check() -func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { +// SetClipRectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClipRectanglesCookie.Check() +func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeKeyboardMappingCookie) Check() error { +func (cook SetClipRectanglesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeKeyboardMapping -// changeKeyboardMappingRequest writes a ChangeKeyboardMapping request to a byte slice. -func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { - size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +// Write request to wire for SetClipRectangles +// setClipRectanglesRequest writes a SetClipRectangles request to a byte slice. +func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 buf := make([]byte, size) - buf[b] = 100 // request opcode + buf[b] = 59 // request opcode b += 1 - buf[b] = KeycodeCount + buf[b] = Ordering b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = byte(FirstKeycode) - b += 1 + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 - buf[b] = KeysymsPerKeycode - b += 1 + xgb.Put16(buf[b:], uint16(ClipXOrigin)) + b += 2 - b += 2 // padding + xgb.Put16(buf[b:], uint16(ClipYOrigin)) + b += 2 - for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { - xgb.Put32(buf[b:], uint32(Keysyms[i])) - b += 4 - } - b = xgb.Pad(b) + b += RectangleListBytes(buf[b:], Rectangles) return buf } -// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. -type GetKeyboardMappingCookie struct { +// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. +type SetCloseDownModeCookie struct { *xgb.Cookie } -// GetKeyboardMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetKeyboardMappingCookie.Reply() -func GetKeyboardMapping(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) - return GetKeyboardMappingCookie{cookie} -} - -// GetKeyboardMappingUnchecked sends an unchecked request. +// SetCloseDownMode sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetKeyboardMappingUnchecked(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) - return GetKeyboardMappingCookie{cookie} -} - -// GetKeyboardMappingReply represents the data returned from a GetKeyboardMapping request. -type GetKeyboardMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - KeysymsPerKeycode byte - // padding: 24 bytes - Keysyms []Keysym // size: xgb.Pad((int(Length) * 4)) +func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} } -// Reply blocks and returns the reply data for a GetKeyboardMapping request. -func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getKeyboardMappingReply(buf), nil +// SetCloseDownModeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCloseDownModeCookie.Check() +func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} } -// getKeyboardMappingReply reads a byte slice into a GetKeyboardMappingReply value. -func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { - v := new(GetKeyboardMappingReply) - b := 1 // skip reply determinant - - v.KeysymsPerKeycode = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Keysyms = make([]Keysym, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Keysyms[i] = Keysym(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetCloseDownModeCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetKeyboardMapping -// getKeyboardMappingRequest writes a GetKeyboardMapping request to a byte slice. -func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte { - size := 8 +// Write request to wire for SetCloseDownMode +// setCloseDownModeRequest writes a SetCloseDownMode request to a byte slice. +func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 101 // request opcode + buf[b] = 112 // request opcode b += 1 - b += 1 // padding + buf[b] = Mode + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = Count - b += 1 - return buf } -// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. -type ChangeKeyboardControlCookie struct { +// SetDashesCookie is a cookie used only for SetDashes requests. +type SetDashesCookie struct { *xgb.Cookie } -// ChangeKeyboardControl sends an unchecked request. +// SetDashes sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { +func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{cookie} } -// ChangeKeyboardControlChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeKeyboardControlCookie.Check() -func ChangeKeyboardControlChecked(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { +// SetDashesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDashesCookie.Check() +func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeKeyboardControlCookie) Check() error { +func (cook SetDashesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeKeyboardControl -// changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice. -func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { - size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// Write request to wire for SetDashes +// setDashesRequest writes a SetDashes request to a byte slice. +func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 102 // request opcode + buf[b] = 58 // request opcode b += 1 b += 1 // padding @@ -13645,267 +13804,237 @@ func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uin xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ValueMask) + xgb.Put32(buf[b:], uint32(Gc)) b += 4 - for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { - xgb.Put32(buf[b:], ValueList[i]) - b += 4 - } - b = xgb.Pad(b) + + xgb.Put16(buf[b:], DashOffset) + b += 2 + + xgb.Put16(buf[b:], DashesLen) + b += 2 + + copy(buf[b:], Dashes[:DashesLen]) + b += xgb.Pad(int(DashesLen)) return buf } -// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. -type GetKeyboardControlCookie struct { +// SetFontPathCookie is a cookie used only for SetFontPath requests. +type SetFontPathCookie struct { *xgb.Cookie } -// GetKeyboardControl sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply() -func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getKeyboardControlRequest(c), cookie) - return GetKeyboardControlCookie{cookie} -} - -// GetKeyboardControlUnchecked sends an unchecked request. +// SetFontPath sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getKeyboardControlRequest(c), cookie) - return GetKeyboardControlCookie{cookie} +func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} } -// GetKeyboardControlReply represents the data returned from a GetKeyboardControl request. -type GetKeyboardControlReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - GlobalAutoRepeat byte - LedMask uint32 - KeyClickPercent byte - BellPercent byte - BellPitch uint16 - BellDuration uint16 - // padding: 2 bytes - AutoRepeats []byte // size: 32 +// SetFontPathChecked sends a checked request. +// If an error occurs, it can be retrieved using SetFontPathCookie.Check() +func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} } -// Reply blocks and returns the reply data for a GetKeyboardControl request. -func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getKeyboardControlReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetFontPathCookie) Check() error { + return cook.Cookie.Check() } -// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. -func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { - v := new(GetKeyboardControlReply) - b := 1 // skip reply determinant - - v.GlobalAutoRepeat = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.LedMask = xgb.Get32(buf[b:]) - b += 4 +// Write request to wire for SetFontPath +// setFontPathRequest writes a SetFontPath request to a byte slice. +func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { + size := xgb.Pad((8 + StrListSize(Font))) + b := 0 + buf := make([]byte, size) - v.KeyClickPercent = buf[b] + buf[b] = 51 // request opcode b += 1 - v.BellPercent = buf[b] - b += 1 + b += 1 // padding - v.BellPitch = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.BellDuration = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], FontQty) b += 2 b += 2 // padding - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += xgb.Pad(int(32)) - - return v -} - -// Write request to wire for GetKeyboardControl -// getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice. -func getKeyboardControlRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 103 // request opcode - b += 1 - - b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + b += StrListBytes(buf[b:], Font) return buf } -// BellCookie is a cookie used only for Bell requests. -type BellCookie struct { +// SetInputFocusCookie is a cookie used only for SetInputFocus requests. +type SetInputFocusCookie struct { *xgb.Cookie } -// Bell sends an unchecked request. +// SetInputFocus sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Bell(c *xgb.Conn, Percent int8) BellCookie { +func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { cookie := c.NewCookie(false, false) - c.NewRequest(bellRequest(c, Percent), cookie) - return BellCookie{cookie} + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{cookie} } -// BellChecked sends a checked request. -// If an error occurs, it can be retrieved using BellCookie.Check() -func BellChecked(c *xgb.Conn, Percent int8) BellCookie { +// SetInputFocusChecked sends a checked request. +// If an error occurs, it can be retrieved using SetInputFocusCookie.Check() +func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { cookie := c.NewCookie(true, false) - c.NewRequest(bellRequest(c, Percent), cookie) - return BellCookie{cookie} + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook BellCookie) Check() error { +func (cook SetInputFocusCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Bell -// bellRequest writes a Bell request to a byte slice. -func bellRequest(c *xgb.Conn, Percent int8) []byte { - size := 4 +// Write request to wire for SetInputFocus +// setInputFocusRequest writes a SetInputFocus request to a byte slice. +func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 104 // request opcode + buf[b] = 42 // request opcode b += 1 - buf[b] = byte(Percent) + buf[b] = RevertTo b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Focus)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + return buf } -// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. -type ChangePointerControlCookie struct { +// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. +type SetModifierMappingCookie struct { *xgb.Cookie } -// ChangePointerControl sends an unchecked request. +// SetModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetModifierMappingCookie.Reply() +func SetModifierMapping(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) + return SetModifierMappingCookie{cookie} +} + +// SetModifierMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} +func SetModifierMappingUnchecked(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) + return SetModifierMappingCookie{cookie} } -// ChangePointerControlChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangePointerControlCookie.Check() -func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} +// SetModifierMappingReply represents the data returned from a SetModifierMapping request. +type SetModifierMappingReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + Status byte +} + +// Reply blocks and returns the reply data for a SetModifierMapping request. +func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setModifierMappingReply(buf), nil } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangePointerControlCookie) Check() error { - return cook.Cookie.Check() +// setModifierMappingReply reads a byte slice into a SetModifierMappingReply value. +func setModifierMappingReply(buf []byte) *SetModifierMappingReply { + v := new(SetModifierMappingReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v } -// Write request to wire for ChangePointerControl -// changePointerControlRequest writes a ChangePointerControl request to a byte slice. -func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { - size := 12 +// Write request to wire for SetModifierMapping +// setModifierMappingRequest writes a SetModifierMapping request to a byte slice. +func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) []byte { + size := xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 105 // request opcode + buf[b] = 118 // request opcode b += 1 - b += 1 // padding + buf[b] = KeycodesPerModifier + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], uint16(AccelerationNumerator)) - b += 2 - - xgb.Put16(buf[b:], uint16(AccelerationDenominator)) - b += 2 - - xgb.Put16(buf[b:], uint16(Threshold)) - b += 2 - - if DoAcceleration { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if DoThreshold { - buf[b] = 1 - } else { - buf[b] = 0 + for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { + buf[b] = byte(Keycodes[i]) + b += 1 } - b += 1 + b = xgb.Pad(b) return buf } -// GetPointerControlCookie is a cookie used only for GetPointerControl requests. -type GetPointerControlCookie struct { +// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. +type SetPointerMappingCookie struct { *xgb.Cookie } -// GetPointerControl sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPointerControlCookie.Reply() -func GetPointerControl(c *xgb.Conn) GetPointerControlCookie { +// SetPointerMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetPointerMappingCookie.Reply() +func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { cookie := c.NewCookie(true, true) - c.NewRequest(getPointerControlRequest(c), cookie) - return GetPointerControlCookie{cookie} + c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) + return SetPointerMappingCookie{cookie} } -// GetPointerControlUnchecked sends an unchecked request. +// SetPointerMappingUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { +func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { cookie := c.NewCookie(false, true) - c.NewRequest(getPointerControlRequest(c), cookie) - return GetPointerControlCookie{cookie} + c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) + return SetPointerMappingCookie{cookie} } -// GetPointerControlReply represents the data returned from a GetPointerControl request. -type GetPointerControlReply struct { +// SetPointerMappingReply represents the data returned from a SetPointerMapping request. +type SetPointerMappingReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply - // padding: 1 bytes - AccelerationNumerator uint16 - AccelerationDenominator uint16 - Threshold uint16 - // padding: 18 bytes + Status byte } -// Reply blocks and returns the reply data for a GetPointerControl request. -func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { +// Reply blocks and returns the reply data for a SetPointerMapping request. +func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -13913,15 +14042,16 @@ func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { if buf == nil { return nil, nil } - return getPointerControlReply(buf), nil + return setPointerMappingReply(buf), nil } -// getPointerControlReply reads a byte slice into a GetPointerControlReply value. -func getPointerControlReply(buf []byte) *GetPointerControlReply { - v := new(GetPointerControlReply) +// setPointerMappingReply reads a byte slice into a SetPointerMappingReply value. +func setPointerMappingReply(buf []byte) *SetPointerMappingReply { + v := new(SetPointerMappingReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -13929,34 +14059,28 @@ func getPointerControlReply(buf []byte) *GetPointerControlReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.AccelerationNumerator = xgb.Get16(buf[b:]) - b += 2 - - v.AccelerationDenominator = xgb.Get16(buf[b:]) - b += 2 - - v.Threshold = xgb.Get16(buf[b:]) - b += 2 - - b += 18 // padding - return v } -// Write request to wire for GetPointerControl -// getPointerControlRequest writes a GetPointerControl request to a byte slice. -func getPointerControlRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for SetPointerMapping +// setPointerMappingRequest writes a SetPointerMapping request to a byte slice. +func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { + size := xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 106 // request opcode + buf[b] = 116 // request opcode + b += 1 + + buf[b] = MapLen b += 1 - b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + copy(buf[b:], Map[:MapLen]) + b += xgb.Pad(int(MapLen)) + return buf } @@ -14017,188 +14141,203 @@ func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBla return buf } -// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. -type GetScreenSaverCookie struct { +// SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests. +type SetSelectionOwnerCookie struct { *xgb.Cookie } -// GetScreenSaver sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetScreenSaverCookie.Reply() -func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getScreenSaverRequest(c), cookie) - return GetScreenSaverCookie{cookie} -} - -// GetScreenSaverUnchecked sends an unchecked request. +// SetSelectionOwner sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getScreenSaverRequest(c), cookie) - return GetScreenSaverCookie{cookie} +func SetSelectionOwner(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} } -// GetScreenSaverReply represents the data returned from a GetScreenSaver request. -type GetScreenSaverReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Timeout uint16 - Interval uint16 - PreferBlanking byte - AllowExposures byte - // padding: 18 bytes +// SetSelectionOwnerChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionOwnerCookie.Check() +func SetSelectionOwnerChecked(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} } -// Reply blocks and returns the reply data for a GetScreenSaver request. -func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getScreenSaverReply(buf), nil +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetSelectionOwnerCookie) Check() error { + return cook.Cookie.Check() } -// getScreenSaverReply reads a byte slice into a GetScreenSaverReply value. -func getScreenSaverReply(buf []byte) *GetScreenSaverReply { - v := new(GetScreenSaverReply) - b := 1 // skip reply determinant +// Write request to wire for SetSelectionOwner +// setSelectionOwnerRequest writes a SetSelectionOwner request to a byte slice. +func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 22 // request opcode + b += 1 b += 1 // padding - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Owner)) b += 4 - v.Timeout = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 - v.Interval = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 - v.PreferBlanking = buf[b] - b += 1 + return buf +} - v.AllowExposures = buf[b] - b += 1 +// StoreColorsCookie is a cookie used only for StoreColors requests. +type StoreColorsCookie struct { + *xgb.Cookie +} - b += 18 // padding +// StoreColors sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func StoreColors(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) + return StoreColorsCookie{cookie} +} - return v +// StoreColorsChecked sends a checked request. +// If an error occurs, it can be retrieved using StoreColorsCookie.Check() +func StoreColorsChecked(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) + return StoreColorsCookie{cookie} } -// Write request to wire for GetScreenSaver -// getScreenSaverRequest writes a GetScreenSaver request to a byte slice. -func getScreenSaverRequest(c *xgb.Conn) []byte { - size := 4 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook StoreColorsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StoreColors +// storeColorsRequest writes a StoreColors request to a byte slice. +func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) b := 0 buf := make([]byte, size) - buf[b] = 108 // request opcode + buf[b] = 89 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + b += ColoritemListBytes(buf[b:], Items) + return buf } -// ChangeHostsCookie is a cookie used only for ChangeHosts requests. -type ChangeHostsCookie struct { +// StoreNamedColorCookie is a cookie used only for StoreNamedColor requests. +type StoreNamedColorCookie struct { *xgb.Cookie } -// ChangeHosts sends an unchecked request. +// StoreNamedColor sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { +func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { cookie := c.NewCookie(false, false) - c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} + c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) + return StoreNamedColorCookie{cookie} } -// ChangeHostsChecked sends a checked request. -// If an error occurs, it can be retrieved using ChangeHostsCookie.Check() -func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { +// StoreNamedColorChecked sends a checked request. +// If an error occurs, it can be retrieved using StoreNamedColorCookie.Check() +func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { cookie := c.NewCookie(true, false) - c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} + c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) + return StoreNamedColorCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ChangeHostsCookie) Check() error { +func (cook StoreNamedColorCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ChangeHosts -// changeHostsRequest writes a ChangeHosts request to a byte slice. -func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { - size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) +// Write request to wire for StoreNamedColor +// storeNamedColorRequest writes a StoreNamedColor request to a byte slice. +func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) b := 0 buf := make([]byte, size) - buf[b] = 109 // request opcode + buf[b] = 90 // request opcode b += 1 - buf[b] = Mode + buf[b] = Flags b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = Family - b += 1 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 - b += 1 // padding + xgb.Put32(buf[b:], Pixel) + b += 4 - xgb.Put16(buf[b:], AddressLen) + xgb.Put16(buf[b:], NameLen) b += 2 - copy(buf[b:], Address[:AddressLen]) - b += xgb.Pad(int(AddressLen)) + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) return buf } -// ListHostsCookie is a cookie used only for ListHosts requests. -type ListHostsCookie struct { +// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. +type TranslateCoordinatesCookie struct { *xgb.Cookie } -// ListHosts sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListHostsCookie.Reply() -func ListHosts(c *xgb.Conn) ListHostsCookie { +// TranslateCoordinates sends a checked request. +// If an error occurs, it will be returned with the reply by calling TranslateCoordinatesCookie.Reply() +func TranslateCoordinates(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { cookie := c.NewCookie(true, true) - c.NewRequest(listHostsRequest(c), cookie) - return ListHostsCookie{cookie} + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} } -// ListHostsUnchecked sends an unchecked request. +// TranslateCoordinatesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { +func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { cookie := c.NewCookie(false, true) - c.NewRequest(listHostsRequest(c), cookie) - return ListHostsCookie{cookie} + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} } -// ListHostsReply represents the data returned from a ListHosts request. -type ListHostsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Mode byte - HostsLen uint16 - // padding: 22 bytes - Hosts []Host // size: HostListSize(Hosts) +// TranslateCoordinatesReply represents the data returned from a TranslateCoordinates request. +type TranslateCoordinatesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + SameScreen bool + Child Window + DstX int16 + DstY int16 } -// Reply blocks and returns the reply data for a ListHosts request. -func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { +// Reply blocks and returns the reply data for a TranslateCoordinates request. +func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -14206,15 +14345,19 @@ func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { if buf == nil { return nil, nil } - return listHostsReply(buf), nil + return translateCoordinatesReply(buf), nil } -// listHostsReply reads a byte slice into a ListHostsReply value. -func listHostsReply(buf []byte) *ListHostsReply { - v := new(ListHostsReply) +// translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value. +func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { + v := new(TranslateCoordinatesReply) b := 1 // skip reply determinant - v.Mode = buf[b] + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } b += 1 v.Sequence = xgb.Get16(buf[b:]) @@ -14223,209 +14366,191 @@ func listHostsReply(buf []byte) *ListHostsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.HostsLen = xgb.Get16(buf[b:]) - b += 2 + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 - b += 22 // padding + v.DstX = int16(xgb.Get16(buf[b:])) + b += 2 - v.Hosts = make([]Host, v.HostsLen) - b += HostReadList(buf[b:], v.Hosts) + v.DstY = int16(xgb.Get16(buf[b:])) + b += 2 return v } -// Write request to wire for ListHosts -// listHostsRequest writes a ListHosts request to a byte slice. -func listHostsRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for TranslateCoordinates +// translateCoordinatesRequest writes a TranslateCoordinates request to a byte slice. +func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { + size := 16 b := 0 buf := make([]byte, size) - buf[b] = 110 // request opcode + buf[b] = 40 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - return buf -} - -// SetAccessControlCookie is a cookie used only for SetAccessControl requests. -type SetAccessControlCookie struct { - *xgb.Cookie -} - -// SetAccessControl sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie { - cookie := c.NewCookie(false, false) - c.NewRequest(setAccessControlRequest(c, Mode), cookie) - return SetAccessControlCookie{cookie} -} - -// SetAccessControlChecked sends a checked request. -// If an error occurs, it can be retrieved using SetAccessControlCookie.Check() -func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie { - cookie := c.NewCookie(true, false) - c.NewRequest(setAccessControlRequest(c, Mode), cookie) - return SetAccessControlCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetAccessControlCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetAccessControl -// setAccessControlRequest writes a SetAccessControl request to a byte slice. -func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { - size := 4 - b := 0 - buf := make([]byte, size) + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 - buf[b] = 111 // request opcode - b += 1 + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 - buf[b] = Mode - b += 1 + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + xgb.Put16(buf[b:], uint16(SrcY)) b += 2 return buf } -// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. -type SetCloseDownModeCookie struct { +// UngrabButtonCookie is a cookie used only for UngrabButton requests. +type UngrabButtonCookie struct { *xgb.Cookie } -// SetCloseDownMode sends an unchecked request. +// UngrabButton sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { +func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { cookie := c.NewCookie(false, false) - c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) - return SetCloseDownModeCookie{cookie} + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{cookie} } -// SetCloseDownModeChecked sends a checked request. -// If an error occurs, it can be retrieved using SetCloseDownModeCookie.Check() -func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { +// UngrabButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabButtonCookie.Check() +func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { cookie := c.NewCookie(true, false) - c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) - return SetCloseDownModeCookie{cookie} + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetCloseDownModeCookie) Check() error { +func (cook UngrabButtonCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetCloseDownMode -// setCloseDownModeRequest writes a SetCloseDownMode request to a byte slice. -func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { - size := 4 +// Write request to wire for UngrabButton +// ungrabButtonRequest writes a UngrabButton request to a byte slice. +func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 112 // request opcode + buf[b] = 29 // request opcode b += 1 - buf[b] = Mode + buf[b] = Button b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + return buf } -// KillClientCookie is a cookie used only for KillClient requests. -type KillClientCookie struct { +// UngrabKeyCookie is a cookie used only for UngrabKey requests. +type UngrabKeyCookie struct { *xgb.Cookie } -// KillClient sends an unchecked request. +// UngrabKey sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { +func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { cookie := c.NewCookie(false, false) - c.NewRequest(killClientRequest(c, Resource), cookie) - return KillClientCookie{cookie} + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{cookie} } -// KillClientChecked sends a checked request. -// If an error occurs, it can be retrieved using KillClientCookie.Check() -func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { +// UngrabKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabKeyCookie.Check() +func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { cookie := c.NewCookie(true, false) - c.NewRequest(killClientRequest(c, Resource), cookie) - return KillClientCookie{cookie} + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook KillClientCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for KillClient -// killClientRequest writes a KillClient request to a byte slice. -func killClientRequest(c *xgb.Conn, Resource uint32) []byte { - size := 8 +func (cook UngrabKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabKey +// ungrabKeyRequest writes a UngrabKey request to a byte slice. +func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte { + size := 12 b := 0 buf := make([]byte, size) - buf[b] = 113 // request opcode + buf[b] = 34 // request opcode b += 1 - b += 1 // padding + buf[b] = byte(Key) + b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], Resource) + xgb.Put32(buf[b:], uint32(GrabWindow)) b += 4 + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + return buf } -// RotatePropertiesCookie is a cookie used only for RotateProperties requests. -type RotatePropertiesCookie struct { +// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. +type UngrabKeyboardCookie struct { *xgb.Cookie } -// RotateProperties sends an unchecked request. +// UngrabKeyboard sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { +func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { cookie := c.NewCookie(false, false) - c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{cookie} } -// RotatePropertiesChecked sends a checked request. -// If an error occurs, it can be retrieved using RotatePropertiesCookie.Check() -func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { +// UngrabKeyboardChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabKeyboardCookie.Check() +func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { cookie := c.NewCookie(true, false) - c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook RotatePropertiesCookie) Check() error { +func (cook UngrabKeyboardCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for RotateProperties -// rotatePropertiesRequest writes a RotateProperties request to a byte slice. -func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { - size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) +// Write request to wire for UngrabKeyboard +// ungrabKeyboardRequest writes a UngrabKeyboard request to a byte slice. +func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 114 // request opcode + buf[b] = 32 // request opcode b += 1 b += 1 // padding @@ -14433,438 +14558,313 @@ func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Time)) b += 4 - xgb.Put16(buf[b:], AtomsLen) - b += 2 - - xgb.Put16(buf[b:], uint16(Delta)) - b += 2 - - for i := 0; i < int(AtomsLen); i++ { - xgb.Put32(buf[b:], uint32(Atoms[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. -type ForceScreenSaverCookie struct { +// UngrabPointerCookie is a cookie used only for UngrabPointer requests. +type UngrabPointerCookie struct { *xgb.Cookie } -// ForceScreenSaver sends an unchecked request. +// UngrabPointer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { +func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(false, false) - c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) - return ForceScreenSaverCookie{cookie} + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} } -// ForceScreenSaverChecked sends a checked request. -// If an error occurs, it can be retrieved using ForceScreenSaverCookie.Check() -func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { +// UngrabPointerChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabPointerCookie.Check() +func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(true, false) - c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) - return ForceScreenSaverCookie{cookie} + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ForceScreenSaverCookie) Check() error { +func (cook UngrabPointerCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for ForceScreenSaver -// forceScreenSaverRequest writes a ForceScreenSaver request to a byte slice. -func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { - size := 4 +// Write request to wire for UngrabPointer +// ungrabPointerRequest writes a UngrabPointer request to a byte slice. +func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 115 // request opcode + buf[b] = 27 // request opcode b += 1 - buf[b] = Mode - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + return buf } -// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. -type SetPointerMappingCookie struct { +// UngrabServerCookie is a cookie used only for UngrabServer requests. +type UngrabServerCookie struct { *xgb.Cookie } -// SetPointerMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetPointerMappingCookie.Reply() -func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) - return SetPointerMappingCookie{cookie} -} - -// SetPointerMappingUnchecked sends an unchecked request. +// UngrabServer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) - return SetPointerMappingCookie{cookie} -} - -// SetPointerMappingReply represents the data returned from a SetPointerMapping request. -type SetPointerMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte +func UngrabServer(c *xgb.Conn) UngrabServerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{cookie} } -// Reply blocks and returns the reply data for a SetPointerMapping request. -func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setPointerMappingReply(buf), nil +// UngrabServerChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabServerCookie.Check() +func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{cookie} } -// setPointerMappingReply reads a byte slice into a SetPointerMappingReply value. -func setPointerMappingReply(buf []byte) *SetPointerMappingReply { - v := new(SetPointerMappingReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook UngrabServerCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for SetPointerMapping -// setPointerMappingRequest writes a SetPointerMapping request to a byte slice. -func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { - size := xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) +// Write request to wire for UngrabServer +// ungrabServerRequest writes a UngrabServer request to a byte slice. +func ungrabServerRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) - buf[b] = 116 // request opcode - b += 1 - - buf[b] = MapLen + buf[b] = 37 // request opcode b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - copy(buf[b:], Map[:MapLen]) - b += xgb.Pad(int(MapLen)) - return buf } -// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. -type GetPointerMappingCookie struct { +// UninstallColormapCookie is a cookie used only for UninstallColormap requests. +type UninstallColormapCookie struct { *xgb.Cookie } -// GetPointerMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPointerMappingCookie.Reply() -func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getPointerMappingRequest(c), cookie) - return GetPointerMappingCookie{cookie} -} - -// GetPointerMappingUnchecked sends an unchecked request. +// UninstallColormap sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPointerMappingUnchecked(c *xgb.Conn) GetPointerMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getPointerMappingRequest(c), cookie) - return GetPointerMappingCookie{cookie} -} - -// GetPointerMappingReply represents the data returned from a GetPointerMapping request. -type GetPointerMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - MapLen byte - // padding: 24 bytes - Map []byte // size: xgb.Pad((int(MapLen) * 1)) +func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} } -// Reply blocks and returns the reply data for a GetPointerMapping request. -func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPointerMappingReply(buf), nil +// UninstallColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using UninstallColormapCookie.Check() +func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} } -// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. -func getPointerMappingReply(buf []byte) *GetPointerMappingReply { - v := new(GetPointerMappingReply) - b := 1 // skip reply determinant - - v.MapLen = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Map = make([]byte, v.MapLen) - copy(v.Map[:v.MapLen], buf[b:]) - b += xgb.Pad(int(v.MapLen)) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook UninstallColormapCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetPointerMapping -// getPointerMappingRequest writes a GetPointerMapping request to a byte slice. -func getPointerMappingRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for UninstallColormap +// uninstallColormapRequest writes a UninstallColormap request to a byte slice. +func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 117 // request opcode + buf[b] = 82 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + return buf } -// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. -type SetModifierMappingCookie struct { +// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. +type UnmapSubwindowsCookie struct { *xgb.Cookie } -// SetModifierMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling SetModifierMappingCookie.Reply() -func SetModifierMapping(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) - return SetModifierMappingCookie{cookie} -} - -// SetModifierMappingUnchecked sends an unchecked request. +// UnmapSubwindows sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetModifierMappingUnchecked(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) - return SetModifierMappingCookie{cookie} -} - -// SetModifierMappingReply represents the data returned from a SetModifierMapping request. -type SetModifierMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - Status byte +func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} } -// Reply blocks and returns the reply data for a SetModifierMapping request. -func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setModifierMappingReply(buf), nil +// UnmapSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using UnmapSubwindowsCookie.Check() +func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} } -// setModifierMappingReply reads a byte slice into a SetModifierMappingReply value. -func setModifierMappingReply(buf []byte) *SetModifierMappingReply { - v := new(SetModifierMappingReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook UnmapSubwindowsCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for SetModifierMapping -// setModifierMappingRequest writes a SetModifierMapping request to a byte slice. -func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) []byte { - size := xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +// Write request to wire for UnmapSubwindows +// unmapSubwindowsRequest writes a UnmapSubwindows request to a byte slice. +func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 118 // request opcode + buf[b] = 11 // request opcode b += 1 - buf[b] = KeycodesPerModifier - b += 1 + b += 1 // padding xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { - buf[b] = byte(Keycodes[i]) - b += 1 - } - b = xgb.Pad(b) + xgb.Put32(buf[b:], uint32(Window)) + b += 4 return buf } -// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. -type GetModifierMappingCookie struct { +// UnmapWindowCookie is a cookie used only for UnmapWindow requests. +type UnmapWindowCookie struct { *xgb.Cookie } -// GetModifierMapping sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetModifierMappingCookie.Reply() -func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie { - cookie := c.NewCookie(true, true) - c.NewRequest(getModifierMappingRequest(c), cookie) - return GetModifierMappingCookie{cookie} -} - -// GetModifierMappingUnchecked sends an unchecked request. +// UnmapWindow sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { - cookie := c.NewCookie(false, true) - c.NewRequest(getModifierMappingRequest(c), cookie) - return GetModifierMappingCookie{cookie} -} - -// GetModifierMappingReply represents the data returned from a GetModifierMapping request. -type GetModifierMappingReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - KeycodesPerModifier byte - // padding: 24 bytes - Keycodes []Keycode // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) +func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} } -// Reply blocks and returns the reply data for a GetModifierMapping request. -func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getModifierMappingReply(buf), nil +// UnmapWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using UnmapWindowCookie.Check() +func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} } -// getModifierMappingReply reads a byte slice into a GetModifierMappingReply value. -func getModifierMappingReply(buf []byte) *GetModifierMappingReply { - v := new(GetModifierMappingReply) - b := 1 // skip reply determinant - - v.KeycodesPerModifier = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) - for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { - v.Keycodes[i] = Keycode(buf[b]) - b += 1 - } - b = xgb.Pad(b) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook UnmapWindowCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetModifierMapping -// getModifierMappingRequest writes a GetModifierMapping request to a byte slice. -func getModifierMappingRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for UnmapWindow +// unmapWindowRequest writes a UnmapWindow request to a byte slice. +func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 b := 0 buf := make([]byte, size) - buf[b] = 119 // request opcode + buf[b] = 10 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + return buf } -// NoOperationCookie is a cookie used only for NoOperation requests. -type NoOperationCookie struct { +// WarpPointerCookie is a cookie used only for WarpPointer requests. +type WarpPointerCookie struct { *xgb.Cookie } -// NoOperation sends an unchecked request. +// WarpPointer sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func NoOperation(c *xgb.Conn) NoOperationCookie { +func WarpPointer(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { cookie := c.NewCookie(false, false) - c.NewRequest(noOperationRequest(c), cookie) - return NoOperationCookie{cookie} + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} } -// NoOperationChecked sends a checked request. -// If an error occurs, it can be retrieved using NoOperationCookie.Check() -func NoOperationChecked(c *xgb.Conn) NoOperationCookie { +// WarpPointerChecked sends a checked request. +// If an error occurs, it can be retrieved using WarpPointerCookie.Check() +func WarpPointerChecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { cookie := c.NewCookie(true, false) - c.NewRequest(noOperationRequest(c), cookie) - return NoOperationCookie{cookie} + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook NoOperationCookie) Check() error { +func (cook WarpPointerCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for NoOperation -// noOperationRequest writes a NoOperation request to a byte slice. -func noOperationRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for WarpPointer +// warpPointerRequest writes a WarpPointer request to a byte slice. +func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { + size := 24 b := 0 buf := make([]byte, size) - buf[b] = 127 // request opcode + buf[b] = 41 // request opcode b += 1 - b += 1 // padding + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcWidth) + b += 2 + + xgb.Put16(buf[b:], SrcHeight) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + return buf } -- cgit v1.2.3-70-g09d2