diff options
author | der richter <der.richter@gmx.de> | 2021-01-19 19:39:56 +0100 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2021-02-13 15:51:32 +0100 |
commit | aa00ad06aae264796a84327f1716534b4f37c622 (patch) | |
tree | 6ac7843e3add15846b8a16f4df02f6821a5f386f /osdep/macosx_touchbar.m | |
parent | 968faef86723c895f5b19c948a43eb0fcf6179e5 (diff) | |
download | mpv-aa00ad06aae264796a84327f1716534b4f37c622.tar.bz2 mpv-aa00ad06aae264796a84327f1716534b4f37c622.tar.xz |
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
Diffstat (limited to 'osdep/macosx_touchbar.m')
-rw-r--r-- | osdep/macosx_touchbar.m | 18 |
1 files 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]]; } |