feat: windowless apps can now be shown in focus-order (closes #4653)

This commit is contained in:
lwouis committed 2025-08-11 11:41:05 +02:00
1 parent e9e732756e
commit 5db53b5a9e
5 files changed
+50 -49

No files matched your search

-13
View File
@@ -343,19 +343,6 @@ enum ShowHowPreference: CaseIterable, MacroPreference {
}
}
// we can't reuse ShowHowPreference because the order of cases matters for serialization
enum ShowHowPreference2: CaseIterable, MacroPreference {
case showAtTheEnd
case hide
var localizedString: LocalizedString {
switch self {
case .showAtTheEnd: return NSLocalizedString("Show at the end", comment: "")
case .hide: return NSLocalizedString("Hide", comment: "")
}
}
}
enum WindowOrderPreference: CaseIterable, MacroPreference {
case recentlyFocused
case recentlyCreated
+5 -5
View File
@@ -36,10 +36,10 @@ class Preferences {
"showFullscreenWindows2": ShowHowPreference.show.indexAsString,
"showFullscreenWindows3": ShowHowPreference.show.indexAsString,
"showFullscreenWindows4": ShowHowPreference.show.indexAsString,
"showWindowlessApps": ShowHowPreference2.showAtTheEnd.indexAsString,
"showWindowlessApps2": ShowHowPreference2.showAtTheEnd.indexAsString,
"showWindowlessApps3": ShowHowPreference2.showAtTheEnd.indexAsString,
"showWindowlessApps4": ShowHowPreference2.showAtTheEnd.indexAsString,
"showWindowlessApps": ShowHowPreference.showAtTheEnd.indexAsString,
"showWindowlessApps2": ShowHowPreference.showAtTheEnd.indexAsString,
"showWindowlessApps3": ShowHowPreference.showAtTheEnd.indexAsString,
"showWindowlessApps4": ShowHowPreference.showAtTheEnd.indexAsString,
"windowOrder": WindowOrderPreference.recentlyFocused.indexAsString,
"windowOrder2": WindowOrderPreference.recentlyFocused.indexAsString,
"windowOrder3": WindowOrderPreference.recentlyFocused.indexAsString,
@@ -145,7 +145,7 @@ class Preferences {
static var showMinimizedWindows: [ShowHowPreference] { ["showMinimizedWindows", "showMinimizedWindows2", "showMinimizedWindows3", "showMinimizedWindows4"].map { CachedUserDefaults.macroPref($0, ShowHowPreference.allCases) } }
static var showHiddenWindows: [ShowHowPreference] { ["showHiddenWindows", "showHiddenWindows2", "showHiddenWindows3", "showHiddenWindows4"].map { CachedUserDefaults.macroPref($0, ShowHowPreference.allCases) } }
static var showFullscreenWindows: [ShowHowPreference] { ["showFullscreenWindows", "showFullscreenWindows2", "showFullscreenWindows3", "showFullscreenWindows4"].map { CachedUserDefaults.macroPref($0, ShowHowPreference.allCases) } }
static var showWindowlessApps: [ShowHowPreference2] { ["showWindowlessApps", "showWindowlessApps2", "showWindowlessApps3", "showWindowlessApps4"].map { CachedUserDefaults.macroPref($0, ShowHowPreference2.allCases) } }
static var showWindowlessApps: [ShowHowPreference] { ["showWindowlessApps", "showWindowlessApps2", "showWindowlessApps3", "showWindowlessApps4"].map { CachedUserDefaults.macroPref($0, ShowHowPreference.allCases) } }
static var windowOrder: [WindowOrderPreference] { ["windowOrder", "windowOrder2", "windowOrder3", "windowOrder4"].map { CachedUserDefaults.macroPref($0, WindowOrderPreference.allCases) } }
static var shortcutStyle: [ShortcutStylePreference] { ["shortcutStyle", "shortcutStyle2", "shortcutStyle3", "shortcutStyle4"].map { CachedUserDefaults.macroPref($0, ShortcutStylePreference.allCases) } }
static var menubarIcon: MenubarIconPreference { CachedUserDefaults.macroPref("menubarIcon", MenubarIconPreference.allCases) }
+43 -29
View File
@@ -20,35 +20,38 @@ class PreferencesMigrations {
private static func updateToNewPreferences(_ versionInPlist: String) {
// x.compare(y) is .orderedDescending if x > y
if versionInPlist.compare("7.25.0", options: .numeric) != .orderedDescending {
migrateHideWindowlessApps()
if versionInPlist.compare("7.13.1", options: .numeric) != .orderedDescending {
migrateGestures()
if versionInPlist.compare("7.8.0", options: .numeric) != .orderedDescending {
migrateMenubarIconWithNewShownToggle()
if versionInPlist.compare("7.0.0", options: .numeric) != .orderedDescending {
migratePreferencesIndexes()
if versionInPlist.compare("6.43.0", options: .numeric) != .orderedDescending {
migrateBlacklists()
if versionInPlist.compare("6.28.1", options: .numeric) != .orderedDescending {
migrateMinMaxWindowsWidthInRow()
if versionInPlist.compare("6.27.1", options: .numeric) != .orderedDescending {
// "Start at login" new implem doesn't use Login Items; we remove the entry from previous versions
(PreferencesMigrations.self as AvoidDeprecationWarnings.Type).migrateLoginItem()
if versionInPlist.compare("6.23.0", options: .numeric) != .orderedDescending {
// "Show windows from:" got the "Active Space" option removed
migrateShowWindowsFrom()
if versionInPlist.compare("6.18.1", options: .numeric) != .orderedDescending {
// nextWindowShortcut used to be able to have modifiers already present in holdShortcut; we remove these
migrateNextWindowShortcuts()
// dropdowns preferences used to store English text; now they store indexes
migrateDropdownsFromTextToIndexes()
// the "Hide menubar icon" checkbox was replaced with a dropdown of: icon1, icon2, hidden
migrateMenubarIconFromCheckboxToDropdown()
// "Show minimized/hidden/fullscreen windows" checkboxes were replaced with dropdowns
migrateShowWindowsCheckboxToDropdown()
// "Max size on screen" was split into max width and max height
migrateMaxSizeOnScreenToWidthAndHeight()
if versionInPlist.compare("7.26.0", options: .numeric) != .orderedDescending {
migrateShowWindowlessApps()
if versionInPlist.compare("7.25.0", options: .numeric) != .orderedDescending {
migrateHideWindowlessApps()
if versionInPlist.compare("7.13.1", options: .numeric) != .orderedDescending {
migrateGestures()
if versionInPlist.compare("7.8.0", options: .numeric) != .orderedDescending {
migrateMenubarIconWithNewShownToggle()
if versionInPlist.compare("7.0.0", options: .numeric) != .orderedDescending {
migratePreferencesIndexes()
if versionInPlist.compare("6.43.0", options: .numeric) != .orderedDescending {
migrateBlacklists()
if versionInPlist.compare("6.28.1", options: .numeric) != .orderedDescending {
migrateMinMaxWindowsWidthInRow()
if versionInPlist.compare("6.27.1", options: .numeric) != .orderedDescending {
// "Start at login" new implem doesn't use Login Items; we remove the entry from previous versions
(PreferencesMigrations.self as AvoidDeprecationWarnings.Type).migrateLoginItem()
if versionInPlist.compare("6.23.0", options: .numeric) != .orderedDescending {
// "Show windows from:" got the "Active Space" option removed
migrateShowWindowsFrom()
if versionInPlist.compare("6.18.1", options: .numeric) != .orderedDescending {
// nextWindowShortcut used to be able to have modifiers already present in holdShortcut; we remove these
migrateNextWindowShortcuts()
// dropdowns preferences used to store English text; now they store indexes
migrateDropdownsFromTextToIndexes()
// the "Hide menubar icon" checkbox was replaced with a dropdown of: icon1, icon2, hidden
migrateMenubarIconFromCheckboxToDropdown()
// "Show minimized/hidden/fullscreen windows" checkboxes were replaced with dropdowns
migrateShowWindowsCheckboxToDropdown()
// "Max size on screen" was split into max width and max height
migrateMaxSizeOnScreenToWidthAndHeight()
}
}
}
}
@@ -60,6 +63,17 @@ class PreferencesMigrations {
}
}
// allow showWindowlessApps to have the third value `show`, in addition to `hide` and `showAtTheEnd`
// before: showAtTheEnd: 0, hide: 1
// after: show: 0, hide: 1, showAtTheEnd: 2
private static func migrateShowWindowlessApps() {
for index in ["", "2", "3", "4"] {
if let old = UserDefaults.standard.string(forKey: "showWindowlessApps" + index) {
UserDefaults.standard.set(old == "0" ? 2 : 1, forKey: "showWindowlessApps" + index)
}
}
}
// we moved from global to per-shortcut
private static func migrateHideWindowlessApps() {
if let old = UserDefaults.standard.string(forKey: "hideWindowlessApps") {
+1 -1
View File
@@ -29,7 +29,7 @@ class Windows {
private static func sort() {
list.sort {
// separate buckets for these types of windows
if $0.isWindowlessApp != $1.isWindowlessApp {
if Preferences.showWindowlessApps[App.app.shortcutIndex] == .showAtTheEnd && $0.isWindowlessApp != $1.isWindowlessApp {
return $1.isWindowlessApp
}
if Preferences.showHiddenWindows[App.app.shortcutIndex] == .showAtTheEnd && $0.isHidden != $1.isHidden {
@@ -105,7 +105,7 @@ class ControlsTab {
let showMinimizedWindows = LabelAndControl.makeDropdown(Preferences.indexToName("showMinimizedWindows", index), ShowHowPreference.allCases)
let showHiddenWindows = LabelAndControl.makeDropdown(Preferences.indexToName("showHiddenWindows", index), ShowHowPreference.allCases)
let showFullscreenWindows = LabelAndControl.makeDropdown(Preferences.indexToName("showFullscreenWindows", index), ShowHowPreference.allCases.filter { $0 != .showAtTheEnd }) // this filter is ok for serialization because the filtered value is last in the enum
let showWindowlessApps = LabelAndControl.makeDropdown(Preferences.indexToName("showWindowlessApps", index), ShowHowPreference2.allCases)
let showWindowlessApps = LabelAndControl.makeDropdown(Preferences.indexToName("showWindowlessApps", index), ShowHowPreference.allCases)
let windowOrder = LabelAndControl.makeDropdown(Preferences.indexToName("windowOrder", index), WindowOrderPreference.allCases)
let shortcutStyle = LabelAndControl.makeDropdown(Preferences.indexToName("shortcutStyle", index), ShortcutStylePreference.allCases)
let table = TableGroupView(width: PreferencesWindow.width)