99using namespace nativeapi ;
1010
1111// Global state for event callbacks
12- struct EventCallbackInfo {
12+ struct WindowEventCallbackInfo {
1313 native_window_event_callback_t callback;
1414 void * user_data;
1515 int id;
1616};
1717
18- static std::mutex g_callback_mutex ;
19- static std::unordered_map<int , EventCallbackInfo> g_event_callbacks ;
20- static int g_next_callback_id = 1 ;
18+ static std::mutex g_window_callback_mutex ;
19+ static std::unordered_map<int , WindowEventCallbackInfo> g_window_event_callbacks ;
20+ static int g_window_next_callback_id = 1 ;
2121
2222// Helper function to create native_window_t from shared_ptr<Window>
2323static native_window_t CreateNativeWindowHandle (std::shared_ptr<Window> window) {
@@ -30,9 +30,9 @@ static native_window_t CreateNativeWindowHandle(std::shared_ptr<Window> window)
3030
3131// Helper function to dispatch events to registered callbacks
3232static void DispatchEvent (const native_window_event_t & event) {
33- std::lock_guard<std::mutex> lock (g_callback_mutex );
33+ std::lock_guard<std::mutex> lock (g_window_callback_mutex );
3434
35- for (const auto & [id, callback_info] : g_event_callbacks ) {
35+ for (const auto & [id, callback_info] : g_window_event_callbacks ) {
3636 try {
3737 callback_info.callback (&event, callback_info.user_data );
3838 } catch (...) {
@@ -42,9 +42,9 @@ static void DispatchEvent(const native_window_event_t& event) {
4242}
4343
4444// Event listener class to bridge C++ events to C callbacks
45- class CEventListener {
45+ class WindowCEventListener {
4646 public:
47- CEventListener () {
47+ WindowCEventListener () {
4848 auto & manager = WindowManager::GetInstance ();
4949
5050 // Register for various window events
@@ -103,7 +103,7 @@ class CEventListener {
103103 }
104104};
105105
106- static std::unique_ptr<CEventListener > g_event_listener;
106+ static std::unique_ptr<WindowCEventListener > g_event_listener;
107107
108108// Hook callbacks (C API)
109109static std::mutex g_hook_mutex;
@@ -177,22 +177,22 @@ int native_window_manager_register_event_callback(native_window_event_callback_t
177177 if (!callback)
178178 return -1 ;
179179
180- std::lock_guard<std::mutex> lock (g_callback_mutex );
180+ std::lock_guard<std::mutex> lock (g_window_callback_mutex );
181181
182- int callback_id = g_next_callback_id ++;
183- EventCallbackInfo info;
182+ int callback_id = g_window_next_callback_id ++;
183+ WindowEventCallbackInfo info;
184184 info.callback = callback;
185185 info.user_data = user_data;
186186 info.id = callback_id;
187187
188- g_event_callbacks [callback_id] = info;
188+ g_window_event_callbacks [callback_id] = info;
189189
190190 // Initialize event listener if this is the first callback
191191 if (!g_event_listener) {
192192 try {
193- g_event_listener = std::make_unique<CEventListener >();
193+ g_event_listener = std::make_unique<WindowCEventListener >();
194194 } catch (...) {
195- g_event_callbacks .erase (callback_id);
195+ g_window_event_callbacks .erase (callback_id);
196196 return -1 ;
197197 }
198198 }
@@ -202,17 +202,17 @@ int native_window_manager_register_event_callback(native_window_event_callback_t
202202
203203FFI_PLUGIN_EXPORT
204204bool native_window_manager_unregister_event_callback (int registration_id) {
205- std::lock_guard<std::mutex> lock (g_callback_mutex );
205+ std::lock_guard<std::mutex> lock (g_window_callback_mutex );
206206
207- auto it = g_event_callbacks .find (registration_id);
208- if (it == g_event_callbacks .end ()) {
207+ auto it = g_window_event_callbacks .find (registration_id);
208+ if (it == g_window_event_callbacks .end ()) {
209209 return false ;
210210 }
211211
212- g_event_callbacks .erase (it);
212+ g_window_event_callbacks .erase (it);
213213
214214 // Clean up event listener if no callbacks remain
215- if (g_event_callbacks .empty ()) {
215+ if (g_window_event_callbacks .empty ()) {
216216 g_event_listener.reset ();
217217 }
218218
@@ -221,10 +221,10 @@ bool native_window_manager_unregister_event_callback(int registration_id) {
221221
222222FFI_PLUGIN_EXPORT
223223void native_window_manager_shutdown (void ) {
224- std::lock_guard<std::mutex> lock (g_callback_mutex );
224+ std::lock_guard<std::mutex> lock (g_window_callback_mutex );
225225
226226 // Clear all callbacks
227- g_event_callbacks .clear ();
227+ g_window_event_callbacks .clear ();
228228
229229 // Clean up event listener
230230 g_event_listener.reset ();
0 commit comments