waveterm/pkg/service/windowservice/windowservice.go
Mike Sawka e46906d423
wsh rpc working (#55)
lots of iterations on an RPC protocol. getting wsh working with a
getmeta/setmeta command in addition to html mode.
2024-06-17 09:58:28 -07:00

35 lines
748 B
Go

// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
package windowservice
import (
"context"
"github.com/wavetermdev/thenextwave/pkg/wstore"
)
type WindowService struct{}
func (ws *WindowService) SetWindowPosAndSize(ctx context.Context, windowId string, pos *wstore.Point, size *wstore.WinSize) (wstore.UpdatesRtnType, error) {
if pos == nil && size == nil {
return nil, nil
}
ctx = wstore.ContextWithUpdates(ctx)
win, err := wstore.DBMustGet[*wstore.Window](ctx, windowId)
if err != nil {
return nil, err
}
if pos != nil {
win.Pos = *pos
}
if size != nil {
win.WinSize = *size
}
err = wstore.DBUpdate(ctx, win)
if err != nil {
return nil, err
}
return wstore.ContextGetUpdatesRtn(ctx), nil
}