2012-05-11 02:06:22 +02:00
// Package xf86dri is the X client API for the XFree86-DRI extension.
2012-05-10 23:01:42 +02:00
package xf86dri
2013-08-12 02:45:36 +02:00
// This file is automatically generated from xf86dri.xml. Edit at your peril!
2012-05-10 23:01:42 +02:00
import (
2018-09-08 19:57:27 +02:00
xgb "janouch.name/haven/nexgb"
2012-05-10 23:01:42 +02:00
2018-09-08 19:57:27 +02:00
"janouch.name/haven/nexgb/xproto"
2012-05-10 23:01:42 +02:00
)
2018-09-21 08:37:21 +02:00
const (
MajorVersion = 4
MinorVersion = 1
)
2012-05-10 23:01:42 +02:00
// Init must be called before using the XFree86-DRI extension.
func Init ( c * xgb . Conn ) error {
reply , err := xproto . QueryExtension ( c , 11 , "XFree86-DRI" ) . Reply ( )
switch {
case err != nil :
return err
case ! reply . Present :
return xgb . Errorf ( "No extension named XFree86-DRI could be found on on the server." )
}
2016-03-01 15:41:38 +01:00
c . ExtLock . Lock ( )
2012-05-10 23:01:42 +02:00
c . Extensions [ "XFree86-DRI" ] = reply . MajorOpcode
2016-03-01 15:41:38 +01:00
c . ExtLock . Unlock ( )
2012-05-10 23:01:42 +02:00
for evNum , fun := range xgb . NewExtEventFuncs [ "XFree86-DRI" ] {
xgb . NewEventFuncs [ int ( reply . FirstEvent ) + evNum ] = fun
}
for errNum , fun := range xgb . NewExtErrorFuncs [ "XFree86-DRI" ] {
xgb . NewErrorFuncs [ int ( reply . FirstError ) + errNum ] = fun
}
return nil
}
func init ( ) {
xgb . NewExtEventFuncs [ "XFree86-DRI" ] = make ( map [ int ] xgb . NewEventFun )
xgb . NewExtErrorFuncs [ "XFree86-DRI" ] = make ( map [ int ] xgb . NewErrorFun )
}
type DrmClipRect struct {
X1 int16
Y1 int16
X2 int16
X3 int16
}
2012-05-11 05:57:34 +02:00
// DrmClipRectRead reads a byte slice into a DrmClipRect value.
2012-05-10 23:01:42 +02:00
func DrmClipRectRead ( buf [ ] byte , v * DrmClipRect ) int {
b := 0
v . X1 = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . Y1 = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . X2 = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . X3 = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
return b
}
2012-05-11 05:57:34 +02:00
// DrmClipRectReadList reads a byte slice into a list of DrmClipRect values.
2012-05-10 23:01:42 +02:00
func DrmClipRectReadList ( buf [ ] byte , dest [ ] DrmClipRect ) int {
b := 0
for i := 0 ; i < len ( dest ) ; i ++ {
dest [ i ] = DrmClipRect { }
b += DrmClipRectRead ( buf [ b : ] , & dest [ i ] )
}
return xgb . Pad ( b )
}
2012-05-11 05:57:34 +02:00
// Bytes writes a DrmClipRect value to a byte slice.
2012-05-10 23:01:42 +02:00
func ( v DrmClipRect ) Bytes ( ) [ ] byte {
buf := make ( [ ] byte , 8 )
b := 0
xgb . Put16 ( buf [ b : ] , uint16 ( v . X1 ) )
b += 2
xgb . Put16 ( buf [ b : ] , uint16 ( v . Y1 ) )
b += 2
xgb . Put16 ( buf [ b : ] , uint16 ( v . X2 ) )
b += 2
xgb . Put16 ( buf [ b : ] , uint16 ( v . X3 ) )
b += 2
2014-05-02 15:09:23 +02:00
return buf [ : b ]
2012-05-10 23:01:42 +02:00
}
2012-05-27 00:24:52 +02:00
// DrmClipRectListBytes writes a list of DrmClipRect values to a byte slice.
2012-05-10 23:01:42 +02:00
func DrmClipRectListBytes ( buf [ ] byte , list [ ] DrmClipRect ) int {
b := 0
var structBytes [ ] byte
for _ , item := range list {
structBytes = item . Bytes ( )
copy ( buf [ b : ] , structBytes )
2013-08-12 02:54:15 +02:00
b += len ( structBytes )
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:54:15 +02:00
return xgb . Pad ( b )
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// 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'
// AuthConnectionCookie is a cookie used only for AuthConnection requests.
type AuthConnectionCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// AuthConnection sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling AuthConnectionCookie.Reply.
func AuthConnection ( c * xgb . Conn , Screen , Magic uint32 ) AuthConnectionCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( authConnectionRequest ( c , Screen , Magic ) , cookie )
return AuthConnectionCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// AuthConnectionUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2018-09-30 16:32:47 +02:00
func AuthConnectionUnchecked ( c * xgb . Conn , Screen , Magic uint32 ) AuthConnectionCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( authConnectionRequest ( c , Screen , Magic ) , cookie )
return AuthConnectionCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// AuthConnectionReply represents the data returned from a AuthConnection request.
type AuthConnectionReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2012-05-10 23:01:42 +02:00
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
Authenticated uint32
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Reply blocks and returns the reply data for a AuthConnection request.
func ( cook AuthConnectionCookie ) Reply ( ) ( * AuthConnectionReply , error ) {
2012-05-10 23:01:42 +02:00
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
2013-08-12 02:43:26 +02:00
return authConnectionReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// authConnectionReply reads a byte slice into a AuthConnectionReply value.
func authConnectionReply ( buf [ ] byte ) * AuthConnectionReply {
v := new ( AuthConnectionReply )
2012-05-10 23:01:42 +02:00
b := 1 // skip reply determinant
b += 1 // padding
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v . Authenticated = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
return v
}
2018-09-30 16:32:47 +02:00
// authConnectionRequest writes a AuthConnection request to a byte slice for transfer.
func authConnectionRequest ( c * xgb . Conn , Screen , Magic uint32 ) [ ] byte {
2013-08-12 02:43:26 +02:00
size := 12
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 11 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
xgb . Put32 ( buf [ b : ] , Magic )
b += 4
2012-05-10 23:01:42 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// CloseConnectionCookie is a cookie used only for CloseConnection requests.
type CloseConnectionCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// CloseConnection sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func CloseConnection ( c * xgb . Conn , Screen uint32 ) CloseConnectionCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2013-08-12 02:43:26 +02:00
cookie := c . NewCookie ( false , false )
c . NewRequest ( closeConnectionRequest ( c , Screen ) , cookie )
return CloseConnectionCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// CloseConnectionChecked sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it can be retrieved using CloseConnectionCookie.Check.
2013-08-12 02:43:26 +02:00
func CloseConnectionChecked ( c * xgb . Conn , Screen uint32 ) CloseConnectionCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
cookie := c . NewCookie ( true , false )
c . NewRequest ( closeConnectionRequest ( c , Screen ) , cookie )
return CloseConnectionCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func ( cook CloseConnectionCookie ) Check ( ) error {
return cook . Cookie . Check ( )
2012-05-10 23:01:42 +02:00
}
2018-09-30 16:32:47 +02:00
// closeConnectionRequest writes a CloseConnection request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func closeConnectionRequest ( c * xgb . Conn , Screen uint32 ) [ ] byte {
2012-05-10 23:01:42 +02:00
size := 8
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 3 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// CreateContextCookie is a cookie used only for CreateContext requests.
type CreateContextCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// CreateContext sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply.
func CreateContext ( c * xgb . Conn , Screen , Visual , Context uint32 ) CreateContextCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( createContextRequest ( c , Screen , Visual , Context ) , cookie )
return CreateContextCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// CreateContextUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2018-09-30 16:32:47 +02:00
func CreateContextUnchecked ( c * xgb . Conn , Screen , Visual , Context uint32 ) CreateContextCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( createContextRequest ( c , Screen , Visual , Context ) , cookie )
return CreateContextCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
/ / CreateContextReply represents the data returned from a CreateContext request .
type CreateContextReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2012-05-10 23:01:42 +02:00
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
HwContext uint32
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Reply blocks and returns the reply data for a CreateContext request.
func ( cook CreateContextCookie ) Reply ( ) ( * CreateContextReply , error ) {
2012-05-10 23:01:42 +02:00
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
2013-08-12 02:43:26 +02:00
return createContextReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// createContextReply reads a byte slice into a CreateContextReply value.
func createContextReply ( buf [ ] byte ) * CreateContextReply {
v := new ( CreateContextReply )
2012-05-10 23:01:42 +02:00
b := 1 // skip reply determinant
b += 1 // padding
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v . HwContext = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
return v
}
2018-09-30 16:32:47 +02:00
// createContextRequest writes a CreateContext request to a byte slice for transfer.
func createContextRequest ( c * xgb . Conn , Screen , Visual , Context uint32 ) [ ] byte {
2013-08-12 02:43:26 +02:00
size := 16
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 5 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Visual )
b += 4
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Context )
2012-05-10 23:01:42 +02:00
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// CreateDrawableCookie is a cookie used only for CreateDrawable requests.
type CreateDrawableCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// CreateDrawable sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply.
func CreateDrawable ( c * xgb . Conn , Screen , Drawable uint32 ) CreateDrawableCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( createDrawableRequest ( c , Screen , Drawable ) , cookie )
return CreateDrawableCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// CreateDrawableUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2018-09-30 16:32:47 +02:00
func CreateDrawableUnchecked ( c * xgb . Conn , Screen , Drawable uint32 ) CreateDrawableCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( createDrawableRequest ( c , Screen , Drawable ) , cookie )
return CreateDrawableCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// CreateDrawableReply represents the data returned from a CreateDrawable request.
type CreateDrawableReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2012-05-10 23:01:42 +02:00
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
HwDrawableHandle uint32
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Reply blocks and returns the reply data for a CreateDrawable request.
func ( cook CreateDrawableCookie ) Reply ( ) ( * CreateDrawableReply , error ) {
2012-05-10 23:01:42 +02:00
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
2013-08-12 02:43:26 +02:00
return createDrawableReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// createDrawableReply reads a byte slice into a CreateDrawableReply value.
func createDrawableReply ( buf [ ] byte ) * CreateDrawableReply {
v := new ( CreateDrawableReply )
2012-05-10 23:01:42 +02:00
b := 1 // skip reply determinant
b += 1 // padding
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v . HwDrawableHandle = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
return v
}
2018-09-30 16:32:47 +02:00
// createDrawableRequest writes a CreateDrawable request to a byte slice for transfer.
func createDrawableRequest ( c * xgb . Conn , Screen , Drawable uint32 ) [ ] byte {
2013-08-12 02:43:26 +02:00
size := 12
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 7 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Drawable )
b += 4
2012-05-10 23:01:42 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// DestroyContextCookie is a cookie used only for DestroyContext requests.
type DestroyContextCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// DestroyContext sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2018-09-30 16:32:47 +02:00
func DestroyContext ( c * xgb . Conn , Screen , Context uint32 ) DestroyContextCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2013-08-12 02:43:26 +02:00
cookie := c . NewCookie ( false , false )
c . NewRequest ( destroyContextRequest ( c , Screen , Context ) , cookie )
return DestroyContextCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// DestroyContextChecked sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it can be retrieved using DestroyContextCookie.Check.
func DestroyContextChecked ( c * xgb . Conn , Screen , Context uint32 ) DestroyContextCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
cookie := c . NewCookie ( true , false )
c . NewRequest ( destroyContextRequest ( c , Screen , Context ) , cookie )
return DestroyContextCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func ( cook DestroyContextCookie ) Check ( ) error {
return cook . Cookie . Check ( )
2012-05-10 23:01:42 +02:00
}
2018-09-30 16:32:47 +02:00
// destroyContextRequest writes a DestroyContext request to a byte slice for transfer.
func destroyContextRequest ( c * xgb . Conn , Screen , Context uint32 ) [ ] byte {
2013-08-12 02:43:26 +02:00
size := 12
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 6 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
xgb . Put32 ( buf [ b : ] , Context )
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests.
type DestroyDrawableCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// DestroyDrawable sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2018-09-30 16:32:47 +02:00
func DestroyDrawable ( c * xgb . Conn , Screen , Drawable uint32 ) DestroyDrawableCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , false )
2013-08-12 02:43:26 +02:00
c . NewRequest ( destroyDrawableRequest ( c , Screen , Drawable ) , cookie )
return DestroyDrawableCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// DestroyDrawableChecked sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check.
func DestroyDrawableChecked ( c * xgb . Conn , Screen , Drawable uint32 ) DestroyDrawableCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , false )
2013-08-12 02:43:26 +02:00
c . NewRequest ( destroyDrawableRequest ( c , Screen , Drawable ) , cookie )
return DestroyDrawableCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
2013-08-12 02:43:26 +02:00
func ( cook DestroyDrawableCookie ) Check ( ) error {
2012-05-10 23:01:42 +02:00
return cook . Cookie . Check ( )
}
2018-09-30 16:32:47 +02:00
// destroyDrawableRequest writes a DestroyDrawable request to a byte slice for transfer.
func destroyDrawableRequest ( c * xgb . Conn , Screen , Drawable uint32 ) [ ] byte {
2012-05-10 23:01:42 +02:00
size := 12
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 8 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Drawable )
2012-05-10 23:01:42 +02:00
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests.
type GetClientDriverNameCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetClientDriverName sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling GetClientDriverNameCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetClientDriverName ( c * xgb . Conn , Screen uint32 ) GetClientDriverNameCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( getClientDriverNameRequest ( c , Screen ) , cookie )
return GetClientDriverNameCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetClientDriverNameUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func GetClientDriverNameUnchecked ( c * xgb . Conn , Screen uint32 ) GetClientDriverNameCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( getClientDriverNameRequest ( c , Screen ) , cookie )
return GetClientDriverNameCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetClientDriverNameReply represents the data returned from a GetClientDriverName request.
type GetClientDriverNameReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2012-05-10 23:01:42 +02:00
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
ClientDriverMajorVersion uint32
ClientDriverMinorVersion uint32
ClientDriverPatchVersion uint32
ClientDriverNameLen uint32
// padding: 8 bytes
ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1))
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Reply blocks and returns the reply data for a GetClientDriverName request.
func ( cook GetClientDriverNameCookie ) Reply ( ) ( * GetClientDriverNameReply , error ) {
2012-05-10 23:01:42 +02:00
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
2013-08-12 02:43:26 +02:00
return getClientDriverNameReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value.
func getClientDriverNameReply ( buf [ ] byte ) * GetClientDriverNameReply {
v := new ( GetClientDriverNameReply )
2012-05-10 23:01:42 +02:00
b := 1 // skip reply determinant
b += 1 // padding
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v . ClientDriverMajorVersion = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v . ClientDriverMinorVersion = xgb . Get32 ( buf [ b : ] )
b += 4
v . ClientDriverPatchVersion = xgb . Get32 ( buf [ b : ] )
b += 4
v . ClientDriverNameLen = xgb . Get32 ( buf [ b : ] )
b += 4
b += 8 // padding
{
byteString := make ( [ ] byte , v . ClientDriverNameLen )
copy ( byteString [ : v . ClientDriverNameLen ] , buf [ b : ] )
v . ClientDriverName = string ( byteString )
2013-12-28 16:02:18 +01:00
b += int ( v . ClientDriverNameLen )
2013-08-12 02:43:26 +02:00
}
2012-05-10 23:01:42 +02:00
return v
}
2018-09-30 16:32:47 +02:00
// getClientDriverNameRequest writes a GetClientDriverName request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getClientDriverNameRequest ( c * xgb . Conn , Screen uint32 ) [ ] byte {
size := 8
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 4 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests.
type GetDeviceInfoCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetDeviceInfo sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply.
2013-08-12 02:43:26 +02:00
func GetDeviceInfo ( c * xgb . Conn , Screen uint32 ) GetDeviceInfoCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2013-08-12 02:43:26 +02:00
cookie := c . NewCookie ( true , true )
c . NewRequest ( getDeviceInfoRequest ( c , Screen ) , cookie )
return GetDeviceInfoCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetDeviceInfoUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetDeviceInfoUnchecked ( c * xgb . Conn , Screen uint32 ) GetDeviceInfoCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2013-08-12 02:43:26 +02:00
cookie := c . NewCookie ( false , true )
c . NewRequest ( getDeviceInfoRequest ( c , Screen ) , cookie )
return GetDeviceInfoCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request.
type GetDeviceInfoReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
FramebufferHandleLow uint32
FramebufferHandleHigh uint32
FramebufferOriginOffset uint32
FramebufferSize uint32
FramebufferStride uint32
DevicePrivateSize uint32
DevicePrivate [ ] uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4))
}
// Reply blocks and returns the reply data for a GetDeviceInfo request.
func ( cook GetDeviceInfoCookie ) Reply ( ) ( * GetDeviceInfoReply , error ) {
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
return getDeviceInfoReply ( buf ) , nil
}
// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value.
func getDeviceInfoReply ( buf [ ] byte ) * GetDeviceInfoReply {
v := new ( GetDeviceInfoReply )
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 . FramebufferHandleLow = xgb . Get32 ( buf [ b : ] )
b += 4
v . FramebufferHandleHigh = xgb . Get32 ( buf [ b : ] )
b += 4
v . FramebufferOriginOffset = xgb . Get32 ( buf [ b : ] )
b += 4
v . FramebufferSize = xgb . Get32 ( buf [ b : ] )
b += 4
v . FramebufferStride = xgb . Get32 ( buf [ b : ] )
b += 4
v . DevicePrivateSize = xgb . Get32 ( buf [ b : ] )
b += 4
v . DevicePrivate = make ( [ ] uint32 , v . DevicePrivateSize )
for i := 0 ; i < int ( v . DevicePrivateSize ) ; i ++ {
v . DevicePrivate [ i ] = xgb . Get32 ( buf [ b : ] )
b += 4
}
return v
2012-05-10 23:01:42 +02:00
}
2018-09-30 16:32:47 +02:00
// getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func getDeviceInfoRequest ( c * xgb . Conn , Screen uint32 ) [ ] byte {
size := 8
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 10 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
return buf
}
2012-05-11 05:57:34 +02:00
// GetDrawableInfoCookie is a cookie used only for GetDrawableInfo requests.
2012-05-10 23:01:42 +02:00
type GetDrawableInfoCookie struct {
* xgb . Cookie
}
2012-05-11 05:57:34 +02:00
// GetDrawableInfo sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling GetDrawableInfoCookie.Reply.
func GetDrawableInfo ( c * xgb . Conn , Screen , Drawable uint32 ) GetDrawableInfoCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2012-05-12 05:58:52 +02:00
panic ( "Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , true )
c . NewRequest ( getDrawableInfoRequest ( c , Screen , Drawable ) , cookie )
return GetDrawableInfoCookie { cookie }
}
2012-05-11 05:57:34 +02:00
// GetDrawableInfoUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2018-09-30 16:32:47 +02:00
func GetDrawableInfoUnchecked ( c * xgb . Conn , Screen , Drawable uint32 ) GetDrawableInfoCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2012-05-12 05:58:52 +02:00
panic ( "Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , true )
c . NewRequest ( getDrawableInfoRequest ( c , Screen , Drawable ) , cookie )
return GetDrawableInfoCookie { cookie }
}
2012-05-11 05:57:34 +02:00
// GetDrawableInfoReply represents the data returned from a GetDrawableInfo request.
2012-05-10 23:01:42 +02:00
type GetDrawableInfoReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2012-05-10 23:01:42 +02:00
// padding: 1 bytes
DrawableTableIndex uint32
DrawableTableStamp uint32
DrawableOriginX int16
DrawableOriginY int16
DrawableSizeW int16
DrawableSizeH int16
NumClipRects uint32
BackX int16
BackY int16
NumBackClipRects uint32
ClipRects [ ] DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8))
2017-01-18 10:52:16 +01:00
BackClipRects [ ] DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8))
2012-05-10 23:01:42 +02:00
}
2012-05-11 05:57:34 +02:00
// Reply blocks and returns the reply data for a GetDrawableInfo request.
2012-05-10 23:01:42 +02:00
func ( cook GetDrawableInfoCookie ) Reply ( ) ( * GetDrawableInfoReply , error ) {
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
return getDrawableInfoReply ( buf ) , nil
}
2012-05-11 05:57:34 +02:00
// getDrawableInfoReply reads a byte slice into a GetDrawableInfoReply value.
2012-05-10 23:01:42 +02:00
func getDrawableInfoReply ( buf [ ] byte ) * GetDrawableInfoReply {
v := new ( GetDrawableInfoReply )
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 . DrawableTableIndex = xgb . Get32 ( buf [ b : ] )
b += 4
v . DrawableTableStamp = xgb . Get32 ( buf [ b : ] )
b += 4
v . DrawableOriginX = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . DrawableOriginY = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . DrawableSizeW = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . DrawableSizeH = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . NumClipRects = xgb . Get32 ( buf [ b : ] )
b += 4
v . BackX = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . BackY = int16 ( xgb . Get16 ( buf [ b : ] ) )
b += 2
v . NumBackClipRects = xgb . Get32 ( buf [ b : ] )
b += 4
v . ClipRects = make ( [ ] DrmClipRect , v . NumClipRects )
b += DrmClipRectReadList ( buf [ b : ] , v . ClipRects )
v . BackClipRects = make ( [ ] DrmClipRect , v . NumBackClipRects )
b += DrmClipRectReadList ( buf [ b : ] , v . BackClipRects )
return v
}
2018-09-30 16:32:47 +02:00
// getDrawableInfoRequest writes a GetDrawableInfo request to a byte slice for transfer.
func getDrawableInfoRequest ( c * xgb . Conn , Screen , Drawable uint32 ) [ ] byte {
2012-05-10 23:01:42 +02:00
size := 12
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
buf [ b ] = 9 // request opcode
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
xgb . Put32 ( buf [ b : ] , Drawable )
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// OpenConnectionCookie is a cookie used only for OpenConnection requests.
type OpenConnectionCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// OpenConnection sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply.
2013-08-12 02:43:26 +02:00
func OpenConnection ( c * xgb . Conn , Screen uint32 ) OpenConnectionCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( openConnectionRequest ( c , Screen ) , cookie )
return OpenConnectionCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// OpenConnectionUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func OpenConnectionUnchecked ( c * xgb . Conn , Screen uint32 ) OpenConnectionCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( openConnectionRequest ( c , Screen ) , cookie )
return OpenConnectionCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// OpenConnectionReply represents the data returned from a OpenConnection request.
type OpenConnectionReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2012-05-10 23:01:42 +02:00
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
SareaHandleLow uint32
SareaHandleHigh uint32
BusIdLen uint32
// padding: 12 bytes
BusId string // size: xgb.Pad((int(BusIdLen) * 1))
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Reply blocks and returns the reply data for a OpenConnection request.
func ( cook OpenConnectionCookie ) Reply ( ) ( * OpenConnectionReply , error ) {
2012-05-10 23:01:42 +02:00
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
2013-08-12 02:43:26 +02:00
return openConnectionReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// openConnectionReply reads a byte slice into a OpenConnectionReply value.
func openConnectionReply ( buf [ ] byte ) * OpenConnectionReply {
v := new ( OpenConnectionReply )
2012-05-10 23:01:42 +02:00
b := 1 // skip reply determinant
b += 1 // padding
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
v . SareaHandleLow = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v . SareaHandleHigh = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v . BusIdLen = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
b += 12 // padding
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
{
byteString := make ( [ ] byte , v . BusIdLen )
copy ( byteString [ : v . BusIdLen ] , buf [ b : ] )
v . BusId = string ( byteString )
2013-12-28 16:02:18 +01:00
b += int ( v . BusIdLen )
2012-05-10 23:01:42 +02:00
}
return v
}
2018-09-30 16:32:47 +02:00
// openConnectionRequest writes a OpenConnection request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func openConnectionRequest ( c * xgb . Conn , Screen uint32 ) [ ] byte {
2012-05-10 23:01:42 +02:00
size := 8
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 2 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
return buf
}
2013-08-12 02:43:26 +02:00
// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests.
type QueryDirectRenderingCapableCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// QueryDirectRenderingCapable sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply.
2013-08-12 02:43:26 +02:00
func QueryDirectRenderingCapable ( c * xgb . Conn , Screen uint32 ) QueryDirectRenderingCapableCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( queryDirectRenderingCapableRequest ( c , Screen ) , cookie )
return QueryDirectRenderingCapableCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// QueryDirectRenderingCapableUnchecked sends an unchecked request.
2012-05-11 05:57:34 +02:00
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2013-08-12 02:43:26 +02:00
func QueryDirectRenderingCapableUnchecked ( c * xgb . Conn , Screen uint32 ) QueryDirectRenderingCapableCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
2012-05-12 05:58:52 +02:00
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , true )
2013-08-12 02:43:26 +02:00
c . NewRequest ( queryDirectRenderingCapableRequest ( c , Screen ) , cookie )
return QueryDirectRenderingCapableCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request.
type QueryDirectRenderingCapableReply struct {
2012-05-11 05:57:34 +02:00
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
2012-05-10 23:01:42 +02:00
// padding: 1 bytes
2013-08-12 02:43:26 +02:00
IsCapable bool
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request.
func ( cook QueryDirectRenderingCapableCookie ) Reply ( ) ( * QueryDirectRenderingCapableReply , error ) {
2012-05-10 23:01:42 +02:00
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
2013-08-12 02:43:26 +02:00
return queryDirectRenderingCapableReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value.
func queryDirectRenderingCapableReply ( buf [ ] byte ) * QueryDirectRenderingCapableReply {
v := new ( QueryDirectRenderingCapableReply )
2012-05-10 23:01:42 +02:00
b := 1 // skip reply determinant
b += 1 // padding
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
b += 4
2013-08-12 02:43:26 +02:00
if buf [ b ] == 1 {
v . IsCapable = true
} else {
v . IsCapable = false
}
b += 1
2012-05-10 23:01:42 +02:00
return v
}
2018-09-30 16:32:47 +02:00
// queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func queryDirectRenderingCapableRequest ( c * xgb . Conn , Screen uint32 ) [ ] byte {
size := 8
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 1 // request opcode
2012-05-10 23:01:42 +02:00
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put32 ( buf [ b : ] , Screen )
b += 4
2013-08-12 02:43:26 +02:00
return buf
}
// QueryVersionCookie is a cookie used only for QueryVersion requests.
type QueryVersionCookie struct {
* xgb . Cookie
}
// QueryVersion sends a checked request.
2018-09-30 16:32:47 +02:00
// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply.
2013-08-12 02:43:26 +02:00
func QueryVersion ( c * xgb . Conn ) QueryVersionCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
}
cookie := c . NewCookie ( true , true )
c . NewRequest ( queryVersionRequest ( c ) , 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 ) QueryVersionCookie {
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
defer c . ExtLock . RUnlock ( )
2013-12-28 16:13:20 +01:00
if _ , ok := c . Extensions [ "XFree86-DRI" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first." )
}
cookie := c . NewCookie ( false , true )
c . NewRequest ( queryVersionRequest ( c ) , 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
DriMajorVersion uint16
DriMinorVersion uint16
DriMinorPatch uint32
}
// 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 . DriMajorVersion = xgb . Get16 ( buf [ b : ] )
b += 2
v . DriMinorVersion = xgb . Get16 ( buf [ b : ] )
b += 2
v . DriMinorPatch = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
return v
}
2018-09-30 16:32:47 +02:00
// queryVersionRequest writes a QueryVersion request to a byte slice for transfer.
2013-08-12 02:43:26 +02:00
func queryVersionRequest ( c * xgb . Conn ) [ ] byte {
size := 4
b := 0
buf := make ( [ ] byte , size )
2016-03-01 15:41:38 +01:00
c . ExtLock . RLock ( )
2013-12-28 16:13:20 +01:00
buf [ b ] = c . Extensions [ "XFree86-DRI" ]
2016-03-01 15:41:38 +01:00
c . ExtLock . RUnlock ( )
2013-08-12 02:43:26 +02:00
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
2012-05-10 23:01:42 +02:00
return buf
}