-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwl_subcompositor.go
67 lines (62 loc) · 1.44 KB
/
wl_subcompositor.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
package main
import (
"errors"
)
type WlSubCompositorImpl struct {
client *Client
}
func RegisterWlSubCompositor(client *Client) {
r := &WlSubCompositorImpl{
client: client,
}
client.Impls["wl_subcompositor"] = r
}
func (r *WlSubCompositorImpl) Request(packet *WaylandPacket) error {
switch packet.Opcode {
case 0: // destroy
case 1: // get_subsurface
oid, err := packet.ReadUint32()
if err != nil {
return err
}
sid, err := packet.ReadUint32()
if err != nil {
return err
}
source_obj := r.client.ObjectMap[sid]
if source_obj == nil {
return errors.New("no such object")
}
source_obj_surface, ok := source_obj.Data.(*WlSurface)
if !ok {
return errors.New("object is not surface")
}
pid, err := packet.ReadUint32()
if err != nil {
return err
}
parent_obj := r.client.ObjectMap[pid]
if parent_obj == nil {
return errors.New("no such object")
}
parent_obj_surface, ok := parent_obj.Data.(*WlSurface)
if !ok {
return errors.New("object is not surface")
}
obj := r.client.NewObject(oid, "wl_subsurface")
d := &WlSubSurface{
Object: obj,
Surface: source_obj_surface,
}
obj.Data = d
parent_obj_surface.Next.Children = append(parent_obj_surface.Next.Children, d)
source_obj_surface.Next.Role = WlSubSurfaceState{
SubSurface: d,
}
source_obj_surface.Next.Parent = parent_obj_surface
}
return nil
}
func (r *WlSubCompositorImpl) Event(packet *WaylandPacket) error {
return nil
}