TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / platform / sdl / window.h
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 #ifndef ANBOX_PLATFORM_SDL_WINDOW_H_
19 #define ANBOX_PLATFORM_SDL_WINDOW_H_
20
21 #include "anbox/wm/window.h"
22 #include "anbox/platform/sdl/sdl_wrapper.h"
23
24 #include <EGL/egl.h>
25
26 #include <memory>
27 #include <vector>
28
29 class Renderer;
30
31 namespace anbox {
32 namespace platform {
33 namespace sdl {
34 class Window : public std::enable_shared_from_this<Window>, public wm::Window {
35  public:
36   typedef std::int32_t Id;
37   static Id Invalid;
38
39   class Observer {
40    public:
41     virtual ~Observer();
42     virtual void window_deleted(const Id &id) = 0;
43     virtual void window_wants_focus(const Id &id) = 0;
44     virtual void window_moved(const Id &id, const std::int32_t &x,
45                               const std::int32_t &y) = 0;
46     virtual void window_resized(const Id &id, const std::int32_t &x,
47                                 const std::int32_t &y) = 0;
48   };
49
50   Window(const std::shared_ptr<Renderer> &renderer,
51          const Id &id, const wm::Task::Id &task,
52          const std::shared_ptr<Observer> &observer,
53          const graphics::Rect &frame,
54          const std::string &title,
55          bool resizable,
56          bool borderless);
57   ~Window();
58
59   void process_event(const SDL_Event &event);
60
61   EGLNativeWindowType native_handle() const override;
62   Id id() const;
63   std::uint32_t window_id() const;
64
65  private:
66   static SDL_HitTestResult on_window_hit(SDL_Window *window, const SDL_Point *pt, void *data);
67
68   void close();
69   void switch_window_state();
70
71   Id id_;
72   std::shared_ptr<Observer> observer_;
73   EGLNativeDisplayType native_display_;
74   EGLNativeWindowType native_window_;
75   SDL_Window *window_;
76 };
77 } // namespace sdl
78 } // namespace platform
79 } // namespace anbox
80
81 #endif