Skip to content

Commit 30850ac

Browse files
committed
Add window show/hide hook methods to WindowManager
Introduces SetWillShowHook, SetWillHideHook, InvokeWillShowHook, and InvokeWillHideHook methods to WindowManager for all supported platforms. These methods allow registration and invocation of hooks before native window show/hide operations, enabling platform-specific customization. Implementations are currently empty stubs.
1 parent aa14618 commit 30850ac

File tree

7 files changed

+113
-0
lines changed

7 files changed

+113
-0
lines changed

src/platform/android/window_manager_android.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,20 @@ std::shared_ptr<Window> WindowManager::Create(const WindowOptions& options) {
144144
return nullptr;
145145
}
146146

147+
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
148+
// Empty implementation
149+
}
150+
151+
void WindowManager::SetWillHideHook(std::optional<WindowWillHideHook> hook) {
152+
// Empty implementation
153+
}
154+
155+
void WindowManager::InvokeWillShowHook(WindowId id) {
156+
// Empty implementation
157+
}
158+
159+
void WindowManager::InvokeWillHideHook(WindowId id) {
160+
// Empty implementation
161+
}
162+
147163
} // namespace nativeapi

src/platform/ios/window_manager_ios.mm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,20 @@
8585
Emit(event);
8686
}
8787

88+
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
89+
// Empty implementation
90+
}
91+
92+
void WindowManager::SetWillHideHook(std::optional<WindowWillHideHook> hook) {
93+
// Empty implementation
94+
}
95+
96+
void WindowManager::InvokeWillShowHook(WindowId id) {
97+
// Empty implementation
98+
}
99+
100+
void WindowManager::InvokeWillHideHook(WindowId id) {
101+
// Empty implementation
102+
}
103+
88104
} // namespace nativeapi

src/platform/linux/window_manager_linux.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,20 @@ bool WindowManager::Destroy(WindowId id) {
288288
return false;
289289
}
290290

291+
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
292+
// Empty implementation
293+
}
294+
295+
void WindowManager::SetWillHideHook(std::optional<WindowWillHideHook> hook) {
296+
// Empty implementation
297+
}
298+
299+
void WindowManager::InvokeWillShowHook(WindowId id) {
300+
// Empty implementation
301+
}
302+
303+
void WindowManager::InvokeWillHideHook(WindowId id) {
304+
// Empty implementation
305+
}
306+
291307
} // namespace nativeapi

src/platform/macos/window_manager_macos.mm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,20 @@ - (void)windowWillClose:(NSNotification*)notification {
285285
return nullptr;
286286
}
287287

288+
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
289+
// Empty implementation
290+
}
291+
292+
void WindowManager::SetWillHideHook(std::optional<WindowWillHideHook> hook) {
293+
// Empty implementation
294+
}
295+
296+
void WindowManager::InvokeWillShowHook(WindowId id) {
297+
// Empty implementation
298+
}
299+
300+
void WindowManager::InvokeWillHideHook(WindowId id) {
301+
// Empty implementation
302+
}
303+
288304
} // namespace nativeapi

src/platform/ohos/window_manager_ohos.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,20 @@ std::shared_ptr<Window> WindowManager::Create(const WindowOptions& options) {
139139
return nullptr;
140140
}
141141

142+
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
143+
// Empty implementation
144+
}
145+
146+
void WindowManager::SetWillHideHook(std::optional<WindowWillHideHook> hook) {
147+
// Empty implementation
148+
}
149+
150+
void WindowManager::InvokeWillShowHook(WindowId id) {
151+
// Empty implementation
152+
}
153+
154+
void WindowManager::InvokeWillHideHook(WindowId id) {
155+
// Empty implementation
156+
}
157+
142158
} // namespace nativeapi

src/platform/windows/window_manager_windows.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,20 @@ std::shared_ptr<Window> WindowManager::GetCurrent() {
217217
return nullptr;
218218
}
219219

220+
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
221+
// Empty implementation
222+
}
223+
224+
void WindowManager::SetWillHideHook(std::optional<WindowWillHideHook> hook) {
225+
// Empty implementation
226+
}
227+
228+
void WindowManager::InvokeWillShowHook(WindowId id) {
229+
// Empty implementation
230+
}
231+
232+
void WindowManager::InvokeWillHideHook(WindowId id) {
233+
// Empty implementation
234+
}
235+
220236
} // namespace nativeapi

src/window_manager.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#pragma once
22

3+
#include <cstddef>
34
#include <functional>
45
#include <memory>
6+
#include <optional>
57
#include <unordered_map>
68
#include <vector>
79

@@ -163,6 +165,21 @@ class WindowManager : public EventEmitter<WindowEvent> {
163165
*/
164166
bool Destroy(WindowId id);
165167

168+
/**
169+
* Hooks invoked before native window show/hide operations (e.g., via swizzling).
170+
* These are declarations only; platform implementations can register and invoke them.
171+
*/
172+
using WindowWillShowHook = std::function<void(WindowId)>;
173+
using WindowWillHideHook = std::function<void(WindowId)>;
174+
175+
// Set or clear single hooks (pass std::nullopt to clear)
176+
void SetWillShowHook(std::optional<WindowWillShowHook> hook);
177+
void SetWillHideHook(std::optional<WindowWillHideHook> hook);
178+
179+
// Called by platform layer BEFORE the actual show/hide happens
180+
void InvokeWillShowHook(WindowId id);
181+
void InvokeWillHideHook(WindowId id);
182+
166183
private:
167184
/**
168185
* @brief Private constructor to enforce singleton pattern

0 commit comments

Comments
 (0)