Skip to content

Commit

Permalink
Make the window visible without it becoming the key window of the app.
Browse files Browse the repository at this point in the history
For the presentation of notifications the window does not have to be key.
It will still receive touch events (gestures, buttons etc) but won't receive keyboard events and motion events.
  • Loading branch information
kairadiagne committed Dec 18, 2020
1 parent aad09b4 commit be26c30
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/UINotificationCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public final class UINotificationCenter {
// MARK: Private properties

/// The window which will be placed on top of the application window.
/// This window is used to present the notifications on and will be hidden when all notifications are presented.
/// This window is used to present the notifications on and will be hidden when notifications are dismissed.
internal let window: UIWindow

/// Handles queueing of all notifications. Contains a queue of `UINotificationRequest` objects.
Expand Down
7 changes: 2 additions & 5 deletions Sources/UINotificationPresentationContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class UINotificationPresentationContext {
private func prepareContainerWindow() {
containerWindow.windowLevel = windowLevel
#if !TEST
containerWindow.makeKeyAndVisible()
containerWindow.isHidden = false
#endif
}

Expand Down Expand Up @@ -94,9 +94,6 @@ public final class UINotificationPresentationContext {
/// Move the window behind the key application window.
containerWindow.windowLevel = UIWindow.Level.normal - 1
containerWindow.rootViewController = nil

/// Make sure the key window of the app is visible again.
guard let applicationWindow = UIApplication.shared.windows.first(where: { $0 != self.containerWindow }) else { return }
applicationWindow.makeKeyAndVisible()
containerWindow.isHidden = true
}
}

0 comments on commit be26c30

Please sign in to comment.