Let the menu's click and shift-click actions be swapped
Clicking a profile switched to it exclusively and shift-click opened it
alongside, with no way round for anyone who opens alongside far more often
than they switch. Settings now carries the choice, storing only the plain
click's action — the other gesture gets whatever is left, so the two can't
both end up meaning the same thing, and no migration is needed for anyone
who never touches it.
Switching also quits the other profiles again when the profile clicked is
already up, which e7777d5 had carved out on the reasoning that a click
reaching for a second open window is someone moving between windows rather
than asking for one to go. That guess is what this setting now settles:
with each action bound to a gesture of its own, choosing the switch gesture
is the instruction, and second-guessing it left no way to ask for an
exclusive switch at all once the target was running.
The menu spells out both gestures rather than only the modified one, since
which of them quits things is no longer fixed. Each profile's tooltip
describes what a click will actually do to it as things stand — it promises
to quit the neighbours only when there are neighbours to quit.
This commit is contained in:
1 parent
97b131070e
commit
ffbd1536b6
3 files changed
+143
-36
No files matched your search
@@ -512,6 +512,9 @@ private final class SettingsViewController: NSViewController {
|
||||
private let tagStyleLabel = NSTextField(labelWithString: "Window tag:")
|
||||
private let tagStylePopUp = NSPopUpButton(frame: .zero, pullsDown: false)
|
||||
private var tagStyleRow: NSStackView!
|
||||
private let clickActionLabel = NSTextField(labelWithString: "Click a profile to:")
|
||||
private let clickActionPopUp = NSPopUpButton(frame: .zero, pullsDown: false)
|
||||
private var clickActionRow: NSStackView!
|
||||
private var stack: NSStackView!
|
||||
|
||||
var onOverlayStyleChanged: (() -> Void)?
|
||||
@@ -523,6 +526,14 @@ private final class SettingsViewController: NSViewController {
|
||||
("Colored dot", .dot),
|
||||
]
|
||||
|
||||
// Same index-to-value arrangement. Each title spells out the Shift-click
|
||||
// half too: the two actions always swap together, so showing only the
|
||||
// plain click's half would leave the other looking unset.
|
||||
private static let clickActions: [(title: String, action: MenuClickAction)] = [
|
||||
("Switch to it (\u{21e7}: open alongside)", .switchTo),
|
||||
("Open it alongside (\u{21e7}: switch to it)", .openAlongside),
|
||||
]
|
||||
|
||||
override func loadView() {
|
||||
view = NSView(frame: NSRect(x: 0, y: 0, width: 420, height: 150))
|
||||
|
||||
@@ -535,6 +546,16 @@ private final class SettingsViewController: NSViewController {
|
||||
tagStyleRow.orientation = .horizontal
|
||||
tagStyleRow.spacing = 8
|
||||
|
||||
clickActionPopUp.addItems(withTitles: Self.clickActions.map(\.title))
|
||||
clickActionPopUp.selectItem(
|
||||
at: Self.clickActions.firstIndex { $0.action == MenuClickBehavior.plainClick } ?? 0)
|
||||
clickActionPopUp.target = self
|
||||
clickActionPopUp.action = #selector(changeClickAction)
|
||||
|
||||
clickActionRow = NSStackView(views: [clickActionLabel, clickActionPopUp])
|
||||
clickActionRow.orientation = .horizontal
|
||||
clickActionRow.spacing = 8
|
||||
|
||||
launchAtLoginCheckbox.target = self
|
||||
launchAtLoginCheckbox.action = #selector(toggleLaunchAtLogin)
|
||||
launchAtLoginCheckbox.state = LaunchAtLogin.isEnabled ? .on : .off
|
||||
@@ -547,7 +568,9 @@ private final class SettingsViewController: NSViewController {
|
||||
checkNowButton.action = #selector(checkNow)
|
||||
checkNowButton.bezelStyle = .rounded
|
||||
|
||||
stack = NSStackView(views: [launchAtLoginCheckbox, tagStyleRow, autoUpdateCheckbox, checkNowButton])
|
||||
stack = NSStackView(views: [
|
||||
launchAtLoginCheckbox, clickActionRow, tagStyleRow, autoUpdateCheckbox, checkNowButton,
|
||||
])
|
||||
stack.orientation = .vertical
|
||||
stack.alignment = .leading
|
||||
stack.spacing = 14
|
||||
@@ -578,14 +601,18 @@ private final class SettingsViewController: NSViewController {
|
||||
// is what AutoLayout itself uses to size an unconstrained control —
|
||||
// sidesteps whatever the stack's own aggregation is getting wrong.
|
||||
private func updatePreferredSize() {
|
||||
// Same reasoning for the tag-style row: summed from its two
|
||||
// controls plus the stack spacing rather than trusting the row's
|
||||
// Same reasoning for the label+popup rows: summed from their two
|
||||
// controls plus the row spacing rather than trusting the row's
|
||||
// own fittingSize.
|
||||
let rowWidth = tagStyleLabel.intrinsicContentSize.width
|
||||
+ tagStylePopUp.intrinsicContentSize.width + tagStyleRow.spacing
|
||||
let widest = [launchAtLoginCheckbox, autoUpdateCheckbox, checkNowButton]
|
||||
.map(\.intrinsicContentSize.width)
|
||||
.max().map { max($0, rowWidth) } ?? rowWidth
|
||||
let rowWidths = [
|
||||
tagStyleLabel.intrinsicContentSize.width
|
||||
+ tagStylePopUp.intrinsicContentSize.width + tagStyleRow.spacing,
|
||||
clickActionLabel.intrinsicContentSize.width
|
||||
+ clickActionPopUp.intrinsicContentSize.width + clickActionRow.spacing,
|
||||
]
|
||||
let widest = ([launchAtLoginCheckbox, autoUpdateCheckbox, checkNowButton]
|
||||
.map(\.intrinsicContentSize.width) + rowWidths)
|
||||
.max() ?? 0
|
||||
preferredContentSize = NSSize(width: widest + 40, height: stack.fittingSize.height)
|
||||
}
|
||||
|
||||
@@ -596,6 +623,14 @@ private final class SettingsViewController: NSViewController {
|
||||
onOverlayStyleChanged?()
|
||||
}
|
||||
|
||||
// Nothing to notify: the menu bar rebuilds its menu on every open and
|
||||
// reads the setting then.
|
||||
@objc private func changeClickAction() {
|
||||
let index = clickActionPopUp.indexOfSelectedItem
|
||||
guard Self.clickActions.indices.contains(index) else { return }
|
||||
MenuClickBehavior.plainClick = Self.clickActions[index].action
|
||||
}
|
||||
|
||||
@objc private func toggleLaunchAtLogin() {
|
||||
do {
|
||||
if launchAtLoginCheckbox.state == .on {
|
||||
|
||||
Reference in new issue
Block a user