Commit 12e2e3d1 authored by Guido Gunther's avatar Guido Gunther

shell: Rotate built-in not primary display

When there's no built-in one we fall back to the first monitor.

Closes: #56
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 80c37a72
......@@ -36,7 +36,7 @@ static void
on_transform_changed (PhoshRotateInfo *self)
{
PhoshShell *shell = phosh_shell_get_default ();
PhoshMonitor *monitor = phosh_shell_get_primary_monitor (shell);
PhoshMonitor *monitor = phosh_shell_get_builtin_monitor (shell);
gboolean monitor_is_landscape;
gboolean portrait;
......
......@@ -307,7 +307,7 @@ phosh_shell_get_property (GObject *object,
switch (property_id) {
case PHOSH_SHELL_PROP_TRANSFORM:
g_value_set_enum (value, phosh_monitor_get_transform(priv->primary_monitor));
g_value_set_enum (value, phosh_monitor_get_transform(priv->builtin_monitor));
break;
case PHOSH_SHELL_PROP_LOCKED:
g_value_set_boolean (value, priv->locked);
......@@ -536,7 +536,7 @@ on_builtin_monitor_power_mode_changed (PhoshShell *self, GParamSpec *pspec, Phos
static void
on_primary_monitor_configured (PhoshShell *self,
on_builtin_monitor_configured (PhoshShell *self,
PhoshMonitor *monitor)
{
PhoshShellPrivate *priv;
......@@ -640,14 +640,14 @@ phosh_shell_constructed (GObject *object)
priv->builtin_monitor = g_object_ref (find_builtin_monitor (self));
g_debug ("Builtin monitor is %s, %d", priv->builtin_monitor->name,
phosh_monitor_is_configured (priv->builtin_monitor));
g_signal_connect_swapped (priv->builtin_monitor,
"configured",
G_CALLBACK (on_builtin_monitor_configured),
self);
/* Can't invoke phosh_shell_set_primary_monitor () since the shell
object does not really exist yet but we need the primary monitor
early for the panels */
priv->primary_monitor = g_object_ref (priv->builtin_monitor);
g_signal_connect_swapped (priv->primary_monitor,
"configured",
G_CALLBACK (on_primary_monitor_configured),
self);
g_assert (PHOSH_IS_MONITOR (priv->primary_monitor));
g_assert (PHOSH_IS_MONITOR (priv->builtin_monitor));
......@@ -700,7 +700,7 @@ phosh_shell_class_init (PhoshShellClass *klass)
props[PHOSH_SHELL_PROP_TRANSFORM] =
g_param_spec_enum ("transform",
"Transform",
"Monitor transform of the primary monitor",
"Monitor transform of the builtin monitor",
PHOSH_TYPE_MONITOR_TRANSFORM,
PHOSH_MONITOR_TRANSFORM_NORMAL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
......@@ -752,16 +752,15 @@ phosh_shell_set_transform (PhoshShell *self,
PhoshShellPrivate *priv = phosh_shell_get_instance_private (self);
PhoshMonitorTransform current;
g_return_if_fail (priv->primary_monitor);
current = phosh_monitor_get_transform (priv->primary_monitor);
current = phosh_monitor_get_transform (priv->builtin_monitor);
if (current == transform)
return;
phosh_monitor_manager_set_monitor_transform (priv->monitor_manager,
priv->primary_monitor,
priv->builtin_monitor,
transform);
phosh_monitor_manager_apply_monitor_config (priv->monitor_manager);
/* Notification change signalled in on_primary_monitor_configured */
/* Notification change signalled in on_builtin_monitor_configured */
}
......@@ -770,7 +769,6 @@ phosh_shell_set_primary_monitor (PhoshShell *self, PhoshMonitor *monitor)
{
PhoshShellPrivate *priv;
PhoshMonitor *m = NULL;
PhoshMonitorTransform transform;
g_return_if_fail (monitor);
g_return_if_fail (PHOSH_IS_SHELL (self));
......@@ -786,19 +784,9 @@ phosh_shell_set_primary_monitor (PhoshShell *self, PhoshMonitor *monitor)
}
g_return_if_fail (monitor == m);
if (priv->primary_monitor)
g_signal_handlers_disconnect_by_data (priv->primary_monitor, self);
g_clear_object (&priv->primary_monitor);
priv->primary_monitor = g_object_ref (monitor);
g_debug ("New primary monitor is %s", monitor->name);
g_signal_connect_swapped (priv->primary_monitor,
"configured",
G_CALLBACK (on_primary_monitor_configured),
self);
/* Catch up if old and new primary monitor's rotation are different */
transform = phosh_monitor_get_transform (priv->primary_monitor);
if (transform != priv->transform)
on_primary_monitor_configured (self, priv->primary_monitor);
/* Move panels to the new monitor by recreating the layer shell surfaces */
panels_dispose (self);
......
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