From dbc24a31d0d6e959534b0469269adbad9e8d326b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 3 Jun 2020 11:43:11 +0200 Subject: [PATCH] Add WindowEvent::is_same_kind_as --- src/sdl2/event.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/sdl2/event.rs b/src/sdl2/event.rs index 41211b5a229..b9315eff04a 100644 --- a/src/sdl2/event.rs +++ b/src/sdl2/event.rs @@ -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)]