Merge lp:~3v1n0/unity/lowgfx-profile-setter into lp:unity

Proposed by Marco Trevisan (Treviño) on 2017-04-04
Status: Superseded
Proposed branch: lp:~3v1n0/unity/lowgfx-profile-setter
Merge into: lp:unity
Diff against target: 597 lines (+332/-43)
11 files modified
data/com.canonical.Unity.gschema.xml (+5/-0)
decorations/DecorationsWindowButton.cpp (+2/-1)
plugins/unityshell/src/unityshell.cpp (+12/-16)
plugins/unityshell/unityshell.xml.in (+0/-6)
tools/CMakeLists.txt (+5/-0)
tools/compiz-profile-selector.in (+24/-6)
tools/compiz_config_profile_setter.c (+229/-0)
tools/unity.cmake (+17/-4)
unity-shared/BackgroundEffectHelper.cpp (+0/-4)
unity-shared/UnitySettings.cpp (+38/-5)
unity-shared/UnitySettings.h (+0/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/lowgfx-profile-setter
Reviewer Review Type Date Requested Status
Unity Team 2017-04-04 Pending
Review via email: mp+321834@code.launchpad.net

This proposal has been superseded by a proposal from 2017-04-04.

Commit Message

compiz-profile-setter: tool to update the current profile and use in systemd and Unity settings

Added a compiz-profile-setter tool that allows to change compiz profile, so we use
this to set the right profile when starting unity and when the gsettings key has changed.

So we can just toggle lowgfx profile on the fly by just doing
  gsettings set com.canonical.Unity lowgfx true|false

To post a comment you must log in.
4243. By Marco Trevisan (Treviño) on 2017-04-04

Merging with trunk

4244. By Marco Trevisan (Treviño) on 2017-04-04

debian/unity.install: include compiz-config-profile-setter

4245. By Marco Trevisan (Treviño) on 2017-04-05

Merging with hikiko's parent branch

4246. By Marco Trevisan (Treviño) on 2017-04-05

test_thumbnail_generator: increase the wait time for multiple checks

4247. By Marco Trevisan (Treviño) on 2017-04-25

compiz_config_profile_setter: use plain strings for upstart dbus infos

As we don't build-depend on libupstart-dev anymore

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.canonical.Unity.gschema.xml'
2--- data/com.canonical.Unity.gschema.xml 2017-01-25 16:40:35 +0000
3+++ data/com.canonical.Unity.gschema.xml 2017-04-04 10:15:47 +0000
4@@ -100,6 +100,11 @@
5 when authenticating. Only do this if you have account
6 configured properly on your system.</description>
7 </key>
8+ <key type="b" name="lowgfx">
9+ <default>false</default>
10+ <summary>Enable/Disable Low Graphics Mode</summary>
11+ <description>Whether Unity runs in Low Graphics Mode.</description>
12+ </key>
13 </schema>
14 <schema path="/com/canonical/unity/interface/" id="com.canonical.Unity.Interface" gettext-domain="unity">
15 <key type="d" name="text-scale-factor">
16
17=== modified file 'decorations/DecorationsWindowButton.cpp'
18--- decorations/DecorationsWindowButton.cpp 2016-08-04 08:53:20 +0000
19+++ decorations/DecorationsWindowButton.cpp 2017-04-04 10:15:47 +0000
20@@ -45,7 +45,8 @@
21
22 void WindowButton::UpdateTexture()
23 {
24- SetTexture(DataPool::Get()->ButtonTexture(scale(), type(), GetCurrentState()));
25+ if (auto tex = DataPool::Get()->ButtonTexture(scale(), type(), GetCurrentState()))
26+ SetTexture(tex);
27 }
28
29 WidgetState WindowButton::GetCurrentState() const
30
31=== modified file 'plugins/unityshell/src/unityshell.cpp'
32--- plugins/unityshell/src/unityshell.cpp 2017-02-27 13:47:32 +0000
33+++ plugins/unityshell/src/unityshell.cpp 2017-04-04 10:15:47 +0000
34@@ -292,23 +292,28 @@
35 }
36 }
37
38- //In case of software rendering then enable lowgfx mode.
39+ //In case of software rendering then enable lowgfx mode.
40 std::string renderer = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_RENDERER)));
41-
42 if (renderer.find("Software Rasterizer") != std::string::npos ||
43 renderer.find("Mesa X11") != std::string::npos ||
44 renderer.find("llvmpipe") != std::string::npos ||
45 renderer.find("softpipe") != std::string::npos ||
46- (getenv("UNITY_LOW_GFX_MODE") != NULL && atoi(getenv("UNITY_LOW_GFX_MODE")) == 1) ||
47- optionGetLowGraphicsMode())
48- {
49- unity_settings_.low_gfx = true;
50- }
51+ (getenv("UNITY_LOW_GFX_MODE") != NULL && atoi(getenv("UNITY_LOW_GFX_MODE")) == 1))
52+ {
53+ unity_settings_.low_gfx = true;
54+ }
55
56 if (getenv("UNITY_LOW_GFX_MODE") != NULL && atoi(getenv("UNITY_LOW_GFX_MODE")) == 0)
57 {
58 unity_settings_.low_gfx = false;
59 }
60+
61+ if (unity_settings_.low_gfx())
62+ BackgroundEffectHelper::blur_type = BLUR_NONE;
63+
64+ Settings::Instance().low_gfx.changed.connect(sigc::track_obj([this] (bool low_gfx) {
65+ BackgroundEffectHelper::blur_type = low_gfx ? BLUR_NONE : (unity::BlurType) optionGetDashBlurExperimental();
66+ }, *this));
67 #endif
68
69 if (!failed)
70@@ -384,7 +389,6 @@
71 optionSetAutohideAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
72 optionSetDashBlurExperimentalNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
73 optionSetShortcutOverlayNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
74- optionSetLowGraphicsModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
75 optionSetShowLauncherInitiate(boost::bind(&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3));
76 optionSetShowLauncherTerminate(boost::bind(&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3));
77 optionSetKeyboardFocusInitiate(boost::bind(&UnityScreen::setKeyboardFocusKeyInitiate, this, _1, _2, _3));
78@@ -3751,14 +3755,6 @@
79 case UnityshellOptions::ShortcutOverlay:
80 shortcut_controller_->SetEnabled(optionGetShortcutOverlay());
81 break;
82- case UnityshellOptions::LowGraphicsMode:
83- if (optionGetLowGraphicsMode())
84- BackgroundEffectHelper::blur_type = BLUR_NONE;
85- else
86- BackgroundEffectHelper::blur_type = (unity::BlurType)optionGetDashBlurExperimental();
87-
88- unity::Settings::Instance().low_gfx = optionGetLowGraphicsMode();
89- break;
90 case UnityshellOptions::DecayRate:
91 launcher_options->edge_decay_rate = optionGetDecayRate() * 100;
92 break;
93
94=== modified file 'plugins/unityshell/unityshell.xml.in'
95--- plugins/unityshell/unityshell.xml.in 2016-07-18 17:20:07 +0000
96+++ plugins/unityshell/unityshell.xml.in 2017-04-04 10:15:47 +0000
97@@ -160,12 +160,6 @@
98 <_long>Enables possibility to display an overlay showing available mouse and keyboard shortcuts.</_long>
99 <default>true</default>
100 </option>
101-
102- <option name="low_graphics_mode" type="bool">
103- <_short>Enable Low Graphics Mode</_short>
104- <_long>Enables low graphics mode regardless of hardware in the system</_long>
105- <default>false</default>
106- </option>
107 </group>
108
109 <group>
110
111=== modified file 'tools/CMakeLists.txt'
112--- tools/CMakeLists.txt 2016-09-05 10:46:49 +0000
113+++ tools/CMakeLists.txt 2017-04-04 10:15:47 +0000
114@@ -19,6 +19,7 @@
115
116 string (REPLACE ";" " " CFLAGS "${CFLAGS}")
117 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFLAGS}")
118+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFLAGS}")
119
120 set(LIBS ${UAPSC_DEPS_LIBRARIES})
121
122@@ -29,6 +30,10 @@
123 target_link_libraries(unity-active-plugins-safety-check ${LIBS})
124 install(TARGETS unity-active-plugins-safety-check DESTINATION ${UNITY_INSTALL_LIBDIR})
125
126+add_executable(compiz-config-profile-setter compiz_config_profile_setter.c)
127+target_link_libraries(compiz-config-profile-setter ${LIBS})
128+install(TARGETS compiz-config-profile-setter DESTINATION ${UNITY_INSTALL_LIBDIR})
129+
130 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/compiz-profile-selector.in ${CMAKE_CURRENT_BINARY_DIR}/compiz-profile-selector @ONLY)
131 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/compiz-profile-selector DESTINATION ${UNITY_INSTALL_LIBDIR})
132
133
134=== modified file 'tools/compiz-profile-selector.in'
135--- tools/compiz-profile-selector.in 2016-09-05 10:46:49 +0000
136+++ tools/compiz-profile-selector.in 2017-04-04 10:15:47 +0000
137@@ -1,13 +1,29 @@
138 #!/bin/bash
139-
140 set -e
141+
142+config_dir="$XDG_CONFIG_HOME"
143+if [ -z "$config_dir" ]; then
144+ config_dir="$HOME/.config"
145+fi
146+
147+default_ini="$config_dir/compiz-1/compizconfig/Default.ini"
148+
149+if [ -f "$default_ini" ]; then
150+ rm "$default_ini"
151+fi
152+
153 compiz_profile="ubuntu"
154+settings_profile="unity"
155
156 if ! /usr/lib/nux/unity_support_test -p; then
157- compiz_profile="ubuntu-lowgfx"
158-fi
159-
160-echo "Using compiz profile '$compiz_profile'"
161+ settings_profile="unity-lowgfx"
162+fi
163+
164+if [ "$(gsettings get com.canonical.Unity lowgfx)" == "true" ]; then
165+ settings_profile="unity-lowgfx"
166+fi
167+
168+echo "Using compiz profile '$compiz_profile:$settings_profile'"
169
170 if [ -n "$UPSTART_SESSION" ]; then
171 initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
172@@ -16,4 +32,6 @@
173 dbus-update-activation-environment --verbose --systemd COMPIZ_CONFIG_PROFILE="$compiz_profile"
174
175 export COMPIZ_CONFIG_PROFILE="$compiz_profile"
176-exec @UNITY_LIBDIR@/unity-active-plugins-safety-check
177+
178+@UNITY_LIBDIR@/compiz-config-profile-setter $settings_profile
179+@UNITY_LIBDIR@/unity-active-plugins-safety-check
180
181=== added file 'tools/compiz_config_profile_setter.c'
182--- tools/compiz_config_profile_setter.c 1970-01-01 00:00:00 +0000
183+++ tools/compiz_config_profile_setter.c 2017-04-04 10:15:47 +0000
184@@ -0,0 +1,229 @@
185+/*
186+ * Copyright (C) 2017 Canonical Ltd
187+ *
188+ * This program is free software: you can redistribute it and/or modify
189+ * it under the terms of the GNU General Public License version 3 as
190+ * published by the Free Software Foundation.
191+ *
192+ * This program is distributed in the hope that it will be useful,
193+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
194+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
195+ * GNU General Public License for more details.
196+ *
197+ * You should have received a copy of the GNU General Public License
198+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
199+ *
200+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
201+ */
202+
203+#include <ccs.h>
204+#include <gio/gio.h>
205+#include <upstart/upstart-dbus.h>
206+
207+#define COMPIZ_CONFIG_PROFILE_ENV "COMPIZ_CONFIG_PROFILE"
208+#define COMPIZ_CONFIG_DEFAULT_PROFILE "ubuntu"
209+
210+extern const CCSInterfaceTable ccsDefaultInterfaceTable;
211+
212+static gchar *
213+get_ccs_profile_env_from_env_list (const gchar **env_vars)
214+{
215+ gchar *var = NULL;
216+
217+ for (; env_vars && *env_vars; ++env_vars)
218+ {
219+ if (g_str_has_prefix (*env_vars, COMPIZ_CONFIG_PROFILE_ENV "="))
220+ {
221+ var = g_strdup (*env_vars + G_N_ELEMENTS (COMPIZ_CONFIG_PROFILE_ENV));
222+ break;
223+ }
224+ }
225+
226+ return var;
227+}
228+
229+static gchar *
230+get_ccs_profile_env_from_session_manager ()
231+{
232+ GDBusConnection *bus;
233+ GVariant *environment_prop, *environment_prop_list;
234+ const gchar **env_vars;
235+ gchar *profile;
236+
237+ profile = NULL;
238+ bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
239+
240+ environment_prop = g_dbus_connection_call_sync (bus,
241+ "org.freedesktop.systemd1",
242+ "/org/freedesktop/systemd1",
243+ "org.freedesktop.DBus.Properties",
244+ "Get",
245+ g_variant_new ("(ss)",
246+ "org.freedesktop.systemd1.Manager",
247+ "Environment"),
248+ G_VARIANT_TYPE ("(v)"),
249+ G_DBUS_CALL_FLAGS_NONE,
250+ -1,
251+ NULL,
252+ NULL);
253+
254+ if (!environment_prop)
255+ goto out;
256+
257+ g_variant_get (environment_prop, "(v)", &environment_prop_list, NULL);
258+ env_vars = g_variant_get_strv (environment_prop_list, NULL);
259+ profile = get_ccs_profile_env_from_env_list (env_vars);
260+
261+ g_clear_pointer (&environment_prop, g_variant_unref);
262+ g_clear_pointer (&environment_prop_list, g_variant_unref);
263+
264+ if (!profile && g_getenv ("UPSTART_SESSION"))
265+ {
266+ const gchar * const * empty_array[] = {0};
267+ environment_prop_list = g_dbus_connection_call_sync (bus,
268+ DBUS_SERVICE_UPSTART,
269+ DBUS_PATH_UPSTART,
270+ DBUS_INTERFACE_UPSTART,
271+ "ListEnv",
272+ g_variant_new("(@as)",
273+ g_variant_new_strv (NULL, 0)),
274+ NULL,
275+ G_DBUS_CALL_FLAGS_NONE,
276+ -1,
277+ NULL,
278+ NULL);
279+ if (!environment_prop_list)
280+ goto out;
281+
282+ g_variant_get (environment_prop_list, "(^a&s)", &env_vars);
283+ profile = get_ccs_profile_env_from_env_list (env_vars);
284+
285+ g_variant_unref (environment_prop_list);
286+ }
287+
288+out:
289+ g_object_unref (bus);
290+
291+ return profile;
292+}
293+
294+static gboolean
295+is_compiz_profile_available (const gchar *profile)
296+{
297+ gboolean is_available;
298+ gchar *profile_path;
299+
300+ profile_path = g_strdup_printf ("%s/compiz-1/compizconfig/%s.ini",
301+ g_get_user_config_dir (), profile);
302+ is_available = g_file_test (profile_path, G_FILE_TEST_EXISTS);
303+ g_free (profile_path);
304+
305+ if (!is_available)
306+ {
307+ profile_path = g_strdup_printf ("/etc/compizconfig/%s.ini", profile);
308+ is_available = g_file_test (profile_path, G_FILE_TEST_EXISTS);
309+ g_free (profile_path);
310+ }
311+
312+ return is_available;
313+}
314+
315+static gboolean
316+set_compiz_profile (CCSContext *ccs_context, const gchar *profile_name)
317+{
318+ CCSPluginList plugins;
319+ const char *ccs_backend;
320+
321+ ccs_backend = ccsGetBackend (ccs_context);
322+
323+ ccsSetProfile (ccs_context, profile_name);
324+ ccsReadSettings (ccs_context);
325+ ccsWriteSettings (ccs_context);
326+
327+ if (g_strcmp0 (ccs_backend, "gsettings") == 0)
328+ g_settings_sync ();
329+
330+ plugins = ccsContextGetPlugins (ccs_context);
331+
332+ for (CCSPluginList p = plugins; p; p = p->next)
333+ {
334+ CCSPlugin* plugin = p->data;
335+ ccsReadPluginSettings (plugin);
336+ }
337+
338+ return TRUE;
339+}
340+
341+int main(int argc, char *argv[])
342+{
343+ CCSContext *context;
344+ const gchar *profile, *current_profile, *ccs_profile_env;
345+ gchar *session_manager_ccs_profile;
346+
347+ if (argc < 2)
348+ {
349+ g_warning ("You need to pass a valid profile as argument\n");
350+ return 1;
351+ }
352+
353+ session_manager_ccs_profile = get_ccs_profile_env_from_session_manager ();
354+
355+ if (session_manager_ccs_profile)
356+ {
357+ g_setenv (COMPIZ_CONFIG_PROFILE_ENV, session_manager_ccs_profile, TRUE);
358+ g_clear_pointer (&session_manager_ccs_profile, g_free);
359+ }
360+ else
361+ {
362+ ccs_profile_env = g_getenv (COMPIZ_CONFIG_PROFILE_ENV);
363+
364+ if (!ccs_profile_env || ccs_profile_env[0] == '\0')
365+ {
366+ g_setenv (COMPIZ_CONFIG_PROFILE_ENV, COMPIZ_CONFIG_DEFAULT_PROFILE, TRUE);
367+ }
368+ }
369+
370+ profile = argv[1];
371+
372+ if (!is_compiz_profile_available (profile))
373+ {
374+ g_warning ("Compiz profile '%s' not found", profile);
375+ return 1;
376+ }
377+
378+ context = ccsContextNew (0, &ccsDefaultInterfaceTable);
379+
380+ if (!context)
381+ {
382+ g_warning ("Impossible to get Compiz config context\n");
383+ return -1;
384+ }
385+
386+ g_debug ("Setting profile to '%s' (for environment '%s')",
387+ profile, g_getenv (COMPIZ_CONFIG_PROFILE_ENV));
388+
389+ current_profile = ccsGetProfile (context);
390+
391+ if (g_strcmp0 (current_profile, profile) == 0)
392+ {
393+ g_print("We're already using profile '%s', no need to switch\n", profile);
394+ return 0;
395+ }
396+
397+ if (!set_compiz_profile (context, profile))
398+ {
399+ ccsFreeContext (context);
400+ return 1;
401+ }
402+
403+ ccsFreeContext (context);
404+
405+ g_print ("Switched to profile '%s' (for environment '%s')\n",
406+ profile, g_getenv (COMPIZ_CONFIG_PROFILE_ENV));
407+
408+ /* This is for printing debug informations */
409+ context = ccsContextNew (0, &ccsDefaultInterfaceTable);
410+ ccsFreeContext (context);
411+
412+ return 0;
413+}
414
415=== modified file 'tools/unity.cmake'
416--- tools/unity.cmake 2016-09-01 18:55:15 +0000
417+++ tools/unity.cmake 2017-04-04 10:15:47 +0000
418@@ -58,13 +58,26 @@
419 def set_unity_env ():
420 '''set variable environnement for unity to run'''
421
422+ compiz_config_profile = 'unity'
423 os.environ['COMPIZ_CONFIG_PROFILE'] = 'ubuntu'
424
425 try:
426- if subprocess.call('/usr/lib/nux/unity_support_test -f'.split()) > 0:
427- os.environ['COMPIZ_CONFIG_PROFILE'] = 'ubuntu-lowgfx'
428- except:
429- pass
430+ if subprocess.call('/usr/lib/nux/unity_support_test -f'.split()) > 0:
431+ compiz_config_profile += '-lowgfx'
432+ except:
433+ pass
434+
435+ try:
436+ if subprocess.check_output('gsettings get com.canonical.Unity lowgfx'.split()) == b'true\n':
437+ compiz_config_profile += '-lowgfx'
438+ except:
439+ pass
440+
441+ try:
442+ subprocess.call('@UNITY_LIBDIR@/compiz-config-profile-setter {}'.format(
443+ compiz_config_profile).split())
444+ except:
445+ pass
446
447 if not 'DISPLAY' in os.environ:
448 # take an optimistic chance and warn about it :)
449
450=== modified file 'unity-shared/BackgroundEffectHelper.cpp'
451--- unity-shared/BackgroundEffectHelper.cpp 2016-12-12 08:27:16 +0000
452+++ unity-shared/BackgroundEffectHelper.cpp 2017-04-04 10:15:47 +0000
453@@ -21,7 +21,6 @@
454 #include "BackgroundEffectHelper.h"
455
456 #include "TextureCache.h"
457-#include "UnitySettings.h"
458
459 namespace
460 {
461@@ -50,9 +49,6 @@
462 owner.changed.connect(sigc::mem_fun(this, &BackgroundEffectHelper::OnOwnerChanged));
463 TextureCache::GetDefault().themed_invalidated.connect(sigc::mem_fun(this, &BackgroundEffectHelper::LoadTextures));
464 LoadTextures();
465-
466- if (Settings::Instance().low_gfx())
467- blur_type = BLUR_NONE;
468 }
469
470 BackgroundEffectHelper::BackgroundEffectHelper()
471
472=== modified file 'unity-shared/UnitySettings.cpp'
473--- unity-shared/UnitySettings.cpp 2016-12-20 16:32:03 +0000
474+++ unity-shared/UnitySettings.cpp 2017-04-04 10:15:47 +0000
475@@ -18,6 +18,8 @@
476 * Andrea Azzarone <andrea.azzarone@canonical.com>
477 */
478
479+#include "config.h"
480+
481 #include <glib.h>
482 #include <NuxCore/Logger.h>
483 #include <UnityCore/GLibSource.h>
484@@ -40,6 +42,7 @@
485 const std::string DOUBLE_CLICK_ACTIVATE = "double-click-activate";
486 const std::string DESKTOP_TYPE = "desktop-type";
487 const std::string PAM_CHECK_ACCOUNT_TYPE = "pam-check-account-type";
488+const std::string LOWGFX = "lowgfx";
489
490 const std::string LAUNCHER_SETTINGS = "com.canonical.Unity.Launcher";
491 const std::string LAUNCHER_POSITION = "launcher-position";
492@@ -72,6 +75,10 @@
493 const std::string DASH_TAP = "dash-tap";
494 const std::string WINDOWS_DRAG_PINCH = "windows-drag-pinch";
495
496+const std::string CCS_PROFILE_CHANGER_TOOL = "compiz-config-profile-setter";
497+const std::string CCS_PROFILE_DEFAULT = "unity";
498+const std::string CCS_PROFILE_LOWGFX = CCS_PROFILE_DEFAULT + "-lowgfx";
499+
500 const int DEFAULT_LAUNCHER_SIZE = 64;
501 const int MINIMUM_DESKTOP_HEIGHT = 800;
502 const int GNOME_SETTINGS_CHANGED_WAIT_SECONDS = 1;
503@@ -112,10 +119,15 @@
504 parent_->launcher_position.SetSetterFunction(sigc::mem_fun(this, &Impl::SetLauncherPosition));
505 parent_->desktop_type.SetGetterFunction(sigc::mem_fun(this, &Impl::GetDesktopType));
506 parent_->pam_check_account_type.SetGetterFunction(sigc::mem_fun(this, &Impl::GetPamCheckAccountType));
507+ parent_->low_gfx.changed.connect(sigc::mem_fun(this, &Impl::UpdateCompizProfile));
508
509 for (unsigned i = 0; i < monitors::MAX; ++i)
510 em_converters_.emplace_back(std::make_shared<EMConverter>());
511
512+ signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + LOWGFX, [this] (GSettings*, const gchar *) {
513+ UpdateLowGfx();
514+ });
515+
516 signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, const gchar*) {
517 CacheFormFactor();
518 });
519@@ -179,8 +191,11 @@
520
521 UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateDPI))));
522
523+ UpdateLowGfx();
524+ UpdateCompizProfile(parent_->low_gfx());
525+ UpdateLimSetting();
526+
527 // The order is important here, DPI is the last thing to be updated
528- UpdateLimSetting();
529 UpdateGesturesSetting();
530 UpdateTextScaleFactor();
531 UpdateCursorScaleFactor();
532@@ -229,6 +244,25 @@
533 cached_launcher_position_ = static_cast<LauncherPosition>(g_settings_get_enum(launcher_settings_, LAUNCHER_POSITION.c_str()));
534 }
535
536+ void UpdateLowGfx()
537+ {
538+ parent_->low_gfx = g_settings_get_boolean(usettings_, LOWGFX.c_str()) != FALSE;
539+ }
540+
541+ void UpdateCompizProfile(bool lowgfx)
542+ {
543+ auto const& profile = lowgfx ? CCS_PROFILE_LOWGFX : CCS_PROFILE_DEFAULT;
544+ auto profile_change_cmd = (std::string(UNITY_LIBDIR G_DIR_SEPARATOR_S) + CCS_PROFILE_CHANGER_TOOL + " " + profile);
545+
546+ glib::Error error;
547+ g_spawn_command_line_async(profile_change_cmd.c_str(), &error);
548+
549+ if (error)
550+ {
551+ LOG_ERROR(logger) << "Failed to switch compiz profile: " << error;
552+ }
553+ }
554+
555 void UpdateLimSetting()
556 {
557 parent_->lim_movement_thresold = g_settings_get_uint(lim_settings_, CLICK_MOVEMENT_THRESHOLD.c_str());
558@@ -329,7 +363,7 @@
559 auto const& geo = uscreen->GetMonitorGeometry(monitor);
560 auto const& size = uscreen->GetMonitorPhysicalSize(monitor);
561 auto scale = DPI_SCALING_STEP;
562-
563+
564 if ((size.width == 160 && size.height == 90) ||
565 (size.width == 160 && size.height == 100) ||
566 (size.width == 16 && size.height == 9) ||
567@@ -340,7 +374,7 @@
568
569 if (size.width > 0 && size.height > 0)
570 {
571- const double dpi_x = static_cast<double>(geo.width) / (size.width / 25.4);
572+ const double dpi_x = static_cast<double>(geo.width) / (size.width / 25.4);
573 const double dpi_y = static_cast<double>(geo.height) / (size.height / 25.4);
574
575 const auto dpi = std::max(dpi_x, dpi_y);
576@@ -481,8 +515,7 @@
577 //
578
579 Settings::Settings()
580- : low_gfx(false)
581- , is_standalone(false)
582+ : is_standalone(false)
583 , pimpl(new Impl(this))
584 {
585 if (settings_instance)
586
587=== modified file 'unity-shared/UnitySettings.h'
588--- unity-shared/UnitySettings.h 2016-07-04 14:21:00 +0000
589+++ unity-shared/UnitySettings.h 2017-04-04 10:15:47 +0000
590@@ -76,7 +76,6 @@
591 nux::Property<bool> gestures_windows_drag_pinch;
592
593 sigc::signal<void> dpi_changed;
594- sigc::signal<void> low_gfx_changed;
595 sigc::signal<void> gestures_changed;
596
597 private: