提交 da5fda98 编写于 作者: N night_xiaoye

window: solve problem: continuously maximize window will crash some app, such as qqmusic...

continuously maximize window will crash some app, such as qqmusic...
上级 0266eaa4
......@@ -298,6 +298,14 @@ void Platform::process_input_event(const SDL_Event &event) {
switch (event.type) {
// Mouse
case SDL_MOUSEBUTTONDOWN:
for (auto &iter : windows_) {
if (auto w = iter.second.lock()) {
if (w->window_id() == event.window.windowID &&
w->title_event_filter(event.button.y)) {
return;
}
}
}
if (config_.no_touch_emulation) {
mouse_events.push_back({EV_KEY, BTN_LEFT, 1});
} else {
......
......@@ -131,6 +131,11 @@ 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;
}
SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt, void *data) {
auto platform_window = reinterpret_cast<Window*>(data);
......
......@@ -72,6 +72,7 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
bool resizable);
~Window();
bool title_event_filter(int y) override;
void process_event(const SDL_Event &event);
bool check_min_state() {return SDL_GetWindowFlags(window_) & SDL_WINDOW_MINIMIZED;}
......
......@@ -58,5 +58,9 @@ void Window::release() {
return;
renderer_->destroyNativeWindow(native_handle());
}
bool Window::title_event_filter(int y) {
return false;
}
} // namespace wm
} // namespace anbox
......@@ -55,6 +55,7 @@ class Window {
void update_frame(const graphics::Rect &frame);
virtual EGLNativeWindowType native_handle() const;
virtual bool title_event_filter(int y);
graphics::Rect frame() const;
Task::Id task() const;
std::string title() const;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册