|
18 | 18 | public: |
19 | 19 | Impl(WindowManager* manager); |
20 | 20 | ~Impl(); |
21 | | - void SetupEventMonitoring(); |
22 | | - void CleanupEventMonitoring(); |
| 21 | + void StartEventListening(); |
| 22 | + void StopEventListening(); |
23 | 23 | void OnWindowEvent(NSWindow* window, const std::string& event_type); |
24 | 24 |
|
25 | 25 | private: |
@@ -160,10 +160,10 @@ - (void)windowWillClose:(NSNotification*)notification { |
160 | 160 | WindowManager::Impl::Impl(WindowManager* manager) : manager_(manager), delegate_(nullptr) {} |
161 | 161 |
|
162 | 162 | WindowManager::Impl::~Impl() { |
163 | | - CleanupEventMonitoring(); |
| 163 | + StopEventListening(); |
164 | 164 | } |
165 | 165 |
|
166 | | -void WindowManager::Impl::SetupEventMonitoring() { |
| 166 | +void WindowManager::Impl::StartEventListening() { |
167 | 167 | if (!delegate_) { |
168 | 168 | delegate_ = [[NativeAPIWindowManagerDelegate alloc] initWithImpl:this]; |
169 | 169 |
|
@@ -199,7 +199,7 @@ - (void)windowWillClose:(NSNotification*)notification { |
199 | 199 | } |
200 | 200 | } |
201 | 201 |
|
202 | | -void WindowManager::Impl::CleanupEventMonitoring() { |
| 202 | +void WindowManager::Impl::StopEventListening() { |
203 | 203 | if (delegate_) { |
204 | 204 | NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
205 | 205 | [center removeObserver:delegate_]; |
@@ -239,23 +239,11 @@ - (void)windowWillClose:(NSNotification*)notification { |
239 | 239 | } |
240 | 240 |
|
241 | 241 | WindowManager::WindowManager() : pimpl_(std::make_unique<Impl>(this)) { |
242 | | - SetupEventMonitoring(); |
| 242 | + StartEventListening(); |
243 | 243 | } |
244 | 244 |
|
245 | 245 | WindowManager::~WindowManager() { |
246 | | - CleanupEventMonitoring(); |
247 | | -} |
248 | | - |
249 | | -void WindowManager::SetupEventMonitoring() { |
250 | | - pimpl_->SetupEventMonitoring(); |
251 | | -} |
252 | | - |
253 | | -void WindowManager::CleanupEventMonitoring() { |
254 | | - pimpl_->CleanupEventMonitoring(); |
255 | | -} |
256 | | - |
257 | | -void WindowManager::DispatchWindowEvent(const WindowEvent& event) { |
258 | | - Emit(event); // Use Dispatch instead of DispatchSync |
| 246 | + StopEventListening(); |
259 | 247 | } |
260 | 248 |
|
261 | 249 | // Create a new window with the given options. |
@@ -373,4 +361,16 @@ - (void)windowWillClose:(NSNotification*)notification { |
373 | 361 | } |
374 | 362 | } |
375 | 363 |
|
| 364 | +void WindowManager::StartEventListening() { |
| 365 | + pimpl_->StartEventListening(); |
| 366 | +} |
| 367 | + |
| 368 | +void WindowManager::StopEventListening() { |
| 369 | + pimpl_->StopEventListening(); |
| 370 | +} |
| 371 | + |
| 372 | +void WindowManager::DispatchWindowEvent(const WindowEvent& event) { |
| 373 | + Emit(event); // Use Dispatch instead of DispatchSync |
| 374 | +} |
| 375 | + |
376 | 376 | } // namespace nativeapi |
0 commit comments