| 1 | |
| 2 | |
| 3 | @@ -536,8 +536,15 @@ |
| 4 | return errCh, nil |
| 5 | } |
| 6 | |
| 7 | +// OffscreenView lets an embedding application service a user-authorized login |
| 8 | +// view without opening Lima's VM window. The application must bind the exact instance. |
| 9 | +var OffscreenView func(ctx context.Context, machine *vz.VirtualMachine, instanceDir string) error |
| 10 | +var OwnsOffscreenView func(instanceDir string) bool |
| 11 | + |
| 12 | func (l *LimaVzDriver) canRunGUI() bool { |
| 13 | switch *l.Instance.Config.Video.Display { |
| 14 | + case "offscreen": |
| 15 | + return *l.Instance.Config.OS == limatype.DARWIN && OffscreenView != nil && OwnsOffscreenView != nil && OwnsOffscreenView(l.Instance.Dir) |
| 16 | case "vz", "default": |
| 17 | return true |
| 18 | default: |
| 19 | @@ -545,8 +552,11 @@ |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | -func (l *LimaVzDriver) RunGUI(_ context.Context) error { |
| 24 | +func (l *LimaVzDriver) RunGUI(ctx context.Context) error { |
| 25 | if l.canRunGUI() { |
| 26 | + if *l.Instance.Config.Video.Display == "offscreen" { |
| 27 | + return OffscreenView(ctx, l.machine.VirtualMachine, l.Instance.Dir) |
| 28 | + } |
| 29 | title := fmt.Sprintf("Lima: %s", l.Instance.Name) |
| 30 | return l.machine.StartGraphicApplication(1920, 1200, vz.WithWindowTitle(title)) |
| 31 | } |