File: test_req_auto.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 (115 lines) | stat: -rw-r--r-- 2,933 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// 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"

func GetVersion(conn *x.Conn, majorVersion uint8, minorVersion uint16) GetVersionCookie {
	body := encodeGetVersion(majorVersion, minorVersion)
	req := &x.ProtocolRequest{
		Ext: _ext,
		Header: x.RequestHeader{
			Data: GetVersionOpcode,
		},
		Body: body,
	}
	seq := conn.SendRequest(x.RequestChecked, req)
	return GetVersionCookie(seq)
}

func (cookie GetVersionCookie) Reply(conn *x.Conn) (*GetVersionReply, error) {
	replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
	if err != nil {
		return nil, err
	}
	r := x.NewReaderFromData(replyBuf)
	var reply GetVersionReply
	err = readGetVersionReply(r, &reply)
	if err != nil {
		return nil, err
	}
	return &reply, nil
}

func CompareCursor(conn *x.Conn, window x.Window, cursor x.Cursor) CompareCursorCookie {
	body := encodeCompareCursor(window, cursor)
	req := &x.ProtocolRequest{
		Ext: _ext,
		Header: x.RequestHeader{
			Data: CompareCursorOpcode,
		},
		Body: body,
	}
	seq := conn.SendRequest(x.RequestChecked, req)
	return CompareCursorCookie(seq)
}

func (cookie CompareCursorCookie) Reply(conn *x.Conn) (*CompareCursorReply, error) {
	replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
	if err != nil {
		return nil, err
	}
	r := x.NewReaderFromData(replyBuf)
	var reply CompareCursorReply
	err = readCompareCursorReply(r, &reply)
	if err != nil {
		return nil, err
	}
	return &reply, nil
}

func FakeInput(conn *x.Conn, evType uint8, detail uint8, time x.Timestamp, root x.Window, rootX, rootY int16, deviceId uint8) {
	body := encodeFakeInput(evType, detail, time, root, rootX, rootY, deviceId)
	req := &x.ProtocolRequest{
		Ext:     _ext,
		NoReply: true,
		Header: x.RequestHeader{
			Data: FakeInputOpcode,
		},
		Body: body,
	}
	conn.SendRequest(0, req)
}

func FakeInputChecked(conn *x.Conn, evType uint8, detail uint8, time x.Timestamp, root x.Window, rootX, rootY int16, deviceId uint8) x.VoidCookie {
	body := encodeFakeInput(evType, detail, time, root, rootX, rootY, deviceId)
	req := &x.ProtocolRequest{
		Ext:     _ext,
		NoReply: true,
		Header: x.RequestHeader{
			Data: FakeInputOpcode,
		},
		Body: body,
	}
	seq := conn.SendRequest(x.RequestChecked, req)
	return x.VoidCookie(seq)
}

func GrabControl(conn *x.Conn, impervious bool) {
	body := encodeGrabControl(impervious)
	req := &x.ProtocolRequest{
		Ext:     _ext,
		NoReply: true,
		Header: x.RequestHeader{
			Data: GrabControlOpcode,
		},
		Body: body,
	}
	conn.SendRequest(0, req)
}

func GrabControlChecked(conn *x.Conn, impervious bool) x.VoidCookie {
	body := encodeGrabControl(impervious)
	req := &x.ProtocolRequest{
		Ext:     _ext,
		NoReply: true,
		Header: x.RequestHeader{
			Data: GrabControlOpcode,
		},
		Body: body,
	}
	seq := conn.SendRequest(x.RequestChecked, req)
	return x.VoidCookie(seq)
}