aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dbus-names.h59
-rw-r--r--src/indicator.h2
-rw-r--r--src/main.cpp14
-rw-r--r--src/service.cpp543
-rw-r--r--src/service.h2
5 files changed, 345 insertions, 275 deletions
diff --git a/src/dbus-names.h b/src/dbus-names.h
deleted file mode 100644
index aa7ef2a..0000000
--- a/src/dbus-names.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2016 Canonical Ltd.
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- * Charles Kerr <charles.kerr@canonical.com>
- */
-
-#pragma once
-
-namespace DBusNames
-{
- namespace Notify
- {
- static constexpr char const * NAME = "org.freedesktop.Notifications";
- static constexpr char const * PATH = "/org/freedesktop/Notifications";
- static constexpr char const * INTERFACE = "org.freedesktop.Notifications";
-
- namespace ActionInvoked
- {
- static constexpr char const * NAME = "ActionInvoked";
- }
-
- namespace NotificationClosed
- {
- static constexpr char const * NAME = "NotificationClosed";
- enum Reason { EXPIRED=1, DISMISSED=2, API=3, UNDEFINED=4 };
- }
- }
-
- namespace Greeter
- {
- static constexpr char const * NAME = "org.ayatana.Greeter";
- static constexpr char const * PATH = "/";
- static constexpr char const * INTERFACE = "org.ayatana.Greeter";
- }
-
- namespace Properties
- {
- static constexpr char const * INTERFACE = "org.freedesktop.DBus.Properties";
-
- namespace PropertiesChanged
- {
- static constexpr char const* NAME = "PropertiesChanged";
- static constexpr char const* ARGS_VARIANT_TYPE = "(sa{sv}as)";
- }
- }
-}
diff --git a/src/indicator.h b/src/indicator.h
index c9ccb1e..db8c5ac 100644
--- a/src/indicator.h
+++ b/src/indicator.h
@@ -65,7 +65,7 @@ class SimpleProfile: public Profile
{
public:
SimpleProfile(const char* name, const std::shared_ptr<GMenuModel>& menu): m_name(name), m_menu(menu) {}
- virtual ~SimpleProfile();
+ virtual ~SimpleProfile() override;
std::string name() const override {return m_name;}
core::Property<Header>& header() override {return m_header;}
diff --git a/src/main.cpp b/src/main.cpp
index a422610..c03a5ec 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -48,6 +48,20 @@ main(int /*argc*/, char** /*argv*/)
// boilerplate i18n
setlocale(LC_ALL, "");
+
+ // Initialize LC_NUMERIC with 'POSIX'. This assures that float number
+ // conversions (from float to string via e.g. g_strdup_sprintf()) always
+ // use a dot in decimal numbers.
+ //
+ // This resolves blackening of the screen if users with e.g. de_DE.UTF-8
+ // use the brightness slider and hand over a komma-decimal to the xsct
+ // executable (which only understands dot-decimals).
+ //
+ // As we don't use numbers / number conversions anywhere else in the
+ // display indicator, this global setting of LC_NUMERIC seems to be the
+ // easiest approach.
+ setlocale(LC_NUMERIC, "POSIX");
+
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
textdomain(GETTEXT_PACKAGE);
diff --git a/src/service.cpp b/src/service.cpp
index 26faec9..d6b4ed7 100644
--- a/src/service.cpp
+++ b/src/service.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 2014 Canonical Ltd.
- * Copyright 2023-2024 Robert Tari
+ * Copyright 2023-2025 Robert Tari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,6 +24,13 @@
#ifdef COLOR_TEMP_ENABLED
#include <geoclue.h>
+
+ #ifdef RDA_ENABLED
+ #include <rda/rda.h>
+ #endif
+
+ #include <X11/Xlib.h>
+ #include <X11/extensions/Xrandr.h>
#endif
extern "C"
@@ -67,6 +74,81 @@ public:
#ifdef COLOR_TEMP_ENABLED
const gchar *sTest = g_getenv ("TEST_NAME");
this->bTest = (sTest != NULL && g_str_equal (sTest, "rotation-lock-test"));
+
+ if (!this->bTest)
+ {
+ // Check if we are on Wayland
+ const gchar *sWayland = g_getenv ("WAYLAND_DISPLAY");
+ this->bXsctUnsupported = (sWayland != NULL);
+ //~Check if we are on Wayland
+
+ // Check if we are in a virtual environment
+ if (!this->bXsctUnsupported)
+ {
+ Display *pDisplay = XOpenDisplay (NULL);
+
+ if (!pDisplay)
+ {
+ g_warning ("Panic: Failed to open X display while checking for virtual environment");
+ }
+ else
+ {
+ guint nScreen = DefaultScreen (pDisplay);
+ Window pWindow = RootWindow (pDisplay, nScreen);
+ XRRScreenResources *pResources = XRRGetScreenResources (pDisplay, pWindow);
+
+ if (!pResources)
+ {
+ g_warning ("Panic: Failed to get screen resources while checking for virtual environment");
+ XCloseDisplay (pDisplay);
+ }
+ else
+ {
+ RROutput nOutputPrimary = XRRGetOutputPrimary (pDisplay, pWindow);
+ XRROutputInfo *pOutputInfo = XRRGetOutputInfo (pDisplay, pResources, nOutputPrimary);
+ GRegex *pRegex = NULL;
+ GError *pError = NULL;
+
+ #if GLIB_CHECK_VERSION(2, 73, 0)
+ pRegex = g_regex_new (".*virtual.*", G_REGEX_CASELESS, G_REGEX_MATCH_DEFAULT, &pError);
+ #else
+ pRegex = g_regex_new (".*virtual.*", G_REGEX_CASELESS, (GRegexMatchFlags) 0, &pError);
+ #endif
+
+ if (!pError)
+ {
+ #if GLIB_CHECK_VERSION(2, 73, 0)
+ gboolean bMatch = g_regex_match (pRegex, pOutputInfo->name, G_REGEX_MATCH_DEFAULT, NULL);
+ #else
+ gboolean bMatch = g_regex_match (pRegex, pOutputInfo->name, (GRegexMatchFlags) 0, NULL);
+ #endif
+
+ if (bMatch)
+ {
+ this->bXsctUnsupported = TRUE;
+ }
+
+ g_regex_unref (pRegex);
+ }
+ else
+ {
+ g_warning ("PANIC: Failed to compile regex: %s", pError->message);
+ g_error_free (pError);
+ }
+
+ XRRFreeOutputInfo (pOutputInfo);
+ XRRFreeScreenResources (pResources);
+ XCloseDisplay (pDisplay);
+
+ #ifdef RDA_ENABLED
+ gboolean bRemote = rda_session_is_remote ();
+ this->bXsctUnsupported = this->bXsctUnsupported || bRemote;
+ #endif
+ }
+ }
+ }
+ //~Check if we are in a virtual environment
+ }
#endif
const char *sUserName = g_get_user_name();
this->bGreeter = g_str_equal (sUserName, "lightdm");
@@ -76,7 +158,7 @@ public:
{
if (ayatana_common_utils_is_lomiri()) {
- GSettingsSchema *pSchema = g_settings_schema_source_lookup(pSource, "com.lomiri.touch.system", FALSE);
+ GSettingsSchema *pSchema = g_settings_schema_source_lookup(pSource, "com.lomiri.touch.system", TRUE);
if (pSchema != NULL)
{
@@ -85,13 +167,12 @@ public:
}
else
{
- g_error("No schema could be found");
+ g_error ("Panic: No com.lomiri.touch.system schema could be found");
}
-
}
else {
- GSettingsSchema *pSchema = g_settings_schema_source_lookup(pSource, "org.ayatana.indicator.display", FALSE);
+ GSettingsSchema *pSchema = g_settings_schema_source_lookup(pSource, "org.ayatana.indicator.display", TRUE);
if (pSchema != NULL)
{
@@ -100,7 +181,7 @@ public:
}
else
{
- g_error("No schema could be found");
+ g_error ("Panic: No org.ayatana.indicator.display schema could be found");
}
#ifdef COLOR_TEMP_ENABLED
@@ -134,40 +215,40 @@ public:
}
}
- pSchema = g_settings_schema_source_lookup (pSource, sSchema, FALSE);
+ pSchema = g_settings_schema_source_lookup (pSource, sSchema, TRUE);
if (pSchema != NULL)
{
g_settings_schema_unref (pSchema);
- pThemeSettings = g_settings_new (sSchema);
+ this->pThemeSettings = g_settings_new (sSchema);
}
else
{
- g_error("No %s schema could be found", sSchema);
+ g_warning ("Panic: No %s schema could be found", sSchema);
}
- pSchema = g_settings_schema_source_lookup (pSource, sCursorSchema, FALSE);
+ pSchema = g_settings_schema_source_lookup (pSource, sCursorSchema, TRUE);
if (pSchema != NULL)
{
g_settings_schema_unref (pSchema);
- pCursorSettings = g_settings_new (sCursorSchema);
+ this->pCursorSettings = g_settings_new (sCursorSchema);
}
else
{
- g_error("No %s schema could be found", sCursorSchema);
+ g_warning ("Panic: No %s schema could be found", sCursorSchema);
}
- pSchema = g_settings_schema_source_lookup (pSource, sMetacitySchema, FALSE);
+ pSchema = g_settings_schema_source_lookup (pSource, sMetacitySchema, TRUE);
if (pSchema != NULL)
{
g_settings_schema_unref (pSchema);
- pMetacitySettings = g_settings_new (sMetacitySchema);
+ this->pMetacitySettings = g_settings_new (sMetacitySchema);
}
else
{
- g_error("No %s schema could be found", sMetacitySchema);
+ g_warning ("Panic: No %s schema could be found", sMetacitySchema);
}
if (this->bTest)
@@ -179,7 +260,7 @@ public:
sSchema = "org.gnome.desktop.interface";
}
- pSchema = g_settings_schema_source_lookup (pSource, sSchema, FALSE);
+ pSchema = g_settings_schema_source_lookup (pSource, sSchema, TRUE);
if (pSchema != NULL)
{
@@ -188,7 +269,7 @@ public:
if (bColorScheme)
{
- pColorSchemeSettings = g_settings_new (sSchema);
+ this->pColorSchemeSettings = g_settings_new (sSchema);
}
else
{
@@ -197,7 +278,7 @@ public:
}
else
{
- g_error("No %s schema could be found", sSchema);
+ g_warning ("Panic: No %s schema could be found", sSchema);
}
}
else
@@ -224,7 +305,7 @@ public:
if (!ayatana_common_utils_is_lomiri())
{
- icon_name = "display-panel";
+ icon_name = "video-display-panel";
}
auto icon = g_themed_icon_new_with_default_fallbacks(icon_name);
@@ -240,7 +321,13 @@ public:
// build the desktop profile
std::shared_ptr<GMenuModel> desktop_menu (create_desktop_menu(), menu_model_deleter);
m_desktop = std::make_shared<SimpleProfile>("desktop", desktop_menu);
- update_desktop_header();
+ gboolean bVisible = !this->bGreeter;
+
+ #ifdef COLOR_TEMP_ENABLED
+ bVisible = bVisible || !this->bXsctUnsupported;
+ #endif
+
+ update_desktop_header(bVisible);
#ifdef COLOR_TEMP_ENABLED
if (ayatana_common_utils_is_lomiri() == FALSE)
@@ -285,25 +372,10 @@ public:
g_free (sLastTheme);
}
- if (pThemeSettings)
- {
- g_clear_object (&pThemeSettings);
- }
-
- if (pCursorSettings)
- {
- g_clear_object (&pCursorSettings);
- }
-
- if (pMetacitySettings)
- {
- g_clear_object (&pMetacitySettings);
- }
-
- if (pColorSchemeSettings)
- {
- g_clear_object (&pColorSchemeSettings);
- }
+ g_clear_object (&pThemeSettings);
+ g_clear_object (&pCursorSettings);
+ g_clear_object (&pMetacitySettings);
+ g_clear_object (&pColorSchemeSettings);
if (this->pAccountsServiceConnection)
{
@@ -334,40 +406,43 @@ private:
#ifdef COLOR_TEMP_ENABLED
static void onUserChanged (GDBusConnection *pConnection, const gchar *sSender, const gchar *sPath, const gchar *sInterface, const gchar *sSignal, GVariant *pParameters, gpointer pUserData)
{
- DisplayIndicator::Impl *pImpl = (DisplayIndicator::Impl*) pUserData;
+ DisplayIndicator::Impl *pImpl = static_cast<DisplayIndicator::Impl*>(pUserData);
g_variant_get (pParameters, "(s)", &pImpl->sUser);
loadManager (pImpl);
}
static void getAccountsService (DisplayIndicator::Impl *pImpl, gint nUid)
{
- pImpl->bReadingAccountsService = TRUE;
- gchar *sPath = g_strdup_printf ("/org/freedesktop/Accounts/User%i", nUid);
- GDBusProxy *pProxy = g_dbus_proxy_new_sync (pImpl->pAccountsServiceConnection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.Accounts", sPath, "org.freedesktop.DBus.Properties", NULL, NULL);
- g_free (sPath);
-
- if (pProxy)
+ if (!pImpl->bXsctUnsupported)
{
- const gchar *lProperties[] = {"brightness", "color-temp", "color-temp-profile"};
+ pImpl->bReadingAccountsService = TRUE;
+ gchar *sPath = g_strdup_printf ("/org/freedesktop/Accounts/User%i", nUid);
+ GDBusProxy *pProxy = g_dbus_proxy_new_sync (pImpl->pAccountsServiceConnection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.Accounts", sPath, "org.freedesktop.DBus.Properties", NULL, NULL);
+ g_free (sPath);
- for (gint nIndex = 0; nIndex < 3; nIndex++)
+ if (pProxy)
{
- GVariant *pParams = g_variant_new ("(ss)", "org.ayatana.indicator.display.AccountsService", lProperties[nIndex]);
- GVariant *pValue = g_dbus_proxy_call_sync (pProxy, "Get", pParams, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
+ const gchar *lProperties[] = {"brightness", "color-temp", "color-temp-profile"};
- if (pValue)
+ for (gint nIndex = 0; nIndex < 3; nIndex++)
{
- GVariant *pChild0 = g_variant_get_child_value (pValue, 0);
- g_variant_unref (pValue);
- GVariant *pChild1 = g_variant_get_child_value (pChild0, 0);
- g_variant_unref (pChild0);
- g_settings_set_value (pImpl->m_settings, lProperties[nIndex], pChild1);
- g_variant_unref (pChild1);
+ GVariant *pParams = g_variant_new ("(ss)", "org.ayatana.indicator.display.AccountsService", lProperties[nIndex]);
+ GVariant *pValue = g_dbus_proxy_call_sync (pProxy, "Get", pParams, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
+
+ if (pValue)
+ {
+ GVariant *pChild0 = g_variant_get_child_value (pValue, 0);
+ g_variant_unref (pValue);
+ GVariant *pChild1 = g_variant_get_child_value (pChild0, 0);
+ g_variant_unref (pChild0);
+ g_settings_set_value (pImpl->m_settings, lProperties[nIndex], pChild1);
+ g_variant_unref (pChild1);
+ }
}
}
- }
- pImpl->bReadingAccountsService = FALSE;
+ pImpl->bReadingAccountsService = FALSE;
+ }
}
static void onUserLoaded (DisplayIndicator::Impl *pImpl, ActUser *pUser)
@@ -449,7 +524,7 @@ private:
static gboolean updateColor (gpointer pData)
{
- DisplayIndicator::Impl *pImpl = (DisplayIndicator::Impl*) pData;
+ DisplayIndicator::Impl *pImpl = static_cast<DisplayIndicator::Impl*>(pData);
if (pImpl->bReadingAccountsService)
{
@@ -457,8 +532,14 @@ private:
}
guint nProfile = 0;
- g_settings_get (pImpl->m_settings, "color-temp-profile", "q", &nProfile);
- gdouble fBrightness = g_settings_get_double (pImpl->m_settings, "brightness");
+ gdouble fBrightness = 0.0;
+
+ if (!pImpl->bXsctUnsupported)
+ {
+ g_settings_get (pImpl->m_settings, "color-temp-profile", "q", &nProfile);
+ fBrightness = g_settings_get_double (pImpl->m_settings, "brightness");
+ }
+
gchar *sThemeProfile = NULL;
gboolean bThemeAdaptive = FALSE;
@@ -474,25 +555,28 @@ private:
gint64 nNow = g_get_real_time ();
gdouble fElevation = solar_elevation((gdouble) nNow / 1000000.0, pImpl->fLatitude, pImpl->fLongitude);
- if (nProfile == 0)
- {
- g_settings_get (pImpl->m_settings, "color-temp", "q", &nTemperature);
- }
- else
+ if (!pImpl->bXsctUnsupported)
{
- gdouble fShifting = 0.0;
-
- if (fElevation < SOLAR_CIVIL_TWILIGHT_ELEV)
+ if (nProfile == 0)
{
- fShifting = 1.0;
+ g_settings_get (pImpl->m_settings, "color-temp", "q", &nTemperature);
}
- else if (fElevation < 3.0)
+ else
{
- fShifting = 1.0 - ((SOLAR_CIVIL_TWILIGHT_ELEV - fElevation) / (SOLAR_CIVIL_TWILIGHT_ELEV - 3.0));
- }
+ gdouble fShifting = 0.0;
- nTemperature = m_lTempProfiles[nProfile].nTempHigh - (m_lTempProfiles[nProfile].nTempHigh - m_lTempProfiles[nProfile].nTempLow) * fShifting;
- pImpl->bAutoSliderUpdate = TRUE;
+ if (fElevation < SOLAR_CIVIL_TWILIGHT_ELEV)
+ {
+ fShifting = 1.0;
+ }
+ else if (fElevation < 3.0)
+ {
+ fShifting = 1.0 - ((SOLAR_CIVIL_TWILIGHT_ELEV - fElevation) / (SOLAR_CIVIL_TWILIGHT_ELEV - 3.0));
+ }
+
+ nTemperature = m_lTempProfiles[nProfile].nTempHigh - (m_lTempProfiles[nProfile].nTempHigh - m_lTempProfiles[nProfile].nTempLow) * fShifting;
+ pImpl->bAutoSliderUpdate = TRUE;
+ }
}
if (!pImpl->bGreeter)
@@ -529,57 +613,63 @@ private:
}
}
- if (pImpl->fLastBrightness != fBrightness || pImpl->nLasColorTemp != nTemperature)
+ if (!pImpl->bXsctUnsupported)
{
- g_debug ("Calling xsct with %u %f", nTemperature, fBrightness);
+ if (pImpl->fLastBrightness != fBrightness || pImpl->nLasColorTemp != nTemperature)
+ {
+ g_debug ("Calling xsct with %u %f", nTemperature, fBrightness);
- GAction *pAction = g_action_map_lookup_action (G_ACTION_MAP (pImpl->m_action_group), "color-temp");
- GVariant *pTemperature = g_variant_new_double (nTemperature);
- g_action_change_state (pAction, pTemperature);
+ GAction *pAction = g_action_map_lookup_action (G_ACTION_MAP (pImpl->m_action_group), "color-temp");
+ GVariant *pTemperature = g_variant_new_double (nTemperature);
+ g_action_change_state (pAction, pTemperature);
- GError *pError = NULL;
- gchar *sCommand = g_strdup_printf ("xsct %u %f", nTemperature, fBrightness);
- gboolean bSuccess = g_spawn_command_line_sync (sCommand, NULL, NULL, NULL, &pError);
+ GError *pError = NULL;
+ gchar *sCommand = g_strdup_printf ("xsct %u %f", nTemperature, fBrightness);
+ gboolean bSuccess = g_spawn_command_line_sync (sCommand, NULL, NULL, NULL, &pError);
- if (!bSuccess)
- {
- g_error ("The call to '%s' failed: %s", sCommand, pError->message);
- g_error_free (pError);
- }
+ if (!bSuccess)
+ {
+ g_warning ("Panic: The call to '%s' failed: %s", sCommand, pError->message);
+ g_error_free (pError);
+ }
+ else
+ {
+ pImpl->fLastBrightness = fBrightness;
+ pImpl->nLasColorTemp = nTemperature;
+ gint nUid = 0;
- pImpl->fLastBrightness = fBrightness;
- pImpl->nLasColorTemp = nTemperature;
- g_free (sCommand);
- gint nUid = 0;
+ if (!pImpl->bGreeter)
+ {
+ nUid = geteuid ();
+ }
+ else if (pImpl->sUser)
+ {
+ const struct passwd *pPasswd = getpwnam (pImpl->sUser);
- if (!pImpl->bGreeter)
- {
- nUid = geteuid ();
- }
- else if (pImpl->sUser)
- {
- const struct passwd *pPasswd = getpwnam (pImpl->sUser);
+ if (pPasswd)
+ {
+ nUid = pPasswd->pw_uid;
+ }
+ }
- if (pPasswd)
- {
- nUid = pPasswd->pw_uid;
+ if (nUid)
+ {
+ gchar *sPath = g_strdup_printf ("/org/freedesktop/Accounts/User%i", nUid);
+ GDBusProxy *pProxy = g_dbus_proxy_new_sync (pImpl->pAccountsServiceConnection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.Accounts", sPath, "org.freedesktop.DBus.Properties", NULL, NULL);
+ g_free (sPath);
+ GVariant *pBrightnessValue = g_variant_new ("d", pImpl->fLastBrightness);
+ GVariant *pBrightnessParams = g_variant_new ("(ssv)", "org.ayatana.indicator.display.AccountsService", "brightness", pBrightnessValue);
+ g_dbus_proxy_call (pProxy, "Set", pBrightnessParams, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+ GVariant *pColorTempValue = g_variant_new ("q", pImpl->nLasColorTemp);
+ GVariant *pColorTempParams = g_variant_new ("(ssv)", "org.ayatana.indicator.display.AccountsService", "color-temp", pColorTempValue);
+ g_dbus_proxy_call (pProxy, "Set", pColorTempParams, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+ GVariant *pProfileValue = g_variant_new ("q", nProfile);
+ GVariant *pProfileParams = g_variant_new ("(ssv)", "org.ayatana.indicator.display.AccountsService", "color-temp-profile", pProfileValue);
+ g_dbus_proxy_call (pProxy, "Set", pProfileParams, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+ }
}
- }
- if (nUid)
- {
- gchar *sPath = g_strdup_printf ("/org/freedesktop/Accounts/User%i", nUid);
- GDBusProxy *pProxy = g_dbus_proxy_new_sync (pImpl->pAccountsServiceConnection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.Accounts", sPath, "org.freedesktop.DBus.Properties", NULL, NULL);
- g_free (sPath);
- GVariant *pBrightnessValue = g_variant_new ("d", pImpl->fLastBrightness);
- GVariant *pBrightnessParams = g_variant_new ("(ssv)", "org.ayatana.indicator.display.AccountsService", "brightness", pBrightnessValue);
- g_dbus_proxy_call (pProxy, "Set", pBrightnessParams, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
- GVariant *pColorTempValue = g_variant_new ("q", pImpl->nLasColorTemp);
- GVariant *pColorTempParams = g_variant_new ("(ssv)", "org.ayatana.indicator.display.AccountsService", "color-temp", pColorTempValue);
- g_dbus_proxy_call (pProxy, "Set", pColorTempParams, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
- GVariant *pProfileValue = g_variant_new ("q", nProfile);
- GVariant *pProfileParams = g_variant_new ("(ssv)", "org.ayatana.indicator.display.AccountsService", "color-temp-profile", pProfileValue);
- g_dbus_proxy_call (pProxy, "Set", pProfileParams, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+ g_free (sCommand);
}
}
@@ -608,7 +698,11 @@ private:
{
g_debug ("Changing theme to %s", sTheme);
- g_settings_set_string (pImpl->pThemeSettings, "gtk-theme", sTheme);
+ if (pImpl->pThemeSettings)
+ {
+ g_settings_set_string (pImpl->pThemeSettings, "gtk-theme", sTheme);
+ }
+
gchar *sThemePath = g_strdup_printf ("/usr/share/themes/%s/index.theme", sTheme);
gboolean bThemePath = g_file_test (sThemePath, G_FILE_TEST_EXISTS);
@@ -639,7 +733,12 @@ private:
if (bMatch)
{
gchar *sIconTheme = g_match_info_fetch (pMatchInfo, 1);
- g_settings_set_string (pImpl->pThemeSettings, "icon-theme", sIconTheme);
+
+ if (pImpl->pThemeSettings)
+ {
+ g_settings_set_string (pImpl->pThemeSettings, "icon-theme", sIconTheme);
+ }
+
g_free (sIconTheme);
}
else
@@ -652,7 +751,7 @@ private:
}
else
{
- g_error ("PANIC: Failed to compile regex: %s", pError->message);
+ g_warning ("Panic: Failed to compile regex: %s", pError->message);
g_error_free (pError);
}
@@ -675,7 +774,12 @@ private:
if (bMatch)
{
gchar *sMetacityTheme = g_match_info_fetch (pMatchInfo, 1);
- g_settings_set_string (pImpl->pMetacitySettings, "theme", sMetacityTheme);
+
+ if (pImpl->pMetacitySettings)
+ {
+ g_settings_set_string (pImpl->pMetacitySettings, "theme", sMetacityTheme);
+ }
+
g_free (sMetacityTheme);
}
else
@@ -688,7 +792,7 @@ private:
}
else
{
- g_error ("PANIC: Failed to compile regex: %s", pError->message);
+ g_warning ("Panic: Failed to compile regex: %s", pError->message);
g_error_free (pError);
}
@@ -711,7 +815,12 @@ private:
if (bMatch)
{
gchar *sCursorTheme = g_match_info_fetch (pMatchInfo, 1);
- g_settings_set_string (pImpl->pCursorSettings, "cursor-theme", sTheme);
+
+ if (pImpl->pCursorSettings)
+ {
+ g_settings_set_string (pImpl->pCursorSettings, "cursor-theme", sTheme);
+ }
+
g_free (sCursorTheme);
}
else
@@ -724,7 +833,7 @@ private:
}
else
{
- g_error ("PANIC: Failed to compile regex: %s", pError->message);
+ g_warning ("Panic: Failed to compile regex: %s", pError->message);
g_error_free (pError);
}
@@ -732,7 +841,7 @@ private:
}
else
{
- g_error ("PANIC: Failed to get index.theme contents: %s", pError->message);
+ g_warning ("Panic: Failed to get index.theme contents: %s", pError->message);
g_error_free (pError);
}
}
@@ -760,7 +869,7 @@ private:
static void onGeoClueLoaded (GObject *pObject, GAsyncResult *pResult, gpointer pData)
{
- DisplayIndicator::Impl *pImpl = (DisplayIndicator::Impl*) pData;
+ DisplayIndicator::Impl *pImpl = static_cast<DisplayIndicator::Impl*>(pData);
GError *pError = NULL;
GClueSimple *pSimple = gclue_simple_new_finish (pResult, &pError);
@@ -816,7 +925,7 @@ private:
{
g_simple_action_set_state (pAction, pVariant);
- DisplayIndicator::Impl *pImpl = (DisplayIndicator::Impl*) pData;
+ DisplayIndicator::Impl *pImpl = static_cast<DisplayIndicator::Impl*>(pData);
if (pImpl->bAutoSliderUpdate)
{
@@ -880,36 +989,39 @@ private:
#ifdef COLOR_TEMP_ENABLED
if (ayatana_common_utils_is_lomiri() == FALSE)
{
- pVariantType = g_variant_type_new ("d");
- guint nTemperature = 0;
- g_settings_get (this->m_settings, "color-temp", "q", &nTemperature);
- action = g_simple_action_new_stateful ("color-temp", pVariantType, g_variant_new_double (nTemperature));
- g_variant_type_free (pVariantType);
- g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
- g_signal_connect (m_settings, "changed::color-temp", G_CALLBACK (onColorTempSettings), this);
- g_signal_connect (action, "change-state", G_CALLBACK (onColorTempState), this);
- g_object_unref(G_OBJECT (action));
+ if (!this->bXsctUnsupported)
+ {
+ pVariantType = g_variant_type_new ("d");
+ guint nTemperature = 0;
+ g_settings_get (this->m_settings, "color-temp", "q", &nTemperature);
+ action = g_simple_action_new_stateful ("color-temp", pVariantType, g_variant_new_double (nTemperature));
+ g_variant_type_free (pVariantType);
+ g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
+ g_signal_connect (m_settings, "changed::color-temp", G_CALLBACK (onColorTempSettings), this);
+ g_signal_connect (action, "change-state", G_CALLBACK (onColorTempState), this);
+ g_object_unref(G_OBJECT (action));
- pVariantType = g_variant_type_new ("s");
- guint nProfile = 0;
- g_settings_get (this->m_settings, "color-temp-profile", "q", &nProfile);
- gchar *sProfile = g_strdup_printf ("%i", nProfile);
- action = g_simple_action_new_stateful ("profile", pVariantType, g_variant_new_string (sProfile));
- g_free (sProfile);
- g_variant_type_free (pVariantType);
- g_settings_bind_with_mapping (this->m_settings, "color-temp-profile", action, "state", G_SETTINGS_BIND_DEFAULT, settingsIntToActionStateString, actionStateStringToSettingsInt, NULL, NULL);
- g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
- g_object_unref(G_OBJECT(action));
- g_signal_connect_swapped (m_settings, "changed::color-temp-profile", G_CALLBACK (updateColor), this);
-
- pVariantType = g_variant_type_new("d");
- gdouble fBrightness = g_settings_get_double (this->m_settings, "brightness");
- action = g_simple_action_new_stateful ("brightness", pVariantType, g_variant_new_double (fBrightness));
- g_variant_type_free(pVariantType);
- g_settings_bind_with_mapping (m_settings, "brightness", action, "state", G_SETTINGS_BIND_DEFAULT, settings_to_action_state, action_state_to_settings, NULL, NULL);
- g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
- g_object_unref (G_OBJECT (action));
- g_signal_connect_swapped (m_settings, "changed::brightness", G_CALLBACK (updateColor), this);
+ pVariantType = g_variant_type_new ("s");
+ guint nProfile = 0;
+ g_settings_get (this->m_settings, "color-temp-profile", "q", &nProfile);
+ gchar *sProfile = g_strdup_printf ("%i", nProfile);
+ action = g_simple_action_new_stateful ("profile", pVariantType, g_variant_new_string (sProfile));
+ g_free (sProfile);
+ g_variant_type_free (pVariantType);
+ g_settings_bind_with_mapping (this->m_settings, "color-temp-profile", action, "state", G_SETTINGS_BIND_DEFAULT, settingsIntToActionStateString, actionStateStringToSettingsInt, NULL, NULL);
+ g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
+ g_object_unref(G_OBJECT(action));
+ g_signal_connect_swapped (m_settings, "changed::color-temp-profile", G_CALLBACK (updateColor), this);
+
+ pVariantType = g_variant_type_new("d");
+ gdouble fBrightness = g_settings_get_double (this->m_settings, "brightness");
+ action = g_simple_action_new_stateful ("brightness", pVariantType, g_variant_new_double (fBrightness));
+ g_variant_type_free(pVariantType);
+ g_settings_bind_with_mapping (m_settings, "brightness", action, "state", G_SETTINGS_BIND_DEFAULT, settings_to_action_state, action_state_to_settings, NULL, NULL);
+ g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
+ g_object_unref (G_OBJECT (action));
+ g_signal_connect_swapped (m_settings, "changed::brightness", G_CALLBACK (updateColor), this);
+ }
if (!this->bGreeter)
{
@@ -1003,69 +1115,71 @@ private:
#ifdef COLOR_TEMP_ENABLED
section = g_menu_new ();
- GIcon *pIconMin = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-brightness-low");
- GIcon *pIconMax = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-brightness-high");
- GVariant *pIconMinSerialised = g_icon_serialize (pIconMin);
- GVariant *pIconMaxSerialised = g_icon_serialize (pIconMax);
- menu_item = g_menu_item_new (_("Brightness"), "indicator.brightness");
- g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
- g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
- g_menu_item_set_attribute_value (menu_item, "min-icon", pIconMinSerialised);
- g_menu_item_set_attribute_value (menu_item, "max-icon", pIconMaxSerialised);
- g_menu_item_set_attribute (menu_item, "min-value", "d", 0.5);
- g_menu_item_set_attribute (menu_item, "max-value", "d", 1.0);
- g_menu_item_set_attribute (menu_item, "step", "d", 0.01);
- g_menu_item_set_attribute (menu_item, "digits", "y", 2);
- g_menu_append_item (section, menu_item);
-
- pIconMin = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-colortemp-on");
- pIconMax = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-colortemp-off");
- pIconMinSerialised = g_icon_serialize (pIconMin);
- pIconMaxSerialised = g_icon_serialize (pIconMax);
- menu_item = g_menu_item_new (_("Color temperature"), "indicator.color-temp");
- g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
- g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
- g_menu_item_set_attribute_value (menu_item, "min-icon", pIconMinSerialised);
- g_menu_item_set_attribute_value (menu_item, "max-icon", pIconMaxSerialised);
- g_menu_item_set_attribute (menu_item, "min-value", "d", 3000.0);
- g_menu_item_set_attribute (menu_item, "max-value", "d", 6500.0);
- g_menu_item_set_attribute (menu_item, "step", "d", 100.0);
- g_menu_item_set_attribute (menu_item, "digits", "y", 0);
- g_menu_append_item (section, menu_item);
-
- GMenu *pMenuProfiles = g_menu_new ();
- GMenuItem *pItemProfiles = g_menu_item_new_submenu (_("Color temperature profile"), G_MENU_MODEL (pMenuProfiles));
- guint nProfile = 0;
-
- while (m_lTempProfiles[nProfile].sName != NULL)
+ if (!this->bXsctUnsupported)
{
- gchar *sAction = g_strdup_printf ("indicator.profile::%u", nProfile);
- gchar *sName = gettext (m_lTempProfiles[nProfile].sName);
- GMenuItem *pItemProfile = g_menu_item_new (sName, sAction);
- g_free(sAction);
- g_menu_append_item (pMenuProfiles, pItemProfile);
- g_object_unref (pItemProfile);
+ GIcon *pIconMin = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-brightness-low");
+ GIcon *pIconMax = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-brightness-high");
+ GVariant *pIconMinSerialised = g_icon_serialize (pIconMin);
+ GVariant *pIconMaxSerialised = g_icon_serialize (pIconMax);
+ menu_item = g_menu_item_new (_("Brightness"), "indicator.brightness");
+ g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
+ g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
+ g_menu_item_set_attribute_value (menu_item, "min-icon", pIconMinSerialised);
+ g_menu_item_set_attribute_value (menu_item, "max-icon", pIconMaxSerialised);
+ g_menu_item_set_attribute (menu_item, "min-value", "d", 0.5);
+ g_menu_item_set_attribute (menu_item, "max-value", "d", 1.0);
+ g_menu_item_set_attribute (menu_item, "step", "d", 0.01);
+ g_menu_item_set_attribute (menu_item, "digits", "y", 2);
+ g_menu_append_item (section, menu_item);
- nProfile++;
- }
+ pIconMin = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-colortemp-on");
+ pIconMax = g_themed_icon_new_with_default_fallbacks ("ayatana-indicator-display-colortemp-off");
+ pIconMinSerialised = g_icon_serialize (pIconMin);
+ pIconMaxSerialised = g_icon_serialize (pIconMax);
+ menu_item = g_menu_item_new (_("Color temperature"), "indicator.color-temp");
+ g_menu_item_set_attribute (menu_item, "x-ayatana-type", "s", "org.ayatana.indicator.slider");
+ g_menu_item_set_attribute_value (menu_item, "min-icon", pIconMinSerialised);
+ g_menu_item_set_attribute_value (menu_item, "max-icon", pIconMaxSerialised);
+ g_menu_item_set_attribute (menu_item, "min-value", "d", 3000.0);
+ g_menu_item_set_attribute (menu_item, "max-value", "d", 6500.0);
+ g_menu_item_set_attribute (menu_item, "step", "d", 100.0);
+ g_menu_item_set_attribute (menu_item, "digits", "y", 0);
+ g_menu_append_item (section, menu_item);
+
+ GMenu *pMenuProfiles = g_menu_new ();
+ GMenuItem *pItemProfiles = g_menu_item_new_submenu (_("Color temperature profile"), G_MENU_MODEL (pMenuProfiles));
+ guint nProfile = 0;
- g_menu_append_item (section, pItemProfiles);
- g_object_unref (pItemProfiles);
- g_object_unref (pMenuProfiles);
+ while (m_lTempProfiles[nProfile].sName != NULL)
+ {
+ gchar *sAction = g_strdup_printf ("indicator.profile::%u", nProfile);
+ gchar *sName = gettext (m_lTempProfiles[nProfile].sName);
+ GMenuItem *pItemProfile = g_menu_item_new (sName, sAction);
+ g_free(sAction);
+ g_menu_append_item (pMenuProfiles, pItemProfile);
+ g_object_unref (pItemProfile);
+
+ nProfile++;
+ }
- g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
- g_object_unref (pIconMin);
- g_object_unref (pIconMax);
- g_variant_unref (pIconMinSerialised);
- g_variant_unref (pIconMaxSerialised);
- g_object_unref (section);
- g_object_unref (menu_item);
+ g_menu_append_item (section, pItemProfiles);
+ g_object_unref (pItemProfiles);
+ g_object_unref (pMenuProfiles);
+
+ g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
+ g_object_unref (pIconMin);
+ g_object_unref (pIconMax);
+ g_variant_unref (pIconMinSerialised);
+ g_variant_unref (pIconMaxSerialised);
+ g_object_unref (section);
+ g_object_unref (menu_item);
+ }
if (!this->bGreeter)
{
section = g_menu_new ();
- pMenuProfiles = g_menu_new ();
- pItemProfiles = g_menu_item_new_submenu (_("Theme profile"), G_MENU_MODEL (pMenuProfiles));
+ GMenu *pMenuProfiles = g_menu_new ();
+ GMenuItem *pItemProfiles = g_menu_item_new_submenu (_("Theme profile"), G_MENU_MODEL (pMenuProfiles));
GMenuItem *pItemProfile = g_menu_item_new (_("Light"), "indicator.theme::light");
g_menu_append_item (pMenuProfiles, pItemProfile);
g_object_unref (pItemProfile);
@@ -1108,13 +1222,13 @@ private:
m_phone->header().set(h);
}
- void update_desktop_header()
+ void update_desktop_header(gboolean bVisible)
{
Header h;
h.title = _("Display");
h.tooltip = _("Display settings and features");
h.a11y = h.title;
- h.is_visible = TRUE;
+ h.is_visible = bVisible;
h.icon = m_icon;
m_desktop->header().set(h);
}
@@ -1149,6 +1263,7 @@ private:
GSList *lUsers = NULL;
gboolean bReadingAccountsService = FALSE;
GDBusConnection *pAccountsServiceConnection = NULL;
+ gboolean bXsctUnsupported = FALSE;
#endif
};
diff --git a/src/service.h b/src/service.h
index da8d8ba..f134853 100644
--- a/src/service.h
+++ b/src/service.h
@@ -30,7 +30,7 @@ class DisplayIndicator: public Indicator
{
public:
DisplayIndicator();
- ~DisplayIndicator();
+ ~DisplayIndicator() override;
const char* name() const override;
GSimpleActionGroup* action_group() const override;