Skip to content

Commit

Permalink
2/n Implement macos-native-fullscreen command
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Mar 8, 2024
1 parent d7db373 commit 1041a96
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 6 deletions.
20 changes: 16 additions & 4 deletions AeroSpace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
45AA5FD4A023AF751922BC22 /* BundleEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B7A2DF0D1F72B80B1F04240 /* BundleEx.swift */; };
45EA2D1C90430C432E123B51 /* keysMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C0D40CBD65704BA9595C2FA /* keysMap.swift */; };
4CC374136F60299FB672662D /* DebugWindowsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71908440CD1ADBE13AD58E26 /* DebugWindowsCommand.swift */; };
4E0BC093AD1FBCCA718A26EC /* parseCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07ADCBFC2E29A2AD5C1B7984 /* parseCommand.swift */; };
51AB4C0992703B2E9D0F55E2 /* MonitorDescriptionEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C1D626244E63437F1CA24C3 /* MonitorDescriptionEx.swift */; };
56E72B24303F5F337B31B776 /* TrayMenuModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F5F52E346D024960EAF5938 /* TrayMenuModel.swift */; };
5BA537EABFE48178D6BD2544 /* parseGaps.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCDFB9D7321F08B5CCEF6AFB /* parseGaps.swift */; };
Expand Down Expand Up @@ -69,7 +70,6 @@
A07FCBE4D69DBA4D6990E143 /* FocusSourceOfTruth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 826EA316AB62F913D1A94466 /* FocusSourceOfTruth.swift */; };
A249B6511A9BD20A298C0DE7 /* SplitCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = B65F0D298D61D85CEB29CE77 /* SplitCommand.swift */; };
A2CBF9674964F9083BB198D2 /* ArrayEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 883D7F7F87FBE7D0BDE4E87F /* ArrayEx.swift */; };
A5BFF75CF8021A585BC1F9D5 /* parseCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB03A4736BC3F6D19E4E69F3 /* parseCommand.swift */; };
AC47DF43EFF42358F033C87C /* WorkspaceBackAndForthCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED7EE20910D7BE4D0150CED /* WorkspaceBackAndForthCommand.swift */; };
B04363E8C28CEC76F39977F2 /* MonitorDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 244190F3707EF2BB3CC7FA5A /* MonitorDescription.swift */; };
B0D0C37BAE7E7F0D0FF1E9FC /* GlobalObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2E5977331398421A4FC168 /* GlobalObserver.swift */; };
Expand All @@ -89,6 +89,7 @@
D24D02B1FD87424B908986AF /* ResizeCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB371951459F8CB0137788C2 /* ResizeCommand.swift */; };
DA43825BE8B903C7AAA00D92 /* HotkeyBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69CB1289E3FA51A35F839238 /* HotkeyBinding.swift */; };
DCCC05496BDAAFB745E99624 /* SplitCommandTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D96FF3675C63A83DC8B8969 /* SplitCommandTest.swift */; };
DEE74487CFB70CEC10D9D3D7 /* MacosNativeFullscreenCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3D87FF4D8238F07870F2F6 /* MacosNativeFullscreenCommand.swift */; };
DFEB9F168281870D09BD1C2C /* Common in Frameworks */ = {isa = PBXBuildFile; productRef = 4227A8D8CDB02646B1E1313D /* Common */; };
E1E35DC5D9D74D54E92AB5F3 /* ExecCommandTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A6EF465EF4129BCB10FE247 /* ExecCommandTest.swift */; };
E22ACB36C90695FBAC78226E /* TestWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F1905935B0C61590A96EFEF /* TestWindow.swift */; };
Expand Down Expand Up @@ -116,6 +117,7 @@

/* Begin PBXFileReference section */
00ECDFE176777828D560A737 /* TilingContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TilingContainer.swift; sourceTree = "<group>"; };
07ADCBFC2E29A2AD5C1B7984 /* parseCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = parseCommand.swift; sourceTree = "<group>"; };
09685297933511208058F7CF /* AeroSpace.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AeroSpace.app; sourceTree = BUILT_PRODUCTS_DIR; };
0A9DFF8980BB3F90A3793BE9 /* parseOnWindowDetected.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = parseOnWindowDetected.swift; sourceTree = "<group>"; };
0AEE5470AF418906B180A593 /* mouse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = mouse.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -186,10 +188,10 @@
B65F0D298D61D85CEB29CE77 /* SplitCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitCommand.swift; sourceTree = "<group>"; };
B7DB782C527ABE0CF31740EB /* MacApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacApp.swift; sourceTree = "<group>"; };
BEF353340822CD20E9DAB3EC /* AeroSpace.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AeroSpace.entitlements; sourceTree = "<group>"; };
BF3D87FF4D8238F07870F2F6 /* MacosNativeFullscreenCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacosNativeFullscreenCommand.swift; sourceTree = "<group>"; };
C3F068BCC50ED846DCBFDE57 /* Workspace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Workspace.swift; sourceTree = "<group>"; };
C704028F402C0DE83EDEABB9 /* normalizeContainers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = normalizeContainers.swift; sourceTree = "<group>"; };
C848D6E57FDF22AAF0FB45E6 /* TilingContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TilingContainer.swift; sourceTree = "<group>"; };
CB03A4736BC3F6D19E4E69F3 /* parseCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = parseCommand.swift; sourceTree = "<group>"; };
CB371951459F8CB0137788C2 /* ResizeCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResizeCommand.swift; sourceTree = "<group>"; };
CC4A8803D3A23C26287D449E /* ListMonitorsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListMonitorsTest.swift; sourceTree = "<group>"; };
CCDFB9D7321F08B5CCEF6AFB /* parseGaps.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = parseGaps.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -416,16 +418,17 @@
9ECC990B6C2D66D343216A12 /* FullscreenCommand.swift */,
D27A7AF7E9A049700BDE276B /* JoinWithCommand.swift */,
1A2B673C67B00DBFCC27FFE7 /* LayoutCommand.swift */,
BF3D87FF4D8238F07870F2F6 /* MacosNativeFullscreenCommand.swift */,
4B0CD3C2A0E86CDB9DF312AB /* ModeCommand.swift */,
1376845BAB666880919B9AA2 /* MoveCommand.swift */,
25AC44D0E9450867215FCBEC /* MoveNodeToWorkspaceCommand.swift */,
51CC651BEB897CB7A555D230 /* MoveWorkspaceToMonitorCommand.swift */,
CB03A4736BC3F6D19E4E69F3 /* parseCommand.swift */,
CF3C9038C846369FDD71D1D2 /* ReloadConfigCommand.swift */,
CB371951459F8CB0137788C2 /* ResizeCommand.swift */,
B65F0D298D61D85CEB29CE77 /* SplitCommand.swift */,
EED7EE20910D7BE4D0150CED /* WorkspaceBackAndForthCommand.swift */,
43DD32B1711B8EFCC834B68E /* WorkspaceCommand.swift */,
BC4C93837A34DB0968E73833 /* other */,
9797FA095A9BE84428C5E2C0 /* query */,
);
path = command;
Expand All @@ -442,6 +445,14 @@
path = tree;
sourceTree = "<group>";
};
BC4C93837A34DB0968E73833 /* other */ = {
isa = PBXGroup;
children = (
07ADCBFC2E29A2AD5C1B7984 /* parseCommand.swift */,
);
path = other;
sourceTree = "<group>";
};
C136937AA077E63558E9707C /* util */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -609,6 +620,7 @@
3AFD7EE961B97F38C0914A0C /* ListWorkspacesCommand.swift in Sources */,
BD6301B2CFC16FDE4223ACB8 /* MacApp.swift in Sources */,
EECC59858691B99A95542D72 /* MacWindow.swift in Sources */,
DEE74487CFB70CEC10D9D3D7 /* MacosNativeFullscreenCommand.swift in Sources */,
6E4E235FDA41307B19F16182 /* ModeCommand.swift in Sources */,
C76E421FB0D0F0EB1C93A06C /* Monitor.swift in Sources */,
B04363E8C28CEC76F39977F2 /* MonitorDescription.swift in Sources */,
Expand Down Expand Up @@ -641,7 +653,7 @@
045D4B46ABACA9E8167EF356 /* mouse.swift in Sources */,
78622D72C0CCE8D69B080D29 /* moveWithMouse.swift in Sources */,
B19980B36D066FD4947D2F92 /* normalizeContainers.swift in Sources */,
A5BFF75CF8021A585BC1F9D5 /* parseCommand.swift in Sources */,
4E0BC093AD1FBCCA718A26EC /* parseCommand.swift in Sources */,
A0765C31043BCFB0420BF1C9 /* parseConfig.swift in Sources */,
5BA537EABFE48178D6BD2544 /* parseGaps.swift in Sources */,
21D0512B48E0E3C28F8CA42A /* parseOnWindowDetected.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let subcommandDescriptions = [
[" list-monitors", "Prints monitors that satisfy conditions"],
[" list-windows", "Prints windows that satisfy conditions"],
[" list-workspaces", "Prints workspaces that satisfy conditions"],
[" macos-native-fullscreen", "Toggle macOS fullscreen for the currently focused window"],
[" mode", "Activates the specified binding modes"],
[" move-node-to-workspace", "Moves currently focused window to the specified workspace"],
[" move-workspace-to-monitor", "Moves currently focused workspace to the next or previous monitor"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public struct MacosNativeFullscreenCmdArgs: RawCmdArgs, CmdArgs {
public init() {}
public static let parser: CmdParser<Self> = noArgsParser(.macosNativeFullscreen, allowInConfig: true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum CmdKind: String, CaseIterable, Equatable {
case listMonitors = "list-monitors"
case listWindows = "list-windows"
case listWorkspaces = "list-workspaces"
case macosNativeFullscreen = "macos-native-fullscreen"
case mode
case move = "move"
case moveNodeToWorkspace = "move-node-to-workspace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ private func initSubcommands() -> [String: any SubCommandParserProtocol] {
result[kind.rawValue] = SubCommandParser(parseListWindowsCmdArgs)
case .listWorkspaces:
result[kind.rawValue] = SubCommandParser(parseListWorkspacesCmdArgs)
case .macosNativeFullscreen:
result[kind.rawValue] = defaultSubCommandParser(MacosNativeFullscreenCmdArgs())
case .mode:
result[kind.rawValue] = defaultSubCommandParser(ModeCmdArgs())
case .moveNodeToWorkspace:
Expand Down
24 changes: 24 additions & 0 deletions docs/aerospace-macos-native-fullscreen.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
= aerospace-macos-native-fullscreen(1)
include::util/man-attributes.adoc[]
:manname: aerospace-macos-native-fullscreen
// tag::purpose[]
:manpurpose: Toggle macOS fullscreen for the currently focused window
// end::purpose[]

== Synopsis
// tag::synopsis[]
macos-native-fullscreen [-h|--help]
// end::synopsis[]

== Description

// tag::body[]
{manpurpose}

// end::body[]

include::util/conditional-options-header.adoc[]

-h, --help:: Print help

include::util/man-footer.adoc[]
7 changes: 7 additions & 0 deletions docs/commands.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ include::aerospace-layout.adoc[tags=synopsis]
include::aerospace-layout.adoc[tags=purpose]
include::aerospace-layout.adoc[tags=body]

== macos-native-fullscreen
----
include::aerospace-macos-native-fullscreen.adoc[tags=synopsis]
----
include::aerospace-macos-native-fullscreen.adoc[tags=purpose]
include::aerospace-macos-native-fullscreen.adoc[tags=body]

== mode
----
include::aerospace-mode.adoc[tags=synopsis]
Expand Down
17 changes: 17 additions & 0 deletions src/command/MacosNativeFullscreenCommand.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Common

struct MacosNativeFullscreenCommand: Command {
let args: MacosNativeFullscreenCmdArgs

func _run(_ state: CommandMutableState, stdin: String) -> Bool {
check(Thread.current.isMainThread)
guard let window = state.subject.windowOrNil else {
state.stderr.append("No window in focus")
return false
}
let axWindow = window.asMacWindow().axWindow
let success = axWindow.set(Ax.isFullscreenAttr, !window.isMacosFullscreen)
if !success { state.stderr.append("Failed") }
return success
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ extension CmdArgs {
command = ListWindowsCommand(args: self as! ListWindowsCmdArgs)
case .listWorkspaces:
command = ListWorkspacesCommand(args: self as! ListWorkspacesCmdArgs)
case .macosNativeFullscreen:
command = MacosNativeFullscreenCommand(args: self as! MacosNativeFullscreenCmdArgs)
case .mode:
command = ModeCommand(args: self as! ModeCmdArgs)
case .moveNodeToWorkspace:
Expand Down
5 changes: 3 additions & 2 deletions src/util/accessibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ enum Ax {
// key: kAXMinimizedAttribute,
// getter: { $0 as? Bool }
//)
static let isFullscreenAttr = ReadableAttrImpl<Bool>(
static let isFullscreenAttr = WritableAttrImpl<Bool>(
key: "AXFullScreen",
getter: { $0 as? Bool }
getter: { $0 as? Bool },
setter: { $0 as CFTypeRef }
)
//static let axMainAttr = ReadableAttrImpl<Bool>(
// key: kAXMainAttribute,
Expand Down

0 comments on commit 1041a96

Please sign in to comment.