0fc948b9df4ec36c855274c429cb20f1700cab63
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / wm / window.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/window.h"
19 #include "anbox/graphics/emugl/Renderer.h"
20 #include "anbox/logger.h"
21
22 namespace anbox {
23 namespace wm {
24 Window::Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title)
25     : renderer_(renderer), task_(task), frame_(frame), title_(title) {}
26
27 Window::~Window() {
28   release();
29 }
30
31 void Window::update_state(const WindowState::List &states) {
32   (void)states;
33 }
34
35 void Window::update_frame(const graphics::Rect &frame) {
36   if (frame == frame_) return;
37
38   frame_ = frame;
39 }
40
41 Task::Id Window::task() const { return task_; }
42
43 graphics::Rect Window::frame() const { return frame_; }
44
45 EGLNativeWindowType Window::native_handle() const { return 0; }
46
47 std::string Window::title() const { return title_; }
48
49 bool Window::attach() {
50   if (!renderer_)
51     return false;
52   attached_ = renderer_->createNativeWindow(native_handle());
53   return attached_;
54 }
55
56 void Window::release() {
57   if (!renderer_ || !attached_)
58     return;
59   renderer_->destroyNativeWindow(native_handle());
60 }
61 }  // namespace wm
62 }  // namespace anbox