Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display(macos): add a setting to start a given VM in fullscreen #6274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Configuration/UTMConfigurationInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ struct UTMConfigurationInfo: Codable {
/// VM name displayed to user.
var name: String = NSLocalizedString("Virtual Machine", comment: "UTMConfigurationInfo")

#if os(macOS)
/// If true, starts the VM in full screen.
var isFullScreenStart: Bool = false
#endif

/// Path to the icon.
var iconURL: URL?

Expand All @@ -39,6 +44,7 @@ struct UTMConfigurationInfo: Codable {
case isIconCustom = "IconCustom"
case notes = "Notes"
case uuid = "UUID"
case isFullScreenStart = "IsFullScreenStart"
}

init() {
Expand All @@ -59,6 +65,9 @@ struct UTMConfigurationInfo: Codable {
}
notes = try values.decodeIfPresent(String.self, forKey: .notes)
uuid = try values.decode(UUID.self, forKey: .uuid)
#if os(macOS)
isFullScreenStart = try values.decodeIfPresent(Bool.self, forKey: .isFullScreenStart) ?? false
#endif
}

func encode(to encoder: Encoder) throws {
Expand All @@ -75,6 +84,9 @@ struct UTMConfigurationInfo: Codable {
}
try container.encodeIfPresent(notes, forKey: .notes)
try container.encode(uuid, forKey: .uuid)
#if os(macOS)
try container.encode(isFullScreenStart, forKey: .isFullScreenStart)
#endif
}

static func builtinIcon(named name: String) -> URL? {
Expand Down
9 changes: 9 additions & 0 deletions Platform/Shared/VMConfigInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ struct VMConfigInfoView: View {
Text("Name").frame(width: 50, alignment: .trailing)
nameField
}
HStack {
Text("").frame(width: 50, alignment: .trailing)
Toggle(isOn:
$config.isFullScreenStart,
label: {
Text("Start the VM display(s) in full screen")
}
)
}
HStack(alignment: .top) {
Text("Notes").frame(width: 50, alignment: .trailing)
notesField
Expand Down
4 changes: 4 additions & 0 deletions Platform/macOS/UTMDataExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ extension UTMData {
vm.wrapped!.delegate = unwrappedWindow
unwrappedWindow.showWindow(nil)
unwrappedWindow.window!.makeMain()
if vm.wrapped!.config.information.isFullScreenStart && !unwrappedWindow.window!.styleMask.contains(.fullScreen) {
unwrappedWindow.window!.toggleFullScreen(nil)
}

if startImmediately {
unwrappedWindow.requestAutoStart(options: options)
}
Expand Down