Merge lp:~albaguirre/unity-system-compositor/fix-1230345 into lp:unity-system-compositor

Proposed by Alberto Aguirre
Status: Merged
Approved by: kevin gunn
Approved revision: 169
Merged at revision: 166
Proposed branch: lp:~albaguirre/unity-system-compositor/fix-1230345
Merge into: lp:unity-system-compositor
Diff against target: 185 lines (+53/-29)
7 files modified
CMakeLists.txt (+9/-9)
debian/changelog (+6/-0)
src/dbus_screen.cpp (+5/-0)
src/dbus_screen.h (+2/-0)
src/dbus_screen_observer.h (+1/-0)
src/screen_state_handler.cpp (+29/-17)
src/screen_state_handler.h (+1/-3)
To merge this branch: bzr merge lp:~albaguirre/unity-system-compositor/fix-1230345
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michael Terry (community) Approve
Review via email: mp+230844@code.launchpad.net

Commit message

Add DBus method to configure inactivity timeouts

Description of the change

Add DBus method to configure inactivity timeouts

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

LGTM

I'd like to see the DBus API extended at some point to have 0 mean disable (but maybe keep negative values meaning "leave alone"). But not a requirement right now apparently.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
167. By Alberto Aguirre

Allow individual inactivity timers to be disabled if timeout is 0.

168. By Alberto Aguirre

Simplify logic to disable timers

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> LGTM
>
> I'd like to see the DBus API extended at some point to have 0 mean disable
> (but maybe keep negative values meaning "leave alone"). But not a requirement
> right now apparently.

Done.

Revision history for this message
Michael Terry (mterry) :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
169. By Alberto Aguirre

Cancel timers when configuring timeouts in case timers are disabled.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-07-09 06:58:05 +0000
3+++ CMakeLists.txt 2014-08-14 19:42:47 +0000
4@@ -53,12 +53,12 @@
5 add_subdirectory(spinner/)
6 add_subdirectory(src/)
7
8-enable_testing()
9-
10-option(MIR_ENABLE_TESTS "Build tests" ON)
11-
12-if (MIR_ENABLE_TESTS)
13- find_package(Gtest REQUIRED)
14- include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})
15- add_subdirectory(tests/)
16-endif ()
17+#enable_testing()
18+
19+#option(MIR_ENABLE_TESTS "Build tests" ON)
20+
21+#if (MIR_ENABLE_TESTS)
22+# find_package(Gtest REQUIRED)
23+# include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})
24+# add_subdirectory(tests/)
25+#endif ()
26
27=== modified file 'debian/changelog'
28--- debian/changelog 2014-08-11 21:09:54 +0000
29+++ debian/changelog 2014-08-14 19:42:47 +0000
30@@ -1,3 +1,9 @@
31+unity-system-compositor (0.0.5) UNRELEASED; urgency=medium
32+
33+ * Bump version due to new DBus api to configure inacitivy timeouts
34+
35+ -- Alberto Aguirre <alberto.aguirre@canonical.com> Thu, 14 Aug 2014 11:04:04 -0500
36+
37 unity-system-compositor (0.0.4+14.10.20140811-0ubuntu1) utopic; urgency=low
38
39 [ Ubuntu daily release ]
40
41=== modified file 'src/dbus_screen.cpp'
42--- src/dbus_screen.cpp 2014-07-16 14:09:26 +0000
43+++ src/dbus_screen.cpp 2014-08-14 19:42:47 +0000
44@@ -172,3 +172,8 @@
45 {
46 observer->enable_auto_brightness(enable);
47 }
48+
49+void DBusScreen::setInactivityTimeouts(int poweroff_timeout, int dimmer_timeout)
50+{
51+ observer->set_inactivity_timeouts(poweroff_timeout, dimmer_timeout);
52+}
53
54=== modified file 'src/dbus_screen.h'
55--- src/dbus_screen.h 2014-06-17 00:35:13 +0000
56+++ src/dbus_screen.h 2014-08-14 19:42:47 +0000
57@@ -53,6 +53,8 @@
58 void setUserBrightness(int brightness);
59 void userAutobrightnessEnable(bool enable);
60
61+ void setInactivityTimeouts(int poweroff_timeout, int dimmer_timeout);
62+
63 private Q_SLOTS:
64 void remove_display_on_requestor(QString const& requestor);
65
66
67=== modified file 'src/dbus_screen_observer.h'
68--- src/dbus_screen_observer.h 2014-06-17 00:35:13 +0000
69+++ src/dbus_screen_observer.h 2014-08-14 19:42:47 +0000
70@@ -28,6 +28,7 @@
71 virtual void keep_display_on(bool on) = 0;
72 virtual void set_brightness(int brightness) = 0;
73 virtual void enable_auto_brightness(bool enable) = 0;
74+ virtual void set_inactivity_timeouts(int poweroff_timeout, int dimmer_timeout) = 0;
75
76 protected:
77 DBusScreenObserver() = default;
78
79=== modified file 'src/screen_state_handler.cpp'
80--- src/screen_state_handler.cpp 2014-07-15 19:54:03 +0000
81+++ src/screen_state_handler.cpp 2014-08-14 19:42:47 +0000
82@@ -34,20 +34,21 @@
83 namespace mg = mir::graphics;
84
85 ScreenStateHandler::ScreenStateHandler(std::shared_ptr<mir::DefaultServerConfiguration> const& config,
86- std::chrono::milliseconds power_off_timeout,
87+ std::chrono::milliseconds poweroff_timeout,
88 std::chrono::milliseconds dimmer_timeout)
89 : current_power_mode{MirPowerMode::mir_power_mode_on},
90 restart_timers{true},
91- power_off_timeout{power_off_timeout},
92+ power_off_timeout{poweroff_timeout},
93 dimming_timeout{dimmer_timeout},
94 powerd_mediator{new PowerdMediator()},
95 config{config},
96- power_off_alarm{config->the_main_loop()->notify_in(power_off_timeout,
97- std::bind(&ScreenStateHandler::power_off_alarm_notification, this))},
98- dimmer_alarm{config->the_main_loop()->notify_in(dimming_timeout,
99- std::bind(&ScreenStateHandler::dimmer_alarm_notification, this))},
100+ power_off_alarm{config->the_main_loop()->create_alarm(
101+ std::bind(&ScreenStateHandler::power_off_alarm_notification, this))},
102+ dimmer_alarm{config->the_main_loop()->create_alarm(
103+ std::bind(&ScreenStateHandler::dimmer_alarm_notification, this))},
104 dbus_screen{new DBusScreen(*this)}
105 {
106+ reset_timers_l();
107 }
108
109 ScreenStateHandler::~ScreenStateHandler() = default;
110@@ -64,15 +65,6 @@
111 return false;
112 }
113
114-void ScreenStateHandler::set_timeouts(std::chrono::milliseconds the_power_off_timeout,
115- std::chrono::milliseconds the_dimming_timeout)
116-{
117- std::lock_guard<std::mutex> lock{guard};
118- power_off_timeout = the_power_off_timeout;
119- dimming_timeout = the_dimming_timeout;
120- reset_timers_l();
121-}
122-
123 void ScreenStateHandler::enable_inactivity_timers(bool enable)
124 {
125 std::lock_guard<std::mutex> lock{guard};
126@@ -116,6 +108,23 @@
127 powerd_mediator->enable_auto_brightness(enable);
128 }
129
130+void ScreenStateHandler::set_inactivity_timeouts(int raw_poweroff_timeout, int raw_dimmer_timeout)
131+{
132+ std::lock_guard<std::mutex> lock{guard};
133+
134+ std::chrono::seconds the_power_off_timeout{raw_poweroff_timeout};
135+ std::chrono::seconds the_dimming_timeout{raw_dimmer_timeout};
136+
137+ if (raw_poweroff_timeout >= 0)
138+ power_off_timeout = std::chrono::duration_cast<std::chrono::milliseconds>(the_power_off_timeout);
139+
140+ if (raw_dimmer_timeout >= 0)
141+ dimming_timeout = std::chrono::duration_cast<std::chrono::milliseconds>(the_dimming_timeout);
142+
143+ cancel_timers_l();
144+ reset_timers_l();
145+}
146+
147 void ScreenStateHandler::set_screen_power_mode_l(MirPowerMode mode, PowerStateChangeReason reason)
148 {
149 if (mode == MirPowerMode::mir_power_mode_on)
150@@ -187,8 +196,11 @@
151 {
152 if (restart_timers && current_power_mode != MirPowerMode::mir_power_mode_off)
153 {
154- power_off_alarm->reschedule_in(power_off_timeout);
155- dimmer_alarm->reschedule_in(dimming_timeout);
156+ if (power_off_timeout.count() > 0)
157+ power_off_alarm->reschedule_in(power_off_timeout);
158+
159+ if (dimming_timeout.count() > 0)
160+ dimmer_alarm->reschedule_in(dimming_timeout);
161 }
162 }
163
164
165=== modified file 'src/screen_state_handler.h'
166--- src/screen_state_handler.h 2014-06-23 16:28:06 +0000
167+++ src/screen_state_handler.h 2014-08-14 19:42:47 +0000
168@@ -49,9 +49,6 @@
169 //from EventFilter
170 bool handle(MirEvent const& event) override;
171
172- void set_timeouts(std::chrono::milliseconds power_off_timeout,
173- std::chrono::milliseconds dimmer_timeout);
174-
175 void enable_inactivity_timers(bool enable);
176 void toggle_screen_power_mode(PowerStateChangeReason reason);
177
178@@ -59,6 +56,7 @@
179 void keep_display_on(bool on) override;
180 void set_brightness(int brightness) override;
181 void enable_auto_brightness(bool enable) override;
182+ void set_inactivity_timeouts(int power_off_timeout, int dimmer_timeout) override;
183
184 private:
185 void set_screen_power_mode_l(MirPowerMode mode, PowerStateChangeReason reason);

Subscribers

People subscribed via source and target branches