5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 06:20:48 +08:00
wails/v2/internal/frontend/dispatcher/systemcalls.go
Lea Anthony 0971857e7e
Fix position runtime (#1123)
* [linux] Move SetTitle and startDrag to main thread

* [linux] Move SetPosition, Center, Fullscreen and UnFullscreen to main thread

* Fix runtime Window Get/Set Position signatures

* Fix vanilla template keyboard handling
2022-02-03 21:42:14 +11:00

39 lines
720 B
Go

package dispatcher
import (
"fmt"
"strings"
"github.com/wailsapp/wails/v2/internal/frontend"
)
const systemCallPrefix = ":wails:"
type position struct {
X int `json:"x"`
Y int `json:"y"`
}
type size struct {
W int `json:"w"`
H int `json:"h"`
}
func (d *Dispatcher) processSystemCall(payload callMessage, sender frontend.Frontend) (interface{}, error) {
// Strip prefix
name := strings.TrimPrefix(payload.Name, systemCallPrefix)
switch name {
case "WindowGetPos":
x, y := sender.WindowGetPosition()
return &position{x, y}, nil
case "WindowGetSize":
w, h := sender.WindowGetSize()
return &size{w, h}, nil
default:
return nil, fmt.Errorf("unknown systemcall message: %s", payload.Name)
}
}