Commit b42be119 authored by Guido Gunther's avatar Guido Gunther

rotation-manager: Use power save mode of builtin display

This allows the lockscreen to ratate
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent a932fbac
Pipeline #63448 passed with stages
in 46 minutes and 26 seconds
......@@ -22,16 +22,15 @@
* @Title: PhoshRotationManager
*
* #PhoshRotationManager is responsible for interfacing with
* #PhoshSensorProxyManager to set the correct orientation of thex
* #built-in display taking the #PhoshLockscreenManager's
* #PhoshLockscreenManager:locked status and the orientation-lock
* #PhoshSensorProxyManager to set the correct orientation of the
* #built-in display taking the displays power mode aand the orientation-lock
* #GSettings and the current #PhoshRotationManagerMode into account.
*/
enum {
PROP_0,
PROP_SENSOR_PROXY_MANAGER,
PROP_LOCKSCREEN_MANAGER,
PROP_BUILTIN_MONITOR,
PROP_ORIENTATION_LOCKED,
PROP_MODE,
LAST_PROP,
......@@ -43,7 +42,7 @@ typedef struct _PhoshRotationManager {
gboolean claimed;
PhoshSensorProxyManager *sensor_proxy_manager;
PhoshLockscreenManager *lockscreen_manager;
PhoshMonitor *builtin_monitor;
GSettings *settings;
gboolean orientation_locked;
......@@ -136,10 +135,10 @@ on_accelerometer_released (PhoshSensorProxyManager *sensor_proxy_manager,
PHOSH_DBUS_SENSOR_PROXY (sensor_proxy_manager),
res, &err);
if (success) {
g_debug ("Released rotation sensor");
g_debug ("Released accelerometer");
self->claimed = FALSE;
} else {
g_warning ("Failed to release rotation sensor: %s", err->message);
g_warning ("Failed to release accelerometer: %s", err->message);
}
g_object_unref (self);
}
......@@ -172,8 +171,8 @@ on_has_accelerometer_changed (PhoshRotationManager *self,
{
gboolean has_accel;
/* Don't claim during screen lock, enables runtime pm */
if (phosh_lockscreen_manager_get_locked (self->lockscreen_manager))
/* Don't claim during blank, enables runtime pm */
if (phosh_monitor_get_power_save_mode (self->builtin_monitor) == PHOSH_MONITOR_POWER_SAVE_MODE_OFF)
return;
has_accel = phosh_dbus_sensor_proxy_get_has_accelerometer (
......@@ -184,19 +183,25 @@ on_has_accelerometer_changed (PhoshRotationManager *self,
}
static void
on_lockscreen_manager_locked (PhoshRotationManager *self, GParamSpec *pspec,
PhoshLockscreenManager *lockscreen_manager)
on_power_mode_changed (PhoshRotationManager *self, GParamSpec *pspec,
PhoshMonitor *monitor)
{
gboolean claim;
PhoshMonitorPowerSaveMode mode;
g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self));
g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (lockscreen_manager));
g_return_if_fail (PHOSH_IS_MONITOR (monitor));
if (self->mode == PHOSH_ROTATION_MANAGER_MODE_OFF)
mode = phosh_monitor_get_power_save_mode (monitor);
if (self->mode == PHOSH_ROTATION_MANAGER_MODE_OFF ||
mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF) {
claim = FALSE;
else
claim = !phosh_lockscreen_manager_get_locked (self->lockscreen_manager);
} else {
claim = TRUE;
}
g_debug ("Power mode changed, %sclaiming", claim ? "" : "un");
phosh_rotation_manager_claim_accelerometer (self, claim);
}
......@@ -224,9 +229,9 @@ phosh_rotation_manager_set_property (GObject *object,
/* construct only */
self->sensor_proxy_manager = g_value_dup_object (value);
break;
case PROP_LOCKSCREEN_MANAGER:
case PROP_BUILTIN_MONITOR:
/* construct only */
self->lockscreen_manager = g_value_dup_object (value);
self->builtin_monitor = g_value_dup_object (value);
break;
case PROP_ORIENTATION_LOCKED:
phosh_rotation_manager_set_orientation_locked (self,
......@@ -253,8 +258,8 @@ phosh_rotation_manager_get_property (GObject *object,
case PROP_SENSOR_PROXY_MANAGER:
g_value_set_object (value, self->sensor_proxy_manager);
break;
case PROP_LOCKSCREEN_MANAGER:
g_value_set_object (value, self->lockscreen_manager);
case PROP_BUILTIN_MONITOR:
g_value_set_object (value, self->builtin_monitor);
break;
case PROP_ORIENTATION_LOCKED:
g_value_set_boolean (value, self->orientation_locked);
......@@ -279,9 +284,9 @@ phosh_rotation_manager_constructed (GObject *object)
if (!self->sensor_proxy_manager)
return;
g_signal_connect_swapped (self->lockscreen_manager,
"notify::locked",
(GCallback) on_lockscreen_manager_locked,
g_signal_connect_swapped (self->builtin_monitor,
"notify::power-mode",
(GCallback) on_power_mode_changed,
self);
g_signal_connect_swapped (self->sensor_proxy_manager,
......@@ -322,10 +327,10 @@ phosh_rotation_manager_dispose (GObject *object)
g_clear_object (&self->sensor_proxy_manager);
}
if (self->lockscreen_manager) {
g_signal_handlers_disconnect_by_data (self->lockscreen_manager,
if (self->builtin_monitor) {
g_signal_handlers_disconnect_by_data (self->builtin_monitor,
self);
g_clear_object (&self->lockscreen_manager);
g_clear_object (&self->builtin_monitor);
}
G_OBJECT_CLASS (phosh_rotation_manager_parent_class)->dispose (object);
......@@ -350,12 +355,12 @@ phosh_rotation_manager_class_init (PhoshRotationManagerClass *klass)
PHOSH_TYPE_SENSOR_PROXY_MANAGER,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
props[PROP_LOCKSCREEN_MANAGER] =
props[PROP_BUILTIN_MONITOR] =
g_param_spec_object (
"lockscreen-manager",
"Lockscren manager",
"The object managing the lock screen",
PHOSH_TYPE_LOCKSCREEN_MANAGER,
"builtin-monitor",
"Builtin monitor",
"The builtn monitor",
PHOSH_TYPE_MONITOR,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
props[PROP_ORIENTATION_LOCKED] =
......@@ -386,11 +391,11 @@ phosh_rotation_manager_init (PhoshRotationManager *self)
PhoshRotationManager *
phosh_rotation_manager_new (PhoshSensorProxyManager *sensor_proxy_manager,
PhoshLockscreenManager *lockscreen_manager)
PhoshMonitor *builtin_monitor)
{
return g_object_new (PHOSH_TYPE_ROTATION_MANAGER,
"sensor-proxy-manager", sensor_proxy_manager,
"lockscreen-manager", lockscreen_manager,
"builtin-monitor", builtin_monitor,
NULL);
}
......
......@@ -5,8 +5,8 @@
*/
#pragma once
#include "lockscreen-manager.h"
#include "sensor-proxy-manager.h"
#include "monitor/monitor.h"
G_BEGIN_DECLS
......@@ -27,7 +27,7 @@ typedef enum {
G_DECLARE_FINAL_TYPE (PhoshRotationManager, phosh_rotation_manager, PHOSH, ROTATION_MANAGER, GObject);
PhoshRotationManager *phosh_rotation_manager_new (PhoshSensorProxyManager *sensor_proxy_manager,
PhoshLockscreenManager *lockscreen_manager);
PhoshMonitor *builtin_monitor);
void phosh_rotation_manager_set_orientation_locked (PhoshRotationManager *self,
gboolean locked);
gboolean phosh_rotation_manager_get_orientation_locked (PhoshRotationManager *self);
......
......@@ -1018,7 +1018,7 @@ phosh_shell_get_rotation_manager (PhoshShell *self)
if (!priv->rotation_manager)
priv->rotation_manager = phosh_rotation_manager_new (priv->sensor_proxy_manager,
priv->lockscreen_manager);
priv->builtin_monitor);
g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (priv->rotation_manager), NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment