2012-05-11 02:06:22 +02:00
// Package xf86vidmode is the X client API for the XFree86-VidModeExtension extension.
2012-05-10 23:01:42 +02:00
package xf86vidmode
2013-08-12 02:45:36 +02:00
// This file is automatically generated from xf86vidmode.xml. Edit at your peril!
2012-05-10 23:01:42 +02:00
import (
"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/xproto"
)
// Init must be called before using the XFree86-VidModeExtension extension.
func Init ( c * xgb . Conn ) error {
reply , err := xproto . QueryExtension ( c , 24 , "XFree86-VidModeExtension" ) . Reply ( )
switch {
case err != nil :
return err
case ! reply . Present :
return xgb . Errorf ( "No extension named XFree86-VidModeExtension could be found on on the server." )
}
xgb . ExtLock . Lock ( )
c . Extensions [ "XFree86-VidModeExtension" ] = reply . MajorOpcode
for evNum , fun := range xgb . NewExtEventFuncs [ "XFree86-VidModeExtension" ] {
xgb . NewEventFuncs [ int ( reply . FirstEvent ) + evNum ] = fun
}
for errNum , fun := range xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] {
xgb . NewErrorFuncs [ int ( reply . FirstError ) + errNum ] = fun
}
xgb . ExtLock . Unlock ( )
return nil
}
func init ( ) {
xgb . NewExtEventFuncs [ "XFree86-VidModeExtension" ] = make ( map [ int ] xgb . NewEventFun )
xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] = make ( map [ int ] xgb . NewErrorFun )
}
2012-05-11 05:57:34 +02:00
// BadBadClock is the error number for a BadBadClock.
2012-05-10 23:01:42 +02:00
const BadBadClock = 0
type BadClockError struct {
Sequence uint16
NiceName string
}
2012-05-11 05:57:34 +02:00
// BadClockErrorNew constructs a BadClockError value that implements xgb.Error from a byte slice.
2012-05-10 23:01:42 +02:00
func BadClockErrorNew ( buf [ ] byte ) xgb . Error {
v := BadClockError { }
v . NiceName = "BadClock"
b := 1 // skip error determinant
b += 1 // don't read error number
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
return v
}
2012-05-11 05:57:34 +02:00
// SequenceId returns the sequence id attached to the BadBadClock error.
// This is mostly used internally.
2012-05-10 23:01:42 +02:00
func ( err BadClockError ) SequenceId ( ) uint16 {
return err . Sequence
}
2012-05-11 07:58:52 +02:00
// BadId returns the 'BadValue' number if one exists for the BadBadClock error. If no bad value exists, 0 is returned.
2012-05-10 23:01:42 +02:00
func ( err BadClockError ) BadId ( ) uint32 {
return 0
}
2012-05-11 07:58:52 +02:00
// Error returns a rudimentary string representation of the BadBadClock error.
2012-05-10 23:01:42 +02:00
func ( err BadClockError ) Error ( ) string {
fieldVals := make ( [ ] string , 0 , 0 )
fieldVals = append ( fieldVals , "NiceName: " + err . NiceName )
fieldVals = append ( fieldVals , xgb . Sprintf ( "Sequence: %d" , err . Sequence ) )
return "BadBadClock {" + xgb . StringsJoin ( fieldVals , ", " ) + "}"
}
func init ( ) {
xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] [ 0 ] = BadClockErrorNew
}
2012-05-11 05:57:34 +02:00
// BadBadHTimings is the error number for a BadBadHTimings.
2012-05-10 23:01:42 +02:00
const BadBadHTimings = 1
type BadHTimingsError struct {
Sequence uint16
NiceName string
}
2012-05-11 05:57:34 +02:00
// BadHTimingsErrorNew constructs a BadHTimingsError value that implements xgb.Error from a byte slice.
2012-05-10 23:01:42 +02:00
func BadHTimingsErrorNew ( buf [ ] byte ) xgb . Error {
v := BadHTimingsError { }
v . NiceName = "BadHTimings"
b := 1 // skip error determinant
b += 1 // don't read error number
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
return v
}
2012-05-11 05:57:34 +02:00
// SequenceId returns the sequence id attached to the BadBadHTimings error.
// This is mostly used internally.
2012-05-10 23:01:42 +02:00
func ( err BadHTimingsError ) SequenceId ( ) uint16 {
return err . Sequence
}
2012-05-11 07:58:52 +02:00
// BadId returns the 'BadValue' number if one exists for the BadBadHTimings error. If no bad value exists, 0 is returned.
2012-05-10 23:01:42 +02:00
func ( err BadHTimingsError ) BadId ( ) uint32 {
return 0
}
2012-05-11 07:58:52 +02:00
// Error returns a rudimentary string representation of the BadBadHTimings error.
2012-05-10 23:01:42 +02:00
func ( err BadHTimingsError ) Error ( ) string {
fieldVals := make ( [ ] string , 0 , 0 )
fieldVals = append ( fieldVals , "NiceName: " + err . NiceName )
fieldVals = append ( fieldVals , xgb . Sprintf ( "Sequence: %d" , err . Sequence ) )
return "BadBadHTimings {" + xgb . StringsJoin ( fieldVals , ", " ) + "}"
}
func init ( ) {
xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] [ 1 ] = BadHTimingsErrorNew
}
2012-05-11 05:57:34 +02:00
// BadBadVTimings is the error number for a BadBadVTimings.
2012-05-10 23:01:42 +02:00
const BadBadVTimings = 2
type BadVTimingsError struct {
Sequence uint16
NiceName string
}
2012-05-11 05:57:34 +02:00
// BadVTimingsErrorNew constructs a BadVTimingsError value that implements xgb.Error from a byte slice.
2012-05-10 23:01:42 +02:00
func BadVTimingsErrorNew ( buf [ ] byte ) xgb . Error {
v := BadVTimingsError { }
v . NiceName = "BadVTimings"
b := 1 // skip error determinant
b += 1 // don't read error number
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
return v
}
2012-05-11 05:57:34 +02:00
// SequenceId returns the sequence id attached to the BadBadVTimings error.
// This is mostly used internally.
2012-05-10 23:01:42 +02:00
func ( err BadVTimingsError ) SequenceId ( ) uint16 {
return err . Sequence
}
2012-05-11 07:58:52 +02:00
// BadId returns the 'BadValue' number if one exists for the BadBadVTimings error. If no bad value exists, 0 is returned.
2012-05-10 23:01:42 +02:00
func ( err BadVTimingsError ) BadId ( ) uint32 {
return 0
}
2012-05-11 07:58:52 +02:00
// Error returns a rudimentary string representation of the BadBadVTimings error.
2012-05-10 23:01:42 +02:00
func ( err BadVTimingsError ) Error ( ) string {
fieldVals := make ( [ ] string , 0 , 0 )
fieldVals = append ( fieldVals , "NiceName: " + err . NiceName )
fieldVals = append ( fieldVals , xgb . Sprintf ( "Sequence: %d" , err . Sequence ) )
return "BadBadVTimings {" + xgb . StringsJoin ( fieldVals , ", " ) + "}"
}
func init ( ) {
xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] [ 2 ] = BadVTimingsErrorNew
}
2013-08-12 02:43:26 +02:00
// BadClientNotLocal is the error number for a BadClientNotLocal.
const BadClientNotLocal = 5
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
type ClientNotLocalError struct {
2012-05-10 23:01:42 +02:00
Sequence uint16
NiceName string
}
2013-08-12 02:43:26 +02:00
// ClientNotLocalErrorNew constructs a ClientNotLocalError value that implements xgb.Error from a byte slice.
func ClientNotLocalErrorNew ( buf [ ] byte ) xgb . Error {
v := ClientNotLocalError { }
v . NiceName = "ClientNotLocal"
2012-05-10 23:01:42 +02:00
b := 1 // skip error determinant
b += 1 // don't read error number
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
return v
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadClientNotLocal error.
2012-05-11 05:57:34 +02:00
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func ( err ClientNotLocalError ) SequenceId ( ) uint16 {
2012-05-10 23:01:42 +02:00
return err . Sequence
}
2013-08-12 02:43:26 +02:00
// BadId returns the 'BadValue' number if one exists for the BadClientNotLocal error. If no bad value exists, 0 is returned.
func ( err ClientNotLocalError ) BadId ( ) uint32 {
2012-05-10 23:01:42 +02:00
return 0
}
2013-08-12 02:43:26 +02:00
// Error returns a rudimentary string representation of the BadClientNotLocal error.
2012-05-11 07:58:52 +02:00
2013-08-12 02:43:26 +02:00
func ( err ClientNotLocalError ) Error ( ) string {
2012-05-10 23:01:42 +02:00
fieldVals := make ( [ ] string , 0 , 0 )
fieldVals = append ( fieldVals , "NiceName: " + err . NiceName )
fieldVals = append ( fieldVals , xgb . Sprintf ( "Sequence: %d" , err . Sequence ) )
2013-08-12 02:43:26 +02:00
return "BadClientNotLocal {" + xgb . StringsJoin ( fieldVals , ", " ) + "}"
2012-05-10 23:01:42 +02:00
}
func init ( ) {
2013-08-12 02:43:26 +02:00
xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] [ 5 ] = ClientNotLocalErrorNew
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
const (
ClockFlagProgramable = 1
)
type Dotclock uint32
2012-05-11 05:57:34 +02:00
// BadExtensionDisabled is the error number for a BadExtensionDisabled.
2012-05-10 23:01:42 +02:00
const BadExtensionDisabled = 4
type ExtensionDisabledError struct {
Sequence uint16
NiceName string
}
2012-05-11 05:57:34 +02:00
// ExtensionDisabledErrorNew constructs a ExtensionDisabledError value that implements xgb.Error from a byte slice.
2012-05-10 23:01:42 +02:00
func ExtensionDisabledErrorNew ( buf [ ] byte ) xgb . Error {
v := ExtensionDisabledError { }
v . NiceName = "ExtensionDisabled"
b := 1 // skip error determinant
b += 1 // don't read error number
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
return v
}
2012-05-11 05:57:34 +02:00
// SequenceId returns the sequence id attached to the BadExtensionDisabled error.
// This is mostly used internally.
2012-05-10 23:01:42 +02:00
func ( err ExtensionDisabledError ) SequenceId ( ) uint16 {
return err . Sequence
}
2012-05-11 07:58:52 +02:00
// BadId returns the 'BadValue' number if one exists for the BadExtensionDisabled error. If no bad value exists, 0 is returned.
2012-05-10 23:01:42 +02:00
func ( err ExtensionDisabledError ) BadId ( ) uint32 {
return 0
}
2012-05-11 07:58:52 +02:00
// Error returns a rudimentary string representation of the BadExtensionDisabled error.
2012-05-10 23:01:42 +02:00
func ( err ExtensionDisabledError ) Error ( ) string {
fieldVals := make ( [ ] string , 0 , 0 )
fieldVals = append ( fieldVals , "NiceName: " + err . NiceName )
fieldVals = append ( fieldVals , xgb . Sprintf ( "Sequence: %d" , err . Sequence ) )
return "BadExtensionDisabled {" + xgb . StringsJoin ( fieldVals , ", " ) + "}"
}
func init ( ) {
xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] [ 4 ] = ExtensionDisabledErrorNew
}
2013-08-12 02:43:26 +02:00
const (
ModeFlagPositiveHsync = 1
ModeFlagNegativeHsync = 2
ModeFlagPositiveVsync = 4
ModeFlagNegativeVsync = 8
ModeFlagInterlace = 16
ModeFlagCompositeSync = 32
ModeFlagPositiveCsync = 64
ModeFlagNegativeCsync = 128
ModeFlagHSkew = 256
ModeFlagBroadcast = 512
ModeFlagPixmux = 1024
ModeFlagDoubleClock = 2048
ModeFlagHalfClock = 4096
)
type ModeInfo struct {
Dotclock Dotclock
Hdisplay uint16
Hsyncstart uint16
Hsyncend uint16
Htotal uint16
Hskew uint32
Vdisplay uint16
Vsyncstart uint16
Vsyncend uint16
Vtotal uint16
// padding: 4 bytes
Flags uint32
// padding: 12 bytes
Privsize uint32
}
// ModeInfoRead reads a byte slice into a ModeInfo value.
func ModeInfoRead ( buf [ ] byte , v * ModeInfo ) int {
b := 0
v . Dotclock = Dotclock ( xgb . Get32 ( buf [ b : ] ) )
b += 4
v . Hdisplay = xgb . Get16 ( buf [ b : ] )
b += 2
v . Hsyncstart = xgb . Get16 ( buf [ b : ] )
b += 2
v . Hsyncend = xgb . Get16 ( buf [ b : ] )
b += 2
v . Htotal = xgb . Get16 ( buf [ b : ] )
b += 2
v . Hskew = xgb . Get32 ( buf [ b : ] )
b += 4
v . Vdisplay = xgb . Get16 ( buf [ b : ] )
b += 2
v . Vsyncstart = xgb . Get16 ( buf [ b : ] )
b += 2
v . Vsyncend = xgb . Get16 ( buf [ b : ] )
b += 2
v . Vtotal = xgb . Get16 ( buf [ b : ] )
b += 2
b += 4 // padding
v . Flags = xgb . Get32 ( buf [ b : ] )
b += 4
b += 12 // padding
v . Privsize = xgb . Get32 ( buf [ b : ] )
b += 4
return b
}
// ModeInfoReadList reads a byte slice into a list of ModeInfo values.
func ModeInfoReadList ( buf [ ] byte , dest [ ] ModeInfo ) int {
b := 0
for i := 0 ; i < len ( dest ) ; i ++ {
dest [ i ] = ModeInfo { }
b += ModeInfoRead ( buf [ b : ] , & dest [ i ] )
}
return xgb . Pad ( b )
}
// Bytes writes a ModeInfo value to a byte slice.
func ( v ModeInfo ) Bytes ( ) [ ] byte {
buf := make ( [ ] byte , 48 )
b := 0
xgb . Put32 ( buf [ b : ] , uint32 ( v . Dotclock ) )
b += 4
xgb . Put16 ( buf [ b : ] , v . Hdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , v . Hsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , v . Hsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , v . Htotal )
b += 2
xgb . Put32 ( buf [ b : ] , v . Hskew )
b += 4
xgb . Put16 ( buf [ b : ] , v . Vdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , v . Vsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , v . Vsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , v . Vtotal )
b += 2
b += 4 // padding
xgb . Put32 ( buf [ b : ] , v . Flags )
b += 4
b += 12 // padding
xgb . Put32 ( buf [ b : ] , v . Privsize )
b += 4
return buf
}
// ModeInfoListBytes writes a list of ModeInfo values to a byte slice.
func ModeInfoListBytes ( buf [ ] byte , list [ ] ModeInfo ) int {
b := 0
var structBytes [ ] byte
for _ , item := range list {
structBytes = item . Bytes ( )
copy ( buf [ b : ] , structBytes )
b += xgb . Pad ( len ( structBytes ) )
}
return b
}
// BadModeUnsuitable is the error number for a BadModeUnsuitable.
const BadModeUnsuitable = 3
type ModeUnsuitableError struct {
Sequence uint16
NiceName string
}
// ModeUnsuitableErrorNew constructs a ModeUnsuitableError value that implements xgb.Error from a byte slice.
func ModeUnsuitableErrorNew ( buf [ ] byte ) xgb . Error {
v := ModeUnsuitableError { }
v . NiceName = "ModeUnsuitable"
b := 1 // skip error determinant
b += 1 // don't read error number
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
2012-05-10 23:01:42 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// SequenceId returns the sequence id attached to the BadModeUnsuitable error.
2012-05-11 05:57:34 +02:00
// This is mostly used internally.
2013-08-12 02:43:26 +02:00
func ( err ModeUnsuitableError ) SequenceId ( ) uint16 {
2012-05-10 23:01:42 +02:00
return err . Sequence
}
2013-08-12 02:43:26 +02:00
// BadId returns the 'BadValue' number if one exists for the BadModeUnsuitable error. If no bad value exists, 0 is returned.
func ( err ModeUnsuitableError ) BadId ( ) uint32 {
2012-05-10 23:01:42 +02:00
return 0
}
2013-08-12 02:43:26 +02:00
// Error returns a rudimentary string representation of the BadModeUnsuitable error.
2012-05-11 07:58:52 +02:00
2013-08-12 02:43:26 +02:00
func ( err ModeUnsuitableError ) Error ( ) string {
2012-05-10 23:01:42 +02:00
fieldVals := make ( [ ] string , 0 , 0 )
fieldVals = append ( fieldVals , "NiceName: " + err . NiceName )
fieldVals = append ( fieldVals , xgb . Sprintf ( "Sequence: %d" , err . Sequence ) )
2013-08-12 02:43:26 +02:00
return "BadModeUnsuitable {" + xgb . StringsJoin ( fieldVals , ", " ) + "}"
2012-05-10 23:01:42 +02:00
}
func init ( ) {
2013-08-12 02:43:26 +02:00
xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] [ 3 ] = ModeUnsuitableErrorNew
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
const (
PermissionRead = 1
PermissionWrite = 2
)
type Syncrange uint32
2012-05-11 05:57:34 +02:00
// BadZoomLocked is the error number for a BadZoomLocked.
2012-05-10 23:01:42 +02:00
const BadZoomLocked = 6
type ZoomLockedError struct {
Sequence uint16
NiceName string
}
2012-05-11 05:57:34 +02:00
// ZoomLockedErrorNew constructs a ZoomLockedError value that implements xgb.Error from a byte slice.
2012-05-10 23:01:42 +02:00
func ZoomLockedErrorNew ( buf [ ] byte ) xgb . Error {
v := ZoomLockedError { }
v . NiceName = "ZoomLocked"
b := 1 // skip error determinant
b += 1 // don't read error number
v . Sequence = xgb . Get16 ( buf [ b : ] )
b += 2
return v
}
2012-05-11 05:57:34 +02:00
// SequenceId returns the sequence id attached to the BadZoomLocked error.
// This is mostly used internally.
2012-05-10 23:01:42 +02:00
func ( err ZoomLockedError ) SequenceId ( ) uint16 {
return err . Sequence
}
2012-05-11 07:58:52 +02:00
// BadId returns the 'BadValue' number if one exists for the BadZoomLocked error. If no bad value exists, 0 is returned.
2012-05-10 23:01:42 +02:00
func ( err ZoomLockedError ) BadId ( ) uint32 {
return 0
}
2012-05-11 07:58:52 +02:00
// Error returns a rudimentary string representation of the BadZoomLocked error.
2012-05-10 23:01:42 +02:00
func ( err ZoomLockedError ) Error ( ) string {
fieldVals := make ( [ ] string , 0 , 0 )
fieldVals = append ( fieldVals , "NiceName: " + err . NiceName )
fieldVals = append ( fieldVals , xgb . Sprintf ( "Sequence: %d" , err . Sequence ) )
return "BadZoomLocked {" + xgb . StringsJoin ( fieldVals , ", " ) + "}"
}
func init ( ) {
xgb . NewExtErrorFuncs [ "XFree86-VidModeExtension" ] [ 6 ] = ZoomLockedErrorNew
}
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'
// AddModeLineCookie is a cookie used only for AddModeLine requests.
type AddModeLineCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// AddModeLine sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func AddModeLine ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , AfterDotclock Dotclock , AfterHdisplay uint16 , AfterHsyncstart uint16 , AfterHsyncend uint16 , AfterHtotal uint16 , AfterHskew uint16 , AfterVdisplay uint16 , AfterVsyncstart uint16 , AfterVsyncend uint16 , AfterVtotal uint16 , AfterFlags uint32 , Private [ ] byte ) AddModeLineCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'AddModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
cookie := c . NewCookie ( false , false )
c . NewRequest ( addModeLineRequest ( c , Screen , Dotclock , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , AfterDotclock , AfterHdisplay , AfterHsyncstart , AfterHsyncend , AfterHtotal , AfterHskew , AfterVdisplay , AfterVsyncstart , AfterVsyncend , AfterVtotal , AfterFlags , Private ) , cookie )
return AddModeLineCookie { cookie }
}
// AddModeLineChecked sends a checked request.
// If an error occurs, it can be retrieved using AddModeLineCookie.Check()
func AddModeLineChecked ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , AfterDotclock Dotclock , AfterHdisplay uint16 , AfterHsyncstart uint16 , AfterHsyncend uint16 , AfterHtotal uint16 , AfterHskew uint16 , AfterVdisplay uint16 , AfterVsyncstart uint16 , AfterVsyncend uint16 , AfterVtotal uint16 , AfterFlags uint32 , Private [ ] byte ) AddModeLineCookie {
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'AddModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
cookie := c . NewCookie ( true , false )
c . NewRequest ( addModeLineRequest ( c , Screen , Dotclock , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , AfterDotclock , AfterHdisplay , AfterHsyncstart , AfterHsyncend , AfterHtotal , AfterHskew , AfterVdisplay , AfterVsyncstart , AfterVsyncend , AfterVtotal , AfterFlags , Private ) , cookie )
return AddModeLineCookie { 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 AddModeLineCookie ) Check ( ) error {
return cook . Cookie . Check ( )
}
// Write request to wire for AddModeLine
// addModeLineRequest writes a AddModeLine request to a byte slice.
func addModeLineRequest ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , AfterDotclock Dotclock , AfterHdisplay uint16 , AfterHsyncstart uint16 , AfterHsyncend uint16 , AfterHtotal uint16 , AfterHskew uint16 , AfterVdisplay uint16 , AfterVsyncstart uint16 , AfterVsyncend uint16 , AfterVtotal uint16 , AfterFlags uint32 , Private [ ] byte ) [ ] byte {
size := xgb . Pad ( ( 92 + xgb . Pad ( ( int ( Privsize ) * 1 ) ) ) )
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
buf [ b ] = 7 // 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 : ] , uint32 ( Dotclock ) )
b += 4
xgb . Put16 ( buf [ b : ] , Hdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , Hsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , Hsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Htotal )
b += 2
xgb . Put16 ( buf [ b : ] , Hskew )
b += 2
xgb . Put16 ( buf [ b : ] , Vdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , Vsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , Vsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Vtotal )
b += 2
b += 2 // padding
xgb . Put32 ( buf [ b : ] , Flags )
b += 4
b += 12 // padding
xgb . Put32 ( buf [ b : ] , Privsize )
b += 4
xgb . Put32 ( buf [ b : ] , uint32 ( AfterDotclock ) )
b += 4
xgb . Put16 ( buf [ b : ] , AfterHdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , AfterHsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , AfterHsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , AfterHtotal )
b += 2
xgb . Put16 ( buf [ b : ] , AfterHskew )
b += 2
xgb . Put16 ( buf [ b : ] , AfterVdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , AfterVsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , AfterVsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , AfterVtotal )
b += 2
b += 2 // padding
xgb . Put32 ( buf [ b : ] , AfterFlags )
b += 4
b += 12 // padding
copy ( buf [ b : ] , Private [ : Privsize ] )
b += xgb . Pad ( int ( Privsize ) )
return buf
}
// DeleteModeLineCookie is a cookie used only for DeleteModeLine requests.
type DeleteModeLineCookie struct {
* xgb . Cookie
}
// DeleteModeLine sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func DeleteModeLine ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) DeleteModeLineCookie {
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'DeleteModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
cookie := c . NewCookie ( false , false )
c . NewRequest ( deleteModeLineRequest ( c , Screen , Dotclock , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , Private ) , cookie )
return DeleteModeLineCookie { cookie }
}
// DeleteModeLineChecked sends a checked request.
// If an error occurs, it can be retrieved using DeleteModeLineCookie.Check()
func DeleteModeLineChecked ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) DeleteModeLineCookie {
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'DeleteModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
cookie := c . NewCookie ( true , false )
c . NewRequest ( deleteModeLineRequest ( c , Screen , Dotclock , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , Private ) , cookie )
return DeleteModeLineCookie { 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 DeleteModeLineCookie ) Check ( ) error {
return cook . Cookie . Check ( )
}
// Write request to wire for DeleteModeLine
// deleteModeLineRequest writes a DeleteModeLine request to a byte slice.
func deleteModeLineRequest ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) [ ] byte {
size := xgb . Pad ( ( 52 + xgb . Pad ( ( int ( Privsize ) * 1 ) ) ) )
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
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 : ] , Screen )
b += 4
xgb . Put32 ( buf [ b : ] , uint32 ( Dotclock ) )
b += 4
xgb . Put16 ( buf [ b : ] , Hdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , Hsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , Hsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Htotal )
b += 2
xgb . Put16 ( buf [ b : ] , Hskew )
b += 2
xgb . Put16 ( buf [ b : ] , Vdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , Vsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , Vsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Vtotal )
b += 2
b += 2 // padding
xgb . Put32 ( buf [ b : ] , Flags )
b += 4
b += 12 // padding
xgb . Put32 ( buf [ b : ] , Privsize )
b += 4
copy ( buf [ b : ] , Private [ : Privsize ] )
b += xgb . Pad ( int ( Privsize ) )
return buf
}
// GetAllModeLinesCookie is a cookie used only for GetAllModeLines requests.
type GetAllModeLinesCookie struct {
* xgb . Cookie
}
// GetAllModeLines sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetAllModeLinesCookie.Reply()
func GetAllModeLines ( c * xgb . Conn , Screen uint16 ) GetAllModeLinesCookie {
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'GetAllModeLines' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getAllModeLinesRequest ( c , Screen ) , cookie )
return GetAllModeLinesCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetAllModeLinesUnchecked 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 GetAllModeLinesUnchecked ( c * xgb . Conn , Screen uint16 ) GetAllModeLinesCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetAllModeLines' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getAllModeLinesRequest ( c , Screen ) , cookie )
return GetAllModeLinesCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetAllModeLinesReply represents the data returned from a GetAllModeLines request.
type GetAllModeLinesReply 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
Modecount uint32
// padding: 20 bytes
Modeinfo [ ] ModeInfo // size: xgb.Pad((int(Modecount) * 48))
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 GetAllModeLines request.
func ( cook GetAllModeLinesCookie ) Reply ( ) ( * GetAllModeLinesReply , 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 getAllModeLinesReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// getAllModeLinesReply reads a byte slice into a GetAllModeLinesReply value.
func getAllModeLinesReply ( buf [ ] byte ) * GetAllModeLinesReply {
v := new ( GetAllModeLinesReply )
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 . Modecount = xgb . Get32 ( buf [ b : ] )
b += 4
b += 20 // padding
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Modeinfo = make ( [ ] ModeInfo , v . Modecount )
b += ModeInfoReadList ( buf [ b : ] , v . Modeinfo )
2012-05-10 23:01:42 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Write request to wire for GetAllModeLines
// getAllModeLinesRequest writes a GetAllModeLines request to a byte slice.
func getAllModeLinesRequest ( c * xgb . Conn , Screen uint16 ) [ ] byte {
size := 8
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
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
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Screen )
b += 2
b += 2 // padding
2012-05-10 23:01:42 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// GetDotClocksCookie is a cookie used only for GetDotClocks requests.
type GetDotClocksCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetDotClocks sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetDotClocksCookie.Reply()
func GetDotClocks ( c * xgb . Conn , Screen uint16 ) GetDotClocksCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetDotClocks' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getDotClocksRequest ( c , Screen ) , cookie )
return GetDotClocksCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetDotClocksUnchecked 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 GetDotClocksUnchecked ( c * xgb . Conn , Screen uint16 ) GetDotClocksCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetDotClocks' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getDotClocksRequest ( c , Screen ) , cookie )
return GetDotClocksCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetDotClocksReply represents the data returned from a GetDotClocks request.
type GetDotClocksReply 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
Flags uint32
Clocks uint32
Maxclocks uint32
2012-05-10 23:01:42 +02:00
// padding: 12 bytes
2013-08-12 02:43:26 +02:00
Clock [ ] uint32 // size: xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4))
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 GetDotClocks request.
func ( cook GetDotClocksCookie ) Reply ( ) ( * GetDotClocksReply , 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 getDotClocksReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// getDotClocksReply reads a byte slice into a GetDotClocksReply value.
func getDotClocksReply ( buf [ ] byte ) * GetDotClocksReply {
v := new ( GetDotClocksReply )
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 . Flags = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v . Clocks = xgb . Get32 ( buf [ b : ] )
b += 4
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Maxclocks = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
b += 12 // padding
2013-08-12 02:43:26 +02:00
v . Clock = make ( [ ] uint32 , ( ( 1 - ( int ( v . Flags ) & 1 ) ) * int ( v . Clocks ) ) )
for i := 0 ; i < int ( ( ( 1 - ( int ( v . Flags ) & 1 ) ) * int ( v . Clocks ) ) ) ; i ++ {
v . Clock [ i ] = xgb . Get32 ( buf [ b : ] )
b += 4
}
b = xgb . Pad ( b )
2012-05-10 23:01:42 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Write request to wire for GetDotClocks
// getDotClocksRequest writes a GetDotClocks request to a byte slice.
func getDotClocksRequest ( c * xgb . Conn , Screen uint16 ) [ ] byte {
2012-05-10 23:01:42 +02:00
size := 8
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 13 // 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 . Put16 ( buf [ b : ] , Screen )
b += 2
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// GetGammaCookie is a cookie used only for GetGamma requests.
type GetGammaCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetGamma sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetGammaCookie.Reply()
func GetGamma ( c * xgb . Conn , Screen uint16 ) GetGammaCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getGammaRequest ( c , Screen ) , cookie )
return GetGammaCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetGammaUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetGammaUnchecked ( c * xgb . Conn , Screen uint16 ) GetGammaCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getGammaRequest ( c , Screen ) , cookie )
return GetGammaCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetGammaReply represents the data returned from a GetGamma request.
type GetGammaReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
Red uint32
Green uint32
Blue uint32
// padding: 12 bytes
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 GetGamma request.
func ( cook GetGammaCookie ) Reply ( ) ( * GetGammaReply , error ) {
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
return getGammaReply ( buf ) , nil
}
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
// getGammaReply reads a byte slice into a GetGammaReply value.
func getGammaReply ( buf [ ] byte ) * GetGammaReply {
v := new ( GetGammaReply )
b := 1 // skip reply determinant
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
b += 1 // padding
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Sequence = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v . Red = xgb . Get32 ( buf [ b : ] )
b += 4
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Green = xgb . Get32 ( buf [ b : ] )
b += 4
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Blue = xgb . Get32 ( buf [ b : ] )
b += 4
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
b += 12 // padding
return v
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Write request to wire for GetGamma
// getGammaRequest writes a GetGamma request to a byte slice.
func getGammaRequest ( c * xgb . Conn , Screen uint16 ) [ ] byte {
size := 32
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 16 // 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 . Put16 ( buf [ b : ] , Screen )
b += 2
2013-08-12 02:43:26 +02:00
b += 26 // padding
2012-05-10 23:01:42 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// GetGammaRampCookie is a cookie used only for GetGammaRamp requests.
type GetGammaRampCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetGammaRamp sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetGammaRampCookie.Reply()
func GetGammaRamp ( c * xgb . Conn , Screen uint16 , Size uint16 ) GetGammaRampCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getGammaRampRequest ( c , Screen , Size ) , cookie )
return GetGammaRampCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetGammaRampUnchecked 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 GetGammaRampUnchecked ( c * xgb . Conn , Screen uint16 , Size uint16 ) GetGammaRampCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getGammaRampRequest ( c , Screen , Size ) , cookie )
return GetGammaRampCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetGammaRampReply represents the data returned from a GetGammaRamp request.
type GetGammaRampReply 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
Size uint16
// padding: 22 bytes
Red [ ] uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2))
Green [ ] uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2))
Blue [ ] uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2))
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 GetGammaRamp request.
func ( cook GetGammaRampCookie ) Reply ( ) ( * GetGammaRampReply , 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 getGammaRampReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// getGammaRampReply reads a byte slice into a GetGammaRampReply value.
func getGammaRampReply ( buf [ ] byte ) * GetGammaRampReply {
v := new ( GetGammaRampReply )
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 . Size = xgb . Get16 ( buf [ b : ] )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
b += 22 // padding
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Red = make ( [ ] uint16 , ( ( int ( v . Size ) + 1 ) & - 2 ) )
for i := 0 ; i < int ( ( ( int ( v . Size ) + 1 ) & - 2 ) ) ; i ++ {
v . Red [ i ] = xgb . Get16 ( buf [ b : ] )
b += 2
2012-05-10 23:01:42 +02:00
}
b = xgb . Pad ( b )
2013-08-12 02:43:26 +02:00
v . Green = make ( [ ] uint16 , ( ( int ( v . Size ) + 1 ) & - 2 ) )
for i := 0 ; i < int ( ( ( int ( v . Size ) + 1 ) & - 2 ) ) ; i ++ {
v . Green [ i ] = xgb . Get16 ( buf [ b : ] )
b += 2
2012-05-10 23:01:42 +02:00
}
b = xgb . Pad ( b )
2013-08-12 02:43:26 +02:00
v . Blue = make ( [ ] uint16 , ( ( int ( v . Size ) + 1 ) & - 2 ) )
for i := 0 ; i < int ( ( ( int ( v . Size ) + 1 ) & - 2 ) ) ; i ++ {
v . Blue [ i ] = xgb . Get16 ( buf [ b : ] )
b += 2
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
b = xgb . Pad ( b )
2012-05-10 23:01:42 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Write request to wire for GetGammaRamp
// getGammaRampRequest writes a GetGammaRamp request to a byte slice.
func getGammaRampRequest ( c * xgb . Conn , Screen uint16 , Size uint16 ) [ ] byte {
2012-05-10 23:01:42 +02:00
size := 8
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 17 // 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 . Put16 ( buf [ b : ] , Screen )
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Size )
2012-05-10 23:01:42 +02:00
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// GetGammaRampSizeCookie is a cookie used only for GetGammaRampSize requests.
type GetGammaRampSizeCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetGammaRampSize sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetGammaRampSizeCookie.Reply()
func GetGammaRampSize ( c * xgb . Conn , Screen uint16 ) GetGammaRampSizeCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetGammaRampSize' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getGammaRampSizeRequest ( c , Screen ) , cookie )
return GetGammaRampSizeCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetGammaRampSizeUnchecked 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 GetGammaRampSizeUnchecked ( c * xgb . Conn , Screen uint16 ) GetGammaRampSizeCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetGammaRampSize' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getGammaRampSizeRequest ( c , Screen ) , cookie )
return GetGammaRampSizeCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetGammaRampSizeReply represents the data returned from a GetGammaRampSize request.
type GetGammaRampSizeReply 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
Size uint16
// padding: 22 bytes
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 GetGammaRampSize request.
func ( cook GetGammaRampSizeCookie ) Reply ( ) ( * GetGammaRampSizeReply , 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 getGammaRampSizeReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// getGammaRampSizeReply reads a byte slice into a GetGammaRampSizeReply value.
func getGammaRampSizeReply ( buf [ ] byte ) * GetGammaRampSizeReply {
v := new ( GetGammaRampSizeReply )
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 . Size = xgb . Get16 ( buf [ b : ] )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
b += 22 // padding
2012-05-10 23:01:42 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Write request to wire for GetGammaRampSize
// getGammaRampSizeRequest writes a GetGammaRampSize request to a byte slice.
func getGammaRampSizeRequest ( c * xgb . Conn , Screen uint16 ) [ ] byte {
2012-05-10 23:01:42 +02:00
size := 8
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 19 // 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 . Put16 ( buf [ b : ] , Screen )
b += 2
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// GetModeLineCookie is a cookie used only for GetModeLine requests.
type GetModeLineCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetModeLine sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetModeLineCookie.Reply()
func GetModeLine ( c * xgb . Conn , Screen uint16 ) GetModeLineCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getModeLineRequest ( c , Screen ) , cookie )
return GetModeLineCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetModeLineUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetModeLineUnchecked ( c * xgb . Conn , Screen uint16 ) GetModeLineCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getModeLineRequest ( c , Screen ) , cookie )
return GetModeLineCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetModeLineReply represents the data returned from a GetModeLine request.
type GetModeLineReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
Dotclock Dotclock
Hdisplay uint16
Hsyncstart uint16
Hsyncend uint16
Htotal uint16
Hskew uint16
Vdisplay uint16
Vsyncstart uint16
Vsyncend uint16
Vtotal uint16
// padding: 2 bytes
Flags uint32
// padding: 12 bytes
Privsize uint32
Private [ ] byte // size: xgb.Pad((int(Privsize) * 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 GetModeLine request.
func ( cook GetModeLineCookie ) Reply ( ) ( * GetModeLineReply , error ) {
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
return getModeLineReply ( buf ) , nil
}
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
// getModeLineReply reads a byte slice into a GetModeLineReply value.
func getModeLineReply ( buf [ ] byte ) * GetModeLineReply {
v := new ( GetModeLineReply )
b := 1 // skip reply determinant
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
b += 1 // padding
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Sequence = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v . Dotclock = Dotclock ( xgb . Get32 ( buf [ b : ] ) )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v . Hdisplay = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Hsyncstart = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Hsyncend = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Htotal = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Hskew = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Vdisplay = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Vsyncstart = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Vsyncend = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Vtotal = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
b += 2 // padding
2013-08-12 02:43:26 +02:00
v . Flags = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
b += 12 // padding
2013-08-12 02:43:26 +02:00
v . Privsize = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
v . Private = make ( [ ] byte , v . Privsize )
copy ( v . Private [ : v . Privsize ] , buf [ b : ] )
b += xgb . Pad ( int ( v . Privsize ) )
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
return v
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Write request to wire for GetModeLine
// getModeLineRequest writes a GetModeLine request to a byte slice.
func getModeLineRequest ( c * xgb . Conn , Screen uint16 ) [ ] byte {
size := 8
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
2013-08-12 02:43:26 +02:00
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
buf [ b ] = 1 // request opcode
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Screen )
2012-05-10 23:01:42 +02:00
b += 2
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// GetMonitorCookie is a cookie used only for GetMonitor requests.
type GetMonitorCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetMonitor sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetMonitorCookie.Reply()
func GetMonitor ( c * xgb . Conn , Screen uint16 ) GetMonitorCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetMonitor' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getMonitorRequest ( c , Screen ) , cookie )
return GetMonitorCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetMonitorUnchecked 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 GetMonitorUnchecked ( c * xgb . Conn , Screen uint16 ) GetMonitorCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetMonitor' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getMonitorRequest ( c , Screen ) , cookie )
return GetMonitorCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetMonitorReply represents the data returned from a GetMonitor request.
type GetMonitorReply 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
VendorLength byte
ModelLength byte
NumHsync byte
NumVsync byte
2012-05-10 23:01:42 +02:00
// padding: 20 bytes
2013-08-12 02:43:26 +02:00
Hsync [ ] Syncrange // size: xgb.Pad((int(NumHsync) * 4))
Vsync [ ] Syncrange // size: xgb.Pad((int(NumVsync) * 4))
Vendor string // size: xgb.Pad((int(VendorLength) * 1))
AlignmentPad [ ] byte // size: xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1))
Model string // size: xgb.Pad((int(ModelLength) * 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 GetMonitor request.
func ( cook GetMonitorCookie ) Reply ( ) ( * GetMonitorReply , 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 getMonitorReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// getMonitorReply reads a byte slice into a GetMonitorReply value.
func getMonitorReply ( buf [ ] byte ) * GetMonitorReply {
v := new ( GetMonitorReply )
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 . VendorLength = buf [ b ]
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . ModelLength = buf [ b ]
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . NumHsync = buf [ b ]
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
v . NumVsync = buf [ b ]
2012-05-10 23:01:42 +02:00
b += 1
2013-08-12 02:43:26 +02:00
b += 20 // padding
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Hsync = make ( [ ] Syncrange , v . NumHsync )
for i := 0 ; i < int ( v . NumHsync ) ; i ++ {
v . Hsync [ i ] = Syncrange ( xgb . Get32 ( buf [ b : ] ) )
b += 4
}
b = xgb . Pad ( b )
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Vsync = make ( [ ] Syncrange , v . NumVsync )
for i := 0 ; i < int ( v . NumVsync ) ; i ++ {
v . Vsync [ i ] = Syncrange ( xgb . Get32 ( buf [ b : ] ) )
b += 4
}
b = xgb . Pad ( b )
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
{
byteString := make ( [ ] byte , v . VendorLength )
copy ( byteString [ : v . VendorLength ] , buf [ b : ] )
v . Vendor = string ( byteString )
b += xgb . Pad ( int ( v . VendorLength ) )
}
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . AlignmentPad = make ( [ ] byte , ( ( ( int ( v . VendorLength ) + 3 ) & - 4 ) - int ( v . VendorLength ) ) )
copy ( v . AlignmentPad [ : ( ( ( int ( v . VendorLength ) + 3 ) & - 4 ) - int ( v . VendorLength ) ) ] , buf [ b : ] )
b += xgb . Pad ( int ( ( ( ( int ( v . VendorLength ) + 3 ) & - 4 ) - int ( v . VendorLength ) ) ) )
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
{
byteString := make ( [ ] byte , v . ModelLength )
copy ( byteString [ : v . ModelLength ] , buf [ b : ] )
v . Model = string ( byteString )
b += xgb . Pad ( int ( v . ModelLength ) )
}
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
return v
}
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
// Write request to wire for GetMonitor
// getMonitorRequest writes a GetMonitor request to a byte slice.
func getMonitorRequest ( c * xgb . Conn , Screen uint16 ) [ ] byte {
size := 8
b := 0
buf := make ( [ ] byte , size )
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
buf [ b ] = 4 // request opcode
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Screen )
2012-05-10 23:01:42 +02:00
b += 2
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// GetPermissionsCookie is a cookie used only for GetPermissions requests.
type GetPermissionsCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// GetPermissions sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetPermissionsCookie.Reply()
func GetPermissions ( c * xgb . Conn , Screen uint16 ) GetPermissionsCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetPermissions' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getPermissionsRequest ( c , Screen ) , cookie )
return GetPermissionsCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetPermissionsUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetPermissionsUnchecked ( c * xgb . Conn , Screen uint16 ) GetPermissionsCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'GetPermissions' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( getPermissionsRequest ( c , Screen ) , cookie )
return GetPermissionsCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// GetPermissionsReply represents the data returned from a GetPermissions request.
type GetPermissionsReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
Permissions uint32
// padding: 20 bytes
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 GetPermissions request.
func ( cook GetPermissionsCookie ) Reply ( ) ( * GetPermissionsReply , error ) {
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
return getPermissionsReply ( buf ) , nil
}
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
// getPermissionsReply reads a byte slice into a GetPermissionsReply value.
func getPermissionsReply ( buf [ ] byte ) * GetPermissionsReply {
v := new ( GetPermissionsReply )
b := 1 // skip reply determinant
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
b += 1 // padding
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Sequence = xgb . Get16 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
v . Length = xgb . Get32 ( buf [ b : ] ) // 4-byte units
b += 4
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . Permissions = xgb . Get32 ( buf [ b : ] )
b += 4
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
b += 20 // padding
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
return v
}
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
// Write request to wire for GetPermissions
// getPermissionsRequest writes a GetPermissions request to a byte slice.
func getPermissionsRequest ( c * xgb . Conn , Screen uint16 ) [ ] byte {
size := 8
b := 0
buf := make ( [ ] byte , size )
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
buf [ b ] = 20 // request opcode
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Screen )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
b += 2 // padding
2012-05-10 23:01:42 +02:00
return buf
}
2012-05-11 05:57:34 +02:00
// GetViewPortCookie is a cookie used only for GetViewPort requests.
2012-05-10 23:01:42 +02:00
type GetViewPortCookie struct {
* xgb . Cookie
}
2012-05-11 05:57:34 +02:00
// GetViewPort sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetViewPortCookie.Reply()
2012-05-10 23:01:42 +02:00
func GetViewPort ( c * xgb . Conn , Screen uint16 ) GetViewPortCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'GetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , true )
c . NewRequest ( getViewPortRequest ( c , Screen ) , cookie )
return GetViewPortCookie { cookie }
}
2012-05-11 05:57:34 +02:00
// GetViewPortUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2012-05-10 23:01:42 +02:00
func GetViewPortUnchecked ( c * xgb . Conn , Screen uint16 ) GetViewPortCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'GetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , true )
c . NewRequest ( getViewPortRequest ( c , Screen ) , cookie )
return GetViewPortCookie { cookie }
}
2012-05-11 05:57:34 +02:00
// GetViewPortReply represents the data returned from a GetViewPort request.
2012-05-10 23:01:42 +02:00
type GetViewPortReply 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
X uint32
Y uint32
// padding: 16 bytes
}
2012-05-11 05:57:34 +02:00
// Reply blocks and returns the reply data for a GetViewPort request.
2012-05-10 23:01:42 +02:00
func ( cook GetViewPortCookie ) Reply ( ) ( * GetViewPortReply , error ) {
buf , err := cook . Cookie . Reply ( )
if err != nil {
return nil , err
}
if buf == nil {
return nil , nil
}
return getViewPortReply ( buf ) , nil
}
2012-05-11 05:57:34 +02:00
// getViewPortReply reads a byte slice into a GetViewPortReply value.
2012-05-10 23:01:42 +02:00
func getViewPortReply ( buf [ ] byte ) * GetViewPortReply {
v := new ( GetViewPortReply )
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 . X = xgb . Get32 ( buf [ b : ] )
b += 4
v . Y = xgb . Get32 ( buf [ b : ] )
b += 4
b += 16 // padding
return v
}
// Write request to wire for GetViewPort
2012-05-11 05:57:34 +02:00
// getViewPortRequest writes a GetViewPort request to a byte slice.
2012-05-10 23:01:42 +02:00
func getViewPortRequest ( c * xgb . Conn , Screen uint16 ) [ ] byte {
size := 8
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
buf [ b ] = 11 // request opcode
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put16 ( buf [ b : ] , Screen )
b += 2
b += 2 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// LockModeSwitchCookie is a cookie used only for LockModeSwitch requests.
type LockModeSwitchCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// LockModeSwitch 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 LockModeSwitch ( c * xgb . Conn , Screen uint16 , Lock uint16 ) LockModeSwitchCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'LockModeSwitch' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( lockModeSwitchRequest ( c , Screen , Lock ) , cookie )
return LockModeSwitchCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// LockModeSwitchChecked sends a checked request.
// If an error occurs, it can be retrieved using LockModeSwitchCookie.Check()
func LockModeSwitchChecked ( c * xgb . Conn , Screen uint16 , Lock uint16 ) LockModeSwitchCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'LockModeSwitch' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( lockModeSwitchRequest ( c , Screen , Lock ) , cookie )
return LockModeSwitchCookie { 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 LockModeSwitchCookie ) Check ( ) error {
2012-05-10 23:01:42 +02:00
return cook . Cookie . Check ( )
}
2013-08-12 02:43:26 +02:00
// Write request to wire for LockModeSwitch
// lockModeSwitchRequest writes a LockModeSwitch request to a byte slice.
func lockModeSwitchRequest ( c * xgb . Conn , Screen uint16 , Lock uint16 ) [ ] byte {
size := 8
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
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 . Put16 ( buf [ b : ] , Screen )
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Lock )
b += 2
return buf
}
// ModModeLineCookie is a cookie used only for ModModeLine requests.
type ModModeLineCookie struct {
* xgb . Cookie
}
// ModModeLine sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ModModeLine ( c * xgb . Conn , Screen uint32 , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) ModModeLineCookie {
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'ModModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
cookie := c . NewCookie ( false , false )
c . NewRequest ( modModeLineRequest ( c , Screen , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , Private ) , cookie )
return ModModeLineCookie { cookie }
}
// ModModeLineChecked sends a checked request.
// If an error occurs, it can be retrieved using ModModeLineCookie.Check()
func ModModeLineChecked ( c * xgb . Conn , Screen uint32 , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) ModModeLineCookie {
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'ModModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
cookie := c . NewCookie ( true , false )
c . NewRequest ( modModeLineRequest ( c , Screen , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , Private ) , cookie )
return ModModeLineCookie { 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 ModModeLineCookie ) Check ( ) error {
return cook . Cookie . Check ( )
}
// Write request to wire for ModModeLine
// modModeLineRequest writes a ModModeLine request to a byte slice.
func modModeLineRequest ( c * xgb . Conn , Screen uint32 , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) [ ] byte {
size := xgb . Pad ( ( 48 + xgb . Pad ( ( int ( Privsize ) * 1 ) ) ) )
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
buf [ b ] = 2 // 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 . Put16 ( buf [ b : ] , Hdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , Hsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , Hsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Htotal )
b += 2
xgb . Put16 ( buf [ b : ] , Hskew )
b += 2
xgb . Put16 ( buf [ b : ] , Vdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , Vsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , Vsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Vtotal )
b += 2
2012-05-10 23:01:42 +02:00
b += 2 // padding
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Flags )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
b += 12 // padding
xgb . Put32 ( buf [ b : ] , Privsize )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
copy ( buf [ b : ] , Private [ : Privsize ] )
b += xgb . Pad ( int ( Privsize ) )
2012-05-10 23:01:42 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// QueryVersionCookie is a cookie used only for QueryVersion requests.
type QueryVersionCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// 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 ) QueryVersionCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( queryVersionRequest ( c ) , cookie )
return QueryVersionCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// QueryVersionUnchecked 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 QueryVersionUnchecked ( c * xgb . Conn ) QueryVersionCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( queryVersionRequest ( c ) , cookie )
return QueryVersionCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// QueryVersionReply represents the data returned from a QueryVersion request.
type QueryVersionReply 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
MajorVersion uint16
MinorVersion uint16
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 QueryVersion request.
func ( cook QueryVersionCookie ) Reply ( ) ( * QueryVersionReply , 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 queryVersionReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// queryVersionReply reads a byte slice into a QueryVersionReply value.
func queryVersionReply ( buf [ ] byte ) * QueryVersionReply {
v := new ( QueryVersionReply )
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 . MajorVersion = xgb . Get16 ( buf [ b : ] )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
v . MinorVersion = xgb . Get16 ( buf [ b : ] )
b += 2
2012-05-10 23:01:42 +02:00
return v
}
2013-08-12 02:43:26 +02:00
// Write request to wire for QueryVersion
// queryVersionRequest writes a QueryVersion request to a byte slice.
func queryVersionRequest ( c * xgb . Conn ) [ ] byte {
size := 4
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 0 // 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
return buf
}
2012-05-11 05:57:34 +02:00
// SetClientVersionCookie is a cookie used only for SetClientVersion requests.
2012-05-10 23:01:42 +02:00
type SetClientVersionCookie struct {
* xgb . Cookie
}
2012-05-11 05:57:34 +02:00
// SetClientVersion sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2012-05-10 23:01:42 +02:00
func SetClientVersion ( c * xgb . Conn , Major uint16 , Minor uint16 ) SetClientVersionCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'SetClientVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , false )
c . NewRequest ( setClientVersionRequest ( c , Major , Minor ) , cookie )
return SetClientVersionCookie { cookie }
}
2012-05-11 05:57:34 +02:00
// SetClientVersionChecked sends a checked request.
// If an error occurs, it can be retrieved using SetClientVersionCookie.Check()
2012-05-10 23:01:42 +02:00
func SetClientVersionChecked ( c * xgb . Conn , Major uint16 , Minor uint16 ) SetClientVersionCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'SetClientVersion' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , false )
c . NewRequest ( setClientVersionRequest ( c , Major , Minor ) , cookie )
return SetClientVersionCookie { cookie }
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
2012-05-10 23:01:42 +02:00
func ( cook SetClientVersionCookie ) Check ( ) error {
return cook . Cookie . Check ( )
}
// Write request to wire for SetClientVersion
2012-05-11 05:57:34 +02:00
// setClientVersionRequest writes a SetClientVersion request to a byte slice.
2012-05-10 23:01:42 +02:00
func setClientVersionRequest ( c * xgb . Conn , Major uint16 , Minor uint16 ) [ ] byte {
size := 8
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
buf [ b ] = 14 // request opcode
b += 1
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
b += 2
xgb . Put16 ( buf [ b : ] , Major )
b += 2
xgb . Put16 ( buf [ b : ] , Minor )
b += 2
return buf
}
2012-05-11 05:57:34 +02:00
// SetGammaCookie is a cookie used only for SetGamma requests.
2012-05-10 23:01:42 +02:00
type SetGammaCookie struct {
* xgb . Cookie
}
2012-05-11 05:57:34 +02:00
// SetGamma sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
2012-05-10 23:01:42 +02:00
func SetGamma ( c * xgb . Conn , Screen uint16 , Red uint32 , Green uint32 , Blue uint32 ) SetGammaCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'SetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( false , false )
c . NewRequest ( setGammaRequest ( c , Screen , Red , Green , Blue ) , cookie )
return SetGammaCookie { cookie }
}
2012-05-11 05:57:34 +02:00
// SetGammaChecked sends a checked request.
// If an error occurs, it can be retrieved using SetGammaCookie.Check()
2012-05-10 23:01:42 +02:00
func SetGammaChecked ( c * xgb . Conn , Screen uint16 , Red uint32 , Green uint32 , Blue uint32 ) SetGammaCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'SetGamma' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.Init(connObj) must be called first." )
}
2012-05-10 23:01:42 +02:00
cookie := c . NewCookie ( true , false )
c . NewRequest ( setGammaRequest ( c , Screen , Red , Green , Blue ) , cookie )
return SetGammaCookie { cookie }
}
2012-05-11 05:57:34 +02:00
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
2012-05-10 23:01:42 +02:00
func ( cook SetGammaCookie ) Check ( ) error {
return cook . Cookie . Check ( )
}
// Write request to wire for SetGamma
2012-05-11 05:57:34 +02:00
// setGammaRequest writes a SetGamma request to a byte slice.
2012-05-10 23:01:42 +02:00
func setGammaRequest ( c * xgb . Conn , Screen uint16 , Red uint32 , Green uint32 , Blue uint32 ) [ ] byte {
size := 32
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
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 . Put16 ( buf [ b : ] , Screen )
b += 2
b += 2 // padding
xgb . Put32 ( buf [ b : ] , Red )
b += 4
xgb . Put32 ( buf [ b : ] , Green )
b += 4
xgb . Put32 ( buf [ b : ] , Blue )
b += 4
b += 12 // padding
return buf
}
2013-08-12 02:43:26 +02:00
// SetGammaRampCookie is a cookie used only for SetGammaRamp requests.
type SetGammaRampCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// SetGammaRamp 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 SetGammaRamp ( c * xgb . Conn , Screen uint16 , Size uint16 , Red [ ] uint16 , Green [ ] uint16 , Blue [ ] uint16 ) SetGammaRampCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'SetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( setGammaRampRequest ( c , Screen , Size , Red , Green , Blue ) , cookie )
return SetGammaRampCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// SetGammaRampChecked sends a checked request.
// If an error occurs, it can be retrieved using SetGammaRampCookie.Check()
func SetGammaRampChecked ( c * xgb . Conn , Screen uint16 , Size uint16 , Red [ ] uint16 , Green [ ] uint16 , Blue [ ] uint16 ) SetGammaRampCookie {
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'SetGammaRamp' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( setGammaRampRequest ( c , Screen , Size , Red , Green , Blue ) , cookie )
return SetGammaRampCookie { 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 SetGammaRampCookie ) Check ( ) error {
return cook . Cookie . Check ( )
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Write request to wire for SetGammaRamp
// setGammaRampRequest writes a SetGammaRamp request to a byte slice.
func setGammaRampRequest ( c * xgb . Conn , Screen uint16 , Size uint16 , Red [ ] uint16 , Green [ ] uint16 , Blue [ ] uint16 ) [ ] byte {
size := xgb . Pad ( ( ( ( 8 + xgb . Pad ( ( ( ( int ( Size ) + 1 ) & - 2 ) * 2 ) ) ) + xgb . Pad ( ( ( ( int ( Size ) + 1 ) & - 2 ) * 2 ) ) ) + xgb . Pad ( ( ( ( int ( Size ) + 1 ) & - 2 ) * 2 ) ) ) )
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 18 // 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 . Put16 ( buf [ b : ] , Screen )
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Size )
b += 2
for i := 0 ; i < int ( ( ( int ( Size ) + 1 ) & - 2 ) ) ; i ++ {
xgb . Put16 ( buf [ b : ] , Red [ i ] )
b += 2
}
b = xgb . Pad ( b )
for i := 0 ; i < int ( ( ( int ( Size ) + 1 ) & - 2 ) ) ; i ++ {
xgb . Put16 ( buf [ b : ] , Green [ i ] )
b += 2
}
b = xgb . Pad ( b )
for i := 0 ; i < int ( ( ( int ( Size ) + 1 ) & - 2 ) ) ; i ++ {
xgb . Put16 ( buf [ b : ] , Blue [ i ] )
b += 2
}
b = xgb . Pad ( b )
2012-05-10 23:01:42 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// SetViewPortCookie is a cookie used only for SetViewPort requests.
type SetViewPortCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// SetViewPort 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 SetViewPort ( c * xgb . Conn , Screen uint16 , X uint32 , Y uint32 ) SetViewPortCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'SetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( setViewPortRequest ( c , Screen , X , Y ) , cookie )
return SetViewPortCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// SetViewPortChecked sends a checked request.
// If an error occurs, it can be retrieved using SetViewPortCookie.Check()
func SetViewPortChecked ( c * xgb . Conn , Screen uint16 , X uint32 , Y uint32 ) SetViewPortCookie {
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
panic ( "Cannot issue request 'SetViewPort' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( setViewPortRequest ( c , Screen , X , Y ) , cookie )
return SetViewPortCookie { 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 SetViewPortCookie ) Check ( ) error {
return cook . Cookie . Check ( )
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Write request to wire for SetViewPort
// setViewPortRequest writes a SetViewPort request to a byte slice.
func setViewPortRequest ( c * xgb . Conn , Screen uint16 , X uint32 , Y uint32 ) [ ] byte {
size := 16
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 12 // 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 . Put16 ( buf [ b : ] , Screen )
b += 2
2013-08-12 02:43:26 +02:00
b += 2 // padding
xgb . Put32 ( buf [ b : ] , X )
b += 4
xgb . Put32 ( buf [ b : ] , Y )
b += 4
2012-05-10 23:01:42 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// SwitchModeCookie is a cookie used only for SwitchMode requests.
type SwitchModeCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// SwitchMode 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 SwitchMode ( c * xgb . Conn , Screen uint16 , Zoom uint16 ) SwitchModeCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'SwitchMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( switchModeRequest ( c , Screen , Zoom ) , cookie )
return SwitchModeCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// SwitchModeChecked sends a checked request.
// If an error occurs, it can be retrieved using SwitchModeCookie.Check()
func SwitchModeChecked ( c * xgb . Conn , Screen uint16 , Zoom uint16 ) SwitchModeCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'SwitchMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( switchModeRequest ( c , Screen , Zoom ) , cookie )
return SwitchModeCookie { 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 SwitchModeCookie ) Check ( ) error {
2012-05-10 23:01:42 +02:00
return cook . Cookie . Check ( )
}
2013-08-12 02:43:26 +02:00
// Write request to wire for SwitchMode
// switchModeRequest writes a SwitchMode request to a byte slice.
func switchModeRequest ( c * xgb . Conn , Screen uint16 , Zoom uint16 ) [ ] byte {
size := 8
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
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 . Put16 ( buf [ b : ] , Screen )
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Zoom )
2012-05-10 23:01:42 +02:00
b += 2
return buf
}
2013-08-12 02:43:26 +02:00
// SwitchToModeCookie is a cookie used only for SwitchToMode requests.
type SwitchToModeCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// SwitchToMode sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func SwitchToMode ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) SwitchToModeCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'SwitchToMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( switchToModeRequest ( c , Screen , Dotclock , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , Private ) , cookie )
return SwitchToModeCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// SwitchToModeChecked sends a checked request.
// If an error occurs, it can be retrieved using SwitchToModeCookie.Check()
func SwitchToModeChecked ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) SwitchToModeCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'SwitchToMode' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 , false )
c . NewRequest ( switchToModeRequest ( c , Screen , Dotclock , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , Private ) , cookie )
return SwitchToModeCookie { 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 SwitchToModeCookie ) Check ( ) error {
return cook . Cookie . Check ( )
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// Write request to wire for SwitchToMode
// switchToModeRequest writes a SwitchToMode request to a byte slice.
func switchToModeRequest ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) [ ] byte {
size := xgb . Pad ( ( 52 + xgb . Pad ( ( int ( Privsize ) * 1 ) ) ) )
b := 0
buf := make ( [ ] byte , size )
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
buf [ b ] = 10 // request opcode
b += 1
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , uint16 ( size / 4 ) ) // write request size in 4-byte units
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Screen )
2012-05-10 23:01:42 +02:00
b += 4
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , uint32 ( Dotclock ) )
b += 4
xgb . Put16 ( buf [ b : ] , Hdisplay )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Hsyncstart )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Hsyncend )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Htotal )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Hskew )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Vdisplay )
b += 2
2012-05-10 23:01:42 +02:00
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Vsyncstart )
2012-05-10 23:01:42 +02:00
b += 2
2013-08-12 02:43:26 +02:00
xgb . Put16 ( buf [ b : ] , Vsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Vtotal )
2012-05-10 23:01:42 +02:00
b += 2
b += 2 // padding
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Flags )
b += 4
b += 12 // padding
xgb . Put32 ( buf [ b : ] , Privsize )
b += 4
copy ( buf [ b : ] , Private [ : Privsize ] )
b += xgb . Pad ( int ( Privsize ) )
2012-05-10 23:01:42 +02:00
return buf
}
2013-08-12 02:43:26 +02:00
// ValidateModeLineCookie is a cookie used only for ValidateModeLine requests.
type ValidateModeLineCookie struct {
2012-05-10 23:01:42 +02:00
* xgb . Cookie
}
2013-08-12 02:43:26 +02:00
// ValidateModeLine sends a checked request.
// If an error occurs, it will be returned with the reply by calling ValidateModeLineCookie.Reply()
func ValidateModeLine ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) ValidateModeLineCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'ValidateModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( validateModeLineRequest ( c , Screen , Dotclock , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , Private ) , cookie )
return ValidateModeLineCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// ValidateModeLineUnchecked 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 ValidateModeLineUnchecked ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) ValidateModeLineCookie {
2012-05-12 05:58:52 +02:00
if _ , ok := c . Extensions [ "XFREE86-VIDMODEEXTENSION" ] ; ! ok {
2013-08-12 02:43:26 +02:00
panic ( "Cannot issue request 'ValidateModeLine' using the uninitialized extension 'XFree86-VidModeExtension'. xf86vidmode.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 ( validateModeLineRequest ( c , Screen , Dotclock , Hdisplay , Hsyncstart , Hsyncend , Htotal , Hskew , Vdisplay , Vsyncstart , Vsyncend , Vtotal , Flags , Privsize , Private ) , cookie )
return ValidateModeLineCookie { cookie }
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// ValidateModeLineReply represents the data returned from a ValidateModeLine request.
type ValidateModeLineReply 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
Status uint32
2012-05-10 23:01:42 +02:00
// padding: 20 bytes
}
2013-08-12 02:43:26 +02:00
// Reply blocks and returns the reply data for a ValidateModeLine request.
func ( cook ValidateModeLineCookie ) Reply ( ) ( * ValidateModeLineReply , 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 validateModeLineReply ( buf ) , nil
2012-05-10 23:01:42 +02:00
}
2013-08-12 02:43:26 +02:00
// validateModeLineReply reads a byte slice into a ValidateModeLineReply value.
func validateModeLineReply ( buf [ ] byte ) * ValidateModeLineReply {
v := new ( ValidateModeLineReply )
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 . Status = xgb . Get32 ( buf [ b : ] )
2012-05-10 23:01:42 +02:00
b += 4
b += 20 // padding
return v
}
2013-08-12 02:43:26 +02:00
// Write request to wire for ValidateModeLine
// validateModeLineRequest writes a ValidateModeLine request to a byte slice.
func validateModeLineRequest ( c * xgb . Conn , Screen uint32 , Dotclock Dotclock , Hdisplay uint16 , Hsyncstart uint16 , Hsyncend uint16 , Htotal uint16 , Hskew uint16 , Vdisplay uint16 , Vsyncstart uint16 , Vsyncend uint16 , Vtotal uint16 , Flags uint32 , Privsize uint32 , Private [ ] byte ) [ ] byte {
size := xgb . Pad ( ( 52 + xgb . Pad ( ( int ( Privsize ) * 1 ) ) ) )
2012-05-10 23:01:42 +02:00
b := 0
buf := make ( [ ] byte , size )
buf [ b ] = c . Extensions [ "XFREE86-VIDMODEEXTENSION" ]
b += 1
2013-08-12 02:43:26 +02:00
buf [ b ] = 9 // 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 : ] , uint32 ( Dotclock ) )
b += 4
xgb . Put16 ( buf [ b : ] , Hdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , Hsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , Hsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Htotal )
b += 2
xgb . Put16 ( buf [ b : ] , Hskew )
b += 2
xgb . Put16 ( buf [ b : ] , Vdisplay )
b += 2
xgb . Put16 ( buf [ b : ] , Vsyncstart )
b += 2
xgb . Put16 ( buf [ b : ] , Vsyncend )
b += 2
xgb . Put16 ( buf [ b : ] , Vtotal )
2012-05-10 23:01:42 +02:00
b += 2
b += 2 // padding
2013-08-12 02:43:26 +02:00
xgb . Put32 ( buf [ b : ] , Flags )
b += 4
b += 12 // padding
xgb . Put32 ( buf [ b : ] , Privsize )
b += 4
copy ( buf [ b : ] , Private [ : Privsize ] )
b += xgb . Pad ( int ( Privsize ) )
2012-05-10 23:01:42 +02:00
return buf
}