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
1=== modified file 'plugins/unityshell/src/HudController.cpp'
2--- plugins/unityshell/src/HudController.cpp 2012-03-21 15:30:49 +0000
3+++ plugins/unityshell/src/HudController.cpp 2012-03-29 13:58:38 +0000
4@@ -50,6 +50,7 @@
5 , launcher_is_locked_out_(false)
6 , view_(nullptr)
7 , monitor_index_(0)
8+ , type_wait_handle_(0)
9 {
10 LOG_DEBUG(logger) << "hud startup";
11 SetupRelayoutCallbacks();
12@@ -87,6 +88,7 @@
13
14 g_source_remove(timeline_id_);
15 g_source_remove(ensure_id_);
16+ g_source_remove(type_wait_handle_);
17 }
18
19 void Controller::SetupWindow()
20@@ -384,8 +386,22 @@
21
22 void Controller::OnSearchChanged(std::string search_string)
23 {
24+ //FIXME!! - when the service is smart enough to not fall over if you send many requests, this should be removed
25 LOG_DEBUG(logger) << "Search Changed";
26- hud_service_.RequestQuery(search_string);
27+ auto on_search_changed_timeout_lambda = [] (gpointer data) -> gboolean {
28+ Controller* self = static_cast<Controller*>(data);
29+ self->hud_service_.RequestQuery(self->last_search_);
30+ self->type_wait_handle_ = 0;
31+ return FALSE;
32+ };
33+
34+ last_search_ = search_string;
35+
36+ if (type_wait_handle_)
37+ {
38+ g_source_remove(type_wait_handle_);
39+ }
40+ type_wait_handle_ = g_timeout_add(100, on_search_changed_timeout_lambda, this);
41 }
42
43 void Controller::OnSearchActivated(std::string search_string)
44
45=== modified file 'plugins/unityshell/src/HudController.h'
46--- plugins/unityshell/src/HudController.h 2012-03-21 15:30:49 +0000
47+++ plugins/unityshell/src/HudController.h 2012-03-29 13:58:38 +0000
48@@ -109,6 +109,8 @@
49 std::string focused_app_icon_;
50 nux::Layout* layout_;
51 uint monitor_index_;
52+ guint type_wait_handle_;
53+ std::string last_search_;
54 };
55
56