summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2017-04-25 17:58:05 +0000
committerBileto Bot <ci-train-bot@canonical.com>2017-04-25 17:58:05 +0000
commite0e9d25ec20c28f86436959108cc2b4255a7ba72 (patch)
treec04d8df1a7061e25ec7d31c321f1a3e3fa70864c /unity-shared
parent440ab2598dc2deba9ac84d0e187952d2fe9f7a88 (diff)
parent12e380d1f463a455c28e6c12427f659c35d9246b (diff)
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 (LP: #1668950) Approved by: Andrea Azzarone (bzr r4233)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/UnitySettings.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp
index eff28667d..32a944df4 100644
--- a/unity-shared/UnitySettings.cpp
+++ b/unity-shared/UnitySettings.cpp
@@ -18,6 +18,8 @@
* Andrea Azzarone <andrea.azzarone@canonical.com>
*/
+#include "config.h"
+
#include <glib.h>
#include <NuxCore/Logger.h>
#include <UnityCore/GLibSource.h>
@@ -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<EMConverter>());
@@ -184,9 +191,11 @@ public:
UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateDPI))));
- // The order is important here, DPI is the last thing to be updated
UpdateLowGfx();
+ UpdateCompizProfile(parent_->low_gfx());
UpdateLimSetting();
+
+ // The order is important here, DPI is the last thing to be updated
UpdateGesturesSetting();
UpdateTextScaleFactor();
UpdateCursorScaleFactor();
@@ -237,7 +246,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 +315,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;