| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | goruntime "runtime" |
| 5 | |
| 6 | "reasonix/desktop/internal/hostrpc" |
| 7 | ) |
| 8 | |
| 9 | const ( |
| 10 | defaultDesktopWindowWidth = 1240 |
| 11 | defaultDesktopWindowHeight = 720 |
| 12 | ) |
| 13 | |
| 14 | // desktopWindowFrameless reports whether the main window is created without a |
| 15 | // native OS frame. |
| 16 | // |
| 17 | // The main window is frameless on Windows and draws its own chrome: the |
| 18 | // frontend supplies the drag rail (the shell rewrites the drag-region marker |
| 19 | // to -webkit-app-region) and the minimise/maximise/close buttons via the App |
| 20 | // bindings. Remote Serve windows are shell BrowserWindows with the native |
| 21 | // frame and never consult this function. |
| 22 | func desktopWindowFrameless(goos string) bool { |
| 23 | return goos == "windows" |
| 24 | } |
| 25 | |
| 26 | // initialDesktopWindowGeometry reads one saved rectangle. The shell fits it to |
| 27 | // the current displays before creation, regardless of the saved maximise flag. |
| 28 | func initialDesktopWindowGeometry() *hostrpc.WindowGeometry { |
| 29 | geometry := &hostrpc.WindowGeometry{ |
| 30 | Width: defaultDesktopWindowWidth, Height: defaultDesktopWindowHeight, |
| 31 | MinWidth: desktopWindowMinWidth, MinHeight: desktopWindowMinHeight, |
| 32 | Frameless: desktopWindowFrameless(goruntime.GOOS), ZoomFactor: initialDesktopZoomFactor(), |
| 33 | } |
| 34 | if saved, ok := loadWindowState(); ok { |
| 35 | geometry.Width, geometry.Height = saved.Width, saved.Height |
| 36 | geometry.Position = &hostrpc.WindowPosition{X: saved.X, Y: saved.Y} |
| 37 | } |
| 38 | return geometry |
| 39 | } |
| 40 |