summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2017-07-21 08:52:11 +0000
committerBileto Bot <ci-train-bot@canonical.com>2017-07-21 08:52:11 +0000
commitdcc44dbb1e2a7a6e0cede0d0e7d64bfaa01224cd (patch)
treeb82c2150dd09318151501d1b4cef553d97ceb317
parentc42da4c62dbeb9210911fd1d318ff11a5a544685 (diff)
parentf46414392be209a3e1fa5f896dcc49db33dc9ab5 (diff)
UnitySettings: listen to compiz profile status in order to set low_gfx value
Instead of changing this value back and forth multiple times, just wait this to be really changed in compiz, and update our internal variable accordingly. Also take care of the gsettings unity's lowgfx value only if the user has set it. This fixes an infinite loop when starting compiz in a lowgfx environment. Approved by: Andrea Azzarone (bzr r4250)
-rw-r--r--plugins/unityshell/src/unityshell.cpp14
-rw-r--r--tests/data/external.gschema.xml8
-rw-r--r--tools/compiz-profile-selector.in26
-rwxr-xr-xtools/unity.cmake11
-rw-r--r--unity-shared/UnitySettings.cpp72
-rw-r--r--unity-shared/UnitySettings.h1
6 files changed, 102 insertions, 30 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index 6fe50d315..20e644860 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -293,24 +293,18 @@ UnityScreen::UnityScreen(CompScreen* screen)
}
//In case of software rendering then enable lowgfx mode.
+ std::string lowgfx_env = glib::gchar_to_string(getenv("UNITY_LOW_GFX_MODE"));
std::string renderer = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_RENDERER)));
if (renderer.find("Software Rasterizer") != std::string::npos ||
renderer.find("Mesa X11") != std::string::npos ||
renderer.find("llvmpipe") != std::string::npos ||
renderer.find("softpipe") != std::string::npos ||
- (getenv("UNITY_LOW_GFX_MODE") != NULL && atoi(getenv("UNITY_LOW_GFX_MODE")) == 1))
+ atoi(lowgfx_env.c_str()) == 1)
{
- unity_settings_.low_gfx = true;
+ if (lowgfx_env.empty() || atoi(lowgfx_env.c_str()) != 0)
+ unity_settings_.supports_3d = false;
}
- if (getenv("UNITY_LOW_GFX_MODE") != NULL && atoi(getenv("UNITY_LOW_GFX_MODE")) == 0)
- {
- unity_settings_.low_gfx = false;
- }
-
- if (unity_settings_.low_gfx())
- BackgroundEffectHelper::blur_type = BLUR_NONE;
-
Settings::Instance().low_gfx.changed.connect(sigc::track_obj([this] (bool low_gfx) {
BackgroundEffectHelper::blur_type = low_gfx ? BLUR_NONE : (unity::BlurType) optionGetDashBlurExperimental();
}, *this));
diff --git a/tests/data/external.gschema.xml b/tests/data/external.gschema.xml
index 160db0572..6d498e2a0 100644
--- a/tests/data/external.gschema.xml
+++ b/tests/data/external.gschema.xml
@@ -8,6 +8,12 @@
</key>
</schema>
+ <schema id="org.compiz" path="/org/compiz/">
+ <key type="s" name="current-profile">
+ <default>'unity'</default>
+ </key>
+ </schema>
+
<schema id="org.compiz.unityshell" gettext-domain="compiz">
<key type="s" name="panel-first-menu">
<default>'&lt;Alt&gt;F10'</default>
@@ -18,7 +24,7 @@
<key type="s" name="show-hud">
<default>'&lt;Alt&gt;'</default>
</key>
- </schema>
+ </schema>
<enum id='com.canonical.desktop.interface.ScrollbarMode'>
<value nick='normal' value='0'/>
diff --git a/tools/compiz-profile-selector.in b/tools/compiz-profile-selector.in
index 591dc66fb..3f11bd5e6 100644
--- a/tools/compiz-profile-selector.in
+++ b/tools/compiz-profile-selector.in
@@ -14,24 +14,36 @@ fi
compiz_profile="ubuntu"
settings_profile="unity"
+supports_3d=true
if ! /usr/lib/nux/unity_support_test -p; then
- settings_profile="unity-lowgfx"
+ supports_3d=false
fi
-if [ "$(gsettings get com.canonical.Unity lowgfx)" == "true" ]; then
- settings_profile="unity-lowgfx"
+if [ "$UNITY_LOW_GFX_MODE" != 0 ]; then
+ if [ "$supports_3d" == false ] ||
+ [ "$(gsettings get com.canonical.Unity lowgfx)" == "true" ]; then
+ settings_profile="unity-lowgfx"
+ fi
fi
echo "Using compiz profile '$compiz_profile:$settings_profile'"
+export COMPIZ_CONFIG_PROFILE="$compiz_profile"
+export UNITY_HAS_3D_SUPPORT="$supports_3d"
+export UNITY_DEFAULT_PROFILE="$settings_profile"
+
if [ -n "$UPSTART_SESSION" ]; then
- initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
+ initctl set-env -g COMPIZ_CONFIG_PROFILE=$COMPIZ_CONFIG_PROFILE
+ initctl set-env -g UNITY_HAS_3D_SUPPORT=$UNITY_HAS_3D_SUPPORT
+ initctl set-env -g UNITY_DEFAULT_PROFILE=$UNITY_DEFAULT_PROFILE
+else
+ update_env_args="--systemd"
fi
-dbus-update-activation-environment --verbose --systemd COMPIZ_CONFIG_PROFILE="$compiz_profile"
-
-export COMPIZ_CONFIG_PROFILE="$compiz_profile"
+dbus-update-activation-environment $update_env_args --verbose COMPIZ_CONFIG_PROFILE
+dbus-update-activation-environment $update_env_args --verbose UNITY_HAS_3D_SUPPORT
+dbus-update-activation-environment $update_env_args --verbose UNITY_DEFAULT_PROFILE
@UNITY_LIBDIR@/compiz-config-profile-setter $settings_profile
@UNITY_LIBDIR@/unity-active-plugins-safety-check
diff --git a/tools/unity.cmake b/tools/unity.cmake
index 95db47a7a..8bc7e270d 100755
--- a/tools/unity.cmake
+++ b/tools/unity.cmake
@@ -30,6 +30,9 @@ import time
import xdg.BaseDirectory
DEFAULT_COMMAND = "compiz --replace"
+COMPIZ_CONFIG_PROFILE = "ubuntu"
+UNITY_DEFAULT_PROFILE = "unity"
+UNITY_LOWGFX_PROFILE = UNITY_DEFAULT_PROFILE + "-lowgfx"
home_dir = os.path.expanduser("~%s" % os.getenv("SUDO_USER"))
supported_prefix = "/usr/local"
@@ -58,18 +61,18 @@ well_known_local_path = ("%s/share/locale/*/LC_MESSAGES/*unity*" % supported_pre
def set_unity_env ():
'''set variable environnement for unity to run'''
- compiz_config_profile = 'unity'
- os.environ['COMPIZ_CONFIG_PROFILE'] = 'ubuntu'
+ compiz_config_profile = UNITY_DEFAULT_PROFILE
+ os.environ['COMPIZ_CONFIG_PROFILE'] = COMPIZ_CONFIG_PROFILE
try:
if subprocess.call('/usr/lib/nux/unity_support_test -f'.split()) > 0:
- compiz_config_profile += '-lowgfx'
+ compiz_config_profile = UNITY_LOWGFX_PROFILE
except:
pass
try:
if subprocess.check_output('gsettings get com.canonical.Unity lowgfx'.split()) == b'true\n':
- compiz_config_profile += '-lowgfx'
+ compiz_config_profile = UNITY_LOWGFX_PROFILE
except:
pass
diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp
index 5d89a5b90..cf3f557d9 100644
--- a/unity-shared/UnitySettings.cpp
+++ b/unity-shared/UnitySettings.cpp
@@ -58,6 +58,9 @@ const std::string CURSOR_SCALE_FACTOR = "cursor-scale-factor";
const std::string APP_SCALE_MONITOR = "app-scale-factor-monitor";
const std::string APP_USE_MAX_SCALE = "app-fallback-to-maximum-scale-factor";
+const std::string COMPIZ_SETTINGS = "org.compiz";
+const std::string COMPIZ_PROFILE = "current-profile";
+
const std::string UBUNTU_UI_SETTINGS = "com.ubuntu.user-interface";
const std::string SCALE_FACTOR = "scale-factor";
@@ -96,6 +99,7 @@ public:
Impl(Settings* owner)
: parent_(owner)
, usettings_(g_settings_new(SETTINGS_NAME.c_str()))
+ , compiz_settings_(g_settings_new(COMPIZ_SETTINGS.c_str()))
, launcher_settings_(g_settings_new(LAUNCHER_SETTINGS.c_str()))
, lim_settings_(g_settings_new(LIM_SETTINGS.c_str()))
, gestures_settings_(g_settings_new(GESTURES_SETTINGS.c_str()))
@@ -110,6 +114,8 @@ public:
, cached_double_click_activate_(true)
, remote_content_enabled_(true)
{
+ InitializeLowGfx();
+
parent_->form_factor.SetGetterFunction(sigc::mem_fun(this, &Impl::GetFormFactor));
parent_->form_factor.SetSetterFunction(sigc::mem_fun(this, &Impl::SetFormFactor));
parent_->double_click_activate.SetGetterFunction(sigc::mem_fun(this, &Impl::GetDoubleClickActivate));
@@ -118,13 +124,18 @@ 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_->supports_3d.changed.connect(sigc::mem_fun(this, &Impl::OnSupports3DChanged));
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>());
+ signals_.Add<void, GSettings*, const gchar*>(compiz_settings_, "changed::" + COMPIZ_PROFILE, [this] (GSettings*, const gchar *) {
+ parent_->low_gfx = (GetCurrentCompizProfile() == CCS_PROFILE_LOWGFX);
+ });
+
signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + LOWGFX, [this] (GSettings*, const gchar *) {
- UpdateLowGfx();
+ UpdateCompizProfile(GetLowGfxSetting());
});
signals_.Add<void, GSettings*, const gchar*>(usettings_, "changed::" + FORM_FACTOR, [this] (GSettings*, const gchar*) {
@@ -187,11 +198,8 @@ public:
UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::UpdateDPI))));
- UpdateLowGfx();
- UpdateCompizProfile(parent_->low_gfx());
- UpdateLimSetting();
-
// The order is important here, DPI is the last thing to be updated
+ UpdateLimSetting();
UpdateGesturesSetting();
UpdateTextScaleFactor();
UpdateCursorScaleFactor();
@@ -240,14 +248,54 @@ public:
cached_launcher_position_ = static_cast<LauncherPosition>(g_settings_get_enum(launcher_settings_, LAUNCHER_POSITION.c_str()));
}
- void UpdateLowGfx()
+ void InitializeLowGfx()
+ {
+ parent_->low_gfx = GetLowGfxSetting();
+ UpdateCompizProfile(parent_->low_gfx());
+ }
+
+ std::string GetCurrentCompizProfile()
+ {
+ return glib::String(g_settings_get_string(compiz_settings_, COMPIZ_PROFILE.c_str())).Str();
+ }
+
+ glib::Variant GetUserLowGfxSetting()
+ {
+ return glib::Variant(g_settings_get_user_value(usettings_, LOWGFX.c_str()), glib::StealRef());
+ }
+
+ bool GetLowGfxSetting()
{
- parent_->low_gfx = g_settings_get_boolean(usettings_, LOWGFX.c_str()) != FALSE;
+ if (glib::Variant const& user_setting = GetUserLowGfxSetting())
+ {
+ return user_setting.GetBool();
+ }
+ else
+ {
+ auto default_profile = glib::gchar_to_string(g_getenv("UNITY_DEFAULT_PROFILE"));
+ if (!default_profile.empty())
+ {
+ return (default_profile == CCS_PROFILE_LOWGFX);
+ }
+ else if (!parent_->supports_3d() ||
+ glib::gchar_to_string(getenv("UNITY_HAS_3D_SUPPORT")) == "false")
+ {
+ return true;
+ }
+ else
+ {
+ return (GetCurrentCompizProfile() == CCS_PROFILE_LOWGFX);
+ }
+ }
}
void UpdateCompizProfile(bool lowgfx)
{
auto const& profile = lowgfx ? CCS_PROFILE_LOWGFX : CCS_PROFILE_DEFAULT;
+
+ if (GetCurrentCompizProfile() == profile)
+ return;
+
auto profile_change_cmd = (std::string(UNITY_LIBDIR G_DIR_SEPARATOR_S) + CCS_PROFILE_CHANGER_TOOL + " " + profile);
glib::Error error;
@@ -259,6 +307,12 @@ public:
}
}
+ void OnSupports3DChanged(bool supports_3d)
+ {
+ if (!GetUserLowGfxSetting())
+ parent_->low_gfx = !supports_3d;
+ }
+
void UpdateLimSetting()
{
parent_->lim_movement_thresold = g_settings_get_uint(lim_settings_, CLICK_MOVEMENT_THRESHOLD.c_str());
@@ -486,6 +540,7 @@ public:
Settings* parent_;
glib::Object<GSettings> usettings_;
+ glib::Object<GSettings> compiz_settings_;
glib::Object<GSettings> launcher_settings_;
glib::Object<GSettings> lim_settings_;
glib::Object<GSettings> gestures_settings_;
@@ -509,7 +564,8 @@ public:
//
Settings::Settings()
- : is_standalone(false)
+ : supports_3d(glib::gchar_to_string(getenv("UNITY_HAS_3D_SUPPORT")) != "false")
+ , is_standalone(false)
, pimpl(new Impl(this))
{
if (settings_instance)
diff --git a/unity-shared/UnitySettings.h b/unity-shared/UnitySettings.h
index b9d0358b4..144e2c124 100644
--- a/unity-shared/UnitySettings.h
+++ b/unity-shared/UnitySettings.h
@@ -60,6 +60,7 @@ public:
int LauncherSize(int mointor) const;
nux::Property<bool> low_gfx;
+ nux::Property<bool> supports_3d;
nux::RWProperty<FormFactor> form_factor;
nux::Property<bool> is_standalone;
nux::ROProperty<DesktopType> desktop_type;