opuntiaOS - an operating system targeting x86 and ARMv7
at master 988 B view raw
1/* 2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors. 3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com> 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#include <libui/App.h> 10#include <memory> 11#include <sys/socket.h> 12 13namespace UI { 14 15App* s_UI_App_the = nullptr; 16 17App::App() 18 : m_event_loop() 19 , m_server_connection(socket(PF_LOCAL, 0, 0)) 20{ 21 s_UI_App_the = this; 22} 23 24void App::receive_event(std::unique_ptr<LFoundation::Event> event) 25{ 26 if (event->type() == Event::Type::WindowCloseRequestEvent) { 27 // TODO: Only 1 window is supported for now 28 WindowCloseRequestEvent& own_event = *(WindowCloseRequestEvent*)event.get(); 29 auto message = DestroyWindowMessage(m_server_connection.key(), own_event.window_id()); 30 auto reply = m_server_connection.send_sync_message<DestroyWindowMessageReply>(message); 31 m_event_loop.stop(reply->status()); 32 } 33} 34 35} // namespace UI