Debian Codegraph @

xf86dri/xf86dri.go

raw symbols SCIP
1 // Package xf86dri is the X client API for the XFree86-DRI extension.
2 package xf86dri
3
4 // This file is automatically generated from xf86dri.xml. Edit at your peril!
5
6 import (
7 "github.com/BurntSushi/xgb"
8
9 "github.com/BurntSushi/xgb/xproto"
10 )
11
12 // Init must be called before using the XFree86-DRI extension.
13 func Init(c *xgb.Conn) error {
14 reply, err := xproto.QueryExtension(c, 11, "XFree86-DRI").Reply()
15 switch {
16 case err != nil:
17 return err
18 case !reply.Present:
19 return xgb.Errorf("No extension named XFree86-DRI could be found on on the server.")
20 }
21
22 c.ExtLock.Lock()
23 c.Extensions["XFree86-DRI"] = reply.MajorOpcode
24 c.ExtLock.Unlock()
25 for evNum, fun := range xgb.NewExtEventFuncs["XFree86-DRI"] {
26 xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
27 }
28 for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-DRI"] {
29 xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
30 }
31 return nil
32 }
33
34 func init() {
35 xgb.NewExtEventFuncs["XFree86-DRI"] = make(map[int]xgb.NewEventFun)
36 xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun)
37 }
38
39 type DrmClipRect struct {
40 X1 int16
41 Y1 int16
42 X2 int16
43 X3 int16
44 }
45
46 // DrmClipRectRead reads a byte slice into a DrmClipRect value.
47 func DrmClipRectRead(buf []byte, v *DrmClipRect) int {
48 b := 0
49
50 v.X1 = int16(xgb.Get16(buf[b:]))
51 b += 2
52
53 v.Y1 = int16(xgb.Get16(buf[b:]))
54 b += 2
55
56 v.X2 = int16(xgb.Get16(buf[b:]))
57 b += 2
58
59 v.X3 = int16(xgb.Get16(buf[b:]))
60 b += 2
61
62 return b
63 }
64
65 // DrmClipRectReadList reads a byte slice into a list of DrmClipRect values.
66 func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int {
67 b := 0
68 for i := 0; i < len(dest); i++ {
69 dest[i] = DrmClipRect{}
70 b += DrmClipRectRead(buf[b:], &dest[i])
71 }
72 return xgb.Pad(b)
73 }
74
75 // Bytes writes a DrmClipRect value to a byte slice.
76 func (v DrmClipRect) Bytes() []byte {
77 buf := make([]byte, 8)
78 b := 0
79
80 xgb.Put16(buf[b:], uint16(v.X1))
81 b += 2
82
83 xgb.Put16(buf[b:], uint16(v.Y1))
84 b += 2
85
86 xgb.Put16(buf[b:], uint16(v.X2))
87 b += 2
88
89 xgb.Put16(buf[b:], uint16(v.X3))
90 b += 2
91
92 return buf[:b]
93 }
94
95 // DrmClipRectListBytes writes a list of DrmClipRect values to a byte slice.
96 func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int {
97 b := 0
98 var structBytes []byte
99 for _, item := range list {
100 structBytes = item.Bytes()
101 copy(buf[b:], structBytes)
102 b += len(structBytes)
103 }
104 return 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 // AuthConnectionCookie is a cookie used only for AuthConnection requests.
132 type AuthConnectionCookie struct {
133 *xgb.Cookie
134 }
135
136 // AuthConnection sends a checked request.
137 // If an error occurs, it will be returned with the reply by calling AuthConnectionCookie.Reply()
138 func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie {
139 c.ExtLock.RLock()
140 defer c.ExtLock.RUnlock()
141 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
142 panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
143 }
144 cookie := c.NewCookie(true, true)
145 c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie)
146 return AuthConnectionCookie{cookie}
147 }
148
149 // AuthConnectionUnchecked sends an unchecked request.
150 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
151 func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie {
152 c.ExtLock.RLock()
153 defer c.ExtLock.RUnlock()
154 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
155 panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
156 }
157 cookie := c.NewCookie(false, true)
158 c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie)
159 return AuthConnectionCookie{cookie}
160 }
161
162 // AuthConnectionReply represents the data returned from a AuthConnection request.
163 type AuthConnectionReply struct {
164 Sequence uint16 // sequence number of the request for this reply
165 Length uint32 // number of bytes in this reply
166 // padding: 1 bytes
167 Authenticated uint32
168 }
169
170 // Reply blocks and returns the reply data for a AuthConnection request.
171 func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) {
172 buf, err := cook.Cookie.Reply()
173 if err != nil {
174 return nil, err
175 }
176 if buf == nil {
177 return nil, nil
178 }
179 return authConnectionReply(buf), nil
180 }
181
182 // authConnectionReply reads a byte slice into a AuthConnectionReply value.
183 func authConnectionReply(buf []byte) *AuthConnectionReply {
184 v := new(AuthConnectionReply)
185 b := 1 // skip reply determinant
186
187 b += 1 // padding
188
189 v.Sequence = xgb.Get16(buf[b:])
190 b += 2
191
192 v.Length = xgb.Get32(buf[b:]) // 4-byte units
193 b += 4
194
195 v.Authenticated = xgb.Get32(buf[b:])
196 b += 4
197
198 return v
199 }
200
201 // Write request to wire for AuthConnection
202 // authConnectionRequest writes a AuthConnection request to a byte slice.
203 func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte {
204 size := 12
205 b := 0
206 buf := make([]byte, size)
207
208 c.ExtLock.RLock()
209 buf[b] = c.Extensions["XFree86-DRI"]
210 c.ExtLock.RUnlock()
211 b += 1
212
213 buf[b] = 11 // request opcode
214 b += 1
215
216 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
217 b += 2
218
219 xgb.Put32(buf[b:], Screen)
220 b += 4
221
222 xgb.Put32(buf[b:], Magic)
223 b += 4
224
225 return buf
226 }
227
228 // CloseConnectionCookie is a cookie used only for CloseConnection requests.
229 type CloseConnectionCookie struct {
230 *xgb.Cookie
231 }
232
233 // CloseConnection sends an unchecked request.
234 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
235 func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie {
236 c.ExtLock.RLock()
237 defer c.ExtLock.RUnlock()
238 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
239 panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
240 }
241 cookie := c.NewCookie(false, false)
242 c.NewRequest(closeConnectionRequest(c, Screen), cookie)
243 return CloseConnectionCookie{cookie}
244 }
245
246 // CloseConnectionChecked sends a checked request.
247 // If an error occurs, it can be retrieved using CloseConnectionCookie.Check()
248 func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie {
249 c.ExtLock.RLock()
250 defer c.ExtLock.RUnlock()
251 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
252 panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
253 }
254 cookie := c.NewCookie(true, false)
255 c.NewRequest(closeConnectionRequest(c, Screen), cookie)
256 return CloseConnectionCookie{cookie}
257 }
258
259 // Check returns an error if one occurred for checked requests that are not expecting a reply.
260 // This cannot be called for requests expecting a reply, nor for unchecked requests.
261 func (cook CloseConnectionCookie) Check() error {
262 return cook.Cookie.Check()
263 }
264
265 // Write request to wire for CloseConnection
266 // closeConnectionRequest writes a CloseConnection request to a byte slice.
267 func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte {
268 size := 8
269 b := 0
270 buf := make([]byte, size)
271
272 c.ExtLock.RLock()
273 buf[b] = c.Extensions["XFree86-DRI"]
274 c.ExtLock.RUnlock()
275 b += 1
276
277 buf[b] = 3 // request opcode
278 b += 1
279
280 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
281 b += 2
282
283 xgb.Put32(buf[b:], Screen)
284 b += 4
285
286 return buf
287 }
288
289 // CreateContextCookie is a cookie used only for CreateContext requests.
290 type CreateContextCookie struct {
291 *xgb.Cookie
292 }
293
294 // CreateContext sends a checked request.
295 // If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply()
296 func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie {
297 c.ExtLock.RLock()
298 defer c.ExtLock.RUnlock()
299 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
300 panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
301 }
302 cookie := c.NewCookie(true, true)
303 c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie)
304 return CreateContextCookie{cookie}
305 }
306
307 // CreateContextUnchecked sends an unchecked request.
308 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
309 func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie {
310 c.ExtLock.RLock()
311 defer c.ExtLock.RUnlock()
312 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
313 panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
314 }
315 cookie := c.NewCookie(false, true)
316 c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie)
317 return CreateContextCookie{cookie}
318 }
319
320 // CreateContextReply represents the data returned from a CreateContext request.
321 type CreateContextReply struct {
322 Sequence uint16 // sequence number of the request for this reply
323 Length uint32 // number of bytes in this reply
324 // padding: 1 bytes
325 HwContext uint32
326 }
327
328 // Reply blocks and returns the reply data for a CreateContext request.
329 func (cook CreateContextCookie) Reply() (*CreateContextReply, error) {
330 buf, err := cook.Cookie.Reply()
331 if err != nil {
332 return nil, err
333 }
334 if buf == nil {
335 return nil, nil
336 }
337 return createContextReply(buf), nil
338 }
339
340 // createContextReply reads a byte slice into a CreateContextReply value.
341 func createContextReply(buf []byte) *CreateContextReply {
342 v := new(CreateContextReply)
343 b := 1 // skip reply determinant
344
345 b += 1 // padding
346
347 v.Sequence = xgb.Get16(buf[b:])
348 b += 2
349
350 v.Length = xgb.Get32(buf[b:]) // 4-byte units
351 b += 4
352
353 v.HwContext = xgb.Get32(buf[b:])
354 b += 4
355
356 return v
357 }
358
359 // Write request to wire for CreateContext
360 // createContextRequest writes a CreateContext request to a byte slice.
361 func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte {
362 size := 16
363 b := 0
364 buf := make([]byte, size)
365
366 c.ExtLock.RLock()
367 buf[b] = c.Extensions["XFree86-DRI"]
368 c.ExtLock.RUnlock()
369 b += 1
370
371 buf[b] = 5 // request opcode
372 b += 1
373
374 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
375 b += 2
376
377 xgb.Put32(buf[b:], Screen)
378 b += 4
379
380 xgb.Put32(buf[b:], Visual)
381 b += 4
382
383 xgb.Put32(buf[b:], Context)
384 b += 4
385
386 return buf
387 }
388
389 // CreateDrawableCookie is a cookie used only for CreateDrawable requests.
390 type CreateDrawableCookie struct {
391 *xgb.Cookie
392 }
393
394 // CreateDrawable sends a checked request.
395 // If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply()
396 func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie {
397 c.ExtLock.RLock()
398 defer c.ExtLock.RUnlock()
399 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
400 panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
401 }
402 cookie := c.NewCookie(true, true)
403 c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie)
404 return CreateDrawableCookie{cookie}
405 }
406
407 // CreateDrawableUnchecked sends an unchecked request.
408 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
409 func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie {
410 c.ExtLock.RLock()
411 defer c.ExtLock.RUnlock()
412 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
413 panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
414 }
415 cookie := c.NewCookie(false, true)
416 c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie)
417 return CreateDrawableCookie{cookie}
418 }
419
420 // CreateDrawableReply represents the data returned from a CreateDrawable request.
421 type CreateDrawableReply struct {
422 Sequence uint16 // sequence number of the request for this reply
423 Length uint32 // number of bytes in this reply
424 // padding: 1 bytes
425 HwDrawableHandle uint32
426 }
427
428 // Reply blocks and returns the reply data for a CreateDrawable request.
429 func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) {
430 buf, err := cook.Cookie.Reply()
431 if err != nil {
432 return nil, err
433 }
434 if buf == nil {
435 return nil, nil
436 }
437 return createDrawableReply(buf), nil
438 }
439
440 // createDrawableReply reads a byte slice into a CreateDrawableReply value.
441 func createDrawableReply(buf []byte) *CreateDrawableReply {
442 v := new(CreateDrawableReply)
443 b := 1 // skip reply determinant
444
445 b += 1 // padding
446
447 v.Sequence = xgb.Get16(buf[b:])
448 b += 2
449
450 v.Length = xgb.Get32(buf[b:]) // 4-byte units
451 b += 4
452
453 v.HwDrawableHandle = xgb.Get32(buf[b:])
454 b += 4
455
456 return v
457 }
458
459 // Write request to wire for CreateDrawable
460 // createDrawableRequest writes a CreateDrawable request to a byte slice.
461 func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte {
462 size := 12
463 b := 0
464 buf := make([]byte, size)
465
466 c.ExtLock.RLock()
467 buf[b] = c.Extensions["XFree86-DRI"]
468 c.ExtLock.RUnlock()
469 b += 1
470
471 buf[b] = 7 // request opcode
472 b += 1
473
474 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
475 b += 2
476
477 xgb.Put32(buf[b:], Screen)
478 b += 4
479
480 xgb.Put32(buf[b:], Drawable)
481 b += 4
482
483 return buf
484 }
485
486 // DestroyContextCookie is a cookie used only for DestroyContext requests.
487 type DestroyContextCookie struct {
488 *xgb.Cookie
489 }
490
491 // DestroyContext sends an unchecked request.
492 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
493 func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie {
494 c.ExtLock.RLock()
495 defer c.ExtLock.RUnlock()
496 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
497 panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
498 }
499 cookie := c.NewCookie(false, false)
500 c.NewRequest(destroyContextRequest(c, Screen, Context), cookie)
501 return DestroyContextCookie{cookie}
502 }
503
504 // DestroyContextChecked sends a checked request.
505 // If an error occurs, it can be retrieved using DestroyContextCookie.Check()
506 func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie {
507 c.ExtLock.RLock()
508 defer c.ExtLock.RUnlock()
509 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
510 panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
511 }
512 cookie := c.NewCookie(true, false)
513 c.NewRequest(destroyContextRequest(c, Screen, Context), cookie)
514 return DestroyContextCookie{cookie}
515 }
516
517 // Check returns an error if one occurred for checked requests that are not expecting a reply.
518 // This cannot be called for requests expecting a reply, nor for unchecked requests.
519 func (cook DestroyContextCookie) Check() error {
520 return cook.Cookie.Check()
521 }
522
523 // Write request to wire for DestroyContext
524 // destroyContextRequest writes a DestroyContext request to a byte slice.
525 func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte {
526 size := 12
527 b := 0
528 buf := make([]byte, size)
529
530 c.ExtLock.RLock()
531 buf[b] = c.Extensions["XFree86-DRI"]
532 c.ExtLock.RUnlock()
533 b += 1
534
535 buf[b] = 6 // request opcode
536 b += 1
537
538 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
539 b += 2
540
541 xgb.Put32(buf[b:], Screen)
542 b += 4
543
544 xgb.Put32(buf[b:], Context)
545 b += 4
546
547 return buf
548 }
549
550 // DestroyDrawableCookie is a cookie used only for DestroyDrawable requests.
551 type DestroyDrawableCookie struct {
552 *xgb.Cookie
553 }
554
555 // DestroyDrawable sends an unchecked request.
556 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
557 func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie {
558 c.ExtLock.RLock()
559 defer c.ExtLock.RUnlock()
560 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
561 panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
562 }
563 cookie := c.NewCookie(false, false)
564 c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie)
565 return DestroyDrawableCookie{cookie}
566 }
567
568 // DestroyDrawableChecked sends a checked request.
569 // If an error occurs, it can be retrieved using DestroyDrawableCookie.Check()
570 func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie {
571 c.ExtLock.RLock()
572 defer c.ExtLock.RUnlock()
573 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
574 panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
575 }
576 cookie := c.NewCookie(true, false)
577 c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie)
578 return DestroyDrawableCookie{cookie}
579 }
580
581 // Check returns an error if one occurred for checked requests that are not expecting a reply.
582 // This cannot be called for requests expecting a reply, nor for unchecked requests.
583 func (cook DestroyDrawableCookie) Check() error {
584 return cook.Cookie.Check()
585 }
586
587 // Write request to wire for DestroyDrawable
588 // destroyDrawableRequest writes a DestroyDrawable request to a byte slice.
589 func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte {
590 size := 12
591 b := 0
592 buf := make([]byte, size)
593
594 c.ExtLock.RLock()
595 buf[b] = c.Extensions["XFree86-DRI"]
596 c.ExtLock.RUnlock()
597 b += 1
598
599 buf[b] = 8 // request opcode
600 b += 1
601
602 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
603 b += 2
604
605 xgb.Put32(buf[b:], Screen)
606 b += 4
607
608 xgb.Put32(buf[b:], Drawable)
609 b += 4
610
611 return buf
612 }
613
614 // GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests.
615 type GetClientDriverNameCookie struct {
616 *xgb.Cookie
617 }
618
619 // GetClientDriverName sends a checked request.
620 // If an error occurs, it will be returned with the reply by calling GetClientDriverNameCookie.Reply()
621 func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie {
622 c.ExtLock.RLock()
623 defer c.ExtLock.RUnlock()
624 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
625 panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
626 }
627 cookie := c.NewCookie(true, true)
628 c.NewRequest(getClientDriverNameRequest(c, Screen), cookie)
629 return GetClientDriverNameCookie{cookie}
630 }
631
632 // GetClientDriverNameUnchecked sends an unchecked request.
633 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
634 func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie {
635 c.ExtLock.RLock()
636 defer c.ExtLock.RUnlock()
637 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
638 panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
639 }
640 cookie := c.NewCookie(false, true)
641 c.NewRequest(getClientDriverNameRequest(c, Screen), cookie)
642 return GetClientDriverNameCookie{cookie}
643 }
644
645 // GetClientDriverNameReply represents the data returned from a GetClientDriverName request.
646 type GetClientDriverNameReply struct {
647 Sequence uint16 // sequence number of the request for this reply
648 Length uint32 // number of bytes in this reply
649 // padding: 1 bytes
650 ClientDriverMajorVersion uint32
651 ClientDriverMinorVersion uint32
652 ClientDriverPatchVersion uint32
653 ClientDriverNameLen uint32
654 // padding: 8 bytes
655 ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1))
656 }
657
658 // Reply blocks and returns the reply data for a GetClientDriverName request.
659 func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) {
660 buf, err := cook.Cookie.Reply()
661 if err != nil {
662 return nil, err
663 }
664 if buf == nil {
665 return nil, nil
666 }
667 return getClientDriverNameReply(buf), nil
668 }
669
670 // getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value.
671 func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply {
672 v := new(GetClientDriverNameReply)
673 b := 1 // skip reply determinant
674
675 b += 1 // padding
676
677 v.Sequence = xgb.Get16(buf[b:])
678 b += 2
679
680 v.Length = xgb.Get32(buf[b:]) // 4-byte units
681 b += 4
682
683 v.ClientDriverMajorVersion = xgb.Get32(buf[b:])
684 b += 4
685
686 v.ClientDriverMinorVersion = xgb.Get32(buf[b:])
687 b += 4
688
689 v.ClientDriverPatchVersion = xgb.Get32(buf[b:])
690 b += 4
691
692 v.ClientDriverNameLen = xgb.Get32(buf[b:])
693 b += 4
694
695 b += 8 // padding
696
697 {
698 byteString := make([]byte, v.ClientDriverNameLen)
699 copy(byteString[:v.ClientDriverNameLen], buf[b:])
700 v.ClientDriverName = string(byteString)
701 b += int(v.ClientDriverNameLen)
702 }
703
704 return v
705 }
706
707 // Write request to wire for GetClientDriverName
708 // getClientDriverNameRequest writes a GetClientDriverName request to a byte slice.
709 func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte {
710 size := 8
711 b := 0
712 buf := make([]byte, size)
713
714 c.ExtLock.RLock()
715 buf[b] = c.Extensions["XFree86-DRI"]
716 c.ExtLock.RUnlock()
717 b += 1
718
719 buf[b] = 4 // request opcode
720 b += 1
721
722 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
723 b += 2
724
725 xgb.Put32(buf[b:], Screen)
726 b += 4
727
728 return buf
729 }
730
731 // GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests.
732 type GetDeviceInfoCookie struct {
733 *xgb.Cookie
734 }
735
736 // GetDeviceInfo sends a checked request.
737 // If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply()
738 func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie {
739 c.ExtLock.RLock()
740 defer c.ExtLock.RUnlock()
741 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
742 panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
743 }
744 cookie := c.NewCookie(true, true)
745 c.NewRequest(getDeviceInfoRequest(c, Screen), cookie)
746 return GetDeviceInfoCookie{cookie}
747 }
748
749 // GetDeviceInfoUnchecked sends an unchecked request.
750 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
751 func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie {
752 c.ExtLock.RLock()
753 defer c.ExtLock.RUnlock()
754 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
755 panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
756 }
757 cookie := c.NewCookie(false, true)
758 c.NewRequest(getDeviceInfoRequest(c, Screen), cookie)
759 return GetDeviceInfoCookie{cookie}
760 }
761
762 // GetDeviceInfoReply represents the data returned from a GetDeviceInfo request.
763 type GetDeviceInfoReply struct {
764 Sequence uint16 // sequence number of the request for this reply
765 Length uint32 // number of bytes in this reply
766 // padding: 1 bytes
767 FramebufferHandleLow uint32
768 FramebufferHandleHigh uint32
769 FramebufferOriginOffset uint32
770 FramebufferSize uint32
771 FramebufferStride uint32
772 DevicePrivateSize uint32
773 DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4))
774 }
775
776 // Reply blocks and returns the reply data for a GetDeviceInfo request.
777 func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) {
778 buf, err := cook.Cookie.Reply()
779 if err != nil {
780 return nil, err
781 }
782 if buf == nil {
783 return nil, nil
784 }
785 return getDeviceInfoReply(buf), nil
786 }
787
788 // getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value.
789 func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply {
790 v := new(GetDeviceInfoReply)
791 b := 1 // skip reply determinant
792
793 b += 1 // padding
794
795 v.Sequence = xgb.Get16(buf[b:])
796 b += 2
797
798 v.Length = xgb.Get32(buf[b:]) // 4-byte units
799 b += 4
800
801 v.FramebufferHandleLow = xgb.Get32(buf[b:])
802 b += 4
803
804 v.FramebufferHandleHigh = xgb.Get32(buf[b:])
805 b += 4
806
807 v.FramebufferOriginOffset = xgb.Get32(buf[b:])
808 b += 4
809
810 v.FramebufferSize = xgb.Get32(buf[b:])
811 b += 4
812
813 v.FramebufferStride = xgb.Get32(buf[b:])
814 b += 4
815
816 v.DevicePrivateSize = xgb.Get32(buf[b:])
817 b += 4
818
819 v.DevicePrivate = make([]uint32, v.DevicePrivateSize)
820 for i := 0; i < int(v.DevicePrivateSize); i++ {
821 v.DevicePrivate[i] = xgb.Get32(buf[b:])
822 b += 4
823 }
824
825 return v
826 }
827
828 // Write request to wire for GetDeviceInfo
829 // getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice.
830 func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte {
831 size := 8
832 b := 0
833 buf := make([]byte, size)
834
835 c.ExtLock.RLock()
836 buf[b] = c.Extensions["XFree86-DRI"]
837 c.ExtLock.RUnlock()
838 b += 1
839
840 buf[b] = 10 // request opcode
841 b += 1
842
843 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
844 b += 2
845
846 xgb.Put32(buf[b:], Screen)
847 b += 4
848
849 return buf
850 }
851
852 // GetDrawableInfoCookie is a cookie used only for GetDrawableInfo requests.
853 type GetDrawableInfoCookie struct {
854 *xgb.Cookie
855 }
856
857 // GetDrawableInfo sends a checked request.
858 // If an error occurs, it will be returned with the reply by calling GetDrawableInfoCookie.Reply()
859 func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie {
860 c.ExtLock.RLock()
861 defer c.ExtLock.RUnlock()
862 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
863 panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
864 }
865 cookie := c.NewCookie(true, true)
866 c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie)
867 return GetDrawableInfoCookie{cookie}
868 }
869
870 // GetDrawableInfoUnchecked sends an unchecked request.
871 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
872 func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie {
873 c.ExtLock.RLock()
874 defer c.ExtLock.RUnlock()
875 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
876 panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
877 }
878 cookie := c.NewCookie(false, true)
879 c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie)
880 return GetDrawableInfoCookie{cookie}
881 }
882
883 // GetDrawableInfoReply represents the data returned from a GetDrawableInfo request.
884 type GetDrawableInfoReply struct {
885 Sequence uint16 // sequence number of the request for this reply
886 Length uint32 // number of bytes in this reply
887 // padding: 1 bytes
888 DrawableTableIndex uint32
889 DrawableTableStamp uint32
890 DrawableOriginX int16
891 DrawableOriginY int16
892 DrawableSizeW int16
893 DrawableSizeH int16
894 NumClipRects uint32
895 BackX int16
896 BackY int16
897 NumBackClipRects uint32
898 ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8))
899 // alignment gap to multiple of 4
900 BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8))
901 }
902
903 // Reply blocks and returns the reply data for a GetDrawableInfo request.
904 func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) {
905 buf, err := cook.Cookie.Reply()
906 if err != nil {
907 return nil, err
908 }
909 if buf == nil {
910 return nil, nil
911 }
912 return getDrawableInfoReply(buf), nil
913 }
914
915 // getDrawableInfoReply reads a byte slice into a GetDrawableInfoReply value.
916 func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply {
917 v := new(GetDrawableInfoReply)
918 b := 1 // skip reply determinant
919
920 b += 1 // padding
921
922 v.Sequence = xgb.Get16(buf[b:])
923 b += 2
924
925 v.Length = xgb.Get32(buf[b:]) // 4-byte units
926 b += 4
927
928 v.DrawableTableIndex = xgb.Get32(buf[b:])
929 b += 4
930
931 v.DrawableTableStamp = xgb.Get32(buf[b:])
932 b += 4
933
934 v.DrawableOriginX = int16(xgb.Get16(buf[b:]))
935 b += 2
936
937 v.DrawableOriginY = int16(xgb.Get16(buf[b:]))
938 b += 2
939
940 v.DrawableSizeW = int16(xgb.Get16(buf[b:]))
941 b += 2
942
943 v.DrawableSizeH = int16(xgb.Get16(buf[b:]))
944 b += 2
945
946 v.NumClipRects = xgb.Get32(buf[b:])
947 b += 4
948
949 v.BackX = int16(xgb.Get16(buf[b:]))
950 b += 2
951
952 v.BackY = int16(xgb.Get16(buf[b:]))
953 b += 2
954
955 v.NumBackClipRects = xgb.Get32(buf[b:])
956 b += 4
957
958 v.ClipRects = make([]DrmClipRect, v.NumClipRects)
959 b += DrmClipRectReadList(buf[b:], v.ClipRects)
960
961 b = (b + 3) & ^3 // alignment gap
962
963 v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects)
964 b += DrmClipRectReadList(buf[b:], v.BackClipRects)
965
966 return v
967 }
968
969 // Write request to wire for GetDrawableInfo
970 // getDrawableInfoRequest writes a GetDrawableInfo request to a byte slice.
971 func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte {
972 size := 12
973 b := 0
974 buf := make([]byte, size)
975
976 c.ExtLock.RLock()
977 buf[b] = c.Extensions["XFree86-DRI"]
978 c.ExtLock.RUnlock()
979 b += 1
980
981 buf[b] = 9 // request opcode
982 b += 1
983
984 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
985 b += 2
986
987 xgb.Put32(buf[b:], Screen)
988 b += 4
989
990 xgb.Put32(buf[b:], Drawable)
991 b += 4
992
993 return buf
994 }
995
996 // OpenConnectionCookie is a cookie used only for OpenConnection requests.
997 type OpenConnectionCookie struct {
998 *xgb.Cookie
999 }
1000
1001 // OpenConnection sends a checked request.
1002 // If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply()
1003 func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie {
1004 c.ExtLock.RLock()
1005 defer c.ExtLock.RUnlock()
1006 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
1007 panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
1008 }
1009 cookie := c.NewCookie(true, true)
1010 c.NewRequest(openConnectionRequest(c, Screen), cookie)
1011 return OpenConnectionCookie{cookie}
1012 }
1013
1014 // OpenConnectionUnchecked sends an unchecked request.
1015 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
1016 func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie {
1017 c.ExtLock.RLock()
1018 defer c.ExtLock.RUnlock()
1019 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
1020 panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
1021 }
1022 cookie := c.NewCookie(false, true)
1023 c.NewRequest(openConnectionRequest(c, Screen), cookie)
1024 return OpenConnectionCookie{cookie}
1025 }
1026
1027 // OpenConnectionReply represents the data returned from a OpenConnection request.
1028 type OpenConnectionReply struct {
1029 Sequence uint16 // sequence number of the request for this reply
1030 Length uint32 // number of bytes in this reply
1031 // padding: 1 bytes
1032 SareaHandleLow uint32
1033 SareaHandleHigh uint32
1034 BusIdLen uint32
1035 // padding: 12 bytes
1036 BusId string // size: xgb.Pad((int(BusIdLen) * 1))
1037 }
1038
1039 // Reply blocks and returns the reply data for a OpenConnection request.
1040 func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) {
1041 buf, err := cook.Cookie.Reply()
1042 if err != nil {
1043 return nil, err
1044 }
1045 if buf == nil {
1046 return nil, nil
1047 }
1048 return openConnectionReply(buf), nil
1049 }
1050
1051 // openConnectionReply reads a byte slice into a OpenConnectionReply value.
1052 func openConnectionReply(buf []byte) *OpenConnectionReply {
1053 v := new(OpenConnectionReply)
1054 b := 1 // skip reply determinant
1055
1056 b += 1 // padding
1057
1058 v.Sequence = xgb.Get16(buf[b:])
1059 b += 2
1060
1061 v.Length = xgb.Get32(buf[b:]) // 4-byte units
1062 b += 4
1063
1064 v.SareaHandleLow = xgb.Get32(buf[b:])
1065 b += 4
1066
1067 v.SareaHandleHigh = xgb.Get32(buf[b:])
1068 b += 4
1069
1070 v.BusIdLen = xgb.Get32(buf[b:])
1071 b += 4
1072
1073 b += 12 // padding
1074
1075 {
1076 byteString := make([]byte, v.BusIdLen)
1077 copy(byteString[:v.BusIdLen], buf[b:])
1078 v.BusId = string(byteString)
1079 b += int(v.BusIdLen)
1080 }
1081
1082 return v
1083 }
1084
1085 // Write request to wire for OpenConnection
1086 // openConnectionRequest writes a OpenConnection request to a byte slice.
1087 func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte {
1088 size := 8
1089 b := 0
1090 buf := make([]byte, size)
1091
1092 c.ExtLock.RLock()
1093 buf[b] = c.Extensions["XFree86-DRI"]
1094 c.ExtLock.RUnlock()
1095 b += 1
1096
1097 buf[b] = 2 // request opcode
1098 b += 1
1099
1100 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
1101 b += 2
1102
1103 xgb.Put32(buf[b:], Screen)
1104 b += 4
1105
1106 return buf
1107 }
1108
1109 // QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests.
1110 type QueryDirectRenderingCapableCookie struct {
1111 *xgb.Cookie
1112 }
1113
1114 // QueryDirectRenderingCapable sends a checked request.
1115 // If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply()
1116 func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie {
1117 c.ExtLock.RLock()
1118 defer c.ExtLock.RUnlock()
1119 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
1120 panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
1121 }
1122 cookie := c.NewCookie(true, true)
1123 c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie)
1124 return QueryDirectRenderingCapableCookie{cookie}
1125 }
1126
1127 // QueryDirectRenderingCapableUnchecked sends an unchecked request.
1128 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
1129 func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie {
1130 c.ExtLock.RLock()
1131 defer c.ExtLock.RUnlock()
1132 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
1133 panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
1134 }
1135 cookie := c.NewCookie(false, true)
1136 c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie)
1137 return QueryDirectRenderingCapableCookie{cookie}
1138 }
1139
1140 // QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request.
1141 type QueryDirectRenderingCapableReply struct {
1142 Sequence uint16 // sequence number of the request for this reply
1143 Length uint32 // number of bytes in this reply
1144 // padding: 1 bytes
1145 IsCapable bool
1146 }
1147
1148 // Reply blocks and returns the reply data for a QueryDirectRenderingCapable request.
1149 func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) {
1150 buf, err := cook.Cookie.Reply()
1151 if err != nil {
1152 return nil, err
1153 }
1154 if buf == nil {
1155 return nil, nil
1156 }
1157 return queryDirectRenderingCapableReply(buf), nil
1158 }
1159
1160 // queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value.
1161 func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply {
1162 v := new(QueryDirectRenderingCapableReply)
1163 b := 1 // skip reply determinant
1164
1165 b += 1 // padding
1166
1167 v.Sequence = xgb.Get16(buf[b:])
1168 b += 2
1169
1170 v.Length = xgb.Get32(buf[b:]) // 4-byte units
1171 b += 4
1172
1173 if buf[b] == 1 {
1174 v.IsCapable = true
1175 } else {
1176 v.IsCapable = false
1177 }
1178 b += 1
1179
1180 return v
1181 }
1182
1183 // Write request to wire for QueryDirectRenderingCapable
1184 // queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice.
1185 func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte {
1186 size := 8
1187 b := 0
1188 buf := make([]byte, size)
1189
1190 c.ExtLock.RLock()
1191 buf[b] = c.Extensions["XFree86-DRI"]
1192 c.ExtLock.RUnlock()
1193 b += 1
1194
1195 buf[b] = 1 // request opcode
1196 b += 1
1197
1198 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
1199 b += 2
1200
1201 xgb.Put32(buf[b:], Screen)
1202 b += 4
1203
1204 return buf
1205 }
1206
1207 // QueryVersionCookie is a cookie used only for QueryVersion requests.
1208 type QueryVersionCookie struct {
1209 *xgb.Cookie
1210 }
1211
1212 // QueryVersion sends a checked request.
1213 // If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
1214 func QueryVersion(c *xgb.Conn) QueryVersionCookie {
1215 c.ExtLock.RLock()
1216 defer c.ExtLock.RUnlock()
1217 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
1218 panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
1219 }
1220 cookie := c.NewCookie(true, true)
1221 c.NewRequest(queryVersionRequest(c), cookie)
1222 return QueryVersionCookie{cookie}
1223 }
1224
1225 // QueryVersionUnchecked sends an unchecked request.
1226 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
1227 func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie {
1228 c.ExtLock.RLock()
1229 defer c.ExtLock.RUnlock()
1230 if _, ok := c.Extensions["XFree86-DRI"]; !ok {
1231 panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
1232 }
1233 cookie := c.NewCookie(false, true)
1234 c.NewRequest(queryVersionRequest(c), cookie)
1235 return QueryVersionCookie{cookie}
1236 }
1237
1238 // QueryVersionReply represents the data returned from a QueryVersion request.
1239 type QueryVersionReply struct {
1240 Sequence uint16 // sequence number of the request for this reply
1241 Length uint32 // number of bytes in this reply
1242 // padding: 1 bytes
1243 DriMajorVersion uint16
1244 DriMinorVersion uint16
1245 DriMinorPatch uint32
1246 }
1247
1248 // Reply blocks and returns the reply data for a QueryVersion request.
1249 func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
1250 buf, err := cook.Cookie.Reply()
1251 if err != nil {
1252 return nil, err
1253 }
1254 if buf == nil {
1255 return nil, nil
1256 }
1257 return queryVersionReply(buf), nil
1258 }
1259
1260 // queryVersionReply reads a byte slice into a QueryVersionReply value.
1261 func queryVersionReply(buf []byte) *QueryVersionReply {
1262 v := new(QueryVersionReply)
1263 b := 1 // skip reply determinant
1264
1265 b += 1 // padding
1266
1267 v.Sequence = xgb.Get16(buf[b:])
1268 b += 2
1269
1270 v.Length = xgb.Get32(buf[b:]) // 4-byte units
1271 b += 4
1272
1273 v.DriMajorVersion = xgb.Get16(buf[b:])
1274 b += 2
1275
1276 v.DriMinorVersion = xgb.Get16(buf[b:])
1277 b += 2
1278
1279 v.DriMinorPatch = xgb.Get32(buf[b:])
1280 b += 4
1281
1282 return v
1283 }
1284
1285 // Write request to wire for QueryVersion
1286 // queryVersionRequest writes a QueryVersion request to a byte slice.
1287 func queryVersionRequest(c *xgb.Conn) []byte {
1288 size := 4
1289 b := 0
1290 buf := make([]byte, size)
1291
1292 c.ExtLock.RLock()
1293 buf[b] = c.Extensions["XFree86-DRI"]
1294 c.ExtLock.RUnlock()
1295 b += 1
1296
1297 buf[b] = 0 // request opcode
1298 b += 1
1299
1300 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
1301 b += 2
1302
1303 return buf
1304 }