File: test.go

package info (click to toggle)
golang-github-linuxdeepin-go-x11-client 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,784 kB
  • sloc: python: 944; sh: 38; makefile: 17
file content (86 lines) | stat: -rw-r--r-- 1,641 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

package test

import (
	x "github.com/linuxdeepin/go-x11-client"
)

// #WREQ
func encodeGetVersion(majorVersion uint8, minorVersion uint16) (b x.RequestBody) {
	b.AddBlock(1).
		Write1b(majorVersion).
		WritePad(1).
		Write2b(minorVersion).
		End()
	return
}

type GetVersionReply struct {
	MajorVersion uint8
	MinorVersion uint16
}

func readGetVersionReply(r *x.Reader, v *GetVersionReply) error {
	if !r.RemainAtLeast4b(3) {
		return x.ErrDataLenShort
	}
	v.MajorVersion, _ = r.ReadReplyHeader()

	v.MinorVersion = r.Read2b() // 3

	return nil
}

// #WREQ
func encodeCompareCursor(window x.Window, cursor x.Cursor) (b x.RequestBody) {
	b.AddBlock(2).
		Write4b(uint32(window)).
		Write4b(uint32(cursor)).
		End()
	return
}

type CompareCursorReply struct {
	Same bool
}

func readCompareCursorReply(r *x.Reader, v *CompareCursorReply) error {
	if !r.RemainAtLeast4b(2) {
		return x.ErrDataLenShort
	}

	same, _ := r.ReadReplyHeader() // 2
	v.Same = x.Uint8ToBool(same)
	return nil
}

// #WREQ
func encodeFakeInput(evType uint8, detail uint8, time x.Timestamp, root x.Window,
	rootX, rootY int16, deviceId uint8) (b x.RequestBody) {

	b.AddBlock(8).
		Write1b(evType).
		Write1b(detail).
		WritePad(2).
		Write4b(uint32(time)).
		Write4b(uint32(root)).
		WritePad(8).
		Write2b(uint16(rootX)).
		Write2b(uint16(rootY)).
		WritePad(7).
		Write1b(deviceId).
		End()
	return
}

// #WREQ
func encodeGrabControl(impervious bool) (b x.RequestBody) {
	b.AddBlock(1).
		WriteBool(impervious).
		WritePad(3).
		End()
	return
}