diff --git a/Amethyst.xcodeproj/project.pbxproj b/Amethyst.xcodeproj/project.pbxproj index 461626d2..cc91fcdb 100644 --- a/Amethyst.xcodeproj/project.pbxproj +++ b/Amethyst.xcodeproj/project.pbxproj @@ -1010,7 +1010,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 112; + CURRENT_PROJECT_VERSION = 113; DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; @@ -1052,7 +1052,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 112; + CURRENT_PROJECT_VERSION = 113; DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 82P2XLB4UH; diff --git a/Amethyst/Managers/WindowManager.swift b/Amethyst/Managers/WindowManager.swift index d8586bdc..8f7fe95b 100644 --- a/Amethyst/Managers/WindowManager.swift +++ b/Amethyst/Managers/WindowManager.swift @@ -731,24 +731,8 @@ extension WindowManager: WindowTransitionTarget { guard let targetScreen = CGSpacesInfo.screenForSpace(space: targetSpace) else { return } - if window.isFocused() { - if activeWindows(on: screen).count == 1, - let finder = NSWorkspace.shared.runningApplications.first(where: { $0.bundleIdentifier == "com.apple.finder" }) { - var psn = ProcessSerialNumber() - let status = GetProcessForPID(finder.processIdentifier, &psn) - if status != noErr { - log.error(status) - } - let cgStatus = _SLPSSetFrontProcessWithOptions(&psn, 0, kCPSNoWindows) - if cgStatus != .success { - log.error(cgStatus.rawValue) - } - } else { - focusTransitionCoordinator.moveFocusClockwise() - } - } markScreen(screen, forReflowWithChange: .remove(window: window)) - window.move(toSpace: targetSpace.id) + window.move(toSpaceAtIndex: UInt(spaceIndex + 1)) if targetScreen.screenID() != screen.screenID() { // necessary to set frame here as window is expected to be at origin relative to targe screen when moved, can be improved. let newFrame = targetScreen.frameWithoutDockOrMenu() @@ -756,9 +740,9 @@ extension WindowManager: WindowTransitionTarget { window.setFrame(newFrame, withThreshold: CGSize(width: 25, height: 25)) } } - if UserConfiguration.shared.followWindowsThrownBetweenSpaces() { - window.focus() - } +// if UserConfiguration.shared.followWindowsThrownBetweenSpaces() { +// window.focus() +// } markScreen(targetScreen, forReflowWithChange: .add(window: window)) case .resetFocus: if let screen = screens.screenManagers.first?.screen { diff --git a/Amethyst/Model/Window.swift b/Amethyst/Model/Window.swift index 994762c8..f32cd103 100644 --- a/Amethyst/Model/Window.swift +++ b/Amethyst/Model/Window.swift @@ -127,6 +127,14 @@ protocol WindowType: Equatable { */ func move(toSpace space: UInt) + /** + Moves the window to the space at an index. + + - Parameters: + - space: The index of the space + */ + func move(toSpaceAtIndex space: UInt) + /** Moves the window to a space. @@ -372,40 +380,47 @@ extension AXWindow: WindowType { move(to: screen.screen) } - func move(toSpace spaceID: CGSSpaceID) { - let osVersion = ProcessInfo.processInfo.operatingSystemVersion - if (osVersion.majorVersion >= 15) || - (osVersion.majorVersion == 14 && osVersion.minorVersion >= 5) || - (osVersion.majorVersion == 13 && osVersion.minorVersion >= 6) || - (osVersion.majorVersion == 12 && osVersion.minorVersion >= 7) { - /* - See: - - https://github.com/ianyh/Amethyst/issues/1643 - - https://github.com/ianyh/Amethyst/issues/1666 - - https://github.com/koekeishiya/yabai/issues/2240 - - https://github.com/koekeishiya/yabai/issues/2408 - - https://github.com/koekeishiya/yabai/commit/98bbdbd1363f27d35f09338cded0de1ec010d830 - - https://github.com/koekeishiya/yabai/commit/c8f913cbc0497d1dfe16138f40a8ba6ecaa744f8 - */ - var error: CGError = .success - - error = SLSSpaceSetCompatID(CGSMainConnectionID(), spaceID, 0x79616265) - defer { _ = SLSSpaceSetCompatID(CGSMainConnectionID(), spaceID, 0x0) } - guard error == .success else { - log.error("failed to set compat aside id: \(error)") - return - } + func move(toSpaceAtIndex space: UInt) { + super.move(toSpace: space) + } - var id = cgID() - error = withUnsafeMutablePointer(to: &id, { pointer -> CGError in - return SLSSetWindowListWorkspace(CGSMainConnectionID(), pointer, 1, 0x79616265) - }) - guard error == .success else { - log.error("failed to throw window: \(error)") - return - } - } else { - SLSMoveWindowsToManagedSpace(CGSMainConnectionID(), [cgID()] as CFArray, spaceID) - } + func move(toSpace spaceID: CGSSpaceID) { } +// func move(toSpace spaceID: CGSSpaceID) { +// super.move(toSpace: spaceID) +// let osVersion = ProcessInfo.processInfo.operatingSystemVersion +// if (osVersion.majorVersion >= 15) || +// (osVersion.majorVersion == 14 && osVersion.minorVersion >= 5) || +// (osVersion.majorVersion == 13 && osVersion.minorVersion >= 6) || +// (osVersion.majorVersion == 12 && osVersion.minorVersion >= 7) { +// /* +// See: +// - https://github.com/ianyh/Amethyst/issues/1643 +// - https://github.com/ianyh/Amethyst/issues/1666 +// - https://github.com/koekeishiya/yabai/issues/2240 +// - https://github.com/koekeishiya/yabai/issues/2408 +// - https://github.com/koekeishiya/yabai/commit/98bbdbd1363f27d35f09338cded0de1ec010d830 +// - https://github.com/koekeishiya/yabai/commit/c8f913cbc0497d1dfe16138f40a8ba6ecaa744f8 +// */ +// var error: CGError = .success +// +// error = SLSSpaceSetCompatID(CGSMainConnectionID(), spaceID, 0x79616265) +// defer { _ = SLSSpaceSetCompatID(CGSMainConnectionID(), spaceID, 0x0) } +// guard error == .success else { +// log.error("failed to set compat aside id: \(error)") +// return +// } +// +// var id = cgID() +// error = withUnsafeMutablePointer(to: &id, { pointer -> CGError in +// return SLSSetWindowListWorkspace(CGSMainConnectionID(), pointer, 1, 0x79616265) +// }) +// guard error == .success else { +// log.error("failed to throw window: \(error)") +// return +// } +// } else { +// SLSMoveWindowsToManagedSpace(CGSMainConnectionID(), [cgID()] as CFArray, spaceID) +// } +// } }