b8937cbd55b17ea677702c70af9181e7771807cf
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / wm / single_window_manager.cpp
1 /*
2  * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
3  *
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.
7  *
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.
12  *
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/>.
15  *
16  */
17
18 #include "anbox/wm/single_window_manager.h"
19 #include "anbox/platform/base_platform.h"
20 #include "anbox/logger.h"
21
22 #include <algorithm>
23
24 #include <sys/types.h>
25 #include <signal.h>
26
27 namespace anbox {
28 namespace wm {
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) {}
33
34 SingleWindowManager::~SingleWindowManager() {}
35
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");
41   } else {
42     throw std::runtime_error("Can't create window as we don't have a platform abstraction");
43   }
44 }
45
46 void SingleWindowManager::apply_window_state_update(const WindowState::List &updated, const WindowState::List &removed) {
47   (void)updated;
48   (void)removed;
49 }
50
51 std::shared_ptr<Window> SingleWindowManager::find_window_for_task(const Task::Id &task) {
52   (void)task;
53   return window_;
54 }
55
56 void SingleWindowManager::resize_task(const Task::Id &task, const anbox::graphics::Rect &rect,
57                                       const std::int32_t &resize_mode) {
58   (void)task;
59   (void)rect;
60   (void)resize_mode;
61 }
62
63 void SingleWindowManager::set_focused_task(const Task::Id &task) {
64   (void)task;
65 }
66
67 void SingleWindowManager::remove_task(const Task::Id &task) {
68   if (task != 0) {
69     WARNING("Window with invalid task id was closed");
70     return;
71   }
72
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
75   // application.
76   kill(getpid(), SIGTERM);
77 }
78 }  // namespace wm
79 }  // namespace anbox