From 76aa47e30eb36418071b721a5f0982a0441c36c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 4 Apr 2017 14:12:06 +0800 Subject: UnitySettings: call the helper tool to change the currently used compiz profile (bzr r4213.4.18) --- unity-shared/UnitySettings.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp index eff28667d..5f912d5fb 100644 --- a/unity-shared/UnitySettings.cpp +++ b/unity-shared/UnitySettings.cpp @@ -18,6 +18,8 @@ * Andrea Azzarone */ +#include "config.h" + #include #include #include @@ -73,6 +75,10 @@ const std::string LAUNCHER_DRAG = "launcher-drag"; const std::string DASH_TAP = "dash-tap"; const std::string WINDOWS_DRAG_PINCH = "windows-drag-pinch"; +const std::string CCS_PROFILE_CHANGER_TOOL = "compiz-config-profile-setter"; +const std::string CCS_PROFILE_DEFAULT = "unity"; +const std::string CCS_PROFILE_LOWGFX = CCS_PROFILE_DEFAULT + "-lowgfx"; + const int DEFAULT_LAUNCHER_SIZE = 64; const int MINIMUM_DESKTOP_HEIGHT = 800; const int GNOME_SETTINGS_CHANGED_WAIT_SECONDS = 1; @@ -113,6 +119,7 @@ public: parent_->launcher_position.SetSetterFunction(sigc::mem_fun(this, &Impl::SetLauncherPosition)); parent_->desktop_type.SetGetterFunction(sigc::mem_fun(this, &Impl::GetDesktopType)); parent_->pam_check_account_type.SetGetterFunction(sigc::mem_fun(this, &Impl::GetPamCheckAccountType)); + parent_->low_gfx.changed.connect(sigc::mem_fun(this, &Impl::UpdateCompizProfile)); for (unsigned i = 0; i < monitors::MAX; ++i) em_converters_.emplace_back(std::make_shared()); @@ -237,7 +244,21 @@ public: void UpdateLowGfx() { - parent_->low_gfx = GetLowGfx(); + parent_->low_gfx = g_settings_get_boolean(usettings_, LOWGFX.c_str()) != FALSE; + } + + void UpdateCompizProfile(bool lowgfx) + { + auto const& profile = lowgfx ? CCS_PROFILE_LOWGFX : CCS_PROFILE_DEFAULT; + auto profile_change_cmd = (std::string(UNITY_LIBDIR G_DIR_SEPARATOR_S) + CCS_PROFILE_CHANGER_TOOL + " " + profile); + + glib::Error error; + g_spawn_command_line_async(profile_change_cmd.c_str(), &error); + + if (error) + { + LOG_ERROR(logger) << "Failed to switch compiz profile: " << error; + } } void UpdateLimSetting() @@ -292,11 +313,6 @@ public: return g_settings_get_boolean(usettings_, PAM_CHECK_ACCOUNT_TYPE.c_str()); } - bool GetLowGfx() const - { - return g_settings_get_boolean(usettings_, LOWGFX.c_str()); - } - int GetFontSize() const { gint font_size; -- cgit v1.2.3