Commit 2355bc52 authored by Guido Gunther's avatar Guido Gunther Committed by Sebastian Krzyszkowiak
Browse files

rotateinfo: Use monitor from rotation-manager consistently



So far this was dependent on mode and incorrectly tracked the primary
monitor for manual toggle.
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 7187a857
......@@ -35,8 +35,7 @@ G_DEFINE_TYPE (PhoshRotateInfo, phosh_rotate_info, PHOSH_TYPE_STATUS_ICON)
static void
on_transform_changed (PhoshRotateInfo *self)
{
PhoshShell *shell = phosh_shell_get_default ();
PhoshMonitor *monitor = phosh_shell_get_primary_monitor (shell);
PhoshMonitor *monitor;
gboolean monitor_is_landscape;
gboolean portrait;
......@@ -44,7 +43,7 @@ on_transform_changed (PhoshRotateInfo *self)
return;
}
switch (phosh_shell_get_transform (shell)) {
switch (phosh_rotation_manager_get_transform (self->manager)) {
case PHOSH_MONITOR_TRANSFORM_NORMAL:
case PHOSH_MONITOR_TRANSFORM_FLIPPED:
case PHOSH_MONITOR_TRANSFORM_180:
......@@ -63,6 +62,7 @@ on_transform_changed (PhoshRotateInfo *self)
}
/* If we have a landscape monitor (tv, laptop) flip the rotation */
monitor = phosh_rotation_manager_get_monitor (self->manager);
monitor_is_landscape = ((double)monitor->width / (double)monitor->height) > 1.0;
portrait = monitor_is_landscape ? !portrait : portrait;
......@@ -128,7 +128,7 @@ phosh_rotate_info_init (PhoshRotateInfo *self)
self->manager = phosh_shell_get_rotation_manager (phosh_shell_get_default());
/* We don't use property bindings since we flip info/icon based on rotation and lock */
g_signal_connect_object (phosh_shell_get_default (),
g_signal_connect_object (self->manager,
"notify::transform",
G_CALLBACK (on_transform_changed),
self,
......
......@@ -36,6 +36,7 @@ enum {
PROP_ORIENTATION_LOCKED,
PROP_MONITOR,
PROP_MODE,
PROP_TRANSFORM,
LAST_PROP,
};
static GParamSpec *props[LAST_PROP];
......@@ -47,6 +48,7 @@ typedef struct _PhoshRotationManager {
PhoshSensorProxyManager *sensor_proxy_manager;
PhoshLockscreenManager *lockscreen_manager;
PhoshMonitor *monitor;
PhoshMonitorTransform transform;
PhoshMonitorTransform prelock_transform;
GSettings *settings;
......@@ -302,6 +304,26 @@ on_accelerometer_orientation_changed (PhoshRotationManager *self,
match_orientation (self);
}
static void
on_monitor_configured (PhoshRotationManager *self,
PhoshMonitor *monitor)
{
PhoshMonitorTransform transform;
g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self));
g_return_if_fail (PHOSH_IS_MONITOR (monitor));
transform = phosh_monitor_get_transform (monitor);
if (transform == self->transform)
return;
self->transform = transform;
g_debug ("Rotation-manager transform %d", transform);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_TRANSFORM]);
}
static void
phosh_rotation_manager_set_property (GObject *object,
guint property_id,
......@@ -357,6 +379,9 @@ phosh_rotation_manager_get_property (GObject *object,
case PROP_MODE:
g_value_set_enum (value, self->mode);
break;
case PROP_TRANSFORM:
g_value_set_enum (value, self->transform);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -391,6 +416,11 @@ phosh_rotation_manager_constructed (GObject *object)
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");
......@@ -493,6 +523,14 @@ phosh_rotation_manager_class_init (PhoshRotationManagerClass *klass)
PHOSH_ROTATION_MANAGER_MODE_OFF,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
props[PROP_TRANSFORM] =
g_param_spec_enum ("transform",
"Transform",
"Monitor transform of the rotation monitor",
PHOSH_TYPE_MONITOR_TRANSFORM,
PHOSH_MONITOR_TRANSFORM_NORMAL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, props);
}
......
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