Skip to content

Commit

Permalink
Add deprecated to Active et al
Browse files Browse the repository at this point in the history
  • Loading branch information
notgull committed Apr 4, 2023
1 parent 7a8d1d7 commit ac9636b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ use crate::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindow
/// and immediately invalidate all window handles. However, it was later discovered that the
/// handle actually remains valid, but the window does not produce any more GPU buffers. This
/// type is a no-op and will be removed at the next major release.
#[deprecated = "Will be removed at next major release, use ActiveHandle::new() for now"]
pub struct Active(());

#[allow(deprecated)]
impl fmt::Debug for Active {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("Active { .. }")
Expand All @@ -51,6 +53,7 @@ impl<'a> fmt::Debug for ActiveHandle<'a> {
}
}

#[allow(deprecated)]
impl Active {
/// Create a new `Active` tracker.
///
Expand All @@ -62,6 +65,7 @@ impl Active {
/// use raw_window_handle::Active;
/// let active = Active::new();
/// ```
#[deprecated = "Will be removed at next major release, use ActiveHandle::new() for now"]
pub const fn new() -> Self {
Self(())
}
Expand All @@ -86,6 +90,7 @@ impl Active {
/// drop(handle);
/// active.set_inactive();
/// ```
#[deprecated = "Will be removed at next major release, use ActiveHandle::new() for now"]
pub fn handle(&self) -> Option<ActiveHandle<'_>> {
Some(ActiveHandle(PhantomData))
}
Expand All @@ -106,6 +111,7 @@ impl Active {
/// // Set the application to be inactive.
/// active.set_inactive();
/// ```
#[deprecated = "Will be removed at next major release, use ActiveHandle::new() for now"]
pub fn set_inactive(&self) {}

/// Set the application to be active.
Expand All @@ -127,6 +133,7 @@ impl Active {
/// // Set the application to be inactive.
/// active.set_inactive();
/// ```
#[deprecated = "Will be removed at next major release, use ActiveHandle::new() for now"]
pub unsafe fn set_active(&self) {}
}

Expand All @@ -151,6 +158,7 @@ impl ActiveHandle<'_> {
/// // SAFETY: The application must actually be active.
/// let handle = unsafe { ActiveHandle::new_unchecked() };
/// ```
#[deprecated = "Will be removed at next major release, use ActiveHandle::new() for now"]
pub unsafe fn new_unchecked() -> Self {
Self(PhantomData)
}
Expand All @@ -165,7 +173,7 @@ impl ActiveHandle<'_> {
/// use raw_window_handle::ActiveHandle;
/// let handle = ActiveHandle::new();
/// ```
#[allow(clippy::new_without_default)]
#[allow(clippy::new_without_default, deprecated)]
pub fn new() -> Self {
// SAFETY: The handle is always active.
unsafe { super::ActiveHandle::new_unchecked() }
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mod windows;
pub use android::{AndroidDisplayHandle, AndroidNdkWindowHandle};
pub use appkit::{AppKitDisplayHandle, AppKitWindowHandle};
#[cfg(any(feature = "std", not(target_os = "android")))]
#[allow(deprecated)]
pub use borrowed::{
Active, ActiveHandle, DisplayHandle, HandleError, HasDisplayHandle, HasWindowHandle,
WindowHandle,
Expand Down

0 comments on commit ac9636b

Please sign in to comment.