提交 960306cc 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!102 window: weixin voice cause maximize & app frame cover titlebar cause disabled

Merge pull request !102 from Night/master
......@@ -95,6 +95,13 @@ std::map<std::shared_ptr<wm::Window>, RenderableList> MultiWindowComposerStrateg
w.first->setResizing(false);
}
}
else {
std::vector<Rect> rects;
for (auto &r : final_renderables) {
rects.push_back(r.screen_position());
}
w.first->set_dis_area(rects);
}
if(!changed) {
w.second = final_renderables;
......
......@@ -59,6 +59,17 @@ class Rect {
bottom_ == rhs.bottom());
}
Rect operator&(const Rect &rhs) const {
int left = left_ > rhs.left() ? left_ : rhs.left();
int right = right_ < rhs.right() ? right_ : rhs.right();
int top = top_ > rhs.top() ? top_ : rhs.top();
int bottom = bottom_ < rhs.bottom() ? bottom_ : rhs.bottom();
if (right <= left || bottom <= top) {
return Rect(0, 0, 0, 0);
}
return Rect(left, top, right, bottom);
}
inline bool operator!=(const Rect &rhs) const { return !operator==(rhs); }
void merge(const Rect &rhs);
......
......@@ -319,7 +319,7 @@ void Platform::process_input_event(const SDL_Event &event) {
for (auto &iter : windows_) {
if (auto w = iter.second.lock()) {
if (w->window_id() == event.window.windowID &&
w->title_event_filter(event.button.y)) {
w->title_event_filter(event.button.x, event.button.y)) {
return;
}
}
......
......@@ -156,9 +156,19 @@ Window::~Window() {
if (window_) SDL_DestroyWindow(window_);
}
bool Window::title_event_filter(int point_y) {
const auto top_drag_area_height = graphics::dp_to_pixel(button_size + (button_margin << 1));
return point_y < top_drag_area_height;
bool Window::title_event_filter(int x, int y) {
std::vector<graphics::Rect> dis_area;
{
std::lock_guard<std::mutex> l(mutex_);
dis_area = dis_area_;
}
int cnt = 0;
for (auto &r : dis_area) {
if (x >= r.left() && x <= r.right() && y >= r.top() && y <= r.bottom()) {
cnt++;
}
}
return cnt == 1;
}
SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt, void *data) {
......@@ -175,7 +185,11 @@ SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt,
SDL_HitTestResult result = SDL_HITTEST_NORMAL;
if (pt->y <= top_drag_area_height) {
if (!platform_window->initialized.load()) {
INFO("window initialized by resize");
platform_window->initialized = true;
}
if (platform_window->title_event_filter(pt->x, pt->y)) {
if (!platform_window->initialized.load()) {
INFO("window initialized by click top");
platform_window->initialized = true;
......@@ -378,6 +392,22 @@ void Window::restore_window() {
SDL_RestoreWindow(window_);
}
}
void Window::set_dis_area(const std::vector<graphics::Rect> &rects) {
const auto top_drag_area_height = graphics::dp_to_pixel(button_size + (button_margin << 1));
auto title = graphics::Rect{0, 0, frame().width(), top_drag_area_height};
std::vector<graphics::Rect> dis_area;
for (auto r : rects) {
auto tmp = r & title;
if (tmp.width() > 0 && tmp.height() > 0) {
dis_area.push_back(tmp);
}
}
{
std::lock_guard<std::mutex> l(mutex_);
dis_area_.swap(dis_area);
}
}
} // namespace sdl
} // namespace platform
} // namespace anbox
......@@ -28,6 +28,7 @@
#include <memory>
#include <vector>
#include <map>
#include <mutex>
class Renderer;
......@@ -71,7 +72,7 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
bool resizable);
~Window();
bool title_event_filter(int y) override;
bool title_event_filter(int x, int y) override;
void process_event(const SDL_Event &event);
bool check_min_state() {return SDL_GetWindowFlags(window_) & SDL_WINDOW_MINIMIZED;}
......@@ -88,6 +89,7 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
inline std::uint32_t get_property() {
return visible_property;
}
void set_dis_area(const std::vector<graphics::Rect> &rects) override;
private:
static SDL_HitTestResult on_window_hit(SDL_Window *window, const SDL_Point *pt, void *data);
......@@ -107,6 +109,8 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
int last_wnd_x{ 0 };
int last_wnd_y{ 0 };
std::uint32_t visible_property;
std::vector<graphics::Rect> dis_area_;
std::mutex mutex_;
};
} // namespace sdl
} // namespace platform
......
......@@ -64,7 +64,7 @@ void Window::release() {
renderer_->destroyNativeWindow(native_handle());
}
bool Window::title_event_filter(int y) {
bool Window::title_event_filter(int x, int y) {
return false;
}
} // namespace wm
......
......@@ -55,7 +55,7 @@ class Window {
void update_frame(const graphics::Rect &frame);
void update_last_frame(const graphics::Rect &frame);
virtual bool title_event_filter(int y);
virtual bool title_event_filter(int x, int y);
void set_native_handle(const EGLNativeWindowType &handle);
EGLNativeWindowType native_handle() const;
......@@ -65,6 +65,7 @@ class Window {
std::string title() const;
virtual bool checkResizeable() { return resizing_; }
virtual void setResizing(bool resizing) { resizing_ = resizing; }
virtual void set_dis_area(const std::vector<graphics::Rect> &rects) {};
protected:
graphics::Rect last_frame_;
bool resizing_{false};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册