Skip to content

Commit 7d82686

Browse files
committed
Remove window destruction API and implementation
Eliminated the Destroy method from WindowManager and its C API, along with all platform-specific implementations. This simplifies the window management interface and removes unused or unsupported window destruction functionality.
1 parent 08aa20c commit 7d82686

File tree

9 files changed

+0
-109
lines changed

9 files changed

+0
-109
lines changed

src/capi/window_manager_c.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,6 @@ native_window_t native_window_manager_get_current(void) {
182182
}
183183
}
184184

185-
FFI_PLUGIN_EXPORT
186-
bool native_window_manager_destroy(native_window_id_t window_id) {
187-
try {
188-
auto& manager = WindowManager::GetInstance();
189-
return manager.Destroy(window_id);
190-
} catch (...) {
191-
return false;
192-
}
193-
}
194-
195185
FFI_PLUGIN_EXPORT
196186
int native_window_manager_register_event_callback(native_window_event_callback_t callback,
197187
void* user_data) {

src/capi/window_manager_c.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ native_window_list_t native_window_manager_get_all(void);
8282
FFI_PLUGIN_EXPORT
8383
native_window_t native_window_manager_get_current(void);
8484

85-
/**
86-
* Destroy a window by its ID
87-
* @param window_id The window ID to destroy
88-
* @return true if window was found and destroyed, false otherwise
89-
*/
90-
FFI_PLUGIN_EXPORT
91-
bool native_window_manager_destroy(native_window_id_t window_id);
92-
9385
/**
9486
* Register a callback for window events
9587
* @param callback The callback function to register

src/platform/android/window_manager_android.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,6 @@ std::shared_ptr<Window> WindowManager::GetCurrent() {
106106
return all.empty() ? nullptr : all.front();
107107
}
108108

109-
bool WindowManager::Destroy(WindowId id) {
110-
auto window = WindowRegistry::GetInstance().Get(id);
111-
if (!window) {
112-
return false;
113-
}
114-
WindowRegistry::GetInstance().Remove(id);
115-
return true;
116-
}
117-
118109
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
119110
// Empty implementation
120111
}

src/platform/ios/window_manager_ios.mm

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,6 @@
3737
return nullptr;
3838
}
3939

40-
bool WindowManager::Destroy(WindowId id) {
41-
auto window = WindowRegistry::GetInstance().Get(id);
42-
if (!window) {
43-
return false;
44-
}
45-
46-
WindowRegistry::GetInstance().Remove(id);
47-
48-
return true;
49-
}
50-
5140
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
5241
// Empty implementation
5342
}

src/platform/linux/window_manager_linux.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,6 @@ std::shared_ptr<Window> WindowManager::GetCurrent() {
337337
return nullptr;
338338
}
339339

340-
bool WindowManager::Destroy(WindowId id) {
341-
auto window = WindowRegistry::GetInstance().Get(id);
342-
if (!window) {
343-
return false;
344-
}
345-
// TODO: Implement proper GTK window destruction
346-
WindowRegistry::GetInstance().Remove(id);
347-
return true;
348-
}
349-
350340
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
351341
pimpl_->will_show_hook_ = std::move(hook);
352342
if (pimpl_->will_show_hook_) {

src/platform/macos/window_manager_macos.mm

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -257,24 +257,6 @@ - (void)windowWillClose:(NSNotification*)notification {
257257
StopEventListening();
258258
}
259259

260-
// Destroy a window by its ID. Returns true if window was destroyed.
261-
bool WindowManager::Destroy(WindowId id) {
262-
auto window = WindowRegistry::GetInstance().Get(id);
263-
if (!window) {
264-
return false;
265-
}
266-
NSArray* ns_windows = [[NSApplication sharedApplication] windows];
267-
for (NSWindow* ns_window in ns_windows) {
268-
if ([ns_window windowNumber] == id) {
269-
[ns_window close];
270-
WindowRegistry::GetInstance().Remove(id);
271-
return true;
272-
}
273-
}
274-
WindowRegistry::GetInstance().Remove(id);
275-
return false;
276-
}
277-
278260
std::shared_ptr<Window> WindowManager::Get(WindowId id) {
279261
// First check if it's already in the registry
280262
auto window = WindowRegistry::GetInstance().Get(id);

src/platform/ohos/window_manager_ohos.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ std::shared_ptr<Window> WindowManager::GetCurrent() {
102102
return all.empty() ? nullptr : all.front();
103103
}
104104

105-
bool WindowManager::Destroy(WindowId id) {
106-
auto window = WindowRegistry::GetInstance().Get(id);
107-
if (!window) {
108-
return false;
109-
}
110-
WindowRegistry::GetInstance().Remove(id);
111-
return true;
112-
}
113-
114105
void WindowManager::SetWillShowHook(std::optional<WindowWillShowHook> hook) {
115106
// Empty implementation
116107
}

src/platform/windows/window_manager_windows.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -359,20 +359,6 @@ WindowManager::~WindowManager() {
359359
StopEventListening();
360360
}
361361

362-
// Destroy a window by its ID. Returns true if window was destroyed.
363-
bool WindowManager::Destroy(WindowId id) {
364-
auto window = WindowRegistry::GetInstance().Get(id);
365-
if (!window) {
366-
return false;
367-
}
368-
HWND hwnd = static_cast<HWND>(window->GetNativeObject());
369-
if (IsWindow(hwnd)) {
370-
DestroyWindow(hwnd);
371-
}
372-
WindowRegistry::GetInstance().Remove(id);
373-
return true;
374-
}
375-
376362
std::shared_ptr<Window> WindowManager::Get(WindowId id) {
377363
// First try to get from registry
378364
auto window = WindowRegistry::GetInstance().Get(id);

src/window_manager.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,6 @@ class WindowManager : public EventEmitter<WindowEvent> {
118118
*/
119119
std::shared_ptr<Window> GetCurrent();
120120

121-
/**
122-
* @brief Destroy a window by its ID
123-
*
124-
* Removes the specified window from the registry and destroys it.
125-
* This will close the window and free its resources.
126-
* Any remaining shared_ptr references to the window will become invalid after
127-
* the window is destroyed.
128-
*
129-
* @param id The unique identifier of the window to destroy
130-
* @return true if the window was found and destroyed, false if window was not found
131-
*
132-
* @code
133-
* WindowId window_id = some_window->GetId();
134-
* bool success = WindowManager::GetInstance().Destroy(window_id);
135-
* if (success) {
136-
* std::cout << "Window destroyed successfully" << std::endl;
137-
* }
138-
* @endcode
139-
*/
140-
bool Destroy(WindowId id);
141121

142122
/**
143123
* Hooks invoked before native window show/hide operations (e.g., via swizzling).

0 commit comments

Comments
 (0)