diff options
| -rw-r--r-- | launcher/SwitcherController.cpp | 14 | ||||
| -rw-r--r-- | launcher/SwitcherModel.cpp | 23 | ||||
| -rw-r--r-- | plugins/unityshell/src/inputremover.cpp | 9 | ||||
| -rw-r--r-- | services/panel-indicator-entry-accessible.c | 2 |
4 files changed, 34 insertions, 14 deletions
diff --git a/launcher/SwitcherController.cpp b/launcher/SwitcherController.cpp index 3f7983372..5f9c6e3f0 100644 --- a/launcher/SwitcherController.cpp +++ b/launcher/SwitcherController.cpp @@ -325,11 +325,18 @@ void Controller::Impl::Show(ShowMode show_mode, SortMode sort_mode, std::vector< model_->selection_changed.connect(sigc::mem_fun(this, &Controller::Impl::OnModelSelectionChanged)); model_->detail_selection.changed.connect([this] (bool) { sources_.Remove(DETAIL_TIMEOUT); }); model_->updated.connect([this] { if (!model_->Size()) Hide(false); }); - obj_->AddChild(model_.get()); + + if (!model_->Size()) + { + model_.reset(); + return; + } SelectFirstItem(); + obj_->AddChild(model_.get()); obj_->visible_ = true; + int real_wait = obj_->timeout_length() - fade_animator_.Duration(); if (real_wait > 0) @@ -442,7 +449,6 @@ void Controller::Impl::ConstructView() sources_.Remove(VIEW_CONSTRUCT_IDLE); view_ = SwitcherView::Ptr(new SwitcherView(icon_renderer_)); - obj_->AddChild(view_.GetPointer()); view_->SetModel(model_); view_->background_color = WindowManager::Default().average_color(); view_->monitor = obj_->monitor_; @@ -462,6 +468,7 @@ void Controller::Impl::ConstructView() view_->switcher_start_detail.connect(sigc::mem_fun(this, &Impl::StartDetailMode)); view_->switcher_stop_detail.connect(sigc::mem_fun(this, &Impl::StopDetailMode)); view_->switcher_close_current.connect(sigc::mem_fun(this, &Impl::CloseSelection)); + obj_->AddChild(view_.GetPointer()); ConstructWindow(); main_layout_->AddView(view_.GetPointer(), 1); @@ -507,6 +514,9 @@ void Controller::Impl::HideWindow() view_window_->ShowWindow(false); view_window_->PushToBack(); + obj_->RemoveChild(model_.get()); + obj_->RemoveChild(view_.GetPointer()); + model_.reset(); view_.Release(); } diff --git a/launcher/SwitcherModel.cpp b/launcher/SwitcherModel.cpp index bfe882fe2..4d8889435 100644 --- a/launcher/SwitcherModel.cpp +++ b/launcher/SwitcherModel.cpp @@ -309,7 +309,7 @@ size_t SwitcherModel::Size() const AbstractLauncherIcon::Ptr SwitcherModel::Selection() const { - return applications_.at(index_); + return index_ < applications_.size() ? applications_.at(index_) : AbstractLauncherIcon::Ptr(); } int SwitcherModel::SelectionIndex() const @@ -319,7 +319,8 @@ int SwitcherModel::SelectionIndex() const bool SwitcherModel::SelectionIsActive() const { - return Selection()->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE); + auto const& selection = Selection(); + return selection ? selection->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) : false; } AbstractLauncherIcon::Ptr SwitcherModel::LastSelection() const @@ -344,8 +345,12 @@ std::vector<Window> SwitcherModel::SelectionWindows() const WindowManager& wm = WindowManager::Default(); std::vector<Window> results; + auto const& selection = Selection(); - for (auto& window : Selection()->Windows()) + if (!selection) + return results; + + for (auto& window : selection->Windows()) { Window xid = window->window_id(); @@ -360,7 +365,7 @@ std::vector<Window> SwitcherModel::SelectionWindows() const return wm.GetWindowActiveNumber(first) > wm.GetWindowActiveNumber(second); }); - if (Selection() == last_active_application_) + if (selection == last_active_application_) { results.push_back(results.front()); results.erase(results.begin()); @@ -397,6 +402,9 @@ void SwitcherModel::UnsetDetailSelection() void SwitcherModel::NextIndex() { + if (applications_.empty()) + return; + last_index_ = index_; ++index_ %= applications_.size(); } @@ -410,6 +418,9 @@ void SwitcherModel::Next() void SwitcherModel::PrevIndex() { + if (applications_.empty()) + return; + last_index_ = index_; index_ = ((index_ > 0 && index_ < applications_.size()) ? index_ : applications_.size()) - 1; } @@ -423,7 +434,7 @@ void SwitcherModel::Prev() void SwitcherModel::NextDetail() { - if (!detail_selection()) + if (!detail_selection() || detail_xids_.empty()) return; detail_selection_index = (detail_selection_index + 1) % detail_xids_.size(); @@ -432,7 +443,7 @@ void SwitcherModel::NextDetail() void SwitcherModel::PrevDetail() { - if (!detail_selection()) + if (!detail_selection() || detail_xids_.empty()) return; detail_selection_index = ((detail_selection_index() > 0) ? detail_selection_index : detail_xids_.size()) - 1; diff --git a/plugins/unityshell/src/inputremover.cpp b/plugins/unityshell/src/inputremover.cpp index b28e7a1e2..ec09f9eeb 100644 --- a/plugins/unityshell/src/inputremover.cpp +++ b/plugins/unityshell/src/inputremover.cpp @@ -19,12 +19,12 @@ * Sam Spilsbury <sam.spilsbury@canonical.com> */ -#include <cstdlib> -#include <boost/scoped_array.hpp> #include "inputremover.h" +#include <cstdlib> #include <X11/Xregion.h> #include <cstdio> #include <cstring> +#include <vector> namespace { @@ -347,8 +347,7 @@ compiz::WindowInputRemover::writeProperty (XRectangle *input, */ const size_t dataSize = headerSize + (nInput * 4); - boost::scoped_array<unsigned long> data(new unsigned long[dataSize]); - + std::vector<unsigned long> data(dataSize); data[0] = propVersion; data[1] = nInput; data[2] = inputOrdering; @@ -370,7 +369,7 @@ compiz::WindowInputRemover::writeProperty (XRectangle *input, type, fmt, PropModeReplace, - reinterpret_cast<unsigned char*>(data.get()), + reinterpret_cast<unsigned char*>(data.data()), dataSize); return true; diff --git a/services/panel-indicator-entry-accessible.c b/services/panel-indicator-entry-accessible.c index 459812dff..55f45d297 100644 --- a/services/panel-indicator-entry-accessible.c +++ b/services/panel-indicator-entry-accessible.c @@ -293,7 +293,7 @@ panel_indicator_entry_accessible_ref_child (AtkObject *accessible, gint i) g_return_val_if_fail (PANEL_IS_INDICATOR_ENTRY_ACCESSIBLE (accessible), NULL); piea = PANEL_INDICATOR_ENTRY_ACCESSIBLE (accessible); - if (piea->priv->entry->parent_object && GTK_IS_MENU (piea->priv->entry->menu)) + if (piea->priv->entry && piea->priv->entry->parent_object && GTK_IS_MENU (piea->priv->entry->menu)) { child = gtk_widget_get_accessible (GTK_WIDGET (piea->priv->entry->menu)); atk_object_set_parent (child, accessible); |
