Add initial bits of window management abstraction
This commit is contained in:
parent
2cbc3a5021
commit
7c7c8982b2
10 changed files with 245 additions and 3 deletions
|
|
@ -134,6 +134,9 @@ set(SOURCES
|
||||||
anbox/wm/task.cpp
|
anbox/wm/task.cpp
|
||||||
anbox/wm/manager.cpp
|
anbox/wm/manager.cpp
|
||||||
anbox/wm/window_state.cpp
|
anbox/wm/window_state.cpp
|
||||||
|
anbox/wm/window.cpp
|
||||||
|
anbox/wm/platform_policy.cpp
|
||||||
|
anbox/wm/default_platform_policy.cpp
|
||||||
|
|
||||||
anbox/input/manager.cpp
|
anbox/input/manager.cpp
|
||||||
anbox/input/device.cpp
|
anbox/input/device.cpp
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#include "anbox/dbus/skeleton/service.h"
|
#include "anbox/dbus/skeleton/service.h"
|
||||||
#include "anbox/container/client.h"
|
#include "anbox/container/client.h"
|
||||||
#include "anbox/wm/manager.h"
|
#include "anbox/wm/manager.h"
|
||||||
|
#include "anbox/wm/default_platform_policy.h"
|
||||||
|
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
|
|
||||||
|
|
@ -89,7 +90,8 @@ anbox::cmds::Run::Run(const BusFactory& bus_factory)
|
||||||
|
|
||||||
auto input_manager = std::make_shared<input::Manager>(rt);
|
auto input_manager = std::make_shared<input::Manager>(rt);
|
||||||
|
|
||||||
auto window_manager = std::make_shared<wm::Manager>();
|
auto policy = std::make_shared<wm::DefaultPlatformPolicy>();
|
||||||
|
auto window_manager = std::make_shared<wm::Manager>(policy);
|
||||||
|
|
||||||
auto window_creator = std::make_shared<ubuntu::WindowCreator>(input_manager);
|
auto window_creator = std::make_shared<ubuntu::WindowCreator>(input_manager);
|
||||||
auto renderer = std::make_shared<graphics::GLRendererServer>(window_creator);
|
auto renderer = std::make_shared<graphics::GLRendererServer>(window_creator);
|
||||||
|
|
|
||||||
39
src/anbox/wm/default_platform_policy.cpp
Normal file
39
src/anbox/wm/default_platform_policy.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "anbox/wm/default_platform_policy.h"
|
||||||
|
#include "anbox/wm/window.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class Window : public anbox::wm::Window {
|
||||||
|
public:
|
||||||
|
Window(const anbox::wm::WindowState &state) :
|
||||||
|
anbox::wm::Window(state) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace anbox {
|
||||||
|
namespace wm {
|
||||||
|
DefaultPlatformPolicy::DefaultPlatformPolicy() {
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Window> DefaultPlatformPolicy::create_window(const WindowState &state) {
|
||||||
|
return std::make_shared<::Window>(state);
|
||||||
|
}
|
||||||
|
} // namespace wm
|
||||||
|
} // namespace anbox
|
||||||
33
src/anbox/wm/default_platform_policy.h
Normal file
33
src/anbox/wm/default_platform_policy.h
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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_DEFAULT_PLATFORM_POLICY_H_
|
||||||
|
#define ANBOX_WM_DEFAULT_PLATFORM_POLICY_H_
|
||||||
|
|
||||||
|
#include "anbox/wm/platform_policy.h"
|
||||||
|
|
||||||
|
namespace anbox {
|
||||||
|
namespace wm {
|
||||||
|
class DefaultPlatformPolicy : public PlatformPolicy {
|
||||||
|
public:
|
||||||
|
DefaultPlatformPolicy();
|
||||||
|
std::shared_ptr<Window> create_window(const WindowState &state) override;
|
||||||
|
};
|
||||||
|
} // namespace wm
|
||||||
|
} // namespace anbox
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace wm {
|
namespace wm {
|
||||||
Manager::Manager() {
|
Manager::Manager(const std::shared_ptr<PlatformPolicy> &platform) :
|
||||||
|
platform_(platform) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::~Manager() {
|
Manager::~Manager() {
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,21 @@
|
||||||
|
|
||||||
#include "anbox/wm/window_state.h"
|
#include "anbox/wm/window_state.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace wm {
|
namespace wm {
|
||||||
|
class PlatformPolicy;
|
||||||
class Manager {
|
class Manager {
|
||||||
public:
|
public:
|
||||||
Manager();
|
Manager(const std::shared_ptr<PlatformPolicy> &platform);
|
||||||
~Manager();
|
~Manager();
|
||||||
|
|
||||||
void apply_window_state_update(const WindowState::List &updated,
|
void apply_window_state_update(const WindowState::List &updated,
|
||||||
const WindowState::List &removed);
|
const WindowState::List &removed);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::shared_ptr<PlatformPolicy> platform_;
|
||||||
};
|
};
|
||||||
} // namespace wm
|
} // namespace wm
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
|
||||||
25
src/anbox/wm/platform_policy.cpp
Normal file
25
src/anbox/wm/platform_policy.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "anbox/wm/platform_policy.h"
|
||||||
|
|
||||||
|
namespace anbox {
|
||||||
|
namespace wm {
|
||||||
|
PlatformPolicy::~PlatformPolicy() {
|
||||||
|
}
|
||||||
|
} // namespace wm
|
||||||
|
} // namespace anbox
|
||||||
38
src/anbox/wm/platform_policy.h
Normal file
38
src/anbox/wm/platform_policy.h
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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_PLATFORM_POLICY_H_
|
||||||
|
#define ANBOX_WM_PLATFORM_POLICY_H_
|
||||||
|
|
||||||
|
#include "anbox/graphics/rect.h"
|
||||||
|
#include "anbox/wm/window_state.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace anbox {
|
||||||
|
namespace wm {
|
||||||
|
class Window;
|
||||||
|
class PlatformPolicy {
|
||||||
|
public:
|
||||||
|
virtual ~PlatformPolicy();
|
||||||
|
|
||||||
|
virtual std::shared_ptr<Window> create_window(const WindowState &state) = 0;
|
||||||
|
};
|
||||||
|
} // namespace wm
|
||||||
|
} // namespace anbox
|
||||||
|
|
||||||
|
#endif
|
||||||
38
src/anbox/wm/window.cpp
Normal file
38
src/anbox/wm/window.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "anbox/wm/window.h"
|
||||||
|
|
||||||
|
namespace anbox {
|
||||||
|
namespace wm {
|
||||||
|
Window::Window(const WindowState &state) :
|
||||||
|
state_(state) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Window::~Window() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::update_state(const WindowState &state) {
|
||||||
|
state_ = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::render_layer(const Layer &layer) {
|
||||||
|
(void) layer;
|
||||||
|
}
|
||||||
|
} // namespace wm
|
||||||
|
} // namespace anbox
|
||||||
|
|
||||||
59
src/anbox/wm/window.h
Normal file
59
src/anbox/wm/window.h
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* 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 <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace anbox {
|
||||||
|
namespace wm {
|
||||||
|
// FIXME(morphis): move this somewhere else once we have the integration
|
||||||
|
// with the emugl layer.
|
||||||
|
class Layer {
|
||||||
|
public:
|
||||||
|
graphics::Rect frame() const { return frame_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
graphics::Rect frame_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Window {
|
||||||
|
public:
|
||||||
|
typedef std::vector<Window> List;
|
||||||
|
|
||||||
|
Window(const WindowState &state);
|
||||||
|
virtual ~Window();
|
||||||
|
|
||||||
|
void update_state(const WindowState &state);
|
||||||
|
|
||||||
|
// Render a layer into the window. The layer itself includes all
|
||||||
|
// necessary information for correct rendering.
|
||||||
|
void render_layer(const Layer &layer);
|
||||||
|
|
||||||
|
WindowState state() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
WindowState state_;
|
||||||
|
};
|
||||||
|
} // namespace wm
|
||||||
|
} // namespace anbox
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue