Merge lp:~gordallott/unity/hud-wait-100ms into lp:unity

Proposed by Gord Allott
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2203
Proposed branch: lp:~gordallott/unity/hud-wait-100ms
Merge into: lp:unity
Diff against target: 54 lines (+19/-1)
2 files modified
plugins/unityshell/src/HudController.cpp (+17/-1)
plugins/unityshell/src/HudController.h (+2/-0)
To merge this branch: bzr merge lp:~gordallott/unity/hud-wait-100ms
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+99775@code.launchpad.net

Commit message

Reduce stress on hud service by waiting 100ms prior to sending request.

Description of the change

helps reduce the stress on the service, request from desrt, only sends a new hud dbus query after waiting 100ms from the last typed letter

helps fix lp:948820

no testing as this is a stop gap fix and not the "correct" behaviour, if i were to write a test it would be to make a failing test so remind everyone to correct this bug properly
but we aren't allowed failing tests so oh well ;)

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

gord, can you put a big insulting FIXME as a comment maybe? ;)

Revision history for this message
Tim Penhey (thumper) wrote :

+1 with the FIXME comment.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/HudController.cpp'
--- plugins/unityshell/src/HudController.cpp 2012-03-21 15:30:49 +0000
+++ plugins/unityshell/src/HudController.cpp 2012-03-29 13:58:38 +0000
@@ -50,6 +50,7 @@
50 , launcher_is_locked_out_(false)50 , launcher_is_locked_out_(false)
51 , view_(nullptr)51 , view_(nullptr)
52 , monitor_index_(0)52 , monitor_index_(0)
53 , type_wait_handle_(0)
53{54{
54 LOG_DEBUG(logger) << "hud startup";55 LOG_DEBUG(logger) << "hud startup";
55 SetupRelayoutCallbacks();56 SetupRelayoutCallbacks();
@@ -87,6 +88,7 @@
8788
88 g_source_remove(timeline_id_);89 g_source_remove(timeline_id_);
89 g_source_remove(ensure_id_);90 g_source_remove(ensure_id_);
91 g_source_remove(type_wait_handle_);
90}92}
9193
92void Controller::SetupWindow()94void Controller::SetupWindow()
@@ -384,8 +386,22 @@
384386
385void Controller::OnSearchChanged(std::string search_string)387void Controller::OnSearchChanged(std::string search_string)
386{388{
389 //FIXME!! - when the service is smart enough to not fall over if you send many requests, this should be removed
387 LOG_DEBUG(logger) << "Search Changed";390 LOG_DEBUG(logger) << "Search Changed";
388 hud_service_.RequestQuery(search_string);391 auto on_search_changed_timeout_lambda = [] (gpointer data) -> gboolean {
392 Controller* self = static_cast<Controller*>(data);
393 self->hud_service_.RequestQuery(self->last_search_);
394 self->type_wait_handle_ = 0;
395 return FALSE;
396 };
397
398 last_search_ = search_string;
399
400 if (type_wait_handle_)
401 {
402 g_source_remove(type_wait_handle_);
403 }
404 type_wait_handle_ = g_timeout_add(100, on_search_changed_timeout_lambda, this);
389}405}
390406
391void Controller::OnSearchActivated(std::string search_string)407void Controller::OnSearchActivated(std::string search_string)
392408
=== modified file 'plugins/unityshell/src/HudController.h'
--- plugins/unityshell/src/HudController.h 2012-03-21 15:30:49 +0000
+++ plugins/unityshell/src/HudController.h 2012-03-29 13:58:38 +0000
@@ -109,6 +109,8 @@
109 std::string focused_app_icon_;109 std::string focused_app_icon_;
110 nux::Layout* layout_;110 nux::Layout* layout_;
111 uint monitor_index_;111 uint monitor_index_;
112 guint type_wait_handle_;
113 std::string last_search_;
112};114};
113115
114116