diff -Nru unity-5.14-r2392-m2386/debian/bzr-builder.manifest unity-5.14-r2393-m2386/debian/bzr-builder.manifest --- unity-5.14-r2392-m2386/debian/bzr-builder.manifest 2012-07-26 19:52:29.000000000 +0000 +++ unity-5.14-r2393-m2386/debian/bzr-builder.manifest 2012-07-27 19:03:45.000000000 +0000 @@ -1,4 +1,4 @@ -# bzr-builder format 0.3 deb-version 5.14-r2392-m2386-p709 -lp:unity/5.0 revid:lukasz.zemczak@canonical.com-20120719090513-zp0aig44tglk9ynf +# bzr-builder format 0.3 deb-version 5.14-r2393-m2386-p709 +lp:unity/5.0 revid:tarmac-20120727111422-fk3njuwuwd2m6sd5 merge menu lp:~3v1n0/unity/always-shown-menus-5.0 revid:mail@3v1n0.net-20120726184904-8s51eux3b5w61b6t nest-part ubuntu lp:~ubuntu-desktop/unity/ubuntu debian debian revid:didrocks@ubuntu.com-20120606150521-jgcrsxsu6fgc7f01 diff -Nru unity-5.14-r2392-m2386/debian/changelog unity-5.14-r2393-m2386/debian/changelog --- unity-5.14-r2392-m2386/debian/changelog 2012-07-26 19:52:29.000000000 +0000 +++ unity-5.14-r2393-m2386/debian/changelog 2012-07-27 19:03:45.000000000 +0000 @@ -1,8 +1,8 @@ -unity (5.14-r2392-m2386-p709~precise1) precise; urgency=low +unity (5.14-r2393-m2386-p709~precise1) precise; urgency=low * Auto build. - -- Marco Trevisan (Treviño) Thu, 26 Jul 2012 19:52:29 +0000 + -- Marco Trevisan (Treviño) Fri, 27 Jul 2012 19:03:45 +0000 unity (5.12-0ubuntu3) UNRELEASED; urgency=low diff -Nru unity-5.14-r2392-m2386/plugins/unityshell/src/EdgeBarrierController.cpp unity-5.14-r2393-m2386/plugins/unityshell/src/EdgeBarrierController.cpp --- unity-5.14-r2392-m2386/plugins/unityshell/src/EdgeBarrierController.cpp 2012-07-26 19:52:11.000000000 +0000 +++ unity-5.14-r2393-m2386/plugins/unityshell/src/EdgeBarrierController.cpp 2012-07-27 19:03:26.000000000 +0000 @@ -15,6 +15,7 @@ * along with this program. If not, see . * * Authored by: Jason Smith + * Marco Trevisan */ #include "EdgeBarrierController.h" @@ -48,7 +49,7 @@ { UScreen *uscreen = UScreen::GetDefault(); - auto monitors = uscreen->GetMonitors(); + auto const& monitors = uscreen->GetMonitors(); ResizeBarrierList(monitors); uscreen->changed.connect([&](int primary, std::vector& layout) { @@ -123,17 +124,17 @@ float decay_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * .3f) + 1; decaymulator_->rate_of_decay = parent_->options()->edge_decay_rate() * decay_responsiveness_mult; - + float overcome_responsiveness_mult = ((parent_->options()->edge_responsiveness() - 1) * 1.0f) + 1; edge_overcome_pressure_ = parent_->options()->edge_overcome_pressure() * overcome_responsiveness_mult; } void EdgeBarrierController::Impl::OnPointerBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event) { - int monitor = owner->index; + unsigned monitor = owner->index; bool process = true; - if ((size_t)monitor <= subscribers_.size()) + if (monitor < subscribers_.size()) { auto subscriber = subscribers_[monitor]; if (subscriber && subscriber->HandleBarrierEvent(owner, event)) @@ -158,30 +159,39 @@ EdgeBarrierController::EdgeBarrierController() : sticky_edges(false) , pimpl(new Impl(this)) -{ -} +{} EdgeBarrierController::~EdgeBarrierController() -{ - -} +{} -void EdgeBarrierController::Subscribe(EdgeBarrierSubscriber* subscriber, int monitor) +void EdgeBarrierController::Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor) { - if (pimpl->subscribers_.size() <= (size_t)monitor) + if (monitor >= pimpl->subscribers_.size()) pimpl->subscribers_.resize(monitor + 1); - pimpl->subscribers_[monitor] = subscriber; - pimpl->SetupBarriers(UScreen::GetDefault()->GetMonitors()); + auto const& monitors = UScreen::GetDefault()->GetMonitors(); + pimpl->subscribers_[monitor] = subscriber; + pimpl->ResizeBarrierList(monitors); + pimpl->SetupBarriers(monitors); } -void EdgeBarrierController::Unsubscribe(EdgeBarrierSubscriber* subscriber, int monitor) +void EdgeBarrierController::Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor) { - if (pimpl->subscribers_.size() < (size_t)monitor || pimpl->subscribers_[monitor] != subscriber) + if (monitor >= pimpl->subscribers_.size() || pimpl->subscribers_[monitor] != subscriber) return; + + auto const& monitors = UScreen::GetDefault()->GetMonitors(); pimpl->subscribers_[monitor] = nullptr; + pimpl->ResizeBarrierList(monitors); + pimpl->SetupBarriers(monitors); +} + +EdgeBarrierSubscriber* EdgeBarrierController::GetSubscriber(unsigned int monitor) +{ + if (monitor >= pimpl->subscribers_.size()) + return nullptr; - pimpl->SetupBarriers(UScreen::GetDefault()->GetMonitors()); + return pimpl->subscribers_[monitor]; } diff -Nru unity-5.14-r2392-m2386/plugins/unityshell/src/EdgeBarrierController.h unity-5.14-r2393-m2386/plugins/unityshell/src/EdgeBarrierController.h --- unity-5.14-r2392-m2386/plugins/unityshell/src/EdgeBarrierController.h 2012-07-26 19:52:11.000000000 +0000 +++ unity-5.14-r2393-m2386/plugins/unityshell/src/EdgeBarrierController.h 2012-07-27 19:03:26.000000000 +0000 @@ -43,12 +43,13 @@ nux::Property sticky_edges; nux::Property options; - void Subscribe(EdgeBarrierSubscriber* subscriber, int monitor); - void Unsubscribe(EdgeBarrierSubscriber* subscriber, int monitor); + void Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); + void Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); + EdgeBarrierSubscriber* GetSubscriber(unsigned int monitor); private: struct Impl; - Impl* pimpl; + std::unique_ptr pimpl; }; } diff -Nru unity-5.14-r2392-m2386/plugins/unityshell/src/LauncherController.cpp unity-5.14-r2393-m2386/plugins/unityshell/src/LauncherController.cpp --- unity-5.14-r2392-m2386/plugins/unityshell/src/LauncherController.cpp 2012-07-26 19:52:11.000000000 +0000 +++ unity-5.14-r2393-m2386/plugins/unityshell/src/LauncherController.cpp 2012-07-27 19:03:26.000000000 +0000 @@ -18,7 +18,6 @@ * Tim Penhey */ -#include #include #include @@ -27,28 +26,21 @@ #include #include -#include "LauncherOptions.h" #include "BamfLauncherIcon.h" +#include "BFBLauncherIcon.h" #include "DesktopLauncherIcon.h" #include "DeviceLauncherIcon.h" -#include "DeviceLauncherSection.h" -#include "EdgeBarrierController.h" #include "FavoriteStore.h" #include "HudLauncherIcon.h" -#include "Launcher.h" #include "LauncherController.h" -#include "LauncherEntryRemote.h" -#include "LauncherEntryRemoteModel.h" -#include "AbstractLauncherIcon.h" +#include "LauncherControllerPrivate.h" +#include "LauncherOptions.h" #include "SoftwareCenterLauncherIcon.h" -#include "LauncherModel.h" -#include "WindowManager.h" +#include "TimeUtil.h" #include "TrashLauncherIcon.h" -#include "BFBLauncherIcon.h" -#include "UScreen.h" -#include "UBusWrapper.h" #include "UBusMessages.h" -#include "TimeUtil.h" +#include "UScreen.h" +#include "WindowManager.h" namespace unity { @@ -70,117 +62,6 @@ } } -class Controller::Impl -{ -public: - Impl(Display* display, Controller* parent); - ~Impl(); - - void UpdateNumWorkspaces(int workspaces); - - Launcher* CreateLauncher(int monitor); - - void Save(); - void SortAndUpdate(); - - nux::ObjectPtr CurrentLauncher(); - - void OnIconAdded(AbstractLauncherIcon::Ptr icon); - void OnIconRemoved(AbstractLauncherIcon::Ptr icon); - - void OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before); - void OnLauncherAddRequestSpecial(std::string const& path, AbstractLauncherIcon::Ptr before, std::string const& aptdaemon_trans_id, std::string const& icon_path, - int icon_x, int icon_y, int icon_size); - void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon); - void OnSCIconAnimationComplete(AbstractLauncherIcon::Ptr icon); - - void OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry); - void OnLauncherEntryRemoteRemoved(LauncherEntryRemote::Ptr const& entry); - - void OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before); - void OnFavoriteStoreFavoriteRemoved(std::string const& entry); - void OnFavoriteStoreReordered(); - - - void InsertExpoAction(); - void RemoveExpoAction(); - - void InsertDesktopIcon(); - void RemoveDesktopIcon(); - - void SendHomeActivationRequest(); - - int MonitorWithMouse(); - - void InsertTrash(); - - void RegisterIcon(AbstractLauncherIcon::Ptr icon); - - AbstractLauncherIcon::Ptr CreateFavorite(const char* file_path); - - SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); - - void SetupBamf(); - - void EnsureLaunchers(int primary, std::vector const& monitors); - - void OnExpoActivated(); - - void OnScreenChanged(int primary_monitor, std::vector& monitors); - - void OnWindowFocusChanged (guint32 xid); - - void OnViewOpened(BamfMatcher* matcher, BamfView* view); - - void ReceiveMouseDownOutsideArea(int x, int y, unsigned long button_flags, unsigned long key_flags); - - void ReceiveLauncherKeyPress(unsigned long eventType, - unsigned long keysym, - unsigned long state, - const char* character, - unsigned short keyCount); - - Controller* parent_; - glib::Object matcher_; - glib::Signal view_opened_signal_; - LauncherModel::Ptr model_; - nux::ObjectPtr launcher_; - nux::ObjectPtr keyboard_launcher_; - int sort_priority_; - DeviceLauncherSection device_section_; - LauncherEntryRemoteModel remote_model_; - AbstractLauncherIcon::Ptr expo_icon_; - AbstractLauncherIcon::Ptr desktop_icon_; - int num_workspaces_; - bool show_desktop_icon_; - Display* display_; - - guint bamf_timer_handler_id_; - guint launcher_key_press_handler_id_; - guint launcher_label_show_handler_id_; - guint launcher_hide_handler_id_; - - bool launcher_open; - bool launcher_keynav; - bool launcher_grabbed; - bool reactivate_keynav; - int reactivate_index; - bool keynav_restore_window_; - - UBusManager ubus; - - int launcher_key_press_time_; - - ui::EdgeBarrierController::Ptr edge_barriers_; - - LauncherList launchers; - - sigc::connection on_expoicon_activate_connection_; - sigc::connection launcher_key_press_connection_; - sigc::connection launcher_event_outside_connection_; -}; - - Controller::Impl::Impl(Display* display, Controller* parent) : parent_(parent) , matcher_(nullptr) @@ -191,9 +72,8 @@ , launcher_key_press_handler_id_(0) , launcher_label_show_handler_id_(0) , launcher_hide_handler_id_(0) - , edge_barriers_(new ui::EdgeBarrierController()) { - edge_barriers_->options = parent_->options(); + edge_barriers_.options = parent_->options(); UScreen* uscreen = UScreen::GetDefault(); auto monitors = uscreen->GetMonitors(); @@ -292,54 +172,43 @@ unsigned int num_monitors = monitors.size(); unsigned int num_launchers = parent_->multiple_launchers ? num_monitors : 1; unsigned int launchers_size = launchers.size(); - unsigned int last_monitor = 0; + unsigned int last_launcher = 0; - if (num_launchers == 1) + for (unsigned int i = 0; i < num_launchers; i++, last_launcher++) { - if (launchers_size == 0) + if (i >= launchers_size) { - launchers.push_back(nux::ObjectPtr(CreateLauncher(primary))); + launchers.push_back(nux::ObjectPtr(CreateLauncher(i))); } - else if (!launchers[0].IsValid()) + else if (!launchers[i]) { - launchers[0] = nux::ObjectPtr(CreateLauncher(primary)); + launchers[i] = nux::ObjectPtr(CreateLauncher(i)); } - launchers[0]->monitor(primary); - launchers[0]->Resize(); - last_monitor = 1; - } - else - { - for (unsigned int i = 0; i < num_monitors; i++, last_monitor++) - { - if (i >= launchers_size) - { - launchers.push_back(nux::ObjectPtr(CreateLauncher(i))); - } + int monitor = (num_launchers == 1) ? primary : i; - launchers[i]->monitor(i); - launchers[i]->Resize(); + if (launchers[i]->monitor() != monitor) + { + edge_barriers_.Unsubscribe(launchers[i].GetPointer(), launchers[i]->monitor); } + + launchers[i]->monitor(monitor); + launchers[i]->Resize(); + edge_barriers_.Subscribe(launchers[i].GetPointer(), launchers[i]->monitor); } - for (unsigned int i = last_monitor; i < launchers_size; ++i) + for (unsigned int i = last_launcher; i < launchers_size; ++i) { auto launcher = launchers[i]; - if (launcher.IsValid()) + if (launcher) { parent_->RemoveChild(launcher.GetPointer()); launcher->GetParent()->UnReference(); - edge_barriers_->Unsubscribe(launcher.GetPointer(), launcher->monitor); + edge_barriers_.Unsubscribe(launcher.GetPointer(), launcher->monitor); } } launchers.resize(num_launchers); - - for (size_t i = 0; i < launchers.size(); ++i) - { - edge_barriers_->Subscribe(launchers[i].GetPointer(), launchers[i]->monitor); - } } void Controller::Impl::OnScreenChanged(int primary_monitor, std::vector& monitors) diff -Nru unity-5.14-r2392-m2386/plugins/unityshell/src/LauncherController.h unity-5.14-r2393-m2386/plugins/unityshell/src/LauncherController.h --- unity-5.14-r2392-m2386/plugins/unityshell/src/LauncherController.h 2012-07-26 19:52:11.000000000 +0000 +++ unity-5.14-r2393-m2386/plugins/unityshell/src/LauncherController.h 2012-07-27 19:03:26.000000000 +0000 @@ -35,6 +35,7 @@ class AbstractLauncherIcon; class Launcher; class LauncherModel; +class TestLauncherController; class Controller : public unity::debug::Introspectable, public sigc::trackable { @@ -86,6 +87,7 @@ void AddProperties(GVariantBuilder* builder); private: + friend class TestLauncherController; class Impl; Impl* pimpl; }; diff -Nru unity-5.14-r2392-m2386/plugins/unityshell/src/LauncherControllerPrivate.h unity-5.14-r2393-m2386/plugins/unityshell/src/LauncherControllerPrivate.h --- unity-5.14-r2392-m2386/plugins/unityshell/src/LauncherControllerPrivate.h 1970-01-01 00:00:00.000000000 +0000 +++ unity-5.14-r2393-m2386/plugins/unityshell/src/LauncherControllerPrivate.h 2012-07-27 19:03:26.000000000 +0000 @@ -0,0 +1,157 @@ +/* + * Copyright 2012 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 3 along with this program. If not, see + * + * + * Authored by: Jason Smith + * Tim Penhey + * Marco Trevisan (Treviño) + * + */ + +#ifndef LAUNCHER_CONTROLLER_PRIVATE_H +#define LAUNCHER_CONTROLLER_PRIVATE_H + +#include + +#include "AbstractLauncherIcon.h" +#include "DeviceLauncherSection.h" +#include "EdgeBarrierController.h" +#include "LauncherController.h" +#include "Launcher.h" +#include "LauncherEntryRemote.h" +#include "LauncherEntryRemoteModel.h" +#include "LauncherModel.h" +#include "SoftwareCenterLauncherIcon.h" +#include "UBusWrapper.h" + +namespace unity +{ +namespace launcher +{ + +class Controller::Impl +{ +public: + Impl(Display* display, Controller* parent); + ~Impl(); + + void UpdateNumWorkspaces(int workspaces); + + Launcher* CreateLauncher(int monitor); + + void Save(); + void SortAndUpdate(); + + nux::ObjectPtr CurrentLauncher(); + + void OnIconAdded(AbstractLauncherIcon::Ptr icon); + void OnIconRemoved(AbstractLauncherIcon::Ptr icon); + + void OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before); + void OnLauncherAddRequestSpecial(std::string const& path, AbstractLauncherIcon::Ptr before, std::string const& aptdaemon_trans_id, std::string const& icon_path, + int icon_x, int icon_y, int icon_size); + void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon); + void OnSCIconAnimationComplete(AbstractLauncherIcon::Ptr icon); + + void OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry); + void OnLauncherEntryRemoteRemoved(LauncherEntryRemote::Ptr const& entry); + + void OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before); + void OnFavoriteStoreFavoriteRemoved(std::string const& entry); + void OnFavoriteStoreReordered(); + + + void InsertExpoAction(); + void RemoveExpoAction(); + + void InsertDesktopIcon(); + void RemoveDesktopIcon(); + + void SendHomeActivationRequest(); + + int MonitorWithMouse(); + + void InsertTrash(); + + void RegisterIcon(AbstractLauncherIcon::Ptr icon); + + AbstractLauncherIcon::Ptr CreateFavorite(const char* file_path); + + SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); + + void SetupBamf(); + + void EnsureLaunchers(int primary, std::vector const& monitors); + + void OnExpoActivated(); + + void OnScreenChanged(int primary_monitor, std::vector& monitors); + + void OnWindowFocusChanged (guint32 xid); + + void OnViewOpened(BamfMatcher* matcher, BamfView* view); + + void ReceiveMouseDownOutsideArea(int x, int y, unsigned long button_flags, unsigned long key_flags); + + void ReceiveLauncherKeyPress(unsigned long eventType, + unsigned long keysym, + unsigned long state, + const char* character, + unsigned short keyCount); + + Controller* parent_; + glib::Object matcher_; + glib::Signal view_opened_signal_; + LauncherModel::Ptr model_; + nux::ObjectPtr launcher_; + nux::ObjectPtr keyboard_launcher_; + int sort_priority_; + DeviceLauncherSection device_section_; + LauncherEntryRemoteModel remote_model_; + AbstractLauncherIcon::Ptr expo_icon_; + AbstractLauncherIcon::Ptr desktop_icon_; + int num_workspaces_; + bool show_desktop_icon_; + Display* display_; + + guint bamf_timer_handler_id_; + guint launcher_key_press_handler_id_; + guint launcher_label_show_handler_id_; + guint launcher_hide_handler_id_; + + bool launcher_open; + bool launcher_keynav; + bool launcher_grabbed; + bool reactivate_keynav; + int reactivate_index; + bool keynav_restore_window_; + + UBusManager ubus; + + int launcher_key_press_time_; + + ui::EdgeBarrierController edge_barriers_; + + LauncherList launchers; + + sigc::connection on_expoicon_activate_connection_; + sigc::connection launcher_key_press_connection_; + sigc::connection launcher_event_outside_connection_; +}; + +} // launcher namespace +} // unity namespace + +#endif diff -Nru unity-5.14-r2392-m2386/plugins/unityshell/src/UScreen.cpp unity-5.14-r2393-m2386/plugins/unityshell/src/UScreen.cpp --- unity-5.14-r2392-m2386/plugins/unityshell/src/UScreen.cpp 2012-07-26 19:52:11.000000000 +0000 +++ unity-5.14-r2393-m2386/plugins/unityshell/src/UScreen.cpp 2012-07-27 19:03:26.000000000 +0000 @@ -24,18 +24,19 @@ namespace { -static UScreen* default_screen_ = nullptr; nux::logging::Logger logger("unity.screen"); } +UScreen* UScreen::default_screen_ = nullptr; + UScreen::UScreen() - : screen_(gdk_screen_get_default(), glib::AddRef()) + : primary_(0) + , screen_(gdk_screen_get_default(), glib::AddRef()) , proxy_("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", G_BUS_TYPE_SYSTEM) , refresh_id_(0) - , primary_(0) { size_changed_signal_.Connect(screen_, "size-changed", sigc::mem_fun(this, &UScreen::Changed)); monitors_changed_signal_.Connect(screen_, "monitors-changed", sigc::mem_fun(this, &UScreen::Changed)); diff -Nru unity-5.14-r2392-m2386/plugins/unityshell/src/UScreen.h unity-5.14-r2393-m2386/plugins/unityshell/src/UScreen.h --- unity-5.14-r2392-m2386/plugins/unityshell/src/UScreen.h 2012-07-26 19:52:11.000000000 +0000 +++ unity-5.14-r2393-m2386/plugins/unityshell/src/UScreen.h 2012-07-27 19:03:26.000000000 +0000 @@ -54,14 +54,17 @@ void Changed(GdkScreen* screen); void Refresh(); -private: +protected: + static UScreen* default_screen_; std::vector monitors_; + int primary_; + +private: glib::Object screen_; glib::DBusProxy proxy_; glib::Signal size_changed_signal_; glib::Signal monitors_changed_signal_; guint refresh_id_; - int primary_; }; } // Namespace diff -Nru unity-5.14-r2392-m2386/tests/CMakeLists.txt unity-5.14-r2393-m2386/tests/CMakeLists.txt --- unity-5.14-r2392-m2386/tests/CMakeLists.txt 2012-07-26 19:52:11.000000000 +0000 +++ unity-5.14-r2393-m2386/tests/CMakeLists.txt 2012-07-27 19:03:26.000000000 +0000 @@ -205,6 +205,7 @@ test_icon_loader.cpp test_im_text_entry.cpp test_hud_view.cpp + test_launcher_controller.cpp test_keyboard_util.cpp test_resultviewgrid.cpp test_single_monitor_launcher_icon.cpp @@ -214,13 +215,21 @@ ${UNITY_SRC}/AbstractPlacesGroup.cpp ${UNITY_SRC}/Animator.cpp ${UNITY_SRC}/BackgroundEffectHelper.cpp + ${UNITY_SRC}/BamfLauncherIcon.cpp + ${UNITY_SRC}/BFBLauncherIcon.cpp ${UNITY_SRC}/CairoBaseWindow.cpp ${UNITY_SRC}/DashSettings.cpp ${UNITY_SRC}/DashStyle.cpp ${UNITY_SRC}/DashViewPrivate.cpp ${UNITY_SRC}/Decaymulator.cpp + ${UNITY_SRC}/DesktopLauncherIcon.cpp + ${UNITY_SRC}/DeviceLauncherIcon.cpp + ${UNITY_SRC}/DeviceLauncherSection.cpp + ${UNITY_SRC}/DevicesSettings.cpp ${UNITY_SRC}/DNDCollectionWindow.cpp ${UNITY_SRC}/DndData.cpp + ${UNITY_SRC}/EdgeBarrierController.cpp + ${UNITY_SRC}/FavoriteStore.cpp ${UNITY_SRC}/GeisAdapter.cpp ${UNITY_SRC}/IconLoader.cpp ${UNITY_SRC}/IconRenderer.cpp @@ -233,16 +242,21 @@ ${UNITY_SRC}/HudController.cpp ${UNITY_SRC}/HudIcon.cpp ${UNITY_SRC}/HudIconTextureSource.cpp + ${UNITY_SRC}/HudLauncherIcon.cpp ${UNITY_SRC}/HudPrivate.cpp ${UNITY_SRC}/HudView.cpp + ${UNITY_SRC}/IntrospectableWrappers.cpp ${UNITY_SRC}/LayoutSystem.cpp ${UNITY_SRC}/Launcher.cpp ${UNITY_SRC}/LauncherDragWindow.cpp + ${UNITY_SRC}/LauncherController.cpp ${UNITY_SRC}/LauncherEntryRemote.cpp + ${UNITY_SRC}/LauncherEntryRemoteModel.cpp ${UNITY_SRC}/LauncherHideMachine.cpp ${UNITY_SRC}/LauncherHoverMachine.cpp ${UNITY_SRC}/LauncherIcon.cpp ${UNITY_SRC}/LauncherModel.cpp + ${UNITY_SRC}/LauncherOptions.cpp ${UNITY_SRC}/KeyboardUtil.cpp ${UNITY_SRC}/OverlayRenderer.cpp ${UNITY_SRC}/JSONParser.cpp @@ -266,6 +280,7 @@ ${UNITY_SRC}/QuicklistMenuItemLabel.cpp ${UNITY_SRC}/QuicklistMenuItemRadio.cpp ${UNITY_SRC}/QuicklistMenuItemSeparator.cpp + ${UNITY_SRC}/SoftwareCenterLauncherIcon.cpp ${UNITY_SRC}/SpacerLauncherIcon.cpp ${UNITY_SRC}/TextureCache.cpp ${UNITY_SRC}/UBusWrapper.cpp @@ -277,7 +292,7 @@ ${UNITY_SRC}/ResultView.cpp ${UNITY_SRC}/ResultViewGrid.cpp ${UNITY_SRC}/ResultRenderer.cpp - ${UNITY_SRC}/IntrospectableWrappers.cpp + ${UNITY_SRC}/TrashLauncherIcon.cpp ) target_link_libraries(test-gtest gtest gmock ${LIBS}) add_test(UnityGTest test-gtest) diff -Nru unity-5.14-r2392-m2386/tests/test_launcher_controller.cpp unity-5.14-r2393-m2386/tests/test_launcher_controller.cpp --- unity-5.14-r2392-m2386/tests/test_launcher_controller.cpp 1970-01-01 00:00:00.000000000 +0000 +++ unity-5.14-r2393-m2386/tests/test_launcher_controller.cpp 2012-07-27 19:03:26.000000000 +0000 @@ -0,0 +1,202 @@ +/* + * Copyright 2012 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 3 along with this program. If not, see + * + * + * Authored by: Marco Trevisan (Treviño) + */ + +#include +#include "test_uscreen_mock.h" + +#include "FavoriteStore.h" +#include "LauncherController.h" +#include "LauncherControllerPrivate.h" +#include "PanelStyle.h" +#include "DashSettings.h" + +using namespace unity::launcher; +using namespace testing; + +namespace unity +{ + +class MockFavoriteStore : public FavoriteStore +{ +public: + FavoriteList const& GetFavorites() + { + return fav_list_; + }; + + void AddFavorite(std::string const& desktop_path, int position) {}; + void RemoveFavorite(std::string const& desktop_path) {}; + void MoveFavorite(std::string const& desktop_path, int position) {}; + void SetFavorites(FavoriteList const& desktop_paths) {}; + +private: + FavoriteList fav_list_; +}; + +namespace launcher +{ +class TestLauncherController : public testing::Test +{ +public: + TestLauncherController() + : lc(nux::GetGraphicsDisplay()->GetX11Display()) + {} + + virtual void SetUp() + { + lc.options = std::make_shared(); + lc.multiple_launchers = true; + } + +protected: + ui::EdgeBarrierController &GetBarrierController() + { + return lc.pimpl->edge_barriers_; + } + + MockUScreen uscreen; + dash::Settings settings; + panel::Style panel_style; + GeisAdapter geis_adapter; + MockFavoriteStore favorite_store; + Controller lc; +}; +} + +TEST_F(TestLauncherController, Construction) +{ + EXPECT_NE(lc.options(), nullptr); + EXPECT_TRUE(lc.multiple_launchers()); +} + +TEST_F(TestLauncherController, MultimonitorMultipleLaunchers) +{ + lc.multiple_launchers = true; + uscreen.SetupFakeMultiMonitor(); + + ASSERT_EQ(lc.launchers().size(), max_num_monitors); + + for (int i = 0; i < max_num_monitors; ++i) + { + EXPECT_EQ(lc.launchers()[i]->monitor(), i); + } +} + +TEST_F(TestLauncherController, MultimonitorSingleLauncher) +{ + lc.multiple_launchers = false; + uscreen.SetupFakeMultiMonitor(0, false); + + for (int i = 0; i < max_num_monitors; ++i) + { + uscreen.SetPrimary(i); + ASSERT_EQ(lc.launchers().size(), 1); + EXPECT_EQ(lc.launcher().monitor(), i); + } +} + +TEST_F(TestLauncherController, MultimonitorSwitchToMultipleLaunchers) +{ + lc.multiple_launchers = false; + uscreen.SetupFakeMultiMonitor(); + + ASSERT_EQ(lc.launchers().size(), 1); + + lc.multiple_launchers = true; + EXPECT_EQ(lc.launchers().size(), max_num_monitors); +} + +TEST_F(TestLauncherController, MultimonitorSwitchToSingleLauncher) +{ + lc.multiple_launchers = true; + int primary = 3; + uscreen.SetupFakeMultiMonitor(primary); + + ASSERT_EQ(lc.launchers().size(), max_num_monitors); + + lc.multiple_launchers = false; + EXPECT_EQ(lc.launchers().size(), 1); + EXPECT_EQ(lc.launcher().monitor(), primary); +} + +TEST_F(TestLauncherController, MultimonitorSwitchToSingleMonitor) +{ + uscreen.SetupFakeMultiMonitor(); + ASSERT_EQ(lc.launchers().size(), max_num_monitors); + + uscreen.Reset(); + EXPECT_EQ(lc.launchers().size(), 1); + EXPECT_EQ(lc.launcher().monitor(), 0); +} + +TEST_F(TestLauncherController, MultimonitorRemoveMiddleMonitor) +{ + uscreen.SetupFakeMultiMonitor(); + ASSERT_EQ(lc.launchers().size(), max_num_monitors); + + std::vector &monitors = uscreen.GetMonitors(); + monitors.erase(monitors.begin() + monitors.size()/2); + uscreen.changed.emit(uscreen.GetPrimaryMonitor(), uscreen.GetMonitors()); + ASSERT_EQ(lc.launchers().size(), max_num_monitors - 1); + + for (int i = 0; i < max_num_monitors - 1; ++i) + EXPECT_EQ(lc.launchers()[i]->monitor(), i); +} + +TEST_F(TestLauncherController, SingleMonitorSwitchToMultimonitor) +{ + ASSERT_EQ(lc.launchers().size(), 1); + + uscreen.SetupFakeMultiMonitor(); + + EXPECT_EQ(lc.launchers().size(), max_num_monitors); +} + +TEST_F(TestLauncherController, MultiMonitorEdgeBarrierSubscriptions) +{ + uscreen.SetupFakeMultiMonitor(); + + for (int i = 0; i < max_num_monitors; ++i) + ASSERT_EQ(GetBarrierController().GetSubscriber(i), lc.launchers()[i].GetPointer()); +} + +TEST_F(TestLauncherController, SingleMonitorEdgeBarrierSubscriptionsUpdates) +{ + lc.multiple_launchers = false; + uscreen.SetupFakeMultiMonitor(0, false); + + for (int i = 0; i < max_num_monitors; ++i) + { + uscreen.SetPrimary(i); + + for (int j = 0; j < max_num_monitors; ++j) + { + if (j == i) + { + ASSERT_EQ(GetBarrierController().GetSubscriber(j), &lc.launcher()); + } + else + { + ASSERT_EQ(GetBarrierController().GetSubscriber(j), nullptr); + } + } + } +} + +} diff -Nru unity-5.14-r2392-m2386/tests/test_uscreen_mock.h unity-5.14-r2393-m2386/tests/test_uscreen_mock.h --- unity-5.14-r2392-m2386/tests/test_uscreen_mock.h 1970-01-01 00:00:00.000000000 +0000 +++ unity-5.14-r2393-m2386/tests/test_uscreen_mock.h 2012-07-27 19:03:26.000000000 +0000 @@ -0,0 +1,85 @@ +/* + * Copyright 2012 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 3 along with this program. If not, see + * + * + * Authored by: Marco Trevisan (Treviño) + + */ + +#ifndef TEST_USCREEN_MOCK_H +#define TEST_USCREEN_MOCK_H + +#include "MultiMonitor.h" +#include "UScreen.h" + +namespace unity +{ + +const unsigned MONITOR_WIDTH = 1024; +const unsigned MONITOR_HEIGHT = 768; + +class MockUScreen : public UScreen +{ +public: + MockUScreen() + { + Reset(false); + } + + ~MockUScreen() + { + if (default_screen_ == this) + default_screen_ = nullptr; + } + + void Reset(bool emit = true) + { + default_screen_ = this; + primary_ = 0; + monitors_ = {nux::Geometry(0, 0, MONITOR_WIDTH, MONITOR_HEIGHT)}; + + changed.emit(primary_, monitors_); + } + + void SetupFakeMultiMonitor(int primary = 0, bool emit_update = true) + { + SetPrimary(primary, false); + monitors_.clear(); + + for (int i = 0, total_width = 0; i < max_num_monitors; ++i) + { + monitors_.push_back(nux::Geometry(MONITOR_WIDTH, MONITOR_HEIGHT, total_width, 0)); + total_width += MONITOR_WIDTH; + + if (emit_update) + changed.emit(GetPrimaryMonitor(), GetMonitors()); + } + } + + void SetPrimary(int primary, bool emit = true) + { + if (primary_ != primary) + { + primary_ = primary; + + if (emit) + changed.emit(primary_, monitors_); + } + } +}; + +} + +#endif \ No newline at end of file