diff options
| author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2015-05-22 13:20:36 +0000 |
|---|---|---|
| committer | CI Train Bot <ci-train-bot@canonical.com> | 2015-05-22 13:20:36 +0000 |
| commit | e5e35384bf653cfd46783d5ccdd8996c527e6929 (patch) | |
| tree | 5c6b8ffcb90d37af6f41cd4d6273ab2e4f22bd25 | |
| parent | 4a62a9bfe09630a9175772a637b0b3cebaaceb49 (diff) | |
| parent | eee51d8b68e6c7d22e67fc9aef0b7ec50322b867 (diff) | |
ResultViewGrid: wait for double-click event only if the relative result needs the Preview
This was causing a 500ms delay between the user click and some results (apps) activation. Also, at this point, we can get rid of PREVIEW_LEFT_BUTTON activation type. Fixes: #1291950, #1447372 Approved by: Christopher Townsend, Brandon Schaefer, PS Jenkins bot (bzr r3967)
| -rw-r--r-- | dash/DashController.h | 1 | ||||
| -rw-r--r-- | dash/DashView.cpp | 56 | ||||
| -rw-r--r-- | dash/DashView.h | 4 | ||||
| -rw-r--r-- | dash/ResultView.cpp | 25 | ||||
| -rw-r--r-- | dash/ResultView.h | 10 | ||||
| -rw-r--r-- | dash/ResultViewGrid.cpp | 29 | ||||
| -rwxr-xr-x | dash/ScopeView.cpp | 31 | ||||
| -rw-r--r-- | hud/HudButton.cpp | 5 | ||||
| -rw-r--r-- | hud/HudController.h | 1 | ||||
| -rw-r--r-- | launcher/DeviceNotificationDisplayImp.cpp | 1 | ||||
| -rw-r--r-- | unity-shared/BGHash.cpp | 7 | ||||
| -rw-r--r-- | unity-shared/SearchBar.cpp | 32 | ||||
| -rw-r--r-- | unity-shared/SearchBar.h | 4 |
13 files changed, 103 insertions, 103 deletions
diff --git a/dash/DashController.h b/dash/DashController.h index ac5c12d93..6228a458e 100644 --- a/dash/DashController.h +++ b/dash/DashController.h @@ -21,7 +21,6 @@ #include <memory> -#include <gdk/gdk.h> #include <UnityCore/ConnectionManager.h> #include <UnityCore/GLibDBusServer.h> #include <UnityCore/GLibSignal.h> diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 4b5609fb3..a0c97c673 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -59,7 +59,7 @@ const RawPixel PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET = 10_em; const RawPixel PREVIEW_CONTAINER_TRIANGLE_WIDTH = 14_em; const RawPixel PREVIEW_CONTAINER_TRIANGLE_HEIGHT = 12_em; -const int MAX_ENTRY_ACTIVATE_WAIT_TIMEOUT = 1000; +const int MAX_ENTRY_ACTIVATE_WAIT_TIMEOUT = 300; } // This is so we can access some protected members in nux::VLayout and @@ -120,7 +120,6 @@ DashView::DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& app , preview_displaying_(false) , preview_navigation_mode_(previews::Navigation::NONE) , last_activated_timestamp_(0) - , search_in_progress_(false) , activate_on_finish_(false) , visible_(false) , opening_column_x_(-1) @@ -1222,21 +1221,27 @@ void DashView::UpdateScopeFilterValue(Filter::Ptr filter, std::string value) void DashView::OnSearchChanged(std::string const& search_string) { - search_in_progress_ = true; + activate_on_finish_ = false; } void DashView::OnLiveSearchReached(std::string const& search_string) { - // reset and set it again once we're sure a search is happening - search_in_progress_ = false; - LOG_DEBUG(logger) << "Live search reached: " << search_string; - if (active_scope_view_) + if (!active_scope_view_.IsValid()) + return; + + if (active_scope_view_->PerformSearch(search_string, sigc::mem_fun(this, &DashView::OnScopeSearchFinished))) { - if (active_scope_view_->PerformSearch(search_string, sigc::mem_fun(this, &DashView::OnScopeSearchFinished))) - { - search_in_progress_ = true; - } + activate_delay_.reset(new glib::Timeout(MAX_ENTRY_ACTIVATE_WAIT_TIMEOUT, [this] { + if (activate_on_finish_) + { + activate_on_finish_ = false; + active_scope_view_->ActivateFirst(); + } + + activate_delay_.reset(); + return false; + })); } } @@ -1255,12 +1260,15 @@ void DashView::OnScopeSearchFinished(std::string const& scope_id, std::string co LOG_DEBUG(logger) << "Search completed: " << search_string; search_bar_->SetSearchFinished(); - search_in_progress_ = false; - activate_timeout_.reset(); - if (activate_on_finish_ && !err) - OnEntryActivated(); - activate_on_finish_= false; + if (activate_on_finish_) + { + activate_on_finish_ = false; + activate_delay_.reset(); + + if (!err) + active_scope_view_->ActivateFirst(); + } } } @@ -1408,20 +1416,12 @@ void DashView::DisableBlur() } void DashView::OnEntryActivated() { - if (active_scope_view_.IsValid() && !search_in_progress_) - { - active_scope_view_->ActivateFirst(); - } - // delay the activation until we get the SearchFinished signal - activate_on_finish_ = search_in_progress_; - - if (activate_on_finish_) + if (active_scope_view_.IsValid()) { - activate_timeout_.reset(new glib::Timeout(MAX_ENTRY_ACTIVATE_WAIT_TIMEOUT, [this] { - activate_on_finish_ = false; + if (!activate_delay_ && !search_bar_->in_live_search()) active_scope_view_->ActivateFirst(); - return FALSE; - })); + else + activate_on_finish_ = true; } } diff --git a/dash/DashView.h b/dash/DashView.h index b69f2b17d..5c7e5c0e6 100644 --- a/dash/DashView.h +++ b/dash/DashView.h @@ -170,10 +170,8 @@ private: LocalResult last_activated_result_; guint64 last_activated_timestamp_; - bool search_in_progress_; bool activate_on_finish_; - glib::Source::UniquePtr activate_timeout_; - + glib::Source::UniquePtr activate_delay_; bool visible_; nux::ObjectPtr<nux::IOpenGLBaseTexture> dash_view_copy_; diff --git a/dash/ResultView.cpp b/dash/ResultView.cpp index 110f4a5d9..a21bc3f86 100644 --- a/dash/ResultView.cpp +++ b/dash/ResultView.cpp @@ -23,6 +23,7 @@ #include "ResultView.h" +#include <boost/algorithm/string.hpp> #include <Nux/Layout.h> #include "unity-shared/IntrospectableWrappers.h" @@ -49,6 +50,7 @@ ResultView::ResultView(NUX_FILE_LINE_DECL) , scale(DEFAULT_SCALE) , renderer_(NULL) , cached_result_(nullptr, nullptr, nullptr) + , default_click_activation_(ActivateType::PREVIEW) { expanded.changed.connect([this](bool value) { @@ -61,6 +63,21 @@ ResultView::ResultView(NUX_FILE_LINE_DECL) NeedRedraw(); }); + default_click_activation.SetGetterFunction([this] { + if (Settings::Instance().double_click_activate()) + return default_click_activation_; + return ActivateType::DIRECT; + }); + + default_click_activation.SetSetterFunction([this] (ActivateType at) { + if (default_click_activation_ != at) + { + default_click_activation_ = at; + return true; + } + return false; + }); + Settings::Instance().font_scaling.changed.connect(sigc::mem_fun(this, &ResultView::UpdateFontScale)); enable_texture_render.changed.connect(sigc::mem_fun(this, &ResultView::OnEnableRenderToTexture)); scale.changed.connect(sigc::mem_fun(this, &ResultView::UpdateScale)); @@ -208,6 +225,14 @@ LocalResult ResultView::GetLocalResultForIndex(unsigned int index) return LocalResult(*GetIteratorAtRow(index)); } +ResultView::ActivateType ResultView::GetLocalResultActivateType(LocalResult const& result) const +{ + if (boost::starts_with(result.uri, "x-unity-no-preview")) + return ActivateType::DIRECT; + + return ActivateType::PREVIEW; +} + void ResultView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) {} diff --git a/dash/ResultView.h b/dash/ResultView.h index 0b7a578ff..2a5cb07a3 100644 --- a/dash/ResultView.h +++ b/dash/ResultView.h @@ -58,12 +58,11 @@ struct ResultViewTexture class ResultView : public nux::View, public debug::Introspectable { public: - typedef enum ActivateType_ + enum class ActivateType { DIRECT, - PREVIEW_LEFT_BUTTON, PREVIEW - } ActivateType; + }; NUX_DECLARE_OBJECT_TYPE(ResultView, nux::View); @@ -73,8 +72,9 @@ public: void SetModelRenderer(ResultRenderer* renderer); void SetResultsModel(Results::Ptr const& results); - unsigned int GetIndexForLocalResult(LocalResult const& local_result); + unsigned int GetIndexForLocalResult(LocalResult const&); LocalResult GetLocalResultForIndex(unsigned int); + ActivateType GetLocalResultActivateType(LocalResult const&) const; nux::Property<bool> expanded; nux::Property<int> results_per_row; @@ -82,6 +82,7 @@ public: nux::Property<float> desaturation_progress; nux::Property<bool> enable_texture_render; nux::Property<double> scale; + nux::RWProperty<ActivateType> default_click_activation; sigc::signal<void, LocalResult const&, ActivateType, GVariant*> ResultActivated; @@ -130,6 +131,7 @@ private: void UpdateFontScale(double scale); Result cached_result_; + ActivateType default_click_activation_; connection::Manager result_connections_; }; diff --git a/dash/ResultViewGrid.cpp b/dash/ResultViewGrid.cpp index 70872e449..c57ad02ef 100644 --- a/dash/ResultViewGrid.cpp +++ b/dash/ResultViewGrid.cpp @@ -24,8 +24,6 @@ #include <NuxCore/Logger.h> #include <Nux/VLayout.h> #include <NuxGraphics/GdkGraphics.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> #include <unity-protocol.h> #include "unity-shared/IntrospectableWrappers.h" @@ -34,7 +32,6 @@ #include "unity-shared/UBusMessages.h" #include "unity-shared/GraphicsUtils.h" #include "unity-shared/RawPixel.h" -#include "unity-shared/UnitySettings.h" #include "unity-shared/WindowManager.h" #include "ResultViewGrid.h" #include "math.h" @@ -94,8 +91,7 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL) scale.changed.connect(sigc::mem_fun(this, &ResultViewGrid::UpdateScale)); key_nav_focus_change.connect(sigc::mem_fun(this, &ResultViewGrid::OnKeyNavFocusChange)); - key_nav_focus_activate.connect([this] (nux::Area *area) - { + key_nav_focus_activate.connect([this] (nux::Area *area) { Activate(focused_result_, selected_index_, ResultView::ActivateType::DIRECT); }); key_down.connect(sigc::mem_fun(this, &ResultViewGrid::OnKeyDown)); @@ -210,6 +206,12 @@ void ResultViewGrid::Activate(LocalResult const& local_result, int index, Result row_y += row_index * row_height; } + if (type == ActivateType::PREVIEW) + { + if (GetLocalResultActivateType(local_result) != type) + type = ActivateType::DIRECT; + } + active_index_ = index; guint64 timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp; glib::Variant data(g_variant_new("(tiiiiii)", timestamp, column_x, row_y, column_width, row_height, left_results, right_results)); @@ -796,6 +798,7 @@ void ResultViewGrid::MouseClick(int x, int y, unsigned long button_flags, unsign unsigned num_results = GetNumResults(); unsigned index = GetIndexAtPosition(x, y); mouse_over_index_ = index; + if (index < num_results) { // we got a click on a button so activate it @@ -805,32 +808,32 @@ void ResultViewGrid::MouseClick(int x, int y, unsigned long button_flags, unsign focused_result_ = result; activated_result_ = result; - if (nux::GetEventButton(button_flags) == nux::NUX_MOUSE_BUTTON1) { - if (unity::Settings::Instance().double_click_activate) + if (default_click_activation() == ActivateType::PREVIEW && + GetLocalResultActivateType(activated_result_) == ActivateType::PREVIEW) { // delay activate for single left click. (for double click check) - activate_timer_.reset(new glib::Timeout(DOUBLE_CLICK_SPEED, [this, index]() { - Activate(activated_result_, index, ResultView::ActivateType::PREVIEW_LEFT_BUTTON); + activate_timer_.reset(new glib::Timeout(DOUBLE_CLICK_SPEED, [this, index] { + Activate(activated_result_, index, ActivateType::PREVIEW); return false; })); } else { - Activate(activated_result_, index, ResultView::ActivateType::DIRECT); + Activate(activated_result_, index, ActivateType::DIRECT); } } else { - Activate(activated_result_, index, ResultView::ActivateType::PREVIEW); + Activate(activated_result_, index, ActivateType::PREVIEW); } } } void ResultViewGrid::MouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags) { - if (unity::Settings::Instance().double_click_activate == false) + if (default_click_activation() == ActivateType::DIRECT) return; unsigned num_results = GetNumResults(); @@ -845,7 +848,7 @@ void ResultViewGrid::MouseDoubleClick(int x, int y, unsigned long button_flags, focused_result_ = result; activated_result_ = result; - Activate(activated_result_, index, ResultView::ActivateType::DIRECT); + Activate(activated_result_, index, ActivateType::DIRECT); } } diff --git a/dash/ScopeView.cpp b/dash/ScopeView.cpp index 8465c5da0..7a43c4de9 100755 --- a/dash/ScopeView.cpp +++ b/dash/ScopeView.cpp @@ -481,47 +481,40 @@ void ScopeView::OnCategoryAdded(Category const& category) /* Reset result count */ counts_[group] = 0; - ResultView* results_view = nullptr; + auto* results_view = new ResultViewGrid(NUX_TRACKER_LOCATION); + if (category.GetContentType() == "social" && category.renderer_name == "default") { - results_view = new ResultViewGrid(NUX_TRACKER_LOCATION); results_view->SetModelRenderer(new ResultRendererHorizontalTile(NUX_TRACKER_LOCATION)); - static_cast<ResultViewGrid*> (results_view)->horizontal_spacing = CARD_VIEW_GAP_HORIZ.CP(scale()); - static_cast<ResultViewGrid*> (results_view)->vertical_spacing = CARD_VIEW_GAP_VERT.CP(scale()); + results_view->horizontal_spacing = CARD_VIEW_GAP_HORIZ.CP(scale()); + results_view->vertical_spacing = CARD_VIEW_GAP_VERT.CP(scale()); } else { - results_view = new ResultViewGrid(NUX_TRACKER_LOCATION); results_view->SetModelRenderer(new ResultRendererTile(NUX_TRACKER_LOCATION)); } if (scope_) { - const std::string category_id = category.id(); - std::string unique_id = category.name() + scope_->name(); - results_view->unique_id = unique_id; + results_view->unique_id = name + scope_->name(); results_view->expanded = false; - results_view->ResultActivated.connect([this, unique_id, category_id] (LocalResult const& local_result, ResultView::ActivateType type, GVariant* data) + if (scope_->id() == "applications.scope" || + (scope_->id() == "home.scope" && category.id() == "applications.scope")) { - if (g_str_has_prefix(local_result.uri.c_str(), "x-unity-no-preview")) - type = ResultView::ActivateType::DIRECT; - - // Applications scope results should be activated on left-click (instead of preview). Note that app scope can still - // respond with preview for activation request (the case for uninstalled apps). - bool is_app_scope_result = (scope_->id() == "applications.scope" || (scope_->id() == "home.scope" && category_id == "applications.scope")); + results_view->default_click_activation = ResultView::ActivateType::DIRECT; + } - if (is_app_scope_result && type == ResultView::ActivateType::PREVIEW_LEFT_BUTTON) - type = ResultView::ActivateType::DIRECT; + results_view->ResultActivated.connect([this, results_view] (LocalResult const& local_result, ResultView::ActivateType type, GVariant* data) + { + result_activated.emit(type, local_result, data, results_view->unique_id()); - result_activated.emit(type, local_result, data, unique_id); switch (type) { case ResultView::ActivateType::DIRECT: { scope_->Activate(local_result, nullptr, cancellable_); } break; - case ResultView::ActivateType::PREVIEW_LEFT_BUTTON: case ResultView::ActivateType::PREVIEW: { scope_->Preview(local_result, nullptr, cancellable_); diff --git a/hud/HudButton.cpp b/hud/HudButton.cpp index 65aafaa45..252ef8d74 100644 --- a/hud/HudButton.cpp +++ b/hud/HudButton.cpp @@ -20,11 +20,6 @@ */ #include "config.h" -#include <pango/pango.h> -#include <pango/pangocairo.h> -#include <gdk/gdk.h> -#include <gtk/gtk.h> - #include <Nux/Nux.h> #include <Nux/HLayout.h> #include <NuxGraphics/CairoGraphics.h> diff --git a/hud/HudController.h b/hud/HudController.h index 559da31e1..a2421aef9 100644 --- a/hud/HudController.h +++ b/hud/HudController.h @@ -22,7 +22,6 @@ #include <functional> #include <memory> -#include <gdk/gdk.h> #include <UnityCore/Hud.h> #include <UnityCore/GLibSignal.h> diff --git a/launcher/DeviceNotificationDisplayImp.cpp b/launcher/DeviceNotificationDisplayImp.cpp index 62f2e5584..6bc647950 100644 --- a/launcher/DeviceNotificationDisplayImp.cpp +++ b/launcher/DeviceNotificationDisplayImp.cpp @@ -17,7 +17,6 @@ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> */ -#include <gdk/gdk.h> #include "config.h" #include <glib/gi18n-lib.h> #include <libnotify/notify.h> diff --git a/unity-shared/BGHash.cpp b/unity-shared/BGHash.cpp index c2f065383..d0ec71b8e 100644 --- a/unity-shared/BGHash.cpp +++ b/unity-shared/BGHash.cpp @@ -116,8 +116,11 @@ void BGHash::TransitionToNewColor(nux::color::Color const& new_color, bool skip_ .SetDuration(skip_animation ? 0 : TRANSITION_DURATION) .Start(); - // This will make sure that the animation starts even if the screen is idle. - nux::GetWindowThread()->RequestRedraw(); + if (nux::WindowThread* wt = nux::GetWindowThread()) + { + // This will make sure that the animation starts even if the screen is idle. + wt->RequestRedraw(); + } } void BGHash::OnTransitionUpdated(nux::Color const& new_color) diff --git a/unity-shared/SearchBar.cpp b/unity-shared/SearchBar.cpp index b9bf13452..658d9f842 100644 --- a/unity-shared/SearchBar.cpp +++ b/unity-shared/SearchBar.cpp @@ -141,6 +141,9 @@ SearchBar::SearchBar(bool show_filter_hint, NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) , showing_filters(false) , can_refine_search(false) + , im_active([this] { return pango_entry_->im_active(); }) + , im_preedit([this] { return pango_entry_->im_preedit(); }) + , in_live_search([this] { return live_search_timeout_ && live_search_timeout_->IsRunning(); }) , live_search_wait(DEFAULT_LIVE_SEARCH_TIMEOUT) , scale(DEFAULT_SCALE) , show_filter_hint_(show_filter_hint) @@ -179,11 +182,11 @@ SearchBar::SearchBar(bool show_filter_hint, NUX_FILE_LINE_DECL) pango_entry_->mouse_down.connect(sigc::mem_fun(this, &SearchBar::OnMouseButtonDown)); pango_entry_->end_key_focus.connect(sigc::mem_fun(this, &SearchBar::OnEndKeyFocus)); pango_entry_->key_up.connect([this] (unsigned int, unsigned long, unsigned long) { - if (get_im_preedit()) - { - hint_->SetVisible(false); - hint_->QueueDraw(); - } + if (im_preedit()) + { + hint_->SetVisible(false); + hint_->QueueDraw(); + } }); layered_layout_ = new nux::LayeredLayout(); @@ -263,10 +266,8 @@ SearchBar::SearchBar(bool show_filter_hint, NUX_FILE_LINE_DECL) OnFontChanged(); search_hint.changed.connect([this](std::string const& s) { OnSearchHintChanged(); }); - search_string.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_search_string)); + search_string.SetGetterFunction([this] { return pango_entry_->GetText(); }); search_string.SetSetterFunction(sigc::mem_fun(this, &SearchBar::set_search_string)); - im_active.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_active)); - im_preedit.SetGetterFunction(sigc::mem_fun(this, &SearchBar::get_im_preedit)); showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged)); scale.changed.connect(sigc::mem_fun(this, &SearchBar::UpdateScale)); Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &SearchBar::UpdateSearchBarSize))); @@ -633,11 +634,6 @@ nux::View* SearchBar::show_filters() const return expander_view_; } -std::string SearchBar::get_search_string() const -{ - return pango_entry_->GetText(); -} - bool SearchBar::set_search_string(std::string const& string) { pango_entry_->SetText(string.c_str()); @@ -649,16 +645,6 @@ bool SearchBar::set_search_string(std::string const& string) return true; } -bool SearchBar::get_im_active() const -{ - return pango_entry_->im_active(); -} - -bool SearchBar::get_im_preedit() const -{ - return pango_entry_->im_preedit(); -} - // // Highlight // diff --git a/unity-shared/SearchBar.h b/unity-shared/SearchBar.h index 9cc6440b6..d9efdf198 100644 --- a/unity-shared/SearchBar.h +++ b/unity-shared/SearchBar.h @@ -63,6 +63,7 @@ public: nux::Property<bool> can_refine_search; nux::ROProperty<bool> im_active; nux::ROProperty<bool> im_preedit; + nux::ROProperty<bool> in_live_search; nux::Property<unsigned> live_search_wait; nux::Property<double> scale; @@ -88,10 +89,7 @@ private: bool OnLiveSearchTimeout(); bool OnSpinnerStartCb(); - std::string get_search_string() const; bool set_search_string(std::string const& string); - bool get_im_active() const; - bool get_im_preedit() const; bool show_filter_hint_; std::string GetName() const; |
