go-tg-screenshot-bot

Форк
0
718 строк · 18.7 Кб
1
// Package xinerama is the X client API for the XINERAMA extension.
2
package xinerama
3

4
// This file is automatically generated from xinerama.xml. Edit at your peril!
5

6
import (
7
	"github.com/jezek/xgb"
8

9
	"github.com/jezek/xgb/xproto"
10
)
11

12
// Init must be called before using the XINERAMA extension.
13
func Init(c *xgb.Conn) error {
14
	reply, err := xproto.QueryExtension(c, 8, "XINERAMA").Reply()
15
	switch {
16
	case err != nil:
17
		return err
18
	case !reply.Present:
19
		return xgb.Errorf("No extension named XINERAMA could be found on on the server.")
20
	}
21

22
	c.ExtLock.Lock()
23
	c.Extensions["XINERAMA"] = reply.MajorOpcode
24
	c.ExtLock.Unlock()
25
	for evNum, fun := range xgb.NewExtEventFuncs["XINERAMA"] {
26
		xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
27
	}
28
	for errNum, fun := range xgb.NewExtErrorFuncs["XINERAMA"] {
29
		xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
30
	}
31
	return nil
32
}
33

34
func init() {
35
	xgb.NewExtEventFuncs["XINERAMA"] = make(map[int]xgb.NewEventFun)
36
	xgb.NewExtErrorFuncs["XINERAMA"] = make(map[int]xgb.NewErrorFun)
37
}
38

39
type ScreenInfo struct {
40
	XOrg   int16
41
	YOrg   int16
42
	Width  uint16
43
	Height uint16
44
}
45

46
// ScreenInfoRead reads a byte slice into a ScreenInfo value.
47
func ScreenInfoRead(buf []byte, v *ScreenInfo) int {
48
	b := 0
49

50
	v.XOrg = int16(xgb.Get16(buf[b:]))
51
	b += 2
52

53
	v.YOrg = int16(xgb.Get16(buf[b:]))
54
	b += 2
55

56
	v.Width = xgb.Get16(buf[b:])
57
	b += 2
58

59
	v.Height = xgb.Get16(buf[b:])
60
	b += 2
61

62
	return b
63
}
64

65
// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values.
66
func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int {
67
	b := 0
68
	for i := 0; i < len(dest); i++ {
69
		dest[i] = ScreenInfo{}
70
		b += ScreenInfoRead(buf[b:], &dest[i])
71
	}
72
	return xgb.Pad(b)
73
}
74

75
// Bytes writes a ScreenInfo value to a byte slice.
76
func (v ScreenInfo) Bytes() []byte {
77
	buf := make([]byte, 8)
78
	b := 0
79

80
	xgb.Put16(buf[b:], uint16(v.XOrg))
81
	b += 2
82

83
	xgb.Put16(buf[b:], uint16(v.YOrg))
84
	b += 2
85

86
	xgb.Put16(buf[b:], v.Width)
87
	b += 2
88

89
	xgb.Put16(buf[b:], v.Height)
90
	b += 2
91

92
	return buf[:b]
93
}
94

95
// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice.
96
func ScreenInfoListBytes(buf []byte, list []ScreenInfo) 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
// GetScreenCountCookie is a cookie used only for GetScreenCount requests.
132
type GetScreenCountCookie struct {
133
	*xgb.Cookie
134
}
135

136
// GetScreenCount sends a checked request.
137
// If an error occurs, it will be returned with the reply by calling GetScreenCountCookie.Reply()
138
func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie {
139
	c.ExtLock.RLock()
140
	defer c.ExtLock.RUnlock()
141
	if _, ok := c.Extensions["XINERAMA"]; !ok {
142
		panic("Cannot issue request 'GetScreenCount' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
143
	}
144
	cookie := c.NewCookie(true, true)
145
	c.NewRequest(getScreenCountRequest(c, Window), cookie)
146
	return 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.
151
func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie {
152
	c.ExtLock.RLock()
153
	defer c.ExtLock.RUnlock()
154
	if _, ok := c.Extensions["XINERAMA"]; !ok {
155
		panic("Cannot issue request 'GetScreenCount' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
156
	}
157
	cookie := c.NewCookie(false, true)
158
	c.NewRequest(getScreenCountRequest(c, Window), cookie)
159
	return GetScreenCountCookie{cookie}
160
}
161

162
// GetScreenCountReply represents the data returned from a GetScreenCount request.
163
type GetScreenCountReply struct {
164
	Sequence    uint16 // sequence number of the request for this reply
165
	Length      uint32 // number of bytes in this reply
166
	ScreenCount byte
167
	Window      xproto.Window
168
}
169

170
// Reply blocks and returns the reply data for a GetScreenCount request.
171
func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, 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 getScreenCountReply(buf), nil
180
}
181

182
// getScreenCountReply reads a byte slice into a GetScreenCountReply value.
183
func getScreenCountReply(buf []byte) *GetScreenCountReply {
184
	v := new(GetScreenCountReply)
185
	b := 1 // skip reply determinant
186

187
	v.ScreenCount = buf[b]
188
	b += 1
189

190
	v.Sequence = xgb.Get16(buf[b:])
191
	b += 2
192

193
	v.Length = xgb.Get32(buf[b:]) // 4-byte units
194
	b += 4
195

196
	v.Window = xproto.Window(xgb.Get32(buf[b:]))
197
	b += 4
198

199
	return v
200
}
201

202
// Write request to wire for GetScreenCount
203
// getScreenCountRequest writes a GetScreenCount request to a byte slice.
204
func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte {
205
	size := 8
206
	b := 0
207
	buf := make([]byte, size)
208

209
	c.ExtLock.RLock()
210
	buf[b] = c.Extensions["XINERAMA"]
211
	c.ExtLock.RUnlock()
212
	b += 1
213

214
	buf[b] = 2 // request opcode
215
	b += 1
216

217
	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
218
	b += 2
219

220
	xgb.Put32(buf[b:], uint32(Window))
221
	b += 4
222

223
	return buf
224
}
225

226
// GetScreenSizeCookie is a cookie used only for GetScreenSize requests.
227
type GetScreenSizeCookie struct {
228
	*xgb.Cookie
229
}
230

231
// GetScreenSize sends a checked request.
232
// If an error occurs, it will be returned with the reply by calling GetScreenSizeCookie.Reply()
233
func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie {
234
	c.ExtLock.RLock()
235
	defer c.ExtLock.RUnlock()
236
	if _, ok := c.Extensions["XINERAMA"]; !ok {
237
		panic("Cannot issue request 'GetScreenSize' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
238
	}
239
	cookie := c.NewCookie(true, true)
240
	c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie)
241
	return 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.
246
func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie {
247
	c.ExtLock.RLock()
248
	defer c.ExtLock.RUnlock()
249
	if _, ok := c.Extensions["XINERAMA"]; !ok {
250
		panic("Cannot issue request 'GetScreenSize' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
251
	}
252
	cookie := c.NewCookie(false, true)
253
	c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie)
254
	return GetScreenSizeCookie{cookie}
255
}
256

257
// GetScreenSizeReply represents the data returned from a GetScreenSize request.
258
type GetScreenSizeReply struct {
259
	Sequence uint16 // sequence number of the request for this reply
260
	Length   uint32 // number of bytes in this reply
261
	// padding: 1 bytes
262
	Width  uint32
263
	Height uint32
264
	Window xproto.Window
265
	Screen uint32
266
}
267

268
// Reply blocks and returns the reply data for a GetScreenSize request.
269
func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) {
270
	buf, err := cook.Cookie.Reply()
271
	if err != nil {
272
		return nil, err
273
	}
274
	if buf == nil {
275
		return nil, nil
276
	}
277
	return getScreenSizeReply(buf), nil
278
}
279

280
// getScreenSizeReply reads a byte slice into a GetScreenSizeReply value.
281
func getScreenSizeReply(buf []byte) *GetScreenSizeReply {
282
	v := new(GetScreenSizeReply)
283
	b := 1 // skip reply determinant
284

285
	b += 1 // padding
286

287
	v.Sequence = xgb.Get16(buf[b:])
288
	b += 2
289

290
	v.Length = xgb.Get32(buf[b:]) // 4-byte units
291
	b += 4
292

293
	v.Width = xgb.Get32(buf[b:])
294
	b += 4
295

296
	v.Height = xgb.Get32(buf[b:])
297
	b += 4
298

299
	v.Window = xproto.Window(xgb.Get32(buf[b:]))
300
	b += 4
301

302
	v.Screen = xgb.Get32(buf[b:])
303
	b += 4
304

305
	return v
306
}
307

308
// Write request to wire for GetScreenSize
309
// getScreenSizeRequest writes a GetScreenSize request to a byte slice.
310
func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []byte {
311
	size := 12
312
	b := 0
313
	buf := make([]byte, size)
314

315
	c.ExtLock.RLock()
316
	buf[b] = c.Extensions["XINERAMA"]
317
	c.ExtLock.RUnlock()
318
	b += 1
319

320
	buf[b] = 3 // request opcode
321
	b += 1
322

323
	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
324
	b += 2
325

326
	xgb.Put32(buf[b:], uint32(Window))
327
	b += 4
328

329
	xgb.Put32(buf[b:], Screen)
330
	b += 4
331

332
	return buf
333
}
334

335
// GetStateCookie is a cookie used only for GetState requests.
336
type GetStateCookie struct {
337
	*xgb.Cookie
338
}
339

340
// GetState sends a checked request.
341
// If an error occurs, it will be returned with the reply by calling GetStateCookie.Reply()
342
func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie {
343
	c.ExtLock.RLock()
344
	defer c.ExtLock.RUnlock()
345
	if _, ok := c.Extensions["XINERAMA"]; !ok {
346
		panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
347
	}
348
	cookie := c.NewCookie(true, true)
349
	c.NewRequest(getStateRequest(c, Window), cookie)
350
	return 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.
355
func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie {
356
	c.ExtLock.RLock()
357
	defer c.ExtLock.RUnlock()
358
	if _, ok := c.Extensions["XINERAMA"]; !ok {
359
		panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
360
	}
361
	cookie := c.NewCookie(false, true)
362
	c.NewRequest(getStateRequest(c, Window), cookie)
363
	return GetStateCookie{cookie}
364
}
365

366
// GetStateReply represents the data returned from a GetState request.
367
type GetStateReply struct {
368
	Sequence uint16 // sequence number of the request for this reply
369
	Length   uint32 // number of bytes in this reply
370
	State    byte
371
	Window   xproto.Window
372
}
373

374
// Reply blocks and returns the reply data for a GetState request.
375
func (cook GetStateCookie) Reply() (*GetStateReply, error) {
376
	buf, err := cook.Cookie.Reply()
377
	if err != nil {
378
		return nil, err
379
	}
380
	if buf == nil {
381
		return nil, nil
382
	}
383
	return getStateReply(buf), nil
384
}
385

386
// getStateReply reads a byte slice into a GetStateReply value.
387
func getStateReply(buf []byte) *GetStateReply {
388
	v := new(GetStateReply)
389
	b := 1 // skip reply determinant
390

391
	v.State = buf[b]
392
	b += 1
393

394
	v.Sequence = xgb.Get16(buf[b:])
395
	b += 2
396

397
	v.Length = xgb.Get32(buf[b:]) // 4-byte units
398
	b += 4
399

400
	v.Window = xproto.Window(xgb.Get32(buf[b:]))
401
	b += 4
402

403
	return v
404
}
405

406
// Write request to wire for GetState
407
// getStateRequest writes a GetState request to a byte slice.
408
func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte {
409
	size := 8
410
	b := 0
411
	buf := make([]byte, size)
412

413
	c.ExtLock.RLock()
414
	buf[b] = c.Extensions["XINERAMA"]
415
	c.ExtLock.RUnlock()
416
	b += 1
417

418
	buf[b] = 1 // request opcode
419
	b += 1
420

421
	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
422
	b += 2
423

424
	xgb.Put32(buf[b:], uint32(Window))
425
	b += 4
426

427
	return buf
428
}
429

430
// IsActiveCookie is a cookie used only for IsActive requests.
431
type IsActiveCookie struct {
432
	*xgb.Cookie
433
}
434

435
// IsActive sends a checked request.
436
// If an error occurs, it will be returned with the reply by calling IsActiveCookie.Reply()
437
func IsActive(c *xgb.Conn) IsActiveCookie {
438
	c.ExtLock.RLock()
439
	defer c.ExtLock.RUnlock()
440
	if _, ok := c.Extensions["XINERAMA"]; !ok {
441
		panic("Cannot issue request 'IsActive' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
442
	}
443
	cookie := c.NewCookie(true, true)
444
	c.NewRequest(isActiveRequest(c), cookie)
445
	return 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.
450
func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie {
451
	c.ExtLock.RLock()
452
	defer c.ExtLock.RUnlock()
453
	if _, ok := c.Extensions["XINERAMA"]; !ok {
454
		panic("Cannot issue request 'IsActive' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
455
	}
456
	cookie := c.NewCookie(false, true)
457
	c.NewRequest(isActiveRequest(c), cookie)
458
	return IsActiveCookie{cookie}
459
}
460

461
// IsActiveReply represents the data returned from a IsActive request.
462
type IsActiveReply struct {
463
	Sequence uint16 // sequence number of the request for this reply
464
	Length   uint32 // number of bytes in this reply
465
	// padding: 1 bytes
466
	State uint32
467
}
468

469
// Reply blocks and returns the reply data for a IsActive request.
470
func (cook IsActiveCookie) Reply() (*IsActiveReply, error) {
471
	buf, err := cook.Cookie.Reply()
472
	if err != nil {
473
		return nil, err
474
	}
475
	if buf == nil {
476
		return nil, nil
477
	}
478
	return isActiveReply(buf), nil
479
}
480

481
// isActiveReply reads a byte slice into a IsActiveReply value.
482
func isActiveReply(buf []byte) *IsActiveReply {
483
	v := new(IsActiveReply)
484
	b := 1 // skip reply determinant
485

486
	b += 1 // padding
487

488
	v.Sequence = xgb.Get16(buf[b:])
489
	b += 2
490

491
	v.Length = xgb.Get32(buf[b:]) // 4-byte units
492
	b += 4
493

494
	v.State = xgb.Get32(buf[b:])
495
	b += 4
496

497
	return v
498
}
499

500
// Write request to wire for IsActive
501
// isActiveRequest writes a IsActive request to a byte slice.
502
func isActiveRequest(c *xgb.Conn) []byte {
503
	size := 4
504
	b := 0
505
	buf := make([]byte, size)
506

507
	c.ExtLock.RLock()
508
	buf[b] = c.Extensions["XINERAMA"]
509
	c.ExtLock.RUnlock()
510
	b += 1
511

512
	buf[b] = 4 // request opcode
513
	b += 1
514

515
	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
516
	b += 2
517

518
	return buf
519
}
520

521
// QueryScreensCookie is a cookie used only for QueryScreens requests.
522
type QueryScreensCookie struct {
523
	*xgb.Cookie
524
}
525

526
// QueryScreens sends a checked request.
527
// If an error occurs, it will be returned with the reply by calling QueryScreensCookie.Reply()
528
func QueryScreens(c *xgb.Conn) QueryScreensCookie {
529
	c.ExtLock.RLock()
530
	defer c.ExtLock.RUnlock()
531
	if _, ok := c.Extensions["XINERAMA"]; !ok {
532
		panic("Cannot issue request 'QueryScreens' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
533
	}
534
	cookie := c.NewCookie(true, true)
535
	c.NewRequest(queryScreensRequest(c), cookie)
536
	return 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.
541
func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie {
542
	c.ExtLock.RLock()
543
	defer c.ExtLock.RUnlock()
544
	if _, ok := c.Extensions["XINERAMA"]; !ok {
545
		panic("Cannot issue request 'QueryScreens' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
546
	}
547
	cookie := c.NewCookie(false, true)
548
	c.NewRequest(queryScreensRequest(c), cookie)
549
	return QueryScreensCookie{cookie}
550
}
551

552
// QueryScreensReply represents the data returned from a QueryScreens request.
553
type QueryScreensReply struct {
554
	Sequence uint16 // sequence number of the request for this reply
555
	Length   uint32 // number of bytes in this reply
556
	// padding: 1 bytes
557
	Number uint32
558
	// padding: 20 bytes
559
	ScreenInfo []ScreenInfo // size: xgb.Pad((int(Number) * 8))
560
}
561

562
// Reply blocks and returns the reply data for a QueryScreens request.
563
func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) {
564
	buf, err := cook.Cookie.Reply()
565
	if err != nil {
566
		return nil, err
567
	}
568
	if buf == nil {
569
		return nil, nil
570
	}
571
	return queryScreensReply(buf), nil
572
}
573

574
// queryScreensReply reads a byte slice into a QueryScreensReply value.
575
func queryScreensReply(buf []byte) *QueryScreensReply {
576
	v := new(QueryScreensReply)
577
	b := 1 // skip reply determinant
578

579
	b += 1 // padding
580

581
	v.Sequence = xgb.Get16(buf[b:])
582
	b += 2
583

584
	v.Length = xgb.Get32(buf[b:]) // 4-byte units
585
	b += 4
586

587
	v.Number = xgb.Get32(buf[b:])
588
	b += 4
589

590
	b += 20 // padding
591

592
	v.ScreenInfo = make([]ScreenInfo, v.Number)
593
	b += ScreenInfoReadList(buf[b:], v.ScreenInfo)
594

595
	return v
596
}
597

598
// Write request to wire for QueryScreens
599
// queryScreensRequest writes a QueryScreens request to a byte slice.
600
func queryScreensRequest(c *xgb.Conn) []byte {
601
	size := 4
602
	b := 0
603
	buf := make([]byte, size)
604

605
	c.ExtLock.RLock()
606
	buf[b] = c.Extensions["XINERAMA"]
607
	c.ExtLock.RUnlock()
608
	b += 1
609

610
	buf[b] = 5 // request opcode
611
	b += 1
612

613
	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
614
	b += 2
615

616
	return buf
617
}
618

619
// QueryVersionCookie is a cookie used only for QueryVersion requests.
620
type QueryVersionCookie struct {
621
	*xgb.Cookie
622
}
623

624
// QueryVersion sends a checked request.
625
// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
626
func QueryVersion(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie {
627
	c.ExtLock.RLock()
628
	defer c.ExtLock.RUnlock()
629
	if _, ok := c.Extensions["XINERAMA"]; !ok {
630
		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
631
	}
632
	cookie := c.NewCookie(true, true)
633
	c.NewRequest(queryVersionRequest(c, Major, Minor), cookie)
634
	return 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.
639
func QueryVersionUnchecked(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie {
640
	c.ExtLock.RLock()
641
	defer c.ExtLock.RUnlock()
642
	if _, ok := c.Extensions["XINERAMA"]; !ok {
643
		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.")
644
	}
645
	cookie := c.NewCookie(false, true)
646
	c.NewRequest(queryVersionRequest(c, Major, Minor), cookie)
647
	return QueryVersionCookie{cookie}
648
}
649

650
// QueryVersionReply represents the data returned from a QueryVersion request.
651
type QueryVersionReply struct {
652
	Sequence uint16 // sequence number of the request for this reply
653
	Length   uint32 // number of bytes in this reply
654
	// padding: 1 bytes
655
	Major uint16
656
	Minor uint16
657
}
658

659
// Reply blocks and returns the reply data for a QueryVersion request.
660
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
661
	buf, err := cook.Cookie.Reply()
662
	if err != nil {
663
		return nil, err
664
	}
665
	if buf == nil {
666
		return nil, nil
667
	}
668
	return queryVersionReply(buf), nil
669
}
670

671
// queryVersionReply reads a byte slice into a QueryVersionReply value.
672
func queryVersionReply(buf []byte) *QueryVersionReply {
673
	v := new(QueryVersionReply)
674
	b := 1 // skip reply determinant
675

676
	b += 1 // padding
677

678
	v.Sequence = xgb.Get16(buf[b:])
679
	b += 2
680

681
	v.Length = xgb.Get32(buf[b:]) // 4-byte units
682
	b += 4
683

684
	v.Major = xgb.Get16(buf[b:])
685
	b += 2
686

687
	v.Minor = xgb.Get16(buf[b:])
688
	b += 2
689

690
	return v
691
}
692

693
// Write request to wire for QueryVersion
694
// queryVersionRequest writes a QueryVersion request to a byte slice.
695
func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte {
696
	size := 8
697
	b := 0
698
	buf := make([]byte, size)
699

700
	c.ExtLock.RLock()
701
	buf[b] = c.Extensions["XINERAMA"]
702
	c.ExtLock.RUnlock()
703
	b += 1
704

705
	buf[b] = 0 // request opcode
706
	b += 1
707

708
	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
709
	b += 2
710

711
	buf[b] = Major
712
	b += 1
713

714
	buf[b] = Minor
715
	b += 1
716

717
	return buf
718
}
719

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.