Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 684141f

Browse files
committed
Bug 1945302 - Support "Prefer non-blinking cursor" setting on macOS. r=mac-reviewers,mstange
Safari and Chrome both supports this a11y setting. Differential Revision: https://phabricator.services.mozilla.com/D236451
1 parent 6b651bf commit 684141f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

widget/cocoa/moz.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ RESOURCE_FILES.__setattr__(
165165
)
166166

167167
OS_LIBS += [
168+
"-framework Accessibility",
168169
"-framework IOSurface",
169170
"-framework Vision",
170171
]

widget/cocoa/nsLookAndFeel.mm

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#import <Cocoa/Cocoa.h>
2525
#import <Carbon/Carbon.h>
26+
#import <Accessibility/Accessibility.h>
2627
#import <AppKit/NSColor.h>
2728

2829
// This must be included last:
@@ -386,6 +387,13 @@ static bool SystemWantsDarkTheme() {
386387
return [aquaOrDarkAqua isEqualToString:NSAppearanceNameDarkAqua];
387388
}
388389

390+
static bool PrefersNonBlinkingTextInsertionIndicator() {
391+
if (@available(macOS 15.0, *)) {
392+
return AXPrefersNonBlinkingTextInsertionIndicator();
393+
}
394+
return false;
395+
}
396+
389397
nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
390398
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
391399

@@ -400,7 +408,7 @@ static bool SystemWantsDarkTheme() {
400408
aResult = 3;
401409
break;
402410
case IntID::CaretBlinkTime:
403-
aResult = 567;
411+
aResult = PrefersNonBlinkingTextInsertionIndicator() ? -1 : 567;
404412
break;
405413
case IntID::CaretWidth:
406414
aResult = 1;
@@ -609,6 +617,15 @@ + (void)startObserving {
609617
- (instancetype)init {
610618
self = [super init];
611619

620+
if (@available(macOS 15.0, *)) {
621+
[NSNotificationCenter.defaultCenter
622+
addObserver:self
623+
selector:@selector(cachedValuesChanged)
624+
name:
625+
AXPrefersNonBlinkingTextInsertionIndicatorDidChangeNotification
626+
object:nil];
627+
}
628+
612629
[NSNotificationCenter.defaultCenter
613630
addObserver:self
614631
selector:@selector(colorsChanged)

0 commit comments

Comments
 (0)