haven/nexgb/xproto/xproto.go

15514 lines
413 KiB
Go
Raw Normal View History

2012-05-11 02:06:22 +02:00
// Package xproto is the X client API for the extension.
package xproto
// This file is automatically generated from xproto.xml. Edit at your peril!
import (
2018-09-08 19:57:27 +02:00
xgb "janouch.name/haven/nexgb"
)
// Setup parses the setup bytes retrieved when
// connecting into a SetupInfo struct.
func Setup(c *xgb.Conn) *SetupInfo {
setup := new(SetupInfo)
SetupInfoRead(c.SetupBytes, setup)
return setup
}
// DefaultScreen gets the default screen info from SetupInfo.
func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo {
return &s.Roots[c.DefaultScreen]
}
2013-08-12 02:43:26 +02:00
// BadAccess is the error number for a BadAccess.
const BadAccess = 10
2013-08-12 02:43:26 +02:00
type AccessError RequestError
2012-05-11 02:06:22 +02:00
2013-08-12 02:43:26 +02:00
// 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
}
2012-05-11 02:06:22 +02:00
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadAccess error.
// This is mostly used internally.
func (err AccessError) SequenceId() uint16 {
return err.Sequence
}
2012-05-11 05:57:34 +02:00
2013-08-12 02:43:26 +02:00
// 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
}
2012-05-11 05:57:34 +02:00
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2012-05-11 05:57:34 +02:00
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewErrorFuncs[10] = AccessErrorNew
}
2012-05-11 05:57:34 +02:00
2013-08-12 02:43:26 +02:00
const (
AccessControlDisable = 0
AccessControlEnable = 1
)
2012-05-11 05:57:34 +02:00
2013-08-12 02:43:26 +02:00
// BadAlloc is the error number for a BadAlloc.
const BadAlloc = 11
2012-06-05 06:14:34 +02:00
2013-08-12 02:43:26 +02:00
type AllocError RequestError
2012-06-05 06:14:34 +02:00
2013-08-12 02:43:26 +02:00
// 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
}
2012-06-05 06:14:34 +02:00
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadAlloc error.
// This is mostly used internally.
func (err AllocError) SequenceId() uint16 {
return err.Sequence
}
2012-06-05 06:14:34 +02:00
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewErrorFuncs[11] = AllocErrorNew
}
const (
2013-08-12 02:43:26 +02:00
AllowAsyncPointer = 0
AllowSyncPointer = 1
AllowReplayPointer = 2
AllowAsyncKeyboard = 3
AllowSyncKeyboard = 4
AllowReplayKeyboard = 5
AllowAsyncBoth = 6
AllowSyncBoth = 7
)
2013-08-12 02:43:26 +02:00
type Arc struct {
X int16
Y int16
Width uint16
Height uint16
Angle1 int16
Angle2 int16
}
2013-08-12 02:43:26 +02:00
// ArcRead reads a byte slice into a Arc value.
func ArcRead(buf []byte, v *Arc) int {
b := 0
2013-08-12 02:43:26 +02:00
v.X = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Width = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Height = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Angle1 = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Angle2 = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
return b
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a Arc value to a byte slice.
func (v Arc) Bytes() []byte {
buf := make([]byte, 12)
b := 0
2013-08-12 02:43:26 +02:00
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[:b]
2013-08-12 02:43:26 +02:00
}
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
2013-08-12 02:43:26 +02:00
}
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
AtomDrawable = 17
AtomFont = 18
AtomInteger = 19
AtomPixmap = 20
AtomPoint = 21
AtomRectangle = 22
AtomResourceManager = 23
AtomRgbColorMap = 24
AtomRgbBestMap = 25
AtomRgbBlueMap = 26
AtomRgbDefaultMap = 27
AtomRgbGrayMap = 28
AtomRgbGreenMap = 29
AtomRgbRedMap = 30
AtomString = 31
AtomVisualid = 32
AtomWindow = 33
AtomWmCommand = 34
AtomWmHints = 35
AtomWmClientMachine = 36
AtomWmIconName = 37
AtomWmIconSize = 38
AtomWmName = 39
AtomWmNormalHints = 40
AtomWmSizeHints = 41
AtomWmZoomHints = 42
AtomMinSpace = 43
AtomNormSpace = 44
AtomMaxSpace = 45
AtomEndSpace = 46
AtomSuperscriptX = 47
AtomSuperscriptY = 48
AtomSubscriptX = 49
AtomSubscriptY = 50
AtomUnderlinePosition = 51
AtomUnderlineThickness = 52
AtomStrikeoutAscent = 53
AtomStrikeoutDescent = 54
AtomItalicAngle = 55
AtomXHeight = 56
AtomQuadWidth = 57
AtomWeight = 58
AtomPointSize = 59
AtomResolution = 60
AtomCopyright = 61
AtomNotice = 62
AtomFontName = 63
AtomFamilyName = 64
AtomFullName = 65
AtomCapHeight = 66
AtomWmClass = 67
AtomWmTransientFor = 68
)
2013-08-12 02:43:26 +02:00
// BadAtom is the error number for a BadAtom.
const BadAtom = 5
2013-08-12 02:43:26 +02:00
type AtomError ValueError
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadAtom error.
// This is mostly used internally.
func (err AtomError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewErrorFuncs[5] = AtomErrorNew
}
const (
2013-08-12 02:43:26 +02:00
AutoRepeatModeOff = 0
AutoRepeatModeOn = 1
AutoRepeatModeDefault = 2
)
const (
2013-08-12 02:43:26 +02:00
BackPixmapNone = 0
BackPixmapParentRelative = 1
)
const (
2013-08-12 02:43:26 +02:00
BackingStoreNotUseful = 0
BackingStoreWhenMapped = 1
BackingStoreAlways = 2
)
const (
2013-08-12 02:43:26 +02:00
BlankingNotPreferred = 0
BlankingPreferred = 1
BlankingDefault = 2
)
2017-01-18 10:52:16 +01:00
type Bool32 uint32
2013-08-12 02:43:26 +02:00
type Button byte
const (
ButtonIndexAny = 0
ButtonIndex1 = 1
ButtonIndex2 = 2
ButtonIndex3 = 3
ButtonIndex4 = 4
ButtonIndex5 = 5
)
const (
2013-08-12 02:43:26 +02:00
ButtonMask1 = 256
ButtonMask2 = 512
ButtonMask3 = 1024
ButtonMask4 = 2048
ButtonMask5 = 4096
ButtonMaskAny = 32768
)
2013-08-12 02:43:26 +02:00
// ButtonPress is the event number for a ButtonPressEvent.
const ButtonPress = 4
2013-08-12 02:43:26 +02:00
type ButtonPressEvent struct {
Sequence uint16
// The keycode (a number representing a physical key on the keyboard) of the key
// which was pressed.
Detail Button
// Time when the event was generated (in milliseconds).
Time Timestamp
// The root window of Child.
Root Window
Event Window
Child Window
// The X coordinate of the pointer relative to the Root window at the time of
// the event.
RootX int16
// The Y coordinate of the pointer relative to the Root window at the time of
// the event.
RootY int16
// If SameScreen is true, this is the X coordinate relative to the Event
// window's origin. Otherwise, EventX will be set to zero.
EventX int16
// If SameScreen is true, this is the Y coordinate relative to the Event
// window's origin. Otherwise, EventY will be set to zero.
EventY int16
// The logical state of the pointer buttons and modifier keys just prior to the
// event.
State uint16
// Whether the Event window is on the same screen as the Root window.
2013-08-12 02:43:26 +02:00
SameScreen bool
// padding: 1 bytes
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Detail = Button(buf[b])
b += 1
2013-08-12 02:43:26 +02:00
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 (
2013-08-12 02:43:26 +02:00
CapStyleNotLast = 0
CapStyleButt = 1
CapStyleRound = 2
CapStyleProjecting = 3
)
2013-08-12 02:43:26 +02:00
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[:b]
2013-08-12 02:43:26 +02:00
}
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
2013-08-12 02:43:26 +02:00
}
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
2013-08-12 02:43:26 +02:00
return b
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a Charinfo value to a byte slice.
func (v Charinfo) Bytes() []byte {
buf := make([]byte, 12)
b := 0
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.LeftSideBearing))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.RightSideBearing))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.CharacterWidth))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Ascent))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Descent))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Attributes)
b += 2
return buf[:b]
2013-08-12 02:43:26 +02:00
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
2013-08-12 02:43:26 +02:00
}
const (
2013-08-12 02:43:26 +02:00
CirculateRaiseLowest = 0
CirculateLowerHighest = 1
)
2013-08-12 02:43:26 +02:00
// CirculateNotify is the event number for a CirculateNotifyEvent.
const CirculateNotify = 26
2013-08-12 02:43:26 +02:00
type CirculateNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
// Either the restacked window or its parent, depending on whether
// StructureNotify or SubstructureNotify was selected.
Event Window
// The restacked window.
2013-08-12 02:43:26 +02:00
Window Window
// padding: 4 bytes
Place byte
// padding: 3 bytes
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Event = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
b += 4 // padding
2013-08-12 02:43:26 +02:00
v.Place = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a CirculateNotifyEvent value to a byte slice.
func (v CirculateNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 26
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Event))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
b += 4 // padding
2013-08-12 02:43:26 +02:00
buf[b] = v.Place
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[26] = CirculateNotifyEventNew
}
2013-08-12 02:43:26 +02:00
// CirculateRequest is the event number for a CirculateRequestEvent.
const CirculateRequest = 27
2013-08-12 02:43:26 +02:00
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))
}
2013-08-12 02:43:26 +02:00
// Bytes writes a CirculateRequestEvent value to a byte slice.
func (v CirculateRequestEvent) Bytes() []byte {
return CirculateNotifyEvent(v).Bytes()
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[27] = CirculateRequestEventNew
}
2013-08-12 02:43:26 +02:00
// ClientMessage is the event number for a ClientMessageEvent.
const ClientMessage = 33
2013-08-12 02:43:26 +02:00
type ClientMessageEvent struct {
Sequence uint16
// Specifies how to interpret Data. Can be either 8, 16 or 32.
Format byte
Window Window
// An atom which indicates how the data should be interpreted by the receiving
// client.
Type Atom
// The data itself (20 bytes max).
Data ClientMessageDataUnion
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Format = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Type = Atom(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Data = ClientMessageDataUnion{}
b += ClientMessageDataUnionRead(buf[b:], &v.Data)
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a ClientMessageEvent value to a byte slice.
func (v ClientMessageEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 33
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.Format
b += 1
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Type))
b += 4
2013-08-12 02:43:26 +02:00
{
unionBytes := v.Data.Bytes()
copy(buf[b:], unionBytes)
b += len(unionBytes)
2013-08-12 02:43:26 +02:00
}
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[33] = ClientMessageEventNew
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// ClientMessageDataUnionData8New constructs a new ClientMessageDataUnion union type with the Data8 field.
func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion {
var b int
buf := make([]byte, 20)
2013-08-12 02:43:26 +02:00
copy(buf[b:], Data8[:20])
b += int(20)
2013-08-12 02:43:26 +02:00
// Create the Union type
v := ClientMessageDataUnion{}
2013-08-12 02:43:26 +02:00
// Now copy buf into all fields
2013-08-12 02:43:26 +02:00
b = 0 // always read the same bytes
v.Data8 = make([]byte, 20)
copy(v.Data8[:20], buf[b:])
b += int(20)
2013-08-12 02:43:26 +02:00
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 = 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
}
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// ClientMessageDataUnionData16New constructs a new ClientMessageDataUnion union type with the Data16 field.
func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion {
var b int
buf := make([]byte, 20)
2013-08-12 02:43:26 +02:00
for i := 0; i < int(10); i++ {
xgb.Put16(buf[b:], Data16[i])
b += 2
}
2013-08-12 02:43:26 +02:00
// Create the Union type
v := ClientMessageDataUnion{}
2013-08-12 02:43:26 +02:00
// Now copy buf into all fields
2013-08-12 02:43:26 +02:00
b = 0 // always read the same bytes
v.Data8 = make([]byte, 20)
copy(v.Data8[:20], buf[b:])
b += int(20)
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// ClientMessageDataUnionData32New constructs a new ClientMessageDataUnion union type with the Data32 field.
func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion {
var b int
buf := make([]byte, 20)
2013-08-12 02:43:26 +02:00
for i := 0; i < int(5); i++ {
xgb.Put32(buf[b:], Data32[i])
b += 4
}
2013-08-12 02:43:26 +02:00
// Create the Union type
v := ClientMessageDataUnion{}
2013-08-12 02:43:26 +02:00
// Now copy buf into all fields
2013-08-12 02:43:26 +02:00
b = 0 // always read the same bytes
v.Data8 = make([]byte, 20)
copy(v.Data8[:20], buf[b:])
b += int(20)
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// ClientMessageDataUnionRead reads a byte slice into a ClientMessageDataUnion value.
func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int {
var b int
2013-08-12 02:43:26 +02:00
b = 0 // re-read the same bytes
v.Data8 = make([]byte, 20)
copy(v.Data8[:20], buf[b:])
b += int(20)
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
return 20
}
2013-08-12 02:43:26 +02:00
// 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++ {
2013-08-12 02:43:26 +02:00
dest[i] = ClientMessageDataUnion{}
b += ClientMessageDataUnionRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
copy(buf[b:], v.Data8[:20])
b += int(20)
return buf
}
// ClientMessageDataUnionListBytes writes a list of ClientMessageDataUnion values to a byte slice.
2013-08-12 02:43:26 +02:00
func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int {
b := 0
2013-08-12 02:43:26 +02:00
var unionBytes []byte
for _, item := range list {
2013-08-12 02:43:26 +02:00
unionBytes = item.Bytes()
copy(buf[b:], unionBytes)
b += xgb.Pad(len(unionBytes))
}
return b
}
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// ColoritemRead reads a byte slice into a Coloritem value.
func ColoritemRead(buf []byte, v *Coloritem) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Pixel = xgb.Get32(buf[b:])
b += 4
v.Red = xgb.Get16(buf[b:])
b += 2
v.Green = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Blue = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Flags = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return b
}
2013-08-12 02:43:26 +02:00
// 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++ {
2013-08-12 02:43:26 +02:00
dest[i] = Coloritem{}
b += ColoritemRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a Coloritem value to a byte slice.
func (v Coloritem) Bytes() []byte {
buf := make([]byte, 12)
b := 0
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], v.Pixel)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Red)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Green)
b += 2
xgb.Put16(buf[b:], v.Blue)
b += 2
buf[b] = v.Flags
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
type Colormap uint32
func NewColormapId(c *xgb.Conn) (Colormap, error) {
id, err := c.NewId()
if err != nil {
return 0, err
}
return Colormap(id), nil
}
2017-01-18 10:52:16 +01:00
const (
ColormapNone = 0
)
2013-08-12 02:43:26 +02:00
// BadColormap is the error number for a BadColormap.
const BadColormap = 12
2013-08-12 02:43:26 +02:00
type ColormapError ValueError
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadColormap error.
// This is mostly used internally.
func (err ColormapError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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 (
ColormapAllocNone = 0
ColormapAllocAll = 1
)
// ColormapNotify is the event number for a ColormapNotifyEvent.
const ColormapNotify = 32
type ColormapNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
// The window whose associated colormap is changed, installed or uninstalled.
Window Window
// The colormap which is changed, installed or uninstalled. This is None
// when the colormap is changed by a call to FreeColormap.
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Colormap = Colormap(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
if buf[b] == 1 {
v.New = true
} else {
v.New = false
}
b += 1
2013-08-12 02:43:26 +02:00
v.State = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a ColormapNotifyEvent value to a byte slice.
func (v ColormapNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Colormap))
b += 4
if v.New {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.State
b += 1
2013-08-12 02:43:26 +02:00
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
// The reconfigured window or its parent, depending on whether StructureNotify
// or SubstructureNotify was selected.
Event Window
// The window whose size, position, border, and/or stacking order was changed.
Window Window
// If None, the Window is on the bottom of the stack with respect to
// sibling windows. However, if set to a sibling window, the Window is placed on
// top of this sibling window.
AboveSibling Window
// The X coordinate of the upper-left outside corner of Window, relative to the
// parent window's origin.
X int16
// The Y coordinate of the upper-left outside corner of Window, relative to the
// parent window's origin.
Y int16
// The inside width of Window, not including the border.
Width uint16
// The inside height of Window, not including the border.
Height uint16
// The border width of Window.
BorderWidth uint16
// Window managers should ignore this window if OverrideRedirect is 1.
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
v.Event = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.AboveSibling = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.X = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a ConfigureNotifyEvent value to a byte slice.
func (v ConfigureNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 22
b += 1
b += 1 // padding
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Event))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.AboveSibling))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Y))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Height)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.BorderWidth)
b += 2
2013-08-12 02:43:26 +02:00
if v.OverrideRedirect {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[22] = ConfigureNotifyEventNew
}
2013-08-12 02:43:26 +02:00
// ConfigureRequest is the event number for a ConfigureRequestEvent.
const ConfigureRequest = 23
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.StackMode = buf[b]
b += 1
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Parent = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Sibling = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.X = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Width = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Height = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.BorderWidth = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ValueMask = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a ConfigureRequestEvent value to a byte slice.
func (v ConfigureRequestEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 23
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.StackMode
b += 1
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Parent))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Sibling))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Y))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Height)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.BorderWidth)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.ValueMask)
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[23] = ConfigureRequestEventNew
}
2013-08-12 02:43:26 +02:00
const (
CoordModeOrigin = 0
CoordModePrevious = 1
)
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Width = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Height = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.BorderWidth = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
if buf[b] == 1 {
v.OverrideRedirect = true
} else {
v.OverrideRedirect = false
}
2013-08-12 02:43:26 +02:00
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a CreateNotifyEvent value to a byte slice.
func (v CreateNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 16
b += 1
b += 1 // padding
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Parent))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Y))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Height)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.BorderWidth)
b += 2
2013-08-12 02:43:26 +02:00
if v.OverrideRedirect {
buf[b] = 1
} else {
buf[b] = 0
}
2013-08-12 02:43:26 +02:00
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[16] = CreateNotifyEventNew
}
2013-08-12 02:43:26 +02:00
type Cursor uint32
2013-08-12 02:43:26 +02:00
func NewCursorId(c *xgb.Conn) (Cursor, error) {
id, err := c.NewId()
if err != nil {
return 0, err
}
return Cursor(id), nil
}
2013-08-12 02:43:26 +02:00
// BadCursor is the error number for a BadCursor.
const BadCursor = 6
2013-08-12 02:43:26 +02:00
type CursorError ValueError
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadCursor error.
// This is mostly used internally.
func (err CursorError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewErrorFuncs[6] = CursorErrorNew
}
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
v.Depth = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.VisualsLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 4 // padding
v.Visuals = make([]VisualInfo, v.VisualsLen)
b += VisualInfoReadList(buf[b:], v.Visuals)
return b
}
2013-08-12 02:43:26 +02:00
// 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++ {
2013-08-12 02:43:26 +02:00
dest[i] = DepthInfo{}
b += DepthInfoRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
buf[b] = v.Depth
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.VisualsLen)
b += 2
2013-08-12 02:43:26 +02:00
b += 4 // padding
b += VisualInfoListBytes(buf[b:], v.Visuals)
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// DepthInfoListSize computes the size (bytes) of a list of DepthInfo values.
func DepthInfoListSize(list []DepthInfo) int {
size := 0
for _, item := range list {
2013-08-12 02:43:26 +02:00
size += (8 + xgb.Pad((int(item.VisualsLen) * 24)))
}
return size
}
2013-08-12 02:43:26 +02:00
// DestroyNotify is the event number for a DestroyNotifyEvent.
const DestroyNotify = 17
type DestroyNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
// The reconfigured window or its parent, depending on whether StructureNotify
// or SubstructureNotify was selected.
Event Window
// The window that is destroyed.
2013-08-12 02:43:26 +02:00
Window Window
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Event = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a DestroyNotifyEvent value to a byte slice.
func (v DestroyNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 17
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Event))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[17] = DestroyNotifyEventNew
}
2013-08-12 02:43:26 +02:00
type Drawable uint32
func NewDrawableId(c *xgb.Conn) (Drawable, error) {
id, err := c.NewId()
if err != nil {
return 0, err
}
2013-08-12 02:43:26 +02:00
return Drawable(id), nil
}
2013-08-12 02:43:26 +02:00
// BadDrawable is the error number for a BadDrawable.
const BadDrawable = 9
2013-08-12 02:43:26 +02:00
type DrawableError ValueError
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadDrawable error.
// This is mostly used internally.
func (err DrawableError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewErrorFuncs[9] = DrawableErrorNew
}
2013-08-12 02:43:26 +02:00
// EnterNotify is the event number for a EnterNotifyEvent.
const EnterNotify = 7
2013-08-12 02:43:26 +02:00
type EnterNotifyEvent struct {
Sequence uint16
Detail byte
Time Timestamp
// The root window for the final cursor position.
Root Window
// The window on which the event was generated.
Event Window
// If the Event window has subwindows and the final pointer position is in one
// of them, then Child is set to that subwindow, WindowNone otherwise.
Child Window
// The pointer X coordinate relative to Root's origin at the time of the event.
RootX int16
// The pointer Y coordinate relative to Root's origin at the time of the event.
RootY int16
// If Event is on the same screen as Root, this is the pointer X coordinate
// relative to the event window's origin.
EventX int16
// If Event is on the same screen as Root, this is the pointer Y coordinate
// relative to the event window's origin.
2013-08-12 02:43:26 +02:00
EventY int16
State uint16
Mode byte
SameScreenFocus byte
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Time = Timestamp(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Root = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Event = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Child = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.RootX = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.RootY = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.EventX = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.EventY = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.State = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Mode = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.SameScreenFocus = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a EnterNotifyEvent value to a byte slice.
func (v EnterNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 7
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.Detail
b += 1
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Root))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Event))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Child))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.RootX))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.RootY))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.EventX))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.EventY))
b += 2
xgb.Put16(buf[b:], v.State)
b += 2
2013-08-12 02:43:26 +02:00
buf[b] = v.Mode
b += 1
buf[b] = v.SameScreenFocus
b += 1
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[7] = EnterNotifyEventNew
}
2013-08-12 02:43:26 +02:00
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
)
2013-08-12 02:43:26 +02:00
// Expose is the event number for a ExposeEvent.
const Expose = 12
2013-08-12 02:43:26 +02:00
type ExposeEvent struct {
Sequence uint16
// padding: 1 bytes
// The exposed (damaged) window.
2013-08-12 02:43:26 +02:00
Window Window
// The X coordinate of the left-upper corner of the exposed rectangle, relative to
// the Window's origin.
X uint16
// The Y coordinate of the left-upper corner of the exposed rectangle, relative to
// the Window's origin.
Y uint16
// The width of the exposed rectangle.
Width uint16
// The height of the exposed rectangle.
2013-08-12 02:43:26 +02:00
Height uint16
// The amount of Expose events following this one. Simple applications that do
// not want to optimize redisplay by distinguishing between subareas of its window
// can just ignore all Expose events with nonzero counts and perform full
// redisplays on events with zero counts.
Count uint16
2013-08-12 02:43:26 +02:00
// padding: 2 bytes
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.X = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Y = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// Bytes writes a ExposeEvent value to a byte slice.
func (v ExposeEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 12
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Y)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Height)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Count)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
type FocusInEvent struct {
Sequence uint16
Detail byte
// The window on which the focus event was generated. This is the window used by
// the X server to report the event.
Event Window
Mode byte
2013-08-12 02:43:26 +02:00
// padding: 3 bytes
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Detail = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Event = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Mode = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a FocusInEvent value to a byte slice.
func (v FocusInEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 9
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.Detail
b += 1
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Event))
b += 4
2013-08-12 02:43:26 +02:00
buf[b] = v.Mode
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[9] = FocusInEventNew
}
2013-08-12 02:43:26 +02:00
// FocusOut is the event number for a FocusOutEvent.
const FocusOut = 10
2013-08-12 02:43:26 +02:00
type FocusOutEvent FocusInEvent
2013-08-12 02:43:26 +02:00
// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice.
func FocusOutEventNew(buf []byte) xgb.Event {
return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent))
}
2013-08-12 02:43:26 +02:00
// Bytes writes a FocusOutEvent value to a byte slice.
func (v FocusOutEvent) Bytes() []byte {
return FocusInEvent(v).Bytes()
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
return Font(id), nil
}
2017-01-18 10:52:16 +01:00
const (
FontNone = 0
)
2013-08-12 02:43:26 +02:00
// BadFont is the error number for a BadFont.
const BadFont = 7
2013-08-12 02:43:26 +02:00
type FontError ValueError
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadFont error.
// This is mostly used internally.
func (err FontError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return Fontable(id), nil
}
2013-08-12 02:43:26 +02:00
type Fontprop struct {
Name Atom
Value uint32
}
2013-08-12 02:43:26 +02:00
// FontpropRead reads a byte slice into a Fontprop value.
func FontpropRead(buf []byte, v *Fontprop) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Name = Atom(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Value = xgb.Get32(buf[b:])
b += 4
return b
}
2013-08-12 02:43:26 +02:00
// 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++ {
2013-08-12 02:43:26 +02:00
dest[i] = Fontprop{}
b += FontpropRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a Fontprop value to a byte slice.
func (v Fontprop) Bytes() []byte {
buf := make([]byte, 8)
b := 0
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Name))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], v.Value)
b += 4
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
type Format struct {
Depth byte
BitsPerPixel byte
ScanlinePad byte
// padding: 5 bytes
}
2013-08-12 02:43:26 +02:00
// FormatRead reads a byte slice into a Format value.
func FormatRead(buf []byte, v *Format) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Depth = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.BitsPerPixel = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.ScanlinePad = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 5 // padding
return b
}
2013-08-12 02:43:26 +02:00
// 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++ {
2013-08-12 02:43:26 +02:00
dest[i] = Format{}
b += FormatRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a Format value to a byte slice.
func (v Format) Bytes() []byte {
buf := make([]byte, 8)
b := 0
2013-08-12 02:43:26 +02:00
buf[b] = v.Depth
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.BitsPerPixel
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.ScanlinePad
b += 1
2013-08-12 02:43:26 +02:00
b += 5 // padding
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// BadGContext is the error number for a BadGContext.
const BadGContext = 13
2013-08-12 02:43:26 +02:00
type GContextError ValueError
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadGContext error.
// This is mostly used internally.
func (err GContextError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewErrorFuncs[13] = GContextErrorNew
}
2013-08-12 02:43:26 +02:00
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
)
2013-08-12 02:43:26 +02:00
type Gcontext uint32
2013-08-12 02:43:26 +02:00
func NewGcontextId(c *xgb.Conn) (Gcontext, error) {
id, err := c.NewId()
if err != nil {
return 0, err
}
2013-08-12 02:43:26 +02:00
return Gcontext(id), nil
}
// GeGeneric is the event number for a GeGenericEvent.
const GeGeneric = 35
type GeGenericEvent struct {
Sequence uint16
// padding: 22 bytes
}
// GeGenericEventNew constructs a GeGenericEvent value that implements xgb.Event from a byte slice.
func GeGenericEventNew(buf []byte) xgb.Event {
v := GeGenericEvent{}
b := 1 // don't read event number
b += 22 // padding
return v
}
// Bytes writes a GeGenericEvent value to a byte slice.
func (v GeGenericEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
buf[b] = 35
b += 1
b += 22 // padding
return buf
}
// SequenceId returns the sequence id attached to the GeGeneric event.
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
func (v GeGenericEvent) SequenceId() uint16 {
return v.Sequence
}
// String is a rudimentary string representation of GeGenericEvent.
func (v GeGenericEvent) String() string {
fieldVals := make([]string, 0, 1)
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
return "GeGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
xgb.NewEventFuncs[35] = GeGenericEventNew
}
2013-08-12 02:43:26 +02:00
const (
GetPropertyTypeAny = 0
)
2013-08-12 02:43:26 +02:00
const (
GrabAny = 0
)
const (
GrabModeSync = 0
GrabModeAsync = 1
)
2013-08-12 02:43:26 +02:00
const (
GrabStatusSuccess = 0
GrabStatusAlreadyGrabbed = 1
GrabStatusInvalidTime = 2
GrabStatusNotViewable = 3
GrabStatusFrozen = 4
)
2013-08-12 02:43:26 +02:00
// GraphicsExposure is the event number for a GraphicsExposureEvent.
const GraphicsExposure = 13
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Drawable = Drawable(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.X = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Y = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Width = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Height = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MinorOpcode = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Count = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MajorOpcode = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a GraphicsExposureEvent value to a byte slice.
func (v GraphicsExposureEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 13
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.X)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Y)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Height)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.MinorOpcode)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Count)
b += 2
2013-08-12 02:43:26 +02:00
buf[b] = v.MajorOpcode
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[13] = GraphicsExposureEventNew
}
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
type GravityNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Event Window
Window Window
X int16
Y int16
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Event = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.X = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a GravityNotifyEvent value to a byte slice.
func (v GravityNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 24
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
b += 2 // skip sequence number
xgb.Put32(buf[b:], uint32(v.Event))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Y))
b += 2
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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))
2017-01-18 10:52:16 +01:00
// alignment gap to multiple of 4
2013-08-12 02:43:26 +02:00
}
// 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
2013-08-12 02:43:26 +02:00
v.Address = make([]byte, v.AddressLen)
copy(v.Address[:v.AddressLen], buf[b:])
b += int(v.AddressLen)
2013-08-12 02:43:26 +02:00
2017-01-18 10:52:16 +01:00
b = (b + 3) & ^3 // alignment gap
2013-08-12 02:43:26 +02:00
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])
}
2013-08-12 02:43:26 +02:00
return xgb.Pad(b)
}
// Bytes writes a Host value to a byte slice.
func (v Host) Bytes() []byte {
2017-01-18 10:52:16 +01:00
buf := make([]byte, ((4 + xgb.Pad((int(v.AddressLen) * 1))) + 4))
2013-08-12 02:43:26 +02:00
b := 0
buf[b] = v.Family
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], v.AddressLen)
b += 2
copy(buf[b:], v.Address[:v.AddressLen])
b += int(v.AddressLen)
2013-08-12 02:43:26 +02:00
2017-01-18 10:52:16 +01:00
b = (b + 3) & ^3 // alignment gap
return buf[:b]
2013-08-12 02:43:26 +02:00
}
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
2013-08-12 02:43:26 +02:00
}
// HostListSize computes the size (bytes) of a list of Host values.
func HostListSize(list []Host) int {
size := 0
for _, item := range list {
2017-01-18 10:52:16 +01:00
size += ((4 + xgb.Pad((int(item.AddressLen) * 1))) + 4)
2013-08-12 02:43:26 +02:00
}
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
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadImplementation error.
2012-05-11 05:57:34 +02:00
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (err ImplementationError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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() {
2013-08-12 02:43:26 +02:00
xgb.NewErrorFuncs[17] = ImplementationErrorNew
}
2013-08-12 02:43:26 +02:00
const (
InputFocusNone = 0
InputFocusPointerRoot = 1
InputFocusParent = 2
InputFocusFollowKeyboard = 3
)
2013-08-12 02:43:26 +02:00
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
// The keycode (a number representing a physical key on the keyboard) of the key
// which was pressed.
Detail Keycode
// Time when the event was generated (in milliseconds).
Time Timestamp
// The root window of Child.
Root Window
Event Window
Child Window
// The X coordinate of the pointer relative to the Root window at the time of
// the event.
RootX int16
// The Y coordinate of the pointer relative to the Root window at the time of
// the event.
RootY int16
// If SameScreen is true, this is the X coordinate relative to the Event
// window's origin. Otherwise, EventX will be set to zero.
EventX int16
// If SameScreen is true, this is the Y coordinate relative to the Event
// window's origin. Otherwise, EventY will be set to zero.
EventY int16
// The logical state of the pointer buttons and modifier keys just prior to the
// event.
State uint16
// Whether the Event window is on the same screen as the Root window.
SameScreen bool
// padding: 1 bytes
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Detail = Keycode(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
b += 1 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a KeyPressEvent value to a byte slice.
func (v KeyPressEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 2
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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the KeyPress event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v KeyPressEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[2] = KeyPressEventNew
}
2013-08-12 02:43:26 +02:00
// KeyRelease is the event number for a KeyReleaseEvent.
const KeyRelease = 3
2013-08-12 02:43:26 +02:00
type KeyReleaseEvent KeyPressEvent
2013-08-12 02:43:26 +02:00
// KeyReleaseEventNew constructs a KeyReleaseEvent value that implements xgb.Event from a byte slice.
func KeyReleaseEventNew(buf []byte) xgb.Event {
return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent))
}
2013-08-12 02:43:26 +02:00
// Bytes writes a KeyReleaseEvent value to a byte slice.
func (v KeyReleaseEvent) Bytes() []byte {
return KeyPressEvent(v).Bytes()
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the KeyRelease event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v KeyReleaseEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
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))
2013-08-12 02:43:26 +02:00
return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[3] = KeyReleaseEventNew
}
2013-08-12 02:43:26 +02:00
type Keycode byte
2017-01-18 10:52:16 +01:00
type Keycode32 uint32
2013-08-12 02:43:26 +02:00
// KeymapNotify is the event number for a KeymapNotifyEvent.
const KeymapNotify = 11
type KeymapNotifyEvent struct {
Keys []byte // size: 32
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Keys = make([]byte, 31)
copy(v.Keys[:31], buf[b:])
b += int(31)
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a KeymapNotifyEvent value to a byte slice.
func (v KeymapNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 11
b += 1
2013-08-12 02:43:26 +02:00
copy(buf[b:], v.Keys[:31])
b += int(31)
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// String is a rudimentary string representation of KeymapNotifyEvent.
func (v KeymapNotifyEvent) String() string {
fieldVals := make([]string, 0, 1)
return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewEventFuncs[11] = KeymapNotifyEventNew
}
2013-08-12 02:43:26 +02:00
type Keysym uint32
2013-08-12 02:43:26 +02:00
const (
KillAllTemporary = 0
)
2013-08-12 02:43:26 +02:00
// LeaveNotify is the event number for a LeaveNotifyEvent.
const LeaveNotify = 8
2013-08-12 02:43:26 +02:00
type LeaveNotifyEvent EnterNotifyEvent
2013-08-12 02:43:26 +02:00
// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice.
func LeaveNotifyEventNew(buf []byte) xgb.Event {
return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent))
}
2013-08-12 02:43:26 +02:00
// Bytes writes a LeaveNotifyEvent value to a byte slice.
func (v LeaveNotifyEvent) Bytes() []byte {
return EnterNotifyEvent(v).Bytes()
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the LeaveNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v LeaveNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
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))
2013-08-12 02:43:26 +02:00
return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[8] = LeaveNotifyEventNew
}
2013-08-12 02:43:26 +02:00
const (
LedModeOff = 0
LedModeOn = 1
)
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
// padding: 1 bytes
// The window which was mapped or its parent, depending on whether
// StructureNotify or SubstructureNotify was selected.
Event Window
// The window that was mapped.
Window Window
// Window managers should ignore this window if OverrideRedirect is 1.
2013-08-12 02:43:26 +02:00
OverrideRedirect bool
// padding: 3 bytes
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Event = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
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
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a MapNotifyEvent value to a byte slice.
func (v MapNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 19
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Event))
b += 4
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
if v.OverrideRedirect {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
b += 3 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the MapNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v MapNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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("Event: %d", v.Event))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[19] = MapNotifyEventNew
}
2013-08-12 02:43:26 +02:00
// MapRequest is the event number for a MapRequestEvent.
const MapRequest = 20
2013-08-12 02:43:26 +02:00
type MapRequestEvent struct {
Sequence uint16
// padding: 1 bytes
// The parent of Window.
2013-08-12 02:43:26 +02:00
Parent Window
// The window to be mapped.
2013-08-12 02:43:26 +02:00
Window Window
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// Bytes writes a MapRequestEvent value to a byte slice.
func (v MapRequestEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 20
b += 1
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the MapRequest event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v MapRequestEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[20] = MapRequestEventNew
}
2013-08-12 02:43:26 +02:00
const (
MapStateUnmapped = 0
MapStateUnviewable = 1
MapStateViewable = 2
)
2013-08-12 02:43:26 +02:00
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
Request byte
// The first number in the range of the altered mapping.
2013-08-12 02:43:26 +02:00
FirstKeycode Keycode
// The number of keycodes altered.
Count byte
2013-08-12 02:43:26 +02:00
// padding: 1 bytes
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Request = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.FirstKeycode = Keycode(buf[b])
b += 1
2013-08-12 02:43:26 +02:00
v.Count = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a MappingNotifyEvent value to a byte slice.
func (v MappingNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 34
b += 1
b += 1 // padding
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
buf[b] = v.Request
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = byte(v.FirstKeycode)
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.Count
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the MappingNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v MappingNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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))
2013-08-12 02:43:26 +02:00
return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// 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
)
2013-08-12 02:43:26 +02:00
// MotionNotify is the event number for a MotionNotifyEvent.
const MotionNotify = 6
type MotionNotifyEvent struct {
Sequence uint16
// The keycode (a number representing a physical key on the keyboard) of the key
// which was pressed.
Detail byte
// Time when the event was generated (in milliseconds).
Time Timestamp
// The root window of Child.
Root Window
Event Window
Child Window
// The X coordinate of the pointer relative to the Root window at the time of
// the event.
RootX int16
// The Y coordinate of the pointer relative to the Root window at the time of
// the event.
RootY int16
// If SameScreen is true, this is the X coordinate relative to the Event
// window's origin. Otherwise, EventX will be set to zero.
EventX int16
// If SameScreen is true, this is the Y coordinate relative to the Event
// window's origin. Otherwise, EventY will be set to zero.
EventY int16
// The logical state of the pointer buttons and modifier keys just prior to the
// event.
State uint16
// Whether the Event window is on the same screen as the Root window.
2013-08-12 02:43:26 +02:00
SameScreen bool
// padding: 1 bytes
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Detail = buf[b]
b += 1
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Time = Timestamp(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Root = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
v.RootY = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.EventX = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.EventY = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.State = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
if buf[b] == 1 {
v.SameScreen = true
} else {
v.SameScreen = false
}
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a MotionNotifyEvent value to a byte slice.
func (v MotionNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 6
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.Detail
b += 1
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Root))
b += 4
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.RootY))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.EventX))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.EventY))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.State)
b += 2
2013-08-12 02:43:26 +02:00
if v.SameScreen {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the MotionNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v MotionNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[6] = MotionNotifyEventNew
}
2013-08-12 02:43:26 +02:00
// BadName is the error number for a BadName.
const BadName = 15
2013-08-12 02:43:26 +02:00
type NameError RequestError
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadName error.
// This is mostly used internally.
func (err NameError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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() {
2013-08-12 02:43:26 +02:00
xgb.NewErrorFuncs[15] = NameErrorNew
}
2013-08-12 02:43:26 +02:00
// NoExposure is the event number for a NoExposureEvent.
const NoExposure = 14
2013-08-12 02:43:26 +02:00
type NoExposureEvent struct {
Sequence uint16
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
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
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Drawable = Drawable(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.MinorOpcode = xgb.Get16(buf[b:])
b += 2
v.MajorOpcode = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a NoExposureEvent value to a byte slice.
func (v NoExposureEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 14
b += 1
b += 1 // padding
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.MinorOpcode)
b += 2
buf[b] = v.MajorOpcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the NoExposure event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v NoExposureEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[14] = NoExposureEventNew
}
2013-08-12 02:43:26 +02:00
const (
NotifyDetailAncestor = 0
NotifyDetailVirtual = 1
NotifyDetailInferior = 2
NotifyDetailNonlinear = 3
NotifyDetailNonlinearVirtual = 4
NotifyDetailPointer = 5
NotifyDetailPointerRoot = 6
NotifyDetailNone = 7
)
2013-08-12 02:43:26 +02:00
const (
NotifyModeNormal = 0
NotifyModeGrab = 1
NotifyModeUngrab = 2
NotifyModeWhileGrabbed = 3
)
2013-08-12 02:43:26 +02:00
type Pixmap uint32
2013-08-12 02:43:26 +02:00
func NewPixmapId(c *xgb.Conn) (Pixmap, error) {
id, err := c.NewId()
if err != nil {
return 0, err
}
return Pixmap(id), nil
}
2016-03-01 15:41:38 +01:00
const (
PixmapNone = 0
)
2013-08-12 02:43:26 +02:00
// BadPixmap is the error number for a BadPixmap.
const BadPixmap = 4
2013-08-12 02:43:26 +02:00
type PixmapError ValueError
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadPixmap error.
// This is mostly used internally.
func (err PixmapError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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, ", ") + "}"
}
2013-08-12 02:43:26 +02:00
func init() {
xgb.NewErrorFuncs[4] = PixmapErrorNew
}
2013-08-12 02:43:26 +02:00
const (
PlaceOnTop = 0
PlaceOnBottom = 1
)
2013-08-12 02:43:26 +02:00
type Point struct {
X int16
Y int16
}
2013-08-12 02:43:26 +02:00
// PointRead reads a byte slice into a Point value.
func PointRead(buf []byte, v *Point) int {
b := 0
2013-08-12 02:43:26 +02:00
v.X = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
return b
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// 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
xgb.Put16(buf[b:], uint16(v.Y))
b += 2
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
const (
PolyShapeComplex = 0
PolyShapeNonconvex = 1
PolyShapeConvex = 2
)
2013-08-12 02:43:26 +02:00
const (
PropModeReplace = 0
PropModePrepend = 1
PropModeAppend = 2
)
const (
PropertyNewValue = 0
PropertyDelete = 1
)
2013-08-12 02:43:26 +02:00
// PropertyNotify is the event number for a PropertyNotifyEvent.
const PropertyNotify = 28
2013-08-12 02:43:26 +02:00
type PropertyNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
// The window whose associated property was changed.
Window Window
// The property's atom, to indicate which property was changed.
Atom Atom
// A timestamp of the server time when the property was changed.
Time Timestamp
State byte
2013-08-12 02:43:26 +02:00
// padding: 3 bytes
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Atom = Atom(xgb.Get32(buf[b:]))
b += 4
v.Time = Timestamp(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.State = buf[b]
b += 1
b += 3 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a PropertyNotifyEvent value to a byte slice.
func (v PropertyNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 28
b += 1
b += 1 // padding
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Atom))
b += 4
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
2013-08-12 02:43:26 +02:00
buf[b] = v.State
b += 1
b += 3 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the PropertyNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v PropertyNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[28] = PropertyNotifyEventNew
}
2013-08-12 02:43:26 +02:00
const (
QueryShapeOfLargestCursor = 0
QueryShapeOfFastestTile = 1
QueryShapeOfFastestStipple = 2
)
2013-08-12 02:43:26 +02:00
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[:b]
2013-08-12 02:43:26 +02:00
}
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
2013-08-12 02:43:26 +02:00
}
// ReparentNotify is the event number for a ReparentNotifyEvent.
const ReparentNotify = 21
type ReparentNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Event Window
Window Window
Parent Window
X int16
Y int16
OverrideRedirect bool
// padding: 3 bytes
}
2013-08-12 02:43:26 +02:00
// 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
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
2013-08-12 02:43:26 +02:00
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 {
2013-08-12 02:43:26 +02:00
v.OverrideRedirect = true
} else {
2013-08-12 02:43:26 +02:00
v.OverrideRedirect = false
}
b += 1
b += 3 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a ReparentNotifyEvent value to a byte slice.
func (v ReparentNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 21
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
2013-08-12 02:43:26 +02:00
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
}
b += 1
b += 3 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the ReparentNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v ReparentNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewErrorFuncs[1] = RequestErrorNew
}
2013-08-12 02:43:26 +02:00
// ResizeRequest is the event number for a ResizeRequestEvent.
const ResizeRequest = 25
2013-08-12 02:43:26 +02:00
type ResizeRequestEvent struct {
Sequence uint16
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Window Window
Width uint16
Height uint16
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Width = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Height = xgb.Get16(buf[b:])
b += 2
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a ResizeRequestEvent value to a byte slice.
func (v ResizeRequestEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 25
b += 1
b += 1 // padding
b += 2 // skip sequence number
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Height)
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the ResizeRequest event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v ResizeRequestEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[25] = ResizeRequestEventNew
}
2013-08-12 02:43:26 +02:00
type Rgb struct {
Red uint16
Green uint16
Blue uint16
// padding: 2 bytes
}
2013-08-12 02:43:26 +02:00
// RgbRead reads a byte slice into a Rgb value.
func RgbRead(buf []byte, v *Rgb) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Red = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Green = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Blue = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
return b
}
2013-08-12 02:43:26 +02:00
// RgbReadList reads a byte slice into a list of Rgb values.
func RgbReadList(buf []byte, dest []Rgb) int {
b := 0
2013-08-12 02:43:26 +02:00
for i := 0; i < len(dest); i++ {
dest[i] = Rgb{}
b += RgbRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a Rgb value to a byte slice.
func (v Rgb) Bytes() []byte {
buf := make([]byte, 8)
b := 0
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Red)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Green)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Blue)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
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)
}
2013-08-12 02:43:26 +02:00
// ScreenInfoRead reads a byte slice into a ScreenInfo value.
func ScreenInfoRead(buf []byte, v *ScreenInfo) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Root = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.DefaultColormap = Colormap(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.WhitePixel = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.BlackPixel = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.CurrentInputMasks = xgb.Get32(buf[b:])
b += 4
v.WidthInPixels = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.HeightInPixels = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.WidthInMillimeters = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.HeightInMillimeters = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MinInstalledMaps = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MaxInstalledMaps = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.RootVisual = Visualid(xgb.Get32(buf[b:]))
b += 4
v.BackingStores = buf[b]
b += 1
if buf[b] == 1 {
2013-08-12 02:43:26 +02:00
v.SaveUnders = true
} else {
2013-08-12 02:43:26 +02:00
v.SaveUnders = false
}
b += 1
2013-08-12 02:43:26 +02:00
v.RootDepth = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.AllowedDepthsLen = buf[b]
b += 1
v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen)
b += DepthInfoReadList(buf[b:], v.AllowedDepths)
return b
}
2013-08-12 02:43:26 +02:00
// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values.
func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int {
b := 0
2013-08-12 02:43:26 +02:00
for i := 0; i < len(dest); i++ {
dest[i] = ScreenInfo{}
b += ScreenInfoRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a ScreenInfo value to a byte slice.
func (v ScreenInfo) Bytes() []byte {
buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths)))
b := 0
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Root))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.DefaultColormap))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], v.WhitePixel)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], v.BlackPixel)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], v.CurrentInputMasks)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.WidthInPixels)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.HeightInPixels)
b += 2
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
buf[b] = v.RootDepth
b += 1
buf[b] = v.AllowedDepthsLen
b += 1
b += DepthInfoListBytes(buf[b:], v.AllowedDepths)
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
const (
ScreenSaverReset = 0
ScreenSaverActive = 1
)
type Segment struct {
X1 int16
Y1 int16
X2 int16
Y2 int16
}
2013-08-12 02:43:26 +02:00
// SegmentRead reads a byte slice into a Segment value.
func SegmentRead(buf []byte, v *Segment) int {
b := 0
2013-08-12 02:43:26 +02:00
v.X1 = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y1 = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.X2 = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y2 = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
return b
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a Segment value to a byte slice.
func (v Segment) Bytes() []byte {
buf := make([]byte, 8)
b := 0
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.X1))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Y1))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.X2))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Y2))
b += 2
return buf[:b]
2013-08-12 02:43:26 +02:00
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
}
return xgb.Pad(b)
2013-08-12 02:43:26 +02:00
}
2013-08-12 02:43:26 +02:00
// SelectionClear is the event number for a SelectionClearEvent.
const SelectionClear = 29
2013-08-12 02:43:26 +02:00
type SelectionClearEvent struct {
Sequence uint16
// padding: 1 bytes
Time Timestamp
Owner Window
Selection Atom
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Time = Timestamp(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Owner = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Selection = Atom(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a SelectionClearEvent value to a byte slice.
func (v SelectionClearEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
2013-08-12 02:43:26 +02:00
// write event number
buf[b] = 29
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Owner))
b += 4
xgb.Put32(buf[b:], uint32(v.Selection))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the SelectionClear event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v SelectionClearEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[29] = SelectionClearEventNew
}
2013-08-12 02:43:26 +02:00
// SelectionNotify is the event number for a SelectionNotifyEvent.
const SelectionNotify = 31
2013-08-12 02:43:26 +02:00
type SelectionNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
Time Timestamp
Requestor Window
Selection Atom
Target Atom
Property Atom
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Time = Timestamp(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Requestor = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Selection = Atom(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Target = Atom(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Property = Atom(xgb.Get32(buf[b:]))
b += 4
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a SelectionNotifyEvent value to a byte slice.
func (v SelectionNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 31
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Requestor))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Selection))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Target))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Property))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the SelectionNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v SelectionNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[31] = SelectionNotifyEventNew
}
2013-08-12 02:43:26 +02:00
// SelectionRequest is the event number for a SelectionRequestEvent.
const SelectionRequest = 30
2013-08-12 02:43:26 +02:00
type SelectionRequestEvent struct {
Sequence uint16
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Time Timestamp
Owner Window
Requestor Window
Selection Atom
Target Atom
Property Atom
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Time = Timestamp(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Owner = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Requestor = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// Bytes writes a SelectionRequestEvent value to a byte slice.
func (v SelectionRequestEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 30
b += 1
b += 1 // padding
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Owner))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Requestor))
b += 4
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the SelectionRequest event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v SelectionRequestEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[30] = SelectionRequestEventNew
}
2013-08-12 02:43:26 +02:00
const (
SendEventDestPointerWindow = 0
SendEventDestItemFocus = 1
)
2013-08-12 02:43:26 +02:00
const (
SetModeInsert = 0
SetModeDelete = 1
)
2013-08-12 02:43:26 +02:00
type SetupAuthenticate struct {
Status byte
// padding: 5 bytes
Length uint16
Reason string // size: xgb.Pad(((int(Length) * 4) * 1))
}
2013-08-12 02:43:26 +02:00
// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value.
func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Status = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 5 // padding
v.Length = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
{
byteString := make([]byte, (int(v.Length) * 4))
copy(byteString[:(int(v.Length)*4)], buf[b:])
v.Reason = string(byteString)
b += int((int(v.Length) * 4))
2013-08-12 02:43:26 +02:00
}
return b
}
2013-08-12 02:43:26 +02:00
// SetupAuthenticateReadList reads a byte slice into a list of SetupAuthenticate values.
func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int {
b := 0
2013-08-12 02:43:26 +02:00
for i := 0; i < len(dest); i++ {
dest[i] = SetupAuthenticate{}
b += SetupAuthenticateRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
buf[b] = v.Status
b += 1
2013-08-12 02:43:26 +02:00
b += 5 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Length)
b += 2
2013-08-12 02:43:26 +02:00
copy(buf[b:], v.Reason[:(int(v.Length)*4)])
b += int((int(v.Length) * 4))
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
type SetupFailed struct {
Status byte
ReasonLen byte
ProtocolMajorVersion uint16
ProtocolMinorVersion uint16
Length uint16
Reason string // size: xgb.Pad((int(ReasonLen) * 1))
}
2013-08-12 02:43:26 +02:00
// SetupFailedRead reads a byte slice into a SetupFailed value.
func SetupFailedRead(buf []byte, v *SetupFailed) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Status = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.ReasonLen = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.ProtocolMajorVersion = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ProtocolMinorVersion = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
{
byteString := make([]byte, v.ReasonLen)
copy(byteString[:v.ReasonLen], buf[b:])
v.Reason = string(byteString)
b += int(v.ReasonLen)
2013-08-12 02:43:26 +02:00
}
2013-08-12 02:43:26 +02:00
return b
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
buf[b] = v.Status
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.ReasonLen
b += 1
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.ProtocolMajorVersion)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.ProtocolMinorVersion)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.Length)
b += 2
2013-08-12 02:43:26 +02:00
copy(buf[b:], v.Reason[:v.ReasonLen])
b += int(v.ReasonLen)
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// 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))
// alignment gap to multiple of 4
2017-01-18 10:52:16 +01:00
PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8))
Roots []ScreenInfo // size: ScreenInfoListSize(Roots)
}
2013-08-12 02:43:26 +02:00
// SetupInfoRead reads a byte slice into a SetupInfo value.
func SetupInfoRead(buf []byte, v *SetupInfo) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Status = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.ProtocolMajorVersion = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ProtocolMinorVersion = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ReleaseNumber = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.ResourceIdBase = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.ResourceIdMask = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.MotionBufferSize = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.VendorLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MaximumRequestLength = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.RootsLen = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.PixmapFormatsLen = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.ImageByteOrder = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.BitmapFormatBitOrder = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.BitmapFormatScanlineUnit = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.BitmapFormatScanlinePad = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.MinKeycode = Keycode(buf[b])
b += 1
2013-08-12 02:43:26 +02:00
v.MaxKeycode = Keycode(buf[b])
b += 1
2013-08-12 02:43:26 +02:00
b += 4 // padding
2013-08-12 02:43:26 +02:00
{
byteString := make([]byte, v.VendorLen)
copy(byteString[:v.VendorLen], buf[b:])
v.Vendor = string(byteString)
b += int(v.VendorLen)
2013-08-12 02:43:26 +02:00
}
b = (b + 3) & ^3 // alignment gap
2013-08-12 02:43:26 +02:00
v.PixmapFormats = make([]Format, v.PixmapFormatsLen)
b += FormatReadList(buf[b:], v.PixmapFormats)
2013-08-12 02:43:26 +02:00
v.Roots = make([]ScreenInfo, v.RootsLen)
b += ScreenInfoReadList(buf[b:], v.Roots)
2013-08-12 02:43:26 +02:00
return b
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a SetupInfo value to a byte slice.
func (v SetupInfo) Bytes() []byte {
2017-01-18 10:52:16 +01:00
buf := make([]byte, ((((40 + xgb.Pad((int(v.VendorLen) * 1))) + 4) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots)))
2013-08-12 02:43:26 +02:00
b := 0
buf[b] = v.Status
b += 1
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.ProtocolMajorVersion)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.ProtocolMinorVersion)
b += 2
xgb.Put16(buf[b:], v.Length)
b += 2
xgb.Put32(buf[b:], v.ReleaseNumber)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], v.ResourceIdBase)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], v.ResourceIdMask)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], v.MotionBufferSize)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.VendorLen)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.MaximumRequestLength)
b += 2
buf[b] = v.RootsLen
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.PixmapFormatsLen
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.ImageByteOrder
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.BitmapFormatBitOrder
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.BitmapFormatScanlineUnit
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = v.BitmapFormatScanlinePad
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = byte(v.MinKeycode)
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = byte(v.MaxKeycode)
b += 1
2013-08-12 02:43:26 +02:00
b += 4 // padding
copy(buf[b:], v.Vendor[:v.VendorLen])
b += int(v.VendorLen)
b = (b + 3) & ^3 // alignment gap
2013-08-12 02:43:26 +02:00
b += FormatListBytes(buf[b:], v.PixmapFormats)
b += ScreenInfoListBytes(buf[b:], v.Roots)
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// SetupInfoListSize computes the size (bytes) of a list of SetupInfo values.
func SetupInfoListSize(list []SetupInfo) int {
size := 0
for _, item := range list {
2017-01-18 10:52:16 +01:00
size += ((((40 + xgb.Pad((int(item.VendorLen) * 1))) + 4) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots))
2013-08-12 02:43:26 +02:00
}
return size
}
2013-08-12 02:43:26 +02:00
type SetupRequest struct {
ByteOrder byte
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
ProtocolMajorVersion uint16
ProtocolMinorVersion uint16
AuthorizationProtocolNameLen uint16
AuthorizationProtocolDataLen uint16
// padding: 2 bytes
AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1))
2018-09-30 16:46:08 +02:00
// alignment gap to multiple of 4
2013-08-12 02:43:26 +02:00
AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1))
2018-09-30 16:46:08 +02:00
// alignment gap to multiple of 4
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.ProtocolMajorVersion = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ProtocolMinorVersion = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
{
byteString := make([]byte, v.AuthorizationProtocolNameLen)
copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:])
v.AuthorizationProtocolName = string(byteString)
b += int(v.AuthorizationProtocolNameLen)
2013-08-12 02:43:26 +02:00
}
2018-09-30 16:46:08 +02:00
b = (b + 3) & ^3 // alignment gap
2013-08-12 02:43:26 +02:00
{
byteString := make([]byte, v.AuthorizationProtocolDataLen)
copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:])
v.AuthorizationProtocolData = string(byteString)
b += int(v.AuthorizationProtocolDataLen)
2013-08-12 02:43:26 +02:00
}
2018-09-30 16:46:08 +02:00
b = (b + 3) & ^3 // alignment gap
2013-08-12 02:43:26 +02:00
return b
}
2013-08-12 02:43:26 +02:00
// 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 {
2018-09-30 16:46:08 +02:00
buf := make([]byte, ((((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + 4) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1))) + 4))
b := 0
2013-08-12 02:43:26 +02:00
buf[b] = v.ByteOrder
b += 1
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.ProtocolMajorVersion)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.ProtocolMinorVersion)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen])
b += int(v.AuthorizationProtocolNameLen)
2018-09-30 16:46:08 +02:00
b = (b + 3) & ^3 // alignment gap
2013-08-12 02:43:26 +02:00
copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen])
b += int(v.AuthorizationProtocolDataLen)
2018-09-30 16:46:08 +02:00
b = (b + 3) & ^3 // alignment gap
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
// SetupRequestListSize computes the size (bytes) of a list of SetupRequest values.
func SetupRequestListSize(list []SetupRequest) int {
size := 0
for _, item := range list {
2018-09-30 16:46:08 +02:00
size += ((((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + 4) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) + 4)
2013-08-12 02:43:26 +02:00
}
return size
}
2013-08-12 02:43:26 +02:00
const (
StackModeAbove = 0
StackModeBelow = 1
StackModeTopIf = 2
StackModeBottomIf = 3
StackModeOpposite = 4
)
type Str struct {
NameLen byte
Name string // size: xgb.Pad((int(NameLen) * 1))
}
2013-08-12 02:43:26 +02:00
// StrRead reads a byte slice into a Str value.
func StrRead(buf []byte, v *Str) int {
b := 0
2013-08-12 02:43:26 +02:00
v.NameLen = buf[b]
b += 1
{
byteString := make([]byte, v.NameLen)
copy(byteString[:v.NameLen], buf[b:])
v.Name = string(byteString)
b += int(v.NameLen)
2013-08-12 02:43:26 +02:00
}
return b
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
buf[b] = v.NameLen
b += 1
2013-08-12 02:43:26 +02:00
copy(buf[b:], v.Name[:v.NameLen])
b += int(v.NameLen)
return buf[:b]
2013-08-12 02:43:26 +02:00
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
2013-08-12 02:43:26 +02:00
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
const (
SubwindowModeClipByChildren = 0
SubwindowModeIncludeInferiors = 1
)
2013-08-12 02:43:26 +02:00
const (
TimeCurrentTime = 0
)
type Timecoord struct {
Time Timestamp
X int16
Y int16
}
2013-08-12 02:43:26 +02:00
// TimecoordRead reads a byte slice into a Timecoord value.
func TimecoordRead(buf []byte, v *Timecoord) int {
b := 0
2013-08-12 02:43:26 +02:00
v.Time = Timestamp(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.X = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
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)
}
2013-08-12 02:43:26 +02:00
// Bytes writes a Timecoord value to a byte slice.
func (v Timecoord) Bytes() []byte {
buf := make([]byte, 8)
b := 0
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(v.Y))
b += 2
return buf[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
type Timestamp uint32
2013-08-12 02:43:26 +02:00
// UnmapNotify is the event number for a UnmapNotifyEvent.
const UnmapNotify = 18
2013-08-12 02:43:26 +02:00
type UnmapNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
// The reconfigured window or its parent, depending on whether StructureNotify
// or SubstructureNotify was selected.
Event Window
// The window that was unmapped.
Window Window
// Set to 1 if the event was generated as a result of a resizing of the window's
// parent when Window had a win_gravity of UnmapGravity.
2013-08-12 02:43:26 +02:00
FromConfigure bool
// padding: 3 bytes
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Event = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
if buf[b] == 1 {
2013-08-12 02:43:26 +02:00
v.FromConfigure = true
} else {
2013-08-12 02:43:26 +02:00
v.FromConfigure = false
}
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a UnmapNotifyEvent value to a byte slice.
func (v UnmapNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 18
b += 1
b += 1 // padding
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Event))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
if v.FromConfigure {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the UnmapNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v UnmapNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event))
fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window))
2013-08-12 02:43:26 +02:00
fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure))
return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[18] = UnmapNotifyEventNew
}
2013-08-12 02:43:26 +02:00
// BadValue is the error number for a BadValue.
const BadValue = 2
2013-08-12 02:43:26 +02:00
type ValueError struct {
Sequence uint16
NiceName string
BadValue uint32
MinorOpcode uint16
MajorOpcode byte
// padding: 1 bytes
}
2013-08-12 02:43:26 +02:00
// ValueErrorNew constructs a ValueError value that implements xgb.Error from a byte slice.
func ValueErrorNew(buf []byte) xgb.Error {
v := ValueError{}
v.NiceName = "Value"
2013-08-12 02:43:26 +02:00
b := 1 // skip error determinant
b += 1 // don't read error number
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.BadValue = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.MinorOpcode = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MajorOpcode = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadValue error.
2012-05-11 05:57:34 +02:00
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (err ValueError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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)
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewErrorFuncs[2] = ValueErrorNew
}
2013-08-12 02:43:26 +02:00
const (
VisibilityUnobscured = 0
VisibilityPartiallyObscured = 1
VisibilityFullyObscured = 2
)
2013-08-12 02:43:26 +02:00
// VisibilityNotify is the event number for a VisibilityNotifyEvent.
const VisibilityNotify = 15
type VisibilityNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Window Window
State byte
// padding: 3 bytes
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Window = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.State = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Bytes writes a VisibilityNotifyEvent value to a byte slice.
func (v VisibilityNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
2013-08-12 02:43:26 +02:00
buf[b] = 15
b += 1
b += 1 // padding
b += 2 // skip sequence number
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(v.Window))
b += 4
2013-08-12 02:43:26 +02:00
buf[b] = v.State
b += 1
2013-08-12 02:43:26 +02:00
b += 3 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the VisibilityNotify event.
2012-05-11 05:57:34 +02:00
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (v VisibilityNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
2013-08-12 02:43:26 +02:00
// 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))
2013-08-12 02:43:26 +02:00
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() {
2013-08-12 02:43:26 +02:00
xgb.NewEventFuncs[15] = VisibilityNotifyEventNew
}
2013-08-12 02:43:26 +02:00
const (
VisualClassStaticGray = 0
VisualClassGrayScale = 1
VisualClassStaticColor = 2
VisualClassPseudoColor = 3
VisualClassTrueColor = 4
VisualClassDirectColor = 5
)
2013-08-12 02:43:26 +02:00
type VisualInfo struct {
VisualId Visualid
Class byte
BitsPerRgbValue byte
ColormapEntries uint16
RedMask uint32
GreenMask uint32
BlueMask uint32
// padding: 4 bytes
}
2013-08-12 02:43:26 +02:00
// VisualInfoRead reads a byte slice into a VisualInfo value.
func VisualInfoRead(buf []byte, v *VisualInfo) int {
b := 0
2013-08-12 02:43:26 +02:00
v.VisualId = Visualid(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Class = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.BitsPerRgbValue = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.ColormapEntries = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.RedMask = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.GreenMask = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.BlueMask = xgb.Get32(buf[b:])
b += 4
b += 4 // padding
return b
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// 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[:b]
}
2013-08-12 02:43:26 +02:00
// 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 += len(structBytes)
2013-08-12 02:43:26 +02:00
}
return xgb.Pad(b)
}
2013-08-12 02:43:26 +02:00
type Visualid uint32
2013-08-12 02:43:26 +02:00
type Window uint32
2013-08-12 02:43:26 +02:00
func NewWindowId(c *xgb.Conn) (Window, error) {
id, err := c.NewId()
if err != nil {
return 0, err
}
return Window(id), nil
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadWindow error.
2012-05-11 05:57:34 +02:00
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func (err WindowError) SequenceId() uint16 {
return err.Sequence
}
2013-08-12 02:43:26 +02:00
// 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() {
2013-08-12 02:43:26 +02:00
xgb.NewErrorFuncs[3] = WindowErrorNew
}
2016-03-01 15:41:38 +01:00
const (
WindowNone = 0
)
2013-08-12 02:43:26 +02:00
const (
WindowClassCopyFromParent = 0
WindowClassInputOutput = 1
WindowClassInputOnly = 2
)
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Bool'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Byte'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Card8'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Char'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Void'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Double'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Float'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Int16'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Int32'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Int8'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Card16'
2013-08-12 02:43:26 +02:00
// Skipping definition for base type 'Card32'
// AllocColorCookie is a cookie used only for AllocColor requests.
type AllocColorCookie struct {
*xgb.Cookie
}
// Allocates a read-only colormap entry corresponding to the closest RGB value
// supported by the hardware. If you are using TrueColor, you can take a shortcut
// and directly calculate the color pixel value to avoid the round trip. But, for
// example, on 16-bit color setups (VNC), you can easily get the closest supported
// RGB value to the RGB value you are specifying.
//
// May return a Colormap error if the specified colormap Cmap does not exist.
//
2013-08-12 02:43:26 +02:00
// 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, Green, Blue uint16) AllocColorCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, true)
c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie)
return AllocColorCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Green, Blue uint16) AllocColorCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, true)
c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie)
return AllocColorCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
Red uint16
Green uint16
Blue uint16
// padding: 2 bytes
Pixel uint32
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.Red = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Green = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Blue = xgb.Get16(buf[b:])
b += 2
b += 2 // padding
v.Pixel = xgb.Get32(buf[b:])
b += 4
return v
}
// allocColorRequest writes a AllocColor request to a byte slice for transfer.
func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red, Green, Blue uint16) []byte {
2013-08-12 02:43:26 +02:00
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 84 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2012-05-11 07:58:52 +02:00
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// AllocColorCellsCookie is a cookie used only for AllocColorCells requests.
type AllocColorCellsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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, Planes uint16) AllocColorCellsCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, true)
c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie)
return AllocColorCellsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Planes uint16) AllocColorCellsCookie {
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
PixelsLen uint16
MasksLen uint16
// padding: 20 bytes
Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4))
2017-01-18 10:52:16 +01:00
Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.PixelsLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MasksLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 20 // padding
2013-08-12 02:43:26 +02:00
v.Pixels = make([]uint32, v.PixelsLen)
for i := 0; i < int(v.PixelsLen); i++ {
v.Pixels[i] = xgb.Get32(buf[b:])
b += 4
}
2013-08-12 02:43:26 +02:00
v.Masks = make([]uint32, v.MasksLen)
for i := 0; i < int(v.MasksLen); i++ {
v.Masks[i] = xgb.Get32(buf[b:])
b += 4
}
2013-08-12 02:43:26 +02:00
return v
}
// allocColorCellsRequest writes a AllocColorCells request to a byte slice for transfer.
func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors, Planes uint16) []byte {
2013-08-12 02:43:26 +02:00
size := 12
b := 0
buf := make([]byte, size)
2012-05-11 07:58:52 +02:00
2013-08-12 02:43:26 +02:00
buf[b] = 86 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
if Contiguous {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Colors)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Planes)
b += 2
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests.
type AllocColorPlanesCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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, Reds, Greens, Blues uint16) AllocColorPlanesCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, true)
c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie)
return AllocColorPlanesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Reds, Greens, Blues uint16) AllocColorPlanesCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, true)
c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie)
return AllocColorPlanesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value.
func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply {
v := new(AllocColorPlanesReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.PixelsLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
v.RedMask = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.GreenMask = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.BlueMask = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
b += 8 // padding
2013-08-12 02:43:26 +02:00
v.Pixels = make([]uint32, v.PixelsLen)
for i := 0; i < int(v.PixelsLen); i++ {
v.Pixels[i] = xgb.Get32(buf[b:])
b += 4
}
return v
}
// allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice for transfer.
func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors, Reds, Greens, Blues uint16) []byte {
2013-08-12 02:43:26 +02:00
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 87 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
if Contiguous {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Colors)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Reds)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Greens)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Blues)
b += 2
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests.
type AllocNamedColorCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// AllocNamedColor sends a checked request.
// If an error occurs, it will be returned with the reply by calling AllocNamedColorCookie.Reply.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value.
func allocNamedColorReply(buf []byte) *AllocNamedColorReply {
v := new(AllocNamedColorReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.Pixel = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.ExactRed = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ExactGreen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ExactBlue = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.VisualRed = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.VisualGreen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.VisualBlue = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
return v
}
// allocNamedColorRequest writes a AllocNamedColor request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 85 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], NameLen)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
copy(buf[b:], Name[:NameLen])
b += int(NameLen)
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// AllowEventsCookie is a cookie used only for AllowEvents requests.
type AllowEventsCookie struct {
*xgb.Cookie
}
// Releases queued events if the client has caused a device (pointer/keyboard) to
// freeze due to grabbing it actively. This request has no effect if Time is
// earlier than the last-grab time of the most recent active grab for this client
// or if Time is later than the current X server time.
//
// May return a Value error if you specified an invalid Mode.
//
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// AllowEventsChecked sends a checked request.
// If an error occurs, it can be retrieved using AllowEventsCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// allowEventsRequest writes a AllowEvents request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 35 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Mode
b += 1
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// BellCookie is a cookie used only for Bell requests.
type BellCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// BellChecked sends a checked request.
// If an error occurs, it can be retrieved using BellCookie.Check.
2013-08-12 02:43:26 +02:00
func BellChecked(c *xgb.Conn, Percent int8) BellCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(bellRequest(c, Percent), cookie)
return BellCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// bellRequest writes a Bell request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func bellRequest(c *xgb.Conn, Percent int8) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 104 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = byte(Percent)
b += 1
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests.
type ChangeActivePointerGrabCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// ChangeActivePointerGrabChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeActivePointerGrabCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// changeActivePointerGrabRequest writes a ChangeActivePointerGrab request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte {
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 30 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cursor))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Time))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], EventMask)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// ChangeGCCookie is a cookie used only for ChangeGC requests.
type ChangeGCCookie struct {
*xgb.Cookie
}
// Changes the components specified by ValueMask for the specified graphics context.
//
// May return a Alloc error if the X server could not allocate the requested resources (no memory?).
//
// May return Font, GContext, Match, Pixmap, Value errors.
//
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// ChangeGCChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeGCCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// changeGCRequest writes a ChangeGC request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte {
2017-01-18 10:52:16 +01:00
size := xgb.Pad((12 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
2013-08-12 02:43:26 +02:00
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 56 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], ValueMask)
b += 4
2017-01-18 10:52:16 +01:00
2013-08-12 02:43:26 +02:00
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i])
b += 4
}
b = xgb.Pad(b)
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// ChangeHostsCookie is a cookie used only for ChangeHosts requests.
type ChangeHostsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ChangeHosts sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ChangeHosts(c *xgb.Conn, Mode, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie)
return ChangeHostsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ChangeHostsChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeHostsCookie.Check.
func ChangeHostsChecked(c *xgb.Conn, Mode, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie)
return ChangeHostsCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ChangeHostsCookie) Check() error {
return cook.Cookie.Check()
}
// changeHostsRequest writes a ChangeHosts request to a byte slice for transfer.
func changeHostsRequest(c *xgb.Conn, Mode, Family byte, AddressLen uint16, Address []byte) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 109 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Mode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
buf[b] = Family
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], AddressLen)
b += 2
2013-08-12 02:43:26 +02:00
copy(buf[b:], Address[:AddressLen])
b += int(AddressLen)
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests.
type ChangeKeyboardControlCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// ChangeKeyboardControlChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeKeyboardControlCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte {
2017-01-18 10:52:16 +01:00
size := xgb.Pad((8 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
2013-08-12 02:43:26 +02:00
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
2017-01-18 10:52:16 +01:00
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i])
b += 4
}
b = xgb.Pad(b)
return buf
}
2013-08-12 02:43:26 +02:00
// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests.
type ChangeKeyboardMappingCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ChangeKeyboardMapping sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie)
return ChangeKeyboardMappingCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ChangeKeyboardMappingChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check.
2013-08-12 02:43:26 +02:00
func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie)
return ChangeKeyboardMappingCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ChangeKeyboardMappingCookie) Check() error {
return cook.Cookie.Check()
}
// changeKeyboardMappingRequest writes a ChangeKeyboardMapping request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 100 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = KeycodeCount
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
buf[b] = byte(FirstKeycode)
b += 1
2013-08-12 02:43:26 +02:00
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
}
return buf
}
2013-08-12 02:43:26 +02:00
// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests.
type ChangePointerControlCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ChangePointerControl sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ChangePointerControl(c *xgb.Conn, AccelerationNumerator, AccelerationDenominator, Threshold int16, DoAcceleration, DoThreshold bool) ChangePointerControlCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie)
return ChangePointerControlCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ChangePointerControlChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangePointerControlCookie.Check.
func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator, AccelerationDenominator, Threshold int16, DoAcceleration, DoThreshold bool) ChangePointerControlCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie)
return ChangePointerControlCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// changePointerControlRequest writes a ChangePointerControl request to a byte slice for transfer.
func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator, AccelerationDenominator, Threshold int16, DoAcceleration, DoThreshold bool) []byte {
2013-08-12 02:43:26 +02:00
size := 12
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 105 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(AccelerationNumerator))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(AccelerationDenominator))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(Threshold))
b += 2
2013-08-12 02:43:26 +02:00
if DoAcceleration {
buf[b] = 1
} else {
2013-08-12 02:43:26 +02:00
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
if DoThreshold {
buf[b] = 1
} else {
2013-08-12 02:43:26 +02:00
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// ChangePropertyCookie is a cookie used only for ChangeProperty requests.
type ChangePropertyCookie struct {
*xgb.Cookie
}
// Sets or updates a property on the specified Window. Properties are for
// example the window title (WM_NAME) or its minimum size (WM_NORMAL_HINTS).
// Protocols such as EWMH also use properties - for example EWMH defines the
// window title, encoded as UTF-8 string, in the _NET_WM_NAME property.
//
// May return a Alloc error if the X server could not store the property (no memory?).
//
// May return a Atom error if property or Type do not refer to a valid atom.
//
// May return a Window error if the specified Window does not exist.
//
// May return Match, Value errors.
//
2013-08-12 02:43:26 +02:00
// 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, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie)
return ChangePropertyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie)
return ChangePropertyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// changePropertyRequest writes a ChangeProperty request to a byte slice for transfer.
func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property, Type Atom, Format byte, DataLen uint32, Data []byte) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 18 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
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 += int(((int(DataLen) * int(Format)) / 8))
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests.
type ChangeSaveSetCookie struct {
*xgb.Cookie
}
// This function either adds or removes the specified window to the client's (your
// application's) save set.
//
// May return a Match error if you created the specified window. This does not make sense, you can only add
// windows created by other clients to your save set.
//
// May return a Value error if you specified an invalid mode.
//
// May return a Window error if the specified window does not exist.
//
2013-08-12 02:43:26 +02:00
// ChangeSaveSet sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie)
return ChangeSaveSetCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ChangeSaveSetChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check.
2013-08-12 02:43:26 +02:00
func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie)
return ChangeSaveSetCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ChangeSaveSetCookie) Check() error {
return cook.Cookie.Check()
}
// changeSaveSetRequest writes a ChangeSaveSet request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 6 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests.
type ChangeWindowAttributesCookie struct {
*xgb.Cookie
}
// Changes the attributes specified by ValueMask for the specified Window.
//
// May return a Window error if the specified Window does not exist.
//
// May return Access, Colormap, Cursor, Match, Pixmap, Value errors.
//
2013-08-12 02:43:26 +02:00
// ChangeWindowAttributes sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie)
return ChangeWindowAttributesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ChangeWindowAttributesChecked sends a checked request.
// If an error occurs, it can be retrieved using ChangeWindowAttributesCookie.Check.
2013-08-12 02:43:26 +02:00
func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie)
return ChangeWindowAttributesCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ChangeWindowAttributesCookie) Check() error {
return cook.Cookie.Check()
}
// changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte {
2017-01-18 10:52:16 +01:00
size := xgb.Pad((12 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 2 // 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
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], ValueMask)
b += 4
2017-01-18 10:52:16 +01:00
2013-08-12 02:43:26 +02:00
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i])
b += 4
}
b = xgb.Pad(b)
return buf
}
2013-08-12 02:43:26 +02:00
// CirculateWindowCookie is a cookie used only for CirculateWindow requests.
type CirculateWindowCookie struct {
*xgb.Cookie
}
// If Direction is CirculateRaiseLowest, the lowest mapped child (if
// any) will be raised to the top of the stack.
//
// If Direction is CirculateLowerHighest, the highest mapped child will
// be lowered to the bottom of the stack.
//
// May return a Value error if the specified Direction is invalid.
//
// May return a Window error if the specified Window does not exist.
//
2013-08-12 02:43:26 +02:00
// CirculateWindow sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie)
return CirculateWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CirculateWindowChecked sends a checked request.
// If an error occurs, it can be retrieved using CirculateWindowCookie.Check.
2013-08-12 02:43:26 +02:00
func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie)
return CirculateWindowCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook CirculateWindowCookie) Check() error {
return cook.Cookie.Check()
}
// circulateWindowRequest writes a CirculateWindow request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 13 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Direction
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
}
2013-08-12 02:43:26 +02:00
// ClearAreaCookie is a cookie used only for ClearArea requests.
type ClearAreaCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ClearArea sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, Y int16, Width, Height uint16) ClearAreaCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie)
return ClearAreaCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Y int16, Width, Height uint16) ClearAreaCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie)
return ClearAreaCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ClearAreaCookie) Check() error {
return cook.Cookie.Check()
}
// clearAreaRequest writes a ClearArea request to a byte slice for transfer.
func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X, Y int16, Width, Height uint16) []byte {
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 61 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
xgb.Put32(buf[b:], uint32(Window))
b += 4
xgb.Put16(buf[b:], uint16(X))
b += 2
xgb.Put16(buf[b:], uint16(Y))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Width)
b += 2
xgb.Put16(buf[b:], Height)
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// CloseFontCookie is a cookie used only for CloseFont requests.
type CloseFontCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// CloseFont sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(closeFontRequest(c, Font), cookie)
return CloseFontCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CloseFontChecked sends a checked request.
// If an error occurs, it can be retrieved using CloseFontCookie.Check.
2013-08-12 02:43:26 +02:00
func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(closeFontRequest(c, Font), cookie)
return CloseFontCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook CloseFontCookie) Check() error {
return cook.Cookie.Check()
}
// closeFontRequest writes a CloseFont request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func closeFontRequest(c *xgb.Conn, Font Font) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 46 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Font))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// ConfigureWindowCookie is a cookie used only for ConfigureWindow requests.
type ConfigureWindowCookie struct {
*xgb.Cookie
}
// Configures a window's size, position, border width and stacking order.
//
// May return a Match error if you specified a Sibling without also specifying StackMode or the window is not
// actually a Sibling.
//
// May return a Window error if the specified window does not exist.
//
// May return Value errors.
//
2013-08-12 02:43:26 +02:00
// ConfigureWindow sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie)
return ConfigureWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ConfigureWindowChecked sends a checked request.
// If an error occurs, it can be retrieved using ConfigureWindowCookie.Check.
2013-08-12 02:43:26 +02:00
func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie)
return ConfigureWindowCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ConfigureWindowCookie) Check() error {
return cook.Cookie.Check()
}
// configureWindowRequest writes a ConfigureWindow request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte {
2017-01-18 10:52:16 +01:00
size := xgb.Pad((12 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 12 // 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
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// ConvertSelectionCookie is a cookie used only for ConvertSelection requests.
type ConvertSelectionCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ConvertSelection sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ConvertSelection(c *xgb.Conn, Requestor Window, Selection, Target, Property Atom, Time Timestamp) ConvertSelectionCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie)
return ConvertSelectionCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ConvertSelectionChecked sends a checked request.
// If an error occurs, it can be retrieved using ConvertSelectionCookie.Check.
func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection, Target, Property Atom, Time Timestamp) ConvertSelectionCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie)
return ConvertSelectionCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ConvertSelectionCookie) Check() error {
return cook.Cookie.Check()
}
// convertSelectionRequest writes a ConvertSelection request to a byte slice for transfer.
func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection, Target, Property Atom, Time Timestamp) []byte {
2013-08-12 02:43:26 +02:00
size := 24
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 24 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// CopyAreaCookie is a cookie used only for CopyArea requests.
type CopyAreaCookie struct {
*xgb.Cookie
}
// Copies the specified rectangle from SrcDrawable to DstDrawable.
//
// May return a Drawable error if the specified Drawable (Window or Pixmap) does not exist.
//
// May return a GContext error if the specified graphics context does not exist.
//
// May return a Match error if srcDrawable has a different root or depth than DstDrawable.
//
2013-08-12 02:43:26 +02:00
// CopyArea sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CopyArea(c *xgb.Conn, SrcDrawable, DstDrawable Drawable, Gc Gcontext, SrcX, SrcY, DstX, DstY int16, Width, Height uint16) CopyAreaCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie)
return CopyAreaCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CopyAreaChecked sends a checked request.
// If an error occurs, it can be retrieved using CopyAreaCookie.Check.
func CopyAreaChecked(c *xgb.Conn, SrcDrawable, DstDrawable Drawable, Gc Gcontext, SrcX, SrcY, DstX, DstY int16, Width, Height uint16) CopyAreaCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie)
return CopyAreaCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook CopyAreaCookie) Check() error {
return cook.Cookie.Check()
}
// copyAreaRequest writes a CopyArea request to a byte slice for transfer.
func copyAreaRequest(c *xgb.Conn, SrcDrawable, DstDrawable Drawable, Gc Gcontext, SrcX, SrcY, DstX, DstY int16, Width, Height uint16) []byte {
2013-08-12 02:43:26 +02:00
size := 28
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 62 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(SrcDrawable))
b += 4
xgb.Put32(buf[b:], uint32(DstDrawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests.
type CopyColormapAndFreeCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// CopyColormapAndFree sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CopyColormapAndFree(c *xgb.Conn, Mid, SrcCmap Colormap) CopyColormapAndFreeCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie)
return CopyColormapAndFreeCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CopyColormapAndFreeChecked sends a checked request.
// If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check.
func CopyColormapAndFreeChecked(c *xgb.Conn, Mid, SrcCmap Colormap) CopyColormapAndFreeCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie)
return CopyColormapAndFreeCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook CopyColormapAndFreeCookie) Check() error {
return cook.Cookie.Check()
}
// copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice for transfer.
func copyColormapAndFreeRequest(c *xgb.Conn, Mid, SrcCmap Colormap) []byte {
2013-08-12 02:43:26 +02:00
size := 12
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 80 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Mid))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(SrcCmap))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// CopyGCCookie is a cookie used only for CopyGC requests.
type CopyGCCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// CopyGC sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CopyGC(c *xgb.Conn, SrcGc, DstGc Gcontext, ValueMask uint32) CopyGCCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie)
return CopyGCCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CopyGCChecked sends a checked request.
// If an error occurs, it can be retrieved using CopyGCCookie.Check.
func CopyGCChecked(c *xgb.Conn, SrcGc, DstGc Gcontext, ValueMask uint32) CopyGCCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie)
return CopyGCCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook CopyGCCookie) Check() error {
return cook.Cookie.Check()
}
// copyGCRequest writes a CopyGC request to a byte slice for transfer.
func copyGCRequest(c *xgb.Conn, SrcGc, DstGc Gcontext, ValueMask uint32) []byte {
2013-08-12 02:43:26 +02:00
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 57 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// CopyPlaneCookie is a cookie used only for CopyPlane requests.
type CopyPlaneCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// CopyPlane sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CopyPlane(c *xgb.Conn, SrcDrawable, DstDrawable Drawable, Gc Gcontext, SrcX, SrcY, DstX, DstY int16, Width, Height uint16, BitPlane uint32) CopyPlaneCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie)
return CopyPlaneCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CopyPlaneChecked sends a checked request.
// If an error occurs, it can be retrieved using CopyPlaneCookie.Check.
func CopyPlaneChecked(c *xgb.Conn, SrcDrawable, DstDrawable Drawable, Gc Gcontext, SrcX, SrcY, DstX, DstY int16, Width, Height uint16, BitPlane uint32) CopyPlaneCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie)
return CopyPlaneCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// copyPlaneRequest writes a CopyPlane request to a byte slice for transfer.
func copyPlaneRequest(c *xgb.Conn, SrcDrawable, DstDrawable Drawable, Gc Gcontext, SrcX, SrcY, DstX, DstY int16, Width, Height uint16, BitPlane uint32) []byte {
2013-08-12 02:43:26 +02:00
size := 32
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 63 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(SrcDrawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(DstDrawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(SrcX))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(SrcY))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(DstX))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(DstY))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Height)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], BitPlane)
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// CreateColormapCookie is a cookie used only for CreateColormap requests.
type CreateColormapCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// CreateColormap sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// CreateColormapChecked sends a checked request.
// If an error occurs, it can be retrieved using CreateColormapCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// createColormapRequest writes a CreateColormap request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte {
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 78 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Alloc
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Mid))
b += 4
xgb.Put32(buf[b:], uint32(Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Visual))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// CreateCursorCookie is a cookie used only for CreateCursor requests.
type CreateCursorCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// CreateCursor sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CreateCursor(c *xgb.Conn, Cid Cursor, Source, Mask Pixmap, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y uint16) CreateCursorCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie)
return CreateCursorCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CreateCursorChecked sends a checked request.
// If an error occurs, it can be retrieved using CreateCursorCookie.Check.
func CreateCursorChecked(c *xgb.Conn, Cid Cursor, Source, Mask Pixmap, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y uint16) CreateCursorCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie)
return CreateCursorCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// createCursorRequest writes a CreateCursor request to a byte slice for transfer.
func createCursorRequest(c *xgb.Conn, Cid Cursor, Source, Mask Pixmap, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y uint16) []byte {
2013-08-12 02:43:26 +02:00
size := 32
b := 0
buf := make([]byte, size)
buf[b] = 93 // request opcode
b += 1
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cid))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Source))
b += 4
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// CreateGCCookie is a cookie used only for CreateGC requests.
type CreateGCCookie struct {
*xgb.Cookie
}
// Creates a graphics context. The graphics context can be used with any drawable
// that has the same root and depth as the specified drawable.
//
// May return a Alloc error if the X server could not allocate the requested resources (no memory?).
//
// May return a Drawable error if the specified Drawable (Window or Pixmap) does not exist.
//
// May return Font, Match, Pixmap, Value errors.
//
2013-08-12 02:43:26 +02:00
// 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.
2013-08-12 02:43:26 +02:00
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()
}
// createGCRequest writes a CreateGC request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte {
2017-01-18 10:52:16 +01:00
size := xgb.Pad((16 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 55 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cid))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], ValueMask)
b += 4
2017-01-18 10:52:16 +01:00
2013-08-12 02:43:26 +02:00
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i])
b += 4
}
b = xgb.Pad(b)
return buf
}
2013-08-12 02:43:26 +02:00
// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests.
type CreateGlyphCursorCookie struct {
*xgb.Cookie
}
// Creates a cursor from a font glyph. X provides a set of standard cursor shapes
// in a special font named cursor. Applications are encouraged to use this
// interface for their cursors because the font can be customized for the
// individual display type.
//
// All pixels which are set to 1 in the source will use the foreground color (as
// specified by ForeRed, ForeGreen and ForeBlue). All pixels set to 0
// will use the background color (as specified by BackRed, BackGreen and
// BackBlue).
//
// May return a Alloc error if the X server could not allocate the requested resources (no memory?).
//
// May return a Font error if the specified SourceFont or MaskFont does not exist.
//
// May return a Value error if either SourceChar or MaskChar are not defined in SourceFont or MaskFont, respectively.
//
2013-08-12 02:43:26 +02:00
// CreateGlyphCursor sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CreateGlyphCursor(c *xgb.Conn, Cid Cursor, SourceFont, MaskFont Font, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue uint16) CreateGlyphCursorCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie)
return CreateGlyphCursorCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CreateGlyphCursorChecked sends a checked request.
// If an error occurs, it can be retrieved using CreateGlyphCursorCookie.Check.
func CreateGlyphCursorChecked(c *xgb.Conn, Cid Cursor, SourceFont, MaskFont Font, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue uint16) CreateGlyphCursorCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie)
return CreateGlyphCursorCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// createGlyphCursorRequest writes a CreateGlyphCursor request to a byte slice for transfer.
func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont, MaskFont Font, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue uint16) []byte {
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], ForeGreen)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], ForeBlue)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], BackRed)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], BackGreen)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], BackBlue)
b += 2
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// CreatePixmapCookie is a cookie used only for CreatePixmap requests.
type CreatePixmapCookie struct {
*xgb.Cookie
}
// Creates a pixmap. The pixmap can only be used on the same screen as Drawable
// is on and only with drawables of the same Depth.
//
// May return a Alloc error if the X server could not allocate the requested resources (no memory?).
//
// May return a Drawable error if the specified Drawable (Window or Pixmap) does not exist.
//
// May return Value errors.
//
2013-08-12 02:43:26 +02:00
// 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, Height uint16) CreatePixmapCookie {
2013-08-12 02:43:26 +02:00
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, Height uint16) CreatePixmapCookie {
2013-08-12 02:43:26 +02:00
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()
}
// createPixmapRequest writes a CreatePixmap request to a byte slice for transfer.
func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width, Height uint16) []byte {
2013-08-12 02:43:26 +02:00
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 53 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Depth
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Pid))
b += 4
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Width)
b += 2
xgb.Put16(buf[b:], Height)
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// CreateWindowCookie is a cookie used only for CreateWindow requests.
type CreateWindowCookie struct {
*xgb.Cookie
}
// Creates an unmapped window as child of the specified Parent window. A
// CreateNotify event will be generated. The new window is placed on top in the
// stacking order with respect to siblings.
//
// The coordinate system has the X axis horizontal and the Y axis vertical with
// the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms
// of pixels, and coincide with pixel centers. Each window and pixmap has its own
// coordinate system. For a window, the origin is inside the border at the inside,
// upper-left corner.
//
// The created window is not yet displayed (mapped), call MapWindow to
// display it.
//
// The created window will initially use the same cursor as its parent.
//
// May return a Alloc error if the X server could not allocate the requested resources (no memory?).
//
// May return Colormap, Cursor, Match, Pixmap, Value, Window errors.
//
2013-08-12 02:43:26 +02:00
// CreateWindow sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CreateWindow(c *xgb.Conn, Depth byte, Wid, Parent Window, X, Y int16, Width, Height, BorderWidth, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie)
return CreateWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// CreateWindowChecked sends a checked request.
// If an error occurs, it can be retrieved using CreateWindowCookie.Check.
func CreateWindowChecked(c *xgb.Conn, Depth byte, Wid, Parent Window, X, Y int16, Width, Height, BorderWidth, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie)
return CreateWindowCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook CreateWindowCookie) Check() error {
return cook.Cookie.Check()
}
// createWindowRequest writes a CreateWindow request to a byte slice for transfer.
func createWindowRequest(c *xgb.Conn, Depth byte, Wid, Parent Window, X, Y int16, Width, Height, BorderWidth, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte {
2017-01-18 10:52:16 +01:00
size := xgb.Pad((32 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 1 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Depth
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Wid))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Parent))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(Y))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Width)
b += 2
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], ValueMask)
b += 4
2017-01-18 10:52:16 +01:00
2013-08-12 02:43:26 +02:00
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i])
b += 4
}
b = xgb.Pad(b)
return buf
}
2012-05-11 05:57:34 +02:00
// DeletePropertyCookie is a cookie used only for DeleteProperty requests.
type DeletePropertyCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// DeleteProperty sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func DeleteProperty(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(deletePropertyRequest(c, Window, Property), cookie)
return DeletePropertyCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// DeletePropertyChecked sends a checked request.
// If an error occurs, it can be retrieved using DeletePropertyCookie.Check.
func DeletePropertyChecked(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(deletePropertyRequest(c, Window, Property), cookie)
return DeletePropertyCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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 DeletePropertyCookie) Check() error {
return cook.Cookie.Check()
}
// deletePropertyRequest writes a DeleteProperty request to a byte slice for transfer.
func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte {
size := 12
b := 0
buf := make([]byte, size)
buf[b] = 19 // 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
xgb.Put32(buf[b:], uint32(Property))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests.
type DestroySubwindowsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// DestroySubwindowsChecked sends a checked request.
// If an error occurs, it can be retrieved using DestroySubwindowsCookie.Check.
2013-08-12 02:43:26 +02:00
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()
}
// destroySubwindowsRequest writes a DestroySubwindows request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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
}
// Destroys the specified window and all of its subwindows. A DestroyNotify event
// is generated for each destroyed window (a DestroyNotify event is first generated
// for any given window's inferiors). If the window was mapped, it will be
// automatically unmapped before destroying.
//
// Calling DestroyWindow on the root window will do nothing.
//
// May return a Window error if the specified window does not exist.
//
2013-08-12 02:43:26 +02:00
// DestroyWindow sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(destroyWindowRequest(c, Window), cookie)
return DestroyWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// DestroyWindowChecked sends a checked request.
// If an error occurs, it can be retrieved using DestroyWindowCookie.Check.
2013-08-12 02:43:26 +02:00
func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(destroyWindowRequest(c, Window), cookie)
return DestroyWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// destroyWindowRequest writes a DestroyWindow request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func destroyWindowRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 4 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// FillPolyCookie is a cookie used only for FillPoly requests.
type FillPolyCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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, CoordinateMode byte, Points []Point) FillPolyCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie)
return FillPolyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, CoordinateMode byte, Points []Point) FillPolyCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie)
return FillPolyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// fillPolyRequest writes a FillPoly request to a byte slice for transfer.
func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape, CoordinateMode byte, Points []Point) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((16 + xgb.Pad((len(Points) * 4))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 69 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
buf[b] = Shape
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = CoordinateMode
b += 1
2013-08-12 02:43:26 +02:00
b += 2 // padding
b += PointListBytes(buf[b:], Points)
return buf
}
2013-08-12 02:43:26 +02:00
// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests.
type ForceScreenSaverCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ForceScreenSaver sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(forceScreenSaverRequest(c, Mode), cookie)
return ForceScreenSaverCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ForceScreenSaverChecked sends a checked request.
// If an error occurs, it can be retrieved using ForceScreenSaverCookie.Check.
2013-08-12 02:43:26 +02:00
func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(forceScreenSaverRequest(c, Mode), cookie)
return ForceScreenSaverCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// forceScreenSaverRequest writes a ForceScreenSaver request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 115 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Mode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// FreeColormapCookie is a cookie used only for FreeColormap requests.
type FreeColormapCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// FreeColormap sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(freeColormapRequest(c, Cmap), cookie)
return FreeColormapCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// FreeColormapChecked sends a checked request.
// If an error occurs, it can be retrieved using FreeColormapCookie.Check.
2013-08-12 02:43:26 +02:00
func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(freeColormapRequest(c, Cmap), cookie)
return FreeColormapCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook FreeColormapCookie) Check() error {
return cook.Cookie.Check()
}
// freeColormapRequest writes a FreeColormap request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 79 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// FreeColorsCookie is a cookie used only for FreeColors requests.
type FreeColorsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// FreeColors sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// FreeColorsChecked sends a checked request.
// If an error occurs, it can be retrieved using FreeColorsCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// freeColorsRequest writes a FreeColors request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], PlaneMask)
b += 4
2013-08-12 02:43:26 +02:00
for i := 0; i < int(len(Pixels)); i++ {
xgb.Put32(buf[b:], Pixels[i])
b += 4
}
return buf
}
2013-08-12 02:43:26 +02:00
// FreeCursorCookie is a cookie used only for FreeCursor requests.
type FreeCursorCookie struct {
*xgb.Cookie
}
// Deletes the association between the cursor resource ID and the specified
// cursor. The cursor is freed when no other resource references it.
//
// May return a Cursor error if the specified cursor does not exist.
//
2013-08-12 02:43:26 +02:00
// 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.
2013-08-12 02:43:26 +02:00
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()
}
// freeCursorRequest writes a FreeCursor request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 95 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cursor))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// FreeGCCookie is a cookie used only for FreeGC requests.
type FreeGCCookie struct {
*xgb.Cookie
}
// Destroys the specified Gc and all associated storage.
//
// May return a GContext error if the specified graphics context does not exist.
//
2013-08-12 02:43:26 +02:00
// FreeGC sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(freeGCRequest(c, Gc), cookie)
return FreeGCCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// FreeGCChecked sends a checked request.
// If an error occurs, it can be retrieved using FreeGCCookie.Check.
2013-08-12 02:43:26 +02:00
func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(freeGCRequest(c, Gc), cookie)
return FreeGCCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook FreeGCCookie) Check() error {
return cook.Cookie.Check()
}
// freeGCRequest writes a FreeGC request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 60 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// FreePixmapCookie is a cookie used only for FreePixmap requests.
type FreePixmapCookie struct {
*xgb.Cookie
}
// Deletes the association between the pixmap ID and the pixmap. The pixmap
// storage will be freed when there are no more references to it.
//
// May return a Pixmap error if the specified pixmap does not exist.
//
2013-08-12 02:43:26 +02:00
// FreePixmap sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(freePixmapRequest(c, Pixmap), cookie)
return FreePixmapCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// FreePixmapChecked sends a checked request.
// If an error occurs, it can be retrieved using FreePixmapCookie.Check.
2013-08-12 02:43:26 +02:00
func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(freePixmapRequest(c, Pixmap), cookie)
return FreePixmapCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook FreePixmapCookie) Check() error {
return cook.Cookie.Check()
}
// freePixmapRequest writes a FreePixmap request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 54 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Pixmap))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GetAtomNameCookie is a cookie used only for GetAtomName requests.
type GetAtomNameCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetAtomName sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetAtomNameCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getAtomNameRequest(c, Atom), cookie)
return GetAtomNameCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetAtomNameUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getAtomNameRequest(c, Atom), cookie)
return GetAtomNameCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetAtomNameReply represents the data returned from a GetAtomName request.
type GetAtomNameReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2013-08-12 02:43:26 +02:00
// padding: 1 bytes
NameLen uint16
// padding: 22 bytes
Name string // size: xgb.Pad((int(NameLen) * 1))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return getAtomNameReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// getAtomNameReply reads a byte slice into a GetAtomNameReply value.
func getAtomNameReply(buf []byte) *GetAtomNameReply {
v := new(GetAtomNameReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.NameLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 22 // padding
2013-08-12 02:43:26 +02:00
{
byteString := make([]byte, v.NameLen)
copy(byteString[:v.NameLen], buf[b:])
v.Name = string(byteString)
b += int(v.NameLen)
2013-08-12 02:43:26 +02:00
}
2013-08-12 02:43:26 +02:00
return v
}
// getAtomNameRequest writes a GetAtomName request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 17 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Atom))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GetFontPathCookie is a cookie used only for GetFontPath requests.
type GetFontPathCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetFontPath sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetFontPathCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetFontPath(c *xgb.Conn) GetFontPathCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(getFontPathRequest(c), cookie)
return GetFontPathCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// getFontPathReply reads a byte slice into a GetFontPathReply value.
func getFontPathReply(buf []byte) *GetFontPathReply {
v := new(GetFontPathReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.PathLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 22 // padding
2013-08-12 02:43:26 +02:00
v.Path = make([]Str, v.PathLen)
b += StrReadList(buf[b:], v.Path)
2013-08-12 02:43:26 +02:00
return v
}
// getFontPathRequest writes a GetFontPath request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getFontPathRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 52 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// GetGeometryCookie is a cookie used only for GetGeometry requests.
type GetGeometryCookie struct {
*xgb.Cookie
}
// Gets the current geometry of the specified drawable (either Window or Pixmap).
//
// May return Drawable, Window errors.
//
2013-08-12 02:43:26 +02:00
// GetGeometry sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetGeometryCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(getGeometryRequest(c, Drawable), cookie)
return GetGeometryCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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
// The depth of the drawable (bits per pixel for the object).
Depth byte
// Root window of the screen containing Drawable.
Root Window
// The X coordinate of Drawable. If Drawable is a window, the coordinate
// specifies the upper-left outer corner relative to its parent's origin. If
// Drawable is a pixmap, the X coordinate is always 0.
X int16
// The Y coordinate of Drawable. If Drawable is a window, the coordinate
// specifies the upper-left outer corner relative to its parent's origin. If
// Drawable is a pixmap, the Y coordinate is always 0.
Y int16
// The width of Drawable.
Width uint16
// The height of Drawable.
Height uint16
// The border width (in pixels).
2013-08-12 02:43:26 +02:00
BorderWidth uint16
// padding: 2 bytes
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// getGeometryReply reads a byte slice into a GetGeometryReply value.
func getGeometryReply(buf []byte) *GetGeometryReply {
v := new(GetGeometryReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.Depth = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.Root = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.X = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Y = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Width = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Height = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.BorderWidth = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
return v
}
// getGeometryRequest writes a GetGeometry request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 14 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GetImageCookie is a cookie used only for GetImage requests.
type GetImageCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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, Y int16, Width, Height uint16, PlaneMask uint32) GetImageCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie)
return GetImageCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetImageUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, Y int16, Width, Height uint16, PlaneMask uint32) GetImageCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie)
return GetImageCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetImageReply represents the data returned from a GetImage request.
type GetImageReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2013-08-12 02:43:26 +02:00
Depth byte
Visual Visualid
// padding: 20 bytes
Data []byte // size: xgb.Pad(((int(Length) * 4) * 1))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return getImageReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// getImageReply reads a byte slice into a GetImageReply value.
func getImageReply(buf []byte) *GetImageReply {
v := new(GetImageReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
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 += int((int(v.Length) * 4))
2013-08-12 02:43:26 +02:00
return v
}
// getImageRequest writes a GetImage request to a byte slice for transfer.
func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X, Y int16, Width, Height uint16, PlaneMask uint32) []byte {
2013-08-12 02:43:26 +02:00
size := 20
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 73 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Format
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(Y))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Height)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], PlaneMask)
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GetInputFocusCookie is a cookie used only for GetInputFocus requests.
type GetInputFocusCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetInputFocus sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetInputFocusCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetInputFocus(c *xgb.Conn) GetInputFocusCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(getInputFocusRequest(c), cookie)
return GetInputFocusCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
if buf == nil {
return nil, nil
}
return getInputFocusReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// getInputFocusReply reads a byte slice into a GetInputFocusReply value.
func getInputFocusReply(buf []byte) *GetInputFocusReply {
v := new(GetInputFocusReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.RevertTo = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.Focus = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
return v
}
// getInputFocusRequest writes a GetInputFocus request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getInputFocusRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 43 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests.
type GetKeyboardControlCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetKeyboardControl sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(getKeyboardControlRequest(c), cookie)
return GetKeyboardControlCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value.
func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply {
v := new(GetKeyboardControlReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.GlobalAutoRepeat = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.LedMask = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.KeyClickPercent = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.BellPercent = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.BellPitch = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.BellDuration = xgb.Get16(buf[b:])
b += 2
b += 2 // padding
v.AutoRepeats = make([]byte, 32)
copy(v.AutoRepeats[:32], buf[b:])
b += int(32)
2013-08-12 02:43:26 +02:00
return v
}
// getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getKeyboardControlRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
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
return buf
}
2013-08-12 02:43:26 +02:00
// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests.
type GetKeyboardMappingCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetKeyboardMapping sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetKeyboardMappingCookie.Reply.
2013-08-12 02:43:26 +02:00
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.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
return v
}
// getKeyboardMappingRequest writes a GetKeyboardMapping request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 101 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
buf[b] = byte(FirstKeycode)
b += 1
buf[b] = Count
b += 1
return buf
}
2013-08-12 02:43:26 +02:00
// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests.
type GetModifierMappingCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetModifierMapping sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetModifierMappingCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getModifierMappingRequest(c), cookie)
return GetModifierMappingCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetModifierMappingUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getModifierMappingRequest(c), cookie)
return GetModifierMappingCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return getModifierMappingReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// getModifierMappingReply reads a byte slice into a GetModifierMappingReply value.
func getModifierMappingReply(buf []byte) *GetModifierMappingReply {
v := new(GetModifierMappingReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
b += 24 // padding
2013-08-12 02:43:26 +02:00
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
}
return v
}
// getModifierMappingRequest writes a GetModifierMapping request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getModifierMappingRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 119 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2012-05-11 05:57:34 +02:00
// GetMotionEventsCookie is a cookie used only for GetMotionEvents requests.
type GetMotionEventsCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// GetMotionEvents sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetMotionEventsCookie.Reply.
func GetMotionEvents(c *xgb.Conn, Window Window, Start, Stop Timestamp) GetMotionEventsCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie)
return GetMotionEventsCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// GetMotionEventsUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start, Stop Timestamp) GetMotionEventsCookie {
cookie := c.NewCookie(false, true)
c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie)
return GetMotionEventsCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// GetMotionEventsReply represents the data returned from a GetMotionEvents request.
type GetMotionEventsReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
EventsLen uint32
// padding: 20 bytes
Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8))
}
2012-05-11 05:57:34 +02:00
// Reply blocks and returns the reply data for a GetMotionEvents request.
func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return getMotionEventsReply(buf), nil
}
2012-05-11 05:57:34 +02:00
// getMotionEventsReply reads a byte slice into a GetMotionEventsReply value.
func getMotionEventsReply(buf []byte) *GetMotionEventsReply {
v := new(GetMotionEventsReply)
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.EventsLen = xgb.Get32(buf[b:])
b += 4
b += 20 // padding
v.Events = make([]Timecoord, v.EventsLen)
b += TimecoordReadList(buf[b:], v.Events)
return v
}
// getMotionEventsRequest writes a GetMotionEvents request to a byte slice for transfer.
func getMotionEventsRequest(c *xgb.Conn, Window Window, Start, Stop Timestamp) []byte {
size := 16
b := 0
buf := make([]byte, size)
buf[b] = 39 // 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
xgb.Put32(buf[b:], uint32(Start))
b += 4
xgb.Put32(buf[b:], uint32(Stop))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GetPointerControlCookie is a cookie used only for GetPointerControl requests.
type GetPointerControlCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetPointerControl sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetPointerControlCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetPointerControl(c *xgb.Conn) GetPointerControlCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getPointerControlRequest(c), cookie)
return GetPointerControlCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetPointerControlUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getPointerControlRequest(c), cookie)
return GetPointerControlCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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 {
2013-08-12 02:43:26 +02:00
return nil, err
}
if buf == nil {
return nil, nil
}
return getPointerControlReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.AccelerationNumerator = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.AccelerationDenominator = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Threshold = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 18 // padding
2013-08-12 02:43:26 +02:00
return v
}
// getPointerControlRequest writes a GetPointerControl request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests.
type GetPointerMappingCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetPointerMapping sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetPointerMappingCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(getPointerMappingRequest(c), cookie)
return GetPointerMappingCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value.
func getPointerMappingReply(buf []byte) *GetPointerMappingReply {
v := new(GetPointerMappingReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.MapLen = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
b += 24 // padding
v.Map = make([]byte, v.MapLen)
copy(v.Map[:v.MapLen], buf[b:])
b += int(v.MapLen)
2013-08-12 02:43:26 +02:00
return v
}
// getPointerMappingRequest writes a GetPointerMapping request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// GetPropertyCookie is a cookie used only for GetProperty requests.
type GetPropertyCookie struct {
*xgb.Cookie
}
// Gets the specified Property from the specified Window. Properties are for
// example the window title (WM_NAME) or its minimum size (WM_NORMAL_HINTS).
// Protocols such as EWMH also use properties - for example EWMH defines the
// window title, encoded as UTF-8 string, in the _NET_WM_NAME property.
//
// May return a Atom error if property or Type do not refer to a valid atom.
//
// May return a Value error if the specified LongOffset is beyond the actual property length (e.g. the
// property has a length of 3 bytes and you are setting LongOffset to 1,
// resulting in a byte offset of 4).
//
// May return a Window error if the specified Window does not exist.
//
2013-08-12 02:43:26 +02:00
// 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, Type Atom, LongOffset, LongLength uint32) GetPropertyCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie)
return GetPropertyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetPropertyUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, Type Atom, LongOffset, LongLength uint32) GetPropertyCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie)
return GetPropertyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
// Specifies whether the data should be viewed as a list of 8-bit, 16-bit, or
// 32-bit quantities. Possible values are 8, 16, and 32. This information allows
// the X server to correctly perform byte-swap operations as necessary.
Format byte
// The actual type of the property (an atom).
Type Atom
// The number of bytes remaining to be read in the property if a partial read was
// performed.
2013-08-12 02:43:26 +02:00
BytesAfter uint32
// The length of value. You should use the corresponding accessor instead of this
// field.
ValueLen uint32
2013-08-12 02:43:26 +02:00
// padding: 12 bytes
Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return getPropertyReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// getPropertyReply reads a byte slice into a GetPropertyReply value.
func getPropertyReply(buf []byte) *GetPropertyReply {
v := new(GetPropertyReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.Format = buf[b]
b += 1
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
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 += int((int(v.ValueLen) * (int(v.Format) / 8)))
2013-08-12 02:43:26 +02:00
return v
}
// getPropertyRequest writes a GetProperty request to a byte slice for transfer.
func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property, Type Atom, LongOffset, LongLength uint32) []byte {
2013-08-12 02:43:26 +02:00
size := 24
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 20 // request opcode
b += 1
if Delete {
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
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests.
type GetScreenSaverCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GetScreenSaver sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetScreenSaverCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getScreenSaverRequest(c), cookie)
return GetScreenSaverCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetScreenSaverUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getScreenSaverRequest(c), cookie)
return GetScreenSaverCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetScreenSaverReply represents the data returned from a GetScreenSaver request.
type GetScreenSaverReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Timeout uint16
Interval uint16
PreferBlanking byte
AllowExposures byte
// padding: 18 bytes
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return getScreenSaverReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
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
}
// getScreenSaverRequest writes a GetScreenSaver request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getScreenSaverRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 108 // 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
}
2013-08-12 02:43:26 +02:00
// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests.
type GetSelectionOwnerCookie struct {
*xgb.Cookie
}
// Gets the owner of the specified selection.
//
// May return a Atom error if selection does not refer to a valid atom.
//
2013-08-12 02:43:26 +02:00
// GetSelectionOwner sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie)
return GetSelectionOwnerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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
// The current selection owner window.
2013-08-12 02:43:26 +02:00
Owner Window
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.Owner = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
return v
}
// getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 23 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Selection))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests.
type GetWindowAttributesCookie struct {
*xgb.Cookie
}
// Gets the current attributes for the specified Window.
//
// May return a Window error if the specified Window does not exist.
//
// May return Drawable errors.
//
2013-08-12 02:43:26 +02:00
// GetWindowAttributes sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetWindowAttributesCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getWindowAttributesRequest(c, Window), cookie)
return GetWindowAttributesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GetWindowAttributesUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(getWindowAttributesRequest(c, Window), cookie)
return GetWindowAttributesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
// The associated visual structure of Window.
Visual Visualid
Class uint16
BitGravity byte
WinGravity byte
// Planes to be preserved if possible.
BackingPlanes uint32
// Value to be used when restoring planes.
BackingPixel uint32
// Boolean, should bits under be saved?
SaveUnder bool
MapIsInstalled bool
MapState byte
// Window managers should ignore this window if OverrideRedirect is 1.
OverrideRedirect bool
// Color map to be associated with window.
Colormap Colormap
// Set of events all people have interest in.
AllEventMasks uint32
// My event mask.
YourEventMask uint32
// Set of events that should not propagate.
2013-08-12 02:43:26 +02:00
DoNotPropagateMask uint16
// padding: 2 bytes
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return getWindowAttributesReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value.
func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply {
v := new(GetWindowAttributesReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.BackingStore = buf[b]
b += 1
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
2013-08-12 02:43:26 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v.Visual = Visualid(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Class = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.BitGravity = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.WinGravity = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.BackingPlanes = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.BackingPixel = xgb.Get32(buf[b:])
b += 4
if buf[b] == 1 {
v.SaveUnder = true
} else {
v.SaveUnder = false
}
b += 1
2013-08-12 02:43:26 +02:00
if buf[b] == 1 {
v.MapIsInstalled = true
} else {
v.MapIsInstalled = false
}
b += 1
2013-08-12 02:43:26 +02:00
v.MapState = buf[b]
b += 1
if buf[b] == 1 {
2013-08-12 02:43:26 +02:00
v.OverrideRedirect = true
} else {
2013-08-12 02:43:26 +02:00
v.OverrideRedirect = false
}
b += 1
2013-08-12 02:43:26 +02:00
v.Colormap = Colormap(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.AllEventMasks = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.YourEventMask = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.DoNotPropagateMask = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
return v
}
// getWindowAttributesRequest writes a GetWindowAttributes request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 3 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GrabButtonCookie is a cookie used only for GrabButton requests.
type GrabButtonCookie struct {
*xgb.Cookie
}
// This request establishes a passive grab. The pointer is actively grabbed as
// described in GrabPointer, the last-pointer-grab time is set to the time at
// which the button was pressed (as transmitted in the ButtonPress event), and the
// ButtonPress event is reported if all of the following conditions are true:
//
// The pointer is not grabbed and the specified button is logically pressed when
// the specified modifier keys are logically down, and no other buttons or
// modifier keys are logically down.
//
// The grab-window contains the pointer.
//
// The confine-to window (if any) is viewable.
//
// A passive grab on the same button/key combination does not exist on any
// ancestor of grab-window.
//
// The interpretation of the remaining arguments is the same as for GrabPointer.
// The active grab is terminated automatically when the logical state of the
// pointer has all buttons released, independent of the logical state of modifier
// keys. Note that the logical state of a device (as seen by means of the
// protocol) may lag the physical state if device event processing is frozen. This
// request overrides all previous passive grabs by the same client on the same
// button/key combinations on the same window. A modifier of AnyModifier is
// equivalent to issuing the request for all possible modifier combinations
// (including the combination of no modifiers). It is not required that all
// specified modifiers have currently assigned keycodes. A button of AnyButton is
// equivalent to issuing the request for all possible buttons. Otherwise, it is
// not required that the button specified currently be assigned to a physical
// button.
//
// An Access error is generated if some other client has already issued a
// GrabButton request with the same button/key combination on the same window.
// When using AnyModifier or AnyButton, the request fails completely (no grabs are
// established), and an Access error is generated if there is a conflicting grab
// for any combination. The request has no effect on an active grab.
//
// May return a Access error if another client has already issued a GrabButton with the same button/key
// combination on the same window.
//
// May return a Cursor error if the specified Cursor does not exist.
//
// May return a Window error if the specified Window does not exist.
//
// May return Value errors.
//
2013-08-12 02:43:26 +02:00
// GrabButton sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie)
return GrabButtonCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie)
return GrabButtonCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// grabButtonRequest writes a GrabButton request to a byte slice for transfer.
func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte {
2013-08-12 02:43:26 +02:00
size := 24
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 28 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
if OwnerEvents {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(GrabWindow))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], EventMask)
b += 2
2013-08-12 02:43:26 +02:00
buf[b] = PointerMode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = KeyboardMode
b += 1
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(ConfineTo))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cursor))
b += 4
2013-08-12 02:43:26 +02:00
buf[b] = Button
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Modifiers)
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// GrabKeyCookie is a cookie used only for GrabKey requests.
type GrabKeyCookie struct {
*xgb.Cookie
}
// Establishes a passive grab on the keyboard. In the future, the keyboard is
// actively grabbed (as for GrabKeyboard), the last-keyboard-grab time is set to
// the time at which the key was pressed (as transmitted in the KeyPress event),
// and the KeyPress event is reported if all of the following conditions are true:
//
// The keyboard is not grabbed and the specified key (which can itself be a
// modifier key) is logically pressed when the specified modifier keys are
// logically down, and no other modifier keys are logically down.
//
// Either the grab_window is an ancestor of (or is) the focus window, or the
// grab_window is a descendant of the focus window and contains the pointer.
//
// A passive grab on the same key combination does not exist on any ancestor of
// grab_window.
//
// The interpretation of the remaining arguments is as for XGrabKeyboard. The active grab is terminated
// automatically when the logical state of the keyboard has the specified key released (independent of the
// logical state of the modifier keys), at which point a KeyRelease event is reported to the grabbing window.
//
// Note that the logical state of a device (as seen by client applications) may lag the physical state if
// device event processing is frozen.
//
// A modifiers argument of AnyModifier is equivalent to issuing the request for all possible modifier combinations (including the combination of no modifiers). It is not required that all modifiers specified
// have currently assigned KeyCodes. A keycode argument of AnyKey is equivalent to issuing the request for
// all possible KeyCodes. Otherwise, the specified keycode must be in the range specified by min_keycode
// and max_keycode in the connection setup, or a BadValue error results.
//
// If some other client has issued a XGrabKey with the same key combination on the same window, a BadAccess
// error results. When using AnyModifier or AnyKey, the request fails completely, and a BadAccess error
// results (no grabs are established) if there is a conflicting grab for any combination.
//
// May return a Access error if another client has already issued a GrabKey with the same button/key
// combination on the same window.
//
// May return a Window error if the specified Window does not exist.
//
// May return Value errors.
//
2013-08-12 02:43:26 +02:00
// GrabKey sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, KeyboardMode byte) GrabKeyCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie)
return GrabKeyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, KeyboardMode byte) GrabKeyCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie)
return GrabKeyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// grabKeyRequest writes a GrabKey request to a byte slice for transfer.
func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode, KeyboardMode byte) []byte {
2013-08-12 02:43:26 +02:00
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 33 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(GrabWindow))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Modifiers)
b += 2
2013-08-12 02:43:26 +02:00
buf[b] = byte(Key)
b += 1
buf[b] = PointerMode
b += 1
buf[b] = KeyboardMode
b += 1
b += 3 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests.
type GrabKeyboardCookie struct {
*xgb.Cookie
}
// Actively grabs control of the keyboard and generates FocusIn and FocusOut
// events. Further key events are reported only to the grabbing client.
//
// Any active keyboard grab by this client is overridden. If the keyboard is
// actively grabbed by some other client, AlreadyGrabbed is returned. If
// GrabWindow is not viewable, GrabNotViewable is returned. If the keyboard
// is frozen by an active grab of another client, GrabFrozen is returned. If the
// specified Time is earlier than the last-keyboard-grab time or later than the
// current X server time, GrabInvalidTime is returned. Otherwise, the
// last-keyboard-grab time is set to the specified time.
//
// May return a Window error if the specified Window does not exist.
//
// May return Value errors.
//
2013-08-12 02:43:26 +02:00
// 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, KeyboardMode byte) GrabKeyboardCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie)
return GrabKeyboardCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GrabKeyboardUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, KeyboardMode byte) GrabKeyboardCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie)
return GrabKeyboardCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
if buf == nil {
return nil, nil
}
2013-08-12 02:43:26 +02:00
return grabKeyboardReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value.
func grabKeyboardReply(buf []byte) *GrabKeyboardReply {
v := new(GrabKeyboardReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
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
}
// grabKeyboardRequest writes a GrabKeyboard request to a byte slice for transfer.
func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode, KeyboardMode byte) []byte {
2013-08-12 02:43:26 +02:00
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 31 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(GrabWindow))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Time))
b += 4
2013-08-12 02:43:26 +02:00
buf[b] = PointerMode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = KeyboardMode
b += 1
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// GrabPointerCookie is a cookie used only for GrabPointer requests.
type GrabPointerCookie struct {
*xgb.Cookie
}
// Actively grabs control of the pointer. Further pointer events are reported only to the grabbing client. Overrides any active pointer grab by this client.
//
// May return a Window error if the specified Window does not exist.
//
// May return Value errors.
//
2013-08-12 02:43:26 +02:00
// 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, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie)
return GrabPointerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GrabPointerUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie)
return GrabPointerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GrabPointerReply represents the data returned from a GrabPointer request.
type GrabPointerReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2013-08-12 02:43:26 +02:00
Status byte
}
2013-08-12 02:43:26 +02:00
// 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
}
if buf == nil {
return nil, nil
}
2013-08-12 02:43:26 +02:00
return grabPointerReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// grabPointerReply reads a byte slice into a GrabPointerReply value.
func grabPointerReply(buf []byte) *GrabPointerReply {
v := new(GrabPointerReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
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
}
// grabPointerRequest writes a GrabPointer request to a byte slice for transfer.
func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte {
2013-08-12 02:43:26 +02:00
size := 24
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(GrabWindow))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], EventMask)
b += 2
2013-08-12 02:43:26 +02:00
buf[b] = PointerMode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = KeyboardMode
b += 1
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(ConfineTo))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cursor))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Time))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GrabServerCookie is a cookie used only for GrabServer requests.
type GrabServerCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// GrabServer sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func GrabServer(c *xgb.Conn) GrabServerCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(grabServerRequest(c), cookie)
return GrabServerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// GrabServerChecked sends a checked request.
// If an error occurs, it can be retrieved using GrabServerCookie.Check.
2013-08-12 02:43:26 +02:00
func GrabServerChecked(c *xgb.Conn) GrabServerCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(grabServerRequest(c), cookie)
return GrabServerCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook GrabServerCookie) Check() error {
return cook.Cookie.Check()
}
// grabServerRequest writes a GrabServer request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func grabServerRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 36 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// ImageText16Cookie is a cookie used only for ImageText16 requests.
type ImageText16Cookie struct {
*xgb.Cookie
}
// Fills the destination rectangle with the background pixel from Gc, then
// paints the text with the foreground pixel from Gc. The upper-left corner of
// the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
// the height is font-ascent + font-descent. The overall-width, font-ascent and
// font-descent are as returned by QueryTextExtents.
//
// Note that using X core fonts is deprecated (but still supported) in favor of
// client-side rendering using Xft.
//
// May return a Drawable error if the specified Drawable (Window or Pixmap) does not exist.
//
// May return a GContext error if the specified graphics context does not exist.
//
// May return Match errors.
//
2013-08-12 02:43:26 +02:00
// ImageText16 sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, Y int16, String []Char2b) ImageText16Cookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie)
return ImageText16Cookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Y int16, String []Char2b) ImageText16Cookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie)
return ImageText16Cookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ImageText16Cookie) Check() error {
return cook.Cookie.Check()
}
// imageText16Request writes a ImageText16 request to a byte slice for transfer.
func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X, Y int16, String []Char2b) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 77 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(X))
b += 2
xgb.Put16(buf[b:], uint16(Y))
b += 2
b += Char2bListBytes(buf[b:], String)
return buf
}
2013-08-12 02:43:26 +02:00
// ImageText8Cookie is a cookie used only for ImageText8 requests.
type ImageText8Cookie struct {
*xgb.Cookie
}
// Fills the destination rectangle with the background pixel from Gc, then
// paints the text with the foreground pixel from Gc. The upper-left corner of
// the filled rectangle is at [x, y - font-ascent]. The width is overall-width,
// the height is font-ascent + font-descent. The overall-width, font-ascent and
// font-descent are as returned by QueryTextExtents.
//
// Note that using X core fonts is deprecated (but still supported) in favor of
// client-side rendering using Xft.
//
// May return a Drawable error if the specified Drawable (Window or Pixmap) does not exist.
//
// May return a GContext error if the specified graphics context does not exist.
//
// May return Match errors.
//
2013-08-12 02:43:26 +02:00
// ImageText8 sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, Y int16, String string) ImageText8Cookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie)
return ImageText8Cookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Y int16, String string) ImageText8Cookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie)
return ImageText8Cookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook ImageText8Cookie) Check() error {
return cook.Cookie.Check()
}
// imageText8Request writes a ImageText8 request to a byte slice for transfer.
func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X, Y int16, String string) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 76 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = StringLen
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(X))
b += 2
xgb.Put16(buf[b:], uint16(Y))
b += 2
copy(buf[b:], String[:StringLen])
b += int(StringLen)
return buf
}
2013-08-12 02:43:26 +02:00
// InstallColormapCookie is a cookie used only for InstallColormap requests.
type InstallColormapCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// InstallColormap sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(installColormapRequest(c, Cmap), cookie)
return InstallColormapCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// InstallColormapChecked sends a checked request.
// If an error occurs, it can be retrieved using InstallColormapCookie.Check.
2013-08-12 02:43:26 +02:00
func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(installColormapRequest(c, Cmap), cookie)
return InstallColormapCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook InstallColormapCookie) Check() error {
return cook.Cookie.Check()
}
// installColormapRequest writes a InstallColormap request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 81 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// InternAtomCookie is a cookie used only for InternAtom requests.
type InternAtomCookie struct {
*xgb.Cookie
}
// Retrieves the identifier for the atom with the specified
// name. Atoms are used in protocols like EWMH, for example to store window titles
// (_NET_WM_NAME atom) as property of a window.
//
// If OnlyIfExists is 0, the atom will be created if it does not already exist.
// If OnlyIfExists is 1, AtomNone will be returned if the atom does
// not yet exist.
//
// May return a Value error if a value other than 0 or 1 was specified for OnlyIfExists.
//
// May return Alloc errors.
//
2013-08-12 02:43:26 +02:00
// InternAtom sends a checked request.
// If an error occurs, it will be returned with the reply by calling InternAtomCookie.Reply.
2013-08-12 02:43:26 +02:00
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.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
// internAtomRequest writes a InternAtom request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 16 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], NameLen)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
copy(buf[b:], Name[:NameLen])
b += int(NameLen)
return buf
}
2013-08-12 02:43:26 +02:00
// KillClientCookie is a cookie used only for KillClient requests.
type KillClientCookie struct {
*xgb.Cookie
}
// Forces a close down of the client that created the specified Resource.
//
// May return a Value error if the specified Resource does not exist.
//
2013-08-12 02:43:26 +02:00
// KillClient sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(killClientRequest(c, Resource), cookie)
return KillClientCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// KillClientChecked sends a checked request.
// If an error occurs, it can be retrieved using KillClientCookie.Check.
2013-08-12 02:43:26 +02:00
func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(killClientRequest(c, Resource), cookie)
return KillClientCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook KillClientCookie) Check() error {
return cook.Cookie.Check()
}
// killClientRequest writes a KillClient request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func killClientRequest(c *xgb.Conn, Resource uint32) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 113 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], Resource)
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// ListExtensionsCookie is a cookie used only for ListExtensions requests.
type ListExtensionsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ListExtensions sends a checked request.
// If an error occurs, it will be returned with the reply by calling ListExtensionsCookie.Reply.
2013-08-12 02:43:26 +02:00
func ListExtensions(c *xgb.Conn) ListExtensionsCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(listExtensionsRequest(c), cookie)
return ListExtensionsCookie{cookie}
}
// ListExtensionsUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie {
cookie := c.NewCookie(false, true)
c.NewRequest(listExtensionsRequest(c), cookie)
return ListExtensionsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
// listExtensionsRequest writes a ListExtensions request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func listExtensionsRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 99 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// ListFontsCookie is a cookie used only for ListFonts requests.
type ListFontsCookie struct {
*xgb.Cookie
}
// Gets a list of available font names which match the given Pattern.
//
2013-08-12 02:43:26 +02:00
// 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, PatternLen uint16, Pattern string) ListFontsCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, true)
c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie)
return ListFontsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, PatternLen uint16, Pattern string) ListFontsCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, true)
c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie)
return ListFontsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
// The number of font names.
2013-08-12 02:43:26 +02:00
NamesLen uint16
// padding: 22 bytes
Names []Str // size: StrListSize(Names)
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
if buf == nil {
return nil, nil
}
return listFontsReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// listFontsReply reads a byte slice into a ListFontsReply value.
func listFontsReply(buf []byte) *ListFontsReply {
v := new(ListFontsReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.NamesLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 22 // padding
2013-08-12 02:43:26 +02:00
v.Names = make([]Str, v.NamesLen)
b += StrReadList(buf[b:], v.Names)
2013-08-12 02:43:26 +02:00
return v
}
// listFontsRequest writes a ListFonts request to a byte slice for transfer.
func listFontsRequest(c *xgb.Conn, MaxNames, PatternLen uint16, Pattern string) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 49 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], MaxNames)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], PatternLen)
b += 2
2013-08-12 02:43:26 +02:00
copy(buf[b:], Pattern[:PatternLen])
b += int(PatternLen)
return buf
}
2013-08-12 02:43:26 +02:00
// ListFontsWithInfoCookie is a cookie used only for ListFontsWithInfo requests.
type ListFontsWithInfoCookie struct {
*xgb.Cookie
}
// Gets a list of available font names which match the given Pattern.
//
2013-08-12 02:43:26 +02:00
// 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, PatternLen uint16, Pattern string) ListFontsWithInfoCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, true)
c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie)
return ListFontsWithInfoCookie{cookie}
}
// ListFontsWithInfoUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames, PatternLen uint16, Pattern string) ListFontsWithInfoCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, true)
c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie)
return ListFontsWithInfoCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
// The number of matched font names.
NameLen byte
// minimum bounds over all existing char
2013-08-12 02:43:26 +02:00
MinBounds Charinfo
// padding: 4 bytes
// maximum bounds over all existing char
2013-08-12 02:43:26 +02:00
MaxBounds Charinfo
// padding: 4 bytes
// first character
2013-08-12 02:43:26 +02:00
MinCharOrByte2 uint16
// last character
2013-08-12 02:43:26 +02:00
MaxCharOrByte2 uint16
// char to print for undefined character
DefaultChar uint16
// how many properties there are
PropertiesLen uint16
DrawDirection byte
MinByte1 byte
MaxByte1 byte
// flag if all characters have nonzero size
AllCharsExist bool
// baseline to top edge of raster
FontAscent int16
// baseline to bottom edge of raster
FontDescent int16
// An indication of how many more fonts will be returned. This is only a hint and
// may be larger or smaller than the number of fonts actually returned. A zero
// value does not guarantee that no more fonts will be returned.
RepliesHint uint32
Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8))
Name string // size: xgb.Pad((int(NameLen) * 1))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// listFontsWithInfoReply reads a byte slice into a ListFontsWithInfoReply value.
func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply {
v := new(ListFontsWithInfoReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.NameLen = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.MinBounds = Charinfo{}
b += CharinfoRead(buf[b:], &v.MinBounds)
2013-08-12 02:43:26 +02:00
b += 4 // padding
2013-08-12 02:43:26 +02:00
v.MaxBounds = Charinfo{}
b += CharinfoRead(buf[b:], &v.MaxBounds)
b += 4 // padding
v.MinCharOrByte2 = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MaxCharOrByte2 = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.DefaultChar = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.PropertiesLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
v.FontDescent = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.RepliesHint = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.Properties = make([]Fontprop, v.PropertiesLen)
b += FontpropReadList(buf[b:], v.Properties)
2013-08-12 02:43:26 +02:00
{
byteString := make([]byte, v.NameLen)
copy(byteString[:v.NameLen], buf[b:])
v.Name = string(byteString)
b += int(v.NameLen)
2013-08-12 02:43:26 +02:00
}
2013-08-12 02:43:26 +02:00
return v
}
// listFontsWithInfoRequest writes a ListFontsWithInfo request to a byte slice for transfer.
func listFontsWithInfoRequest(c *xgb.Conn, MaxNames, PatternLen uint16, Pattern string) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 50 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], MaxNames)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], PatternLen)
b += 2
2013-08-12 02:43:26 +02:00
copy(buf[b:], Pattern[:PatternLen])
b += int(PatternLen)
return buf
}
2013-08-12 02:43:26 +02:00
// ListHostsCookie is a cookie used only for ListHosts requests.
type ListHostsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ListHosts sends a checked request.
// If an error occurs, it will be returned with the reply by calling ListHostsCookie.Reply.
2013-08-12 02:43:26 +02:00
func ListHosts(c *xgb.Conn) ListHostsCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(listHostsRequest(c), cookie)
return ListHostsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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)
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// listHostsReply reads a byte slice into a ListHostsReply value.
func listHostsReply(buf []byte) *ListHostsReply {
v := new(ListHostsReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.Mode = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.HostsLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 22 // padding
v.Hosts = make([]Host, v.HostsLen)
b += HostReadList(buf[b:], v.Hosts)
return v
}
// listHostsRequest writes a ListHosts request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
// ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests.
type ListInstalledColormapsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ListInstalledColormaps sends a checked request.
// If an error occurs, it will be returned with the reply by calling ListInstalledColormapsCookie.Reply.
2013-08-12 02:43:26 +02:00
func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(listInstalledColormapsRequest(c, Window), cookie)
return ListInstalledColormapsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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))
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.CmapsLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 22 // padding
2013-08-12 02:43:26 +02:00
v.Cmaps = make([]Colormap, v.CmapsLen)
for i := 0; i < int(v.CmapsLen); i++ {
v.Cmaps[i] = Colormap(xgb.Get32(buf[b:]))
b += 4
}
2013-08-12 02:43:26 +02:00
return v
}
// listInstalledColormapsRequest writes a ListInstalledColormaps request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 83 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// ListPropertiesCookie is a cookie used only for ListProperties requests.
type ListPropertiesCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// ListProperties sends a checked request.
// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply.
2013-08-12 02:43:26 +02:00
func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(listPropertiesRequest(c, Window), cookie)
return ListPropertiesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.AtomsLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 22 // padding
2013-08-12 02:43:26 +02:00
v.Atoms = make([]Atom, v.AtomsLen)
for i := 0; i < int(v.AtomsLen); i++ {
v.Atoms[i] = Atom(xgb.Get32(buf[b:]))
b += 4
}
2013-08-12 02:43:26 +02:00
return v
}
// listPropertiesRequest writes a ListProperties request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func listPropertiesRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 21 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// LookupColorCookie is a cookie used only for LookupColor requests.
type LookupColorCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// LookupColor sends a checked request.
// If an error occurs, it will be returned with the reply by calling LookupColorCookie.Reply.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.ExactRed = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ExactGreen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.ExactBlue = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.VisualRed = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.VisualGreen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.VisualBlue = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
return v
}
// lookupColorRequest writes a LookupColor request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 92 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], NameLen)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
copy(buf[b:], Name[:NameLen])
b += int(NameLen)
return buf
}
2013-08-12 02:43:26 +02:00
// MapSubwindowsCookie is a cookie used only for MapSubwindows requests.
type MapSubwindowsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// MapSubwindows sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(mapSubwindowsRequest(c, Window), cookie)
return MapSubwindowsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// MapSubwindowsChecked sends a checked request.
// If an error occurs, it can be retrieved using MapSubwindowsCookie.Check.
2013-08-12 02:43:26 +02:00
func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(mapSubwindowsRequest(c, Window), cookie)
return MapSubwindowsCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook MapSubwindowsCookie) Check() error {
return cook.Cookie.Check()
}
// mapSubwindowsRequest writes a MapSubwindows request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 9 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// MapWindowCookie is a cookie used only for MapWindow requests.
type MapWindowCookie struct {
*xgb.Cookie
}
// Maps the specified window. This means making the window visible (as long as its
// parent is visible).
//
// This MapWindow request will be translated to a MapRequest request if a window
// manager is running. The window manager then decides to either map the window or
// not. Set the override-redirect window attribute to true if you want to bypass
// this mechanism.
//
// If the window manager decides to map the window (or if no window manager is
// running), a MapNotify event is generated.
//
// If the window becomes viewable and no earlier contents for it are remembered,
// the X server tiles the window with its background. If the window's background
// is undefined, the existing screen contents are not altered, and the X server
// generates zero or more Expose events.
//
// If the window type is InputOutput, an Expose event will be generated when the
// window becomes visible. The normal response to an Expose event should be to
// repaint the window.
//
// May return a Match error if the specified window does not exist.
//
2013-08-12 02:43:26 +02:00
// MapWindow sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(mapWindowRequest(c, Window), cookie)
return MapWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// MapWindowChecked sends a checked request.
// If an error occurs, it can be retrieved using MapWindowCookie.Check.
2013-08-12 02:43:26 +02:00
func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(mapWindowRequest(c, Window), cookie)
return MapWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// mapWindowRequest writes a MapWindow request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func mapWindowRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 8 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// NoOperationCookie is a cookie used only for NoOperation requests.
type NoOperationCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// NoOperation sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func NoOperation(c *xgb.Conn) NoOperationCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(noOperationRequest(c), cookie)
return NoOperationCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// NoOperationChecked sends a checked request.
// If an error occurs, it can be retrieved using NoOperationCookie.Check.
2013-08-12 02:43:26 +02:00
func NoOperationChecked(c *xgb.Conn) NoOperationCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(noOperationRequest(c), cookie)
return NoOperationCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook NoOperationCookie) Check() error {
return cook.Cookie.Check()
}
// noOperationRequest writes a NoOperation request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func noOperationRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 127 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// OpenFontCookie is a cookie used only for OpenFont requests.
type OpenFontCookie struct {
*xgb.Cookie
}
// Opens any X core font matching the given Name (for example "-misc-fixed-*").
//
// Note that X core fonts are deprecated (but still supported) in favor of
// client-side rendering using Xft.
//
// May return a Name error if no font matches the given Name.
//
2013-08-12 02:43:26 +02:00
// OpenFont sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie)
return OpenFontCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// OpenFontChecked sends a checked request.
// If an error occurs, it can be retrieved using OpenFontCookie.Check.
2013-08-12 02:43:26 +02:00
func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie)
return OpenFontCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook OpenFontCookie) Check() error {
return cook.Cookie.Check()
}
// openFontRequest writes a OpenFont request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 45 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Fid))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], NameLen)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
copy(buf[b:], Name[:NameLen])
b += int(NameLen)
return buf
}
2013-08-12 02:43:26 +02:00
// PolyArcCookie is a cookie used only for PolyArc requests.
type PolyArcCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// PolyArc sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie)
return PolyArcCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// PolyArcChecked sends a checked request.
// If an error occurs, it can be retrieved using PolyArcCookie.Check.
2013-08-12 02:43:26 +02:00
func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie)
return PolyArcCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook PolyArcCookie) Check() error {
return cook.Cookie.Check()
}
// polyArcRequest writes a PolyArc request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 68 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
b += ArcListBytes(buf[b:], Arcs)
return buf
}
2013-08-12 02:43:26 +02:00
// PolyFillArcCookie is a cookie used only for PolyFillArc requests.
type PolyFillArcCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// PolyFillArc sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie)
return PolyFillArcCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// PolyFillArcChecked sends a checked request.
// If an error occurs, it can be retrieved using PolyFillArcCookie.Check.
2013-08-12 02:43:26 +02:00
func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie)
return PolyFillArcCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook PolyFillArcCookie) Check() error {
return cook.Cookie.Check()
}
// polyFillArcRequest writes a PolyFillArc request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 71 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
b += ArcListBytes(buf[b:], Arcs)
return buf
}
2013-08-12 02:43:26 +02:00
// PolyFillRectangleCookie is a cookie used only for PolyFillRectangle requests.
type PolyFillRectangleCookie struct {
*xgb.Cookie
}
// Fills the specified rectangle(s) in the order listed in the array. For any
// given rectangle, each pixel is not drawn more than once. If rectangles
// intersect, the intersecting pixels are drawn multiple times.
//
// May return a Drawable error if the specified Drawable (Window or Pixmap) does not exist.
//
// May return a GContext error if the specified graphics context does not exist.
//
// May return Match errors.
//
2013-08-12 02:43:26 +02:00
// PolyFillRectangle sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie)
return PolyFillRectangleCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// PolyFillRectangleChecked sends a checked request.
// If an error occurs, it can be retrieved using PolyFillRectangleCookie.Check.
2013-08-12 02:43:26 +02:00
func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie)
return PolyFillRectangleCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook PolyFillRectangleCookie) Check() error {
return cook.Cookie.Check()
}
// polyFillRectangleRequest writes a PolyFillRectangle request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 70 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
b += RectangleListBytes(buf[b:], Rectangles)
return buf
}
2013-08-12 02:43:26 +02:00
// PolyLineCookie is a cookie used only for PolyLine requests.
type PolyLineCookie struct {
*xgb.Cookie
}
// Draws PointsLen-1 lines between each pair of points (point[i], point[i+1])
// in the Points array. The lines are drawn in the order listed in the array.
// They join correctly at all intermediate points, and if the first and last
// points coincide, the first and last lines also join correctly. For any given
// line, a pixel is not drawn more than once. If thin (zero line-width) lines
// intersect, the intersecting pixels are drawn multiple times. If wide lines
// intersect, the intersecting pixels are drawn only once, as though the entire
// request were a single, filled shape.
//
// May return Drawable, GContext, Match, Value errors.
//
2013-08-12 02:43:26 +02:00
// PolyLine sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie)
return PolyLineCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// PolyLineChecked sends a checked request.
// If an error occurs, it can be retrieved using PolyLineCookie.Check.
2013-08-12 02:43:26 +02:00
func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie)
return PolyLineCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook PolyLineCookie) Check() error {
return cook.Cookie.Check()
}
// polyLineRequest writes a PolyLine request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 65 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = CoordinateMode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
b += PointListBytes(buf[b:], Points)
return buf
}
2013-08-12 02:43:26 +02:00
// PolyPointCookie is a cookie used only for PolyPoint requests.
type PolyPointCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// PolyPoint sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie)
return PolyPointCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// PolyPointChecked sends a checked request.
// If an error occurs, it can be retrieved using PolyPointCookie.Check.
2013-08-12 02:43:26 +02:00
func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie)
return PolyPointCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook PolyPointCookie) Check() error {
return cook.Cookie.Check()
}
// polyPointRequest writes a PolyPoint request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 64 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = CoordinateMode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
b += PointListBytes(buf[b:], Points)
return buf
}
2013-08-12 02:43:26 +02:00
// PolyRectangleCookie is a cookie used only for PolyRectangle requests.
type PolyRectangleCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// PolyRectangle sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie)
return PolyRectangleCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// PolyRectangleChecked sends a checked request.
// If an error occurs, it can be retrieved using PolyRectangleCookie.Check.
2013-08-12 02:43:26 +02:00
func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie)
return PolyRectangleCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook PolyRectangleCookie) Check() error {
return cook.Cookie.Check()
}
// polyRectangleRequest writes a PolyRectangle request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 67 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
b += RectangleListBytes(buf[b:], Rectangles)
return buf
}
2013-08-12 02:43:26 +02:00
// PolySegmentCookie is a cookie used only for PolySegment requests.
type PolySegmentCookie struct {
*xgb.Cookie
}
// Draws multiple, unconnected lines. For each segment, a line is drawn between
// (x1, y1) and (x2, y2). The lines are drawn in the order listed in the array of
// Segment structures and does not perform joining at coincident
// endpoints. For any given line, a pixel is not drawn more than once. If lines
// intersect, the intersecting pixels are drawn multiple times.
//
// May return a Drawable error if the specified Drawable does not exist.
//
// May return a GContext error if the specified Gc does not exist.
//
// May return Match errors.
//
2013-08-12 02:43:26 +02:00
// PolySegment sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie)
return PolySegmentCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// PolySegmentChecked sends a checked request.
// If an error occurs, it can be retrieved using PolySegmentCookie.Check.
2013-08-12 02:43:26 +02:00
func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie)
return PolySegmentCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook PolySegmentCookie) Check() error {
return cook.Cookie.Check()
}
// polySegmentRequest writes a PolySegment request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 66 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
b += SegmentListBytes(buf[b:], Segments)
return buf
}
2013-08-12 02:43:26 +02:00
// PolyText16Cookie is a cookie used only for PolyText16 requests.
type PolyText16Cookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// PolyText16 sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, Y int16, Items []byte) PolyText16Cookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie)
return PolyText16Cookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Y int16, Items []byte) PolyText16Cookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie)
return PolyText16Cookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// polyText16Request writes a PolyText16 request to a byte slice for transfer.
func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X, Y int16, Items []byte) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((16 + xgb.Pad((len(Items) * 1))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 75 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(X))
b += 2
xgb.Put16(buf[b:], uint16(Y))
b += 2
copy(buf[b:], Items[:len(Items)])
b += int(len(Items))
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// PolyText8Cookie is a cookie used only for PolyText8 requests.
type PolyText8Cookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// PolyText8 sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, Y int16, Items []byte) PolyText8Cookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie)
return PolyText8Cookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, Y int16, Items []byte) PolyText8Cookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie)
return PolyText8Cookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// polyText8Request writes a PolyText8 request to a byte slice for transfer.
func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X, Y int16, Items []byte) []byte {
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(Y))
b += 2
2013-08-12 02:43:26 +02:00
copy(buf[b:], Items[:len(Items)])
b += int(len(Items))
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// PutImageCookie is a cookie used only for PutImage requests.
type PutImageCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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, Height uint16, DstX, DstY int16, LeftPad, Depth byte, Data []byte) PutImageCookie {
2013-08-12 02:43:26 +02:00
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, Height uint16, DstX, DstY int16, LeftPad, Depth byte, Data []byte) PutImageCookie {
2013-08-12 02:43:26 +02:00
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()
}
// putImageRequest writes a PutImage request to a byte slice for transfer.
func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width, Height uint16, DstX, DstY int16, LeftPad, Depth byte, Data []byte) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((24 + xgb.Pad((len(Data) * 1))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 72 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Format
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
xgb.Put16(buf[b:], Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Height)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(DstX))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(DstY))
b += 2
buf[b] = LeftPad
b += 1
buf[b] = Depth
b += 1
b += 2 // padding
2013-08-12 02:43:26 +02:00
copy(buf[b:], Data[:len(Data)])
b += int(len(Data))
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// QueryBestSizeCookie is a cookie used only for QueryBestSize requests.
type QueryBestSizeCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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, Height uint16) QueryBestSizeCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie)
return QueryBestSizeCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryBestSizeUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, Height uint16) QueryBestSizeCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie)
return QueryBestSizeCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryBestSizeReply represents the data returned from a QueryBestSize request.
type QueryBestSizeReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Width uint16
Height uint16
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return queryBestSizeReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Width = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Height = xgb.Get16(buf[b:])
b += 2
return v
}
// queryBestSizeRequest writes a QueryBestSize request to a byte slice for transfer.
func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width, Height uint16) []byte {
2013-08-12 02:43:26 +02:00
size := 12
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 97 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Class
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Width)
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Height)
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// QueryColorsCookie is a cookie used only for QueryColors requests.
type QueryColorsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// QueryColors sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryColorsCookie.Reply.
2013-08-12 02:43:26 +02:00
func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie)
return QueryColorsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryColorsUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie)
return QueryColorsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryColorsReply represents the data returned from a QueryColors request.
type QueryColorsReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
ColorsLen uint16
// padding: 22 bytes
Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8))
}
2013-08-12 02:43:26 +02:00
// 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
}
if buf == nil {
return nil, nil
}
2013-08-12 02:43:26 +02:00
return queryColorsReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.ColorsLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 22 // padding
2013-08-12 02:43:26 +02:00
v.Colors = make([]Rgb, v.ColorsLen)
b += RgbReadList(buf[b:], v.Colors)
return v
}
// queryColorsRequest writes a QueryColors request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 91 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
for i := 0; i < int(len(Pixels)); i++ {
xgb.Put32(buf[b:], Pixels[i])
b += 4
}
return buf
}
2013-08-12 02:43:26 +02:00
// QueryExtensionCookie is a cookie used only for QueryExtension requests.
type QueryExtensionCookie struct {
*xgb.Cookie
}
// Determines if the specified extension is present on this X11 server.
//
// Every extension has a unique MajorOpcode to identify requests, the minor
// opcodes and request formats are extension-specific. If the extension provides
// events and errors, the FirstEvent and FirstError fields in the reply are
// set accordingly.
//
// There should rarely be a need to use this request directly, XCB provides the
// GetExtensionData function instead.
//
2013-08-12 02:43:26 +02:00
// QueryExtension sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply.
2013-08-12 02:43:26 +02:00
func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie)
return QueryExtensionCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryExtensionUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie)
return QueryExtensionCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryExtensionReply represents the data returned from a QueryExtension request.
type QueryExtensionReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
// Whether the extension is present on this X11 server.
Present bool
// The major opcode for requests.
2013-08-12 02:43:26 +02:00
MajorOpcode byte
// The first event code, if any.
FirstEvent byte
// The first error code, if any.
FirstError byte
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return queryExtensionReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
if buf[b] == 1 {
v.Present = true
} else {
v.Present = false
}
b += 1
2013-08-12 02:43:26 +02:00
v.MajorOpcode = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.FirstEvent = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.FirstError = buf[b]
b += 1
return v
}
// queryExtensionRequest writes a QueryExtension request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 98 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], NameLen)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
copy(buf[b:], Name[:NameLen])
b += int(NameLen)
return buf
}
2013-08-12 02:43:26 +02:00
// QueryFontCookie is a cookie used only for QueryFont requests.
type QueryFontCookie struct {
*xgb.Cookie
}
// Queries information associated with the font.
//
2013-08-12 02:43:26 +02:00
// QueryFont sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryFontCookie.Reply.
2013-08-12 02:43:26 +02:00
func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(queryFontRequest(c, Font), cookie)
return QueryFontCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// 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
// minimum bounds over all existing char
2013-08-12 02:43:26 +02:00
MinBounds Charinfo
// padding: 4 bytes
// maximum bounds over all existing char
2013-08-12 02:43:26 +02:00
MaxBounds Charinfo
// padding: 4 bytes
// first character
2013-08-12 02:43:26 +02:00
MinCharOrByte2 uint16
// last character
2013-08-12 02:43:26 +02:00
MaxCharOrByte2 uint16
// char to print for undefined character
DefaultChar uint16
// how many properties there are
PropertiesLen uint16
DrawDirection byte
MinByte1 byte
MaxByte1 byte
// flag if all characters have nonzero size
AllCharsExist bool
// baseline to top edge of raster
FontAscent int16
// baseline to bottom edge of raster
FontDescent int16
CharInfosLen uint32
Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8))
CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12))
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.MinBounds = Charinfo{}
b += CharinfoRead(buf[b:], &v.MinBounds)
b += 4 // padding
v.MaxBounds = Charinfo{}
b += CharinfoRead(buf[b:], &v.MaxBounds)
b += 4 // padding
2013-08-12 02:43:26 +02:00
v.MinCharOrByte2 = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.MaxCharOrByte2 = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.DefaultChar = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.PropertiesLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.DrawDirection = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.MinByte1 = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.MaxByte1 = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
if buf[b] == 1 {
v.AllCharsExist = true
} else {
v.AllCharsExist = false
}
b += 1
2013-08-12 02:43:26 +02:00
v.FontAscent = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.FontDescent = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.CharInfosLen = xgb.Get32(buf[b:])
b += 4
2013-08-12 02:43:26 +02:00
v.Properties = make([]Fontprop, v.PropertiesLen)
b += FontpropReadList(buf[b:], v.Properties)
2013-08-12 02:43:26 +02:00
v.CharInfos = make([]Charinfo, v.CharInfosLen)
b += CharinfoReadList(buf[b:], v.CharInfos)
2013-08-12 02:43:26 +02:00
return v
}
// queryFontRequest writes a QueryFont request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func queryFontRequest(c *xgb.Conn, Font Fontable) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 47 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Font))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// QueryKeymapCookie is a cookie used only for QueryKeymap requests.
type QueryKeymapCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// QueryKeymap sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryKeymapCookie.Reply.
2013-08-12 02:43:26 +02:00
func QueryKeymap(c *xgb.Conn) QueryKeymapCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryKeymapRequest(c), cookie)
return QueryKeymapCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryKeymapUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryKeymapRequest(c), cookie)
return QueryKeymapCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryKeymapReply represents the data returned from a QueryKeymap request.
type QueryKeymapReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Keys []byte // size: 32
}
2013-08-12 02:43:26 +02:00
// 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
}
if buf == nil {
return nil, nil
}
2013-08-12 02:43:26 +02:00
return queryKeymapReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// 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
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.Keys = make([]byte, 32)
copy(v.Keys[:32], buf[b:])
b += int(32)
return v
}
// queryKeymapRequest writes a QueryKeymap request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func queryKeymapRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 44 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// QueryPointerCookie is a cookie used only for QueryPointer requests.
type QueryPointerCookie struct {
*xgb.Cookie
}
// Gets the root window the pointer is logically on and the pointer coordinates
// relative to the root window's origin.
//
// May return a Window error if the specified Window does not exist.
//
2013-08-12 02:43:26 +02:00
// QueryPointer sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryPointerCookie.Reply.
2013-08-12 02:43:26 +02:00
func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryPointerRequest(c, Window), cookie)
return QueryPointerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// QueryPointerUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(queryPointerRequest(c, Window), cookie)
return QueryPointerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
// If SameScreen is False, then the pointer is not on the same screen as the
// argument window, Child is None, and WinX and WinY are zero. If
// SameScreen is True, then WinX and WinY are the pointer coordinates
// relative to the argument window's origin, and child is the child containing the
// pointer, if any.
2013-08-12 02:43:26 +02:00
SameScreen bool
// The root window the pointer is logically on.
Root Window
// The child window containing the pointer, if any, if SameScreen is true. If
// SameScreen is false, None is returned.
Child Window
// The pointer X position, relative to Root.
RootX int16
// The pointer Y position, relative to Root.
RootY int16
// The pointer X coordinate, relative to Child, if SameScreen is true. Zero
// otherwise.
WinX int16
// The pointer Y coordinate, relative to Child, if SameScreen is true. Zero
// otherwise.
WinY int16
// The current logical state of the modifier keys and the buttons. Note that the
// logical state of a device (as seen by means of the protocol) may lag the
// physical state if device event processing is frozen.
Mask uint16
2013-08-12 02:43:26 +02:00
// padding: 2 bytes
}
2013-08-12 02:43:26 +02:00
// 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
}
if buf == nil {
return nil, nil
}
2013-08-12 02:43:26 +02:00
return queryPointerReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// queryPointerReply reads a byte slice into a QueryPointerReply value.
func queryPointerReply(buf []byte) *QueryPointerReply {
v := new(QueryPointerReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
v.Root = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Child = Window(xgb.Get32(buf[b:]))
b += 4
v.RootX = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.RootY = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.WinX = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.WinY = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.Mask = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
return v
}
// queryPointerRequest writes a QueryPointer request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func queryPointerRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 38 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests.
type QueryTextExtentsCookie struct {
*xgb.Cookie
}
// Query text extents from the X11 server. This request returns the bounding box
// of the specified 16-bit character string in the specified Font or the font
// contained in the specified graphics context.
//
// FontAscent is set to the maximum of the ascent metrics of all characters in
// the string. FontDescent is set to the maximum of the descent metrics.
// OverallWidth is set to the sum of the character-width metrics of all
// characters in the string. For each character in the string, let W be the sum of
// the character-width metrics of all characters preceding it in the string. Let L
// be the left-side-bearing metric of the character plus W. Let R be the
// right-side-bearing metric of the character plus W. The lbearing member is set
// to the minimum L of all characters in the string. The rbearing member is set to
// the maximum R.
//
// For fonts defined with linear indexing rather than 2-byte matrix indexing, each
// Char2b structure is interpreted as a 16-bit number with byte1 as the
// most significant byte. If the font has no defined default character, undefined
// characters in the string are taken to have all zero metrics.
//
// Characters with all zero metrics are ignored. If the font has no defined
// default_char, the undefined characters in the string are also ignored.
//
// May return a Font error if the specified Font does not exist.
//
// May return a GContext error if the specified graphics context does not exist.
//
2013-08-12 02:43:26 +02:00
// QueryTextExtents sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryTextExtentsCookie.Reply.
2013-08-12 02:43:26 +02:00
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.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value.
func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply {
v := new(QueryTextExtentsReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
v.DrawDirection = buf[b]
b += 1
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.FontAscent = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.FontDescent = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.OverallAscent = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.OverallDescent = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.OverallWidth = int32(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.OverallLeft = int32(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.OverallRight = int32(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
return v
}
// queryTextExtentsRequest writes a QueryTextExtents request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 48 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = byte((int(StringLen) & 1))
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Font))
b += 4
2013-08-12 02:43:26 +02:00
b += Char2bListBytes(buf[b:], String)
2013-08-12 02:43:26 +02:00
// skip writing local field: StringLen (2) :: uint16
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// QueryTreeCookie is a cookie used only for QueryTree requests.
type QueryTreeCookie struct {
*xgb.Cookie
}
// Gets the root window ID, parent window ID and list of children windows for the
// specified Window. The children are listed in bottom-to-top stacking order.
//
2013-08-12 02:43:26 +02:00
// QueryTree sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryTreeCookie.Reply.
2013-08-12 02:43:26 +02:00
func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie {
cookie := c.NewCookie(true, true)
c.NewRequest(queryTreeRequest(c, Window), cookie)
return QueryTreeCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
// The root window of Window.
Root Window
// The parent window of Window.
Parent Window
// The number of child windows.
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
v.Sequence = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v.Root = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.Parent = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.ChildrenLen = xgb.Get16(buf[b:])
b += 2
2013-08-12 02:43:26 +02:00
b += 14 // padding
2013-08-12 02:43:26 +02:00
v.Children = make([]Window, v.ChildrenLen)
for i := 0; i < int(v.ChildrenLen); i++ {
v.Children[i] = Window(xgb.Get32(buf[b:]))
b += 4
}
2013-08-12 02:43:26 +02:00
return v
}
// queryTreeRequest writes a QueryTree request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func queryTreeRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 15 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2012-05-11 05:57:34 +02:00
// RecolorCursorCookie is a cookie used only for RecolorCursor requests.
type RecolorCursorCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// RecolorCursor sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue uint16) RecolorCursorCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie)
return RecolorCursorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// RecolorCursorChecked sends a checked request.
// If an error occurs, it can be retrieved using RecolorCursorCookie.Check.
func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue uint16) RecolorCursorCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie)
return RecolorCursorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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 RecolorCursorCookie) Check() error {
return cook.Cookie.Check()
}
// recolorCursorRequest writes a RecolorCursor request to a byte slice for transfer.
func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue uint16) []byte {
size := 20
b := 0
buf := make([]byte, size)
buf[b] = 96 // 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(Cursor))
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
return buf
}
2013-08-12 02:43:26 +02:00
// ReparentWindowCookie is a cookie used only for ReparentWindow requests.
type ReparentWindowCookie struct {
*xgb.Cookie
}
// Makes the specified window a child of the specified parent window. If the
// window is mapped, it will automatically be unmapped before reparenting and
// re-mapped after reparenting. The window is placed in the stacking order on top
// with respect to sibling windows.
//
// After reparenting, a ReparentNotify event is generated.
//
// May return a Match error if the new parent window is not on the same screen as the old parent window.
//
// The new parent window is the specified window or an inferior of the specified window.
//
// The new parent is InputOnly and the window is not.
//
// The specified window has a ParentRelative background and the new parent window is not the same depth as the specified window.
//
// May return a Window error if the specified window does not exist.
//
2013-08-12 02:43:26 +02:00
// ReparentWindow sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ReparentWindow(c *xgb.Conn, Window, Parent Window, X, Y int16) ReparentWindowCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(false, false)
c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie)
return ReparentWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// ReparentWindowChecked sends a checked request.
// If an error occurs, it can be retrieved using ReparentWindowCookie.Check.
func ReparentWindowChecked(c *xgb.Conn, Window, Parent Window, X, Y int16) ReparentWindowCookie {
2013-08-12 02:43:26 +02:00
cookie := c.NewCookie(true, false)
c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie)
return ReparentWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// reparentWindowRequest writes a ReparentWindow request to a byte slice for transfer.
func reparentWindowRequest(c *xgb.Conn, Window, Parent Window, X, Y int16) []byte {
2013-08-12 02:43:26 +02:00
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 7 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Parent))
b += 4
xgb.Put16(buf[b:], uint16(X))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(Y))
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// RotatePropertiesCookie is a cookie used only for RotateProperties requests.
type RotatePropertiesCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// RotateProperties sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// RotatePropertiesChecked sends a checked request.
// If an error occurs, it can be retrieved using RotatePropertiesCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// rotatePropertiesRequest writes a RotateProperties request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
2013-08-12 02:43:26 +02:00
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
}
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// SendEventCookie is a cookie used only for SendEvent requests.
type SendEventCookie struct {
*xgb.Cookie
}
// Identifies the Destination window, determines which clients should receive
// the specified event and ignores any active grabs.
//
// The Event must be one of the core events or an event defined by an extension,
// so that the X server can correctly byte-swap the contents as necessary. The
// contents of Event are otherwise unaltered and unchecked except for the
// SendEvent field which is forced to 'true'.
//
// May return a Value error if the given Event is neither a core event nor an event defined by an extension.
//
// May return a Window error if the specified Destination window does not exist.
//
2013-08-12 02:43:26 +02:00
// 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.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// sendEventRequest writes a SendEvent request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte {
size := 44
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 25 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Destination))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], EventMask)
b += 4
2013-08-12 02:43:26 +02:00
copy(buf[b:], Event[:32])
b += int(32)
return buf
}
2013-08-12 02:43:26 +02:00
// SetAccessControlCookie is a cookie used only for SetAccessControl requests.
type SetAccessControlCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// SetAccessControl sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(setAccessControlRequest(c, Mode), cookie)
return SetAccessControlCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// SetAccessControlChecked sends a checked request.
// If an error occurs, it can be retrieved using SetAccessControlCookie.Check.
2013-08-12 02:43:26 +02:00
func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(setAccessControlRequest(c, Mode), cookie)
return SetAccessControlCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// setAccessControlRequest writes a SetAccessControl request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 111 // request opcode
b += 1
buf[b] = Mode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests.
type SetClipRectanglesCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// SetClipRectangles sends an unchecked request.
2012-05-11 05:57:34 +02:00
// 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, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie)
return SetClipRectanglesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie)
return SetClipRectanglesCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook SetClipRectanglesCookie) Check() error {
return cook.Cookie.Check()
}
// setClipRectanglesRequest writes a SetClipRectangles request to a byte slice for transfer.
func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin, ClipYOrigin int16, Rectangles []Rectangle) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 59 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Ordering
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(ClipXOrigin))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(ClipYOrigin))
b += 2
2013-08-12 02:43:26 +02:00
b += RectangleListBytes(buf[b:], Rectangles)
return buf
}
2013-08-12 02:43:26 +02:00
// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests.
type SetCloseDownModeCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// SetCloseDownMode sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(setCloseDownModeRequest(c, Mode), cookie)
return SetCloseDownModeCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// SetCloseDownModeChecked sends a checked request.
// If an error occurs, it can be retrieved using SetCloseDownModeCookie.Check.
2013-08-12 02:43:26 +02:00
func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(setCloseDownModeRequest(c, Mode), cookie)
return SetCloseDownModeCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// setCloseDownModeRequest writes a SetCloseDownMode request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 112 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Mode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// SetDashesCookie is a cookie used only for SetDashes requests.
type SetDashesCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// SetDashes sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset, DashesLen uint16, Dashes []byte) SetDashesCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie)
return SetDashesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// SetDashesChecked sends a checked request.
// If an error occurs, it can be retrieved using SetDashesCookie.Check.
func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset, DashesLen uint16, Dashes []byte) SetDashesCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie)
return SetDashesCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook SetDashesCookie) Check() error {
return cook.Cookie.Check()
}
// setDashesRequest writes a SetDashes request to a byte slice for transfer.
func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset, DashesLen uint16, Dashes []byte) []byte {
2013-08-12 02:43:26 +02:00
size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1))))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 58 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Gc))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], DashOffset)
b += 2
xgb.Put16(buf[b:], DashesLen)
b += 2
copy(buf[b:], Dashes[:DashesLen])
b += int(DashesLen)
return buf
}
2013-08-12 02:43:26 +02:00
// SetFontPathCookie is a cookie used only for SetFontPath requests.
type SetFontPathCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// SetFontPath sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// SetFontPathChecked sends a checked request.
// If an error occurs, it can be retrieved using SetFontPathCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// setFontPathRequest writes a SetFontPath request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte {
size := xgb.Pad((8 + StrListSize(Font)))
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 51 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], FontQty)
b += 2
b += 2 // padding
2013-08-12 02:43:26 +02:00
b += StrListBytes(buf[b:], Font)
return buf
}
2013-08-12 02:43:26 +02:00
// SetInputFocusCookie is a cookie used only for SetInputFocus requests.
type SetInputFocusCookie struct {
*xgb.Cookie
}
// Changes the input focus and the last-focus-change time. If the specified Time
// is earlier than the current last-focus-change time, the request is ignored (to
// avoid race conditions when running X over the network).
//
// A FocusIn and FocusOut event is generated when focus is changed.
//
// May return a Match error if the specified Focus window is not viewable.
//
// May return a Window error if the specified Focus window does not exist.
//
// May return Value errors.
//
2013-08-12 02:43:26 +02:00
// SetInputFocus sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie)
return SetInputFocusCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// SetInputFocusChecked sends a checked request.
// If an error occurs, it can be retrieved using SetInputFocusCookie.Check.
2013-08-12 02:43:26 +02:00
func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie)
return SetInputFocusCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook SetInputFocusCookie) Check() error {
return cook.Cookie.Check()
}
// setInputFocusRequest writes a SetInputFocus request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte {
size := 12
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 42 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = RevertTo
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Focus))
b += 4
xgb.Put32(buf[b:], uint32(Time))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests.
type SetModifierMappingCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// SetModifierMapping sends a checked request.
// If an error occurs, it will be returned with the reply by calling SetModifierMappingCookie.Reply.
2013-08-12 02:43:26 +02:00
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.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
// setModifierMappingRequest writes a SetModifierMapping request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 118 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = KeycodesPerModifier
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ {
buf[b] = byte(Keycodes[i])
b += 1
}
return buf
}
2013-08-12 02:43:26 +02:00
// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests.
type SetPointerMappingCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// SetPointerMapping sends a checked request.
// If an error occurs, it will be returned with the reply by calling SetPointerMappingCookie.Reply.
2013-08-12 02:43:26 +02:00
func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie)
return SetPointerMappingCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// SetPointerMappingUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie)
return SetPointerMappingCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// SetPointerMappingReply represents the data returned from a SetPointerMapping request.
type SetPointerMappingReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2013-08-12 02:43:26 +02:00
Status byte
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
return setPointerMappingReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// setPointerMappingReply reads a byte slice into a SetPointerMappingReply value.
func setPointerMappingReply(buf []byte) *SetPointerMappingReply {
v := new(SetPointerMappingReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
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
}
// setPointerMappingRequest writes a SetPointerMapping request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 116 // request opcode
b += 1
buf[b] = MapLen
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
copy(buf[b:], Map[:MapLen])
b += int(MapLen)
2013-08-12 02:43:26 +02:00
return buf
}
2012-05-11 05:57:34 +02:00
// SetScreenSaverCookie is a cookie used only for SetScreenSaver requests.
type SetScreenSaverCookie struct {
*xgb.Cookie
}
2012-05-11 05:57:34 +02:00
// SetScreenSaver sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func SetScreenSaver(c *xgb.Conn, Timeout, Interval int16, PreferBlanking, AllowExposures byte) SetScreenSaverCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie)
return SetScreenSaverCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// SetScreenSaverChecked sends a checked request.
// If an error occurs, it can be retrieved using SetScreenSaverCookie.Check.
func SetScreenSaverChecked(c *xgb.Conn, Timeout, Interval int16, PreferBlanking, AllowExposures byte) SetScreenSaverCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie)
return SetScreenSaverCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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 SetScreenSaverCookie) Check() error {
return cook.Cookie.Check()
}
// setScreenSaverRequest writes a SetScreenSaver request to a byte slice for transfer.
func setScreenSaverRequest(c *xgb.Conn, Timeout, Interval int16, PreferBlanking, AllowExposures byte) []byte {
size := 12
b := 0
buf := make([]byte, size)
buf[b] = 107 // request opcode
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:], uint16(Timeout))
b += 2
xgb.Put16(buf[b:], uint16(Interval))
b += 2
buf[b] = PreferBlanking
b += 1
buf[b] = AllowExposures
b += 1
return buf
}
2013-08-12 02:43:26 +02:00
// SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests.
type SetSelectionOwnerCookie struct {
*xgb.Cookie
}
// Makes Window the owner of the selection Selection and updates the
// last-change time of the specified selection.
//
// May return a Atom error if selection does not refer to a valid atom.
//
2013-08-12 02:43:26 +02:00
// SetSelectionOwner sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// SetSelectionOwnerChecked sends a checked request.
// If an error occurs, it can be retrieved using SetSelectionOwnerCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// setSelectionOwnerRequest writes a SetSelectionOwner request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Owner))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Selection))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Time))
b += 4
2013-08-12 02:43:26 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// StoreColorsCookie is a cookie used only for StoreColors requests.
type StoreColorsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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}
}
2013-08-12 02:43:26 +02:00
// StoreColorsChecked sends a checked request.
// If an error occurs, it can be retrieved using StoreColorsCookie.Check.
2013-08-12 02:43:26 +02:00
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}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// storeColorsRequest writes a StoreColors request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 89 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
b += ColoritemListBytes(buf[b:], Items)
return buf
}
2013-08-12 02:43:26 +02:00
// StoreNamedColorCookie is a cookie used only for StoreNamedColor requests.
type StoreNamedColorCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// StoreNamedColor sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie)
return StoreNamedColorCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// StoreNamedColorChecked sends a checked request.
// If an error occurs, it can be retrieved using StoreNamedColorCookie.Check.
2013-08-12 02:43:26 +02:00
func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie)
return StoreNamedColorCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook StoreNamedColorCookie) Check() error {
return cook.Cookie.Check()
}
// storeNamedColorRequest writes a StoreNamedColor request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
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)
2013-08-12 02:43:26 +02:00
buf[b] = 90 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Flags
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], Pixel)
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], NameLen)
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
copy(buf[b:], Name[:NameLen])
b += int(NameLen)
return buf
}
2013-08-12 02:43:26 +02:00
// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests.
type TranslateCoordinatesCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// 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, DstWindow Window, SrcX, SrcY int16) TranslateCoordinatesCookie {
cookie := c.NewCookie(true, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie)
return TranslateCoordinatesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// TranslateCoordinatesUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow, DstWindow Window, SrcX, SrcY int16) TranslateCoordinatesCookie {
cookie := c.NewCookie(false, true)
2013-08-12 02:43:26 +02:00
c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie)
return TranslateCoordinatesCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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
}
2013-08-12 02:43:26 +02:00
// 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
}
if buf == nil {
return nil, nil
}
2013-08-12 02:43:26 +02:00
return translateCoordinatesReply(buf), nil
}
2013-08-12 02:43:26 +02:00
// translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value.
func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply {
v := new(TranslateCoordinatesReply)
b := 1 // skip reply determinant
2013-08-12 02:43:26 +02:00
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
2013-08-12 02:43:26 +02:00
v.Child = Window(xgb.Get32(buf[b:]))
b += 4
2013-08-12 02:43:26 +02:00
v.DstX = int16(xgb.Get16(buf[b:]))
b += 2
2013-08-12 02:43:26 +02:00
v.DstY = int16(xgb.Get16(buf[b:]))
b += 2
return v
}
// translateCoordinatesRequest writes a TranslateCoordinates request to a byte slice for transfer.
func translateCoordinatesRequest(c *xgb.Conn, SrcWindow, DstWindow Window, SrcX, SrcY int16) []byte {
2013-08-12 02:43:26 +02:00
size := 16
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 40 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(SrcWindow))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(DstWindow))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(SrcX))
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], uint16(SrcY))
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// UngrabButtonCookie is a cookie used only for UngrabButton requests.
type UngrabButtonCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// UngrabButton sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie)
return UngrabButtonCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// UngrabButtonChecked sends a checked request.
// If an error occurs, it can be retrieved using UngrabButtonCookie.Check.
2013-08-12 02:43:26 +02:00
func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie)
return UngrabButtonCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook UngrabButtonCookie) Check() error {
return cook.Cookie.Check()
}
// ungrabButtonRequest writes a UngrabButton request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte {
size := 12
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 29 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = Button
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(GrabWindow))
b += 4
xgb.Put16(buf[b:], Modifiers)
b += 2
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// UngrabKeyCookie is a cookie used only for UngrabKey requests.
type UngrabKeyCookie struct {
*xgb.Cookie
}
// Releases the key combination on GrabWindow if you grabbed it using
// GrabKey before.
//
// May return a Window error if the specified GrabWindow does not exist.
//
// May return Value errors.
//
2013-08-12 02:43:26 +02:00
// UngrabKey sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie)
return UngrabKeyCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// UngrabKeyChecked sends a checked request.
// If an error occurs, it can be retrieved using UngrabKeyCookie.Check.
2013-08-12 02:43:26 +02:00
func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie)
return UngrabKeyCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook UngrabKeyCookie) Check() error {
return cook.Cookie.Check()
}
// ungrabKeyRequest writes a UngrabKey request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte {
size := 12
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 34 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
buf[b] = byte(Key)
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(GrabWindow))
b += 4
2013-08-12 02:43:26 +02:00
xgb.Put16(buf[b:], Modifiers)
b += 2
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests.
type UngrabKeyboardCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// UngrabKeyboard sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(ungrabKeyboardRequest(c, Time), cookie)
return UngrabKeyboardCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// UngrabKeyboardChecked sends a checked request.
// If an error occurs, it can be retrieved using UngrabKeyboardCookie.Check.
2013-08-12 02:43:26 +02:00
func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(ungrabKeyboardRequest(c, Time), cookie)
return UngrabKeyboardCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook UngrabKeyboardCookie) Check() error {
return cook.Cookie.Check()
}
// ungrabKeyboardRequest writes a UngrabKeyboard request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 32 // request opcode
b += 1
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Time))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// UngrabPointerCookie is a cookie used only for UngrabPointer requests.
type UngrabPointerCookie struct {
*xgb.Cookie
}
// Releases the pointer and any queued events if you actively grabbed the pointer
// before using GrabPointer, GrabButton or within a normal button
// press.
//
// EnterNotify and LeaveNotify events are generated.
//
2013-08-12 02:43:26 +02:00
// UngrabPointer sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(ungrabPointerRequest(c, Time), cookie)
return UngrabPointerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// UngrabPointerChecked sends a checked request.
// If an error occurs, it can be retrieved using UngrabPointerCookie.Check.
2013-08-12 02:43:26 +02:00
func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(ungrabPointerRequest(c, Time), cookie)
return UngrabPointerCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook UngrabPointerCookie) Check() error {
return cook.Cookie.Check()
}
// ungrabPointerRequest writes a UngrabPointer request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 27 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Time))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// UngrabServerCookie is a cookie used only for UngrabServer requests.
type UngrabServerCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// UngrabServer sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func UngrabServer(c *xgb.Conn) UngrabServerCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(ungrabServerRequest(c), cookie)
return UngrabServerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// UngrabServerChecked sends a checked request.
// If an error occurs, it can be retrieved using UngrabServerCookie.Check.
2013-08-12 02:43:26 +02:00
func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(ungrabServerRequest(c), cookie)
return UngrabServerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// ungrabServerRequest writes a UngrabServer request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func ungrabServerRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 37 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// UninstallColormapCookie is a cookie used only for UninstallColormap requests.
type UninstallColormapCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// UninstallColormap sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(uninstallColormapRequest(c, Cmap), cookie)
return UninstallColormapCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// UninstallColormapChecked sends a checked request.
// If an error occurs, it can be retrieved using UninstallColormapCookie.Check.
2013-08-12 02:43:26 +02:00
func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(uninstallColormapRequest(c, Cmap), cookie)
return UninstallColormapCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// uninstallColormapRequest writes a UninstallColormap request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 82 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Cmap))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests.
type UnmapSubwindowsCookie struct {
*xgb.Cookie
}
2013-08-12 02:43:26 +02:00
// UnmapSubwindows sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(unmapSubwindowsRequest(c, Window), cookie)
return UnmapSubwindowsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// UnmapSubwindowsChecked sends a checked request.
// If an error occurs, it can be retrieved using UnmapSubwindowsCookie.Check.
2013-08-12 02:43:26 +02:00
func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(unmapSubwindowsRequest(c, Window), cookie)
return UnmapSubwindowsCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// unmapSubwindowsRequest writes a UnmapSubwindows request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 11 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// UnmapWindowCookie is a cookie used only for UnmapWindow requests.
type UnmapWindowCookie struct {
*xgb.Cookie
}
// Unmaps the specified window. This means making the window invisible (and all
// its child windows).
//
// Unmapping a window leads to the UnmapNotify event being generated. Also,
// Expose events are generated for formerly obscured windows.
//
// May return a Window error if the specified window does not exist.
//
2013-08-12 02:43:26 +02:00
// UnmapWindow sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie {
cookie := c.NewCookie(false, false)
c.NewRequest(unmapWindowRequest(c, Window), cookie)
return UnmapWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// UnmapWindowChecked sends a checked request.
// If an error occurs, it can be retrieved using UnmapWindowCookie.Check.
2013-08-12 02:43:26 +02:00
func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie {
cookie := c.NewCookie(true, false)
c.NewRequest(unmapWindowRequest(c, Window), cookie)
return UnmapWindowCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// 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()
}
// unmapWindowRequest writes a UnmapWindow request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func unmapWindowRequest(c *xgb.Conn, Window Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 10 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// WarpPointerCookie is a cookie used only for WarpPointer requests.
type WarpPointerCookie struct {
*xgb.Cookie
}
// Moves the mouse pointer to the specified position.
//
// If SrcWindow is not None, the move will only take place if the
// pointer is inside SrcWindow and within the rectangle specified by (SrcX,
// SrcY, SrcWidth, SrcHeight). The rectangle coordinates are relative to
// SrcWindow.
//
// If DstWindow is not None, the pointer will be moved to the
// offsets (DstX, DstY) relative to DstWindow. If DstWindow is
// None, the pointer will be moved by the offsets (DstX, DstY)
// relative to the current position of the pointer.
//
// May return Window errors.
//
2013-08-12 02:43:26 +02:00
// WarpPointer sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func WarpPointer(c *xgb.Conn, SrcWindow, DstWindow Window, SrcX, SrcY int16, SrcWidth, SrcHeight uint16, DstX, DstY int16) WarpPointerCookie {
cookie := c.NewCookie(false, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie)
return WarpPointerCookie{cookie}
}
2013-08-12 02:43:26 +02:00
// WarpPointerChecked sends a checked request.
// If an error occurs, it can be retrieved using WarpPointerCookie.Check.
func WarpPointerChecked(c *xgb.Conn, SrcWindow, DstWindow Window, SrcX, SrcY int16, SrcWidth, SrcHeight uint16, DstX, DstY int16) WarpPointerCookie {
cookie := c.NewCookie(true, false)
2013-08-12 02:43:26 +02:00
c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie)
return WarpPointerCookie{cookie}
}
2012-05-11 05:57:34 +02:00
// 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.
2013-08-12 02:43:26 +02:00
func (cook WarpPointerCookie) Check() error {
return cook.Cookie.Check()
}
// warpPointerRequest writes a WarpPointer request to a byte slice for transfer.
func warpPointerRequest(c *xgb.Conn, SrcWindow, DstWindow Window, SrcX, SrcY int16, SrcWidth, SrcHeight uint16, DstX, DstY int16) []byte {
2013-08-12 02:43:26 +02:00
size := 24
b := 0
buf := make([]byte, size)
2013-08-12 02:43:26 +02:00
buf[b] = 41 // request opcode
b += 1
2013-08-12 02:43:26 +02:00
b += 1 // padding
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
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
}