mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 07:10:40 +08:00
38 lines
718 B
Go
38 lines
718 B
Go
package dispatcher
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/wailsapp/wails/v2/internal/frontend"
|
|
"strings"
|
|
)
|
|
|
|
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.WindowGetPos()
|
|
return &position{x, y}, nil
|
|
case "WindowGetSize":
|
|
w, h := sender.WindowGetSize()
|
|
return &position{w, h}, nil
|
|
default:
|
|
return nil, fmt.Errorf("unknown systemcall message: %s", payload.Name)
|
|
}
|
|
|
|
}
|