~unity-system-compositor-team/unity-system-compositor/trunk

« back to all changes in this revision

Viewing changes to src/unity_screen_service.cpp

  • Committer: Tarmac
  • Author(s): Alexandros Frantzis
  • Date: 2015-07-13 15:21:24 UTC
  • mfrom: (223.1.1 fix-1461476-display-off)
  • Revision ID: tarmac-20150713152124-fkj6e79jagzs71ry
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. Fixes: https://bugs.launchpad.net/bugs/1461476.

Approved by Andreas Pokorny, Alberto Aguirre, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
305
305
{
306
306
    std::lock_guard<std::mutex> lock{keep_display_on_mutex};
307
307
 
 
308
    bool id_removed{false};
 
309
 
308
310
    auto range = keep_display_on_ids.equal_range(sender);
309
311
    for (auto iter = range.first;
310
312
         iter != range.second;
313
315
        if (iter->second == id)
314
316
        {
315
317
            keep_display_on_ids.erase(iter);
 
318
            id_removed = true;
316
319
            break;
317
320
        }
318
321
    }
319
322
 
320
 
    if (keep_display_on_ids.empty())
 
323
    if (id_removed && keep_display_on_ids.empty())
321
324
        screen->keep_display_on(false);
322
325
}
323
326
 
329
332
    if (new_owner.empty() && old_owner == name)
330
333
    {
331
334
        std::lock_guard<std::mutex> lock{keep_display_on_mutex};
332
 
        keep_display_on_ids.erase(name);
333
 
        if (keep_display_on_ids.empty())
 
335
        // If the disconnected client had issued keepDisplayOn requests
 
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
341
            screen->keep_display_on(false);
 
342
        }
335
343
    }
336
344
}
337
345