fix: focus issues with show-main-window setting (closes #5684)
This commit is contained in:
1 parent
3059dc2356
commit
0899f61654
8 files changed
+17
-42
No files matched your search
@@ -217,14 +217,14 @@ enum TitleTruncationPreference: CaseIterable, MacroPreference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ShowAppsOrWindowsPreference: CaseIterable, MacroPreference {
|
enum GroupAppsPreference: CaseIterable, MacroPreference {
|
||||||
case applications
|
case mainWindow
|
||||||
case windows
|
case allWindows
|
||||||
|
|
||||||
var localizedString: LocalizedString {
|
var localizedString: LocalizedString {
|
||||||
switch self {
|
switch self {
|
||||||
case .applications: return NSLocalizedString("Show main window", comment: "")
|
case .mainWindow: return NSLocalizedString("Show main window", comment: "")
|
||||||
case .windows: return NSLocalizedString("Show all windows", comment: "")
|
case .allWindows: return NSLocalizedString("Show all windows", comment: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class Preferences {
|
|||||||
values[indexToName("showWindowlessApps", index)] = ShowHowPreference.showAtTheEnd.indexAsString
|
values[indexToName("showWindowlessApps", index)] = ShowHowPreference.showAtTheEnd.indexAsString
|
||||||
values[indexToName("windowOrder", index)] = WindowOrderPreference.recentlyFocused.indexAsString
|
values[indexToName("windowOrder", index)] = WindowOrderPreference.recentlyFocused.indexAsString
|
||||||
values[indexToName("shortcutStyle", index)] = ShortcutStylePreference.focusOnRelease.indexAsString
|
values[indexToName("shortcutStyle", index)] = ShortcutStylePreference.focusOnRelease.indexAsString
|
||||||
values[indexToName("showAppsOrWindows", index)] = ShowAppsOrWindowsPreference.windows.indexAsString
|
values[indexToName("showAppsOrWindows", index)] = GroupAppsPreference.allWindows.indexAsString
|
||||||
values[indexToName("showTabsAsWindows", index)] = GroupTabsPreference.singleWindow.indexAsString
|
values[indexToName("showTabsAsWindows", index)] = GroupTabsPreference.singleWindow.indexAsString
|
||||||
// Override defaults are the FREE-tier value for Pro-gated prefs (so `snapshotAndDowngrade`
|
// Override defaults are the FREE-tier value for Pro-gated prefs (so `snapshotAndDowngrade`
|
||||||
// is a no-op for unset overrides), and the global default for non-gated prefs.
|
// is a no-op for unset overrides), and the global default for non-gated prefs.
|
||||||
@@ -150,8 +150,7 @@ class Preferences {
|
|||||||
static func showFullscreenWindows(_ i: Int) -> ShowHowPreference { CachedUserDefaults.macroPref(indexToName("showFullscreenWindows", i), ShowHowPreference.allCases) }
|
static func showFullscreenWindows(_ i: Int) -> ShowHowPreference { CachedUserDefaults.macroPref(indexToName("showFullscreenWindows", i), ShowHowPreference.allCases) }
|
||||||
static func showWindowlessApps(_ i: Int) -> ShowHowPreference { CachedUserDefaults.macroPref(indexToName("showWindowlessApps", i), ShowHowPreference.allCases) }
|
static func showWindowlessApps(_ i: Int) -> ShowHowPreference { CachedUserDefaults.macroPref(indexToName("showWindowlessApps", i), ShowHowPreference.allCases) }
|
||||||
static func windowOrder(_ i: Int) -> WindowOrderPreference { CachedUserDefaults.macroPref(indexToName("windowOrder", i), WindowOrderPreference.allCases) }
|
static func windowOrder(_ i: Int) -> WindowOrderPreference { CachedUserDefaults.macroPref(indexToName("windowOrder", i), WindowOrderPreference.allCases) }
|
||||||
static var showAppsOrWindows: [ShowAppsOrWindowsPreference] { (0...maxShortcutCount).map { CachedUserDefaults.macroPref(indexToName("showAppsOrWindows", $0), ShowAppsOrWindowsPreference.allCases) } }
|
static func groupApps(_ i: Int) -> GroupAppsPreference { CachedUserDefaults.macroPref(indexToName("showAppsOrWindows", i), GroupAppsPreference.allCases) }
|
||||||
static func showAppsOrWindows(_ i: Int) -> ShowAppsOrWindowsPreference { CachedUserDefaults.macroPref(indexToName("showAppsOrWindows", i), ShowAppsOrWindowsPreference.allCases) }
|
|
||||||
static func groupTabs(_ i: Int) -> GroupTabsPreference { CachedUserDefaults.macroPref(indexToName("showTabsAsWindows", i), GroupTabsPreference.allCases) }
|
static func groupTabs(_ i: Int) -> GroupTabsPreference { CachedUserDefaults.macroPref(indexToName("showTabsAsWindows", i), GroupTabsPreference.allCases) }
|
||||||
static var shortcutStyle: ShortcutStylePreference { ProGatedPreferences.shortcutStyle.read() }
|
static var shortcutStyle: ShortcutStylePreference { ProGatedPreferences.shortcutStyle.read() }
|
||||||
static var menubarIcon: MenubarIconPreference { CachedUserDefaults.macroPref("menubarIcon", MenubarIconPreference.allCases) }
|
static var menubarIcon: MenubarIconPreference { CachedUserDefaults.macroPref("menubarIcon", MenubarIconPreference.allCases) }
|
||||||
@@ -248,8 +247,8 @@ class Preferences {
|
|||||||
cachedAll = nil
|
cachedAll = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
static func onlyShowApplications(_ index: Int = SwitcherSession.activeShortcutIndex) -> Bool {
|
static func onlyShowMainWindows(_ index: Int = SwitcherSession.activeShortcutIndex) -> Bool {
|
||||||
return showAppsOrWindows(index) == .applications && effectiveAppearanceStyle(index) != .thumbnails
|
return groupApps(index) == .mainWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Per-shortcut appearance overrides
|
// MARK: - Per-shortcut appearance overrides
|
||||||
|
|||||||
@@ -390,7 +390,6 @@ class AppearanceTab: NSObject {
|
|||||||
static var animationsButton: NSButton!
|
static var animationsButton: NSButton!
|
||||||
static var customizeStyleSheet: CustomizeStyleSheet!
|
static var customizeStyleSheet: CustomizeStyleSheet!
|
||||||
static var animationsSheet: AnimationsSheet!
|
static var animationsSheet: AnimationsSheet!
|
||||||
static var previewSelectedWindowRowInfo: TableGroupView.RowInfo!
|
|
||||||
|
|
||||||
// References used by `refreshProLockUi()` to update Pro-lock affordances while Settings stays open.
|
// References used by `refreshProLockUi()` to update Pro-lock affordances while Settings stays open.
|
||||||
private static weak var styleButtonsStack: NSStackView?
|
private static weak var styleButtonsStack: NSStackView?
|
||||||
@@ -433,7 +432,6 @@ class AppearanceTab: NSObject {
|
|||||||
animationsButton = nil
|
animationsButton = nil
|
||||||
customizeStyleSheet = nil
|
customizeStyleSheet = nil
|
||||||
animationsSheet = nil
|
animationsSheet = nil
|
||||||
previewSelectedWindowRowInfo = nil
|
|
||||||
autoSegmentOverlayRef = nil
|
autoSegmentOverlayRef = nil
|
||||||
shortcutStyleSegmentOverlayRef = nil
|
shortcutStyleSegmentOverlayRef = nil
|
||||||
overrideInfoIcons.removeAll()
|
overrideInfoIcons.removeAll()
|
||||||
@@ -459,7 +457,6 @@ class AppearanceTab: NSObject {
|
|||||||
width: SettingsWindow.contentWidth)
|
width: SettingsWindow.contentWidth)
|
||||||
let styleButtons = LabelAndControl.makeImageRadioButtons("appearanceStyle", AppearanceStylePreference.allCases, extraAction: { _ in
|
let styleButtons = LabelAndControl.makeImageRadioButtons("appearanceStyle", AppearanceStylePreference.allCases, extraAction: { _ in
|
||||||
toggleCustomizeStyleButton()
|
toggleCustomizeStyleButton()
|
||||||
updatePreviewSelectedWindowState()
|
|
||||||
ControlsTab.syncOverrideControlsToGlobal()
|
ControlsTab.syncOverrideControlsToGlobal()
|
||||||
refreshAllOverrideInfoLabels()
|
refreshAllOverrideInfoLabels()
|
||||||
}, buttonSpacing: 10, proGatedIndices: proGatedAppearanceStyleIndices())
|
}, buttonSpacing: 10, proGatedIndices: proGatedAppearanceStyleIndices())
|
||||||
@@ -622,28 +619,8 @@ class AppearanceTab: NSObject {
|
|||||||
ControlsTab.syncOverrideControlsToGlobal()
|
ControlsTab.syncOverrideControlsToGlobal()
|
||||||
refreshAllOverrideInfoLabels()
|
refreshAllOverrideInfoLabels()
|
||||||
})
|
})
|
||||||
previewSelectedWindowRowInfo = table.addRow(leftText: AppearanceTab.labelPreviewSelectedWindow,
|
_ = table.addRow(leftText: AppearanceTab.labelPreviewSelectedWindow,
|
||||||
rightViews: [switchControl, makeOverrideIcon("previewFocusedWindowOverride")])
|
rightViews: [switchControl, makeOverrideIcon("previewFocusedWindowOverride")])
|
||||||
updatePreviewSelectedWindowState()
|
|
||||||
}
|
|
||||||
|
|
||||||
static func updatePreviewSelectedWindowState() {
|
|
||||||
guard let rowInfo = previewSelectedWindowRowInfo else { return }
|
|
||||||
let isEnabled = !isPreviewSelectedWindowDisabled()
|
|
||||||
rowInfo.leftViews?.forEach { view in
|
|
||||||
if let textField = view as? NSTextField {
|
|
||||||
textField.textColor = isEnabled ? .textColor : .gray
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rowInfo.rightViews?.forEach { view in
|
|
||||||
if let switchControl = view as? Switch {
|
|
||||||
switchControl.isEnabled = isEnabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static func isPreviewSelectedWindowDisabled() -> Bool {
|
|
||||||
return Preferences.onlyShowApplications()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func makeMultipleScreensView() -> NSView {
|
private static func makeMultipleScreensView() -> NSView {
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ final class OrderingPane {
|
|||||||
/// See `FilteringPane.searchableStrings`.
|
/// See `FilteringPane.searchableStrings`.
|
||||||
static let searchableStrings: [String] = [
|
static let searchableStrings: [String] = [
|
||||||
labelGroupApps, labelGroupTabs, labelWindowOrder,
|
labelGroupApps, labelGroupTabs, labelWindowOrder,
|
||||||
] + ShowAppsOrWindowsPreference.allCases.map { $0.localizedString }
|
] + GroupAppsPreference.allCases.map { $0.localizedString }
|
||||||
+ GroupTabsPreference.allCases.map { $0.localizedString }
|
+ GroupTabsPreference.allCases.map { $0.localizedString }
|
||||||
+ WindowOrderPreference.allCases.map { $0.localizedString }
|
+ WindowOrderPreference.allCases.map { $0.localizedString }
|
||||||
|
|
||||||
@@ -376,7 +376,7 @@ final class OrderingPane {
|
|||||||
private let windowOrder: ShortcutBoundDropdown
|
private let windowOrder: ShortcutBoundDropdown
|
||||||
|
|
||||||
init(width: CGFloat) {
|
init(width: CGFloat) {
|
||||||
showAppsOrWindows = ShortcutBoundDropdown(baseName: "showAppsOrWindows", cases: ShowAppsOrWindowsPreference.allCases)
|
showAppsOrWindows = ShortcutBoundDropdown(baseName: "showAppsOrWindows", cases: GroupAppsPreference.allCases)
|
||||||
showTabsAsWindows = ShortcutBoundDropdown(baseName: "showTabsAsWindows", cases: GroupTabsPreference.allCases)
|
showTabsAsWindows = ShortcutBoundDropdown(baseName: "showTabsAsWindows", cases: GroupTabsPreference.allCases)
|
||||||
windowOrder = ShortcutBoundDropdown(baseName: "windowOrder", cases: WindowOrderPreference.allCases)
|
windowOrder = ShortcutBoundDropdown(baseName: "windowOrder", cases: WindowOrderPreference.allCases)
|
||||||
|
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ class TileView: FlippedView {
|
|||||||
|
|
||||||
private func searchSpanRanges() -> [NSRange] {
|
private func searchSpanRanges() -> [NSRange] {
|
||||||
var spanRanges = [NSRange]()
|
var spanRanges = [NSRange]()
|
||||||
if Preferences.onlyShowApplications() || Preferences.showTitles == .appName {
|
if Preferences.showTitles == .appName {
|
||||||
for result in window_?.swAppResults ?? [] {
|
for result in window_?.swAppResults ?? [] {
|
||||||
spanRanges.append(NSRange(location: result.span.lowerBound, length: result.span.count))
|
spanRanges.append(NSRange(location: result.span.lowerBound, length: result.span.count))
|
||||||
}
|
}
|
||||||
@@ -570,7 +570,7 @@ class TileView: FlippedView {
|
|||||||
private func getAppOrAndWindowTitle() -> String {
|
private func getAppOrAndWindowTitle() -> String {
|
||||||
let appName = window_?.application.localizedName
|
let appName = window_?.application.localizedName
|
||||||
let windowTitle = window_?.title
|
let windowTitle = window_?.title
|
||||||
if Preferences.onlyShowApplications() || Preferences.showTitles == .appName {
|
if Preferences.showTitles == .appName {
|
||||||
return appName ?? ""
|
return appName ?? ""
|
||||||
} else if Preferences.showTitles == .appNameAndWindowTitle {
|
} else if Preferences.showTitles == .appNameAndWindowTitle {
|
||||||
if appName == windowTitle {
|
if appName == windowTitle {
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ class Window {
|
|||||||
App.shared.activate(ignoringOtherApps: true)
|
App.shared.activate(ignoringOtherApps: true)
|
||||||
altTabWindow.makeKeyAndOrderFront(nil)
|
altTabWindow.makeKeyAndOrderFront(nil)
|
||||||
WindowThumbnails.previewSelectedIfNeeded()
|
WindowThumbnails.previewSelectedIfNeeded()
|
||||||
} else if isWindowlessApp || cgWindowId == nil || Preferences.onlyShowApplications() {
|
} else if isWindowlessApp || cgWindowId == nil {
|
||||||
if let bundleUrl = application.bundleURL, isWindowlessApp {
|
if let bundleUrl = application.bundleURL, isWindowlessApp {
|
||||||
if (try? NSWorkspace.shared.launchApplication(at: bundleUrl, configuration: [:])) == nil {
|
if (try? NSWorkspace.shared.launchApplication(at: bundleUrl, configuration: [:])) == nil {
|
||||||
application.runningApplication.activate(options: .activateAllWindows)
|
application.runningApplication.activate(options: .activateAllWindows)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Cocoa
|
|||||||
enum WindowThumbnails {
|
enum WindowThumbnails {
|
||||||
static func previewSelectedIfNeeded() {
|
static func previewSelectedIfNeeded() {
|
||||||
if let session = SwitcherSession.current, ScreenRecordingPermission.status == .granted
|
if let session = SwitcherSession.current, ScreenRecordingPermission.status == .granted
|
||||||
&& Preferences.effectivePreviewSelectedWindow(session.shortcutIndex) && !Preferences.onlyShowApplications(session.shortcutIndex)
|
&& Preferences.effectivePreviewSelectedWindow(session.shortcutIndex)
|
||||||
&& TilesPanel.shared.isKeyWindow,
|
&& TilesPanel.shared.isKeyWindow,
|
||||||
let window = Windows.selectedWindow(),
|
let window = Windows.selectedWindow(),
|
||||||
let id = window.cgWindowId,
|
let id = window.cgWindowId,
|
||||||
@@ -22,7 +22,6 @@ enum WindowThumbnails {
|
|||||||
static func refreshAsync(_ windows: [Window], _ source: RefreshCausedBy, windowRemoved: Bool = false, prioritizedIds: Set<CGWindowID>? = nil) {
|
static func refreshAsync(_ windows: [Window], _ source: RefreshCausedBy, windowRemoved: Bool = false, prioritizedIds: Set<CGWindowID>? = nil) {
|
||||||
let shortcutIndex = SwitcherSession.activeShortcutIndex
|
let shortcutIndex = SwitcherSession.activeShortcutIndex
|
||||||
guard (!windows.isEmpty || windowRemoved) && ScreenRecordingPermission.status == .granted
|
guard (!windows.isEmpty || windowRemoved) && ScreenRecordingPermission.status == .granted
|
||||||
&& !Preferences.onlyShowApplications(shortcutIndex)
|
|
||||||
&& (!Appearance.hideThumbnails || Preferences.effectivePreviewSelectedWindow(shortcutIndex))
|
&& (!Appearance.hideThumbnails || Preferences.effectivePreviewSelectedWindow(shortcutIndex))
|
||||||
&& (Preferences.captureWindowsInBackground || SwitcherSession.isActive) else { return }
|
&& (Preferences.captureWindowsInBackground || SwitcherSession.isActive) else { return }
|
||||||
var eligibleWindows = [Window]()
|
var eligibleWindows = [Window]()
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func refreshWhichWindowsToShowTheUser() {
|
static func refreshWhichWindowsToShowTheUser() {
|
||||||
if Preferences.onlyShowApplications() {
|
if Preferences.onlyShowMainWindows() {
|
||||||
// Group windows by application and select the optimal main window
|
// Group windows by application and select the optimal main window
|
||||||
let windowsGroupedByApp = Dictionary(grouping: list) { $0.application.pid }
|
let windowsGroupedByApp = Dictionary(grouping: list) { $0.application.pid }
|
||||||
windowsGroupedByApp.forEach { (app, windows) in
|
windowsGroupedByApp.forEach { (app, windows) in
|
||||||
|
|||||||
Reference in new issue
Block a user