From ef588d4cb60daef7fb165e827e3552a0858932a8 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 22 Jun 2018 18:52:45 +0900 Subject: Rename struct name App to WindowManager Change-Id: I9c1ac771f0fb2336c23b68a4c98fd1cd07e3d51a Signed-off-by: Kazumasa Mitsunari --- src/controller_hooks.hpp | 4 +- src/main.cpp | 60 +++++++++++++-------------- src/window_manager.cpp | 106 +++++++++++++++++++++++------------------------ src/window_manager.hpp | 14 +++---- 4 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/controller_hooks.hpp b/src/controller_hooks.hpp index b8c142c..8e6558a 100644 --- a/src/controller_hooks.hpp +++ b/src/controller_hooks.hpp @@ -24,11 +24,11 @@ namespace wm { -struct App; +struct WindowManager; struct controller_hooks { - struct App *app; + struct WindowManager *app; void surface_created(uint32_t surface_id); diff --git a/src/main.cpp b/src/main.cpp index feb2124..85abf24 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,9 +43,9 @@ typedef struct WMClientCtxt struct afb_instance { std::unique_ptr display; - wm::App app; + wm::WindowManager wmgr; - afb_instance() : display{new wl::display}, app{this->display.get()} {} + afb_instance() : display{new wl::display}, wmgr{this->display.get()} {} int init(); }; @@ -55,7 +55,7 @@ std::mutex binding_m; int afb_instance::init() { - return this->app.init(); + return this->wmgr.init(); } int display_event_callback(sd_event_source *evs, int /*fd*/, uint32_t events, @@ -75,8 +75,8 @@ int display_event_callback(sd_event_source *evs, int /*fd*/, uint32_t events, { { STN(display_read_events); - g_afb_instance->app.display->read_events(); - g_afb_instance->app.set_pending_events(); + g_afb_instance->wmgr.display->read_events(); + g_afb_instance->wmgr.set_pending_events(); } { // We want do dispatch pending wayland events from within @@ -191,11 +191,11 @@ static void cbRemoveClientCtxt(void *data) } HMI_DEBUG("wm", "remove app %s", ctxt->name.c_str()); // Lookup surfaceID and remove it because App is dead. - auto pSid = g_afb_instance->app.id_alloc.lookup(ctxt->role.c_str()); + auto pSid = g_afb_instance->wmgr.id_alloc.lookup(ctxt->role.c_str()); if (pSid) { auto sid = *pSid; - auto o_state = *g_afb_instance->app.layers.get_layout_state(sid); + auto o_state = *g_afb_instance->wmgr.layers.get_layout_state(sid); if (o_state != nullptr) { if (o_state->main == sid) @@ -207,13 +207,13 @@ static void cbRemoveClientCtxt(void *data) o_state->sub = -1; } } - g_afb_instance->app.id_alloc.remove_id(sid); - g_afb_instance->app.layers.remove_surface(sid); - g_afb_instance->app.controller->sprops.erase(sid); - g_afb_instance->app.controller->surfaces.erase(sid); + g_afb_instance->wmgr.id_alloc.remove_id(sid); + g_afb_instance->wmgr.layers.remove_surface(sid); + g_afb_instance->wmgr.controller->sprops.erase(sid); + g_afb_instance->wmgr.controller->surfaces.erase(sid); HMI_DEBUG("wm", "delete surfaceID %d", sid); } - g_afb_instance->app.removeClient(ctxt->name); + g_afb_instance->wmgr.removeClient(ctxt->name); delete ctxt; } @@ -252,7 +252,7 @@ void windowmanager_requestsurface(afb_req req) noexcept } } - auto ret = g_afb_instance->app.api_request_surface( + auto ret = g_afb_instance->wmgr.api_request_surface( afb_req_get_application_id(req), a_drawing_name); if (isFirstReq) @@ -314,7 +314,7 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept } char const *a_ivi_id = json_object_get_string(j_ivi_id); - auto ret = g_afb_instance->app.api_request_surface( + auto ret = g_afb_instance->wmgr.api_request_surface( afb_req_get_application_id(req), a_drawing_name, a_ivi_id); if (ret != nullptr) { @@ -359,7 +359,7 @@ void windowmanager_activatesurface(afb_req req) noexcept return; } - g_afb_instance->app.api_activate_surface( + g_afb_instance->wmgr.api_activate_surface( afb_req_get_application_id(req), a_drawing_name, a_drawing_area, [&req](const char *errmsg) { @@ -375,7 +375,7 @@ void windowmanager_activatesurface(afb_req req) noexcept catch (std::exception &e) { HMI_WARNING("wm", "failed: Uncaught exception while calling activatesurface: %s", e.what()); - g_afb_instance->app.exeptionProcessForTransition(); + g_afb_instance->wmgr.exeptionProcessForTransition(); return; } } @@ -401,7 +401,7 @@ void windowmanager_deactivatesurface(afb_req req) noexcept return; } - g_afb_instance->app.api_deactivate_surface( + g_afb_instance->wmgr.api_deactivate_surface( afb_req_get_application_id(req), a_drawing_name, [&req](const char *errmsg) { if (errmsg != nullptr) @@ -416,7 +416,7 @@ void windowmanager_deactivatesurface(afb_req req) noexcept catch (std::exception &e) { HMI_WARNING("wm", "failed: Uncaught exception while calling deactivatesurface: %s", e.what()); - g_afb_instance->app.exeptionProcessForTransition(); + g_afb_instance->wmgr.exeptionProcessForTransition(); return; } } @@ -443,13 +443,13 @@ void windowmanager_enddraw(afb_req req) noexcept } afb_req_success(req, NULL, "success"); - g_afb_instance->app.api_enddraw( + g_afb_instance->wmgr.api_enddraw( afb_req_get_application_id(req), a_drawing_name); } catch (std::exception &e) { HMI_WARNING("wm", "failed: Uncaught exception while calling enddraw: %s", e.what()); - g_afb_instance->app.exeptionProcessForTransition(); + g_afb_instance->wmgr.exeptionProcessForTransition(); return; } } @@ -468,7 +468,7 @@ void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept try { - auto ret = g_afb_instance->app.api_get_display_info(); + auto ret = g_afb_instance->wmgr.api_get_display_info(); if (ret.is_err()) { afb_req_fail(req, "failed", ret.unwrap_err()); @@ -508,7 +508,7 @@ void windowmanager_getareainfo_thunk(afb_req req) noexcept } char const *a_drawing_name = json_object_get_string(j_drawing_name); - auto ret = g_afb_instance->app.api_get_area_info(a_drawing_name); + auto ret = g_afb_instance->wmgr.api_get_area_info(a_drawing_name); if (ret.is_err()) { afb_req_fail(req, "failed", ret.unwrap_err()); @@ -546,8 +546,8 @@ void windowmanager_wm_subscribe(afb_req req) noexcept return; } int event_type = json_object_get_int(j); - const char *event_name = g_afb_instance->app.kListEventName[event_type]; - struct afb_event event = g_afb_instance->app.map_afb_event[event_name]; + const char *event_name = g_afb_instance->wmgr.kListEventName[event_type]; + struct afb_event event = g_afb_instance->wmgr.map_afb_event[event_name]; int ret = afb_req_subscribe(req, event); if (ret) { @@ -578,7 +578,7 @@ void windowmanager_list_drawing_names(afb_req req) noexcept try { - nlohmann::json j = g_afb_instance->app.id_alloc.name2id; + nlohmann::json j = g_afb_instance->wmgr.id_alloc.name2id; auto ret = wm::Ok(json_tokener_parse(j.dump().c_str())); if (ret.is_err()) { @@ -610,7 +610,7 @@ void windowmanager_ping(afb_req req) noexcept try { - g_afb_instance->app.api_ping(); + g_afb_instance->wmgr.api_ping(); afb_req_success(req, NULL, "success"); } @@ -638,8 +638,8 @@ void windowmanager_debug_status(afb_req req) noexcept json_object *jr = json_object_new_object(); json_object_object_add(jr, "surfaces", - to_json(g_afb_instance->app.controller->sprops)); - json_object_object_add(jr, "layers", to_json(g_afb_instance->app.controller->lprops)); + to_json(g_afb_instance->wmgr.controller->sprops)); + json_object_object_add(jr, "layers", to_json(g_afb_instance->wmgr.controller->lprops)); afb_req_success(req, jr, "success"); } @@ -664,7 +664,7 @@ void windowmanager_debug_layers(afb_req req) noexcept try { - auto ret = wm::Ok(json_tokener_parse(g_afb_instance->app.layers.to_json().dump().c_str())); + auto ret = wm::Ok(json_tokener_parse(g_afb_instance->wmgr.layers.to_json().dump().c_str())); afb_req_success(req, ret, "success"); } @@ -690,7 +690,7 @@ void windowmanager_debug_surfaces(afb_req req) noexcept try { - auto ret = wm::Ok(to_json(g_afb_instance->app.controller->sprops)); + auto ret = wm::Ok(to_json(g_afb_instance->wmgr.controller->sprops)); if (ret.is_err()) { afb_req_fail(req, "failed", ret.unwrap_err()); diff --git a/src/window_manager.cpp b/src/window_manager.cpp index 70228fa..98883a5 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -95,13 +95,13 @@ static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata) { HMI_NOTICE("wm", "Time out occurs because the client replys endDraw slow, so revert the request"); - reinterpret_cast(userdata)->timerHandler(); + reinterpret_cast(userdata)->timerHandler(); return 0; } } // namespace -void App::timerHandler() +void WindowManager::timerHandler() { unsigned req_num = g_app_list.currentRequestNumber(); HMI_SEQ_DEBUG(req_num, "Timer expired remove Request"); @@ -110,13 +110,13 @@ void App::timerHandler() this->processNextRequest(); } -void App::removeClient(const std::string &appid) +void WindowManager::removeClient(const std::string &appid) { HMI_DEBUG("wm", "Remove clinet %s from list", appid.c_str()); g_app_list.removeClient(appid); } -void App::exeptionProcessForTransition() +void WindowManager::exeptionProcessForTransition() { unsigned req_num = g_app_list.currentRequestNumber(); HMI_SEQ_NOTICE(req_num, "Process exeption handling for request. Remove current request %d", req_num); @@ -125,7 +125,7 @@ void App::exeptionProcessForTransition() this->processNextRequest(); } -bool App::subscribeEventForApp(const std::string &appid, afb_req req, const std::string &evname) +bool WindowManager::subscribeEventForApp(const std::string &appid, afb_req req, const std::string &evname) { if(!g_app_list.contains(appid)){ HMI_DEBUG("wm", "Client %s is not registered", appid.c_str()); @@ -136,9 +136,9 @@ bool App::subscribeEventForApp(const std::string &appid, afb_req req, const std: } /** - * App Impl + * WindowManager Impl */ -App::App(wl::display *d) +WindowManager::WindowManager(wl::display *d) : chooks{this}, display{d}, controller{}, @@ -179,7 +179,7 @@ App::App(wl::display *d) } } -int App::init() +int WindowManager::init() { if (!this->display->ok()) { @@ -234,7 +234,7 @@ int App::init() return init_layers(); } -int App::dispatch_pending_events() +int WindowManager::dispatch_pending_events() { if (this->pop_pending_events()) { @@ -244,23 +244,23 @@ int App::dispatch_pending_events() return -1; } -bool App::pop_pending_events() +bool WindowManager::pop_pending_events() { bool x{true}; return this->pending_events.compare_exchange_strong( x, false, std::memory_order_consume); } -void App::set_pending_events() +void WindowManager::set_pending_events() { this->pending_events.store(true, std::memory_order_release); } -optional App::lookup_id(char const *name) +optional WindowManager::lookup_id(char const *name) { return this->id_alloc.lookup(std::string(name)); } -optional App::lookup_name(int id) +optional WindowManager::lookup_name(int id) { return this->id_alloc.lookup(id); } @@ -268,7 +268,7 @@ optional App::lookup_name(int id) /** * init_layers() */ -int App::init_layers() +int WindowManager::init_layers() { if (!this->controller) { @@ -320,7 +320,7 @@ int App::init_layers() return 0; } -void App::surface_set_layout(int surface_id, const std::string& area) +void WindowManager::surface_set_layout(int surface_id, const std::string& area) { if (!this->controller->surface_exists(surface_id)) { @@ -376,13 +376,13 @@ void App::surface_set_layout(int surface_id, const std::string& area) surface_id, layer_id, x, y, w, h); } -void App::layout_commit() +void WindowManager::layout_commit() { this->controller->commit_changes(); this->display->flush(); } -void App::setTimer() +void WindowManager::setTimer() { HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Timer set activate"); if (g_timer_ev_src == nullptr) @@ -403,7 +403,7 @@ void App::setTimer() } } -void App::stopTimer() +void WindowManager::stopTimer() { unsigned req_num = g_app_list.currentRequestNumber(); HMI_SEQ_DEBUG(req_num, "Timer stop"); @@ -414,7 +414,7 @@ void App::stopTimer() } } -WMError App::doTransition(unsigned req_num) +WMError WindowManager::doTransition(unsigned req_num) { HMI_SEQ_DEBUG(req_num, "check policy"); WMError ret = this->checkPolicy(req_num); @@ -427,7 +427,7 @@ WMError App::doTransition(unsigned req_num) return ret; } -WMError App::checkPolicy(unsigned req_num) +WMError WindowManager::checkPolicy(unsigned req_num) { /* * Check Policy @@ -532,7 +532,7 @@ WMError App::checkPolicy(unsigned req_num) return ret; } -WMError App::startTransition(unsigned req_num) +WMError WindowManager::startTransition(unsigned req_num) { bool sync_draw_happen = false; bool found = false; @@ -579,7 +579,7 @@ WMError App::startTransition(unsigned req_num) return ret; } -WMError App::setInvisibleTask(const std::string &role, bool split) +WMError WindowManager::setInvisibleTask(const std::string &role, bool split) { unsigned req_num = g_app_list.currentRequestNumber(); HMI_SEQ_DEBUG(req_num, "set current visible app to invisible task"); @@ -723,7 +723,7 @@ WMError App::setInvisibleTask(const std::string &role, bool split) return WMError::SUCCESS; } -const char *App::check_surface_exist(const char *drawing_name) +const char *WindowManager::check_surface_exist(const char *drawing_name) { auto const &surface_id = this->lookup_id(drawing_name); if (!surface_id) @@ -759,7 +759,7 @@ const char *App::check_surface_exist(const char *drawing_name) //reply(nullptr); } -WMError App::setRequest(const std::string& appid, const std::string &role, const std::string &area, +WMError WindowManager::setRequest(const std::string& appid, const std::string &role, const std::string &area, Task task, unsigned* req_num) { if (!g_app_list.contains(appid)) @@ -791,7 +791,7 @@ WMError App::setRequest(const std::string& appid, const std::string &role, const return WMError::SUCCESS; } -void App::api_activate_surface(char const *appid, char const *drawing_name, +void WindowManager::api_activate_surface(char const *appid, char const *drawing_name, char const *drawing_area, const reply_func &reply) { ST(); @@ -834,7 +834,7 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, } } -void App::api_deactivate_surface(char const *appid, char const *drawing_name, +void WindowManager::api_deactivate_surface(char const *appid, char const *drawing_name, const reply_func &reply) { ST(); @@ -880,7 +880,7 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, } } -WMError App::doEndDraw(unsigned req_num) +WMError WindowManager::doEndDraw(unsigned req_num) { // get actions bool found; @@ -935,14 +935,14 @@ WMError App::doEndDraw(unsigned req_num) return ret; } -WMError App::setSurfaceSize(unsigned surface, const std::string &area) +WMError WindowManager::setSurfaceSize(unsigned surface, const std::string &area) { this->surface_set_layout(surface, area); return WMError::SUCCESS; } -WMError App::layoutChange(const WMAction &action) +WMError WindowManager::layoutChange(const WMAction &action) { if (action.visible == TaskVisible::INVISIBLE) { @@ -962,7 +962,7 @@ WMError App::layoutChange(const WMAction &action) return ret; } -WMError App::visibilityChange(const WMAction &action) +WMError WindowManager::visibilityChange(const WMAction &action) { HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Change visibility"); if(!g_app_list.contains(action.appid)){ @@ -988,7 +988,7 @@ WMError App::visibilityChange(const WMAction &action) return WMError::SUCCESS; } -WMError App::changeCurrentState(unsigned req_num) +WMError WindowManager::changeCurrentState(unsigned req_num) { HMI_SEQ_DEBUG(req_num, "Change current layout state"); bool trigger_found = false, action_found = false; @@ -1056,7 +1056,7 @@ WMError App::changeCurrentState(unsigned req_num) return WMError::SUCCESS; } -void App::api_enddraw(char const *appid, char const *drawing_name) +void WindowManager::api_enddraw(char const *appid, char const *drawing_name) { std::string id = appid; std::string role = drawing_name; @@ -1092,7 +1092,7 @@ void App::api_enddraw(char const *appid, char const *drawing_name) } } -void App::processNextRequest() +void WindowManager::processNextRequest() { g_app_list.next(); g_app_list.reqDump(); @@ -1112,9 +1112,9 @@ void App::processNextRequest() } } -void App::api_ping() { this->dispatch_pending_events(); } +void WindowManager::api_ping() { this->dispatch_pending_events(); } -void App::send_event(char const *evname, char const *label) +void WindowManager::send_event(char const *evname, char const *label) { HMI_DEBUG("wm", "%s: %s(%s)", __func__, evname, label); @@ -1128,7 +1128,7 @@ void App::send_event(char const *evname, char const *label) } } -void App::send_event(char const *evname, char const *label, char const *area, +void WindowManager::send_event(char const *evname, char const *label, char const *area, int x, int y, int w, int h) { HMI_DEBUG("wm", "%s: %s(%s, %s) x:%d y:%d w:%d h:%d", @@ -1155,7 +1155,7 @@ void App::send_event(char const *evname, char const *label, char const *area, /** * proxied events */ -void App::surface_created(uint32_t surface_id) +void WindowManager::surface_created(uint32_t surface_id) { auto layer_id = this->layers.get_layer_id(surface_id); if (!layer_id) @@ -1171,29 +1171,29 @@ void App::surface_created(uint32_t surface_id) this->layout_commit(); } -void App::surface_removed(uint32_t surface_id) +void WindowManager::surface_removed(uint32_t surface_id) { HMI_DEBUG("wm", "surface_id is %u", surface_id); g_app_list.removeSurface(surface_id); } -void App::emit_activated(char const *label) +void WindowManager::emit_activated(char const *label) { this->send_event(kListEventName[Event_Active], label); } -void App::emit_deactivated(char const *label) +void WindowManager::emit_deactivated(char const *label) { this->send_event(kListEventName[Event_Inactive], label); } -void App::emit_syncdraw(char const *label, char const *area, int x, int y, int w, int h) +void WindowManager::emit_syncdraw(char const *label, char const *area, int x, int y, int w, int h) { this->send_event(kListEventName[Event_SyncDraw], label, area, x, y, w, h); } -void App::emit_syncdraw(const std::string &role, const std::string &area) +void WindowManager::emit_syncdraw(const std::string &role, const std::string &area) { compositor::rect rect = this->layers.getAreaSize(area); //this->lm_get_area_info(area, &x, &y, &w, &h); @@ -1201,24 +1201,24 @@ void App::emit_syncdraw(const std::string &role, const std::string &area) role.c_str(), area.c_str(), rect.x, rect.y, rect.w, rect.h); } -void App::emit_flushdraw(char const *label) +void WindowManager::emit_flushdraw(char const *label) { this->send_event(kListEventName[Event_FlushDraw], label); } -void App::emit_visible(char const *label, bool is_visible) +void WindowManager::emit_visible(char const *label, bool is_visible) { this->send_event(is_visible ? kListEventName[Event_Visible] : kListEventName[Event_Invisible], label); } -void App::emit_invisible(char const *label) +void WindowManager::emit_invisible(char const *label) { return emit_visible(label, false); } -void App::emit_visible(char const *label) { return emit_visible(label, true); } +void WindowManager::emit_visible(char const *label) { return emit_visible(label, true); } -result App::api_request_surface(char const *appid, char const *drawing_name) +result WindowManager::api_request_surface(char const *appid, char const *drawing_name) { auto lid = this->layers.get_layer_id(std::string(drawing_name)); if (!lid) @@ -1262,7 +1262,7 @@ result App::api_request_surface(char const *appid, char const *drawing_name return Err("Surface already present"); } -char const *App::api_request_surface(char const *appid, char const *drawing_name, +char const *WindowManager::api_request_surface(char const *appid, char const *drawing_name, char const *ivi_id) { ST(); @@ -1303,7 +1303,7 @@ char const *App::api_request_surface(char const *appid, char const *drawing_name return nullptr; } -result App::api_get_display_info() +result WindowManager::api_get_display_info() { // Check controller if (!this->controller) @@ -1324,7 +1324,7 @@ result App::api_get_display_info() return Ok(object); } -result App::api_get_area_info(char const *drawing_name) +result WindowManager::api_get_area_info(char const *drawing_name) { HMI_DEBUG("wm", "called"); @@ -1369,7 +1369,7 @@ result App::api_get_area_info(char const *drawing_name) return Ok(object); } -void App::activate(int id) +void WindowManager::activate(int id) { auto ip = this->controller->sprops.find(id); if (ip != this->controller->sprops.end()) @@ -1415,7 +1415,7 @@ void App::activate(int id) } } -void App::deactivate(int id) +void WindowManager::deactivate(int id) { auto ip = this->controller->sprops.find(id); if (ip != this->controller->sprops.end()) @@ -1454,7 +1454,7 @@ void App::deactivate(int id) } } -bool App::can_split(struct LayoutState const &state, int new_id) +bool WindowManager::can_split(struct LayoutState const &state, int new_id) { if (state.main != -1 && state.main != new_id) { diff --git a/src/window_manager.hpp b/src/window_manager.hpp index af7cd8f..bd3f701 100644 --- a/src/window_manager.hpp +++ b/src/window_manager.hpp @@ -134,7 +134,7 @@ struct id_allocator } }; -struct App +struct WindowManager { typedef std::unordered_map rect_map; @@ -192,13 +192,13 @@ struct App // FOR CES DEMO std::vector surface_bg; - explicit App(wl::display *d); - ~App() = default; + explicit WindowManager(wl::display *d); + ~WindowManager() = default; - App(App const &) = delete; - App &operator=(App const &) = delete; - App(App &&) = delete; - App &operator=(App &&) = delete; + WindowManager(WindowManager const &) = delete; + WindowManager &operator=(WindowManager const &) = delete; + WindowManager(WindowManager &&) = delete; + WindowManager &operator=(WindowManager &&) = delete; int init(); -- cgit 1.2.3-korg