go-tg-screenshot-bot
718 строк · 18.7 Кб
1// Package xinerama is the X client API for the XINERAMA extension.
2package xinerama3
4// This file is automatically generated from xinerama.xml. Edit at your peril!
5
6import (7"github.com/jezek/xgb"8
9"github.com/jezek/xgb/xproto"10)
11
12// Init must be called before using the XINERAMA extension.
13func Init(c *xgb.Conn) error {14reply, err := xproto.QueryExtension(c, 8, "XINERAMA").Reply()15switch {16case err != nil:17return err18case !reply.Present:19return xgb.Errorf("No extension named XINERAMA could be found on on the server.")20}21
22c.ExtLock.Lock()23c.Extensions["XINERAMA"] = reply.MajorOpcode24c.ExtLock.Unlock()25for evNum, fun := range xgb.NewExtEventFuncs["XINERAMA"] {26xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun27}28for errNum, fun := range xgb.NewExtErrorFuncs["XINERAMA"] {29xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun30}31return nil32}
33
34func init() {35xgb.NewExtEventFuncs["XINERAMA"] = make(map[int]xgb.NewEventFun)36xgb.NewExtErrorFuncs["XINERAMA"] = make(map[int]xgb.NewErrorFun)37}
38
39type ScreenInfo struct {40XOrg int1641YOrg int1642Width uint1643Height uint1644}
45
46// ScreenInfoRead reads a byte slice into a ScreenInfo value.
47func ScreenInfoRead(buf []byte, v *ScreenInfo) int {48b := 049
50v.XOrg = int16(xgb.Get16(buf[b:]))51b += 252
53v.YOrg = int16(xgb.Get16(buf[b:]))54b += 255
56v.Width = xgb.Get16(buf[b:])57b += 258
59v.Height = xgb.Get16(buf[b:])60b += 261
62return b63}
64
65// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values.
66func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int {67b := 068for i := 0; i < len(dest); i++ {69dest[i] = ScreenInfo{}70b += ScreenInfoRead(buf[b:], &dest[i])71}72return xgb.Pad(b)73}
74
75// Bytes writes a ScreenInfo value to a byte slice.
76func (v ScreenInfo) Bytes() []byte {77buf := make([]byte, 8)78b := 079
80xgb.Put16(buf[b:], uint16(v.XOrg))81b += 282
83xgb.Put16(buf[b:], uint16(v.YOrg))84b += 285
86xgb.Put16(buf[b:], v.Width)87b += 288
89xgb.Put16(buf[b:], v.Height)90b += 291
92return buf[:b]93}
94
95// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice.
96func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int {97b := 098var structBytes []byte99for _, item := range list {100structBytes = item.Bytes()101copy(buf[b:], structBytes)102b += len(structBytes)103}104return xgb.Pad(b)105}
106
107// Skipping definition for base type 'Bool'
108
109// Skipping definition for base type 'Byte'
110
111// Skipping definition for base type 'Card8'
112
113// Skipping definition for base type 'Char'
114
115// Skipping definition for base type 'Void'
116
117// Skipping definition for base type 'Double'
118
119// Skipping definition for base type 'Float'
120
121// Skipping definition for base type 'Int16'
122
123// Skipping definition for base type 'Int32'
124
125// Skipping definition for base type 'Int8'
126
127// Skipping definition for base type 'Card16'
128
129// Skipping definition for base type 'Card32'
130
131// GetScreenCountCookie is a cookie used only for GetScreenCount requests.
132type GetScreenCountCookie struct {133*xgb.Cookie134}
135
136// GetScreenCount sends a checked request.
137// If an error occurs, it will be returned with the reply by calling GetScreenCountCookie.Reply()
138func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie {139c.ExtLock.RLock()140defer c.ExtLock.RUnlock()141if _, ok := c.Extensions["XINERAMA"]; !ok {142panic("Cannot issue request 'GetScreenCount' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")143}144cookie := c.NewCookie(true, true)145c.NewRequest(getScreenCountRequest(c, Window), cookie)146return GetScreenCountCookie{cookie}147}
148
149// GetScreenCountUnchecked sends an unchecked request.
150// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
151func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie {152c.ExtLock.RLock()153defer c.ExtLock.RUnlock()154if _, ok := c.Extensions["XINERAMA"]; !ok {155panic("Cannot issue request 'GetScreenCount' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")156}157cookie := c.NewCookie(false, true)158c.NewRequest(getScreenCountRequest(c, Window), cookie)159return GetScreenCountCookie{cookie}160}
161
162// GetScreenCountReply represents the data returned from a GetScreenCount request.
163type GetScreenCountReply struct {164Sequence uint16 // sequence number of the request for this reply165Length uint32 // number of bytes in this reply166ScreenCount byte167Window xproto.Window168}
169
170// Reply blocks and returns the reply data for a GetScreenCount request.
171func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, error) {172buf, err := cook.Cookie.Reply()173if err != nil {174return nil, err175}176if buf == nil {177return nil, nil178}179return getScreenCountReply(buf), nil180}
181
182// getScreenCountReply reads a byte slice into a GetScreenCountReply value.
183func getScreenCountReply(buf []byte) *GetScreenCountReply {184v := new(GetScreenCountReply)185b := 1 // skip reply determinant186
187v.ScreenCount = buf[b]188b += 1189
190v.Sequence = xgb.Get16(buf[b:])191b += 2192
193v.Length = xgb.Get32(buf[b:]) // 4-byte units194b += 4195
196v.Window = xproto.Window(xgb.Get32(buf[b:]))197b += 4198
199return v200}
201
202// Write request to wire for GetScreenCount
203// getScreenCountRequest writes a GetScreenCount request to a byte slice.
204func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte {205size := 8206b := 0207buf := make([]byte, size)208
209c.ExtLock.RLock()210buf[b] = c.Extensions["XINERAMA"]211c.ExtLock.RUnlock()212b += 1213
214buf[b] = 2 // request opcode215b += 1216
217xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units218b += 2219
220xgb.Put32(buf[b:], uint32(Window))221b += 4222
223return buf224}
225
226// GetScreenSizeCookie is a cookie used only for GetScreenSize requests.
227type GetScreenSizeCookie struct {228*xgb.Cookie229}
230
231// GetScreenSize sends a checked request.
232// If an error occurs, it will be returned with the reply by calling GetScreenSizeCookie.Reply()
233func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie {234c.ExtLock.RLock()235defer c.ExtLock.RUnlock()236if _, ok := c.Extensions["XINERAMA"]; !ok {237panic("Cannot issue request 'GetScreenSize' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")238}239cookie := c.NewCookie(true, true)240c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie)241return GetScreenSizeCookie{cookie}242}
243
244// GetScreenSizeUnchecked sends an unchecked request.
245// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
246func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie {247c.ExtLock.RLock()248defer c.ExtLock.RUnlock()249if _, ok := c.Extensions["XINERAMA"]; !ok {250panic("Cannot issue request 'GetScreenSize' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")251}252cookie := c.NewCookie(false, true)253c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie)254return GetScreenSizeCookie{cookie}255}
256
257// GetScreenSizeReply represents the data returned from a GetScreenSize request.
258type GetScreenSizeReply struct {259Sequence uint16 // sequence number of the request for this reply260Length uint32 // number of bytes in this reply261// padding: 1 bytes262Width uint32263Height uint32264Window xproto.Window265Screen uint32266}
267
268// Reply blocks and returns the reply data for a GetScreenSize request.
269func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) {270buf, err := cook.Cookie.Reply()271if err != nil {272return nil, err273}274if buf == nil {275return nil, nil276}277return getScreenSizeReply(buf), nil278}
279
280// getScreenSizeReply reads a byte slice into a GetScreenSizeReply value.
281func getScreenSizeReply(buf []byte) *GetScreenSizeReply {282v := new(GetScreenSizeReply)283b := 1 // skip reply determinant284
285b += 1 // padding286
287v.Sequence = xgb.Get16(buf[b:])288b += 2289
290v.Length = xgb.Get32(buf[b:]) // 4-byte units291b += 4292
293v.Width = xgb.Get32(buf[b:])294b += 4295
296v.Height = xgb.Get32(buf[b:])297b += 4298
299v.Window = xproto.Window(xgb.Get32(buf[b:]))300b += 4301
302v.Screen = xgb.Get32(buf[b:])303b += 4304
305return v306}
307
308// Write request to wire for GetScreenSize
309// getScreenSizeRequest writes a GetScreenSize request to a byte slice.
310func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []byte {311size := 12312b := 0313buf := make([]byte, size)314
315c.ExtLock.RLock()316buf[b] = c.Extensions["XINERAMA"]317c.ExtLock.RUnlock()318b += 1319
320buf[b] = 3 // request opcode321b += 1322
323xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units324b += 2325
326xgb.Put32(buf[b:], uint32(Window))327b += 4328
329xgb.Put32(buf[b:], Screen)330b += 4331
332return buf333}
334
335// GetStateCookie is a cookie used only for GetState requests.
336type GetStateCookie struct {337*xgb.Cookie338}
339
340// GetState sends a checked request.
341// If an error occurs, it will be returned with the reply by calling GetStateCookie.Reply()
342func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie {343c.ExtLock.RLock()344defer c.ExtLock.RUnlock()345if _, ok := c.Extensions["XINERAMA"]; !ok {346panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")347}348cookie := c.NewCookie(true, true)349c.NewRequest(getStateRequest(c, Window), cookie)350return GetStateCookie{cookie}351}
352
353// GetStateUnchecked sends an unchecked request.
354// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
355func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie {356c.ExtLock.RLock()357defer c.ExtLock.RUnlock()358if _, ok := c.Extensions["XINERAMA"]; !ok {359panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")360}361cookie := c.NewCookie(false, true)362c.NewRequest(getStateRequest(c, Window), cookie)363return GetStateCookie{cookie}364}
365
366// GetStateReply represents the data returned from a GetState request.
367type GetStateReply struct {368Sequence uint16 // sequence number of the request for this reply369Length uint32 // number of bytes in this reply370State byte371Window xproto.Window372}
373
374// Reply blocks and returns the reply data for a GetState request.
375func (cook GetStateCookie) Reply() (*GetStateReply, error) {376buf, err := cook.Cookie.Reply()377if err != nil {378return nil, err379}380if buf == nil {381return nil, nil382}383return getStateReply(buf), nil384}
385
386// getStateReply reads a byte slice into a GetStateReply value.
387func getStateReply(buf []byte) *GetStateReply {388v := new(GetStateReply)389b := 1 // skip reply determinant390
391v.State = buf[b]392b += 1393
394v.Sequence = xgb.Get16(buf[b:])395b += 2396
397v.Length = xgb.Get32(buf[b:]) // 4-byte units398b += 4399
400v.Window = xproto.Window(xgb.Get32(buf[b:]))401b += 4402
403return v404}
405
406// Write request to wire for GetState
407// getStateRequest writes a GetState request to a byte slice.
408func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte {409size := 8410b := 0411buf := make([]byte, size)412
413c.ExtLock.RLock()414buf[b] = c.Extensions["XINERAMA"]415c.ExtLock.RUnlock()416b += 1417
418buf[b] = 1 // request opcode419b += 1420
421xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units422b += 2423
424xgb.Put32(buf[b:], uint32(Window))425b += 4426
427return buf428}
429
430// IsActiveCookie is a cookie used only for IsActive requests.
431type IsActiveCookie struct {432*xgb.Cookie433}
434
435// IsActive sends a checked request.
436// If an error occurs, it will be returned with the reply by calling IsActiveCookie.Reply()
437func IsActive(c *xgb.Conn) IsActiveCookie {438c.ExtLock.RLock()439defer c.ExtLock.RUnlock()440if _, ok := c.Extensions["XINERAMA"]; !ok {441panic("Cannot issue request 'IsActive' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")442}443cookie := c.NewCookie(true, true)444c.NewRequest(isActiveRequest(c), cookie)445return IsActiveCookie{cookie}446}
447
448// IsActiveUnchecked sends an unchecked request.
449// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
450func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie {451c.ExtLock.RLock()452defer c.ExtLock.RUnlock()453if _, ok := c.Extensions["XINERAMA"]; !ok {454panic("Cannot issue request 'IsActive' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")455}456cookie := c.NewCookie(false, true)457c.NewRequest(isActiveRequest(c), cookie)458return IsActiveCookie{cookie}459}
460
461// IsActiveReply represents the data returned from a IsActive request.
462type IsActiveReply struct {463Sequence uint16 // sequence number of the request for this reply464Length uint32 // number of bytes in this reply465// padding: 1 bytes466State uint32467}
468
469// Reply blocks and returns the reply data for a IsActive request.
470func (cook IsActiveCookie) Reply() (*IsActiveReply, error) {471buf, err := cook.Cookie.Reply()472if err != nil {473return nil, err474}475if buf == nil {476return nil, nil477}478return isActiveReply(buf), nil479}
480
481// isActiveReply reads a byte slice into a IsActiveReply value.
482func isActiveReply(buf []byte) *IsActiveReply {483v := new(IsActiveReply)484b := 1 // skip reply determinant485
486b += 1 // padding487
488v.Sequence = xgb.Get16(buf[b:])489b += 2490
491v.Length = xgb.Get32(buf[b:]) // 4-byte units492b += 4493
494v.State = xgb.Get32(buf[b:])495b += 4496
497return v498}
499
500// Write request to wire for IsActive
501// isActiveRequest writes a IsActive request to a byte slice.
502func isActiveRequest(c *xgb.Conn) []byte {503size := 4504b := 0505buf := make([]byte, size)506
507c.ExtLock.RLock()508buf[b] = c.Extensions["XINERAMA"]509c.ExtLock.RUnlock()510b += 1511
512buf[b] = 4 // request opcode513b += 1514
515xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units516b += 2517
518return buf519}
520
521// QueryScreensCookie is a cookie used only for QueryScreens requests.
522type QueryScreensCookie struct {523*xgb.Cookie524}
525
526// QueryScreens sends a checked request.
527// If an error occurs, it will be returned with the reply by calling QueryScreensCookie.Reply()
528func QueryScreens(c *xgb.Conn) QueryScreensCookie {529c.ExtLock.RLock()530defer c.ExtLock.RUnlock()531if _, ok := c.Extensions["XINERAMA"]; !ok {532panic("Cannot issue request 'QueryScreens' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")533}534cookie := c.NewCookie(true, true)535c.NewRequest(queryScreensRequest(c), cookie)536return QueryScreensCookie{cookie}537}
538
539// QueryScreensUnchecked sends an unchecked request.
540// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
541func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie {542c.ExtLock.RLock()543defer c.ExtLock.RUnlock()544if _, ok := c.Extensions["XINERAMA"]; !ok {545panic("Cannot issue request 'QueryScreens' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")546}547cookie := c.NewCookie(false, true)548c.NewRequest(queryScreensRequest(c), cookie)549return QueryScreensCookie{cookie}550}
551
552// QueryScreensReply represents the data returned from a QueryScreens request.
553type QueryScreensReply struct {554Sequence uint16 // sequence number of the request for this reply555Length uint32 // number of bytes in this reply556// padding: 1 bytes557Number uint32558// padding: 20 bytes559ScreenInfo []ScreenInfo // size: xgb.Pad((int(Number) * 8))560}
561
562// Reply blocks and returns the reply data for a QueryScreens request.
563func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) {564buf, err := cook.Cookie.Reply()565if err != nil {566return nil, err567}568if buf == nil {569return nil, nil570}571return queryScreensReply(buf), nil572}
573
574// queryScreensReply reads a byte slice into a QueryScreensReply value.
575func queryScreensReply(buf []byte) *QueryScreensReply {576v := new(QueryScreensReply)577b := 1 // skip reply determinant578
579b += 1 // padding580
581v.Sequence = xgb.Get16(buf[b:])582b += 2583
584v.Length = xgb.Get32(buf[b:]) // 4-byte units585b += 4586
587v.Number = xgb.Get32(buf[b:])588b += 4589
590b += 20 // padding591
592v.ScreenInfo = make([]ScreenInfo, v.Number)593b += ScreenInfoReadList(buf[b:], v.ScreenInfo)594
595return v596}
597
598// Write request to wire for QueryScreens
599// queryScreensRequest writes a QueryScreens request to a byte slice.
600func queryScreensRequest(c *xgb.Conn) []byte {601size := 4602b := 0603buf := make([]byte, size)604
605c.ExtLock.RLock()606buf[b] = c.Extensions["XINERAMA"]607c.ExtLock.RUnlock()608b += 1609
610buf[b] = 5 // request opcode611b += 1612
613xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units614b += 2615
616return buf617}
618
619// QueryVersionCookie is a cookie used only for QueryVersion requests.
620type QueryVersionCookie struct {621*xgb.Cookie622}
623
624// QueryVersion sends a checked request.
625// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
626func QueryVersion(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie {627c.ExtLock.RLock()628defer c.ExtLock.RUnlock()629if _, ok := c.Extensions["XINERAMA"]; !ok {630panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")631}632cookie := c.NewCookie(true, true)633c.NewRequest(queryVersionRequest(c, Major, Minor), cookie)634return QueryVersionCookie{cookie}635}
636
637// QueryVersionUnchecked sends an unchecked request.
638// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
639func QueryVersionUnchecked(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie {640c.ExtLock.RLock()641defer c.ExtLock.RUnlock()642if _, ok := c.Extensions["XINERAMA"]; !ok {643panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")644}645cookie := c.NewCookie(false, true)646c.NewRequest(queryVersionRequest(c, Major, Minor), cookie)647return QueryVersionCookie{cookie}648}
649
650// QueryVersionReply represents the data returned from a QueryVersion request.
651type QueryVersionReply struct {652Sequence uint16 // sequence number of the request for this reply653Length uint32 // number of bytes in this reply654// padding: 1 bytes655Major uint16656Minor uint16657}
658
659// Reply blocks and returns the reply data for a QueryVersion request.
660func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {661buf, err := cook.Cookie.Reply()662if err != nil {663return nil, err664}665if buf == nil {666return nil, nil667}668return queryVersionReply(buf), nil669}
670
671// queryVersionReply reads a byte slice into a QueryVersionReply value.
672func queryVersionReply(buf []byte) *QueryVersionReply {673v := new(QueryVersionReply)674b := 1 // skip reply determinant675
676b += 1 // padding677
678v.Sequence = xgb.Get16(buf[b:])679b += 2680
681v.Length = xgb.Get32(buf[b:]) // 4-byte units682b += 4683
684v.Major = xgb.Get16(buf[b:])685b += 2686
687v.Minor = xgb.Get16(buf[b:])688b += 2689
690return v691}
692
693// Write request to wire for QueryVersion
694// queryVersionRequest writes a QueryVersion request to a byte slice.
695func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte {696size := 8697b := 0698buf := make([]byte, size)699
700c.ExtLock.RLock()701buf[b] = c.Extensions["XINERAMA"]702c.ExtLock.RUnlock()703b += 1704
705buf[b] = 0 // request opcode706b += 1707
708xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units709b += 2710
711buf[b] = Major712b += 1713
714buf[b] = Minor715b += 1716
717return buf718}
719