Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"Ring" = "Ring";
"scanning local logs…" = "scanning local logs…";
"Settings" = "Settings";
"Switch to %@ (⌘%d)" = "Switch to %@ (⌘%d)";
"Show on" = "Show on";
"Sparkline" = "Sparkline";
"Spacing" = "Spacing";
Expand Down
1 change: 1 addition & 0 deletions Resources/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"Ring" = "环形";
"scanning local logs…" = "正在扫描本地日志…";
"Settings" = "设置";
"Switch to %@ (⌘%d)" = "切换到%@(⌘%d)";
"Show on" = "显示在";
"Sparkline" = "折线";
"Spacing" = "间距";
Expand Down
26 changes: 15 additions & 11 deletions Sources/Views/PageIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ struct PageIndicator: View {

private func dot(for screen: ScreenPref.Screen) -> some View {
let isActive = screenPref.screen == screen
return Circle()
.fill(.white.opacity(isActive ? 0.78 : 0.22))
.frame(width: 5, height: 5)
// Visual stays 5pt; hit area expands ~6pt outward so the dot
// is reachable without pixel-precise aim.
.contentShape(Rectangle().inset(by: -6))
.onTapGesture { model.showScreen(screen) }
.accessibilityElement()
.accessibilityLabel(accessibilityLabel(for: screen))
.accessibilityAddTraits(.isButton)
.accessibilityAddTraits(isActive ? .isSelected : [])
return Button {
model.showScreen(screen)
} label: {
Circle()
.fill(.white.opacity(isActive ? 0.78 : 0.22))
.frame(width: 5, height: 5)
// Visual stays 5pt; hit area expands ~6pt outward so the dot
// is reachable without pixel-precise aim.
.contentShape(Rectangle().inset(by: -6))
}
.buttonStyle(.plain)
.help(L10n.tr("Switch to %@ (⌘%d)", screen.pageLabel, screen.pageIndex + 1))
.accessibilityLabel(accessibilityLabel(for: screen))
.accessibilityAddTraits(.isButton)
.accessibilityAddTraits(isActive ? .isSelected : [])
}

private func accessibilityLabel(for screen: ScreenPref.Screen) -> String {
Expand Down
43 changes: 36 additions & 7 deletions Sources/Window/IslandWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,8 @@ final class IslandWindowController {
if inside {
NSApp.activate(ignoringOtherApps: true)
window.makeKey()
cmdQMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { event in
if event.modifierFlags.contains(.command),
event.charactersIgnoringModifiers == "q" {
NSApp.terminate(nil)
return nil
}
return event
cmdQMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in
self?.handleKeyDown(event) ?? event
}
} else {
if let m = cmdQMonitor { NSEvent.removeMonitor(m) }
Expand All @@ -151,6 +146,40 @@ final class IslandWindowController {
}
}

private func handleKeyDown(_ event: NSEvent) -> NSEvent? {
guard window.isKeyWindow else { return event }

let modifiers = event.modifierFlags
.intersection(.deviceIndependentFlagsMask)
.subtracting([.capsLock])
if modifiers == .command, event.charactersIgnoringModifiers == "q" {
NSApp.terminate(nil)
return nil
}

guard model.state == .expanded else { return event }

if modifiers == .command,
let character = event.charactersIgnoringModifiers,
let index = ["1", "2", "3"].firstIndex(of: character) {
Comment on lines +162 to +164

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match Command-number shortcuts across keyboard layouts

On keyboard layouts where number-row digits require Shift, such as French AZERTY, the key labeled 1 produces either & without Shift or 1 with .shift; the exact modifiers == .command check therefore rejects both ways of entering the advertised ⌘1 shortcut. Numeric-keypad events are similarly rejected because they include .numericPad. Match these shortcuts through layout-aware key-equivalent handling or otherwise account for the additional flags so direct page selection remains usable outside US-style layouts.

Useful? React with 👍 / 👎.

model.showScreen(ScreenPref.Screen.allCases[index])
return nil
}

let navigationModifiers = modifiers.subtracting([.function, .numericPad, .capsLock])
guard navigationModifiers.isEmpty else { return event }
switch event.keyCode {
case 123:
model.rewindScreen()
return nil
case 124:
model.advanceScreen()
return nil
default:
return event
}
}

@MainActor
private static func targetScreen() -> NSScreen? {
DisplayInfo.currentTarget()?.screen
Expand Down