     self.titlebarThemed = true
   }
 
+  fileprivate func clearCustomTitle() {
+    self.titleView?.removeFromSuperview()
+    self.repIcon?.removeFromSuperview()
+
+    self.titleView = nil
+    self.repIcon = nil
+  }
+
   fileprivate func unthemeTitlebar(dueFullScreen: Bool) {
-    self.repIcon?.removeFromSuperview()
-    self.titleView?.removeFromSuperview()
-
-    self.repIcon = nil
-    self.titleView = nil
+    self.clearCustomTitle()
 
     self.root.removeFromSuperview()
 

    }
  }

  func windowWillEnterFullScreen(_: Notification) {
    self.unthemeTitlebar(dueFullScreen: true)
  }

  func windowDidExitFullScreen(_: Notification) {
    if self.titlebarThemed {
      self.themeTitlebar(nil)
    }
  }

  fileprivate func set(repUrl url: URL?, themed: Bool) {

fileprivate let gap = CGFloat(4.0)

class WindowController: NSWindowController, NSWindowDelegate {

  func windowWillEnterFullScreen(_: Notification) {
    self.unthemeTitlebar(dueFullScreen: true)
  }

  func windowDidExitFullScreen(_: Notification) {
    if self.titlebarThemed {
      self.themeTitlebar(nil)
    }
  }

  fileprivate var titlebarThemed = false
  fileprivate var repIcon: NSButton?
