summaryrefslogtreecommitdiff
path: root/macos/Sources/Features/QuickTerminal/QuickTerminalSpaceBehavior.swift
blob: 0561aaa1888372e8cbdf4dea610e976f071174c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Foundation
import Cocoa

enum QuickTerminalSpaceBehavior {
    case remain
    case move

    init?(fromGhosttyConfig string: String) {
        switch (string) {
            case "move":
                self = .move

            case "remain":
                self = .remain

            default:
                return nil
        }
    }

    var collectionBehavior: NSWindow.CollectionBehavior {
        let commonBehavior: [NSWindow.CollectionBehavior] = [
            .ignoresCycle,
            .fullScreenAuxiliary
        ]

        switch (self) {
            case .move:
                // We want this to move the window to the active space.
                return NSWindow.CollectionBehavior([.canJoinAllSpaces] + commonBehavior)
            case .remain:
                // We want this to remain the window in the current space.
                return NSWindow.CollectionBehavior([.moveToActiveSpace] + commonBehavior)
        }
    }
}