Merge lp:~azzar1/unity/fix-1044681 into lp:unity
- fix-1044681
- Merge into trunk
Proposed by
Andrea Azzarone
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2712 |
Proposed branch: | lp:~azzar1/unity/fix-1044681 |
Merge into: | lp:unity |
Diff against target: |
607 lines (+210/-118) 12 files modified
dash/DashController.cpp (+2/-2) dash/DashView.cpp (+8/-6) panel/WindowButtons.cpp (+6/-7) panel/WindowButtons.h (+2/-1) tests/CMakeLists.txt (+1/-0) tests/test_unity_settings.cpp (+110/-0) unity-shared/DashStyle.cpp (+4/-4) unity-shared/OverlayRenderer.cpp (+3/-3) unity-shared/PanelStyle.cpp (+3/-3) unity-shared/UnitySettings.cpp (+61/-80) unity-shared/UnitySettings.h (+9/-11) unity-standalone/StandaloneUnity.cpp (+1/-1) |
To merge this branch: | bzr merge lp:~azzar1/unity/fix-1044681 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Omer Akram (community) | functional | Approve | |
Review via email: mp+124630@code.launchpad.net |
Commit message
Refactor unity::Settings to use nux::RWProperty.
Description of the change
== Problem ==
Bug #1044681: [regression] Minimizing a window does not give focus to the window behind
== Fix ==
Refactored unity::Settings to use RWProperty.
== Test ==
Unit tests added for unity::Settings.
To post a comment you must log in.
Revision history for this message
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'dash/DashController.cpp' | |||
2 | --- dash/DashController.cpp 2012-09-17 10:00:38 +0000 | |||
3 | +++ dash/DashController.cpp 2012-09-18 13:56:19 +0000 | |||
4 | @@ -74,9 +74,9 @@ | |||
5 | 74 | 74 | ||
6 | 75 | SetupWindow(); | 75 | SetupWindow(); |
7 | 76 | 76 | ||
9 | 77 | Settings::Instance().changed.connect([&]() | 77 | Settings::Instance().form_factor.changed.connect([this](FormFactor) |
10 | 78 | { | 78 | { |
12 | 79 | if (window_ && view_) | 79 | if (window_ && view_ && visible_) |
13 | 80 | { | 80 | { |
14 | 81 | window_->PushToFront(); | 81 | window_->PushToFront(); |
15 | 82 | window_->SetInputFocus(); | 82 | window_->SetInputFocus(); |
16 | 83 | 83 | ||
17 | === modified file 'dash/DashView.cpp' | |||
18 | --- dash/DashView.cpp 2012-09-18 09:05:50 +0000 | |||
19 | +++ dash/DashView.cpp 2012-09-18 13:56:19 +0000 | |||
20 | @@ -98,7 +98,10 @@ | |||
21 | 98 | SetupViews(); | 98 | SetupViews(); |
22 | 99 | SetupUBusConnections(); | 99 | SetupUBusConnections(); |
23 | 100 | 100 | ||
25 | 101 | Settings::Instance().changed.connect(sigc::mem_fun(this, &DashView::Relayout)); | 101 | Settings::Instance().form_factor.changed.connect([this](FormFactor) { |
26 | 102 | Relayout(); | ||
27 | 103 | }); | ||
28 | 104 | |||
29 | 102 | lenses_.lens_added.connect(sigc::mem_fun(this, &DashView::OnLensAdded)); | 105 | lenses_.lens_added.connect(sigc::mem_fun(this, &DashView::OnLensAdded)); |
30 | 103 | mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown)); | 106 | mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown)); |
31 | 104 | preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview)); | 107 | preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview)); |
32 | @@ -337,7 +340,6 @@ | |||
33 | 337 | content_geo_ = geo; | 340 | content_geo_ = geo; |
34 | 338 | } | 341 | } |
35 | 339 | 342 | ||
36 | 340 | |||
37 | 341 | // kinda hacky, but it makes sure the content isn't so big that it throws | 343 | // kinda hacky, but it makes sure the content isn't so big that it throws |
38 | 342 | // the bottom of the dash off the screen | 344 | // the bottom of the dash off the screen |
39 | 343 | // not hugely happy with this, so FIXME | 345 | // not hugely happy with this, so FIXME |
40 | @@ -422,7 +424,7 @@ | |||
41 | 422 | dash::Style& style = dash::Style::Instance(); | 424 | dash::Style& style = dash::Style::Instance(); |
42 | 423 | nux::Geometry geo(content_geo_); | 425 | nux::Geometry geo(content_geo_); |
43 | 424 | 426 | ||
45 | 425 | if (Settings::Instance().GetFormFactor() == FormFactor::DESKTOP) | 427 | if (Settings::Instance().form_factor() == FormFactor::DESKTOP) |
46 | 426 | { | 428 | { |
47 | 427 | geo.width += style.GetDashRightTileWidth(); | 429 | geo.width += style.GetDashRightTileWidth(); |
48 | 428 | geo.height += style.GetDashBottomTileHeight(); | 430 | geo.height += style.GetDashBottomTileHeight(); |
49 | @@ -854,11 +856,11 @@ | |||
50 | 854 | 856 | ||
51 | 855 | std::string form_factor("unknown"); | 857 | std::string form_factor("unknown"); |
52 | 856 | 858 | ||
54 | 857 | if (Settings::Instance().GetFormFactor() == FormFactor::NETBOOK) | 859 | if (Settings::Instance().form_factor() == FormFactor::NETBOOK) |
55 | 858 | form_factor = "netbook"; | 860 | form_factor = "netbook"; |
57 | 859 | else if (Settings::Instance().GetFormFactor() == FormFactor::DESKTOP) | 861 | else if (Settings::Instance().form_factor() == FormFactor::DESKTOP) |
58 | 860 | form_factor = "desktop"; | 862 | form_factor = "desktop"; |
60 | 861 | else if (Settings::Instance().GetFormFactor() == FormFactor::TV) | 863 | else if (Settings::Instance().form_factor() == FormFactor::TV) |
61 | 862 | form_factor = "tv"; | 864 | form_factor = "tv"; |
62 | 863 | 865 | ||
63 | 864 | unity::variant::BuilderWrapper wrapper(builder); | 866 | unity::variant::BuilderWrapper wrapper(builder); |
64 | 865 | 867 | ||
65 | === modified file 'panel/WindowButtons.cpp' | |||
66 | --- panel/WindowButtons.cpp 2012-07-06 22:36:27 +0000 | |||
67 | +++ panel/WindowButtons.cpp 2012-09-18 13:56:19 +0000 | |||
68 | @@ -395,7 +395,7 @@ | |||
69 | 395 | 395 | ||
70 | 396 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &WindowButtons::OnOverlayShown)); | 396 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &WindowButtons::OnOverlayShown)); |
71 | 397 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &WindowButtons::OnOverlayHidden)); | 397 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &WindowButtons::OnOverlayHidden)); |
73 | 398 | Settings::Instance().changed.connect(sigc::mem_fun(this, &WindowButtons::OnDashSettingsUpdated)); | 398 | Settings::Instance().form_factor.changed.connect(sigc::mem_fun(this, &WindowButtons::OnDashSettingsUpdated)); |
74 | 399 | } | 399 | } |
75 | 400 | 400 | ||
76 | 401 | nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type) | 401 | nux::Area* WindowButtons::FindAreaUnderMouse(const nux::Point& mouse, nux::NuxEventType event_type) |
77 | @@ -470,7 +470,7 @@ | |||
78 | 470 | 470 | ||
79 | 471 | if (win_button->IsOverlayOpen()) | 471 | if (win_button->IsOverlayOpen()) |
80 | 472 | { | 472 | { |
82 | 473 | Settings::Instance().SetFormFactor(FormFactor::DESKTOP); | 473 | Settings::Instance().form_factor = FormFactor::DESKTOP; |
83 | 474 | } | 474 | } |
84 | 475 | else | 475 | else |
85 | 476 | { | 476 | { |
86 | @@ -494,7 +494,7 @@ | |||
87 | 494 | 494 | ||
88 | 495 | if (win_button->IsOverlayOpen()) | 495 | if (win_button->IsOverlayOpen()) |
89 | 496 | { | 496 | { |
91 | 497 | Settings::Instance().SetFormFactor(FormFactor::NETBOOK); | 497 | Settings::Instance().form_factor = FormFactor::NETBOOK; |
92 | 498 | } | 498 | } |
93 | 499 | 499 | ||
94 | 500 | maximize_clicked.emit(); | 500 | maximize_clicked.emit(); |
95 | @@ -550,7 +550,7 @@ | |||
96 | 550 | if (restore_button && maximize_button) | 550 | if (restore_button && maximize_button) |
97 | 551 | { | 551 | { |
98 | 552 | Settings &dash_settings = Settings::Instance(); | 552 | Settings &dash_settings = Settings::Instance(); |
100 | 553 | bool maximizable = (dash_settings.GetFormFactor() == FormFactor::DESKTOP); | 553 | bool maximizable = (dash_settings.form_factor() == FormFactor::DESKTOP); |
101 | 554 | 554 | ||
102 | 555 | restore_button->SetEnabled(can_maximise); | 555 | restore_button->SetEnabled(can_maximise); |
103 | 556 | maximize_button->SetEnabled(can_maximise); | 556 | maximize_button->SetEnabled(can_maximise); |
104 | @@ -645,7 +645,7 @@ | |||
105 | 645 | } | 645 | } |
106 | 646 | } | 646 | } |
107 | 647 | 647 | ||
109 | 648 | void WindowButtons::OnDashSettingsUpdated() | 648 | void WindowButtons::OnDashSettingsUpdated(FormFactor form_factor) |
110 | 649 | { | 649 | { |
111 | 650 | WindowButton* maximize_button = nullptr; | 650 | WindowButton* maximize_button = nullptr; |
112 | 651 | WindowButton* restore_button = nullptr; | 651 | WindowButton* restore_button = nullptr; |
113 | @@ -672,8 +672,7 @@ | |||
114 | 672 | 672 | ||
115 | 673 | if (restore_button && restore_button->IsOverlayOpen() && maximize_button) | 673 | if (restore_button && restore_button->IsOverlayOpen() && maximize_button) |
116 | 674 | { | 674 | { |
119 | 675 | Settings &dash_settings = Settings::Instance(); | 675 | bool maximizable = (form_factor == FormFactor::DESKTOP); |
118 | 676 | bool maximizable = (dash_settings.GetFormFactor() == FormFactor::DESKTOP); | ||
120 | 677 | 676 | ||
121 | 678 | if (maximizable != maximize_button->IsVisible()) | 677 | if (maximizable != maximize_button->IsVisible()) |
122 | 679 | { | 678 | { |
123 | 680 | 679 | ||
124 | === modified file 'panel/WindowButtons.h' | |||
125 | --- panel/WindowButtons.h 2012-05-06 23:48:38 +0000 | |||
126 | +++ panel/WindowButtons.h 2012-09-18 13:56:19 +0000 | |||
127 | @@ -26,6 +26,7 @@ | |||
128 | 26 | 26 | ||
129 | 27 | #include "unity-shared/UBusWrapper.h" | 27 | #include "unity-shared/UBusWrapper.h" |
130 | 28 | #include "unity-shared/Introspectable.h" | 28 | #include "unity-shared/Introspectable.h" |
131 | 29 | #include "unity-shared/UnitySettings.h" | ||
132 | 29 | 30 | ||
133 | 30 | namespace unity | 31 | namespace unity |
134 | 31 | { | 32 | { |
135 | @@ -70,7 +71,7 @@ | |||
136 | 70 | void OnMaximizeClicked(nux::Button *button); | 71 | void OnMaximizeClicked(nux::Button *button); |
137 | 71 | void OnOverlayShown(GVariant* data); | 72 | void OnOverlayShown(GVariant* data); |
138 | 72 | void OnOverlayHidden(GVariant* data); | 73 | void OnOverlayHidden(GVariant* data); |
140 | 73 | void OnDashSettingsUpdated(); | 74 | void OnDashSettingsUpdated(FormFactor form_factor); |
141 | 74 | 75 | ||
142 | 75 | int monitor_; | 76 | int monitor_; |
143 | 76 | double opacity_; | 77 | double opacity_; |
144 | 77 | 78 | ||
145 | === modified file 'tests/CMakeLists.txt' | |||
146 | --- tests/CMakeLists.txt 2012-09-17 14:07:30 +0000 | |||
147 | +++ tests/CMakeLists.txt 2012-09-18 13:56:19 +0000 | |||
148 | @@ -231,6 +231,7 @@ | |||
149 | 231 | test_texture_cache.cpp | 231 | test_texture_cache.cpp |
150 | 232 | test_thumbnail_generator.cpp | 232 | test_thumbnail_generator.cpp |
151 | 233 | test_launcher_minimize_speed.cpp | 233 | test_launcher_minimize_speed.cpp |
152 | 234 | test_unity_settings.cpp | ||
153 | 234 | test_volume_imp.cpp | 235 | test_volume_imp.cpp |
154 | 235 | test_volume_launcher_icon.cpp | 236 | test_volume_launcher_icon.cpp |
155 | 236 | gmockmount.c | 237 | gmockmount.c |
156 | 237 | 238 | ||
157 | === added file 'tests/test_unity_settings.cpp' | |||
158 | --- tests/test_unity_settings.cpp 1970-01-01 00:00:00 +0000 | |||
159 | +++ tests/test_unity_settings.cpp 2012-09-18 13:56:19 +0000 | |||
160 | @@ -0,0 +1,110 @@ | |||
161 | 1 | /* | ||
162 | 2 | * Copyright 2012 Canonical Ltd. | ||
163 | 3 | * | ||
164 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
165 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
166 | 6 | * by the Free Software Foundation. | ||
167 | 7 | * | ||
168 | 8 | * This program is distributed in the hope that it will be useful, but | ||
169 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
170 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
171 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
172 | 12 | * | ||
173 | 13 | * You should have received a copy of the GNU General Public License | ||
174 | 14 | * version 3 along with this program. If not, see | ||
175 | 15 | * <http://www.gnu.org/licenses/> | ||
176 | 16 | * | ||
177 | 17 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
178 | 18 | * | ||
179 | 19 | */ | ||
180 | 20 | |||
181 | 21 | #include <gio/gio.h> | ||
182 | 22 | #include <gtest/gtest.h> | ||
183 | 23 | |||
184 | 24 | #include "test_utils.h" | ||
185 | 25 | #include "unity-shared/UnitySettings.h" | ||
186 | 26 | |||
187 | 27 | #include <UnityCore/GLibWrapper.h> | ||
188 | 28 | |||
189 | 29 | namespace | ||
190 | 30 | { | ||
191 | 31 | |||
192 | 32 | class TestUnitySettings : public testing::Test | ||
193 | 33 | { | ||
194 | 34 | public: | ||
195 | 35 | unity::glib::Object<GSettings> gsettings; | ||
196 | 36 | std::unique_ptr<unity::Settings> unity_settings; | ||
197 | 37 | |||
198 | 38 | void SetUp() | ||
199 | 39 | { | ||
200 | 40 | g_setenv("GSETTINGS_BACKEND", "memory", TRUE); | ||
201 | 41 | |||
202 | 42 | gsettings = g_settings_new("com.canonical.Unity"); | ||
203 | 43 | g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::DESKTOP)); | ||
204 | 44 | |||
205 | 45 | unity_settings.reset(new unity::Settings); | ||
206 | 46 | } | ||
207 | 47 | |||
208 | 48 | void TearDown() | ||
209 | 49 | { | ||
210 | 50 | g_setenv("GSETTINGS_BACKEND", "", TRUE); | ||
211 | 51 | } | ||
212 | 52 | }; | ||
213 | 53 | |||
214 | 54 | TEST_F(TestUnitySettings, SetFormFactor) | ||
215 | 55 | { | ||
216 | 56 | unity_settings->form_factor = unity::FormFactor::NETBOOK; | ||
217 | 57 | |||
218 | 58 | int raw_form_factor = g_settings_get_enum(gsettings, "form-factor"); | ||
219 | 59 | EXPECT_EQ(raw_form_factor, static_cast<int>(unity::FormFactor::NETBOOK)); | ||
220 | 60 | } | ||
221 | 61 | |||
222 | 62 | TEST_F(TestUnitySettings, GetFormFactor) | ||
223 | 63 | { | ||
224 | 64 | EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::DESKTOP); | ||
225 | 65 | |||
226 | 66 | g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::NETBOOK)); | ||
227 | 67 | EXPECT_EQ(unity_settings->form_factor(), unity::FormFactor::NETBOOK); | ||
228 | 68 | } | ||
229 | 69 | |||
230 | 70 | TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern) | ||
231 | 71 | { | ||
232 | 72 | bool signal_received = false; | ||
233 | 73 | unity::FormFactor new_form_factor; | ||
234 | 74 | unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) { | ||
235 | 75 | signal_received = true; | ||
236 | 76 | new_form_factor = form_factor; | ||
237 | 77 | }); | ||
238 | 78 | |||
239 | 79 | g_settings_set_enum(gsettings, "form-factor", static_cast<int>(unity::FormFactor::NETBOOK)); | ||
240 | 80 | Utils::WaitUntil(signal_received); | ||
241 | 81 | EXPECT_EQ(new_form_factor, unity::FormFactor::NETBOOK); | ||
242 | 82 | } | ||
243 | 83 | |||
244 | 84 | TEST_F(TestUnitySettings, FormFactorChangedSignal_Extern_OtherKeys) | ||
245 | 85 | { | ||
246 | 86 | bool signal_received = false; | ||
247 | 87 | unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) { | ||
248 | 88 | signal_received = true; | ||
249 | 89 | }); | ||
250 | 90 | |||
251 | 91 | g_settings_set_int(gsettings, "minimize-count", 0); | ||
252 | 92 | Utils::WaitForTimeout(1); | ||
253 | 93 | EXPECT_FALSE(signal_received); | ||
254 | 94 | } | ||
255 | 95 | |||
256 | 96 | TEST_F(TestUnitySettings, FormFactorChangedSignal_Inter) | ||
257 | 97 | { | ||
258 | 98 | bool signal_received = false; | ||
259 | 99 | unity::FormFactor new_form_factor; | ||
260 | 100 | unity_settings->form_factor.changed.connect([&](unity::FormFactor form_factor) { | ||
261 | 101 | signal_received = true; | ||
262 | 102 | new_form_factor = form_factor; | ||
263 | 103 | }); | ||
264 | 104 | |||
265 | 105 | unity_settings->form_factor = unity::FormFactor::NETBOOK; | ||
266 | 106 | Utils::WaitUntil(signal_received); | ||
267 | 107 | EXPECT_EQ(new_form_factor, unity::FormFactor::NETBOOK); | ||
268 | 108 | } | ||
269 | 109 | |||
270 | 110 | } | ||
271 | 0 | 111 | ||
272 | === modified file 'unity-shared/DashStyle.cpp' | |||
273 | --- unity-shared/DashStyle.cpp 2012-09-16 23:45:17 +0000 | |||
274 | +++ unity-shared/DashStyle.cpp 2012-09-18 13:56:19 +0000 | |||
275 | @@ -427,14 +427,14 @@ | |||
276 | 427 | style_instance = this; | 427 | style_instance = this; |
277 | 428 | } | 428 | } |
278 | 429 | 429 | ||
280 | 430 | auto formfactor_lambda = [this] () | 430 | auto formfactor_lambda = [this] (FormFactor) |
281 | 431 | { | 431 | { |
283 | 432 | FormFactor formfactor = Settings::Instance().GetFormFactor(); | 432 | FormFactor formfactor = Settings::Instance().form_factor(); |
284 | 433 | always_maximised = (formfactor == FormFactor::NETBOOK || formfactor == FormFactor::TV); | 433 | always_maximised = (formfactor == FormFactor::NETBOOK || formfactor == FormFactor::TV); |
285 | 434 | }; | 434 | }; |
286 | 435 | 435 | ||
289 | 436 | Settings::Instance().changed.connect(formfactor_lambda); | 436 | Settings::Instance().form_factor.changed.connect(formfactor_lambda); |
290 | 437 | formfactor_lambda(); | 437 | formfactor_lambda(FormFactor()); |
291 | 438 | } | 438 | } |
292 | 439 | 439 | ||
293 | 440 | Style::~Style () | 440 | Style::~Style () |
294 | 441 | 441 | ||
295 | === modified file 'unity-shared/OverlayRenderer.cpp' | |||
296 | --- unity-shared/OverlayRenderer.cpp 2012-09-14 10:26:33 +0000 | |||
297 | +++ unity-shared/OverlayRenderer.cpp 2012-09-18 13:56:19 +0000 | |||
298 | @@ -438,7 +438,7 @@ | |||
299 | 438 | bool paint_blur = BackgroundEffectHelper::blur_type != BLUR_NONE; | 438 | bool paint_blur = BackgroundEffectHelper::blur_type != BLUR_NONE; |
300 | 439 | nux::Geometry geo(content_geo); | 439 | nux::Geometry geo(content_geo); |
301 | 440 | 440 | ||
303 | 441 | int excess_border = (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK || force_edges) ? EXCESS_BORDER : 0; | 441 | int excess_border = (Settings::Instance().form_factor() != FormFactor::NETBOOK || force_edges) ? EXCESS_BORDER : 0; |
304 | 442 | 442 | ||
305 | 443 | nux::Geometry larger_content_geo = content_geo; | 443 | nux::Geometry larger_content_geo = content_geo; |
306 | 444 | larger_content_geo.OffsetSize(excess_border, excess_border); | 444 | larger_content_geo.OffsetSize(excess_border, excess_border); |
307 | @@ -578,7 +578,7 @@ | |||
308 | 578 | } | 578 | } |
309 | 579 | 579 | ||
310 | 580 | 580 | ||
312 | 581 | if (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK || force_edges) | 581 | if (Settings::Instance().form_factor() != FormFactor::NETBOOK || force_edges) |
313 | 582 | { | 582 | { |
314 | 583 | // Paint the edges | 583 | // Paint the edges |
315 | 584 | { | 584 | { |
316 | @@ -835,7 +835,7 @@ | |||
317 | 835 | nux::Geometry geo = geometry; | 835 | nux::Geometry geo = geometry; |
318 | 836 | bgs = 0; | 836 | bgs = 0; |
319 | 837 | 837 | ||
321 | 838 | int excess_border = (Settings::Instance().GetFormFactor() != FormFactor::NETBOOK) ? EXCESS_BORDER : 0; | 838 | int excess_border = (Settings::Instance().form_factor() != FormFactor::NETBOOK) ? EXCESS_BORDER : 0; |
322 | 839 | 839 | ||
323 | 840 | nux::Geometry larger_content_geo = content_geo; | 840 | nux::Geometry larger_content_geo = content_geo; |
324 | 841 | larger_content_geo.OffsetSize(excess_border, excess_border); | 841 | larger_content_geo.OffsetSize(excess_border, excess_border); |
325 | 842 | 842 | ||
326 | === modified file 'unity-shared/PanelStyle.cpp' | |||
327 | --- unity-shared/PanelStyle.cpp 2012-08-29 18:29:18 +0000 | |||
328 | +++ unity-shared/PanelStyle.cpp 2012-09-18 13:56:19 +0000 | |||
329 | @@ -73,12 +73,12 @@ | |||
330 | 73 | style_instance = this; | 73 | style_instance = this; |
331 | 74 | } | 74 | } |
332 | 75 | 75 | ||
334 | 76 | if (Settings::Instance().GetFormFactor() == FormFactor::TV) | 76 | if (Settings::Instance().form_factor() == FormFactor::TV) |
335 | 77 | panel_height = 0; | 77 | panel_height = 0; |
336 | 78 | 78 | ||
338 | 79 | Settings::Instance().changed.connect([this]() | 79 | Settings::Instance().form_factor.changed.connect([this](FormFactor form_factor) |
339 | 80 | { | 80 | { |
341 | 81 | if (Settings::Instance().GetFormFactor() == FormFactor::TV) | 81 | if (form_factor == FormFactor::TV) |
342 | 82 | panel_height = 0; | 82 | panel_height = 0; |
343 | 83 | }); | 83 | }); |
344 | 84 | 84 | ||
345 | 85 | 85 | ||
346 | === modified file 'unity-shared/UnitySettings.cpp' | |||
347 | --- unity-shared/UnitySettings.cpp 2012-05-22 14:33:41 +0000 | |||
348 | +++ unity-shared/UnitySettings.cpp 2012-09-18 13:56:19 +0000 | |||
349 | @@ -1,6 +1,6 @@ | |||
350 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
351 | 2 | /* | 2 | /* |
353 | 3 | * Copyright (C) 2010, 2011 Canonical Ltd | 3 | * Copyright (C) 2010, 2011, 2012 Canonical Ltd |
354 | 4 | * | 4 | * |
355 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
356 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
357 | @@ -15,6 +15,7 @@ | |||
358 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
359 | 16 | * | 16 | * |
360 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
361 | 18 | * Andrea Azzarone <andrea.azzarone@canonical.com> | ||
362 | 18 | */ | 19 | */ |
363 | 19 | 20 | ||
364 | 20 | #include <gdk/gdk.h> | 21 | #include <gdk/gdk.h> |
365 | @@ -32,81 +33,69 @@ | |||
366 | 32 | nux::logging::Logger logger("unity"); | 33 | nux::logging::Logger logger("unity"); |
367 | 33 | 34 | ||
368 | 34 | Settings* settings_instance = nullptr; | 35 | Settings* settings_instance = nullptr; |
370 | 35 | const char* const FORM_FACTOR = "form-factor"; | 36 | |
371 | 37 | const std::string SETTINGS_NAME = "com.canonical.Unity"; | ||
372 | 38 | const std::string FORM_FACTOR = "form-factor"; | ||
373 | 36 | } | 39 | } |
374 | 37 | 40 | ||
375 | 41 | // | ||
376 | 42 | // Start private implementation | ||
377 | 43 | // | ||
378 | 38 | class Settings::Impl | 44 | class Settings::Impl |
379 | 39 | { | 45 | { |
380 | 40 | public: | 46 | public: |
395 | 41 | Impl(Settings* owner); | 47 | Impl(Settings* owner) |
396 | 42 | ~Impl(); | 48 | : parent_(owner) |
397 | 43 | 49 | , gsettings_(g_settings_new(SETTINGS_NAME.c_str())) | |
398 | 44 | FormFactor GetFormFactor() const; | 50 | , cached_form_factor_(FormFactor::DESKTOP) |
399 | 45 | void SetFormFactor(FormFactor factor); | 51 | { |
400 | 46 | 52 | CacheFormFactor(); | |
401 | 47 | private: | 53 | |
402 | 48 | void Refresh(); | 54 | form_factor_changed_.Connect(gsettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, gchar*) { |
403 | 49 | static void Changed(GSettings* settings, gchar* key, Impl* self); | 55 | CacheFormFactor(); |
404 | 50 | 56 | parent_->form_factor.changed.emit(cached_form_factor_); | |
405 | 51 | private: | 57 | }); |
406 | 52 | Settings* owner_; | 58 | } |
407 | 53 | GSettings* settings_; | 59 | |
408 | 54 | FormFactor form_factor_; | 60 | void CacheFormFactor() |
409 | 61 | { | ||
410 | 62 | int raw_from_factor = g_settings_get_enum(gsettings_, FORM_FACTOR.c_str()); | ||
411 | 63 | |||
412 | 64 | if (raw_from_factor == 0) //Automatic | ||
413 | 65 | { | ||
414 | 66 | auto uscreen = UScreen::GetDefault(); | ||
415 | 67 | int primary_monitor = uscreen->GetMonitorWithMouse(); | ||
416 | 68 | auto const& geo = uscreen->GetMonitorGeometry(primary_monitor); | ||
417 | 69 | |||
418 | 70 | cached_form_factor_ = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK; | ||
419 | 71 | } | ||
420 | 72 | else | ||
421 | 73 | { | ||
422 | 74 | cached_form_factor_ = static_cast<FormFactor>(raw_from_factor); | ||
423 | 75 | } | ||
424 | 76 | } | ||
425 | 77 | |||
426 | 78 | FormFactor GetFormFactor() const | ||
427 | 79 | { | ||
428 | 80 | return cached_form_factor_; | ||
429 | 81 | } | ||
430 | 82 | |||
431 | 83 | bool SetFormFactor(FormFactor factor) | ||
432 | 84 | { | ||
433 | 85 | g_settings_set_enum(gsettings_, FORM_FACTOR.c_str(), static_cast<int>(factor)); | ||
434 | 86 | return true; | ||
435 | 87 | } | ||
436 | 88 | |||
437 | 89 | Settings* parent_; | ||
438 | 90 | glib::Object<GSettings> gsettings_; | ||
439 | 91 | FormFactor cached_form_factor_; | ||
440 | 92 | |||
441 | 93 | glib::Signal<void, GSettings*, gchar* > form_factor_changed_; | ||
442 | 55 | }; | 94 | }; |
443 | 56 | 95 | ||
497 | 57 | 96 | // | |
498 | 58 | Settings::Impl::Impl(Settings* owner) | 97 | // End private implementation |
499 | 59 | : owner_(owner) | 98 | // |
447 | 60 | , settings_(nullptr) | ||
448 | 61 | , form_factor_(FormFactor::DESKTOP) | ||
449 | 62 | { | ||
450 | 63 | settings_ = g_settings_new("com.canonical.Unity"); | ||
451 | 64 | g_signal_connect(settings_, "changed", | ||
452 | 65 | (GCallback)(Impl::Changed), this); | ||
453 | 66 | Refresh(); | ||
454 | 67 | } | ||
455 | 68 | |||
456 | 69 | Settings::Impl::~Impl() | ||
457 | 70 | { | ||
458 | 71 | g_object_unref(settings_); | ||
459 | 72 | } | ||
460 | 73 | |||
461 | 74 | void Settings::Impl::Refresh() | ||
462 | 75 | { | ||
463 | 76 | int raw_from_factor = g_settings_get_enum(settings_, FORM_FACTOR); | ||
464 | 77 | |||
465 | 78 | if (raw_from_factor == 0) //Automatic | ||
466 | 79 | { | ||
467 | 80 | UScreen *uscreen = UScreen::GetDefault(); | ||
468 | 81 | int primary_monitor = uscreen->GetMonitorWithMouse(); | ||
469 | 82 | auto geo = uscreen->GetMonitorGeometry(primary_monitor); | ||
470 | 83 | |||
471 | 84 | form_factor_ = geo.height > 799 ? FormFactor::DESKTOP : FormFactor::NETBOOK; | ||
472 | 85 | } | ||
473 | 86 | else | ||
474 | 87 | { | ||
475 | 88 | form_factor_ = static_cast<FormFactor>(raw_from_factor); | ||
476 | 89 | } | ||
477 | 90 | |||
478 | 91 | owner_->changed.emit(); | ||
479 | 92 | } | ||
480 | 93 | |||
481 | 94 | void Settings::Impl::Changed(GSettings* settings, char* key, Impl* self) | ||
482 | 95 | { | ||
483 | 96 | self->Refresh(); | ||
484 | 97 | } | ||
485 | 98 | |||
486 | 99 | FormFactor Settings::Impl::GetFormFactor() const | ||
487 | 100 | { | ||
488 | 101 | return form_factor_; | ||
489 | 102 | } | ||
490 | 103 | |||
491 | 104 | void Settings::Impl::SetFormFactor(FormFactor factor) | ||
492 | 105 | { | ||
493 | 106 | form_factor_ = factor; | ||
494 | 107 | g_settings_set_enum(settings_, FORM_FACTOR, static_cast<int>(factor)); | ||
495 | 108 | owner_->changed.emit(); | ||
496 | 109 | } | ||
500 | 110 | 99 | ||
501 | 111 | Settings::Settings() | 100 | Settings::Settings() |
502 | 112 | : is_standalone(false) | 101 | : is_standalone(false) |
503 | @@ -118,13 +107,15 @@ | |||
504 | 118 | } | 107 | } |
505 | 119 | else | 108 | else |
506 | 120 | { | 109 | { |
507 | 110 | form_factor.SetGetterFunction(sigc::mem_fun(*pimpl, &Impl::GetFormFactor)); | ||
508 | 111 | form_factor.SetSetterFunction(sigc::mem_fun(*pimpl, &Impl::SetFormFactor)); | ||
509 | 112 | |||
510 | 121 | settings_instance = this; | 113 | settings_instance = this; |
511 | 122 | } | 114 | } |
512 | 123 | } | 115 | } |
513 | 124 | 116 | ||
514 | 125 | Settings::~Settings() | 117 | Settings::~Settings() |
515 | 126 | { | 118 | { |
516 | 127 | delete pimpl; | ||
517 | 128 | if (settings_instance == this) | 119 | if (settings_instance == this) |
518 | 129 | settings_instance = nullptr; | 120 | settings_instance = nullptr; |
519 | 130 | } | 121 | } |
520 | @@ -139,15 +130,5 @@ | |||
521 | 139 | return *settings_instance; | 130 | return *settings_instance; |
522 | 140 | } | 131 | } |
523 | 141 | 132 | ||
524 | 142 | FormFactor Settings::GetFormFactor() const | ||
525 | 143 | { | ||
526 | 144 | return pimpl->GetFormFactor(); | ||
527 | 145 | } | ||
528 | 146 | |||
529 | 147 | void Settings::SetFormFactor(FormFactor factor) | ||
530 | 148 | { | ||
531 | 149 | pimpl->SetFormFactor(factor); | ||
532 | 150 | } | ||
533 | 151 | |||
534 | 152 | 133 | ||
535 | 153 | } // namespace unity | 134 | } // namespace unity |
536 | 154 | 135 | ||
537 | === modified file 'unity-shared/UnitySettings.h' | |||
538 | --- unity-shared/UnitySettings.h 2012-05-22 14:33:41 +0000 | |||
539 | +++ unity-shared/UnitySettings.h 2012-09-18 13:56:19 +0000 | |||
540 | @@ -1,6 +1,6 @@ | |||
541 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
542 | 2 | /* | 2 | /* |
544 | 3 | * Copyright (C) 2010, 2011 Canonical Ltd | 3 | * Copyright (C) 2010, 2011, 2012 Canonical Ltd |
545 | 4 | * | 4 | * |
546 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
547 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
548 | @@ -15,11 +15,13 @@ | |||
549 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
550 | 16 | * | 16 | * |
551 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
552 | 18 | * Andrea Azzarone <andrea.azzarone@canonical.com> | ||
553 | 18 | */ | 19 | */ |
554 | 19 | 20 | ||
557 | 20 | #ifndef UNITY_SETTINGS_H | 21 | #ifndef UNITYSHELL_SETTINGS_H |
558 | 21 | #define UNITY_SETTINGS_H | 22 | #define UNITYSHELL_SETTINGS_H |
559 | 22 | 23 | ||
560 | 24 | #include <memory> | ||
561 | 23 | #include <sigc++/signal.h> | 25 | #include <sigc++/signal.h> |
562 | 24 | #include <Nux/Nux.h> | 26 | #include <Nux/Nux.h> |
563 | 25 | 27 | ||
564 | @@ -29,7 +31,7 @@ | |||
565 | 29 | enum class FormFactor | 31 | enum class FormFactor |
566 | 30 | { | 32 | { |
567 | 31 | DESKTOP = 1, | 33 | DESKTOP = 1, |
569 | 32 | NETBOOK = 2, | 34 | NETBOOK, |
570 | 33 | TV | 35 | TV |
571 | 34 | }; | 36 | }; |
572 | 35 | 37 | ||
573 | @@ -41,18 +43,14 @@ | |||
574 | 41 | 43 | ||
575 | 42 | static Settings& Instance(); | 44 | static Settings& Instance(); |
576 | 43 | 45 | ||
581 | 44 | // NOTE: could potentially refactor this into a nux::Property | 46 | nux::RWProperty<FormFactor> form_factor; |
578 | 45 | FormFactor GetFormFactor() const; | ||
579 | 46 | void SetFormFactor(FormFactor factor); | ||
580 | 47 | |||
582 | 48 | nux::Property<bool> is_standalone; | 47 | nux::Property<bool> is_standalone; |
583 | 49 | sigc::signal<void> changed; | ||
584 | 50 | 48 | ||
585 | 51 | private: | 49 | private: |
586 | 52 | class Impl; | 50 | class Impl; |
588 | 53 | Impl* pimpl; | 51 | std::unique_ptr<Impl> pimpl; |
589 | 54 | }; | 52 | }; |
590 | 55 | 53 | ||
591 | 56 | } | 54 | } |
592 | 57 | 55 | ||
594 | 58 | #endif // UNITY_SETTINGS_H | 56 | #endif |
595 | 59 | 57 | ||
596 | === modified file 'unity-standalone/StandaloneUnity.cpp' | |||
597 | --- unity-standalone/StandaloneUnity.cpp 2012-09-11 13:57:19 +0000 | |||
598 | +++ unity-standalone/StandaloneUnity.cpp 2012-09-18 13:56:19 +0000 | |||
599 | @@ -160,7 +160,7 @@ | |||
600 | 160 | // The instances for the pseudo-singletons. | 160 | // The instances for the pseudo-singletons. |
601 | 161 | Settings settings; | 161 | Settings settings; |
602 | 162 | settings.is_standalone = true; | 162 | settings.is_standalone = true; |
604 | 163 | if (force_tv) Settings::Instance().SetFormFactor(FormFactor::TV); | 163 | if (force_tv) Settings::Instance().form_factor(FormFactor::TV); |
605 | 164 | 164 | ||
606 | 165 | PluginAdapter::Initialize(NULL); | 165 | PluginAdapter::Initialize(NULL); |
607 | 166 | dash::Style dash_style; | 166 | dash::Style dash_style; |
fix works for me.