window.h 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3, as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef ANBOX_WM_WINDOW_H_
#define ANBOX_WM_WINDOW_H_

#include "anbox/wm/window_state.h"

#include <string>
24
#include <vector>
25

26 27
#include <EGL/egl.h>

S
Simon Fels 已提交
28 29 30 31
#include <memory>

class Renderer;

32 33 34 35 36
namespace anbox {
namespace wm {
// FIXME(morphis): move this somewhere else once we have the integration
// with the emugl layer.
class Layer {
37 38
 public:
  graphics::Rect frame() const { return frame_; }
39

40 41
 private:
  graphics::Rect frame_;
42 43
};

44 45 46
class Window {
 public:
  typedef std::vector<Window> List;
47

48
  Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title);
49
  virtual ~Window();
50

51 52
  bool attach();
  void release();
53

54
  virtual void update_state(const WindowState::List &states);
55
  void update_frame(const graphics::Rect &frame);
56
  void update_last_frame(const graphics::Rect &frame);
57

58
  virtual bool title_event_filter(int x, int y);
59 60 61
  void set_native_handle(const EGLNativeWindowType &handle);
  EGLNativeWindowType native_handle() const;

62
  graphics::Rect frame() const;
63
  graphics::Rect last_frame() const;
64
  Task::Id task() const;
65
  std::string title() const;
66 67 68 69 70
  virtual bool checkResizeable() { return resizing_; }
  virtual void setResizing(bool resizing) { resizing_ = resizing; }
 protected:
  graphics::Rect last_frame_;
  bool resizing_{false};
71
 private:
72
  EGLNativeWindowType native_window_;
S
Simon Fels 已提交
73
  std::shared_ptr<Renderer> renderer_;
74 75
  Task::Id task_;
  graphics::Rect frame_;
76
  std::string title_;
77
  bool attached_ = false;
78
};
79 80
}  // namespace wm
}  // namespace anbox
81 82

#endif