262 lines
9.1 KiB
Diff
262 lines
9.1 KiB
Diff
From 721d073ebbcb2ba973b21f8213af3d4cd7781110 Mon Sep 17 00:00:00 2001
|
|
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
|
|
Date: Tue, 27 Oct 2020 15:07:37 +0100
|
|
Subject: [PATCH 1/5] shell: add an accessor for the mode manager
|
|
|
|
Other modules should be able to query the device type too.
|
|
---
|
|
src/shell.c | 13 +++++++++++++
|
|
src/shell.h | 1 +
|
|
2 files changed, 14 insertions(+)
|
|
|
|
diff --git a/src/shell.c b/src/shell.c
|
|
index 42893d44..f38bdab4 100644
|
|
--- a/src/shell.c
|
|
+++ b/src/shell.c
|
|
@@ -819,6 +819,19 @@ phosh_shell_get_lockscreen_manager (PhoshShell *self)
|
|
}
|
|
|
|
|
|
+PhoshModeManager *
|
|
+phosh_shell_get_mode_manager (PhoshShell *self)
|
|
+{
|
|
+ PhoshShellPrivate *priv;
|
|
+
|
|
+ g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL);
|
|
+ priv = phosh_shell_get_instance_private (self);
|
|
+
|
|
+ g_return_val_if_fail (PHOSH_IS_MODE_MANAGER (priv->mode_manager), NULL);
|
|
+ return priv->mode_manager;
|
|
+}
|
|
+
|
|
+
|
|
PhoshMonitorManager *
|
|
phosh_shell_get_monitor_manager (PhoshShell *self)
|
|
{
|
|
diff --git a/src/shell.h b/src/shell.h
|
|
index 65680a57..541203db 100644
|
|
--- a/src/shell.h
|
|
+++ b/src/shell.h
|
|
@@ -47,6 +47,7 @@ void phosh_shell_set_primary_monitor (PhoshShell *self, PhoshMon
|
|
PhoshMonitor *phosh_shell_get_primary_monitor (PhoshShell *self);
|
|
PhoshMonitor *phosh_shell_get_builtin_monitor (PhoshShell *self);
|
|
PhoshLockscreenManager *phosh_shell_get_lockscreen_manager (PhoshShell *self);
|
|
+PhoshModeManager *phosh_shell_get_mode_manager (PhoshShell *self);
|
|
PhoshMonitorManager *phosh_shell_get_monitor_manager (PhoshShell *self);
|
|
PhoshOskManager *phosh_shell_get_osk_manager (PhoshShell *self);
|
|
PhoshToplevelManager *phosh_shell_get_toplevel_manager (PhoshShell *self);
|
|
--
|
|
2.26.2
|
|
|
|
|
|
From bb69665789137e9ee3391d55cd86ad7f01122790 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
Date: Fri, 13 Nov 2020 18:00:49 +0100
|
|
Subject: [PATCH 2/5] monitor: Add phosh_monitor_get_power_save_mode
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Simple getter
|
|
|
|
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
|
|
---
|
|
src/monitor/monitor.c | 12 ++++++++++++
|
|
src/monitor/monitor.h | 1 +
|
|
2 files changed, 13 insertions(+)
|
|
|
|
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
|
|
index c7199ea8..8379c944 100644
|
|
--- a/src/monitor/monitor.c
|
|
+++ b/src/monitor/monitor.c
|
|
@@ -572,3 +572,15 @@ phosh_monitor_set_power_save_mode (PhoshMonitor *self, PhoshMonitorPowerSaveMode
|
|
|
|
zwlr_output_power_v1_set_mode (self->wlr_output_power, wl_mode);
|
|
}
|
|
+
|
|
+/**
|
|
+ * phosh_monitor_get_power_save_mode:
|
|
+ * @self: A #PhoshMonitor
|
|
+ *
|
|
+ * Returns: The current power save mode
|
|
+ */
|
|
+PhoshMonitorPowerSaveMode
|
|
+phosh_monitor_get_power_save_mode (PhoshMonitor *self)
|
|
+{
|
|
+ return self->power_mode;
|
|
+}
|
|
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
|
|
index 7fbd4570..d7fea9cf 100644
|
|
--- a/src/monitor/monitor.h
|
|
+++ b/src/monitor/monitor.h
|
|
@@ -149,5 +149,6 @@ gboolean phosh_monitor_is_flipped (PhoshMonitor *self);
|
|
guint phosh_monitor_get_transform (PhoshMonitor *self);
|
|
void phosh_monitor_set_power_save_mode (PhoshMonitor *self,
|
|
PhoshMonitorPowerSaveMode mode);
|
|
+PhoshMonitorPowerSaveMode phosh_monitor_get_power_save_mode (PhoshMonitor *self);
|
|
|
|
G_END_DECLS
|
|
--
|
|
2.26.2
|
|
|
|
|
|
From 9f409166802e032b4f37586f88936ef9c8082d1e Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
Date: Fri, 13 Nov 2020 17:01:06 +0100
|
|
Subject: [PATCH 3/5] lockscreen-manager: Handle transform only on power mode
|
|
changes
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
This makes sure we rotate correctly when the screen unblanks and
|
|
we don't operate on disabled outputs which trips up phoc.
|
|
|
|
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
|
|
---
|
|
src/lockscreen-manager.c | 33 +++++++++++++++++++++++++++------
|
|
1 file changed, 27 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
|
|
index 781d131b..81f562cb 100644
|
|
--- a/src/lockscreen-manager.c
|
|
+++ b/src/lockscreen-manager.c
|
|
@@ -72,14 +72,17 @@ lockscreen_unlock_cb (PhoshLockscreenManager *self, PhoshLockscreen *lockscreen)
|
|
{
|
|
PhoshShell *shell = phosh_shell_get_default ();
|
|
PhoshMonitorManager *monitor_manager = phosh_shell_get_monitor_manager (shell);
|
|
-
|
|
- phosh_shell_set_transform (shell, self->transform);
|
|
- self->transform = PHOSH_MONITOR_TRANSFORM_NORMAL;
|
|
+ PhoshMonitor *primary_monitor = phosh_shell_get_primary_monitor (shell);
|
|
|
|
g_return_if_fail (PHOSH_IS_LOCKSCREEN (lockscreen));
|
|
g_return_if_fail (lockscreen == PHOSH_LOCKSCREEN (self->lockscreen));
|
|
|
|
+ /* Fixup transform in case the lockscreen needed to rotate to unlock */
|
|
+ g_debug ("Restoring transform %d", self->transform);
|
|
+ phosh_shell_set_transform (shell, self->transform);
|
|
+
|
|
g_signal_handlers_disconnect_by_data (monitor_manager, self);
|
|
+ g_signal_handlers_disconnect_by_data (primary_monitor, self);
|
|
g_signal_handlers_disconnect_by_data (shell, self);
|
|
g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy);
|
|
|
|
@@ -168,6 +171,23 @@ on_monitor_added (PhoshLockscreenManager *self,
|
|
lock_monitor (self, monitor);
|
|
}
|
|
|
|
+static void
|
|
+on_primary_monitor_power_mode_changed (PhoshLockscreenManager *self,
|
|
+ GParamSpec *pspec,
|
|
+ PhoshMonitor *monitor)
|
|
+{
|
|
+ PhoshShell *shell = phosh_shell_get_default ();
|
|
+
|
|
+ switch (phosh_monitor_get_power_save_mode (monitor)) {
|
|
+ case PHOSH_MONITOR_POWER_SAVE_MODE_ON:
|
|
+ phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
|
|
+ break;
|
|
+ case PHOSH_MONITOR_POWER_SAVE_MODE_OFF:
|
|
+ break;
|
|
+ default:
|
|
+ g_warn_if_reached ();
|
|
+ }
|
|
+}
|
|
|
|
static void
|
|
lock_primary_monitor (PhoshLockscreenManager *self)
|
|
@@ -177,10 +197,7 @@ lock_primary_monitor (PhoshLockscreenManager *self)
|
|
PhoshShell *shell = phosh_shell_get_default ();
|
|
|
|
primary_monitor = phosh_shell_get_primary_monitor (shell);
|
|
-
|
|
- /* Undo any transform on the primary display so the keypad becomes usable */
|
|
self->transform = phosh_shell_get_transform (shell);
|
|
- phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
|
|
|
|
/* The primary output gets the clock, keypad, ... */
|
|
self->lockscreen = PHOSH_LOCKSCREEN (phosh_lockscreen_new (
|
|
@@ -193,6 +210,10 @@ lock_primary_monitor (PhoshLockscreenManager *self)
|
|
"swapped-object-signal::wakeup-output", G_CALLBACK (lockscreen_wakeup_output_cb), self,
|
|
NULL);
|
|
|
|
+ g_signal_connect_swapped (primary_monitor, "notify::power-mode",
|
|
+ G_CALLBACK(on_primary_monitor_power_mode_changed),
|
|
+ self);
|
|
+
|
|
gtk_widget_show (GTK_WIDGET (self->lockscreen));
|
|
/* Old lockscreen gets remove due to `layer_surface_closed` */
|
|
}
|
|
--
|
|
2.26.2
|
|
|
|
|
|
From 6abda174169c3257230cfa5d9253e4ab83985572 Mon Sep 17 00:00:00 2001
|
|
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
|
|
Date: Tue, 27 Oct 2020 15:09:39 +0100
|
|
Subject: [PATCH 4/5] lockscreen-manager: undo transform only for phones
|
|
|
|
If the display is large enough to make the keypad usable even when
|
|
rotated, we should not try to rotate it back to the default orientation.
|
|
---
|
|
src/lockscreen-manager.c | 8 ++++++++
|
|
1 file changed, 8 insertions(+)
|
|
|
|
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
|
|
index 81f562cb..2dbc3111 100644
|
|
--- a/src/lockscreen-manager.c
|
|
+++ b/src/lockscreen-manager.c
|
|
@@ -177,6 +177,14 @@ on_primary_monitor_power_mode_changed (PhoshLockscreenManager *self,
|
|
PhoshMonitor *monitor)
|
|
{
|
|
PhoshShell *shell = phosh_shell_get_default ();
|
|
+ PhoshModeManager *mode_manager = phosh_shell_get_mode_manager(shell);
|
|
+
|
|
+ /*
|
|
+ * Only phones need to switch orientation so that the lock screen fits
|
|
+ * https://source.puri.sm/Librem5/phosh/-/issues/388
|
|
+ */
|
|
+ if (phosh_mode_manager_get_device_type(mode_manager) != PHOSH_MODE_DEVICE_TYPE_PHONE)
|
|
+ return;
|
|
|
|
switch (phosh_monitor_get_power_save_mode (monitor)) {
|
|
case PHOSH_MONITOR_POWER_SAVE_MODE_ON:
|
|
--
|
|
2.26.2
|
|
|
|
|
|
From f2ab3ffd704ad4600ad254116829714029591ba4 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
Date: Sat, 14 Nov 2020 11:32:15 +0100
|
|
Subject: [PATCH 5/5] lockscreen-manager: Don't rotate external screens
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
We keep the transform there as well assuming the lock screen fits.
|
|
|
|
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
|
|
---
|
|
src/lockscreen-manager.c | 4 ++++
|
|
1 file changed, 4 insertions(+)
|
|
|
|
diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c
|
|
index 2dbc3111..c731dae5 100644
|
|
--- a/src/lockscreen-manager.c
|
|
+++ b/src/lockscreen-manager.c
|
|
@@ -186,6 +186,10 @@ on_primary_monitor_power_mode_changed (PhoshLockscreenManager *self,
|
|
if (phosh_mode_manager_get_device_type(mode_manager) != PHOSH_MODE_DEVICE_TYPE_PHONE)
|
|
return;
|
|
|
|
+ /* Don't mess with transforms on external screens either */
|
|
+ if (!phosh_monitor_is_builtin (monitor))
|
|
+ return;
|
|
+
|
|
switch (phosh_monitor_get_power_save_mode (monitor)) {
|
|
case PHOSH_MONITOR_POWER_SAVE_MODE_ON:
|
|
phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
|
|
--
|
|
2.26.2
|
|
|