Skip to content

Commit

Permalink
wl_seat: show name
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion authored and kennylevinsen committed Mar 8, 2024
1 parent 7411538 commit b71e5be
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion wl_seat.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package main

import (
"fmt"
)

type WlSeat struct {
Object *WaylandObject
Name string
Children []*WaylandObject
}

Expand All @@ -14,7 +19,11 @@ func (*WlSeat) DashboardCategory() string {
}

func (seat *WlSeat) DashboardPrint(printer func(string, ...interface{})) error {
printer("%s - %s", Indent(0), seat.Object)
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
Expand Down Expand Up @@ -89,9 +98,16 @@ func (r *WlSeatImpl) Request(packet *WaylandPacket) error {
}

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
}

0 comments on commit b71e5be

Please sign in to comment.