|
@ -0,0 +1,280 @@ |
|
|
|
|
|
--- a/src/anbox/application/database.cpp 2020-07-01 10:01:41.501731372 +0300
|
|
|
|
|
|
+++ b/src/anbox/application/database.cpp 2020-07-01 15:26:15.991751825 +0300
|
|
|
|
|
|
@@ -42,6 +42,10 @@ void Database::store_or_update(const Ite
|
|
|
|
|
|
items_[item.package].icon.clear(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
+std::string Database::set_icon(const Item &item) const {
|
|
|
|
|
|
+ return storage_->find_icon(item);
|
|
|
|
|
|
+}
|
|
|
|
|
|
+
|
|
|
|
|
|
void Database::remove(const Item &item) { |
|
|
|
|
|
auto iter = items_.find(item.package); |
|
|
|
|
|
if (iter == items_.end()) |
|
|
|
|
|
--- a/src/anbox/application/database.h 2020-07-01 10:01:46.011731377 +0300
|
|
|
|
|
|
+++ b/src/anbox/application/database.h 2020-07-01 12:17:07.385073237 +0300
|
|
|
|
|
|
@@ -48,6 +48,8 @@ class Database {
|
|
|
|
|
|
|
|
|
|
|
|
const Item& find_by_package(const std::string &package) const; |
|
|
|
|
|
|
|
|
|
|
|
+ std::string set_icon(const Item &item) const;
|
|
|
|
|
|
+
|
|
|
|
|
|
private: |
|
|
|
|
|
std::shared_ptr<LauncherStorage> storage_; |
|
|
|
|
|
std::map<std::string,Item> items_; |
|
|
|
|
|
--- a/src/anbox/application/launcher_storage.cpp 2020-07-01 10:13:25.078398779 +0300
|
|
|
|
|
|
+++ b/src/anbox/application/launcher_storage.cpp 2020-07-01 14:49:15.495082807 +0300
|
|
|
|
|
|
@@ -64,6 +64,14 @@ fs::path LauncherStorage::path_for_item_
|
|
|
|
|
|
return path_ / utils::string_format("anbox-%s.png", package_name); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
+std::string LauncherStorage::find_icon(const Database::Item &item) {
|
|
|
|
|
|
+ // TODO error handling
|
|
|
|
|
|
+ auto package_name = item.package;
|
|
|
|
|
|
+ std::replace(package_name.begin(), package_name.end(), '.', '-');
|
|
|
|
|
|
+ const auto item_icon_path = path_for_item_icon(package_name).string();
|
|
|
|
|
|
+ return item_icon_path;
|
|
|
|
|
|
+}
|
|
|
|
|
|
+
|
|
|
|
|
|
void LauncherStorage::add_or_update(const Database::Item &item) { |
|
|
|
|
|
if (!fs::exists(path_)) fs::create_directories(path_); |
|
|
|
|
|
|
|
|
|
|
|
--- a/src/anbox/application/launcher_storage.h 2020-07-01 10:13:21.398398775 +0300
|
|
|
|
|
|
+++ b/src/anbox/application/launcher_storage.h 2020-07-01 11:18:23.951736195 +0300
|
|
|
|
|
|
@@ -38,11 +38,12 @@ class LauncherStorage {
|
|
|
|
|
|
void add_or_update(const Database::Item &item); |
|
|
|
|
|
void remove(const Database::Item &item); |
|
|
|
|
|
|
|
|
|
|
|
+ std::string find_icon(const Database::Item &item);
|
|
|
|
|
|
+
|
|
|
|
|
|
private: |
|
|
|
|
|
std::string clean_package_name(const std::string &package_name); |
|
|
|
|
|
boost::filesystem::path path_for_item(const std::string &package_name); |
|
|
|
|
|
boost::filesystem::path path_for_item_icon(const std::string &package_name); |
|
|
|
|
|
-
|
|
|
|
|
|
boost::filesystem::path path_; |
|
|
|
|
|
}; |
|
|
|
|
|
} // namespace application |
|
|
|
|
|
--- a/src/anbox/wm/window.cpp 2020-07-01 09:24:37.405062354 +0300
|
|
|
|
|
|
+++ b/src/anbox/wm/window.cpp 2020-07-01 10:53:21.195067959 +0300
|
|
|
|
|
|
@@ -21,8 +21,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace anbox { |
|
|
|
|
|
namespace wm { |
|
|
|
|
|
-Window::Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title)
|
|
|
|
|
|
- : renderer_(renderer), task_(task), frame_(frame), title_(title) {}
|
|
|
|
|
|
+Window::Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title, const std::string &icon)
|
|
|
|
|
|
+ : renderer_(renderer), task_(task), frame_(frame), title_(title), icon_(icon) {}
|
|
|
|
|
|
|
|
|
|
|
|
Window::~Window() { |
|
|
|
|
|
release(); |
|
|
|
|
|
@@ -46,6 +46,8 @@ EGLNativeWindowType Window::native_handl
|
|
|
|
|
|
|
|
|
|
|
|
std::string Window::title() const { return title_; } |
|
|
|
|
|
|
|
|
|
|
|
+std::string Window::icon() const { return icon_; }
|
|
|
|
|
|
+
|
|
|
|
|
|
bool Window::attach() { |
|
|
|
|
|
if (!renderer_) |
|
|
|
|
|
return false; |
|
|
|
|
|
--- a/src/anbox/wm/window.h 2020-07-01 09:24:40.605062358 +0300
|
|
|
|
|
|
+++ b/src/anbox/wm/window.h 2020-07-01 10:36:49.868400246 +0300
|
|
|
|
|
|
@@ -45,7 +45,7 @@ class Window {
|
|
|
|
|
|
public: |
|
|
|
|
|
typedef std::vector<Window> List; |
|
|
|
|
|
|
|
|
|
|
|
- Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title);
|
|
|
|
|
|
+ Window(const std::shared_ptr<Renderer> &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title, const std::string &icon);
|
|
|
|
|
|
virtual ~Window(); |
|
|
|
|
|
|
|
|
|
|
|
bool attach(); |
|
|
|
|
|
@@ -58,12 +58,14 @@ class Window {
|
|
|
|
|
|
graphics::Rect frame() const; |
|
|
|
|
|
Task::Id task() const; |
|
|
|
|
|
std::string title() const; |
|
|
|
|
|
+ std::string icon() const;
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
std::shared_ptr<Renderer> renderer_; |
|
|
|
|
|
Task::Id task_; |
|
|
|
|
|
graphics::Rect frame_; |
|
|
|
|
|
std::string title_; |
|
|
|
|
|
+ std::string icon_;
|
|
|
|
|
|
bool attached_ = false; |
|
|
|
|
|
}; |
|
|
|
|
|
} // namespace wm |
|
|
|
|
|
--- a/src/anbox/platform/sdl/window.cpp 2020-07-01 10:39:21.251733736 +0300
|
|
|
|
|
|
+++ b/src/anbox/platform/sdl/window.cpp 2020-07-01 18:03:19.775094384 +0300
|
|
|
|
|
|
@@ -20,6 +20,8 @@
|
|
|
|
|
|
#include "anbox/graphics/density.h" |
|
|
|
|
|
#include "anbox/logger.h" |
|
|
|
|
|
|
|
|
|
|
|
+#include <SDL2/SDL_image.h>
|
|
|
|
|
|
+
|
|
|
|
|
|
#include <boost/throw_exception.hpp> |
|
|
|
|
|
|
|
|
|
|
|
#if defined(MIR_SUPPORT) |
|
|
|
|
|
@@ -46,9 +48,10 @@ Window::Window(const std::shared_ptr<Ren
|
|
|
|
|
|
const std::shared_ptr<Observer> &observer, |
|
|
|
|
|
const graphics::Rect &frame, |
|
|
|
|
|
const std::string &title, |
|
|
|
|
|
+ const std::string &icon,
|
|
|
|
|
|
bool resizable, |
|
|
|
|
|
bool borderless) |
|
|
|
|
|
- : wm::Window(renderer, task, frame, title),
|
|
|
|
|
|
+ : wm::Window(renderer, task, frame, title, icon),
|
|
|
|
|
|
id_(id), |
|
|
|
|
|
observer_(observer), |
|
|
|
|
|
native_display_(0), |
|
|
|
|
|
@@ -70,11 +73,18 @@ Window::Window(const std::shared_ptr<Ren
|
|
|
|
|
|
frame.left(), frame.top(), |
|
|
|
|
|
frame.width(), frame.height(), |
|
|
|
|
|
flags); |
|
|
|
|
|
+
|
|
|
|
|
|
if (!window_) { |
|
|
|
|
|
const auto message = utils::string_format("Failed to create window: %s", SDL_GetError()); |
|
|
|
|
|
BOOST_THROW_EXCEPTION(std::runtime_error(message)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
+ icon_ = IMG_Load(icon.c_str());
|
|
|
|
|
|
+ if (icon_ != NULL) {
|
|
|
|
|
|
+ SDL_SetWindowIcon(window_, icon_);
|
|
|
|
|
|
+ SDL_FreeSurface(icon_);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
|
|
|
// If we create a window with border (server-side decoration), We |
|
|
|
|
|
// should not set hit test handler beacuse we don't need to simulate |
|
|
|
|
|
// the behavior of the title bar and resize area. |
|
|
|
|
|
@@ -112,6 +122,7 @@ Window::Window(const std::shared_ptr<Ren
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SDL_ShowWindow(window_); |
|
|
|
|
|
+
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Window::~Window() { |
|
|
|
|
|
--- a/src/anbox/platform/sdl/window.h 2020-07-01 10:39:21.251733736 +0300
|
|
|
|
|
|
+++ b/src/anbox/platform/sdl/window.h 2020-07-01 17:42:38.021759755 +0300
|
|
|
|
|
|
@@ -53,6 +53,7 @@ class Window : public std::enable_shared
|
|
|
|
|
|
const std::shared_ptr<Observer> &observer, |
|
|
|
|
|
const graphics::Rect &frame, |
|
|
|
|
|
const std::string &title, |
|
|
|
|
|
+ const std::string &icon,
|
|
|
|
|
|
bool resizable, |
|
|
|
|
|
bool borderless); |
|
|
|
|
|
~Window(); |
|
|
|
|
|
@@ -74,6 +75,7 @@ class Window : public std::enable_shared
|
|
|
|
|
|
EGLNativeDisplayType native_display_; |
|
|
|
|
|
EGLNativeWindowType native_window_; |
|
|
|
|
|
SDL_Window *window_; |
|
|
|
|
|
+ SDL_Surface *icon_;
|
|
|
|
|
|
}; |
|
|
|
|
|
} // namespace sdl |
|
|
|
|
|
} // namespace platform |
|
|
|
|
|
--- a/src/anbox/platform/sdl/platform.cpp 2020-07-01 11:58:53.388405411 +0300
|
|
|
|
|
|
+++ b/src/anbox/platform/sdl/platform.cpp 2020-07-01 17:42:07.345093053 +0300
|
|
|
|
|
|
@@ -411,14 +411,14 @@ Window::Id Platform::next_window_id() {
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<wm::Window> Platform::create_window( |
|
|
|
|
|
- const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) {
|
|
|
|
|
|
+ const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title, const std::string &icon) {
|
|
|
|
|
|
if (!renderer_) { |
|
|
|
|
|
ERROR("Can't create window without a renderer set"); |
|
|
|
|
|
return nullptr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto id = next_window_id(); |
|
|
|
|
|
- auto w = std::make_shared<Window>(renderer_, id, task, shared_from_this(), frame, title,
|
|
|
|
|
|
+ auto w = std::make_shared<Window>(renderer_, id, task, shared_from_this(), frame, title, icon,
|
|
|
|
|
|
!window_size_immutable_, !config_.server_side_decoration); |
|
|
|
|
|
focused_sdl_window_id_ = w->window_id(); |
|
|
|
|
|
windows_.insert({id, w}); |
|
|
|
|
|
--- a/src/anbox/platform/sdl/platform.h 2020-07-01 11:40:48.875070925 +0300
|
|
|
|
|
|
+++ b/src/anbox/platform/sdl/platform.h 2020-07-01 17:42:20.438426402 +0300
|
|
|
|
|
|
@@ -50,7 +50,8 @@ class Platform : public std::enable_shar
|
|
|
|
|
|
std::shared_ptr<wm::Window> create_window( |
|
|
|
|
|
const anbox::wm::Task::Id &task, |
|
|
|
|
|
const anbox::graphics::Rect &frame, |
|
|
|
|
|
- const std::string &title) override;
|
|
|
|
|
|
+ const std::string &title,
|
|
|
|
|
|
+ const std::string &icon) override;
|
|
|
|
|
|
|
|
|
|
|
|
void window_deleted(const Window::Id &id) override; |
|
|
|
|
|
void window_wants_focus(const Window::Id &id) override; |
|
|
|
|
|
--- a/src/anbox/platform/null/platform.cpp 2020-07-01 11:20:17.578402976 +0300
|
|
|
|
|
|
+++ b/src/anbox/platform/null/platform.cpp 2020-07-01 11:23:09.188403157 +0300
|
|
|
|
|
|
@@ -24,8 +24,10 @@ class NullWindow : public anbox::wm::Win
|
|
|
|
|
|
public: |
|
|
|
|
|
NullWindow(const anbox::wm::Task::Id &task, |
|
|
|
|
|
const anbox::graphics::Rect &frame, |
|
|
|
|
|
- const std::string &title)
|
|
|
|
|
|
- : anbox::wm::Window(nullptr, task, frame, title) {}
|
|
|
|
|
|
+ const std::string &title,
|
|
|
|
|
|
+ const std::string &icon
|
|
|
|
|
|
+ )
|
|
|
|
|
|
+ : anbox::wm::Window(nullptr, task, frame, title, icon) {}
|
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@@ -34,8 +36,8 @@ namespace platform {
|
|
|
|
|
|
NullPlatform::NullPlatform() {} |
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<wm::Window> NullPlatform::create_window( |
|
|
|
|
|
- const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) {
|
|
|
|
|
|
- return std::make_shared<::NullWindow>(task, frame, title);
|
|
|
|
|
|
+ const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title, const std::string &icon) {
|
|
|
|
|
|
+ return std::make_shared<::NullWindow>(task, frame, title, icon);
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NullPlatform::set_clipboard_data(const ClipboardData &data) { |
|
|
|
|
|
--- a/src/anbox/platform/null/platform.h 2020-07-01 11:24:27.591736574 +0300
|
|
|
|
|
|
+++ b/src/anbox/platform/null/platform.h 2020-07-01 11:24:49.625069928 +0300
|
|
|
|
|
|
@@ -28,7 +28,8 @@ class NullPlatform : public BasePlatform
|
|
|
|
|
|
std::shared_ptr<wm::Window> create_window( |
|
|
|
|
|
const anbox::wm::Task::Id &task, |
|
|
|
|
|
const anbox::graphics::Rect &frame, |
|
|
|
|
|
- const std::string &title) override;
|
|
|
|
|
|
+ const std::string &title,
|
|
|
|
|
|
+ const std::string &icon) override;
|
|
|
|
|
|
void set_clipboard_data(const ClipboardData &data) override; |
|
|
|
|
|
ClipboardData get_clipboard_data() override; |
|
|
|
|
|
std::shared_ptr<audio::Sink> create_audio_sink(const std::shared_ptr<network::LocalSocketMessenger> &messenger) override; |
|
|
|
|
|
--- a/src/anbox/platform/base_platform.h 2020-07-01 11:35:58.168403951 +0300
|
|
|
|
|
|
+++ b/src/anbox/platform/base_platform.h 2020-07-01 11:36:17.055070636 +0300
|
|
|
|
|
|
@@ -43,7 +43,7 @@ class BasePlatform {
|
|
|
|
|
|
public: |
|
|
|
|
|
virtual ~BasePlatform() {} |
|
|
|
|
|
|
|
|
|
|
|
- virtual std::shared_ptr<wm::Window> create_window(const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) = 0;
|
|
|
|
|
|
+ virtual std::shared_ptr<wm::Window> create_window(const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title, const std::string &icon) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
struct ClipboardData { |
|
|
|
|
|
std::string text; |
|
|
|
|
|
--- a/src/anbox/wm/single_window_manager.cpp 2020-07-01 11:43:18.281737753 +0300
|
|
|
|
|
|
+++ b/src/anbox/wm/single_window_manager.cpp 2020-07-01 11:43:31.661737769 +0300
|
|
|
|
|
|
@@ -35,7 +35,7 @@ SingleWindowManager::~SingleWindowManage
|
|
|
|
|
|
|
|
|
|
|
|
void SingleWindowManager::setup() { |
|
|
|
|
|
if (auto p = platform_.lock()) { |
|
|
|
|
|
- window_ = p->create_window(0, window_size_, "Anbox - Android in a Box");
|
|
|
|
|
|
+ window_ = p->create_window(0, window_size_, "Anbox - Android in a Box", "");
|
|
|
|
|
|
if (!window_->attach()) |
|
|
|
|
|
WARNING("Failed to attach window to renderer"); |
|
|
|
|
|
} else { |
|
|
|
|
|
--- a/src/anbox/wm/multi_window_manager.cpp 2020-07-01 09:57:23.678397769 +0300
|
|
|
|
|
|
+++ b/src/anbox/wm/multi_window_manager.cpp 2020-07-01 16:14:42.061754884 +0300
|
|
|
|
|
|
@@ -64,11 +64,12 @@ void MultiWindowManager::apply_window_st
|
|
|
|
|
|
|
|
|
|
|
|
auto title = window.package_name(); |
|
|
|
|
|
auto app = app_db_->find_by_package(window.package_name()); |
|
|
|
|
|
+ auto icon = app_db_->set_icon(app);
|
|
|
|
|
|
if (app.valid()) |
|
|
|
|
|
title = app.name; |
|
|
|
|
|
|
|
|
|
|
|
if (auto p = platform_.lock()) { |
|
|
|
|
|
- auto w = p->create_window(window.task(), window.frame(), title);
|
|
|
|
|
|
+ auto w = p->create_window(window.task(), window.frame(), title, icon);
|
|
|
|
|
|
if (w) { |
|
|
|
|
|
w->attach(); |
|
|
|
|
|
windows_.insert({window.task(), w}); |