Skip to content

Commit e482561

Browse files
committed
Fix color space of block cursor in Metal. Issue 12719
1 parent 56868a1 commit e482561

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

sources/Metal/Renderers/iTermCursorRenderer.m

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,23 +330,27 @@ - (iTermCursorDescription)cursorDescriptionWithTransientState:(iTermCursorRender
330330
const CGFloat scale = tState.configuration.scale;
331331
y += cellSize.height - MAX(0, round(((cellSize.height - cellSizeWithoutSpacing.height) / 2) / scale) * scale) - tState.cursorHeight;
332332
}
333+
// Convert color to the target color space before extracting components.
334+
// This ensures the filled cursor matches the frame cursor, which goes through
335+
// AppKit's color space conversion when drawing into an NSImage.
336+
NSColor *color = [tState.color colorUsingColorSpace:tState.configuration.colorSpace];
333337
iTermCursorDescription description = {
334338
.origin = {
335339
tState.cellConfiguration.cellSize.width * tState.coord.x,
336340
y
337341
},
338342
.color = {
339-
tState.color.redComponent,
340-
tState.color.greenComponent,
341-
tState.color.blueComponent,
343+
color.redComponent,
344+
color.greenComponent,
345+
color.blueComponent,
342346
1
343347
}
344348
};
345349
if ([iTermAdvancedSettingsModel hdrCursor] &&
346-
tState.color.redComponent == 1 &&
347-
tState.color.greenComponent == 1 &&
348-
tState.color.blueComponent == 1 &&
349-
tState.color.alphaComponent == 1) {
350+
color.redComponent == 1 &&
351+
color.greenComponent == 1 &&
352+
color.blueComponent == 1 &&
353+
color.alphaComponent == 1) {
350354
CGFloat maxValue = tState.configuration.maximumExtendedDynamicRangeColorComponentValue;
351355
description.color = simd_make_float4(maxValue, maxValue, maxValue, 1);
352356
}

0 commit comments

Comments
 (0)