mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 13:35:07 +00:00

As a consequence, move to use an explicit handshake() method rather than calling virtuals from the constructor. This seemed to not bother AClientConnection, but LibGUI crashes (rightfully) because of it.
49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
#include "WindowList.h"
|
|
#include <LibGUI/GEventLoop.h>
|
|
#include <WindowServer/WSAPITypes.h>
|
|
|
|
WindowList& WindowList::the()
|
|
{
|
|
static WindowList* s_the;
|
|
if (!s_the)
|
|
s_the = new WindowList;
|
|
return *s_the;
|
|
}
|
|
|
|
Window* WindowList::window(const WindowIdentifier& identifier)
|
|
{
|
|
auto it = m_windows.find(identifier);
|
|
if (it != m_windows.end())
|
|
return it->value;
|
|
return nullptr;
|
|
}
|
|
|
|
Window& WindowList::ensure_window(const WindowIdentifier& identifier)
|
|
{
|
|
auto it = m_windows.find(identifier);
|
|
if (it != m_windows.end())
|
|
return *it->value;
|
|
auto window = make<Window>(identifier);
|
|
window->set_button(aid_create_button(identifier));
|
|
window->button()->on_click = [window = window.ptr(), identifier](GButton&) {
|
|
WSAPI_ClientMessage message;
|
|
if (window->is_minimized() || !window->is_active()) {
|
|
message.type = WSAPI_ClientMessage::Type::WM_SetActiveWindow;
|
|
} else {
|
|
message.type = WSAPI_ClientMessage::Type::WM_SetWindowMinimized;
|
|
message.wm.minimized = true;
|
|
}
|
|
message.wm.client_id = identifier.client_id();
|
|
message.wm.window_id = identifier.window_id();
|
|
bool success = GEventLoop::current().connection().post_message_to_server(message);
|
|
ASSERT(success);
|
|
};
|
|
auto& window_ref = *window;
|
|
m_windows.set(identifier, move(window));
|
|
return window_ref;
|
|
}
|
|
|
|
void WindowList::remove_window(const WindowIdentifier& identifier)
|
|
{
|
|
m_windows.remove(identifier);
|
|
}
|