1+ #pragma once
2+ #include < string>
3+ #include " display.h"
4+ #include " event.h"
5+ #include " geometry.h"
6+
7+ namespace nativeapi {
8+
9+ /* *
10+ * Base class for all display-related events
11+ *
12+ * This class provides common functionality for display events,
13+ * including access to the display that triggered the event.
14+ */
15+ class DisplayEvent : public Event {
16+ public:
17+ /* *
18+ * Constructor for DisplayEvent
19+ * @param display The display associated with this event
20+ */
21+ explicit DisplayEvent (const Display& display) : display_(display) {}
22+
23+ /* *
24+ * Virtual destructor
25+ */
26+ virtual ~DisplayEvent () = default ;
27+
28+ /* *
29+ * Get the display associated with this event
30+ * @return Reference to the display
31+ */
32+ const Display& GetDisplay () const { return display_; }
33+
34+ /* *
35+ * Get a string representation of the event type (for debugging)
36+ * Default implementation returns "DisplayEvent"
37+ */
38+ std::string GetTypeName () const override { return " DisplayEvent" ; }
39+
40+ private:
41+ Display display_;
42+ };
43+
44+ /* *
45+ * Event class for display addition
46+ *
47+ * This event is emitted when a new display is connected to the system.
48+ */
49+ class DisplayAddedEvent : public DisplayEvent {
50+ public:
51+ explicit DisplayAddedEvent (const Display& display) : DisplayEvent(display) {}
52+
53+ /* *
54+ * Get a string representation of the event type
55+ */
56+ std::string GetTypeName () const override { return " DisplayAddedEvent" ; }
57+
58+ /* *
59+ * Get the static type index for this event type
60+ */
61+ static std::type_index GetStaticType () {
62+ return std::type_index (typeid (DisplayAddedEvent));
63+ }
64+
65+ /* *
66+ * Get the type index for this event instance
67+ */
68+ std::type_index GetType () const {
69+ return GetStaticType ();
70+ }
71+ };
72+
73+ /* *
74+ * Event class for display removal
75+ *
76+ * This event is emitted when a display is disconnected from the system.
77+ */
78+ class DisplayRemovedEvent : public DisplayEvent {
79+ public:
80+ explicit DisplayRemovedEvent (const Display& display) : DisplayEvent(display) {}
81+
82+ /* *
83+ * Get a string representation of the event type
84+ */
85+ std::string GetTypeName () const override { return " DisplayRemovedEvent" ; }
86+
87+ /* *
88+ * Get the static type index for this event type
89+ */
90+ static std::type_index GetStaticType () {
91+ return std::type_index (typeid (DisplayRemovedEvent));
92+ }
93+
94+ /* *
95+ * Get the type index for this event instance
96+ */
97+ std::type_index GetType () const {
98+ return GetStaticType ();
99+ }
100+ };
101+
102+ /* *
103+ * Event class for display configuration changes
104+ *
105+ * This event is emitted when a display's properties change (resolution, orientation, etc.).
106+ */
107+ class DisplayChangedEvent : public DisplayEvent {
108+ public:
109+ DisplayChangedEvent (const Display& old_display, const Display& new_display)
110+ : DisplayEvent(new_display), old_display_(old_display) {}
111+
112+ /* *
113+ * Get the display information before the change
114+ * @return Reference to the old display state
115+ */
116+ const Display& GetOldDisplay () const { return old_display_; }
117+
118+ /* *
119+ * Get the display information after the change
120+ * @return Reference to the new display state
121+ */
122+ const Display& GetNewDisplay () const { return GetDisplay (); }
123+
124+ /* *
125+ * Get a string representation of the event type
126+ */
127+ std::string GetTypeName () const override { return " DisplayChangedEvent" ; }
128+
129+ /* *
130+ * Get the static type index for this event type
131+ */
132+ static std::type_index GetStaticType () {
133+ return std::type_index (typeid (DisplayChangedEvent));
134+ }
135+
136+ /* *
137+ * Get the type index for this event instance
138+ */
139+ std::type_index GetType () const {
140+ return GetStaticType ();
141+ }
142+
143+ private:
144+ Display old_display_;
145+ };
146+
147+ } // namespace nativeapi
0 commit comments