Merge lp:~3v1n0/unity/compiz-average-color into lp:unity
- compiz-average-color
- Merge into trunk
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4244 |
Proposed branch: | lp:~3v1n0/unity/compiz-average-color |
Merge into: | lp:unity |
Diff against target: |
364 lines (+63/-114) 7 files modified
debian/control (+2/-1) plugins/unityshell/src/unityshell.cpp (+31/-46) plugins/unityshell/src/unityshell.h (+2/-1) tools/CMakeLists.txt (+1/-1) tools/compiz_config_profile_setter.c (+2/-2) unity-shared/BGHash.cpp (+22/-59) unity-shared/BGHash.h (+3/-4) |
To merge this branch: | bzr merge lp:~3v1n0/unity/compiz-average-color |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone (community) | Approve | ||
Review via email: mp+326571@code.launchpad.net |
Commit message
BGHash, UnityScreen: get desktop averageColor from compiz
compiz now supports getting this value, let's use it instead of
doing this again here.
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2017-06-19 09:00:18 +0000 | |||
3 | +++ debian/control 2017-07-03 15:31:53 +0000 | |||
4 | @@ -3,9 +3,10 @@ | |||
5 | 3 | Priority: optional | 3 | Priority: optional |
6 | 4 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> | 4 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
7 | 5 | Build-Depends: cmake, | 5 | Build-Depends: cmake, |
9 | 6 | compiz-dev (>= 1:0.9.12.2), | 6 | compiz-dev (>= 1:0.9.13.1+17.10.20170630), |
10 | 7 | debhelper (>= 9.0.0~), | 7 | debhelper (>= 9.0.0~), |
11 | 8 | dbus-test-runner, | 8 | dbus-test-runner, |
12 | 9 | dbus-x11, | ||
13 | 9 | dh-migrations, | 10 | dh-migrations, |
14 | 10 | dh-translations (>= 94), | 11 | dh-translations (>= 94), |
15 | 11 | dh-python, | 12 | dh-python, |
16 | 12 | 13 | ||
17 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
18 | --- plugins/unityshell/src/unityshell.cpp 2017-04-05 07:58:57 +0000 | |||
19 | +++ plugins/unityshell/src/unityshell.cpp 2017-07-03 15:31:53 +0000 | |||
20 | @@ -482,9 +482,10 @@ | |||
21 | 482 | 482 | ||
22 | 483 | Introspectable::AddChild(deco_manager_.get()); | 483 | Introspectable::AddChild(deco_manager_.get()); |
23 | 484 | auto const& deco_style = decoration::Style::Get(); | 484 | auto const& deco_style = decoration::Style::Get(); |
25 | 485 | auto deco_style_cb = sigc::hide(sigc::mem_fun(this, &UnityScreen::OnDecorationStyleChanged)); | 485 | auto deco_style_cb = sigc::hide(sigc::mem_fun(this, &UnityScreen::UpdateDecorationStyle)); |
26 | 486 | deco_style->theme.changed.connect(deco_style_cb); | 486 | deco_style->theme.changed.connect(deco_style_cb); |
27 | 487 | deco_style->title_font.changed.connect(deco_style_cb); | 487 | deco_style->title_font.changed.connect(deco_style_cb); |
28 | 488 | UpdateDecorationStyle(); | ||
29 | 488 | 489 | ||
30 | 489 | minimize_speed_controller_.DurationChanged.connect( | 490 | minimize_speed_controller_.DurationChanged.connect( |
31 | 490 | sigc::mem_fun(this, &UnityScreen::OnMinimizeDurationChanged) | 491 | sigc::mem_fun(this, &UnityScreen::OnMinimizeDurationChanged) |
32 | @@ -864,17 +865,28 @@ | |||
33 | 864 | wy = y + (last_bound.height - height) / 2; | 865 | wy = y + (last_bound.height - height) / 2; |
34 | 865 | } | 866 | } |
35 | 866 | 867 | ||
37 | 867 | void UnityScreen::OnDecorationStyleChanged() | 868 | void UnityScreen::UpdateDecorationStyle() |
38 | 868 | { | 869 | { |
39 | 869 | for (UnityWindow* uwin : fake_decorated_windows_) | 870 | for (UnityWindow* uwin : fake_decorated_windows_) |
40 | 870 | uwin->CleanupCachedTextures(); | 871 | uwin->CleanupCachedTextures(); |
41 | 871 | 872 | ||
48 | 872 | auto const& style = decoration::Style::Get(); | 873 | if (optionGetOverrideDecorationTheme()) |
49 | 873 | deco_manager_->shadow_offset = style->ShadowOffset(); | 874 | { |
50 | 874 | deco_manager_->active_shadow_color = style->ActiveShadowColor(); | 875 | deco_manager_->active_shadow_color = NuxColorFromCompizColor(optionGetActiveShadowColor()); |
51 | 875 | deco_manager_->active_shadow_radius = style->ActiveShadowRadius(); | 876 | deco_manager_->inactive_shadow_color = NuxColorFromCompizColor(optionGetInactiveShadowColor()); |
52 | 876 | deco_manager_->inactive_shadow_color = style->InactiveShadowColor(); | 877 | deco_manager_->active_shadow_radius = optionGetActiveShadowRadius(); |
53 | 877 | deco_manager_->inactive_shadow_radius = style->InactiveShadowRadius(); | 878 | deco_manager_->inactive_shadow_radius = optionGetInactiveShadowRadius(); |
54 | 879 | deco_manager_->shadow_offset = nux::Point(optionGetShadowXOffset(), optionGetShadowYOffset()); | ||
55 | 880 | } | ||
56 | 881 | else | ||
57 | 882 | { | ||
58 | 883 | auto const& style = decoration::Style::Get(); | ||
59 | 884 | deco_manager_->shadow_offset = style->ShadowOffset(); | ||
60 | 885 | deco_manager_->active_shadow_color = style->ActiveShadowColor(); | ||
61 | 886 | deco_manager_->active_shadow_radius = style->ActiveShadowRadius(); | ||
62 | 887 | deco_manager_->inactive_shadow_color = style->InactiveShadowColor(); | ||
63 | 888 | deco_manager_->inactive_shadow_radius = style->InactiveShadowRadius(); | ||
64 | 889 | } | ||
65 | 878 | } | 890 | } |
66 | 879 | 891 | ||
67 | 880 | void UnityScreen::DamageBlurUpdateRegion(nux::Geometry const& blur_update) | 892 | void UnityScreen::DamageBlurUpdateRegion(nux::Geometry const& blur_update) |
68 | @@ -2061,13 +2073,6 @@ | |||
69 | 2061 | case MapRequest: | 2073 | case MapRequest: |
70 | 2062 | ShowdesktopHandler::InhibitLeaveShowdesktopMode (event->xmaprequest.window); | 2074 | ShowdesktopHandler::InhibitLeaveShowdesktopMode (event->xmaprequest.window); |
71 | 2063 | break; | 2075 | break; |
72 | 2064 | case PropertyNotify: | ||
73 | 2065 | if (bghash_ && event->xproperty.window == GDK_ROOT_WINDOW() && | ||
74 | 2066 | event->xproperty.atom == bghash_->ColorAtomId()) | ||
75 | 2067 | { | ||
76 | 2068 | bghash_->RefreshColor(); | ||
77 | 2069 | } | ||
78 | 2070 | break; | ||
79 | 2071 | default: | 2076 | default: |
80 | 2072 | if (screen->shapeEvent() + ShapeNotify == event->type) | 2077 | if (screen->shapeEvent() + ShapeNotify == event->type) |
81 | 2073 | { | 2078 | { |
82 | @@ -3617,43 +3622,16 @@ | |||
83 | 3617 | break; | 3622 | break; |
84 | 3618 | } | 3623 | } |
85 | 3619 | case UnityshellOptions::OverrideDecorationTheme: | 3624 | case UnityshellOptions::OverrideDecorationTheme: |
86 | 3620 | if (optionGetOverrideDecorationTheme()) | ||
87 | 3621 | { | ||
88 | 3622 | deco_manager_->active_shadow_color = NuxColorFromCompizColor(optionGetActiveShadowColor()); | ||
89 | 3623 | deco_manager_->inactive_shadow_color = NuxColorFromCompizColor(optionGetInactiveShadowColor()); | ||
90 | 3624 | deco_manager_->active_shadow_radius = optionGetActiveShadowRadius(); | ||
91 | 3625 | deco_manager_->inactive_shadow_radius = optionGetInactiveShadowRadius(); | ||
92 | 3626 | deco_manager_->shadow_offset = nux::Point(optionGetShadowXOffset(), optionGetShadowYOffset()); | ||
93 | 3627 | } | ||
94 | 3628 | else | ||
95 | 3629 | { | ||
96 | 3630 | OnDecorationStyleChanged(); | ||
97 | 3631 | } | ||
98 | 3632 | break; | ||
99 | 3633 | case UnityshellOptions::ActiveShadowColor: | 3625 | case UnityshellOptions::ActiveShadowColor: |
103 | 3634 | if (optionGetOverrideDecorationTheme()) | 3626 | case UnityshellOptions::ActiveShadowRadius: |
101 | 3635 | deco_manager_->active_shadow_color = NuxColorFromCompizColor(optionGetActiveShadowColor()); | ||
102 | 3636 | break; | ||
104 | 3637 | case UnityshellOptions::InactiveShadowColor: | 3627 | case UnityshellOptions::InactiveShadowColor: |
105 | 3638 | if (optionGetOverrideDecorationTheme()) | ||
106 | 3639 | deco_manager_->inactive_shadow_color = NuxColorFromCompizColor(optionGetInactiveShadowColor()); | ||
107 | 3640 | break; | ||
108 | 3641 | case UnityshellOptions::ActiveShadowRadius: | ||
109 | 3642 | if (optionGetOverrideDecorationTheme()) | ||
110 | 3643 | deco_manager_->active_shadow_radius = optionGetActiveShadowRadius(); | ||
111 | 3644 | break; | ||
112 | 3645 | case UnityshellOptions::InactiveShadowRadius: | 3628 | case UnityshellOptions::InactiveShadowRadius: |
113 | 3646 | if (optionGetOverrideDecorationTheme()) | ||
114 | 3647 | deco_manager_->inactive_shadow_radius = optionGetInactiveShadowRadius(); | ||
115 | 3648 | break; | ||
116 | 3649 | case UnityshellOptions::ShadowXOffset: | 3629 | case UnityshellOptions::ShadowXOffset: |
117 | 3650 | if (optionGetOverrideDecorationTheme()) | ||
118 | 3651 | deco_manager_->shadow_offset = nux::Point(optionGetShadowXOffset(), optionGetShadowYOffset()); | ||
119 | 3652 | break; | ||
120 | 3653 | case UnityshellOptions::ShadowYOffset: | 3630 | case UnityshellOptions::ShadowYOffset: |
123 | 3654 | if (optionGetOverrideDecorationTheme()) | 3631 | { |
124 | 3655 | deco_manager_->shadow_offset = nux::Point(optionGetShadowXOffset(), optionGetShadowYOffset()); | 3632 | UpdateDecorationStyle(); |
125 | 3656 | break; | 3633 | break; |
126 | 3634 | } | ||
127 | 3657 | case UnityshellOptions::LauncherHideMode: | 3635 | case UnityshellOptions::LauncherHideMode: |
128 | 3658 | { | 3636 | { |
129 | 3659 | launcher_options->hide_mode = (launcher::LauncherHideMode) optionGetLauncherHideMode(); | 3637 | launcher_options->hide_mode = (launcher::LauncherHideMode) optionGetLauncherHideMode(); |
130 | @@ -3854,6 +3832,12 @@ | |||
131 | 3854 | ScheduleRelayout(500); | 3832 | ScheduleRelayout(500); |
132 | 3855 | } | 3833 | } |
133 | 3856 | 3834 | ||
134 | 3835 | void UnityScreen::averageColorChangeNotify(const unsigned short *color) | ||
135 | 3836 | { | ||
136 | 3837 | bghash_->UpdateColor(color, nux::animation::Animation::State::Running); | ||
137 | 3838 | screen->averageColorChangeNotify (color); | ||
138 | 3839 | } | ||
139 | 3840 | |||
140 | 3857 | bool UnityScreen::layoutSlotsAndAssignWindows() | 3841 | bool UnityScreen::layoutSlotsAndAssignWindows() |
141 | 3858 | { | 3842 | { |
142 | 3859 | auto const& scaled_windows = sScreen->getWindows(); | 3843 | auto const& scaled_windows = sScreen->getWindows(); |
143 | @@ -4078,6 +4062,7 @@ | |||
144 | 4078 | nux::GetWindowCompositor().sigHiddenViewWindow.connect(sigc::mem_fun(this, &UnityScreen::OnViewHidden)); | 4062 | nux::GetWindowCompositor().sigHiddenViewWindow.connect(sigc::mem_fun(this, &UnityScreen::OnViewHidden)); |
145 | 4079 | 4063 | ||
146 | 4080 | bghash_.reset(new BGHash()); | 4064 | bghash_.reset(new BGHash()); |
147 | 4065 | bghash_->UpdateColor(screen->averageColor(), nux::animation::Animation::State::Stopped); | ||
148 | 4081 | LOG_INFO(logger) << "InitUnityComponents-BGHash " << timer.ElapsedSeconds() << "s"; | 4066 | LOG_INFO(logger) << "InitUnityComponents-BGHash " << timer.ElapsedSeconds() << "s"; |
149 | 4082 | 4067 | ||
150 | 4083 | auto xdnd_collection_window = std::make_shared<XdndCollectionWindowImp>(); | 4068 | auto xdnd_collection_window = std::make_shared<XdndCollectionWindowImp>(); |
151 | 4084 | 4069 | ||
152 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
153 | --- plugins/unityshell/src/unityshell.h 2017-01-09 15:09:26 +0000 | |||
154 | +++ plugins/unityshell/src/unityshell.h 2017-07-03 15:31:53 +0000 | |||
155 | @@ -163,6 +163,7 @@ | |||
156 | 163 | bool initPluginForScreen(CompPlugin* p) override; | 163 | bool initPluginForScreen(CompPlugin* p) override; |
157 | 164 | 164 | ||
158 | 165 | void outputChangeNotify() override; | 165 | void outputChangeNotify() override; |
159 | 166 | void averageColorChangeNotify(const unsigned short *color) override; | ||
160 | 166 | 167 | ||
161 | 167 | CompAction::Vector& getActions() override; | 168 | CompAction::Vector& getActions() override; |
162 | 168 | 169 | ||
163 | @@ -282,7 +283,7 @@ | |||
164 | 282 | 283 | ||
165 | 283 | bool SaveInputThenFocus(const guint xid); | 284 | bool SaveInputThenFocus(const guint xid); |
166 | 284 | 285 | ||
168 | 285 | void OnDecorationStyleChanged(); | 286 | void UpdateDecorationStyle(); |
169 | 286 | 287 | ||
170 | 287 | void InitGesturesSupport(); | 288 | void InitGesturesSupport(); |
171 | 288 | void UpdateGesturesSupport(); | 289 | void UpdateGesturesSupport(); |
172 | 289 | 290 | ||
173 | === modified file 'tools/CMakeLists.txt' | |||
174 | --- tools/CMakeLists.txt 2017-03-27 19:33:50 +0000 | |||
175 | +++ tools/CMakeLists.txt 2017-07-03 15:31:53 +0000 | |||
176 | @@ -21,7 +21,7 @@ | |||
177 | 21 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFLAGS}") | 21 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFLAGS}") |
178 | 22 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFLAGS}") | 22 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFLAGS}") |
179 | 23 | 23 | ||
181 | 24 | set(LIBS ${UAPSC_DEPS_LIBRARIES}) | 24 | set(LIBS ${UAPSC_DEPS_LIBRARIES} -lm) |
182 | 25 | 25 | ||
183 | 26 | set(LIB_PATHS ${UAPSC_DEPS_LIBRARY_DIRS}) | 26 | set(LIB_PATHS ${UAPSC_DEPS_LIBRARY_DIRS}) |
184 | 27 | link_directories(${LIB_PATHS}) | 27 | link_directories(${LIB_PATHS}) |
185 | 28 | 28 | ||
186 | === modified file 'tools/compiz_config_profile_setter.c' | |||
187 | --- tools/compiz_config_profile_setter.c 2017-04-25 17:58:23 +0000 | |||
188 | +++ tools/compiz_config_profile_setter.c 2017-07-03 15:31:53 +0000 | |||
189 | @@ -130,7 +130,7 @@ | |||
190 | 130 | static gboolean | 130 | static gboolean |
191 | 131 | set_compiz_profile (CCSContext *ccs_context, const gchar *profile_name) | 131 | set_compiz_profile (CCSContext *ccs_context, const gchar *profile_name) |
192 | 132 | { | 132 | { |
194 | 133 | CCSPluginList plugins; | 133 | CCSPluginList plugins, p; |
195 | 134 | const char *ccs_backend; | 134 | const char *ccs_backend; |
196 | 135 | 135 | ||
197 | 136 | ccs_backend = ccsGetBackend (ccs_context); | 136 | ccs_backend = ccsGetBackend (ccs_context); |
198 | @@ -144,7 +144,7 @@ | |||
199 | 144 | 144 | ||
200 | 145 | plugins = ccsContextGetPlugins (ccs_context); | 145 | plugins = ccsContextGetPlugins (ccs_context); |
201 | 146 | 146 | ||
203 | 147 | for (CCSPluginList p = plugins; p; p = p->next) | 147 | for (p = plugins; p; p = p->next) |
204 | 148 | { | 148 | { |
205 | 149 | CCSPlugin* plugin = p->data; | 149 | CCSPlugin* plugin = p->data; |
206 | 150 | ccsReadPluginSettings (plugin); | 150 | ccsReadPluginSettings (plugin); |
207 | 151 | 151 | ||
208 | === modified file 'unity-shared/BGHash.cpp' | |||
209 | --- unity-shared/BGHash.cpp 2016-07-04 14:51:28 +0000 | |||
210 | +++ unity-shared/BGHash.cpp 2017-07-03 15:31:53 +0000 | |||
211 | @@ -1,5 +1,5 @@ | |||
212 | 1 | /* | 1 | /* |
214 | 2 | * Copyright (C) 2011-2012 Canonical Ltd | 2 | * Copyright (C) 2011-2017 Canonical Ltd |
215 | 3 | * | 3 | * |
216 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
217 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
218 | @@ -14,6 +14,7 @@ | |||
219 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
220 | 15 | * | 15 | * |
221 | 16 | * Authored by: Gordon Allott <gord.alott@canonical.com> | 16 | * Authored by: Gordon Allott <gord.alott@canonical.com> |
222 | 17 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
223 | 17 | */ | 18 | */ |
224 | 18 | 19 | ||
225 | 19 | 20 | ||
226 | @@ -23,18 +24,13 @@ | |||
227 | 23 | #include "unity-shared/UnitySettings.h" | 24 | #include "unity-shared/UnitySettings.h" |
228 | 24 | #include "unity-shared/WindowManager.h" | 25 | #include "unity-shared/WindowManager.h" |
229 | 25 | 26 | ||
235 | 26 | #ifndef XA_STRING | 27 | namespace na = nux::animation; |
231 | 27 | #define XA_STRING ((Atom) 31) | ||
232 | 28 | #endif | ||
233 | 29 | |||
234 | 30 | DECLARE_LOGGER(logger, "unity.bghash"); | ||
236 | 31 | 28 | ||
237 | 32 | namespace unity | 29 | namespace unity |
238 | 33 | { | 30 | { |
239 | 34 | |||
240 | 35 | namespace | 31 | namespace |
241 | 36 | { | 32 | { |
243 | 37 | Atom COLORS_ATOM = 0; | 33 | DECLARE_LOGGER(logger, "unity.bghash"); |
244 | 38 | const unsigned TRANSITION_DURATION = 500; | 34 | const unsigned TRANSITION_DURATION = 500; |
245 | 39 | } | 35 | } |
246 | 40 | 36 | ||
247 | @@ -42,77 +38,44 @@ | |||
248 | 42 | : transition_animator_(Settings::Instance().low_gfx() ? 0 : TRANSITION_DURATION) | 38 | : transition_animator_(Settings::Instance().low_gfx() ? 0 : TRANSITION_DURATION) |
249 | 43 | , override_color_(nux::color::Transparent) | 39 | , override_color_(nux::color::Transparent) |
250 | 44 | { | 40 | { |
251 | 45 | COLORS_ATOM = gdk_x11_get_xatom_by_name("_GNOME_BACKGROUND_REPRESENTATIVE_COLORS"); | ||
252 | 46 | transition_animator_.updated.connect(sigc::mem_fun(this, &BGHash::OnTransitionUpdated)); | 41 | transition_animator_.updated.connect(sigc::mem_fun(this, &BGHash::OnTransitionUpdated)); |
253 | 47 | WindowManager::Default().average_color = unity::colors::Aubergine; | 42 | WindowManager::Default().average_color = unity::colors::Aubergine; |
254 | 48 | RefreshColor(/* skip_animation */ true); | ||
255 | 49 | 43 | ||
256 | 50 | Settings::Instance().low_gfx.changed.connect(sigc::track_obj([this] (bool low_gfx) { | 44 | Settings::Instance().low_gfx.changed.connect(sigc::track_obj([this] (bool low_gfx) { |
257 | 51 | transition_animator_.SetDuration(low_gfx ? 0 : TRANSITION_DURATION); | 45 | transition_animator_.SetDuration(low_gfx ? 0 : TRANSITION_DURATION); |
258 | 52 | }, *this)); | 46 | }, *this)); |
259 | 53 | } | 47 | } |
260 | 54 | 48 | ||
261 | 55 | uint64_t BGHash::ColorAtomId() const | ||
262 | 56 | { | ||
263 | 57 | return COLORS_ATOM; | ||
264 | 58 | } | ||
265 | 59 | |||
266 | 60 | void BGHash::OverrideColor(nux::Color const& color) | 49 | void BGHash::OverrideColor(nux::Color const& color) |
267 | 61 | { | 50 | { |
268 | 62 | override_color_ = color; | 51 | override_color_ = color; |
270 | 63 | RefreshColor(); | 52 | TransitionToNewColor(override_color_, nux::animation::Animation::State::Running); |
271 | 64 | } | 53 | } |
272 | 65 | 54 | ||
274 | 66 | void BGHash::RefreshColor(bool skip_animation) | 55 | void BGHash::UpdateColor(const unsigned short *color, na::Animation::State animate) |
275 | 67 | { | 56 | { |
276 | 68 | if (override_color_.alpha > 0.0f) | 57 | if (override_color_.alpha > 0.0f) |
277 | 69 | { | 58 | { |
319 | 70 | TransitionToNewColor(override_color_, skip_animation); | 59 | TransitionToNewColor(override_color_, animate); |
320 | 71 | return; | 60 | return; |
321 | 72 | } | 61 | } |
322 | 73 | 62 | ||
323 | 74 | // XXX: move this part to PluginAdapter | 63 | if (!color) |
324 | 75 | Atom real_type; | 64 | return; |
325 | 76 | gint result; | 65 | |
326 | 77 | gint real_format; | 66 | nux::Color new_color; |
327 | 78 | gulong items_read; | 67 | const double MAX_USHORT = std::numeric_limits<unsigned short>::max (); |
328 | 79 | gulong items_left; | 68 | new_color.red = color[0] / MAX_USHORT; |
329 | 80 | gchar* colors; | 69 | new_color.green = color[1] / MAX_USHORT; |
330 | 81 | Display* display; | 70 | new_color.blue = color[2] / MAX_USHORT; |
331 | 82 | GdkRGBA color_gdk; | 71 | |
332 | 83 | 72 | TransitionToNewColor(MatchColor(new_color), animate); | |
292 | 84 | colors = nullptr; | ||
293 | 85 | display = gdk_x11_display_get_xdisplay(gdk_display_get_default()); | ||
294 | 86 | |||
295 | 87 | gdk_error_trap_push(); | ||
296 | 88 | result = XGetWindowProperty (display, | ||
297 | 89 | GDK_ROOT_WINDOW(), | ||
298 | 90 | COLORS_ATOM, | ||
299 | 91 | 0L, | ||
300 | 92 | G_MAXLONG, | ||
301 | 93 | False, | ||
302 | 94 | XA_STRING, | ||
303 | 95 | &real_type, | ||
304 | 96 | &real_format, | ||
305 | 97 | &items_read, | ||
306 | 98 | &items_left, | ||
307 | 99 | (guchar **) &colors); | ||
308 | 100 | gdk_flush (); | ||
309 | 101 | gdk_error_trap_pop_ignored (); | ||
310 | 102 | |||
311 | 103 | if (result == Success && items_read) | ||
312 | 104 | { | ||
313 | 105 | gdk_rgba_parse(&color_gdk, colors); | ||
314 | 106 | nux::Color new_color(color_gdk.red, color_gdk.green, color_gdk.blue, 1.0f); | ||
315 | 107 | TransitionToNewColor(MatchColor(new_color), skip_animation); | ||
316 | 108 | } | ||
317 | 109 | |||
318 | 110 | XFree(colors); | ||
333 | 111 | } | 73 | } |
334 | 112 | 74 | ||
336 | 113 | void BGHash::TransitionToNewColor(nux::color::Color const& new_color, bool skip_animation) | 75 | void BGHash::TransitionToNewColor(nux::color::Color const& new_color, na::Animation::State animate) |
337 | 114 | { | 76 | { |
338 | 115 | auto const& current_color = WindowManager::Default().average_color(); | 77 | auto const& current_color = WindowManager::Default().average_color(); |
339 | 78 | bool skip_animation = (animate != na::Animation::State::Running); | ||
340 | 116 | LOG_DEBUG(logger) << "transitioning from: " << current_color.red << " to " << new_color.red; | 79 | LOG_DEBUG(logger) << "transitioning from: " << current_color.red << " to " << new_color.red; |
341 | 117 | 80 | ||
342 | 118 | transition_animator_.Stop(); | 81 | transition_animator_.Stop(); |
343 | 119 | 82 | ||
344 | === modified file 'unity-shared/BGHash.h' | |||
345 | --- unity-shared/BGHash.h 2016-07-04 14:51:28 +0000 | |||
346 | +++ unity-shared/BGHash.h 2017-07-03 15:31:53 +0000 | |||
347 | @@ -36,14 +36,13 @@ | |||
348 | 36 | BGHash(); | 36 | BGHash(); |
349 | 37 | 37 | ||
350 | 38 | nux::Color CurrentColor() const; | 38 | nux::Color CurrentColor() const; |
353 | 39 | uint64_t ColorAtomId() const; | 39 | void UpdateColor(const unsigned short *compiz_color, nux::animation::Animation::State); |
352 | 40 | void RefreshColor(bool skip_animation = false); | ||
354 | 41 | void OverrideColor(nux::Color const& color); | 40 | void OverrideColor(nux::Color const& color); |
355 | 42 | 41 | ||
356 | 43 | private: | 42 | private: |
357 | 43 | void TransitionToNewColor(nux::Color const& new_color, nux::animation::Animation::State); | ||
358 | 44 | nux::Color MatchColor(nux::Color const& base_color) const; | ||
359 | 44 | void OnTransitionUpdated(nux::Color const& new_color); | 45 | void OnTransitionUpdated(nux::Color const& new_color); |
360 | 45 | void TransitionToNewColor(nux::Color const& new_color, bool skip_animation = false); | ||
361 | 46 | nux::Color MatchColor(nux::Color const& base_color) const; | ||
362 | 47 | 46 | ||
363 | 48 | private: | 47 | private: |
364 | 49 | nux::animation::AnimateValue<nux::Color> transition_animator_; | 48 | nux::animation::AnimateValue<nux::Color> transition_animator_; |
LGTM.