diff --git a/clients.go b/clients.go index c749a1e..95ffa8a 100644 --- a/clients.go +++ b/clients.go @@ -41,6 +41,7 @@ func (clients *ClientsView) showSurface(ctx *libui.Context, surface *WlSurface, rolestr := "" suffix := "" + details := "" if surface.Current.Role != nil { switch role := surface.Current.Role.(type) { case WlSubSurfaceState: @@ -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()) } @@ -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 diff --git a/xdg_shell.go b/xdg_shell.go index 5b7cd31..bdf591a 100644 --- a/xdg_shell.go +++ b/xdg_shell.go @@ -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{} } @@ -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 } @@ -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 @@ -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