Skip to content

Commit

Permalink
wl_output: 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 b71e5be commit 3ba0aa0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion wl_output.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package main

import (
"fmt"
)

type WlOutput struct {
Object *WaylandObject
Name string
}

func (*WlOutput) DashboardShouldDisplay() bool {
Expand All @@ -13,7 +18,11 @@ func (*WlOutput) DashboardCategory() string {
}

func (output *WlOutput) DashboardPrint(printer func(string, ...interface{})) error {
printer("%s - %s", Indent(0), output.Object)
s := output.Object.String()
if output.Name != "" {
s += fmt.Sprintf(" %q", output.Name)
}
printer("%s - %s", Indent(0), s)
return nil
}

Expand Down Expand Up @@ -46,11 +55,20 @@ func (r *WlOutputImpl) Request(packet *WaylandPacket) error {
}

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
case 4: // name
name, err := packet.ReadString()
if err != nil {
return err
}
output.Name = name
case 5: // description
}
return nil
}

0 comments on commit 3ba0aa0

Please sign in to comment.