Skip to content

Commit

Permalink
Show configure info
Browse files Browse the repository at this point in the history
  • Loading branch information
kennylevinsen committed Jun 3, 2020
1 parent 2cf80b9 commit 1caef08
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
15 changes: 15 additions & 0 deletions clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (clients *ClientsView) showSurface(ctx *libui.Context, surface *WlSurface,

rolestr := "<unknown>"
suffix := ""
details := ""
if surface.Current.Role != nil {
switch role := surface.Current.Role.(type) {
case WlSubSurfaceState:
Expand All @@ -56,6 +57,11 @@ func (clients *ClientsView) showSurface(ctx *libui.Context, surface *WlSurface,
if xdg_role.Parent != nil {
suffix = fmt.Sprintf("%s, parent: %s", suffix, xdg_role.Parent.Object.String())
}
if role.CurrentConfigure.Serial == role.PendingConfigure.Serial {
details = fmt.Sprintf("current: w=%d h=%d", role.CurrentConfigure.Width, role.CurrentConfigure.Height)
} else {
details = fmt.Sprintf("current: w=%d h=%d, pending: w=%d h=%d", role.CurrentConfigure.Width, role.CurrentConfigure.Height, role.PendingConfigure.Width, role.PendingConfigure.Height)
}
case XdgPopupState:
suffix = fmt.Sprintf(", parent: %s", xdg_role.XdgPopup.Parent.Object.String())
}
Expand All @@ -64,6 +70,15 @@ func (clients *ClientsView) showSurface(ctx *libui.Context, surface *WlSurface,
ctx.Printf(0, y, tcell.StyleDefault,
"%s%s, role: %s, buffers: %d, frames: %d/%d%s", prefix, surface.Object, rolestr, surface.Current.BufferNum, surface.Frames, surface.RequestedFrames, suffix)
y++
if details != "" && y < ctx.Height() {
prefix := ""
for i := 0; i <= depth+3; i++ {
prefix += " "
}
ctx.Printf(0, y, tcell.StyleDefault,
"%s%s", prefix, details)
y++
}
for _, child := range surface.Current.Children {
if y >= ctx.Height() {
return y
Expand Down
30 changes: 26 additions & 4 deletions xdg_shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ import (
// Yes, I know. I regret everything.
//

type XdgConfigure struct {
Serial int32
Width int32
Height int32
}

type XdgSurfaceState struct {
XdgSurface *XdgSurface
CurrentConfigure, PendingConfigure int32
CurrentConfigure, PendingConfigure XdgConfigure
GeometryX, GeometryY, GeometryW, GeometryH int32
XdgRole interface{}
}
Expand Down Expand Up @@ -172,7 +178,10 @@ func (r *XdgSurfaceImpl) Request(packet *WaylandPacket) error {
if err != nil {
return err
}
robj.CurrentConfigure = conf
if robj.PendingConfigure.Serial == conf {
robj.CurrentConfigure = robj.PendingConfigure
}
xdg_surface.Surface.Next.Role = robj
}
return nil
}
Expand All @@ -186,8 +195,7 @@ func (r *XdgSurfaceImpl) Event(packet *WaylandPacket) error {
if err != nil {
return err
}
robj.PendingConfigure = conf

robj.PendingConfigure.Serial = conf
}
object.Data.(*XdgSurface).Surface.Next.Role = robj
return nil
Expand Down Expand Up @@ -278,8 +286,22 @@ func (r *XdgToplevelImpl) Request(packet *WaylandPacket) error {
}

func (r *XdgToplevelImpl) Event(packet *WaylandPacket) error {
object := r.client.ObjectMap[packet.ObjectId]
xdg_surface := object.Data.(*XdgToplevel).XdgSurface
xdgstate := xdg_surface.Surface.Next.Role.(XdgSurfaceState)
switch packet.Opcode {
case 0: // configure
width, err := packet.ReadInt32()
if err != nil && err != io.EOF {
return err
}
height, err := packet.ReadInt32()
if err != nil && err != io.EOF {
return err
}
xdgstate.PendingConfigure.Width = width
xdgstate.PendingConfigure.Height = height
xdg_surface.Surface.Next.Role = xdgstate
case 1: // close
}
return nil
Expand Down

0 comments on commit 1caef08

Please sign in to comment.