Commit 8f61e112 authored by Guido Gunther's avatar Guido Gunther Committed by Sebastian Krzyszkowiak

rotation-manager: Update tracked monitor

Update tracked monitor when builtin changes. We do this explicitly
rather than listening to changes on monitor-manager since this way
the rotation-manager doesn't need to be aware that it's tracking
a built-in monitor. It just tracks what's passed in.
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 4fea7ed8
......@@ -67,7 +67,9 @@ apply_transform (PhoshRotationManager *self, PhoshMonitorTransform transform)
PhoshMonitorManager *monitor_manager = phosh_shell_get_monitor_manager (phosh_shell_get_default());
g_return_if_fail (PHOSH_IS_MONITOR_MANAGER (monitor_manager));
g_return_if_fail (PHOSH_IS_MONITOR (self->monitor));
if (!self->monitor)
return;
g_debug ("Rotating %s: %d", self->monitor->name, transform);
......@@ -229,7 +231,9 @@ fixup_lockscreen_orientation (PhoshRotationManager *self, gboolean force)
PhoshModeManager *mode_manager = phosh_shell_get_mode_manager(shell);
g_return_if_fail (PHOSH_IS_MODE_MANAGER (mode_manager));
g_return_if_fail (PHOSH_IS_MONITOR (self->monitor));
if (!self->monitor)
return;
/* Only bother on phones */
if (phosh_mode_manager_get_device_type(mode_manager) != PHOSH_MODE_DEVICE_TYPE_PHONE &&
......@@ -346,8 +350,7 @@ phosh_rotation_manager_set_property (GObject *object,
self->lockscreen_manager = g_value_dup_object (value);
break;
case PROP_MONITOR:
/* construct only */
self->monitor = g_value_dup_object (value);
phosh_rotation_manager_set_monitor (self, g_value_get_object (value));
break;
case PROP_ORIENTATION_LOCKED:
phosh_rotation_manager_set_orientation_locked (self,
......@@ -414,18 +417,6 @@ phosh_rotation_manager_constructed (GObject *object)
self);
on_lockscreen_manager_locked (self, NULL, self->lockscreen_manager);
g_signal_connect_swapped (self->monitor,
"notify::power-mode",
(GCallback) on_power_mode_changed,
self);
on_power_mode_changed (self, NULL, self->monitor);
g_signal_connect_swapped (self->monitor,
"configured",
G_CALLBACK (on_monitor_configured),
self);
on_monitor_configured (self, self->monitor);
if (!self->sensor_proxy_manager) {
g_warning ("Got not sensor-proxy, no automatic rotation");
return;
......@@ -508,7 +499,7 @@ phosh_rotation_manager_class_init (PhoshRotationManagerClass *klass)
"Monitor",
"The monitor to rotate",
PHOSH_TYPE_MONITOR,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
props[PROP_ORIENTATION_LOCKED] =
g_param_spec_boolean (
......@@ -645,8 +636,8 @@ phosh_rotation_manager_set_transform (PhoshRotationManager *self,
PhoshMonitorTransform
phosh_rotation_manager_get_transform (PhoshRotationManager *self)
{
g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (self),
PHOSH_MONITOR_TRANSFORM_NORMAL);
g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (self), PHOSH_MONITOR_TRANSFORM_NORMAL);
g_return_val_if_fail (PHOSH_IS_MONITOR (self->monitor), PHOSH_MONITOR_TRANSFORM_NORMAL);
return self->monitor->transform;
}
......@@ -664,3 +655,39 @@ phosh_rotation_manager_get_monitor (PhoshRotationManager *self)
return self->monitor;
}
void
phosh_rotation_manager_set_monitor (PhoshRotationManager *self, PhoshMonitor *monitor)
{
g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self));
g_return_if_fail (PHOSH_IS_MONITOR (monitor) || monitor == NULL);
g_debug ("Using monitor %p", monitor);
if (self->monitor == monitor)
return;
if (self->monitor) {
g_signal_handlers_disconnect_by_data (self->monitor, self);
g_clear_object (&self->monitor);
}
if (monitor == NULL) {
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MONITOR]);
return;
}
self->monitor = g_object_ref (monitor);
g_signal_connect_swapped (self->monitor,
"notify::power-mode",
G_CALLBACK (on_power_mode_changed),
self);
on_power_mode_changed (self, NULL, self->monitor);
g_signal_connect_swapped (self->monitor,
"configured",
G_CALLBACK (on_monitor_configured),
self);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MONITOR]);
}
......@@ -41,5 +41,7 @@ void phosh_rotation_manager_set_transform (PhoshRotationMana
PhoshMonitorTransform tranform);
PhoshMonitorTransform phosh_rotation_manager_get_transform (PhoshRotationManager *self);
PhoshMonitor *phosh_rotation_manager_get_monitor (PhoshRotationManager *self);
void phosh_rotation_manager_set_monitor (PhoshRotationManager *self,
PhoshMonitor *monitor);
G_END_DECLS
......@@ -583,6 +583,9 @@ on_monitor_added (PhoshShell *self, PhoshMonitor *monitor)
self);
g_debug ("Updating builtin monitor to %s", monitor->name);
if (priv->rotation_manager)
phosh_rotation_manager_set_monitor (priv->rotation_manager, monitor);
g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_SHELL_PROP_BUILTIN_MONITOR]);
}
......@@ -605,6 +608,9 @@ on_monitor_removed (PhoshShell *self, PhoshMonitor *monitor)
g_clear_object (&priv->builtin_monitor);
}
if (priv->rotation_manager)
phosh_rotation_manager_set_monitor (priv->rotation_manager, NULL);
g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_SHELL_PROP_BUILTIN_MONITOR]);
}
......
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