         let duration = enabled ? self.duration.show : self.duration.hide
 
         isEnabled = enabled
-        adjustWindowLevel?()
+        adjustWindowAttributes?(window, enabled)
         setNeedsStatusBarAppearanceUpdate()
 
         if enabled {
             window.isHidden = false
-            window.makeKey()
 
             guard animated else {
                 view.alpha = 1

        self.windowLevel = maxWinLevel + 1
    }

    private lazy var adjustWindowLevel: (() -> Void)? = { [weak self] in
        self?.setDefaultWindowLevel()
    }

    /// A block to adjust window level so this HUD is displayed appropriately.
    ///
    /// For example, you can adjust the window level so this HUD is always shown
    /// behind the passcode screen to ensure that this HUD is not shown before user

    ///
    /// - Note: By default, window level is set so it appears on the top of the
    /// currently visible window.
    open func adjustWindowAttributes(_ callback: @escaping (_ window: UIWindow, _ willShow: Bool) -> Void) {
        adjustWindowAttributes = { [weak self] window, willShow in
            self?.setDefaultWindowLevel()
            callback(window, willShow)
        }
    }

