+#ifdef USE_TOUCHBAR
+
+static NSString *touchbar_cid = @"org.jwz.xscreensaver.touchbar";
+static NSString *touchbar_iid = @"org.jwz.xscreensaver.touchbar";
+
+- (NSTouchBar *) makeTouchBar
+{
+ NSTouchBar *t = [[NSTouchBar alloc] init];
+ t.delegate = self;
+ t.customizationIdentifier = touchbar_cid;
+ t.defaultItemIdentifiers = @[touchbar_iid,
+ NSTouchBarItemIdentifierOtherItemsProxy];
+ t.customizationAllowedItemIdentifiers = @[touchbar_iid];
+ t.principalItemIdentifier = touchbar_iid;
+ return t;
+}
+
+- (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar
+ makeItemForIdentifier:(NSTouchBarItemIdentifier)id
+{
+ if ([id isEqualToString:touchbar_iid])
+ {
+ NSRect rect = [self frame];
+ // #### debugging
+ rect.origin.x = 0;
+ rect.origin.y = 0;
+ rect.size.width = 200;
+ rect.size.height = 40;
+ touchbar_view = [[[self class] alloc]
+ initWithFrame:rect
+ saverName:[NSString stringWithCString:xsft->progclass
+ encoding:NSISOLatin1StringEncoding]
+ isPreview:self.isPreview
+ isTouchbar:True];
+ [touchbar_view setAutoresizingMask:
+ NSViewWidthSizable|NSViewHeightSizable];
+ NSCustomTouchBarItem *item =
+ [[NSCustomTouchBarItem alloc] initWithIdentifier:id];
+ item.view = touchbar_view;
+ item.customizationLabel = touchbar_cid;
+
+ if ([self isAnimating])
+ // TouchBar was created after animation begun.
+ [touchbar_view startAnimation];
+ }
+ return nil;
+}
+
+#endif // USE_TOUCHBAR
+
+