Merge lp:~afrantzis/unity-system-compositor/fix-1461476-display-off-ubuntu into lp:unity-system-compositor/ubuntu

Proposed by Alexandros Frantzis
Status: Merged
Merged at revision: 205
Proposed branch: lp:~afrantzis/unity-system-compositor/fix-1461476-display-off-ubuntu
Merge into: lp:unity-system-compositor/ubuntu
Diff against target: 80 lines (+37/-3)
2 files modified
src/unity_screen_service.cpp (+11/-3)
tests/integration-tests/test_unity_screen_service.cpp (+26/-0)
To merge this branch: bzr merge lp:~afrantzis/unity-system-compositor/fix-1461476-display-off-ubuntu
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity System Compositor Development Team Pending
Review via email: mp+264128@code.launchpad.net

Commit message

Don't restart the inactivity timers when receiving invalid dbus calls or uninteresting dbus events

Previously, invalid dbus calls (e.g., trying to remove a non-existent keepDisplayOn request), or uninteresting dbus events (e.g., being informed about disconnections of dbus clients that hadn't issued any keepDisplayOn requests), would restart the inactivity timers, effectively increasing the delay until display dimming and poweroff.

Description of the change

Don't restart the inactivity timers when receiving invalid dbus calls or uninteresting dbus events

Previously, invalid dbus calls (e.g., trying to remove a non-existent keepDisplayOn request), or uninteresting dbus events (e.g., being informed about disconnections of dbus clients that hadn't issued any keepDisplayOn requests), would restart the inactivity timers, effectively increasing the delay until display dimming and poweroff.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/unity_screen_service.cpp'
--- src/unity_screen_service.cpp 2015-03-18 13:06:10 +0000
+++ src/unity_screen_service.cpp 2015-07-08 11:44:41 +0000
@@ -305,6 +305,8 @@
305{305{
306 std::lock_guard<std::mutex> lock{keep_display_on_mutex};306 std::lock_guard<std::mutex> lock{keep_display_on_mutex};
307307
308 bool id_removed{false};
309
308 auto range = keep_display_on_ids.equal_range(sender);310 auto range = keep_display_on_ids.equal_range(sender);
309 for (auto iter = range.first;311 for (auto iter = range.first;
310 iter != range.second;312 iter != range.second;
@@ -313,11 +315,12 @@
313 if (iter->second == id)315 if (iter->second == id)
314 {316 {
315 keep_display_on_ids.erase(iter);317 keep_display_on_ids.erase(iter);
318 id_removed = true;
316 break;319 break;
317 }320 }
318 }321 }
319322
320 if (keep_display_on_ids.empty())323 if (id_removed && keep_display_on_ids.empty())
321 screen->keep_display_on(false);324 screen->keep_display_on(false);
322}325}
323326
@@ -329,9 +332,14 @@
329 if (new_owner.empty() && old_owner == name)332 if (new_owner.empty() && old_owner == name)
330 {333 {
331 std::lock_guard<std::mutex> lock{keep_display_on_mutex};334 std::lock_guard<std::mutex> lock{keep_display_on_mutex};
332 keep_display_on_ids.erase(name);335 // If the disconnected client had issued keepDisplayOn requests
333 if (keep_display_on_ids.empty())336 // and after removing them there are now no more requests left,
337 // tell the screen we don't need to keep the display on.
338 if (keep_display_on_ids.erase(name) > 0 &&
339 keep_display_on_ids.empty())
340 {
334 screen->keep_display_on(false);341 screen->keep_display_on(false);
342 }
335 }343 }
336}344}
337345
338346
=== modified file 'tests/integration-tests/test_unity_screen_service.cpp'
--- tests/integration-tests/test_unity_screen_service.cpp 2015-03-18 13:06:10 +0000
+++ tests/integration-tests/test_unity_screen_service.cpp 2015-07-08 11:44:41 +0000
@@ -365,6 +365,32 @@
365 EXPECT_TRUE(request_processed.woken());365 EXPECT_TRUE(request_processed.woken());
366}366}
367367
368TEST_F(AUnityScreenService, ignores_invalid_display_on_removal_request)
369{
370 ut::WaitCondition request_processed;
371
372 int32_t const invalid_id{-1};
373 EXPECT_CALL(*mock_screen, keep_display_on(false)).Times(0);
374
375 client.request_remove_display_on_request(invalid_id);
376 client.disconnect();
377
378 // Allow some time for dbus calls to reach UnityScreenService
379 std::this_thread::sleep_for(std::chrono::milliseconds(100));
380}
381
382TEST_F(AUnityScreenService, ignores_disconnects_from_clients_without_display_on_request)
383{
384 ut::WaitCondition request_processed;
385
386 EXPECT_CALL(*mock_screen, keep_display_on(false)).Times(0);
387
388 client.disconnect();
389
390 // Allow some time for disconnect notification to reach UnityScreenService
391 std::this_thread::sleep_for(std::chrono::milliseconds(100));
392}
393
368TEST_F(AUnityScreenService, emits_power_state_change_signal)394TEST_F(AUnityScreenService, emits_power_state_change_signal)
369{395{
370 using namespace testing;396 using namespace testing;

Subscribers

People subscribed via source and target branches