diff options
52 files changed, 722 insertions, 419 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0298f932e..1edbd2770 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,7 @@ find_package (Gettext REQUIRED) set (COMPIZ_I18N_DIR ${CMAKE_SOURCE_DIR}/po) add_custom_command (OUTPUT ${CMAKE_SOURCE_DIR}/po/unity.pot - COMMAND xgettext -c --files-from ${CMAKE_SOURCE_DIR}/po/POTFILES.in --keyword=_ -o ${CMAKE_SOURCE_DIR}/po/unity.pot --copyright-holder="Canonical Ltd" --msgid-bugs-address="ayatana-dev@lists.launchpad.net" --no-wrap --no-location + COMMAND xgettext -c --from-code=UTF-8 --files-from ${CMAKE_SOURCE_DIR}/po/POTFILES.in --keyword=_ -o ${CMAKE_SOURCE_DIR}/po/unity.pot --copyright-holder="Canonical Ltd" --msgid-bugs-address="ayatana-dev@lists.launchpad.net" --no-wrap --no-location WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) diff --git a/dash/ApplicationStarter.h b/dash/ApplicationStarter.h index 817a5466d..d74f302fe 100644 --- a/dash/ApplicationStarter.h +++ b/dash/ApplicationStarter.h @@ -32,6 +32,8 @@ class ApplicationStarter : boost::noncopyable public: typedef std::shared_ptr<ApplicationStarter> Ptr; + virtual ~ApplicationStarter() {} + virtual bool Launch(std::string const& application_name, Time timestamp) = 0; }; diff --git a/dash/DashController.cpp b/dash/DashController.cpp index 9f6d7a735..68ca20c3e 100644 --- a/dash/DashController.cpp +++ b/dash/DashController.cpp @@ -160,7 +160,7 @@ void Controller::RegisterUBusInterests() { ubus_manager_.RegisterInterest(UBUS_DASH_EXTERNAL_ACTIVATION, sigc::mem_fun(this, &Controller::OnExternalShowDash)); - ubus_manager_.RegisterInterest(UBUS_PLACE_VIEW_CLOSE_REQUEST, + ubus_manager_.RegisterInterest(UBUS_OVERLAY_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideDash)); place_entry_request_id_ = ubus_manager_.RegisterInterest(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 2fcdf11c6..a9e3c7caf 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -1099,7 +1099,7 @@ void DashView::OnActivateRequest(GVariant* args) } else if (/* visible_ && */ handled_type == ScopeHandledType::NOT_HANDLED) { - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST, NULL, + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST, NULL, glib::Source::Priority::HIGH); } else if (/* visible_ && */ handled_type == ScopeHandledType::GOTO_DASH_URI) @@ -1314,7 +1314,7 @@ void DashView::OnResultActivatedReply(LocalResult const& local_result, ScopeHand return; } - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); } bool DashView::DoFallbackActivation(std::string const& uri) @@ -1390,7 +1390,7 @@ bool DashView::InspectKeyEvent(unsigned int eventType, else if (search_bar_->search_string != "") search_bar_->search_string = ""; else - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); return true; } @@ -1460,7 +1460,7 @@ nux::Area* DashView::KeyNavIteration(nux::KeyNavDirection direction) void DashView::ProcessDndEnter() { - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); } nux::Area* DashView::FindKeyFocusArea(unsigned int key_symbol, @@ -1510,7 +1510,7 @@ nux::Area* DashView::FindKeyFocusArea(unsigned int key_symbol, if (close_key.first == special_keys_state && close_key.second == x11_key_code) { - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); return nullptr; } diff --git a/dash/ScopeBar.cpp b/dash/ScopeBar.cpp index 395a34a89..47d4897cf 100644 --- a/dash/ScopeBar.cpp +++ b/dash/ScopeBar.cpp @@ -129,7 +129,7 @@ void ScopeBar::DoOpenLegalise() g_creat(legal_seen_file_path_.c_str(), S_IRWXU); - ubus_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); } void ScopeBar::AddScope(Scope::Ptr const& scope) diff --git a/debian/changelog b/debian/changelog index 169bc5dd9..b0b59ad94 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,59 @@ unity (6.12.0daily13.03.13-0ubuntu1) UNRELEASED; urgency=low -- Didier Roche <didrocks@ubuntu.com> Wed, 13 Mar 2013 11:26:45 +0100 +unity (6.12.0daily13.03.20-0ubuntu1) raring; urgency=low + + [ Stephen M. Webb ] + * ‘No Image Available’ in previews isn’t translatable (LP: #1106849) + + [ Brandon Schaefer ] + * Unity unit tests take too long to finish (LP: #1053163) + * Unity FTBFS xgettext unicode TrashLauncherIcon.cpp:91 (LP: #1156931) + * HUD's item which is being mouse-hovered is selected, making fast + typing and clicking Enter unsafe (LP: #1066442) + + [ Marco Trevisan (Treviño) ] + * Icons edges are not visible on the 13.04 unity launcher (LP: + #1156698) + * Clicking on a device (volume) icon doesn't always bring nautilus to + focus (LP: #1154792) + * [Regression] No "filter result" label in the dash. (LP: #1155550) + * Launcher icon edges become invisible when loading an application + (LP: #1157303) + * [regression] Tooltip label is not centered (LP: #1155553) + * Clicking on trash icon doesn't always bring nautilus to focus (LP: + #1154862) + * Shutdown dialogue should close the overlays when activated from + power button (LP: #1155610) + * New shutdown Dialogs, shutdown/restart should change order. (LP: + #1154578) + * Shut Down dialog spells "Shut Down" incorrectly (LP: #1156641) + * New shutdown dialog had no default option selected (LP: #1155562) + * alt-tab - the 'pips' the indicate a application has multiple windows + open look pixelated (LP: #863331) + * Log Out dialog spells "Log Out" incorrectly (LP: #1156638) + * Launching an application from the "Appname" quicklist could not + bring it to focus (LP: #1155225) + + [ Mathieu Trudel-Lapierre ] + * gcalctool desktop file got renamed (LP: #1156810) + + [ Chris Townsend ] + * Launcher - auto-scroll needs to be more progressive (LP: #765732) + + [ Andrea Azzarone ] + * Tooltip timeout should not be resetted on each mouse movement. (LP: + #1155659) + * The sharp white line between dash and launcher is missing (LP: + #1125346) + * Reduce launcher tooltip timeout. (LP: #1155665) + * Launcher tooltips need fade animation on show/hide. (LP: #1155672) + + [ Ubuntu daily release ] + * Automatic snapshot from revision 3239 + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 20 Mar 2013 04:03:16 +0000 + unity (6.12.0daily13.03.13.1-0ubuntu1) raring; urgency=low [ Sebastien Bacher ] diff --git a/hud/HudAbstractView.h b/hud/HudAbstractView.h index 56f20e2be..a1c9ca0ba 100644 --- a/hud/HudAbstractView.h +++ b/hud/HudAbstractView.h @@ -43,7 +43,6 @@ public: virtual void AboutToShow() = 0; virtual void AboutToHide() = 0; - virtual void Relayout() = 0; virtual void ResetToDefault() = 0; virtual void SearchFinished() = 0; virtual void SetIcon(std::string const& icon_name, unsigned int tile_size, unsigned int size, unsigned int padding) = 0; diff --git a/hud/HudController.cpp b/hud/HudController.cpp index c6f5d5ddc..61b642236 100644 --- a/hud/HudController.cpp +++ b/hud/HudController.cpp @@ -80,7 +80,7 @@ Controller::Controller(Controller::ViewCreator const& create_view, ubus.RegisterInterest(UBUS_HUD_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideHud)); //!!FIXME!! - just hijacks the dash close request so we get some more requests than normal, - ubus.RegisterInterest(UBUS_PLACE_VIEW_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideHud)); + ubus.RegisterInterest(UBUS_OVERLAY_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideHud)); ubus.RegisterInterest(UBUS_OVERLAY_SHOWN, [&] (GVariant *data) { unity::glib::String overlay_identity; @@ -252,7 +252,7 @@ void Controller::Relayout(bool check_monitor) } nux::Geometry const& geo = GetIdealWindowGeometry(); - view_->Relayout(); + view_->QueueDraw(); window_->SetGeometry(geo); panel::Style &panel_style = panel::Style::Instance(); view_->SetMonitorOffset(launcher_width, panel_style.panel_height); diff --git a/hud/HudView.cpp b/hud/HudView.cpp index 32d6e548e..e32190218 100644 --- a/hud/HudView.cpp +++ b/hud/HudView.cpp @@ -114,9 +114,14 @@ View::View() } }); + mouse_move.connect([this] (int x, int y, int dx, int dy, unsigned long mouse_button, unsigned long special_key) { + for (auto button : buttons_) + button->SetInputEventSensitivity(true); + }); + mouse_down.connect(sigc::mem_fun(this, &View::OnMouseButtonDown)); - Relayout(); + QueueDraw(); } View::~View() @@ -182,28 +187,17 @@ void View::ProcessGrowShrink() } } - void View::ResetToDefault() { SetQueries(Hud::Queries()); current_height_ = content_layout_->GetBaseHeight();; + UpdateLayoutGeometry(); + search_bar_->search_string = ""; search_bar_->search_hint = _("Type your command"); } -void View::Relayout() -{ - nux::Geometry const& geo = GetGeometry(); - content_geo_ = GetBestFitGeometry(geo); - LOG_DEBUG(logger) << "content_geo: " << content_geo_.width << "x" << content_geo_.height; - - layout_->SetMinimumWidth(content_geo_.width); - layout_->SetMaximumSize(content_geo_.width, content_geo_.height); - - QueueDraw(); -} - nux::View* View::default_focus() const { return search_bar_->text_entry(); @@ -238,6 +232,7 @@ void View::SetQueries(Hud::Queries queries) HudButton::Ptr button(new HudButton()); buttons_.push_front(button); + button->SetInputEventSensitivity(false); button->SetMinimumWidth(content_width); button->SetMaximumWidth(content_width); button->SetQuery(query); @@ -248,7 +243,7 @@ void View::SetQueries(Hud::Queries queries) query_activated.emit(dynamic_cast<HudButton*>(view)->GetQuery()); }); - button->mouse_move.connect([&](int x, int y, int dx, int dy, unsigned long mouse_button, unsigned long special_key) { + button->mouse_move.connect([this](int x, int y, int dx, int dy, unsigned long mouse_button, unsigned long special_key) { if (keyboard_stole_focus_) { MouseStealsHudButtonFocus(); @@ -256,19 +251,19 @@ void View::SetQueries(Hud::Queries queries) } }); - button->mouse_enter.connect([&](int x, int y, unsigned long mouse_button, unsigned long special_key) { + button->mouse_enter.connect([this](int x, int y, unsigned long mouse_button, unsigned long special_key) { MouseStealsHudButtonFocus(); }); - button->mouse_leave.connect([&](int x, int y, unsigned long mouse_button, unsigned long special_key) { + button->mouse_leave.connect([this](int x, int y, unsigned long mouse_button, unsigned long special_key) { SelectLastFocusedButton(); }); - button->key_nav_focus_activate.connect([&](nux::Area* area) { + button->key_nav_focus_activate.connect([this](nux::Area* area) { query_activated.emit(dynamic_cast<HudButton*>(area)->GetQuery()); }); - button->key_nav_focus_change.connect([&](nux::Area* area, bool recieving, nux::KeyNavDirection direction){ + button->key_nav_focus_change.connect([this](nux::Area* area, bool recieving, nux::KeyNavDirection direction){ if (recieving) query_selected.emit(dynamic_cast<HudButton*>(area)->GetQuery()); }); @@ -323,7 +318,8 @@ void View::ShowEmbeddedIcon(bool show) RemoveChild(icon_.GetPointer()); } - Relayout(); + UpdateLayoutGeometry(); + QueueDraw(); } // Gives us the width and height of the contents that will give us the best "fit", @@ -404,6 +400,7 @@ void View::SetupViews() } }); + UpdateLayoutGeometry(); layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_START); } @@ -412,15 +409,22 @@ void View::SetupViews() SetLayout(super_layout); } +void View::UpdateLayoutGeometry() +{ + nux::Geometry const& geo = GetGeometry(); + content_geo_ = GetBestFitGeometry(geo); + + layout_->SetMinimumWidth(content_geo_.width); + layout_->SetMaximumSize(content_geo_.width, content_geo_.height); +} + void View::OnSearchChanged(std::string const& search_string) { LOG_DEBUG(logger) << "got search change"; search_changed.emit(search_string); for(auto button : buttons_) - { button->fake_focused = false; - } if (!buttons_.empty()) buttons_.back()->fake_focused = true; diff --git a/hud/HudView.h b/hud/HudView.h index 8161187fa..9cb88ce61 100644 --- a/hud/HudView.h +++ b/hud/HudView.h @@ -49,7 +49,6 @@ public: void ResetToDefault(); - void Relayout(); nux::View* default_focus() const; std::list<HudButton::Ptr> const& buttons() const; @@ -83,7 +82,9 @@ private: bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character); void OnSearchbarActivated(); bool AcceptKeyNavFocus(); + nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo); + void UpdateLayoutGeometry(); void ProcessGrowShrink(); diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index 0f4c6f020..49e694f22 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -2736,7 +2736,7 @@ void Launcher::ProcessDndDrop(int x, int y) else if (_dnd_hovered_icon && _drag_action != nux::DNDACTION_NONE) { if (IsOverlayOpen()) - ubus_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); _dnd_hovered_icon->AcceptDrop(_dnd_data); } diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp index bf431dc44..7e27ce774 100644 --- a/launcher/LauncherIcon.cpp +++ b/launcher/LauncherIcon.cpp @@ -62,6 +62,8 @@ const std::string UNITY_THEME_NAME = "unity-icon-theme"; const std::string CENTER_STABILIZE_TIMEOUT = "center-stabilize-timeout"; const std::string PRESENT_TIMEOUT = "present-timeout"; const std::string QUIRK_DELAY_TIMEOUT = "quirk-delay-timeout"; + +const unsigned TOOLTIP_FADE_DURATION = 80; } NUX_IMPLEMENT_OBJECT_TYPE(LauncherIcon); @@ -86,6 +88,7 @@ LauncherIcon::LauncherIcon(IconType type) , _parent_geo(max_num_monitors) , _saved_center(max_num_monitors) , _allow_quicklist_to_show(true) + , _tooltip_fade_animator(TOOLTIP_FADE_DURATION) { for (unsigned i = 0; i < unsigned(Quirk::LAST); ++i) { @@ -115,6 +118,19 @@ LauncherIcon::LauncherIcon(IconType type) mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown)); mouse_up.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseUp)); mouse_click.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseClick)); + + _tooltip_fade_animator.updated.connect([this] (double opacity) { + if (_tooltip) + { + _tooltip->SetOpacity(opacity); + + if (opacity == 0.0f && _tooltip_fade_animator.GetStartValue() > _tooltip_fade_animator.GetFinishValue()) + { + _tooltip->ShowWindow(false); + _tooltip->SetOpacity(0.0f); + } + } + }); } LauncherIcon::~LauncherIcon() @@ -143,6 +159,7 @@ LauncherIcon::~LauncherIcon() void LauncherIcon::LoadTooltip() { _tooltip = new Tooltip(); + _tooltip->SetOpacity(0.0f); AddChild(_tooltip.GetPointer()); _tooltip->text = tooltip_text(); @@ -522,6 +539,11 @@ LauncherIcon::ShowTooltip() _tooltip->ShowTooltipWithTipAt(tip_x, tip_y); _tooltip->ShowWindow(!tooltip_text().empty()); tooltip_visible.emit(_tooltip); + + if (_tooltip_fade_animator.CurrentState() == nux::animation::Animation::State::Running) + _tooltip_fade_animator.Reverse(); + else + _tooltip_fade_animator.SetStartValue(0.0f).SetFinishValue(1.0f).Start(); } void @@ -669,7 +691,13 @@ void LauncherIcon::RecvMouseClick(int button, int monitor, unsigned long key_fla void LauncherIcon::HideTooltip() { if (_tooltip) - _tooltip->ShowWindow(false); + { + if (_tooltip_fade_animator.CurrentState() == nux::animation::Animation::State::Running) + _tooltip_fade_animator.Reverse(); + else + _tooltip_fade_animator.SetStartValue(1.0f).SetFinishValue(0.0f).Start(); + } + tooltip_visible.emit(nux::ObjectPtr<nux::View>(nullptr)); } diff --git a/launcher/LauncherIcon.h b/launcher/LauncherIcon.h index 26f8b04e4..68a783b60 100644 --- a/launcher/LauncherIcon.h +++ b/launcher/LauncherIcon.h @@ -21,12 +21,9 @@ #ifndef LAUNCHERICON_H #define LAUNCHERICON_H -#include <set> -#include <boost/unordered_map.hpp> - #include <Nux/Nux.h> #include <Nux/BaseWindow.h> -#include <NuxCore/Math/MathInc.h> +#include <NuxCore/Animation.h> #include <gtk/gtk.h> #include <libdbusmenu-glib/client.h> @@ -338,6 +335,8 @@ private: std::list<LauncherEntryRemote::Ptr> _entry_list; + nux::animation::AnimateValue<double> _tooltip_fade_animator; + protected: glib::SourceManager _source_manager; }; diff --git a/launcher/MockLauncherIcon.h b/launcher/MockLauncherIcon.h index 06e0edb33..e1057515c 100644 --- a/launcher/MockLauncherIcon.h +++ b/launcher/MockLauncherIcon.h @@ -22,7 +22,6 @@ #define MOCKLAUNCHERICON_H #include <Nux/Nux.h> -#include <NuxCore/Math/MathInc.h> #include <Nux/BaseWindow.h> #include <Nux/View.h> diff --git a/launcher/QuicklistMenuItem.cpp b/launcher/QuicklistMenuItem.cpp index bd13841ab..9d3d9bac0 100644 --- a/launcher/QuicklistMenuItem.cpp +++ b/launcher/QuicklistMenuItem.cpp @@ -140,7 +140,7 @@ void QuicklistMenuItem::Activate() const if (!IsOverlayQuicklist()) { UBusManager manager; - manager.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + manager.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); } } diff --git a/launcher/SimpleLauncherIcon.cpp b/launcher/SimpleLauncherIcon.cpp index 7138a0bf7..8cf1d97b0 100644 --- a/launcher/SimpleLauncherIcon.cpp +++ b/launcher/SimpleLauncherIcon.cpp @@ -88,7 +88,7 @@ void SimpleLauncherIcon::OnMouseLeave(int monitor) void SimpleLauncherIcon::ActivateLauncherIcon(ActionArg arg) { activate.emit(); - UBusManager::SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST, + UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST, g_variant_new_boolean(FALSE)); } diff --git a/launcher/StandaloneLauncher.cpp b/launcher/StandaloneLauncher.cpp index 777951f6f..cec0cd82d 100644 --- a/launcher/StandaloneLauncher.cpp +++ b/launcher/StandaloneLauncher.cpp @@ -18,7 +18,9 @@ * */ -#include "Nux/Nux.h" +#include <Nux/Nux.h> +#include <Nux/NuxTimerTickSource.h> +#include <NuxCore/AnimationController.h> #include <gtk/gtk.h> #include "unity-shared/BackgroundEffectHelper.h" @@ -43,6 +45,7 @@ struct LauncherWindow { LauncherWindow() : wt(nux::CreateGUIThread("Unity Launcher", win_size.width, win_size.height, 0, &LauncherWindow::ThreadWidgetInit, this)) + , animation_controller(tick_source) {} void Show() @@ -85,6 +88,8 @@ private: unity::Settings settings; panel::Style panel_style; std::shared_ptr<nux::WindowThread> wt; + nux::NuxTimerTickSource tick_source; + nux::animation::AnimationController animation_controller; launcher::Controller::Ptr controller; }; diff --git a/launcher/SwitcherController.cpp b/launcher/SwitcherController.cpp index bd48fb74f..58b3850b9 100644 --- a/launcher/SwitcherController.cpp +++ b/launcher/SwitcherController.cpp @@ -316,7 +316,7 @@ void Controller::Impl::Show(ShowMode show, SortMode sort, std::vector<AbstractLa sources_.AddTimeout(obj_->initial_detail_timeout_length, cb_func, DETAIL_TIMEOUT); } - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); ubus_manager_.SendMessage(UBUS_SWITCHER_SHOWN, g_variant_new("(bi)", true, obj_->monitor_)); } diff --git a/panel/PanelView.cpp b/panel/PanelView.cpp index 80a57af37..25c053807 100644 --- a/panel/PanelView.cpp +++ b/panel/PanelView.cpp @@ -647,7 +647,7 @@ void PanelView::OnEntryActivated(std::string const& entry_id, nux::Rect const& g } if (overlay_is_open_) - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); } void PanelView::OnEntryShowMenu(std::string const& entry_id, unsigned xid, diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index e1ccc86df..522f177e9 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -425,7 +425,6 @@ UnityScreen::~UnityScreen() notify_uninit(); unity_a11y_finalize(); - ::unity::ui::IconRenderer::DestroyTextures(); QuicklistManager::Destroy(); reset_glib_logging(); @@ -1718,7 +1717,7 @@ void UnityScreen::handleCompizEvent(const char* plugin, if (launcher_controller_->IsOverlayOpen() && g_strcmp0(event, "start_viewport_switch") == 0) { - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); } if (adapter.IsScaleActive() && g_strcmp0(plugin, "scale") == 0 && diff --git a/po/POTFILES.in b/po/POTFILES.in index f57de6cb5..86c847465 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -33,6 +33,7 @@ shortcuts/ShortcutHintPrivate.cpp shortcuts/ShortcutView.cpp shortcuts/CompizShortcutModeller.cpp shutdown/SessionView.cpp +shutdown/SessionButton.cpp services/panel-service.c unity-shared/DashStyle.cpp unity-shared/SearchBar.cpp diff --git a/resources/launcher_icon_back_170.png b/resources/launcher_icon_back_170.png Binary files differdeleted file mode 100644 index efc6794a4..000000000 --- a/resources/launcher_icon_back_170.png +++ /dev/null diff --git a/resources/launcher_icon_edge_150.png b/resources/launcher_icon_edge_150.png Binary files differindex df07bd264..9a982fefb 100644 --- a/resources/launcher_icon_edge_150.png +++ b/resources/launcher_icon_edge_150.png diff --git a/resources/launcher_icon_edge_170.png b/resources/launcher_icon_edge_170.png Binary files differdeleted file mode 100644 index 5ed464976..000000000 --- a/resources/launcher_icon_edge_170.png +++ /dev/null diff --git a/resources/launcher_icon_edge_54.png b/resources/launcher_icon_edge_54.png Binary files differindex e0f85f305..e97bfdb7f 100644 --- a/resources/launcher_icon_edge_54.png +++ b/resources/launcher_icon_edge_54.png diff --git a/resources/launcher_icon_selected_back_170.png b/resources/launcher_icon_selected_back_170.png Binary files differdeleted file mode 100644 index 303532ee2..000000000 --- a/resources/launcher_icon_selected_back_170.png +++ /dev/null diff --git a/resources/launcher_icon_selected_edge_170.png b/resources/launcher_icon_selected_edge_170.png Binary files differdeleted file mode 100644 index 4ec6455fe..000000000 --- a/resources/launcher_icon_selected_edge_170.png +++ /dev/null diff --git a/resources/launcher_icon_shine_170.png b/resources/launcher_icon_shine_170.png Binary files differdeleted file mode 100644 index 41aba4632..000000000 --- a/resources/launcher_icon_shine_170.png +++ /dev/null diff --git a/resources/launcher_pip_large_ltr.png b/resources/launcher_pip_large_ltr.png Binary files differnew file mode 100644 index 000000000..33f0a6d45 --- /dev/null +++ b/resources/launcher_pip_large_ltr.png diff --git a/resources/launcher_pip_large_rtl.png b/resources/launcher_pip_large_rtl.png Binary files differnew file mode 100644 index 000000000..9c036c921 --- /dev/null +++ b/resources/launcher_pip_large_rtl.png diff --git a/shutdown/SessionButton.cpp b/shutdown/SessionButton.cpp index ef45506c1..8af0b6ee7 100644 --- a/shutdown/SessionButton.cpp +++ b/shutdown/SessionButton.cpp @@ -22,7 +22,7 @@ #include <Nux/VLayout.h> #include <UnityCore/Variant.h> - +#include <glib/gi18n-lib.h> namespace unity { @@ -38,15 +38,47 @@ namespace style NUX_IMPLEMENT_OBJECT_TYPE(Button); -Button::Button(std::string const& label, std::string const& texture_name, NUX_FILE_LINE_DECL) +Button::Button(Action action, NUX_FILE_LINE_DECL) : nux::View(NUX_FILE_LINE_PARAM) , highlighted(false) + , action([this] { return action_; }) , label([this] { return label_view_->GetText(); }) + , action_(action) { SetAcceptKeyNavFocusOnMouseDown(false); SetAcceptKeyNavFocusOnMouseEnter(true); - std::string texture_prefix = PKGDATADIR"/" + texture_name; + std::string texture_prefix = PKGDATADIR"/"; + std::string label; + + switch (action_) + { + case Action::LOCK: + texture_prefix += "lockscreen"; + label = _("Lock"); + break; + case Action::LOGOUT: + texture_prefix += "logout"; + label = _("Log Out"); + break; + case Action::SUSPEND: + texture_prefix += "suspend"; + label = _("Suspend"); + break; + case Action::HIBERNATE: + texture_prefix += "hibernate"; + label = _("Hibernate"); + break; + case Action::SHUTDOWN: + texture_prefix += "shutdown"; + label = _("Shut Down"); + break; + case Action::REBOOT: + texture_prefix += "restart"; + label = _("Restart"); + break; + } + normal_tex_.Adopt(nux::CreateTexture2DFromFile((texture_prefix + ".png").c_str(), -1, true)); highlight_tex_.Adopt(nux::CreateTexture2DFromFile((texture_prefix + "_highlight.png").c_str(), -1, true)); diff --git a/shutdown/SessionButton.h b/shutdown/SessionButton.h index f9b0ae362..055360048 100644 --- a/shutdown/SessionButton.h +++ b/shutdown/SessionButton.h @@ -37,9 +37,20 @@ class Button : public nux::View, public debug::Introspectable { NUX_DECLARE_OBJECT_TYPE(Button, nux::View); public: - Button(std::string const& label, std::string const& texture_name, NUX_FILE_LINE_PROTO); + enum class Action + { + LOCK, + LOGOUT, + SUSPEND, + HIBERNATE, + SHUTDOWN, + REBOOT + }; + + Button(Action, NUX_FILE_LINE_PROTO); nux::Property<bool> highlighted; + nux::ROProperty<Action> action; nux::ROProperty<std::string> label; sigc::signal<void> activated; @@ -54,6 +65,7 @@ protected: private: friend class TestSessionButton; + Action action_; IconTexture* image_view_; StaticCairoText* label_view_; nux::ObjectPtr<nux::BaseTexture> normal_tex_; diff --git a/shutdown/SessionController.cpp b/shutdown/SessionController.cpp index 0261efaad..d4f7f0bf6 100644 --- a/shutdown/SessionController.cpp +++ b/shutdown/SessionController.cpp @@ -91,6 +91,7 @@ void Controller::Show(View::Mode mode, bool inhibitors) if (Visible() && mode == view_->mode()) return; + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); WindowManager::Default().SaveInputFocus(); if (nux::GetWindowThread()->IsEmbeddedWindow()) @@ -107,7 +108,7 @@ void Controller::Show(View::Mode mode, bool inhibitors) view_window_->ShowWindow(true); view_window_->PushToFront(); view_window_->SetInputFocus(); - nux::GetWindowCompositor().SetKeyFocusArea(view_.GetPointer()); + nux::GetWindowCompositor().SetKeyFocusArea(view_->key_focus_area()); if (fade_animator_.CurrentState() == na::Animation::State::Running) { diff --git a/shutdown/SessionView.cpp b/shutdown/SessionView.cpp index 967f6b16b..a6cafacde 100644 --- a/shutdown/SessionView.cpp +++ b/shutdown/SessionView.cpp @@ -47,7 +47,9 @@ NUX_IMPLEMENT_OBJECT_TYPE(View); View::View(Manager::Ptr const& manager) : mode(Mode::FULL) + , key_focus_area([this] { return key_focus_area_; }) , manager_(manager) + , key_focus_area_(this) { closable = true; auto main_layout = new nux::VLayout(); @@ -170,35 +172,37 @@ void View::Populate() { debug::Introspectable::RemoveAllChildren(); buttons_layout_->Clear(); + key_focus_area_ = this; if (mode() == Mode::LOGOUT) { - auto* button = new Button(_("Lock"), "lockscreen", NUX_TRACKER_LOCATION); + auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); AddButton(button); - button = new Button(_("Logout"), "logout", NUX_TRACKER_LOCATION); + button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout)); + key_focus_area_ = button; AddButton(button); } else { if (mode() == Mode::FULL) { - auto* button = new Button(_("Lock"), "lockscreen", NUX_TRACKER_LOCATION); + auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen)); AddButton(button); if (manager_->CanSuspend()) { - button = new Button(_("Suspend"), "suspend", NUX_TRACKER_LOCATION); + button = new Button(Button::Action::SUSPEND, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Suspend)); AddButton(button); } if (manager_->CanHibernate()) { - button = new Button(_("Hibernate"), "hibernate", NUX_TRACKER_LOCATION); + button = new Button(Button::Action::HIBERNATE, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Hibernate)); AddButton(button); } @@ -206,17 +210,18 @@ void View::Populate() if (manager_->CanShutdown()) { - auto* button = new Button(_("Shutdown"), "shutdown", NUX_TRACKER_LOCATION); - button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Shutdown)); + auto *button = new Button(Button::Action::REBOOT, NUX_TRACKER_LOCATION); + button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Reboot)); AddButton(button); - button = new Button(_("Restart"), "restart", NUX_TRACKER_LOCATION); - button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Reboot)); + button = new Button(Button::Action::SHUTDOWN, NUX_TRACKER_LOCATION); + button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Shutdown)); + key_focus_area_ = (mode() == Mode::SHUTDOWN) ? button : key_focus_area_; AddButton(button); } else if (mode() == Mode::FULL) { - auto* button = new Button(_("Logout"), "logout", NUX_TRACKER_LOCATION); + auto* button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION); button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout)); AddButton(button); } diff --git a/shutdown/SessionView.h b/shutdown/SessionView.h index 05deb8fa3..b7ec5728f 100644 --- a/shutdown/SessionView.h +++ b/shutdown/SessionView.h @@ -50,6 +50,7 @@ public: nux::Property<Mode> mode; nux::Property<bool> have_inhibitors; + nux::ROProperty<nux::InputArea*> key_focus_area; sigc::signal<void> request_hide; @@ -76,6 +77,7 @@ private: StaticCairoText* title_; StaticCairoText* subtitle_; nux::HLayout* buttons_layout_; + nux::InputArea* key_focus_area_; }; } // namespace session diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fccf843da..68a0b87e8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -98,6 +98,27 @@ if (GTEST_SRC_DIR AND test_service_panel.cpp) target_link_libraries(test-gtest-service unity-shared ${LIBS}) +# gtest-slow, start moving things over that are slow running tests + set (GTEST_SLOW_SOURCES + test_main.cpp + logger_helper.cpp + test_im_text_entry_slow.cpp + test_im_text_entry_class.cpp + test_tooltip_manager.cpp + ) + + set (GTEST_SLOW_LIBS + gtest + gmock + launcher-lib + unity-shared + ) + + add_executable(test-gtest-slow ${GTEST_SLOW_SOURCES}) + + target_link_libraries(test-gtest-slow ${GTEST_SLOW_LIBS}) + + add_test(UnityGTestSlow test-gtest-slow) # The actual test executable (xless) - do not put anything that requires X in here set (GTEST_XLESS_SOURCES @@ -212,6 +233,7 @@ if (ENABLE_X_SUPPORT) test_hud_view.cpp test_icon_loader.cpp test_im_text_entry.cpp + test_im_text_entry_class.cpp test_launcher.cpp test_launcher_controller.cpp test_launcher_drag_window.cpp @@ -256,7 +278,6 @@ if (ENABLE_X_SUPPORT) test_texture_cache.cpp test_text_input.cpp test_thumbnail_generator.cpp - test_tooltip_manager.cpp test_trash_launcher_icon.cpp test_unity_settings.cpp test_unity_window_style.cpp @@ -315,6 +336,7 @@ if (ENABLE_X_SUPPORT) set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures) endif (ENABLE_X_SUPPORT) set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless) +set (GTEST_TEST_COMMAND_SLOW ./test-gtest-slow) set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus) set (TEST_COMMAND @@ -323,6 +345,7 @@ set (TEST_COMMAND && ${GTEST_TEST_COMMAND_XLESS} --gtest_output=xml:./ && ${GTEST_TEST_COMMAND_GESTURES} --gtest_output=xml:./ && ${GTEST_TEST_COMMAND_DBUS} --gtest_output=xml:./ + && ${GTEST_TEST_COMMAND_SLOW} --gtest_output=xml:./ ) set (TEST_COMMAND_HEADLESS @@ -333,7 +356,7 @@ set (TEST_COMMAND_HEADLESS if (GTEST_SRC_DIR) if (ENABLE_X_SUPPORT) - add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gestures) + add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-slow test-gtest-xless test-gtest-dbus test-gestures) add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures) add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless) else () diff --git a/tests/autopilot/unity/emulators/launcher.py b/tests/autopilot/unity/emulators/launcher.py index ac7842192..0f74d9bff 100644 --- a/tests/autopilot/unity/emulators/launcher.py +++ b/tests/autopilot/unity/emulators/launcher.py @@ -494,7 +494,7 @@ class LauncherModel(UnityIntrospectionObject): looking for an icon. For example, to find an icon with a particular desktop_id, one might do this from within a test: - >>> self.launcher.model.get_icon(desktop_id="gnome-calculator.desktop") + >>> self.launcher.model.get_icon(desktop_id="gcalctool.desktop") This method returns only one icon. It is the callers responsibility to ensure that the filter matches only one icon. diff --git a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py index c7c0847b1..da6e38cae 100644 --- a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py +++ b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py @@ -315,7 +315,7 @@ class LauncherDragIconsBehavior(LauncherTestCase): # not exist, and we don't want to wait for 10 seconds, so we do this # the old fashioned way. get_icon_fn = lambda: self.unity.launcher.model.get_children_by_type( - ApplicationLauncherIcon, desktop_id="gnome-calculator.desktop") + ApplicationLauncherIcon, desktop_id="gcalctool.desktop") calc_icon = get_icon_fn() if calc_icon: self.launcher_instance.unlock_from_launcher(calc_icon[0]) diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index 97938b9d9..bc040a1ed 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -459,6 +459,17 @@ class HudBehaviorTests(HudTestsBase): self.assertProperty(char_win, is_active=True) + def test_mouse_does_not_steal_button_focus(self): + """When typing in the hud the mouse must not steal button focus.""" + + self.unity.hud.ensure_visible() + + (x,y,w,h) = self.unity.hud.view.geometry + self.mouse.move(w/4, h/4) + + self.keyboard.type("a") + self.assertThat(self.unity.hud.view.selected_button, Eventually(Equals(1))) + class HudLauncherInteractionsTests(HudTestsBase): diff --git a/tests/test_im_text_entry.cpp b/tests/test_im_text_entry.cpp index 2c5457119..334b6ab9d 100644 --- a/tests/test_im_text_entry.cpp +++ b/tests/test_im_text_entry.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Canonical Ltd. + * Copyright 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, as @@ -19,49 +19,12 @@ * */ -#include <gmock/gmock.h> -#include "unity-shared/IMTextEntry.h" +#include "test_im_text_entry.h" using namespace testing; using namespace unity; using namespace nux; -namespace -{ - -class TestEvent : public nux::Event -{ -public: - TestEvent(nux::KeyModifier keymod, unsigned long keysym) - { - type = NUX_KEYDOWN; - key_modifiers = keymod; - x11_keysym = keysym; - } - - TestEvent(unsigned long keysym) - { - type = NUX_KEYDOWN; - x11_keysym = keysym; - } -}; - -class MockTextEntry : public IMTextEntry -{ -public: - MOCK_METHOD0(CutClipboard, void()); - MOCK_METHOD0(CopyClipboard, void()); - MOCK_METHOD0(PasteClipboard, void()); - MOCK_METHOD0(PastePrimaryClipboard, void()); - - bool InspectKeyEvent(nux::Event const& event) - { - key_down.emit(event.type, event.GetKeySym(), event.GetKeyState(), nullptr, 0); - return IMTextEntry::InspectKeyEvent(event); - } -}; - - TEST(TestIMTextEntry, CopyCtrlC) { MockTextEntry text_entry; @@ -173,27 +136,3 @@ TEST(TestIMTextEntry, CtrlKeybindings) EXPECT_TRUE(text_entry.InspectKeyEvent(event)); } } - -TEST(TestIMTextEntry, AltKeybindings) -{ - MockTextEntry text_entry; - - for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym) - { - TestEvent event(KEY_MODIFIER_ALT, keysym); - EXPECT_FALSE(text_entry.InspectKeyEvent(event)); - } -} - -TEST(TestIMTextEntry, SuperKeybindings) -{ - MockTextEntry text_entry; - - for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym) - { - TestEvent event(KEY_MODIFIER_SUPER, keysym); - EXPECT_FALSE(text_entry.InspectKeyEvent(event)); - } -} - -} diff --git a/tests/test_im_text_entry.h b/tests/test_im_text_entry.h new file mode 100644 index 000000000..1fa0e8f10 --- /dev/null +++ b/tests/test_im_text_entry.h @@ -0,0 +1,47 @@ +/* + * Copyright 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> + * + */ + +#ifndef TEST_IM_TEXT_ENTRY_H +#define TEST_IM_TEXT_ENTRY_H + +#include <gmock/gmock.h> +#include "unity-shared/IMTextEntry.h" + +class TestEvent : public nux::Event +{ +public: + TestEvent(nux::KeyModifier keymod, unsigned long keysym); + + TestEvent(unsigned long keysym); +}; + +class MockTextEntry : public unity::IMTextEntry +{ +public: + MOCK_METHOD0(CutClipboard, void()); + MOCK_METHOD0(CopyClipboard, void()); + MOCK_METHOD0(PasteClipboard, void()); + MOCK_METHOD0(PastePrimaryClipboard, void()); + + bool InspectKeyEvent(nux::Event const& event); +}; + +#endif // TEST_IM_TEXT_ENTRY_H diff --git a/tests/test_im_text_entry_class.cpp b/tests/test_im_text_entry_class.cpp new file mode 100644 index 000000000..52083994f --- /dev/null +++ b/tests/test_im_text_entry_class.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> + * + */ + +#include "test_im_text_entry.h" + +TestEvent::TestEvent(nux::KeyModifier keymod, unsigned long keysym) +{ + type = nux::NUX_KEYDOWN; + key_modifiers = keymod; + x11_keysym = keysym; +} + +TestEvent::TestEvent(unsigned long keysym) +{ + type = nux::NUX_KEYDOWN; + x11_keysym = keysym; +} + +bool MockTextEntry::InspectKeyEvent(nux::Event const& event) +{ + key_down.emit(event.type, event.GetKeySym(), event.GetKeyState(), nullptr, 0); + return IMTextEntry::InspectKeyEvent(event); +} diff --git a/tests/test_im_text_entry_slow.cpp b/tests/test_im_text_entry_slow.cpp new file mode 100644 index 000000000..caa3493b8 --- /dev/null +++ b/tests/test_im_text_entry_slow.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> + * + */ + +#include "test_im_text_entry.h" + +using namespace nux; + +TEST(TestIMTextEntry, AltKeybindings) +{ + MockTextEntry text_entry; + + for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym) + { + TestEvent event(KEY_MODIFIER_ALT, keysym); + EXPECT_FALSE(text_entry.InspectKeyEvent(event)); + } +} + +TEST(TestIMTextEntry, SuperKeybindings) +{ + MockTextEntry text_entry; + + for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym) + { + TestEvent event(KEY_MODIFIER_SUPER, keysym); + EXPECT_FALSE(text_entry.InspectKeyEvent(event)); + } +} diff --git a/tests/test_quicklist_menu_item.cpp b/tests/test_quicklist_menu_item.cpp index 786fc02fc..3727ef624 100644 --- a/tests/test_quicklist_menu_item.cpp +++ b/tests/test_quicklist_menu_item.cpp @@ -196,7 +196,7 @@ TEST_F(TestQuicklistMenuItem, ItemActivateClosesDash) bool closes_dash = false; UBusManager manager; - manager.RegisterInterest(UBUS_PLACE_VIEW_CLOSE_REQUEST, [&] (GVariant*) { closes_dash = true; }); + manager.RegisterInterest(UBUS_OVERLAY_CLOSE_REQUEST, [&] (GVariant*) { closes_dash = true; }); qlitem->Activate(); Utils::WaitUntil(closes_dash); @@ -214,7 +214,7 @@ TEST_F(TestQuicklistMenuItem, OverlayItemActivateDoesNotCloseDash) bool closes_dash = false; UBusManager manager; - manager.RegisterInterest(UBUS_PLACE_VIEW_CLOSE_REQUEST, [&] (GVariant*) { closes_dash = true; }); + manager.RegisterInterest(UBUS_OVERLAY_CLOSE_REQUEST, [&] (GVariant*) { closes_dash = true; }); qlitem->Activate(); Utils::WaitForTimeoutMSec(100); diff --git a/tests/test_session_button.cpp b/tests/test_session_button.cpp index a108a7373..67e28d496 100644 --- a/tests/test_session_button.cpp +++ b/tests/test_session_button.cpp @@ -31,7 +31,7 @@ struct TestSessionButton : testing::Test { struct ButtonWrap : Button { - ButtonWrap() : Button("ButtonLabel", "hibernate") {} + ButtonWrap() : Button(Action::LOCK) {} using Button::AcceptKeyNavFocusOnMouseEnter; using Button::AcceptKeyNavFocusOnMouseDown; @@ -46,8 +46,8 @@ struct TestSessionButton : testing::Test TEST_F(TestSessionButton, Construct) { + EXPECT_EQ(button.action(), Button::Action::LOCK); EXPECT_FALSE(button.highlighted()); - EXPECT_EQ(button.label(), "ButtonLabel"); EXPECT_TRUE(button.AcceptKeyNavFocusOnMouseEnter()); EXPECT_FALSE(button.AcceptKeyNavFocusOnMouseDown()); } @@ -120,5 +120,50 @@ TEST_F(TestSessionButton, KeyFocusActivatesIt) EXPECT_TRUE(activated); } +// Action typed buttons tests + +struct ActionButton : public testing::TestWithParam<Button::Action> { + ActionButton() + : button(GetParam()) + {} + + std::string GetExpectedLabel() + { + switch (GetParam()) + { + case Button::Action::LOCK: + return "Lock"; + case Button::Action::LOGOUT: + return "Log Out"; + case Button::Action::SUSPEND: + return "Suspend"; + case Button::Action::HIBERNATE: + return "Hibernate"; + case Button::Action::SHUTDOWN: + return "Shut Down"; + case Button::Action::REBOOT: + return "Restart"; + } + + return ""; + } + + Button button; +}; + +INSTANTIATE_TEST_CASE_P(TestSessionButtonTypes, ActionButton, + testing::Values(Button::Action::LOCK, Button::Action::LOGOUT, Button::Action::SUSPEND, + Button::Action::HIBERNATE, Button::Action::SHUTDOWN, Button::Action::REBOOT)); + +TEST_P(/*TestSessionButtonTypes*/ActionButton, Label) +{ + EXPECT_EQ(button.label(), GetExpectedLabel()); +} + +TEST_P(/*TestSessionButtonTypes*/ActionButton, Action) +{ + EXPECT_EQ(button.action(), GetParam()); +} + } // session } // unity \ No newline at end of file diff --git a/tests/test_session_controller.cpp b/tests/test_session_controller.cpp index b138cbf25..420412b06 100644 --- a/tests/test_session_controller.cpp +++ b/tests/test_session_controller.cpp @@ -22,7 +22,9 @@ #include <NuxCore/AnimationController.h> #include "test_mock_session_manager.h" #include "SessionController.h" +#include "UBusMessages.h" #include "UnitySettings.h" +#include "test_utils.h" namespace unity { @@ -70,10 +72,20 @@ TEST_P(/*TestSessionController*/ShowMode, Show) controller.Show(GetParam()); EXPECT_TRUE(controller.Visible()); EXPECT_EQ(controller.view_->mode(), GetParam()); - EXPECT_EQ(nux::GetWindowCompositor().GetKeyFocusArea(), controller.view_.GetPointer()); + EXPECT_EQ(nux::GetWindowCompositor().GetKeyFocusArea(), controller.view_->key_focus_area()); EXPECT_TRUE(controller.view_->live_background()); } +TEST_P(/*TestSessionController*/ShowMode, RequestsHideOverlay) +{ + UBusManager ubus; + bool request_hide = false; + ubus.RegisterInterest(UBUS_OVERLAY_CLOSE_REQUEST, [&request_hide] (GVariant*) { request_hide = true; }); + + controller.Show(GetParam()); + Utils::WaitUntilMSec(request_hide); +} + TEST_F(TestSessionController, Hide) { controller.Show(View::Mode::FULL); diff --git a/tests/test_session_view.cpp b/tests/test_session_view.cpp index 5b65178e6..17d6d9886 100644 --- a/tests/test_session_view.cpp +++ b/tests/test_session_view.cpp @@ -60,16 +60,30 @@ struct TestSessionView : testing::Test return buttons; } - Button* GetButtonByLabel(std::string const& label) const + Button* GetButtonByAction(Button::Action action) const { for (auto const& button : GetButtons()) { - if (button->label() == label) + if (button->action() == action) return button; } return nullptr; } + + int GetButtonPosition(Button::Action action) const + { + int pos = 0; + for (auto const& button : GetButtons()) + { + if (button->action() == action) + return pos; + + ++pos; + } + + return -1; + } }; void TearDown() @@ -87,6 +101,7 @@ TEST_F(TestSessionView, Construct) EXPECT_TRUE(view.closable()); EXPECT_FALSE(view.have_inhibitors()); EXPECT_EQ(view.mode(), View::Mode::FULL); + EXPECT_EQ(view.key_focus_area(), &view); } TEST_F(TestSessionView, RequestCloseOnBoundingAreaClick) @@ -129,29 +144,30 @@ TEST_F(TestSessionView, FullModeButtons) ON_CALL(*manager, CanHibernate()).WillByDefault(testing::Return(true)); view.mode.changed.emit(View::Mode::FULL); - EXPECT_EQ(view.GetButtonByLabel("Logout"), nullptr); - EXPECT_NE(view.GetButtonByLabel("Lock"), nullptr); - EXPECT_NE(view.GetButtonByLabel("Suspend"), nullptr); - EXPECT_NE(view.GetButtonByLabel("Hibernate"), nullptr); - EXPECT_NE(view.GetButtonByLabel("Shutdown"), nullptr); - EXPECT_NE(view.GetButtonByLabel("Restart"), nullptr); + EXPECT_EQ(view.GetButtonByAction(Button::Action::LOGOUT), nullptr); + EXPECT_EQ(view.GetButtonPosition(Button::Action::LOCK), 0); + EXPECT_EQ(view.GetButtonPosition(Button::Action::SUSPEND), 1); + EXPECT_EQ(view.GetButtonPosition(Button::Action::HIBERNATE), 2); + EXPECT_EQ(view.GetButtonPosition(Button::Action::REBOOT), 3); + EXPECT_EQ(view.GetButtonPosition(Button::Action::SHUTDOWN), 4); + EXPECT_EQ(view.key_focus_area(), &view); ON_CALL(*manager, CanShutdown()).WillByDefault(testing::Return(false)); view.mode.changed.emit(View::Mode::FULL); - EXPECT_NE(view.GetButtonByLabel("Logout"), nullptr); - EXPECT_EQ(view.GetButtonByLabel("Shutdown"), nullptr); - EXPECT_EQ(view.GetButtonByLabel("Restart"), nullptr); + EXPECT_NE(view.GetButtonByAction(Button::Action::LOGOUT), nullptr); + EXPECT_EQ(view.GetButtonByAction(Button::Action::SHUTDOWN), nullptr); + EXPECT_EQ(view.GetButtonByAction(Button::Action::REBOOT), nullptr); ON_CALL(*manager, CanSuspend()).WillByDefault(testing::Return(false)); view.mode.changed.emit(View::Mode::FULL); - EXPECT_EQ(view.GetButtonByLabel("Suspend"), nullptr); + EXPECT_EQ(view.GetButtonByAction(Button::Action::SUSPEND), nullptr); ON_CALL(*manager, CanHibernate()).WillByDefault(testing::Return(false)); view.mode.changed.emit(View::Mode::FULL); - EXPECT_EQ(view.GetButtonByLabel("Hibernate"), nullptr); + EXPECT_EQ(view.GetButtonByAction(Button::Action::HIBERNATE), nullptr); } TEST_F(TestSessionView, ShutdownModeButtons) @@ -160,8 +176,9 @@ TEST_F(TestSessionView, ShutdownModeButtons) view.mode = View::Mode::SHUTDOWN; EXPECT_EQ(view.GetButtons().size(), 2); - EXPECT_NE(view.GetButtonByLabel("Shutdown"), nullptr); - EXPECT_NE(view.GetButtonByLabel("Restart"), nullptr); + EXPECT_EQ(view.GetButtonPosition(Button::Action::REBOOT), 0); + EXPECT_EQ(view.GetButtonPosition(Button::Action::SHUTDOWN), 1); + EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::SHUTDOWN)); } TEST_F(TestSessionView, LogoutModeButtons) @@ -169,8 +186,9 @@ TEST_F(TestSessionView, LogoutModeButtons) view.mode = View::Mode::LOGOUT; EXPECT_EQ(view.GetButtons().size(), 2); - EXPECT_NE(view.GetButtonByLabel("Logout"), nullptr); - EXPECT_NE(view.GetButtonByLabel("Lock"), nullptr); + EXPECT_EQ(view.GetButtonPosition(Button::Action::LOCK), 0); + EXPECT_EQ(view.GetButtonPosition(Button::Action::LOGOUT), 1); + EXPECT_EQ(view.key_focus_area(), view.GetButtonByAction(Button::Action::LOGOUT)); } TEST_F(TestSessionView, FullModeTitle) @@ -198,7 +216,7 @@ TEST_F(TestSessionView, ButtonsActivateRequestsHide) bool request_hide = false; view.request_hide.connect([&request_hide] { request_hide = true; }); - auto button = view.GetButtonByLabel("Lock"); + auto button = view.GetButtonByAction(Button::Action::LOCK); ASSERT_NE(button, nullptr); button->activated.emit(); @@ -207,7 +225,7 @@ TEST_F(TestSessionView, ButtonsActivateRequestsHide) TEST_F(TestSessionView, ButtonsActivateDeselectButton) { - auto button = view.GetButtonByLabel("Lock"); + auto button = view.GetButtonByAction(Button::Action::LOCK); ASSERT_NE(button, nullptr); button->highlighted = true; button->activated.emit(); @@ -218,7 +236,7 @@ TEST_F(TestSessionView, ButtonsActivateDeselectButton) TEST_F(TestSessionView, LockButtonActivateLocks) { EXPECT_CALL(*manager, LockScreen()); - auto button = view.GetButtonByLabel("Lock"); + auto button = view.GetButtonByAction(Button::Action::LOCK); ASSERT_NE(button, nullptr); button->activated.emit(); } @@ -227,7 +245,7 @@ TEST_F(TestSessionView, LogoutButtonActivateLogouts) { view.mode = View::Mode::LOGOUT; EXPECT_CALL(*manager, Logout()); - auto button = view.GetButtonByLabel("Logout"); + auto button = view.GetButtonByAction(Button::Action::LOGOUT); ASSERT_NE(button, nullptr); button->activated.emit(); } @@ -238,7 +256,7 @@ TEST_F(TestSessionView, SuspendButtonActivateSuspends) view.mode.changed.emit(View::Mode::FULL); EXPECT_CALL(*manager, Suspend()); - auto button = view.GetButtonByLabel("Suspend"); + auto button = view.GetButtonByAction(Button::Action::SUSPEND); ASSERT_NE(button, nullptr); button->activated.emit(); } @@ -249,7 +267,7 @@ TEST_F(TestSessionView, HibernateButtonActivateHibernates) view.mode.changed.emit(View::Mode::FULL); EXPECT_CALL(*manager, Hibernate()); - auto button = view.GetButtonByLabel("Hibernate"); + auto button = view.GetButtonByAction(Button::Action::HIBERNATE); ASSERT_NE(button, nullptr); button->activated.emit(); } @@ -260,7 +278,7 @@ TEST_F(TestSessionView, ShutdownButtonActivateShutsdown) view.mode = View::Mode::SHUTDOWN; EXPECT_CALL(*manager, Shutdown()); - auto button = view.GetButtonByLabel("Shutdown"); + auto button = view.GetButtonByAction(Button::Action::SHUTDOWN); ASSERT_NE(button, nullptr); button->activated.emit(); } @@ -271,7 +289,7 @@ TEST_F(TestSessionView, RebootButtonActivateReboots) view.mode = View::Mode::SHUTDOWN; EXPECT_CALL(*manager, Reboot()); - auto button = view.GetButtonByLabel("Restart"); + auto button = view.GetButtonByAction(Button::Action::REBOOT); ASSERT_NE(button, nullptr); button->activated.emit(); } diff --git a/unity-shared/IconRenderer.cpp b/unity-shared/IconRenderer.cpp index 39153795b..da8c2b868 100644 --- a/unity-shared/IconRenderer.cpp +++ b/unity-shared/IconRenderer.cpp @@ -25,7 +25,9 @@ #include <NuxGraphics/GpuDevice.h> #include <NuxGraphics/GLTextureResourceManager.h> +#include <UnityCore/GLibWrapper.h> #include <NuxGraphics/CairoGraphics.h> +#include "unity-shared/CairoTexture.h" #include "GraphicsUtils.h" #include <gtk/gtk.h> @@ -39,6 +41,8 @@ namespace unity { namespace ui { +namespace +{ #ifdef USE_GLES #define VertexShaderHeader "#version 100\n" @@ -171,6 +175,7 @@ LRP temp, factor.x, color, desat; \n\ MUL result.color.rgb, temp, colorify_color; \n\ MOV result.color.a, color; \n\ END"); +} // anonymous namespace // The local namespace is purely for namespacing the file local variables below. namespace local @@ -181,58 +186,83 @@ enum IconSize { SMALL = 0, BIG, - LAST, + SIZE, }; +} // anonymous namespace +} // local namespace + +struct IconRenderer::TexturesPool +{ + static std::shared_ptr<TexturesPool> Get() + { + static std::shared_ptr<TexturesPool> instance(new TexturesPool()); + return instance; + } -bool textures_created = false; -nux::BaseTexture* progress_bar_trough = 0; -nux::BaseTexture* progress_bar_fill = 0; -nux::BaseTexture* pip_ltr = 0; -nux::BaseTexture* pip_rtl = 0; -nux::BaseTexture* arrow_ltr = 0; -nux::BaseTexture* arrow_rtl = 0; -nux::BaseTexture* arrow_empty_ltr = 0; -nux::BaseTexture* arrow_empty_rtl = 0; - -// nux::BaseTexture* squircle_base = 0; -// nux::BaseTexture* squircle_base_selected = 0; -// nux::BaseTexture* squircle_edge = 0; -// nux::BaseTexture* squircle_glow = 0; -// nux::BaseTexture* squircle_shadow = 0; -// nux::BaseTexture* squircle_shine = 0; - -std::vector<nux::BaseTexture*> icon_background; -std::vector<nux::BaseTexture*> icon_selected_background; -std::vector<nux::BaseTexture*> icon_edge; -std::vector<nux::BaseTexture*> icon_glow; -std::vector<nux::BaseTexture*> icon_shadow; -std::vector<nux::BaseTexture*> icon_shine; -nux::ObjectPtr<nux::IOpenGLBaseTexture> offscreen_progress_texture; -nux::ObjectPtr<nux::IOpenGLShaderProgram> shader_program_uv_persp_correction; + nux::ObjectPtr<nux::BaseTexture> RenderLabelTexture(char label, int icon_size, nux::Color const& bg_color); + + BaseTexturePtr progress_bar_trough; + BaseTexturePtr progress_bar_fill; + BaseTexturePtr pip_ltr; + BaseTexturePtr large_pip_ltr; + // BaseTexturePtr pip_rtl; + // BaseTexturePtr large_pip_rtl; + BaseTexturePtr arrow_ltr; + BaseTexturePtr arrow_rtl; + BaseTexturePtr arrow_empty_ltr; + // BaseTexturePtr arrow_empty_rtl; + + // BaseTexturePtr squircle_base; + // BaseTexturePtr squircle_base_selected; + // BaseTexturePtr squircle_edge; + // BaseTexturePtr squircle_glow; + // BaseTexturePtr squircle_shadow; + // BaseTexturePtr squircle_shine; + + BaseTexturePtr icon_background[local::IconSize::SIZE]; + BaseTexturePtr icon_selected_background[local::IconSize::SIZE]; + BaseTexturePtr icon_edge[local::IconSize::SIZE]; + BaseTexturePtr icon_glow[local::IconSize::SIZE]; + BaseTexturePtr icon_shadow[local::IconSize::SIZE]; + BaseTexturePtr icon_shine[local::IconSize::SIZE]; + + nux::ObjectPtr<nux::IOpenGLBaseTexture> offscreen_progress_texture; + nux::ObjectPtr<nux::IOpenGLShaderProgram> shader_program_uv_persp_correction; #ifndef USE_GLES -nux::ObjectPtr<nux::IOpenGLAsmShaderProgram> asm_shader; + nux::ObjectPtr<nux::IOpenGLAsmShaderProgram> asm_shader; #endif -std::map<char, nux::BaseTexture*> label_map; -void generate_textures(); -void destroy_textures(); -} -} + std::map<char, BaseTexturePtr> labels; + +private: + TexturesPool(); + + inline void LoadTexture(BaseTexturePtr &texture_ptr, std::string const& filename) + { + texture_ptr.Adopt(nux::CreateTexture2DFromFile(filename.c_str(), -1, true)); + } + + inline void GenerateTextures(BaseTexturePtr (&texture)[local::IconSize::SIZE], + std::string const& big_file, std::string const& small_file) + { + LoadTexture(texture[local::IconSize::SMALL], small_file); + LoadTexture(texture[local::IconSize::BIG], big_file); + } + + void SetupShaders(); +}; IconRenderer::IconRenderer() : icon_size(0) , image_size(0) , spacing(0) + , textures_(TexturesPool::Get()) { pip_style = OUTSIDE_TILE; - - if (!local::textures_created) - local::generate_textures(); } IconRenderer::~IconRenderer() -{ -} +{} void IconRenderer::SetTargetSize(int tile_size, int image_size_, int spacing_) { @@ -248,7 +278,7 @@ void IconRenderer::PreprocessIcons(std::list<RenderArg>& args, nux::Geometry con nux::Matrix4 ProjectionMatrix; nux::Matrix4 ViewProjectionMatrix; - _stored_projection_matrix = nux::GetWindowThread()->GetGraphicsEngine().GetOpenGLModelViewProjectionMatrix(); + stored_projection_matrix_ = nux::GetWindowThread()->GetGraphicsEngine().GetOpenGLModelViewProjectionMatrix(); GetInverseScreenPerspectiveMatrix(ViewMatrix, ProjectionMatrix, geo.width, geo.height, 0.1f, 1000.0f, DEGTORAD(90)); @@ -404,19 +434,20 @@ void IconRenderer::RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& nux::Color background_tile_color = arg.icon->BackgroundColor(); nux::Color glow_color = arg.icon->GlowColor(); - nux::Color edge_color(0x55555555); + nux::Color edge_color = nux::color::White; nux::Color colorify = arg.colorify; nux::Color background_tile_colorify = arg.colorify; + nux::Color edge_tile_colorify = nux::color::White; bool colorify_background = arg.colorify_background; float backlight_intensity = arg.backlight_intensity; float glow_intensity = arg.glow_intensity; float shadow_intensity = 0.6f; - nux::BaseTexture* background = local::icon_background[size]; - nux::BaseTexture* edge = local::icon_edge[size]; - nux::BaseTexture* glow = local::icon_glow[size]; - nux::BaseTexture* shine = local::icon_shine[size]; - nux::BaseTexture* shadow = local::icon_shadow[size]; + BaseTexturePtr background = textures_->icon_background[size]; + BaseTexturePtr const& edge = textures_->icon_edge[size]; + BaseTexturePtr const& glow = textures_->icon_glow[size]; + BaseTexturePtr const& shine = textures_->icon_shine[size]; + BaseTexturePtr const& shadow = textures_->icon_shadow[size]; nux::Color shortcut_color = arg.colorify; @@ -445,7 +476,7 @@ void IconRenderer::RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& glow_intensity = 1.0f; shadow_intensity = 0.0f; - background = local::icon_selected_background[size]; + background = textures_->icon_selected_background[size]; } else { @@ -477,8 +508,6 @@ void IconRenderer::RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& { nux::Color shadow_color = background_tile_colorify * 0.3f; - // FIXME it is using the same transformation of the glow, - // should have its own transformation. RenderElement(GfxContext, arg, shadow->GetDeviceTexture(), @@ -502,10 +531,9 @@ void IconRenderer::RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& backlight_intensity * arg.alpha, force_filter, tile_transform); - } - edge_color = edge_color + ((background_tile_color - edge_color) * backlight_intensity); - nux::Color edge_tile_colorify = background_tile_colorify; + edge_color = edge_color + ((background_tile_color - edge_color) * backlight_intensity); + } if (colorify_background && !arg.keyboard_nav_hl) { @@ -575,7 +603,7 @@ void IconRenderer::RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& RenderElement(GfxContext, arg, - local::icon_glow[size]->GetDeviceTexture(), + textures_->icon_glow[size]->GetDeviceTexture(), arg.icon->GlowColor(), nux::color::White, fade_out * arg.alpha, @@ -588,17 +616,17 @@ void IconRenderer::RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& // draw progress bar if (arg.progress_bias > -1.0f && arg.progress_bias < 1.0f) { - if (local::offscreen_progress_texture->GetWidth() != icon_size || - local::offscreen_progress_texture->GetHeight() != icon_size) + if (textures_->offscreen_progress_texture->GetWidth() != icon_size || + textures_->offscreen_progress_texture->GetHeight() != icon_size) { - local::offscreen_progress_texture = nux::GetGraphicsDisplay()->GetGpuDevice() + textures_->offscreen_progress_texture = nux::GetGraphicsDisplay()->GetGpuDevice() ->CreateSystemCapableDeviceTexture(icon_size, icon_size, 1, nux::BITFMT_R8G8B8A8); } - RenderProgressToTexture(GfxContext, local::offscreen_progress_texture, arg.progress, arg.progress_bias); + RenderProgressToTexture(GfxContext, textures_->offscreen_progress_texture, arg.progress, arg.progress_bias); RenderElement(GfxContext, arg, - local::offscreen_progress_texture, + textures_->offscreen_progress_texture, nux::color::White, nux::color::White, arg.alpha, @@ -631,12 +659,22 @@ void IconRenderer::RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& { char shortcut = (char) arg.shortcut_label; - if (local::label_map.find(shortcut) == local::label_map.end()) - local::label_map[shortcut] = RenderCharToTexture(shortcut, icon_size, icon_size, shortcut_color); + BaseTexturePtr label; + auto label_it = textures_->labels.find(shortcut); + + if (label_it != textures_->labels.end()) + { + label = label_it->second; + } + else + { + label = textures_->RenderLabelTexture(shortcut, icon_size, shortcut_color); + textures_->labels[shortcut] = label; + } RenderElement(GfxContext, arg, - local::label_map[shortcut]->GetDeviceTexture(), + label->GetDeviceTexture(), nux::Color(0xFFFFFFFF), nux::color::White, arg.alpha, @@ -645,23 +683,19 @@ void IconRenderer::RenderIcon(nux::GraphicsEngine& GfxContext, RenderArg const& } } -nux::BaseTexture* IconRenderer::RenderCharToTexture(char label, int width, int height, nux::Color const& bg_color) +nux::ObjectPtr<nux::BaseTexture> IconRenderer::TexturesPool::RenderLabelTexture(char label, int icon_size, nux::Color const& bg_color) { - nux::BaseTexture* texture = NULL; - nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height); - cairo_t* cr = cg.GetInternalContext(); - PangoLayout* layout = NULL; - PangoFontDescription* desc = NULL; - GtkSettings* settings = gtk_settings_get_default(); // not ref'ed - gchar* fontName = NULL; - - double label_ratio = 0.44f; - double label_size = icon_size * label_ratio; - double label_x = (icon_size - label_size) / 2; - double label_y = (icon_size - label_size) / 2; - double label_w = label_size; - double label_h = label_size; - double label_radius = 3.0f; + nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, icon_size, icon_size); + cairo_t* cr = cg.GetInternalContext(); + glib::String font_name; + + const double label_ratio = 0.44f; + const double label_size = icon_size * label_ratio; + const double label_x = (icon_size - label_size) / 2.0f; + const double label_y = (icon_size - label_size) / 2.0f; + const double label_w = label_size; + const double label_h = label_size; + const double label_radius = 3.0f; cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); @@ -673,35 +707,27 @@ nux::BaseTexture* IconRenderer::RenderCharToTexture(char label, int width, int h cairo_set_source_rgba(cr, bg_color.red, bg_color.green, bg_color.blue, 0.20f); cairo_fill(cr); - double text_ratio = 0.75; - double text_size = label_size * text_ratio; - layout = pango_cairo_create_layout(cr); - g_object_get(settings, "gtk-font-name", &fontName, NULL); - desc = pango_font_description_from_string(fontName); - pango_font_description_set_absolute_size(desc, text_size * PANGO_SCALE); - pango_layout_set_font_description(layout, desc); + const double text_ratio = 0.75; + double text_size = label_size * text_ratio; + glib::Object<PangoLayout> layout(pango_cairo_create_layout(cr)); + g_object_get(gtk_settings_get_default(), "gtk-font-name", &font_name, NULL); + std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), + pango_font_description_free); + pango_font_description_set_absolute_size(desc.get(), text_size * PANGO_SCALE); + pango_layout_set_font_description(layout, desc.get()); pango_layout_set_text(layout, &label, 1); - PangoRectangle logRect; - PangoRectangle inkRect; - pango_layout_get_extents(layout, &inkRect, &logRect); + nux::Size extents; + pango_layout_get_pixel_size(layout, &extents.width, &extents.height); // position and paint text cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f); - double x = label_x - ((logRect.width / PANGO_SCALE) - label_w) / 2.0f; - double y = label_y - ((logRect.height / PANGO_SCALE) - label_h) / 2.0f - 1; + double x = label_x - std::round((extents.width - label_w) / 2.0f); + double y = label_y - std::round((extents.height - label_h) / 2.0f); cairo_move_to(cr, x, y); pango_cairo_show_layout(cr, layout); - nux::NBitmapData* bitmap = cg.GetBitmap(); - texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture(); - texture->Update(bitmap); - delete bitmap; - g_object_unref(layout); - pango_font_description_free(desc); - g_free(fontName); - - return texture; + return texture_ptr_from_cairo_graphics(cg); } void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext, @@ -783,28 +809,28 @@ void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext, if (nux::GetWindowThread()->GetGraphicsEngine().UsingGLSLCodePath()) { - local::shader_program_uv_persp_correction->Begin(); + textures_->shader_program_uv_persp_correction->Begin(); - int TextureObjectLocation = local::shader_program_uv_persp_correction->GetUniformLocationARB("TextureObject0"); - VertexLocation = local::shader_program_uv_persp_correction->GetAttributeLocation("iVertex"); - TextureCoord0Location = local::shader_program_uv_persp_correction->GetAttributeLocation("iTexCoord0"); - FragmentColor = local::shader_program_uv_persp_correction->GetUniformLocationARB("color0"); - ColorifyColor = local::shader_program_uv_persp_correction->GetUniformLocationARB("colorify_color"); - DesatFactor = local::shader_program_uv_persp_correction->GetUniformLocationARB("desat_factor"); + int TextureObjectLocation = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("TextureObject0"); + VertexLocation = textures_->shader_program_uv_persp_correction->GetAttributeLocation("iVertex"); + TextureCoord0Location = textures_->shader_program_uv_persp_correction->GetAttributeLocation("iTexCoord0"); + FragmentColor = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("color0"); + ColorifyColor = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("colorify_color"); + DesatFactor = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("desat_factor"); if (TextureObjectLocation != -1) CHECKGL(glUniform1iARB(TextureObjectLocation, 0)); - int VPMatrixLocation = local::shader_program_uv_persp_correction->GetUniformLocationARB("ViewProjectionMatrix"); + int VPMatrixLocation = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("ViewProjectionMatrix"); if (VPMatrixLocation != -1) { - local::shader_program_uv_persp_correction->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*) & (_stored_projection_matrix.m)); + textures_->shader_program_uv_persp_correction->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*) & (stored_projection_matrix_.m)); } } #ifndef USE_GLES else { - local::asm_shader->Begin(); + textures_->asm_shader->Begin(); VertexLocation = nux::VTXATTRIB_POSITION; TextureCoord0Location = nux::VTXATTRIB_TEXCOORD0; @@ -866,12 +892,12 @@ void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext, if (nux::GetWindowThread()->GetGraphicsEngine().UsingGLSLCodePath()) { - local::shader_program_uv_persp_correction->End(); + textures_->shader_program_uv_persp_correction->End(); } else { #ifndef USE_GLES - local::asm_shader->End(); + textures_->asm_shader->End(); #endif } } @@ -890,8 +916,8 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, if (running > 0) { int scale = 1; - int markerX; + if (pip_style == OUTSIDE_TILE) { markerX = geo.x; @@ -899,8 +925,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, else { auto bounds = arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_TILE, monitor); - markerX = bounds[0].x + 2; - scale = 2; + markerX = bounds[0].x + 1; } nux::TexCoordXForm texxform; @@ -914,46 +939,66 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, color = color * alpha; - nux::BaseTexture* texture; + BaseTexturePtr texture; // markers are well outside screen bounds to start int markers [3] = {-100, -100, -100}; if (!arg.running_on_viewport) { + scale = (pip_style == OUTSIDE_TILE) ? 1 : 2; markers[0] = markerCenter; - texture = local::arrow_empty_ltr; + texture = textures_->arrow_empty_ltr; } else if (running == 1) { + scale = (pip_style == OUTSIDE_TILE) ? 1 : 2; markers[0] = markerCenter; - texture = local::arrow_ltr; + texture = textures_->arrow_ltr; } else if (running == 2) { - markers[0] = markerCenter - 2 * scale; - markers[1] = markerCenter + 2 * scale; - texture = local::pip_ltr; + if (pip_style == OUTSIDE_TILE) + { + texture = textures_->pip_ltr; + markers[0] = markerCenter - 2; + markers[1] = markerCenter + 2; + } + else + { + texture = textures_->large_pip_ltr; + markers[0] = markerCenter - 4; + markers[1] = markerCenter + 4; + } } else { - markers[0] = markerCenter - 4 * scale; - markers[1] = markerCenter; - markers[2] = markerCenter + 4 * scale; - texture = local::pip_ltr; + if (pip_style == OUTSIDE_TILE) + { + texture = textures_->pip_ltr; + markers[0] = markerCenter - 4; + markers[1] = markerCenter; + markers[2] = markerCenter + 4; + } + else + { + texture = textures_->large_pip_ltr; + markers[0] = markerCenter - 8; + markers[1] = markerCenter; + markers[2] = markerCenter + 8; + } } - for (int i = 0; i < 3; i++) { int center = markers[i]; if (center == -100) break; - + GfxContext.QRP_1Tex(markerX, - center - ((texture->GetHeight() * scale) / 2) - 1, - (float) texture->GetWidth() * scale, - (float) texture->GetHeight() * scale, + center - std::round((texture->GetHeight() * scale) / 2.0f), + texture->GetWidth() * scale, + texture->GetHeight() * scale, texture->GetDeviceTexture(), texxform, color); @@ -965,11 +1010,11 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, nux::TexCoordXForm texxform; nux::Color color = nux::color::LightGrey * alpha; - GfxContext.QRP_1Tex((geo.x + geo.width) - local::arrow_rtl->GetWidth(), - markerCenter - (local::arrow_rtl->GetHeight() / 2) - 1, - (float) local::arrow_rtl->GetWidth(), - (float) local::arrow_rtl->GetHeight(), - local::arrow_rtl->GetDeviceTexture(), + GfxContext.QRP_1Tex((geo.x + geo.width) - textures_->arrow_rtl->GetWidth(), + markerCenter - std::round(textures_->arrow_rtl->GetHeight() / 2.0f), + textures_->arrow_rtl->GetWidth(), + textures_->arrow_rtl->GetHeight(), + textures_->arrow_rtl->GetDeviceTexture(), texxform, color); } @@ -984,10 +1029,10 @@ void IconRenderer::RenderProgressToTexture(nux::GraphicsEngine& GfxContext, int height = texture->GetHeight(); int progress_width = icon_size; - int progress_height = local::progress_bar_trough->GetHeight(); + int progress_height = textures_->progress_bar_trough->GetHeight(); int fill_width = image_size - (icon_size - image_size); - int fill_height = local::progress_bar_fill->GetHeight(); + int fill_height = textures_->progress_bar_fill->GetHeight(); int fill_offset = (progress_width - fill_width) / 2; @@ -1022,10 +1067,10 @@ void IconRenderer::RenderProgressToTexture(nux::GraphicsEngine& GfxContext, // left door GfxContext.PushClippingRectangle(nux::Geometry(left_edge, 0, half_size, height)); GfxContext.QRP_1Tex(left_edge, progress_y, progress_width, progress_height, - local::progress_bar_trough->GetDeviceTexture(), texxform, + textures_->progress_bar_trough->GetDeviceTexture(), texxform, nux::color::White); GfxContext.QRP_1Tex(left_edge + fill_offset, fill_y, fill_width, fill_height, - local::progress_bar_fill->GetDeviceTexture(), texxform, + textures_->progress_bar_fill->GetDeviceTexture(), texxform, nux::color::White); GfxContext.PopClippingRectangle(); @@ -1033,11 +1078,11 @@ void IconRenderer::RenderProgressToTexture(nux::GraphicsEngine& GfxContext, GfxContext.PushClippingRectangle(nux::Geometry(left_edge + half_size, 0, half_size, height)); GfxContext.QRP_1Tex(right_edge - progress_width, progress_y, progress_width, progress_height, - local::progress_bar_trough->GetDeviceTexture(), texxform, + textures_->progress_bar_trough->GetDeviceTexture(), texxform, nux::color::White); GfxContext.QRP_1Tex(right_edge - progress_width + fill_offset, fill_y, fill_width, fill_height, - local::progress_bar_fill->GetDeviceTexture(), texxform, + textures_->progress_bar_fill->GetDeviceTexture(), texxform, nux::color::White); GfxContext.PopClippingRectangle(); @@ -1045,16 +1090,9 @@ void IconRenderer::RenderProgressToTexture(nux::GraphicsEngine& GfxContext, unity::graphics::PopOffscreenRenderTarget(); } -void IconRenderer::DestroyTextures() -{ - local::destroy_textures(); -} - void IconRenderer::DestroyShortcutTextures() { - for (auto texture : local::label_map) - texture.second->UnReference(); - local::label_map.clear(); + TexturesPool::Get()->labels.clear(); } void IconRenderer::GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix, @@ -1142,12 +1180,57 @@ void IconRenderer::GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, n PerspectiveMatrix.Perspective(Fovy, AspectRatio, NearClipPlane, FarClipPlane); } -// The local namespace is purely for namespacing the file local variables below. -namespace local +IconRenderer::TexturesPool::TexturesPool() + : offscreen_progress_texture(nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8)) { -namespace -{ -void setup_shaders() + LoadTexture(progress_bar_trough, PKGDATADIR"/progress_bar_trough.png"); + LoadTexture(progress_bar_fill, PKGDATADIR"/progress_bar_fill.png"); + LoadTexture(pip_ltr, PKGDATADIR"/launcher_pip_ltr.png"); + LoadTexture(large_pip_ltr, PKGDATADIR"/launcher_pip_large_ltr.png"); + // LoadTexture(pip_rtl, PKGDATADIR"/launcher_pip_rtl.png"); + // LoadTexture(large_pip_rtl, PKGDATADIR"/launcher_pip_large_rtl.png"); + LoadTexture(arrow_ltr, PKGDATADIR"/launcher_arrow_ltr.png"); + LoadTexture(arrow_rtl, PKGDATADIR"/launcher_arrow_rtl.png"); + LoadTexture(arrow_empty_ltr, PKGDATADIR"/launcher_arrow_outline_ltr.png"); + // LoadTexture(arrow_empty_rtl, PKGDATADIR"/launcher_arrow_outline_rtl.png"); + + // LoadTexture(squircle_base, PKGDATADIR"/squircle_base_54.png"); + // LoadTexture(squircle_base_selected, PKGDATADIR"/squircle_base_selected_54.png"); + // LoadTexture(squircle_edge, PKGDATADIR"/squircle_edge_54.png"); + // LoadTexture(squircle_glow, PKGDATADIR"/squircle_glow_62.png"); + // LoadTexture(squircle_shadow, PKGDATADIR"/squircle_shadow_62.png"); + // LoadTexture(squircle_shine, PKGDATADIR"/squircle_shine_54.png"); + + // BaseTexturePtr icon_background[local::IconSize::SIZE]; + // BaseTexturePtr icon_selected_background[local::IconSize::SIZE]; + // BaseTexturePtr icon_edge[local::IconSize::SIZE]; + // BaseTexturePtr icon_glow[local::IconSize::SIZE]; + // BaseTexturePtr icon_shadow[local::IconSize::SIZE]; + // BaseTexturePtr icon_shine[local::IconSize::SIZE]; + + GenerateTextures(icon_background, + PKGDATADIR"/launcher_icon_back_150.png", + PKGDATADIR"/launcher_icon_back_54.png"); + GenerateTextures(icon_selected_background, + PKGDATADIR"/launcher_icon_selected_back_150.png", + PKGDATADIR"/launcher_icon_back_54.png"); + GenerateTextures(icon_edge, + PKGDATADIR"/launcher_icon_edge_150.png", + PKGDATADIR"/launcher_icon_edge_54.png"); + GenerateTextures(icon_glow, + PKGDATADIR"/launcher_icon_glow_200.png", + PKGDATADIR"/launcher_icon_glow_62.png"); + GenerateTextures(icon_shadow, + PKGDATADIR"/launcher_icon_shadow_200.png", + PKGDATADIR"/launcher_icon_shadow_62.png"); + GenerateTextures(icon_shine, + PKGDATADIR"/launcher_icon_shine_150.png", + PKGDATADIR"/launcher_icon_shine_54.png"); + + SetupShaders(); +} + +void IconRenderer::TexturesPool::SetupShaders() { if (nux::GetWindowThread()->GetGraphicsEngine().UsingGLSLCodePath()) { @@ -1178,107 +1261,5 @@ void setup_shaders() } } - -inline nux::BaseTexture* load_texture(const char* filename) -{ - return nux::CreateTexture2DFromFile(filename, -1, true); -} - -void generate_textures(std::vector<nux::BaseTexture*>& icons, const char* big_file, const char* small_file) -{ - icons.resize(IconSize::LAST); - icons[IconSize::BIG] = load_texture(big_file); - icons[IconSize::SMALL] = load_texture(small_file); -} - -void generate_textures() -{ - progress_bar_trough = load_texture(PKGDATADIR"/progress_bar_trough.png"); - progress_bar_fill = load_texture(PKGDATADIR"/progress_bar_fill.png"); - - generate_textures(icon_background, - PKGDATADIR"/launcher_icon_back_150.png", - PKGDATADIR"/launcher_icon_back_54.png"); - generate_textures(icon_selected_background, - PKGDATADIR"/launcher_icon_selected_back_150.png", - PKGDATADIR"/launcher_icon_back_54.png"); - generate_textures(icon_edge, - PKGDATADIR"/launcher_icon_edge_150.png", - PKGDATADIR"/launcher_icon_edge_54.png"); - generate_textures(icon_glow, - PKGDATADIR"/launcher_icon_glow_200.png", - PKGDATADIR"/launcher_icon_glow_62.png"); - generate_textures(icon_shadow, - PKGDATADIR"/launcher_icon_shadow_200.png", - PKGDATADIR"/launcher_icon_shadow_62.png"); - generate_textures(icon_shine, - PKGDATADIR"/launcher_icon_shine_150.png", - PKGDATADIR"/launcher_icon_shine_54.png"); - - // squircle_base = load_texture(PKGDATADIR"/squircle_base_54.png"); - // squircle_base_selected = load_texture(PKGDATADIR"/squircle_base_selected_54.png"); - // squircle_edge = load_texture(PKGDATADIR"/squircle_edge_54.png"); - // squircle_glow = load_texture(PKGDATADIR"/squircle_glow_62.png"); - // squircle_shadow = load_texture(PKGDATADIR"/squircle_shadow_62.png"); - // squircle_shine = load_texture(PKGDATADIR"/squircle_shine_54.png"); - - pip_ltr = load_texture(PKGDATADIR"/launcher_pip_ltr.png"); - arrow_ltr = load_texture(PKGDATADIR"/launcher_arrow_ltr.png"); - arrow_empty_ltr = load_texture(PKGDATADIR"/launcher_arrow_outline_ltr.png"); - - pip_rtl = load_texture(PKGDATADIR"/launcher_pip_rtl.png"); - arrow_rtl = load_texture(PKGDATADIR"/launcher_arrow_rtl.png"); - arrow_empty_rtl = load_texture(PKGDATADIR"/launcher_arrow_outline_rtl.png"); - - offscreen_progress_texture = nux::GetGraphicsDisplay()->GetGpuDevice() - ->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8); - - setup_shaders(); - textures_created = true; -} - -void destroy_textures(std::vector<nux::BaseTexture*>& icons) -{ - icons[SMALL]->UnReference(); - icons[BIG]->UnReference(); - icons.clear(); -} - -void destroy_textures() -{ - if (!textures_created) - return; - - progress_bar_trough->UnReference(); - progress_bar_fill->UnReference(); - pip_ltr->UnReference(); - pip_rtl->UnReference(); - arrow_ltr->UnReference(); - arrow_rtl->UnReference(); - arrow_empty_ltr->UnReference(); - arrow_empty_rtl->UnReference(); - - destroy_textures(icon_background); - destroy_textures(icon_selected_background); - destroy_textures(icon_edge); - destroy_textures(icon_glow); - destroy_textures(icon_shadow); - destroy_textures(icon_shine); - - // squircle_base->UnReference(); - // squircle_base_selected->UnReference(); - // squircle_edge->UnReference(); - // squircle_glow->UnReference(); - // squircle_shadow->UnReference(); - // squircle_shine->UnReference(); - - IconRenderer::DestroyShortcutTextures(); - - textures_created = false; -} - -} // anon namespace -} // namespace local - } // namespace ui } // namespace unity diff --git a/unity-shared/IconRenderer.h b/unity-shared/IconRenderer.h index e3e458bb5..00b5985d8 100644 --- a/unity-shared/IconRenderer.h +++ b/unity-shared/IconRenderer.h @@ -45,12 +45,9 @@ public: void SetTargetSize(int tile_size, int image_size, int spacing); - static void DestroyTextures(); static void DestroyShortcutTextures(); protected: - nux::BaseTexture* RenderCharToTexture(char label, int width, int height, nux::Color const& bg_color); - void RenderElement(nux::GraphicsEngine& GfxContext, RenderArg const& arg, nux::ObjectPtr<nux::IOpenGLBaseTexture> const& icon, @@ -90,7 +87,9 @@ private: int image_size; int spacing; - nux::Matrix4 _stored_projection_matrix; + struct TexturesPool; + std::shared_ptr<TexturesPool> textures_; + nux::Matrix4 stored_projection_matrix_; }; } diff --git a/unity-shared/Timer.h b/unity-shared/Timer.h index 8669164b5..a646dec62 100644 --- a/unity-shared/Timer.h +++ b/unity-shared/Timer.h @@ -20,7 +20,6 @@ #ifndef UNITY_TIMER_H #define UNITY_TIMER_H -#include <iosfwd> #include <string> #include <glib.h> diff --git a/unity-shared/UBusMessages.h b/unity-shared/UBusMessages.h index ab1a509bf..f15e48947 100644 --- a/unity-shared/UBusMessages.h +++ b/unity-shared/UBusMessages.h @@ -26,7 +26,7 @@ #define UBUS_AUTOPILOT_TEST_FINISHED "AUTOPILOT_TEST_FINISHED" #define UBUS_DASH_EXTERNAL_ACTIVATION "DASH_EXTERNAL_ACTIVATION" -#define UBUS_PLACE_VIEW_CLOSE_REQUEST "PLACE_VIEW_CLOSE_REQUEST" +#define UBUS_OVERLAY_CLOSE_REQUEST "OVERLAY_CLOSE_REQUEST" // Request a PlaceEntry to be shown. // Payload should be: (sus) = (id, section, search_string). diff --git a/unity-shared/WindowButtons.cpp b/unity-shared/WindowButtons.cpp index 9dd104560..f01450d17 100644 --- a/unity-shared/WindowButtons.cpp +++ b/unity-shared/WindowButtons.cpp @@ -360,7 +360,7 @@ void WindowButtons::OnCloseClicked(nux::Button *button) if (win_button->overlay_mode()) { - ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); + ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); } else { |
