提交 db05591b 编写于 作者: T twwang 提交者: night_xiaoye

window: add fullscreen on anbox side.

Add fullscreen on anbox side.
上级 c7ca9981
...@@ -64,6 +64,7 @@ void PlatformApiStub::update_window_state(const WindowStateUpdate &state) { ...@@ -64,6 +64,7 @@ void PlatformApiStub::update_window_state(const WindowStateUpdate &state) {
out->set_frame_bottom(in.frame.bottom); out->set_frame_bottom(in.frame.bottom);
out->set_task_id(in.task_id); out->set_task_id(in.task_id);
out->set_stack_id(in.stack_id); out->set_stack_id(in.stack_id);
out->set_videofullscreen(false);
}; };
for (const auto &window : state.updated_windows) { for (const auto &window : state.updated_windows) {
......
...@@ -84,7 +84,8 @@ void PlatformApiSkeleton::handle_window_state_update_event(const anbox::protobuf ...@@ -84,7 +84,8 @@ void PlatformApiSkeleton::handle_window_state_update_event(const anbox::protobuf
graphics::Rect(window.frame_left(), window.frame_top(), graphics::Rect(window.frame_left(), window.frame_top(),
window.frame_right(), window.frame_bottom()), window.frame_right(), window.frame_bottom()),
window.package_name(), wm::Task::Id(window.task_id()), window.package_name(), wm::Task::Id(window.task_id()),
wm::Stack::Id(window.stack_id())); wm::Stack::Id(window.stack_id()),
window.has_videofullscreen() && window.videofullscreen());
}; };
wm::WindowState::List updated; wm::WindowState::List updated;
......
...@@ -157,6 +157,9 @@ Window::~Window() { ...@@ -157,6 +157,9 @@ Window::~Window() {
} }
bool Window::title_event_filter(int x, int y) { bool Window::title_event_filter(int x, int y) {
if (fullscreen_) {
return false;
}
std::vector<graphics::Rect> dis_area; std::vector<graphics::Rect> dis_area;
{ {
std::lock_guard<std::mutex> l(mutex_); std::lock_guard<std::mutex> l(mutex_);
...@@ -174,6 +177,10 @@ bool Window::title_event_filter(int x, int y) { ...@@ -174,6 +177,10 @@ bool Window::title_event_filter(int x, int y) {
SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt, void *data) { SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt, void *data) {
auto platform_window = reinterpret_cast<Window*>(data); auto platform_window = reinterpret_cast<Window*>(data);
if (platform_window->get_fullscreen()) {
return SDL_HITTEST_NORMAL;
}
int w = 0, h = 0; int w = 0, h = 0;
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
...@@ -344,6 +351,19 @@ void Window::setResizing(bool resizing) { ...@@ -344,6 +351,19 @@ void Window::setResizing(bool resizing) {
} }
void Window::update_state(const wm::WindowState::List &states) { void Window::update_state(const wm::WindowState::List &states) {
for (auto ws : states)
{
if (!fullscreen_ && ws.videofullscreen()) {
SDL_SetWindowFullscreen(window_, SDL_WINDOW_FULLSCREEN_DESKTOP);
fullscreen_ = true;
} else if (fullscreen_ && !ws.videofullscreen()) {
SDL_SetWindowFullscreen(window_, 0);
fullscreen_ = false;
}
if (fullscreen_) {
return;
}
}
if (!initialized.load() && !states.empty()) { if (!initialized.load() && !states.empty()) {
int w = 0; int w = 0;
int h = 0; int h = 0;
......
...@@ -83,6 +83,7 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window { ...@@ -83,6 +83,7 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
void setResizing(bool resizing) override; void setResizing(bool resizing) override;
void restore_window(); void restore_window();
bool get_fullscreen() { return fullscreen_; }
Id id() const; Id id() const;
std::uint32_t window_id() const; std::uint32_t window_id() const;
Uint32 GetWindowFlags(){return SDL_GetWindowFlags(window_);} Uint32 GetWindowFlags(){return SDL_GetWindowFlags(window_);}
...@@ -111,6 +112,7 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window { ...@@ -111,6 +112,7 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
std::uint32_t visible_property; std::uint32_t visible_property;
std::vector<graphics::Rect> dis_area_; std::vector<graphics::Rect> dis_area_;
std::mutex mutex_; std::mutex mutex_;
bool fullscreen_ = false;
}; };
} // namespace sdl } // namespace sdl
} // namespace platform } // namespace platform
......
...@@ -78,6 +78,7 @@ message WindowStateUpdateEvent { ...@@ -78,6 +78,7 @@ message WindowStateUpdateEvent {
required int32 frame_bottom = 7; required int32 frame_bottom = 7;
required int32 task_id = 8; required int32 task_id = 8;
required int32 stack_id = 9; required int32 stack_id = 9;
required bool videoFullscreen = 10;
} }
repeated WindowState windows = 1; repeated WindowState windows = 1;
repeated WindowState removed_windows = 2; repeated WindowState removed_windows = 2;
......
...@@ -44,7 +44,7 @@ void MultiWindowManager::apply_window_state_update(const WindowState::List &upda ...@@ -44,7 +44,7 @@ void MultiWindowManager::apply_window_state_update(const WindowState::List &upda
for (const auto &window : updated) { for (const auto &window : updated) {
// Ignore all windows which are not part of the freeform task stack // Ignore all windows which are not part of the freeform task stack
if (window.stack() != Stack::Id::Freeform) continue; if (window.stack() != Stack::Id::Freeform && window.stack() != Stack::Id::Fullscreen) continue;
// And also those which don't have a surface mapped at the moment // And also those which don't have a surface mapped at the moment
if (!window.has_surface()) continue; if (!window.has_surface()) continue;
......
...@@ -30,13 +30,15 @@ WindowState::WindowState() ...@@ -30,13 +30,15 @@ WindowState::WindowState()
WindowState::WindowState(const Display::Id &display, bool has_surface, WindowState::WindowState(const Display::Id &display, bool has_surface,
const graphics::Rect &frame, const graphics::Rect &frame,
const std::string &package_name, const Task::Id &task, const std::string &package_name, const Task::Id &task,
const Stack::Id &stack) const Stack::Id &stack,
const bool videofullscreen)
: display_(display), : display_(display),
has_surface_(has_surface), has_surface_(has_surface),
frame_(frame), frame_(frame),
package_name_(package_name), package_name_(package_name),
task_(task), task_(task),
stack_(stack) {} stack_(stack),
videofullscreen_(videofullscreen) {}
WindowState::~WindowState() {} WindowState::~WindowState() {}
} // namespace wm } // namespace wm
......
...@@ -35,11 +35,12 @@ class WindowState { ...@@ -35,11 +35,12 @@ class WindowState {
WindowState(); WindowState();
WindowState(const Display::Id &display, bool has_surface, WindowState(const Display::Id &display, bool has_surface,
const graphics::Rect &frame, const std::string &package_name, const graphics::Rect &frame, const std::string &package_name,
const Task::Id &task, const Stack::Id &stack); const Task::Id &task, const Stack::Id &stack, const bool videofullscreen = false);
~WindowState(); ~WindowState();
Display::Id display() const { return display_; } Display::Id display() const { return display_; }
bool has_surface() const { return has_surface_; } bool has_surface() const { return has_surface_; }
bool videofullscreen() const { return videofullscreen_; }
graphics::Rect frame() const { return frame_; } graphics::Rect frame() const { return frame_; }
std::string package_name() const { return package_name_; } std::string package_name() const { return package_name_; }
Task::Id task() const { return task_; } Task::Id task() const { return task_; }
...@@ -52,6 +53,7 @@ class WindowState { ...@@ -52,6 +53,7 @@ class WindowState {
std::string package_name_; std::string package_name_;
Task::Id task_; Task::Id task_;
Stack::Id stack_; Stack::Id stack_;
bool videofullscreen_;
}; };
} // namespace wm } // namespace wm
} // namespace anbox } // namespace anbox
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册