From 0685fb57e14104ee4ad9f70ec94f787a9a22c028 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:43:26 -0400 Subject: Update to latest xproto XML. --- nexgb/xselinux/xselinux.go | 1762 ++++++++++++++++++++++---------------------- 1 file changed, 881 insertions(+), 881 deletions(-) (limited to 'nexgb/xselinux') diff --git a/nexgb/xselinux/xselinux.go b/nexgb/xselinux/xselinux.go index 6024d65..c7183bf 100644 --- a/nexgb/xselinux/xselinux.go +++ b/nexgb/xselinux/xselinux.go @@ -2,7 +2,7 @@ package xselinux /* - This file was generated by xselinux.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xselinux.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,30 +40,6 @@ func init() { xgb.NewExtErrorFuncs["SELinux"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - type ListItem struct { Name xproto.Atom ObjectContextLen uint32 @@ -156,44 +132,69 @@ func ListItemListSize(list []ListItem) int { return size } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + +// GetClientContextCookie is a cookie used only for GetClientContext requests. +type GetClientContextCookie struct { *xgb.Cookie } -// QueryVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() -func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { +// GetClientContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetClientContextCookie.Reply() +func GetClientContext(c *xgb.Conn, Resource uint32) GetClientContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// GetClientContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { +func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// GetClientContextReply represents the data returned from a GetClientContext request. +type GetClientContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { +// Reply blocks and returns the reply data for a GetClientContext request. +func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -201,12 +202,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return getClientContextReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// getClientContextReply reads a byte slice into a GetClientContextReply value. +func getClientContextReply(buf []byte) *GetClientContextReply { + v := new(GetClientContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -217,18 +218,24 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ServerMajor = xgb.Get16(buf[b:]) - b += 2 + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 - v.ServerMinor = xgb.Get16(buf[b:]) - b += 2 + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } return v } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { +// Write request to wire for GetClientContext +// getClientContextRequest writes a GetClientContext request to a byte slice. +func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -236,76 +243,114 @@ func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 22 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - buf[b] = ClientMajor - b += 1 - - buf[b] = ClientMinor - b += 1 + xgb.Put32(buf[b:], Resource) + b += 4 return buf } -// SetDeviceCreateContextCookie is a cookie used only for SetDeviceCreateContext requests. -type SetDeviceCreateContextCookie struct { +// GetDeviceContextCookie is a cookie used only for GetDeviceContext requests. +type GetDeviceContextCookie struct { *xgb.Cookie } -// SetDeviceCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { +// GetDeviceContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceContextCookie.Reply() +func GetDeviceContext(c *xgb.Conn, Device uint32) GetDeviceContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) - return SetDeviceCreateContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceContextRequest(c, Device), cookie) + return GetDeviceContextCookie{cookie} } -// SetDeviceCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetDeviceCreateContextCookie.Check() -func SetDeviceCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { +// GetDeviceContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceContextUnchecked(c *xgb.Conn, Device uint32) GetDeviceContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) - return SetDeviceCreateContextCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceContextRequest(c, Device), cookie) + return GetDeviceContextCookie{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 SetDeviceCreateContextCookie) Check() error { - return cook.Cookie.Check() +// GetDeviceContextReply represents the data returned from a GetDeviceContext request. +type GetDeviceContextReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Write request to wire for SetDeviceCreateContext -// setDeviceCreateContextRequest writes a SetDeviceCreateContext request to a byte slice. -func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// Reply blocks and returns the reply data for a GetDeviceContext request. +func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceContextReply(buf), nil +} + +// getDeviceContextReply reads a byte slice into a GetDeviceContextReply value. +func getDeviceContextReply(buf []byte) *GetDeviceContextReply { + v := new(GetDeviceContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetDeviceContext +// getDeviceContextRequest writes a GetDeviceContext request to a byte slice. +func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ContextLen) + xgb.Put32(buf[b:], Device) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } @@ -405,96 +450,35 @@ func getDeviceCreateContextRequest(c *xgb.Conn) []byte { return buf } -// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. -type SetDeviceContextCookie struct { +// GetPropertyContextCookie is a cookie used only for GetPropertyContext requests. +type GetPropertyContextCookie struct { *xgb.Cookie } -// SetDeviceContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { +// GetPropertyContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyContextCookie.Reply() +func GetPropertyContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) - return SetDeviceContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{cookie} } -// SetDeviceContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetDeviceContextCookie.Check() -func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { +// GetPropertyContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetPropertyContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) - return SetDeviceContextCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{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 SetDeviceContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetDeviceContext -// setDeviceContextRequest writes a SetDeviceContext request to a byte slice. -func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { - size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], Device) - b += 4 - - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// GetDeviceContextCookie is a cookie used only for GetDeviceContext requests. -type GetDeviceContextCookie struct { - *xgb.Cookie -} - -// GetDeviceContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceContextCookie.Reply() -func GetDeviceContext(c *xgb.Conn, Device uint32) GetDeviceContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceContextRequest(c, Device), cookie) - return GetDeviceContextCookie{cookie} -} - -// GetDeviceContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceContextUnchecked(c *xgb.Conn, Device uint32) GetDeviceContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceContextRequest(c, Device), cookie) - return GetDeviceContextCookie{cookie} -} - -// GetDeviceContextReply represents the data returned from a GetDeviceContext request. -type GetDeviceContextReply struct { +// GetPropertyContextReply represents the data returned from a GetPropertyContext request. +type GetPropertyContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -503,8 +487,8 @@ type GetDeviceContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetDeviceContext request. -func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { +// Reply blocks and returns the reply data for a GetPropertyContext request. +func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -512,12 +496,12 @@ func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { if buf == nil { return nil, nil } - return getDeviceContextReply(buf), nil + return getPropertyContextReply(buf), nil } -// getDeviceContextReply reads a byte slice into a GetDeviceContextReply value. -func getDeviceContextReply(buf []byte) *GetDeviceContextReply { - v := new(GetDeviceContextReply) +// getPropertyContextReply reads a byte slice into a GetPropertyContextReply value. +func getPropertyContextReply(buf []byte) *GetPropertyContextReply { + v := new(GetPropertyContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -543,115 +527,60 @@ func getDeviceContextReply(buf []byte) *GetDeviceContextReply { return v } -// Write request to wire for GetDeviceContext -// getDeviceContextRequest writes a GetDeviceContext request to a byte slice. -func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { - size := 8 +// Write request to wire for GetPropertyContext +// getPropertyContextRequest writes a GetPropertyContext request to a byte slice. +func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], Device) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - return buf -} - -// SetWindowCreateContextCookie is a cookie used only for SetWindowCreateContext requests. -type SetWindowCreateContextCookie struct { - *xgb.Cookie -} - -// SetWindowCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetWindowCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) - return SetWindowCreateContextCookie{cookie} -} - -// SetWindowCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetWindowCreateContextCookie.Check() -func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) - return SetWindowCreateContextCookie{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 SetWindowCreateContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetWindowCreateContext -// setWindowCreateContextRequest writes a SetWindowCreateContext request to a byte slice. -func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], ContextLen) + xgb.Put32(buf[b:], uint32(Property)) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } -// GetWindowCreateContextCookie is a cookie used only for GetWindowCreateContext requests. -type GetWindowCreateContextCookie struct { +// GetPropertyCreateContextCookie is a cookie used only for GetPropertyCreateContext requests. +type GetPropertyCreateContextCookie struct { *xgb.Cookie } -// GetWindowCreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetWindowCreateContextCookie.Reply() -func GetWindowCreateContext(c *xgb.Conn) GetWindowCreateContextCookie { +// GetPropertyCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyCreateContextCookie.Reply() +func GetPropertyCreateContext(c *xgb.Conn) GetPropertyCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getWindowCreateContextRequest(c), cookie) - return GetWindowCreateContextCookie{cookie} + c.NewRequest(getPropertyCreateContextRequest(c), cookie) + return GetPropertyCreateContextCookie{cookie} } -// GetWindowCreateContextUnchecked sends an unchecked request. +// GetPropertyCreateContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetWindowCreateContextUnchecked(c *xgb.Conn) GetWindowCreateContextCookie { +func GetPropertyCreateContextUnchecked(c *xgb.Conn) GetPropertyCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getWindowCreateContextRequest(c), cookie) - return GetWindowCreateContextCookie{cookie} + c.NewRequest(getPropertyCreateContextRequest(c), cookie) + return GetPropertyCreateContextCookie{cookie} } -// GetWindowCreateContextReply represents the data returned from a GetWindowCreateContext request. -type GetWindowCreateContextReply struct { +// GetPropertyCreateContextReply represents the data returned from a GetPropertyCreateContext request. +type GetPropertyCreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -660,8 +589,8 @@ type GetWindowCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetWindowCreateContext request. -func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetPropertyCreateContext request. +func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -669,12 +598,12 @@ func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, if buf == nil { return nil, nil } - return getWindowCreateContextReply(buf), nil + return getPropertyCreateContextReply(buf), nil } -// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. -func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { - v := new(GetWindowCreateContextReply) +// getPropertyCreateContextReply reads a byte slice into a GetPropertyCreateContextReply value. +func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { + v := new(GetPropertyCreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -700,9 +629,9 @@ func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { return v } -// Write request to wire for GetWindowCreateContext -// getWindowCreateContextRequest writes a GetWindowCreateContext request to a byte slice. -func getWindowCreateContextRequest(c *xgb.Conn) []byte { +// Write request to wire for GetPropertyCreateContext +// getPropertyCreateContextRequest writes a GetPropertyCreateContext request to a byte slice. +func getPropertyCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -710,7 +639,7 @@ func getWindowCreateContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -719,35 +648,35 @@ func getWindowCreateContextRequest(c *xgb.Conn) []byte { return buf } -// GetWindowContextCookie is a cookie used only for GetWindowContext requests. -type GetWindowContextCookie struct { +// GetPropertyDataContextCookie is a cookie used only for GetPropertyDataContext requests. +type GetPropertyDataContextCookie struct { *xgb.Cookie } -// GetWindowContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetWindowContextCookie.Reply() -func GetWindowContext(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { +// GetPropertyDataContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyDataContextCookie.Reply() +func GetPropertyDataContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getWindowContextRequest(c, Window), cookie) - return GetWindowContextCookie{cookie} + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} } -// GetWindowContextUnchecked sends an unchecked request. +// GetPropertyDataContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetWindowContextUnchecked(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { +func GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetWindowContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getWindowContextRequest(c, Window), cookie) - return GetWindowContextCookie{cookie} + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} } -// GetWindowContextReply represents the data returned from a GetWindowContext request. -type GetWindowContextReply struct { +// GetPropertyDataContextReply represents the data returned from a GetPropertyDataContext request. +type GetPropertyDataContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -756,8 +685,8 @@ type GetWindowContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetWindowContext request. -func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { +// Reply blocks and returns the reply data for a GetPropertyDataContext request. +func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -765,12 +694,12 @@ func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { if buf == nil { return nil, nil } - return getWindowContextReply(buf), nil + return getPropertyDataContextReply(buf), nil } -// getWindowContextReply reads a byte slice into a GetWindowContextReply value. -func getWindowContextReply(buf []byte) *GetWindowContextReply { - v := new(GetWindowContextReply) +// getPropertyDataContextReply reads a byte slice into a GetPropertyDataContextReply value. +func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { + v := new(GetPropertyDataContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -796,17 +725,17 @@ func getWindowContextReply(buf []byte) *GetWindowContextReply { return v } -// Write request to wire for GetWindowContext -// getWindowContextRequest writes a GetWindowContext request to a byte slice. -func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for GetPropertyDataContext +// getPropertyDataContextRequest writes a GetPropertyDataContext request to a byte slice. +func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -815,96 +744,41 @@ func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + return buf } -// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. -type SetPropertyCreateContextCookie struct { +// GetPropertyUseContextCookie is a cookie used only for GetPropertyUseContext requests. +type GetPropertyUseContextCookie struct { *xgb.Cookie } -// SetPropertyCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) - return SetPropertyCreateContextCookie{cookie} -} - -// SetPropertyCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPropertyCreateContextCookie.Check() -func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) - return SetPropertyCreateContextCookie{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 SetPropertyCreateContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPropertyCreateContext -// setPropertyCreateContextRequest writes a SetPropertyCreateContext request to a byte slice. -func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - - return buf -} - -// GetPropertyCreateContextCookie is a cookie used only for GetPropertyCreateContext requests. -type GetPropertyCreateContextCookie struct { - *xgb.Cookie -} - -// GetPropertyCreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyCreateContextCookie.Reply() -func GetPropertyCreateContext(c *xgb.Conn) GetPropertyCreateContextCookie { +// GetPropertyUseContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyUseContextCookie.Reply() +func GetPropertyUseContext(c *xgb.Conn) GetPropertyUseContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyCreateContextRequest(c), cookie) - return GetPropertyCreateContextCookie{cookie} + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} } -// GetPropertyCreateContextUnchecked sends an unchecked request. +// GetPropertyUseContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyCreateContextUnchecked(c *xgb.Conn) GetPropertyCreateContextCookie { +func GetPropertyUseContextUnchecked(c *xgb.Conn) GetPropertyUseContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyCreateContextRequest(c), cookie) - return GetPropertyCreateContextCookie{cookie} + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} } -// GetPropertyCreateContextReply represents the data returned from a GetPropertyCreateContext request. -type GetPropertyCreateContextReply struct { +// GetPropertyUseContextReply represents the data returned from a GetPropertyUseContext request. +type GetPropertyUseContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -913,8 +787,8 @@ type GetPropertyCreateContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetPropertyCreateContext request. -func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextReply, error) { +// Reply blocks and returns the reply data for a GetPropertyUseContext request. +func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -922,12 +796,12 @@ func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextRep if buf == nil { return nil, nil } - return getPropertyCreateContextReply(buf), nil + return getPropertyUseContextReply(buf), nil } -// getPropertyCreateContextReply reads a byte slice into a GetPropertyCreateContextReply value. -func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { - v := new(GetPropertyCreateContextReply) +// getPropertyUseContextReply reads a byte slice into a GetPropertyUseContextReply value. +func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { + v := new(GetPropertyUseContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -953,9 +827,9 @@ func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { return v } -// Write request to wire for GetPropertyCreateContext -// getPropertyCreateContextRequest writes a GetPropertyCreateContext request to a byte slice. -func getPropertyCreateContextRequest(c *xgb.Conn) []byte { +// Write request to wire for GetPropertyUseContext +// getPropertyUseContextRequest writes a GetPropertyUseContext request to a byte slice. +func getPropertyUseContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -963,7 +837,7 @@ func getPropertyCreateContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -972,93 +846,134 @@ func getPropertyCreateContextRequest(c *xgb.Conn) []byte { return buf } -// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. -type SetPropertyUseContextCookie struct { +// GetSelectionContextCookie is a cookie used only for GetSelectionContext requests. +type GetSelectionContextCookie struct { *xgb.Cookie } -// SetPropertyUseContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { +// GetSelectionContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionContextCookie.Reply() +func GetSelectionContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) - return SetPropertyUseContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{cookie} } -// SetPropertyUseContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPropertyUseContextCookie.Check() -func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { +// GetSelectionContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetSelectionContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) - return SetPropertyUseContextCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{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 SetPropertyUseContextCookie) Check() error { - return cook.Cookie.Check() +// GetSelectionContextReply represents the data returned from a GetSelectionContext request. +type GetSelectionContextReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Write request to wire for SetPropertyUseContext -// setPropertyUseContextRequest writes a SetPropertyUseContext request to a byte slice. -func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// Reply blocks and returns the reply data for a GetSelectionContext request. +func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionContextReply(buf), nil +} + +// getSelectionContextReply reads a byte slice into a GetSelectionContextReply value. +func getSelectionContextReply(buf []byte) *GetSelectionContextReply { + v := new(GetSelectionContextReply) + 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.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionContext +// getSelectionContextRequest writes a GetSelectionContext request to a byte slice. +func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 19 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ContextLen) + xgb.Put32(buf[b:], uint32(Selection)) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } -// GetPropertyUseContextCookie is a cookie used only for GetPropertyUseContext requests. -type GetPropertyUseContextCookie struct { +// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. +type GetSelectionCreateContextCookie struct { *xgb.Cookie } -// GetPropertyUseContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyUseContextCookie.Reply() -func GetPropertyUseContext(c *xgb.Conn) GetPropertyUseContextCookie { +// GetSelectionCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionCreateContextCookie.Reply() +func GetSelectionCreateContext(c *xgb.Conn) GetSelectionCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyUseContextRequest(c), cookie) - return GetPropertyUseContextCookie{cookie} + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} } -// GetPropertyUseContextUnchecked sends an unchecked request. +// GetSelectionCreateContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyUseContextUnchecked(c *xgb.Conn) GetPropertyUseContextCookie { +func GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyUseContextRequest(c), cookie) - return GetPropertyUseContextCookie{cookie} + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} } -// GetPropertyUseContextReply represents the data returned from a GetPropertyUseContext request. -type GetPropertyUseContextReply struct { +// GetSelectionCreateContextReply represents the data returned from a GetSelectionCreateContext request. +type GetSelectionCreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -1067,8 +982,8 @@ type GetPropertyUseContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetPropertyUseContext request. -func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, error) { +// Reply blocks and returns the reply data for a GetSelectionCreateContext request. +func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1076,12 +991,12 @@ func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, er if buf == nil { return nil, nil } - return getPropertyUseContextReply(buf), nil + return getSelectionCreateContextReply(buf), nil } -// getPropertyUseContextReply reads a byte slice into a GetPropertyUseContextReply value. -func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { - v := new(GetPropertyUseContextReply) +// getSelectionCreateContextReply reads a byte slice into a GetSelectionCreateContextReply value. +func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { + v := new(GetSelectionCreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1107,9 +1022,9 @@ func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { return v } -// Write request to wire for GetPropertyUseContext -// getPropertyUseContextRequest writes a GetPropertyUseContext request to a byte slice. -func getPropertyUseContextRequest(c *xgb.Conn) []byte { +// Write request to wire for GetSelectionCreateContext +// getSelectionCreateContextRequest writes a GetSelectionCreateContext request to a byte slice. +func getSelectionCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -1117,7 +1032,7 @@ func getPropertyUseContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1126,35 +1041,35 @@ func getPropertyUseContextRequest(c *xgb.Conn) []byte { return buf } -// GetPropertyContextCookie is a cookie used only for GetPropertyContext requests. -type GetPropertyContextCookie struct { +// GetSelectionDataContextCookie is a cookie used only for GetSelectionDataContext requests. +type GetSelectionDataContextCookie struct { *xgb.Cookie } -// GetPropertyContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyContextCookie.Reply() -func GetPropertyContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { +// GetSelectionDataContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionDataContextCookie.Reply() +func GetSelectionDataContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) - return GetPropertyContextCookie{cookie} + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} } -// GetPropertyContextUnchecked sends an unchecked request. +// GetSelectionDataContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { +func GetSelectionDataContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) - return GetPropertyContextCookie{cookie} + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} } -// GetPropertyContextReply represents the data returned from a GetPropertyContext request. -type GetPropertyContextReply struct { +// GetSelectionDataContextReply represents the data returned from a GetSelectionDataContext request. +type GetSelectionDataContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -1163,8 +1078,8 @@ type GetPropertyContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetPropertyContext request. -func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { +// Reply blocks and returns the reply data for a GetSelectionDataContext request. +func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1172,12 +1087,12 @@ func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { if buf == nil { return nil, nil } - return getPropertyContextReply(buf), nil + return getSelectionDataContextReply(buf), nil } -// getPropertyContextReply reads a byte slice into a GetPropertyContextReply value. -func getPropertyContextReply(buf []byte) *GetPropertyContextReply { - v := new(GetPropertyContextReply) +// getSelectionDataContextReply reads a byte slice into a GetSelectionDataContextReply value. +func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { + v := new(GetSelectionDataContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1203,60 +1118,57 @@ func getPropertyContextReply(buf []byte) *GetPropertyContextReply { return v } -// Write request to wire for GetPropertyContext -// getPropertyContextRequest writes a GetPropertyContext request to a byte slice. -func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { - size := 12 +// Write request to wire for GetSelectionDataContext +// getSelectionDataContextRequest writes a GetSelectionDataContext request to a byte slice. +func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 12 // request opcode + buf[b] = 20 // request opcode 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.Put32(buf[b:], uint32(Property)) + xgb.Put32(buf[b:], uint32(Selection)) b += 4 return buf } -// GetPropertyDataContextCookie is a cookie used only for GetPropertyDataContext requests. -type GetPropertyDataContextCookie struct { +// GetSelectionUseContextCookie is a cookie used only for GetSelectionUseContext requests. +type GetSelectionUseContextCookie struct { *xgb.Cookie } -// GetPropertyDataContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPropertyDataContextCookie.Reply() -func GetPropertyDataContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { +// GetSelectionUseContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionUseContextCookie.Reply() +func GetSelectionUseContext(c *xgb.Conn) GetSelectionUseContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) - return GetPropertyDataContextCookie{cookie} + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} } -// GetPropertyDataContextUnchecked sends an unchecked request. +// GetSelectionUseContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { +func GetSelectionUseContextUnchecked(c *xgb.Conn) GetSelectionUseContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetPropertyDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) - return GetPropertyDataContextCookie{cookie} + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} } -// GetPropertyDataContextReply represents the data returned from a GetPropertyDataContext request. -type GetPropertyDataContextReply struct { +// GetSelectionUseContextReply represents the data returned from a GetSelectionUseContext request. +type GetSelectionUseContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes @@ -1265,8 +1177,8 @@ type GetPropertyDataContextReply struct { Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a GetPropertyDataContext request. -func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, error) { +// Reply blocks and returns the reply data for a GetSelectionUseContext request. +func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1274,12 +1186,12 @@ func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, if buf == nil { return nil, nil } - return getPropertyDataContextReply(buf), nil + return getSelectionUseContextReply(buf), nil } -// getPropertyDataContextReply reads a byte slice into a GetPropertyDataContextReply value. -func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { - v := new(GetPropertyDataContextReply) +// getSelectionUseContextReply reads a byte slice into a GetSelectionUseContextReply value. +func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { + v := new(GetSelectionUseContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1305,70 +1217,64 @@ func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { return v } -// Write request to wire for GetPropertyDataContext -// getPropertyDataContextRequest writes a GetPropertyDataContext request to a byte slice. -func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { - size := 12 +// Write request to wire for GetSelectionUseContext +// getSelectionUseContextRequest writes a GetSelectionUseContext request to a byte slice. +func getSelectionUseContextRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 13 // request opcode + buf[b] = 18 // request opcode 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.Put32(buf[b:], uint32(Property)) - b += 4 - return buf } -// ListPropertiesCookie is a cookie used only for ListProperties requests. -type ListPropertiesCookie struct { +// GetWindowContextCookie is a cookie used only for GetWindowContext requests. +type GetWindowContextCookie struct { *xgb.Cookie } -// ListProperties sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() -func ListProperties(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { +// GetWindowContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowContextCookie.Reply() +func GetWindowContext(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'ListProperties' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetWindowContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} } -// ListPropertiesUnchecked sends an unchecked request. +// GetWindowContextUnchecked 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 xproto.Window) ListPropertiesCookie { +func GetWindowContextUnchecked(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'ListProperties' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetWindowContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listPropertiesRequest(c, Window), cookie) - return ListPropertiesCookie{cookie} + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} } -// ListPropertiesReply represents the data returned from a ListProperties request. -type ListPropertiesReply struct { +// GetWindowContextReply represents the data returned from a GetWindowContext request. +type GetWindowContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - PropertiesLen uint32 + ContextLen uint32 // padding: 20 bytes - Properties []ListItem // size: ListItemListSize(Properties) + Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Reply blocks and returns the reply data for a ListProperties request. -func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { +// Reply blocks and returns the reply data for a GetWindowContext request. +func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1376,12 +1282,12 @@ func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { if buf == nil { return nil, nil } - return listPropertiesReply(buf), nil + return getWindowContextReply(buf), nil } -// listPropertiesReply reads a byte slice into a ListPropertiesReply value. -func listPropertiesReply(buf []byte) *ListPropertiesReply { - v := new(ListPropertiesReply) +// getWindowContextReply reads a byte slice into a GetWindowContextReply value. +func getWindowContextReply(buf []byte) *GetWindowContextReply { + v := new(GetWindowContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -1392,20 +1298,24 @@ func listPropertiesReply(buf []byte) *ListPropertiesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.PropertiesLen = xgb.Get32(buf[b:]) + v.ContextLen = xgb.Get32(buf[b:]) b += 4 b += 20 // padding - v.Properties = make([]ListItem, v.PropertiesLen) - b += ListItemReadList(buf[b:], v.Properties) + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } return v } -// Write request to wire for ListProperties -// listPropertiesRequest writes a ListProperties request to a byte slice. -func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetWindowContext +// getWindowContextRequest writes a GetWindowContext request to a byte slice. +func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1413,7 +1323,7 @@ func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 14 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1425,103 +1335,141 @@ func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. -type SetSelectionCreateContextCookie struct { +// GetWindowCreateContextCookie is a cookie used only for GetWindowCreateContext requests. +type GetWindowCreateContextCookie struct { *xgb.Cookie } -// SetSelectionCreateContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { +// GetWindowCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowCreateContextCookie.Reply() +func GetWindowCreateContext(c *xgb.Conn) GetWindowCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) - return SetSelectionCreateContextCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{cookie} } -// SetSelectionCreateContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetSelectionCreateContextCookie.Check() -func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { +// GetWindowCreateContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetWindowCreateContextUnchecked(c *xgb.Conn) GetWindowCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'GetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) - return SetSelectionCreateContextCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{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 SetSelectionCreateContextCookie) Check() error { - return cook.Cookie.Check() +// GetWindowCreateContextReply represents the data returned from a GetWindowCreateContext request. +type GetWindowCreateContextReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Write request to wire for SetSelectionCreateContext -// setSelectionCreateContextRequest writes a SetSelectionCreateContext request to a byte slice. -func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a GetWindowCreateContext request. +func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getWindowCreateContextReply(buf), nil +} - buf[b] = c.Extensions["SELINUX"] - b += 1 +// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. +func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { + v := new(GetWindowCreateContextReply) + b := 1 // skip reply determinant - buf[b] = 15 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], ContextLen) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 - return buf -} + b += 20 // padding -// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. -type GetSelectionCreateContextCookie struct { + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetWindowCreateContext +// getWindowCreateContextRequest writes a GetWindowCreateContext request to a byte slice. +func getWindowCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// ListPropertiesCookie is a cookie used only for ListProperties requests. +type ListPropertiesCookie struct { *xgb.Cookie } -// GetSelectionCreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionCreateContextCookie.Reply() -func GetSelectionCreateContext(c *xgb.Conn) GetSelectionCreateContextCookie { +// ListProperties sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() +func ListProperties(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'ListProperties' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionCreateContextRequest(c), cookie) - return GetSelectionCreateContextCookie{cookie} + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// GetSelectionCreateContextUnchecked sends an unchecked request. +// ListPropertiesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { +func ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'ListProperties' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionCreateContextRequest(c), cookie) - return GetSelectionCreateContextCookie{cookie} + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} } -// GetSelectionCreateContextReply represents the data returned from a GetSelectionCreateContext request. -type GetSelectionCreateContextReply struct { +// 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 - ContextLen uint32 + PropertiesLen uint32 // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) + Properties []ListItem // size: ListItemListSize(Properties) } -// Reply blocks and returns the reply data for a GetSelectionCreateContext request. -func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { +// 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 @@ -1529,12 +1477,12 @@ func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextR if buf == nil { return nil, nil } - return getSelectionCreateContextReply(buf), nil + return listPropertiesReply(buf), nil } -// getSelectionCreateContextReply reads a byte slice into a GetSelectionCreateContextReply value. -func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { - v := new(GetSelectionCreateContextReply) +// 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 @@ -1545,137 +1493,78 @@ func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextLen = xgb.Get32(buf[b:]) + v.PropertiesLen = xgb.Get32(buf[b:]) b += 4 b += 20 // padding - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) - } + v.Properties = make([]ListItem, v.PropertiesLen) + b += ListItemReadList(buf[b:], v.Properties) return v } -// Write request to wire for GetSelectionCreateContext -// getSelectionCreateContextRequest writes a GetSelectionCreateContext request to a byte slice. -func getSelectionCreateContextRequest(c *xgb.Conn) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["SELINUX"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// SetSelectionUseContextCookie is a cookie used only for SetSelectionUseContext requests. -type SetSelectionUseContextCookie struct { - *xgb.Cookie -} - -// SetSelectionUseContext sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) - return SetSelectionUseContextCookie{cookie} -} - -// SetSelectionUseContextChecked sends a checked request. -// If an error occurs, it can be retrieved using SetSelectionUseContextCookie.Check() -func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { - if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) - return SetSelectionUseContextCookie{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 SetSelectionUseContextCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetSelectionUseContext -// setSelectionUseContextRequest writes a SetSelectionUseContext request to a byte slice. -func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { - size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// Write request to wire for ListProperties +// listPropertiesRequest writes a ListProperties request to a byte slice. +func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 17 // request opcode + buf[b] = 14 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], ContextLen) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) - return buf } -// GetSelectionUseContextCookie is a cookie used only for GetSelectionUseContext requests. -type GetSelectionUseContextCookie struct { +// ListSelectionsCookie is a cookie used only for ListSelections requests. +type ListSelectionsCookie struct { *xgb.Cookie } -// GetSelectionUseContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionUseContextCookie.Reply() -func GetSelectionUseContext(c *xgb.Conn) GetSelectionUseContextCookie { +// ListSelections sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSelectionsCookie.Reply() +func ListSelections(c *xgb.Conn) ListSelectionsCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'ListSelections' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionUseContextRequest(c), cookie) - return GetSelectionUseContextCookie{cookie} + c.NewRequest(listSelectionsRequest(c), cookie) + return ListSelectionsCookie{cookie} } -// GetSelectionUseContextUnchecked sends an unchecked request. +// ListSelectionsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionUseContextUnchecked(c *xgb.Conn) GetSelectionUseContextCookie { +func ListSelectionsUnchecked(c *xgb.Conn) ListSelectionsCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'ListSelections' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionUseContextRequest(c), cookie) - return GetSelectionUseContextCookie{cookie} + c.NewRequest(listSelectionsRequest(c), cookie) + return ListSelectionsCookie{cookie} } -// GetSelectionUseContextReply represents the data returned from a GetSelectionUseContext request. -type GetSelectionUseContextReply struct { +// ListSelectionsReply represents the data returned from a ListSelections request. +type ListSelectionsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ContextLen uint32 + SelectionsLen uint32 // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) + Selections []ListItem // size: ListItemListSize(Selections) } -// Reply blocks and returns the reply data for a GetSelectionUseContext request. -func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { +// Reply blocks and returns the reply data for a ListSelections request. +func (cook ListSelectionsCookie) Reply() (*ListSelectionsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1683,12 +1572,12 @@ func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, if buf == nil { return nil, nil } - return getSelectionUseContextReply(buf), nil + return listSelectionsReply(buf), nil } -// getSelectionUseContextReply reads a byte slice into a GetSelectionUseContextReply value. -func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { - v := new(GetSelectionUseContextReply) +// listSelectionsReply reads a byte slice into a ListSelectionsReply value. +func listSelectionsReply(buf []byte) *ListSelectionsReply { + v := new(ListSelectionsReply) b := 1 // skip reply determinant b += 1 // padding @@ -1699,24 +1588,20 @@ func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextLen = xgb.Get32(buf[b:]) + v.SelectionsLen = xgb.Get32(buf[b:]) b += 4 b += 20 // padding - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) - } + v.Selections = make([]ListItem, v.SelectionsLen) + b += ListItemReadList(buf[b:], v.Selections) return v } -// Write request to wire for GetSelectionUseContext -// getSelectionUseContextRequest writes a GetSelectionUseContext request to a byte slice. -func getSelectionUseContextRequest(c *xgb.Conn) []byte { +// Write request to wire for ListSelections +// listSelectionsRequest writes a ListSelections request to a byte slice. +func listSelectionsRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -1724,7 +1609,7 @@ func getSelectionUseContextRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 21 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1733,45 +1618,44 @@ func getSelectionUseContextRequest(c *xgb.Conn) []byte { return buf } -// GetSelectionContextCookie is a cookie used only for GetSelectionContext requests. -type GetSelectionContextCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// GetSelectionContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionContextCookie.Reply() -func GetSelectionContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionContextRequest(c, Selection), cookie) - return GetSelectionContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// GetSelectionContextUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { +func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionContextRequest(c, Selection), cookie) - return GetSelectionContextCookie{cookie} + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} } -// GetSelectionContextReply represents the data returned from a GetSelectionContext request. -type GetSelectionContextReply struct { +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) + ServerMajor uint16 + ServerMinor uint16 } -// Reply blocks and returns the reply data for a GetSelectionContext request. -func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) { +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1779,12 +1663,12 @@ func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) if buf == nil { return nil, nil } - return getSelectionContextReply(buf), nil + return queryVersionReply(buf), nil } -// getSelectionContextReply reads a byte slice into a GetSelectionContextReply value. -func getSelectionContextReply(buf []byte) *GetSelectionContextReply { - v := new(GetSelectionContextReply) +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) b := 1 // skip reply determinant b += 1 // padding @@ -1795,24 +1679,18 @@ func getSelectionContextReply(buf []byte) *GetSelectionContextReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ContextLen = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) - } + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for GetSelectionContext -// getSelectionContextRequest writes a GetSelectionContext request to a byte slice. -func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1820,304 +1698,426 @@ func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Selection)) - b += 4 + buf[b] = ClientMajor + b += 1 + + buf[b] = ClientMinor + b += 1 return buf } -// GetSelectionDataContextCookie is a cookie used only for GetSelectionDataContext requests. -type GetSelectionDataContextCookie struct { +// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. +type SetDeviceContextCookie struct { *xgb.Cookie } -// GetSelectionDataContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetSelectionDataContextCookie.Reply() -func GetSelectionDataContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { +// SetDeviceContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) - return GetSelectionDataContextCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} } -// GetSelectionDataContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetSelectionDataContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { +// SetDeviceContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceContextCookie.Check() +func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetSelectionDataContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetDeviceContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) - return GetSelectionDataContextCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} } -// GetSelectionDataContextReply represents the data returned from a GetSelectionDataContext request. -type GetSelectionDataContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetDeviceContextCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetSelectionDataContext request. -func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSelectionDataContextReply(buf), nil -} +// Write request to wire for SetDeviceContext +// setDeviceContextRequest writes a SetDeviceContext request to a byte slice. +func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) -// getSelectionDataContextReply reads a byte slice into a GetSelectionDataContextReply value. -func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { - v := new(GetSelectionDataContextReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["SELINUX"] + b += 1 - b += 1 // padding + buf[b] = 3 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], Device) b += 4 - v.ContextLen = xgb.Get32(buf[b:]) + xgb.Put32(buf[b:], ContextLen) b += 4 - b += 20 // padding + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) + return buf +} + +// SetDeviceCreateContextCookie is a cookie used only for SetDeviceCreateContext requests. +type SetDeviceCreateContextCookie struct { + *xgb.Cookie +} + +// SetDeviceCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetDeviceCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} +} - return v +// SetDeviceCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceCreateContextCookie.Check() +func SetDeviceCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetDeviceCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} } -// Write request to wire for GetSelectionDataContext -// getSelectionDataContextRequest writes a GetSelectionDataContext request to a byte slice. -func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { - size := 8 +// 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 SetDeviceCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceCreateContext +// setDeviceCreateContextRequest writes a SetDeviceCreateContext request to a byte slice. +func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Selection)) + xgb.Put32(buf[b:], ContextLen) b += 4 + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + return buf } -// ListSelectionsCookie is a cookie used only for ListSelections requests. -type ListSelectionsCookie struct { +// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. +type SetPropertyCreateContextCookie struct { *xgb.Cookie } -// ListSelections sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListSelectionsCookie.Reply() -func ListSelections(c *xgb.Conn) ListSelectionsCookie { +// SetPropertyCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'ListSelections' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(listSelectionsRequest(c), cookie) - return ListSelectionsCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} } -// ListSelectionsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListSelectionsUnchecked(c *xgb.Conn) ListSelectionsCookie { +// SetPropertyCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPropertyCreateContextCookie.Check() +func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'ListSelections' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetPropertyCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(listSelectionsRequest(c), cookie) - return ListSelectionsCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} } -// ListSelectionsReply represents the data returned from a ListSelections request. -type ListSelectionsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - SelectionsLen uint32 - // padding: 20 bytes - Selections []ListItem // size: ListItemListSize(Selections) +// 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 SetPropertyCreateContextCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a ListSelections request. -func (cook ListSelectionsCookie) Reply() (*ListSelectionsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listSelectionsReply(buf), nil -} +// Write request to wire for SetPropertyCreateContext +// setPropertyCreateContextRequest writes a SetPropertyCreateContext request to a byte slice. +func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) -// listSelectionsReply reads a byte slice into a ListSelectionsReply value. -func listSelectionsReply(buf []byte) *ListSelectionsReply { - v := new(ListSelectionsReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["SELINUX"] + b += 1 - b += 1 // padding + buf[b] = 8 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], ContextLen) b += 4 - v.SelectionsLen = xgb.Get32(buf[b:]) - b += 4 + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) - b += 20 // padding + return buf +} - v.Selections = make([]ListItem, v.SelectionsLen) - b += ListItemReadList(buf[b:], v.Selections) +// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. +type SetPropertyUseContextCookie struct { + *xgb.Cookie +} - return v +// SetPropertyUseContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{cookie} } -// Write request to wire for ListSelections -// listSelectionsRequest writes a ListSelections request to a byte slice. -func listSelectionsRequest(c *xgb.Conn) []byte { - size := 4 +// SetPropertyUseContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPropertyUseContextCookie.Check() +func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetPropertyUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{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 SetPropertyUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyUseContext +// setPropertyUseContextRequest writes a SetPropertyUseContext request to a byte slice. +func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 21 // request opcode + buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + return buf } -// GetClientContextCookie is a cookie used only for GetClientContext requests. -type GetClientContextCookie struct { +// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. +type SetSelectionCreateContextCookie struct { *xgb.Cookie } -// GetClientContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetClientContextCookie.Reply() -func GetClientContext(c *xgb.Conn, Resource uint32) GetClientContextCookie { +// SetSelectionCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getClientContextRequest(c, Resource), cookie) - return GetClientContextCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} } -// GetClientContextUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { +// SetSelectionCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionCreateContextCookie.Check() +func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { if _, ok := c.Extensions["SELINUX"]; !ok { - panic("Cannot issue request 'GetClientContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + panic("Cannot issue request 'SetSelectionCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getClientContextRequest(c, Resource), cookie) - return GetClientContextCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} } -// GetClientContextReply represents the data returned from a GetClientContext request. -type GetClientContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: xgb.Pad((int(ContextLen) * 1)) +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetSelectionCreateContextCookie) Check() error { + return cook.Cookie.Check() } -// Reply blocks and returns the reply data for a GetClientContext request. -func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err +// Write request to wire for SetSelectionCreateContext +// setSelectionCreateContextRequest writes a SetSelectionCreateContext request to a byte slice. +func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// SetSelectionUseContextCookie is a cookie used only for SetSelectionUseContext requests. +type SetSelectionUseContextCookie struct { + *xgb.Cookie +} + +// SetSelectionUseContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - if buf == nil { - return nil, nil + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} +} + +// SetSelectionUseContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionUseContextCookie.Check() +func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetSelectionUseContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } - return getClientContextReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} } -// getClientContextReply reads a byte slice into a GetClientContextReply value. -func getClientContextReply(buf []byte) *GetClientContextReply { - v := new(GetClientContextReply) - b := 1 // skip reply determinant +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetSelectionUseContextCookie) Check() error { + return cook.Cookie.Check() +} - b += 1 // padding +// Write request to wire for SetSelectionUseContext +// setSelectionUseContextRequest writes a SetSelectionUseContext request to a byte slice. +func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], ContextLen) b += 4 - v.ContextLen = xgb.Get32(buf[b:]) - b += 4 + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) - b += 20 // padding + return buf +} - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += xgb.Pad(int(v.ContextLen)) +// SetWindowCreateContextCookie is a cookie used only for SetWindowCreateContext requests. +type SetWindowCreateContextCookie struct { + *xgb.Cookie +} + +// SetWindowCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetWindowCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") } + cookie := c.NewCookie(false, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} +} - return v +// SetWindowCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetWindowCreateContextCookie.Check() +func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + if _, ok := c.Extensions["SELINUX"]; !ok { + panic("Cannot issue request 'SetWindowCreateContext' using the uninitialized extension 'SELinux'. xselinux.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} } -// Write request to wire for GetClientContext -// getClientContextRequest writes a GetClientContext request to a byte slice. -func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { - size := 8 +// 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 SetWindowCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetWindowCreateContext +// setWindowCreateContextRequest writes a SetWindowCreateContext request to a byte slice. +func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SELINUX"] b += 1 - buf[b] = 22 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], Resource) + xgb.Put32(buf[b:], ContextLen) b += 4 + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + return buf } -- cgit v1.2.3