diff --git a/README.md b/README.md index 83aaa18..fbba447 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,10 @@ Place into `/usr/local/bin/` folder and set as executable (`chmod +x - Details: Some Android applications such as [NewPipe](https://github.com/TeamNewPipe/NewPipe) require `SDL_WINDOWEVENT_RESTORED` handling so that application window contents are correctly rendered after minimize/maximize operations. +- [patch_window-icons.patch](anbox_files/patch_window-icons.patch) + + - Details: Set SDL window icon property for each application window by using application specific PNG icons. Adds value for `_NET_WM_ICON` property in X11 environment (`xprop` command). + ## Android OS files Subdirectory [androidOS_files](androidOS_files). Contains Android OS image file build instructions and additional patches. You find patched Android image along with additional information and possible other images on [https://fjordtek.com/public/applications/anbox/images/](https://fjordtek.com/public/applications/anbox/images/). diff --git a/anbox_files/PKGBUILD b/anbox_files/PKGBUILD index cbdb2b4..2fa6aae 100644 --- a/anbox_files/PKGBUILD +++ b/anbox_files/PKGBUILD @@ -28,6 +28,7 @@ source=("git+https://github.com/anbox/anbox.git" 'patch_bytesize-to-bytesizelong.patch' 'patch_remove-unknown-opt.patch' 'patch_window-restored.patch' + 'patch_window-icons.patch' ) sha256sums=('SKIP' 'SKIP' @@ -45,7 +46,8 @@ sha256sums=('SKIP' '7430e889f1a882b7393896baaaf1a22650d770ed810182def364fde9d8682223' 'bf751d44500c3689a3fd56c757d59632441bee78d1857bef84319f38da1a33ba' 'b96eedc64972c671a57052c53760b60aac00e95c80a7020818582957d247558f' - '926e13e113baf307cc1556e11e0b621e5fae455f9a02eb3cc0a75c6584dd27a2') + '926e13e113baf307cc1556e11e0b621e5fae455f9a02eb3cc0a75c6584dd27a2' + 'ccea9d574da7861a9a1978e6dec2f8d47ef751acde874fd75f041076ae8cce58') pkgver() { cd "$srcdir/$_pkgname" diff --git a/anbox_files/patch_window-icons.patch b/anbox_files/patch_window-icons.patch new file mode 100644 index 0000000..9f40d5d --- /dev/null +++ b/anbox_files/patch_window-icons.patch @@ -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 storage_; + std::map 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, 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, 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 List; + +- Window(const std::shared_ptr &renderer, const Task::Id &task, const graphics::Rect &frame, const std::string &title); ++ Window(const std::shared_ptr &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_; + 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 ++ + #include + + #if defined(MIR_SUPPORT) +@@ -46,9 +48,10 @@ Window::Window(const std::shared_ptr &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 &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 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(renderer_, id, task, shared_from_this(), frame, title, ++ auto w = std::make_shared(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 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 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 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 create_audio_sink(const std::shared_ptr &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 create_window(const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) = 0; ++ virtual std::shared_ptr 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});