2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "anbox/wm/single_window_manager.h"
19 #include "anbox/platform/base_platform.h"
20 #include "anbox/logger.h"
24 #include <sys/types.h>
29 SingleWindowManager::SingleWindowManager(const std::weak_ptr<platform::BasePlatform> &platform,
30 const graphics::Rect &window_size,
31 const std::shared_ptr<application::Database> &app_db)
32 : platform_(platform), window_size_(window_size), app_db_(app_db) {}
34 SingleWindowManager::~SingleWindowManager() {}
36 void SingleWindowManager::setup() {
37 if (auto p = platform_.lock()) {
38 window_ = p->create_window(0, window_size_, "Anbox - Android in a Box");
39 if (!window_->attach())
40 WARNING("Failed to attach window to renderer");
42 throw std::runtime_error("Can't create window as we don't have a platform abstraction");
46 void SingleWindowManager::apply_window_state_update(const WindowState::List &updated, const WindowState::List &removed) {
51 std::shared_ptr<Window> SingleWindowManager::find_window_for_task(const Task::Id &task) {
56 void SingleWindowManager::resize_task(const Task::Id &task, const anbox::graphics::Rect &rect,
57 const std::int32_t &resize_mode) {
63 void SingleWindowManager::set_focused_task(const Task::Id &task) {
67 void SingleWindowManager::remove_task(const Task::Id &task) {
69 WARNING("Window with invalid task id was closed");
73 // FIXME easiest to terminate is sending ourself the terminate signal
74 // which will be then processed by the main loop and terminate the whole
76 kill(getpid(), SIGTERM);