diff options
| author | Brandon Schaefer <brandontschaefer@gmail.com> | 2012-07-27 12:32:41 -0700 |
|---|---|---|
| committer | Brandon Schaefer <brandontschaefer@gmail.com> | 2012-07-27 12:32:41 -0700 |
| commit | e1412231dd80260409dbfd6941aa8a706e0225a3 (patch) | |
| tree | 7eef90e51f90c612dc995550679722b98abc527f /launcher | |
| parent | 85279f4dccd9f49aec4a4c148830b078a2de06e9 (diff) | |
| parent | 0d0b998a22cc38adcb223c95078e771a31a11533 (diff) | |
*Merged trunk. Fixed an AP test
(bzr r2520.6.4)
Diffstat (limited to 'launcher')
| -rw-r--r-- | launcher/EdgeBarrierController.cpp | 23 | ||||
| -rw-r--r-- | launcher/EdgeBarrierController.h | 1 | ||||
| -rw-r--r-- | launcher/LauncherController.cpp | 166 | ||||
| -rw-r--r-- | launcher/LauncherController.h | 2 | ||||
| -rw-r--r-- | launcher/LauncherControllerPrivate.h | 163 | ||||
| -rw-r--r-- | launcher/SwitcherModel.cpp | 4 | ||||
| -rw-r--r-- | launcher/SwitcherModel.h | 2 |
7 files changed, 206 insertions, 155 deletions
diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp index f01e1090d..8bfa1ebac 100644 --- a/launcher/EdgeBarrierController.cpp +++ b/launcher/EdgeBarrierController.cpp @@ -15,6 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Authored by: Jason Smith <jason.smith@canonical.com> + * Marco Trevisan <marco.trevisan@canonical.com> */ #include "EdgeBarrierController.h" @@ -157,7 +158,7 @@ void EdgeBarrierController::Impl::OnPointerBarrierEvent(PointerBarrierWrapper* o unsigned int monitor = owner->index; bool process = true; - if (monitor <= subscribers_.size()) + if (monitor < subscribers_.size()) { auto subscriber = subscribers_[monitor]; @@ -206,20 +207,32 @@ EdgeBarrierController::~EdgeBarrierController() void EdgeBarrierController::Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor) { - if (pimpl->subscribers_.size() <= monitor) + if (monitor >= pimpl->subscribers_.size()) pimpl->subscribers_.resize(monitor + 1); + auto const& monitors = UScreen::GetDefault()->GetMonitors(); pimpl->subscribers_[monitor] = subscriber; - pimpl->SetupBarriers(UScreen::GetDefault()->GetMonitors()); + pimpl->ResizeBarrierList(monitors); + pimpl->SetupBarriers(monitors); } void EdgeBarrierController::Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor) { - if (pimpl->subscribers_.size() < 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->SetupBarriers(UScreen::GetDefault()->GetMonitors()); + pimpl->ResizeBarrierList(monitors); + pimpl->SetupBarriers(monitors); +} + +EdgeBarrierSubscriber* EdgeBarrierController::GetSubscriber(unsigned int monitor) +{ + if (monitor >= pimpl->subscribers_.size()) + return nullptr; + + return pimpl->subscribers_[monitor]; } void EdgeBarrierController::ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) diff --git a/launcher/EdgeBarrierController.h b/launcher/EdgeBarrierController.h index 92295dde0..6096f706a 100644 --- a/launcher/EdgeBarrierController.h +++ b/launcher/EdgeBarrierController.h @@ -43,6 +43,7 @@ public: void Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); void Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor); + EdgeBarrierSubscriber* GetSubscriber(unsigned int monitor); protected: void ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event); diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index 6db3f0b24..edc8192fa 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -30,23 +30,15 @@ #include "BamfLauncherIcon.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 "SoftwareCenterLauncherIcon.h" -#include "LauncherModel.h" -#include "VolumeMonitorWrapper.h" #include "unity-shared/WindowManager.h" #include "TrashLauncherIcon.h" #include "BFBLauncherIcon.h" #include "unity-shared/UScreen.h" -#include "unity-shared/UBusWrapper.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/TimeUtil.h" @@ -93,120 +85,7 @@ namespace } } -class Controller::Impl -{ -public: - Impl(Display* display, Controller* parent); - ~Impl(); - - void UpdateNumWorkspaces(int workspaces); - - Launcher* CreateLauncher(int monitor); - - void Save(); - void SortAndUpdate(); - - nux::ObjectPtr<Launcher> CurrentLauncher(); - - void OnIconAdded(AbstractLauncherIcon::Ptr icon); - void OnIconRemoved(AbstractLauncherIcon::Ptr icon); - - void OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before); - void OnLauncherAddRequestSpecial(std::string const& path, 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<nux::Geometry> const& monitors); - - void OnExpoActivated(); - - void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& 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); - - static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data); - static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender, const gchar* object_path, - const gchar* interface_name, const gchar* method_name, - GVariant* parameters, GDBusMethodInvocation* invocation, - gpointer user_data); - - static GDBusInterfaceVTable interface_vtable; - - Controller* parent_; - LauncherModel::Ptr model_; - nux::ObjectPtr<Launcher> launcher_; - nux::ObjectPtr<Launcher> keyboard_launcher_; - int sort_priority_; - AbstractVolumeMonitorWrapper::Ptr volume_monitor_; - DeviceLauncherSection device_section_; - LauncherEntryRemoteModel remote_model_; - AbstractLauncherIcon::Ptr expo_icon_; - AbstractLauncherIcon::Ptr desktop_icon_; - int num_workspaces_; - bool show_desktop_icon_; - Display* display_; - - bool launcher_open; - bool launcher_keynav; - bool launcher_grabbed; - bool reactivate_keynav; - int reactivate_index; - bool keynav_restore_window_; - int launcher_key_press_time_; - unsigned int dbus_owner_; - - ui::EdgeBarrierController edge_barriers_; - - LauncherList launchers; - - glib::Object<BamfMatcher> matcher_; - glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_; - glib::SourceManager sources_; - UBusManager ubus; - - sigc::connection on_expoicon_activate_connection_; - sigc::connection launcher_key_press_connection_; - sigc::connection launcher_event_outside_connection_; -}; GDBusInterfaceVTable Controller::Impl::interface_vtable = { Controller::Impl::OnDBusMethodCall, NULL, NULL}; @@ -316,41 +195,35 @@ void Controller::Impl::EnsureLaunchers(int primary, std::vector<nux::Geometry> c 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<Launcher>(CreateLauncher(primary))); + launchers.push_back(nux::ObjectPtr<Launcher>(CreateLauncher(i))); } - else if (!launchers[0].IsValid()) + else if (!launchers[i]) { - launchers[0] = nux::ObjectPtr<Launcher>(CreateLauncher(primary)); + launchers[i] = nux::ObjectPtr<Launcher>(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<Launcher>(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(); @@ -359,11 +232,6 @@ void Controller::Impl::EnsureLaunchers(int primary, std::vector<nux::Geometry> c } 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<nux::Geometry>& monitors) diff --git a/launcher/LauncherController.h b/launcher/LauncherController.h index 36ceb7912..3e5dec6b0 100644 --- a/launcher/LauncherController.h +++ b/launcher/LauncherController.h @@ -35,6 +35,7 @@ namespace launcher class AbstractLauncherIcon; class Launcher; class LauncherModel; +class TestLauncherController; class Controller : public unity::debug::Introspectable, public sigc::trackable { @@ -86,6 +87,7 @@ protected: void AddProperties(GVariantBuilder* builder); private: + friend class TestLauncherController; class Impl; std::unique_ptr<Impl> pimpl; }; diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h new file mode 100644 index 000000000..2eb1a1f9a --- /dev/null +++ b/launcher/LauncherControllerPrivate.h @@ -0,0 +1,163 @@ +/* + * 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 + * <http://www.gnu.org/licenses/> + * + * Authored by: Jason Smith <jason.smith@canonical.com> + * Tim Penhey <tim.penhey@canonical.com> + * Marco Trevisan (TreviƱo) <marco.trevisan@canonical.com> + * + */ + +#ifndef LAUNCHER_CONTROLLER_PRIVATE_H +#define LAUNCHER_CONTROLLER_PRIVATE_H + +#include <Nux/Nux.h> + +#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 "unity-shared/UBusWrapper.h" +#include "VolumeMonitorWrapper.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<Launcher> CurrentLauncher(); + + void OnIconAdded(AbstractLauncherIcon::Ptr icon); + void OnIconRemoved(AbstractLauncherIcon::Ptr icon); + + void OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before); + void OnLauncherAddRequestSpecial(std::string const& path, 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<nux::Geometry> const& monitors); + + void OnExpoActivated(); + + void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& 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); + + static void OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data); + static void OnDBusMethodCall(GDBusConnection* connection, const gchar* sender, const gchar* object_path, + const gchar* interface_name, const gchar* method_name, + GVariant* parameters, GDBusMethodInvocation* invocation, + gpointer user_data); + + static GDBusInterfaceVTable interface_vtable; + + Controller* parent_; + LauncherModel::Ptr model_; + nux::ObjectPtr<Launcher> launcher_; + nux::ObjectPtr<Launcher> keyboard_launcher_; + int sort_priority_; + AbstractVolumeMonitorWrapper::Ptr volume_monitor_; + DeviceLauncherSection device_section_; + LauncherEntryRemoteModel remote_model_; + AbstractLauncherIcon::Ptr expo_icon_; + AbstractLauncherIcon::Ptr desktop_icon_; + int num_workspaces_; + bool show_desktop_icon_; + Display* display_; + + bool launcher_open; + bool launcher_keynav; + bool launcher_grabbed; + bool reactivate_keynav; + int reactivate_index; + bool keynav_restore_window_; + int launcher_key_press_time_; + unsigned int dbus_owner_; + + ui::EdgeBarrierController edge_barriers_; + + LauncherList launchers; + + glib::Object<BamfMatcher> matcher_; + glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_; + glib::SourceManager sources_; + UBusManager ubus; + + sigc::connection on_expoicon_activate_connection_; + sigc::connection launcher_key_press_connection_; + sigc::connection launcher_event_outside_connection_; +}; + +} // launcher namespace +} // unity namespace + +#endif diff --git a/launcher/SwitcherModel.cpp b/launcher/SwitcherModel.cpp index 600c2fea8..3f94e88f9 100644 --- a/launcher/SwitcherModel.cpp +++ b/launcher/SwitcherModel.cpp @@ -42,6 +42,8 @@ SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon::Ptr> icons) for (auto icon : _inner) { AddChild(icon.GetPointer()); + if (icon->GetQuirk(AbstractLauncherIcon::QUIRK_ACTIVE)) + _last_active_icon = icon; } } @@ -157,7 +159,7 @@ SwitcherModel::DetailXids() std::sort (results.begin (), results.end (), &CompareWindowsByActive); // swap so we focus the last focused window first - if (Selection()->GetQuirk (AbstractLauncherIcon::QUIRK_ACTIVE) && results.size () > 1) + if (Selection() == _last_active_icon && results.size () > 1) std::swap (results[0], results[1]); return results; diff --git a/launcher/SwitcherModel.h b/launcher/SwitcherModel.h index 1e539fbd5..41d56b5f0 100644 --- a/launcher/SwitcherModel.h +++ b/launcher/SwitcherModel.h @@ -97,6 +97,8 @@ private: Base _inner; unsigned int _index; unsigned int _last_index; + + launcher::AbstractLauncherIcon::Ptr _last_active_icon; }; } |
