Skip to content

Commit

Permalink
Merge pull request Rust-SDL2#1005 from GuillaumeGomez/w-event
Browse files Browse the repository at this point in the history
Add WindowEvent::is_same_kind_as
  • Loading branch information
Cobrand authored Jun 3, 2020
2 parents 6b18572 + 63b22e3 commit be259e6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/sdl2/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,28 @@ impl WindowEvent {
}
}

pub fn is_same_kind_as(&self, other: &WindowEvent) -> bool {
match (self, other) {
(Self::None, Self::None)
| (Self::Shown, Self::Shown)
| (Self::Hidden, Self::Hidden)
| (Self::Exposed, Self::Exposed)
| (Self::Moved(_, _), Self::Moved(_, _))
| (Self::Resized(_, _), Self::Resized(_, _))
| (Self::SizeChanged(_, _), Self::SizeChanged(_, _))
| (Self::Minimized, Self::Minimized)
| (Self::Maximized, Self::Maximized)
| (Self::Restored, Self::Restored)
| (Self::Enter, Self::Enter)
| (Self::Leave, Self::Leave)
| (Self::FocusGained, Self::FocusGained)
| (Self::FocusLost, Self::FocusLost)
| (Self::Close, Self::Close)
| (Self::TakeFocus, Self::TakeFocus)
| (Self::HitTest, Self::HitTest) => true,
_ => false,
}
}
}

#[derive(Clone, PartialEq, Debug)]
Expand Down

0 comments on commit be259e6

Please sign in to comment.