From debc587ce2ed309bb7425b12208673c7165b1b73 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 13 Jul 2019 18:35:13 +0200 Subject: [PATCH] LibCore: Add CCustomEvent, a custom CEvent for arbitrary use. For convenience it includes an int, and a void*. Interpretation of the contents is up to the client. --- Libraries/LibCore/CEvent.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Libraries/LibCore/CEvent.h b/Libraries/LibCore/CEvent.h index 9d262c4a76..6238cc59a4 100644 --- a/Libraries/LibCore/CEvent.h +++ b/Libraries/LibCore/CEvent.h @@ -17,6 +17,7 @@ public: DeferredInvoke, ChildAdded, ChildRemoved, + Custom, }; CEvent() {} @@ -72,3 +73,22 @@ public: private: WeakPtr m_child; }; + +class CCustomEvent : public CEvent { +public: + CCustomEvent(int custom_type, void* data = nullptr) + : CEvent(CEvent::Type::Custom) + , m_custom_type(custom_type) + , m_data(data) + { + } + ~CCustomEvent() {} + + int custom_type() const { return m_custom_type; } + void* data() { return m_data; } + const void* data() const { return m_data; } + +private: + int m_custom_type { 0 }; + void* m_data { nullptr }; +};