@@ -494,6 +494,23 @@ - (void)setScrollbarPosition:(int)pos length:(int)len identifier:(int32_t)ident
494
494
- (void )setDefaultColorsBackground : (NSColor *)back foreground : (NSColor *)fore
495
495
{
496
496
[textView setDefaultColorsBackground: back foreground: fore];
497
+
498
+ CALayer *backedLayer = [self layer ];
499
+ if (backedLayer) {
500
+ // This would only trigger in 10.14 where all views are layer-backed.
501
+ //
502
+ // Note: This doesn't do much now. Should fix this class to use
503
+ // updateLayer: instead of drawRect: at a later time, which would draw
504
+ // the background color automatically. When we do that we can remove the
505
+ // hack at drawKnobSlotInRect: since it would overlay properly without
506
+ // needing to manually draw the background color itself.
507
+ [backedLayer setBackgroundColor: [back CGColor ]];
508
+ }
509
+
510
+ for (NSUInteger i = 0 , count = [scrollbars count ]; i < count; ++i) {
511
+ MMScroller *sb = [scrollbars objectAtIndex: i];
512
+ [sb setNeedsDisplay: YES ];
513
+ }
497
514
}
498
515
499
516
@@ -801,10 +818,15 @@ - (void)placeScrollbars
801
818
}
802
819
}
803
820
804
- // HACK: If there is no bottom or right scrollbar the resize indicator will
805
- // cover the bottom-right corner of the text view so tell NSWindow not to
806
- // draw it in this situation.
807
- [[self window ] setShowsResizeIndicator: (rightSbVisible||botSbVisible)];
821
+ if (NSAppKitVersionNumber < NSAppKitVersionNumber10_7 ) {
822
+ // HACK: If there is no bottom or right scrollbar the resize indicator will
823
+ // cover the bottom-right corner of the text view so tell NSWindow not to
824
+ // draw it in this situation.
825
+ //
826
+ // Note: This API is ignored from 10.7 onward and is now deprecated. This
827
+ // should be removed if we want to drop support for 10.6.
828
+ [[self window ] setShowsResizeIndicator: (rightSbVisible||botSbVisible)];
829
+ }
808
830
}
809
831
810
832
- (NSUInteger )representedIndexOfTabViewItem : (NSTabViewItem *)tvi
@@ -973,6 +995,27 @@ - (id)initWithIdentifier:(int32_t)ident type:(int)theType
973
995
return self;
974
996
}
975
997
998
+ - (void )drawKnobSlotInRect : (NSRect )slotRect highlight : (BOOL )flag
999
+ {
1000
+ // Dark mode scrollbars draw a translucent knob slot overlaid on top of
1001
+ // whatever background the view has, even when we are using legacy
1002
+ // scrollbars with a dedicated space. This means we need to draw the
1003
+ // background with some colors first, or else it would look really black, or
1004
+ // show through rendering artifacts (e.g. if guioption 'k' is on, and you
1005
+ // turn off the bar bar, the artiacts will show through in the overlay).
1006
+ //
1007
+ // Note: This should ideally be done on MMVimView itself by setting a background
1008
+ // color. This would be fixed at a later time by telling the view to just
1009
+ // use the background color form the backed CALayer (mandated since Mojave
1010
+ // 10.14).
1011
+ MMVimView *vimView = [self target ];
1012
+ NSColor *defaultBackgroundColor = [[vimView textView ] defaultBackgroundColor ];
1013
+ [defaultBackgroundColor setFill ];
1014
+ NSRectFill (slotRect);
1015
+
1016
+ [super drawKnobSlotInRect: slotRect highlight: flag];
1017
+ }
1018
+
976
1019
- (int32_t )scrollerId
977
1020
{
978
1021
return identifier;
0 commit comments