From aa00ad06aae264796a84327f1716534b4f37c622 Mon Sep 17 00:00:00 2001 From: der richter Date: Tue, 19 Jan 2021 19:39:56 +0100 Subject: mac: use custom touch bar item and slider instead of a touch bar slider the NSSliderTouchBarItem seem to be broken in a way it can't be fixed. it has constraints set by default that can't be removed and lead to warnings and render performance regressions. instead of using the preconfigured NSSliderTouchBarItem we use a custom touch bar item (NSCustomTouchBarItem) with a slider, which essential are the same. this way we can configure our constraints ourselves, which aren't needed in the first place. Fixes: #7047 --- osdep/macosx_touchbar.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osdep/macosx_touchbar.m b/osdep/macosx_touchbar.m index c189e32354..3e949bc364 100644 --- a/osdep/macosx_touchbar.m +++ b/osdep/macosx_touchbar.m @@ -131,13 +131,13 @@ makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier { if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"slider"]) { - NSSliderTouchBarItem *tbItem = [[NSSliderTouchBarItem alloc] initWithIdentifier:identifier]; - tbItem.slider.minValue = 0.0f; - tbItem.slider.maxValue = 100.0f; - tbItem.target = self; - tbItem.action = @selector(seekbarChanged:); + NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; + NSSlider *slider = [NSSlider sliderWithTarget:self action:@selector(seekbarChanged:)]; + slider.minValue = 0.0f; + slider.maxValue = 100.0f; + tbItem.view = slider; tbItem.customizationLabel = self.touchbarItems[identifier][@"name"]; - [self.touchbarItems[identifier] setObject:tbItem.slider forKey:@"view"]; + [self.touchbarItems[identifier] setObject:slider forKey:@"view"]; return tbItem; } else if ([self.touchbarItems[identifier][@"type"] isEqualToString:@"button"]) { NSCustomTouchBarItem *tbItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; @@ -261,11 +261,11 @@ [self.app queueCommand:(char *)[self.touchbarItems[identifier][@"cmd"] UTF8String]]; } -- (void)seekbarChanged:(NSSliderTouchBarItem *)sender +- (void)seekbarChanged:(NSSlider *)slider { - NSString *identifier = [self getIdentifierFromView:sender.slider]; + NSString *identifier = [self getIdentifierFromView:slider]; NSString *seek = [NSString stringWithFormat: - self.touchbarItems[identifier][@"cmd"], sender.slider.doubleValue]; + self.touchbarItems[identifier][@"cmd"], slider.doubleValue]; [self.app queueCommand:(char *)[seek UTF8String]]; } -- cgit v1.2.3