diff options
Diffstat (limited to 'nexgb/screensaver')
-rw-r--r-- | nexgb/screensaver/screensaver.go | 336 |
1 files changed, 168 insertions, 168 deletions
diff --git a/nexgb/screensaver/screensaver.go b/nexgb/screensaver/screensaver.go index f336d0d..f693b52 100644 --- a/nexgb/screensaver/screensaver.go +++ b/nexgb/screensaver/screensaver.go @@ -2,7 +2,7 @@ package screensaver /* - This file was generated by screensaver.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by screensaver.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,46 +40,15 @@ func init() { xgb.NewExtErrorFuncs["MIT-SCREEN-SAVER"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// 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' - -const ( - KindBlanked = 0 - KindInternal = 1 - KindExternal = 2 -) - const ( EventNotifyMask = 1 EventCycleMask = 2 ) const ( - StateOff = 0 - StateOn = 1 - StateCycle = 2 - StateDisabled = 3 + KindBlanked = 0 + KindInternal = 1 + KindExternal = 2 ) // Notify is the event number for a NotifyEvent. @@ -214,105 +183,36 @@ func init() { xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"][0] = NotifyEventNew } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie 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, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { - if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// QueryVersionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { - if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// 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 - ServerMajorVersion uint16 - ServerMinorVersion uint16 - // padding: 20 bytes -} - -// 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 - } - if buf == nil { - return nil, nil - } - return queryVersionReply(buf), nil -} - -// 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 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +const ( + StateOff = 0 + StateOn = 1 + StateCycle = 2 + StateDisabled = 3 +) - v.ServerMajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Bool' - v.ServerMinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Byte' - b += 20 // padding +// Skipping definition for base type 'Card8' - return v -} +// Skipping definition for base type 'Char' -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Skipping definition for base type 'Void' - buf[b] = c.Extensions["MIT-SCREEN-SAVER"] - b += 1 +// Skipping definition for base type 'Double' - buf[b] = 0 // request opcode - b += 1 +// Skipping definition for base type 'Float' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Int16' - buf[b] = ClientMajorVersion - b += 1 +// Skipping definition for base type 'Int32' - buf[b] = ClientMinorVersion - b += 1 +// Skipping definition for base type 'Int8' - b += 2 // padding +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' // QueryInfoCookie is a cookie used only for QueryInfo requests. type QueryInfoCookie struct { @@ -422,6 +322,106 @@ func queryInfoRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { return buf } +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie 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, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { + if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { + if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// 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 + ServerMajorVersion uint16 + ServerMinorVersion uint16 + // padding: 20 bytes +} + +// 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 + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// 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 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = ClientMajorVersion + b += 1 + + buf[b] = ClientMinorVersion + b += 1 + + b += 2 // padding + + return buf +} + // SelectInputCookie is a cookie used only for SelectInput requests. type SelectInputCookie struct { *xgb.Cookie @@ -567,42 +567,42 @@ func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int1 return buf } -// UnsetAttributesCookie is a cookie used only for UnsetAttributes requests. -type UnsetAttributesCookie struct { +// SuspendCookie is a cookie used only for Suspend requests. +type SuspendCookie struct { *xgb.Cookie } -// UnsetAttributes sends an unchecked request. +// Suspend sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnsetAttributes(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { +func Suspend(c *xgb.Conn, Suspend bool) SuspendCookie { if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'UnsetAttributes' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + panic("Cannot issue request 'Suspend' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) - return UnsetAttributesCookie{cookie} + c.NewRequest(suspendRequest(c, Suspend), cookie) + return SuspendCookie{cookie} } -// UnsetAttributesChecked sends a checked request. -// If an error occurs, it can be retrieved using UnsetAttributesCookie.Check() -func UnsetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { +// SuspendChecked sends a checked request. +// If an error occurs, it can be retrieved using SuspendCookie.Check() +func SuspendChecked(c *xgb.Conn, Suspend bool) SuspendCookie { if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'UnsetAttributes' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + panic("Cannot issue request 'Suspend' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) - return UnsetAttributesCookie{cookie} + c.NewRequest(suspendRequest(c, Suspend), cookie) + return SuspendCookie{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 UnsetAttributesCookie) Check() error { +func (cook SuspendCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for UnsetAttributes -// unsetAttributesRequest writes a UnsetAttributes request to a byte slice. -func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { +// Write request to wire for Suspend +// suspendRequest writes a Suspend request to a byte slice. +func suspendRequest(c *xgb.Conn, Suspend bool) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -610,54 +610,60 @@ func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { buf[b] = c.Extensions["MIT-SCREEN-SAVER"] b += 1 - buf[b] = 4 // 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:], uint32(Drawable)) - b += 4 + if Suspend { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding return buf } -// SuspendCookie is a cookie used only for Suspend requests. -type SuspendCookie struct { +// UnsetAttributesCookie is a cookie used only for UnsetAttributes requests. +type UnsetAttributesCookie struct { *xgb.Cookie } -// Suspend sends an unchecked request. +// UnsetAttributes sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Suspend(c *xgb.Conn, Suspend bool) SuspendCookie { +func UnsetAttributes(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'Suspend' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + panic("Cannot issue request 'UnsetAttributes' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(suspendRequest(c, Suspend), cookie) - return SuspendCookie{cookie} + c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) + return UnsetAttributesCookie{cookie} } -// SuspendChecked sends a checked request. -// If an error occurs, it can be retrieved using SuspendCookie.Check() -func SuspendChecked(c *xgb.Conn, Suspend bool) SuspendCookie { +// UnsetAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using UnsetAttributesCookie.Check() +func UnsetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { if _, ok := c.Extensions["MIT-SCREEN-SAVER"]; !ok { - panic("Cannot issue request 'Suspend' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") + panic("Cannot issue request 'UnsetAttributes' using the uninitialized extension 'MIT-SCREEN-SAVER'. screensaver.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(suspendRequest(c, Suspend), cookie) - return SuspendCookie{cookie} + c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) + return UnsetAttributesCookie{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 SuspendCookie) Check() error { +func (cook UnsetAttributesCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Suspend -// suspendRequest writes a Suspend request to a byte slice. -func suspendRequest(c *xgb.Conn, Suspend bool) []byte { +// Write request to wire for UnsetAttributes +// unsetAttributesRequest writes a UnsetAttributes request to a byte slice. +func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -665,20 +671,14 @@ func suspendRequest(c *xgb.Conn, Suspend bool) []byte { buf[b] = c.Extensions["MIT-SCREEN-SAVER"] b += 1 - buf[b] = 5 // 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 - if Suspend { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 return buf } |