color-manager: Add API to set brightness
It uses the org.gnome.SettingsDaemon.Power.Screen D-Bus API. Currently brightness set if the proxy is not ready are ignored; whether the brightness value should be cached and set once it appears or whether color profiles should be reapplied is yet to be decided. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
This commit is contained in:
parent
7b71ec8ff0
commit
b3fa4a6cd8
@ -0,0 +1,5 @@
|
|||||||
|
<node>
|
||||||
|
<interface name="org.gnome.SettingsDaemon.Power.Screen">
|
||||||
|
<property name="Brightness" type="i" access="readwrite"/>
|
||||||
|
</interface>
|
||||||
|
</node>
|
@ -53,6 +53,7 @@
|
|||||||
#include "backends/meta-monitor.h"
|
#include "backends/meta-monitor.h"
|
||||||
|
|
||||||
#include "meta-dbus-gsd-color.h"
|
#include "meta-dbus-gsd-color.h"
|
||||||
|
#include "meta-dbus-gsd-power-screen.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -79,6 +80,7 @@ typedef struct _MetaColorManagerPrivate
|
|||||||
GHashTable *devices;
|
GHashTable *devices;
|
||||||
|
|
||||||
MetaDbusSettingsDaemonColor *gsd_color;
|
MetaDbusSettingsDaemonColor *gsd_color;
|
||||||
|
MetaDbusSettingsDaemonPowerScreen *gsd_power_screen;
|
||||||
|
|
||||||
gboolean is_ready;
|
gboolean is_ready;
|
||||||
} MetaColorManagerPrivate;
|
} MetaColorManagerPrivate;
|
||||||
@ -243,6 +245,34 @@ on_gsd_color_ready (GObject *source_object,
|
|||||||
priv->gsd_color = gsd_color;
|
priv->gsd_color = gsd_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_gsd_power_screen_ready (GObject *source_object,
|
||||||
|
GAsyncResult *res,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MetaColorManager *color_manager = META_COLOR_MANAGER (user_data);
|
||||||
|
MetaColorManagerPrivate *priv =
|
||||||
|
meta_color_manager_get_instance_private (color_manager);
|
||||||
|
MetaDbusSettingsDaemonPowerScreen *gsd_power_screen;
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
|
gsd_power_screen =
|
||||||
|
meta_dbus_settings_daemon_power_screen_proxy_new_for_bus_finish (res,
|
||||||
|
&error);
|
||||||
|
if (!gsd_power_screen)
|
||||||
|
{
|
||||||
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_warning ("Failed to create gsd-power-screen D-Bus proxy: %s", error->message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_COLOR,
|
||||||
|
"Connection to org.gnome.SettingsDaemon.PowerScreen established");
|
||||||
|
priv->gsd_power_screen = gsd_power_screen;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_color_manager_constructed (GObject *object)
|
meta_color_manager_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
@ -266,6 +296,15 @@ meta_color_manager_constructed (GObject *object)
|
|||||||
priv->cancellable,
|
priv->cancellable,
|
||||||
on_gsd_color_ready,
|
on_gsd_color_ready,
|
||||||
color_manager);
|
color_manager);
|
||||||
|
|
||||||
|
meta_dbus_settings_daemon_power_screen_proxy_new_for_bus (
|
||||||
|
G_BUS_TYPE_SESSION,
|
||||||
|
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||||
|
"org.gnome.SettingsDaemon.Power.Screen",
|
||||||
|
"/org/gnome/SettingsDaemon/Power",
|
||||||
|
priv->cancellable,
|
||||||
|
on_gsd_power_screen_ready,
|
||||||
|
color_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -278,6 +317,7 @@ meta_color_manager_finalize (GObject *object)
|
|||||||
g_cancellable_cancel (priv->cancellable);
|
g_cancellable_cancel (priv->cancellable);
|
||||||
g_clear_object (&priv->cancellable);
|
g_clear_object (&priv->cancellable);
|
||||||
g_clear_pointer (&priv->devices, g_hash_table_unref);
|
g_clear_pointer (&priv->devices, g_hash_table_unref);
|
||||||
|
g_clear_object (&priv->gsd_power_screen);
|
||||||
g_clear_object (&priv->gsd_color);
|
g_clear_object (&priv->gsd_color);
|
||||||
g_clear_object (&priv->color_store);
|
g_clear_object (&priv->color_store);
|
||||||
g_clear_pointer (&priv->lcms_context, cmsDeleteContext);
|
g_clear_pointer (&priv->lcms_context, cmsDeleteContext);
|
||||||
@ -418,3 +458,22 @@ meta_color_manager_get_lcms_context (MetaColorManager *color_manager)
|
|||||||
|
|
||||||
return priv->lcms_context;
|
return priv->lcms_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_color_manager_set_brightness (MetaColorManager *color_manager,
|
||||||
|
int brightness)
|
||||||
|
{
|
||||||
|
MetaColorManagerPrivate *priv =
|
||||||
|
meta_color_manager_get_instance_private (color_manager);
|
||||||
|
|
||||||
|
if (!priv->gsd_power_screen)
|
||||||
|
{
|
||||||
|
meta_topic (META_DEBUG_COLOR,
|
||||||
|
"No org.gnome.SettingsDaemon.Power.Screen service available, "
|
||||||
|
"not setting brightness");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_dbus_settings_daemon_power_screen_set_brightness (priv->gsd_power_screen,
|
||||||
|
brightness);
|
||||||
|
}
|
||||||
|
@ -35,4 +35,7 @@ META_EXPORT_TEST
|
|||||||
MetaColorDevice * meta_color_manager_get_color_device (MetaColorManager *color_manager,
|
MetaColorDevice * meta_color_manager_get_color_device (MetaColorManager *color_manager,
|
||||||
MetaMonitor *monitor);
|
MetaMonitor *monitor);
|
||||||
|
|
||||||
|
void meta_color_manager_set_brightness (MetaColorManager *color_manager,
|
||||||
|
int brightness);
|
||||||
|
|
||||||
#endif /* META_COLOR_MANAGER_H */
|
#endif /* META_COLOR_MANAGER_H */
|
||||||
|
@ -930,6 +930,13 @@ dbus_gsd_color_built_sources = gnome.gdbus_codegen('meta-dbus-gsd-color',
|
|||||||
)
|
)
|
||||||
mutter_built_sources += dbus_gsd_color_built_sources
|
mutter_built_sources += dbus_gsd_color_built_sources
|
||||||
|
|
||||||
|
dbus_gsd_power_screen_built_sources = gnome.gdbus_codegen('meta-dbus-gsd-power-screen',
|
||||||
|
join_paths(dbus_interfaces_dir, 'org.gnome.SettingsDaemon.Power.Screen.xml'),
|
||||||
|
interface_prefix: 'org.gnome.',
|
||||||
|
namespace: 'MetaDbus',
|
||||||
|
)
|
||||||
|
mutter_built_sources += dbus_gsd_power_screen_built_sources
|
||||||
|
|
||||||
wayland_protocol_server_headers = []
|
wayland_protocol_server_headers = []
|
||||||
wayland_protocol_client_headers = []
|
wayland_protocol_client_headers = []
|
||||||
wayland_protocol_sources = []
|
wayland_protocol_sources = []
|
||||||
|
Loading…
Reference in New Issue
Block a user