From 2543c4bf9af9242d5bb333805861bcc1e00abe3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sim=C3=A3o?= Date: Sat, 6 Nov 2021 13:55:42 -0300 Subject: [PATCH] added wingui-display cli --- api/wingui/cli.go | 62 ++++++++++++++++++++++++++++++++++++++++++++--- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/api/wingui/cli.go b/api/wingui/cli.go index f35c73c..f6893d1 100644 --- a/api/wingui/cli.go +++ b/api/wingui/cli.go @@ -10,9 +10,53 @@ type Cli struct { *api.ApiCli } -//func (c *Cli) HttpCli() *api.Cli { -// return c.cli -//} +const ( + CCHDEVICENAME = 32 + CCHFORMNAME = 32 + ENUM_CURRENT_SETTINGS uint32 = 0xFFFFFFFF + ENUM_REGISTRY_SETTINGS uint32 = 0xFFFFFFFE + DISP_CHANGE_SUCCESSFUL uint32 = 0 + DISP_CHANGE_RESTART uint32 = 1 + DISP_CHANGE_FAILED uint32 = 0xFFFFFFFF + DISP_CHANGE_BADMODE uint32 = 0xFFFFFFFE +) + +type DEVMODE struct { + DmDeviceName [CCHDEVICENAME]uint16 + DmSpecVersion uint16 + DmDriverVersion uint16 + DmSize uint16 + DmDriverExtra uint16 + DmFields uint32 + DmOrientation int16 + DmPaperSize int16 + DmPaperLength int16 + DmPaperWidth int16 + DmScale int16 + DmCopies int16 + DmDefaultSource int16 + DmPrintQuality int16 + DmColor int16 + DmDuplex int16 + DmYResolution int16 + DmTTOption int16 + DmCollate int16 + DmFormName [CCHFORMNAME]uint16 + DmLogPixels uint16 + DmBitsPerPel uint32 + DmPelsWidth uint32 + DmPelsHeight uint32 + DmDisplayFlags uint32 + DmDisplayFrequency uint32 + DmICMMethod uint32 + DmICMIntent uint32 + DmMediaType uint32 + DmDitherType uint32 + DmReserved1 uint32 + DmReserved2 uint32 + DmPanningWidth uint32 + DmPanningHeight uint32 +} func (c *Cli) ClipRead() (string, error) { ret := "" @@ -208,11 +252,23 @@ func (c *Cli) ScreenRes() ([]byte, error) { } return ret, err } + func (c *Cli) ScreenSetRes(x, y, cor int) error { err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/setres?x=%d&y=%d&c=%d", x, y, cor), nil) return err } +func (c *Cli) DisplayRes() (*DEVMODE, error) { + ret := &DEVMODE{} + err := c.HttpCli().JsonGet("/ipc/wingui/display/res", ret) + return ret, err +} + +func (c *Cli) DisplaySetRes(d *DEVMODE) error { + err := c.HttpCli().JsonPost("/ipc/wingui/display/setres", d, nil) + return err +} + func NewCli() *Cli { ret := &Cli{ApiCli: api.NewApiCli()} return ret diff --git a/go.mod b/go.mod index e2159fe..95ff4f2 100644 --- a/go.mod +++ b/go.mod @@ -10,5 +10,5 @@ require ( github.com/gorilla/websocket v1.4.2 github.com/mitchellh/go-ps v1.0.0 go.digitalcircle.com.br/open/httpcli v0.0.0-20211031093505-ecf33aed8afb - golang.org/x/sys v0.0.0-20211031064116-611d5d643895 // indirect + golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68 // indirect ) diff --git a/go.sum b/go.sum index e194fcc..e3c6a5e 100644 --- a/go.sum +++ b/go.sum @@ -21,3 +21,5 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyX golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211031064116-611d5d643895 h1:iaNpwpnrgL5jzWS0vCNnfa8HqzxveCFpFx3uC/X4Tps= golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68 h1:Ywe/f3fNleF8I6F6qv3MeFoSZ6CTf2zBMMa/7qVML8M= +golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=