-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwl_seat.go
113 lines (102 loc) · 2.16 KB
/
wl_seat.go
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
package main
import (
"fmt"
)
type WlSeat struct {
Object *WaylandObject
Name string
Children []*WaylandObject
}
func (*WlSeat) DashboardShouldDisplay() bool {
return true
}
func (*WlSeat) DashboardCategory() string {
return "Seats"
}
func (seat *WlSeat) DashboardPrint(printer func(string, ...interface{})) error {
s := seat.Object.String()
if seat.Name != "" {
s += fmt.Sprintf(" %q", seat.Name)
}
printer("%s - %s", Indent(0), s)
for _, child := range seat.Children {
if i, ok := child.Data.(interface {
dashboardPrint(func(string, ...interface{}), int) error
}); ok {
i.dashboardPrint(printer, 1)
}
}
return nil
}
func (r *WlSeat) Destroy() error {
return nil
}
type WlSeatImpl struct {
client *Client
}
func RegisterWlSeat(client *Client) {
r := &WlSeatImpl{
client: client,
}
client.Impls["wl_seat"] = r
}
func (r *WlSeatImpl) Create(obj *WaylandObject) Destroyable {
return &WlSeat{
Object: obj,
}
}
func (r *WlSeatImpl) Request(packet *WaylandPacket) error {
object := r.client.ObjectMap[packet.ObjectId]
seat := object.Data.(*WlSeat)
switch packet.Opcode {
case 0: // get_pointer
oid, err := packet.ReadUint32()
if err != nil {
return err
}
obj := r.client.NewObject(oid, "wl_pointer")
obj.Data = &WlPointer{
Object: obj,
Seat: seat,
}
seat.Children = append(seat.Children, obj)
case 1: // get_keyboard
oid, err := packet.ReadUint32()
if err != nil {
return err
}
obj := r.client.NewObject(oid, "wl_keyboard")
obj.Data = &WlKeyboard{
Object: obj,
Seat: seat,
}
seat.Children = append(seat.Children, obj)
case 2: // get_touch
oid, err := packet.ReadUint32()
if err != nil {
return err
}
obj := r.client.NewObject(oid, "wl_touch")
obj.Data = &WlTouch{
Object: obj,
Seat: seat,
}
seat.Children = append(seat.Children, obj)
case 3: // release
}
return nil
}
func (r *WlSeatImpl) Event(packet *WaylandPacket) error {
object := r.client.ObjectMap[packet.ObjectId]
seat := object.Data.(*WlSeat)
switch packet.Opcode {
case 0: // capabilities
case 1: // name
name, err := packet.ReadString()
if err != nil {
return err
}
seat.Name = name
}
return nil
}