提交 83b161d5 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!14 Pull Request

Merge pull request !14 from Night/master
......@@ -152,7 +152,7 @@ if (SNAP_CONFINEMENT)
endif()
install(FILES data/ui/loading-screen.png DESTINATION ${ANBOX_RESOURCE_DIR}/ui)
install(FILES data/ui/kpandroid.png DESTINATION ${ANBOX_RESOURCE_DIR}/ui)
install(FILES data/ui/logo.png DESTINATION ${ANBOX_RESOURCE_DIR}/ui)
install(PROGRAMS scripts/anbox-bridge.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
install(PROGRAMS scripts/anbox-launch.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
......
......@@ -78,7 +78,7 @@ Window::Window(const std::shared_ptr<Renderer> &renderer,
if (SDL_SetWindowHitTest(window_, &Window::on_window_hit, this) < 0)
BOOST_THROW_EXCEPTION(std::runtime_error("Failed to register for window hit test"));
std::string strPath = SystemConfiguration::instance().resource_dir() + "/ui/kpandroid.png";
std::string strPath = SystemConfiguration::instance().resource_dir() + "/ui/logo.png";
SDL_Surface *icon = IMG_Load(strPath.c_str());
SDL_SetWindowIcon(window_, icon);
......@@ -114,7 +114,8 @@ Window::Window(const std::shared_ptr<Renderer> &renderer,
struct timeval now = (struct timeval) { 0 };
gettimeofday(&now, NULL);
lastClickTime = USEC_PER_SEC * (now.tv_sec) + now.tv_usec;
last_update_time = USEC_PER_SEC * (now.tv_sec) + now.tv_usec;
lastClickTime = last_update_time;
SDL_ShowWindow(window_);
}
......@@ -157,10 +158,19 @@ SDL_HitTestResult Window::on_window_hit(SDL_Window *window, const SDL_Point *pt,
else
break;
if (!platform_window->initialized.load()) {
INFO("window initialized by resize");
platform_window->initialized = true;
}
return result;
}
if (pt->y < top_drag_area_height) {
if (!platform_window->initialized.load()) {
INFO("window initialized by click top");
platform_window->initialized = true;
}
if (pt->x > 0 && pt->x < button_area_width) {
std::shared_ptr<anbox::platform::sdl::Window::Observer> observer_temp = platform_window->observer_;
if (observer_temp) {
......@@ -270,6 +280,48 @@ EGLNativeWindowType Window::native_handle() const { return native_window_; }
Window::Id Window::id() const { return id_; }
std::uint32_t Window::window_id() const { return SDL_GetWindowID(window_); }
void Window::update_state(const wm::WindowState::List &states) {
if (!initialized.load() && !states.empty()) {
int w = 0;
int h = 0;
int x = 0;
int y = 0;
SDL_GetWindowSize(window_, &w, &h);
SDL_GetWindowPosition(window_, &x, &y);
graphics::Rect rect;
int area = w * h;
for (auto ws : states)
{
int temp = ws.frame().width() * ws.frame().height();
if (temp >= area) {
rect = ws.frame();
}
}
if (w == rect.width() &&
h == rect.height() &&
x == rect.left() &&
y == rect.top()) {
return;
}
struct timeval now = (struct timeval) { 0 };
gettimeofday(&now, NULL);
long long current_time = USEC_PER_SEC * (now.tv_sec) + now.tv_usec;
if (current_time - last_update_time >= APP_START_MAX_TIME) {
INFO("window initialized by timeout");
initialized = true;
return;
}
last_update_time = current_time;
SDL_SetWindowSize(window_, rect.width(), rect.height());
SDL_SetWindowPosition(window_, rect.left(), rect.top());
update_frame(rect);
}
}
} // namespace sdl
} // namespace platform
} // namespace anbox
......@@ -70,6 +70,8 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
void process_event(const SDL_Event &event);
bool check_min_state() {return SDL_GetWindowFlags(window_) & SDL_WINDOW_MINIMIZED;}
void update_state(const wm::WindowState::List &states) override;
bool check_db_clicked(int x, int y);
EGLNativeWindowType native_handle() const override;
......@@ -82,6 +84,8 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
void close();
void switch_window_state();
std::atomic<bool> initialized{false};
long long last_update_time{ 0 };
Id id_;
std::shared_ptr<Observer> observer_;
EGLNativeDisplayType native_display_;
......
......@@ -51,7 +51,7 @@ class Window {
bool attach();
void release();
void update_state(const WindowState::List &states);
virtual void update_state(const WindowState::List &states);
void update_frame(const graphics::Rect &frame);
virtual EGLNativeWindowType native_handle() const;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册