-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwl_output.go
83 lines (72 loc) · 1.44 KB
/
wl_output.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
package main
import (
"fmt"
)
type WlOutput struct {
Object *WaylandObject
Name string
Scale int32
}
func (*WlOutput) DashboardShouldDisplay() bool {
return true
}
func (*WlOutput) DashboardCategory() string {
return "Outputs"
}
func (output *WlOutput) DashboardPrint(printer func(string, ...interface{})) error {
s := output.Object.String()
if output.Name != "" {
s += fmt.Sprintf(" %q", output.Name)
}
if output.Scale != 0 {
s += fmt.Sprintf(", scale: %d", output.Scale)
}
printer("%s - %s", Indent(0), s)
return nil
}
func (*WlOutput) Destroy() error {
return nil
}
type WlOutputImpl struct {
client *Client
}
func RegisterWlOutput(client *Client) {
r := &WlOutputImpl{
client: client,
}
client.Impls["wl_output"] = r
}
func (r *WlOutputImpl) Create(obj *WaylandObject) Destroyable {
return &WlOutput{
Object: obj,
}
}
func (r *WlOutputImpl) Request(packet *WaylandPacket) error {
switch packet.Opcode {
case 0: // release
}
return nil
}
func (r *WlOutputImpl) Event(packet *WaylandPacket) error {
object := r.client.ObjectMap[packet.ObjectId]
output := object.Data.(*WlOutput)
switch packet.Opcode {
case 0: // geometry
case 1: // mode
case 2: // done
case 3: // scale
scale, err := packet.ReadInt32()
if err != nil {
return err
}
output.Scale = scale
case 4: // name
name, err := packet.ReadString()
if err != nil {
return err
}
output.Name = name
case 5: // description
}
return nil
}