diff --git a/gui-wm/phosh/files/0001-Revert-home-Bind-key-to-show-overview.patch b/gui-wm/phosh/files/0001-Revert-home-Bind-key-to-show-overview.patch new file mode 100644 index 0000000..9ab7b86 --- /dev/null +++ b/gui-wm/phosh/files/0001-Revert-home-Bind-key-to-show-overview.patch @@ -0,0 +1,174 @@ +From 3a1f2f4fd7448ce1093bc08b1167ece63121371c Mon Sep 17 00:00:00 2001 +From: Danct12 +Date: Thu, 29 Oct 2020 16:00:28 +0700 +Subject: [PATCH] Revert "home: Bind key to show overview" + +This reverts commit f70af466ff57763bc94548e3086a3caa50c8eacc. +--- + src/home.c | 108 ----------------------------------------------------- + 1 file changed, 108 deletions(-) + +diff --git a/src/home.c b/src/home.c +index b8fc99e..9b3b722 100644 +--- a/src/home.c ++++ b/src/home.c +@@ -18,10 +18,6 @@ + + #include + +-#define KEYBINDINGS_SCHEMA_ID "org.gnome.shell.keybindings" +-#define KEYBINDING_KEY_TOGGLE_OVERVIEW "toggle-overview" +-#define KEYBINDING_KEY_TOGGLE_APPLICATION_VIEW "toggle-application-view" +- + /** + * SECTION:home + * @short_description: The home surface contains the overview and +@@ -65,10 +61,6 @@ struct _PhoshHome + + PhoshHomeState state; + +- /* Keybinding */ +- GArray *actions; +- GSettings *settings; +- + /* osk button */ + gboolean osk_enabled; + }; +@@ -207,77 +199,6 @@ key_press_event_cb (PhoshHome *self, GdkEventKey *event, gpointer data) + } + + +-static void +-toggle_overview_action (GSimpleAction *action, GVariant *param, gpointer data) +-{ +- PhoshHome *self = PHOSH_HOME (data); +- PhoshHomeState state; +- +- g_return_if_fail (PHOSH_IS_HOME (self)); +- +- state = self->state == PHOSH_HOME_STATE_UNFOLDED ? +- PHOSH_HOME_STATE_FOLDED : PHOSH_HOME_STATE_UNFOLDED; +- phosh_home_set_state (self, state); +-} +- +- +-static void +-toggle_application_view_action (GSimpleAction *action, GVariant *param, gpointer data) +-{ +- PhoshHome *self = PHOSH_HOME (data); +- PhoshHomeState state; +- +- g_return_if_fail (PHOSH_IS_HOME (self)); +- +- state = self->state == PHOSH_HOME_STATE_UNFOLDED ? +- PHOSH_HOME_STATE_FOLDED : PHOSH_HOME_STATE_UNFOLDED; +- phosh_home_set_state (self, state); +- phosh_overview_focus_app_search (PHOSH_OVERVIEW (self->overview)); +-} +- +- +-static void +-add_keybindings (PhoshHome *self) +-{ +- g_auto (GStrv) bindings = NULL; +- g_autoptr (GSettings) settings = g_settings_new (KEYBINDINGS_SCHEMA_ID); +- +- bindings = g_settings_get_strv (settings, KEYBINDING_KEY_TOGGLE_OVERVIEW); +- for (int i = 0; i < g_strv_length (bindings); i++) { +- GActionEntry entry = { bindings[i], +- toggle_overview_action, }; +- g_array_append_val (self->actions, entry); +- } +- +- bindings = g_settings_get_strv (settings, KEYBINDING_KEY_TOGGLE_APPLICATION_VIEW); +- for (int i = 0; i < g_strv_length (bindings); i++) { +- GActionEntry entry = { bindings[i], +- toggle_application_view_action, }; +- g_array_append_val (self->actions, entry); +- } +- +- phosh_shell_add_global_keyboard_action_entries (phosh_shell_get_default (), +- (GActionEntry*)self->actions->data, +- self->actions->len, +- self); +-} +- +- +-static void +-on_keybindings_changed (PhoshHome *self, +- gchar *key, +- GSettings *settings) +-{ +- /* For now just redo all keybindings */ +- g_debug ("Updating keybindings"); +- phosh_shell_remove_global_keyboard_action_entries (phosh_shell_get_default (), +- (GActionEntry*)self->actions->data, +- self->actions->len); +- g_array_set_size (self->actions, 0); +- add_keybindings (self); +-} +- +- + static gboolean + on_idle (PhoshOskButton *self) + { +@@ -332,14 +253,6 @@ phosh_home_constructed (GObject *object) + G_CALLBACK (key_press_event_cb), + NULL); + +- g_object_connect (self->settings, +- "swapped-signal::changed::" KEYBINDING_KEY_TOGGLE_OVERVIEW, +- on_keybindings_changed, self, +- "swapped-signal::changed::" KEYBINDING_KEY_TOGGLE_APPLICATION_VIEW, +- on_keybindings_changed, self, +- NULL); +- add_keybindings (self); +- + phosh_connect_feedback (self->btn_home); + + g_idle_add ((GSourceFunc) on_idle, self); +@@ -348,24 +261,6 @@ phosh_home_constructed (GObject *object) + } + + +-static void +-phosh_home_dispose (GObject *object) +-{ +- PhoshHome *self = PHOSH_HOME (object); +- +- g_clear_object (&self->settings); +- +- if (self->actions) { +- phosh_shell_remove_global_keyboard_action_entries (phosh_shell_get_default (), +- (GActionEntry*)self->actions->data, +- self->actions->len); +- g_clear_pointer (&self->actions, g_array_unref); +- } +- +- G_OBJECT_CLASS (phosh_home_parent_class)->dispose (object); +-} +- +- + static void + phosh_home_class_init (PhoshHomeClass *klass) + { +@@ -373,7 +268,6 @@ phosh_home_class_init (PhoshHomeClass *klass) + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->constructed = phosh_home_constructed; +- object_class->dispose = phosh_home_dispose; + + object_class->set_property = phosh_home_set_property; + object_class->get_property = phosh_home_get_property; +@@ -419,8 +313,6 @@ phosh_home_init (PhoshHome *self) + { + self->state = PHOSH_HOME_STATE_FOLDED; + self->animation.progress = 1.0; +- self->actions = g_array_new (FALSE, TRUE, sizeof (GActionEntry)); +- self->settings = g_settings_new (KEYBINDINGS_SCHEMA_ID); + + gtk_widget_init_template (GTK_WIDGET (self)); + } +-- +2.29.2 + diff --git a/gui-wm/phosh/files/0001-system-prompt-allow-blank-passwords.patch b/gui-wm/phosh/files/0001-system-prompt-allow-blank-passwords.patch new file mode 100644 index 0000000..e10824d --- /dev/null +++ b/gui-wm/phosh/files/0001-system-prompt-allow-blank-passwords.patch @@ -0,0 +1,49 @@ +From e88f5dee0cbb7fa0851b43a5ded5d94256c756d2 Mon Sep 17 00:00:00 2001 +From: Arnaud Ferraris +Date: Sat, 21 Mar 2020 03:00:34 +0100 +Subject: [PATCH] system-prompt: allow blank passwords + +--- + src/system-prompt.c | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/src/system-prompt.c b/src/system-prompt.c +index 30aa3f1..bd06ee0 100644 +--- a/src/system-prompt.c ++++ b/src/system-prompt.c +@@ -256,8 +256,6 @@ phosh_system_prompt_password_async (GcrPrompt *prompt, + priv->task = g_task_new (self, NULL, callback, user_data); + g_task_set_source_tag (priv->task, phosh_system_prompt_password_async); + +- if (!gtk_entry_get_text_length (GTK_ENTRY (priv->entry_password))) +- gtk_widget_set_sensitive (priv->btn_continue, FALSE); + gtk_widget_set_sensitive (priv->grid, TRUE); + + obj = G_OBJECT (self); +@@ -315,7 +313,6 @@ phosh_system_prompt_confirm_async (GcrPrompt *prompt, + priv->task = g_task_new (self, NULL, callback, user_data); + g_task_set_source_tag (priv->task, phosh_system_prompt_confirm_async); + +- gtk_widget_set_sensitive (priv->btn_continue, TRUE); + gtk_widget_set_sensitive (priv->grid, TRUE); + + obj = G_OBJECT (self); +@@ -392,7 +389,6 @@ prompt_complete (PhoshSystemPrompt *self) + g_task_return_pointer (res, (gpointer)password, NULL); + g_object_unref (res); + +- gtk_widget_set_sensitive (priv->btn_continue, FALSE); + gtk_widget_set_sensitive (priv->grid, FALSE); + + return TRUE; +@@ -451,7 +447,6 @@ on_password_changed (PhoshSystemPrompt *self, + if (!gtk_entry_get_text_length (GTK_ENTRY (editable))) + return; + +- gtk_widget_set_sensitive (priv->btn_continue, TRUE); + password = gtk_entry_get_text (GTK_ENTRY (editable)); + + /* +-- +2.24.1 + diff --git a/gui-wm/phosh/files/0002-fade-for-5s-first.patch b/gui-wm/phosh/files/0002-fade-for-5s-first.patch new file mode 100644 index 0000000..76cef94 --- /dev/null +++ b/gui-wm/phosh/files/0002-fade-for-5s-first.patch @@ -0,0 +1,32 @@ +diff --git a/src/proximity.c b/src/proximity.c +index 0beca69..8e93b21 100644 +--- a/src/proximity.c ++++ b/src/proximity.c +@@ -148,8 +155,9 @@ on_proximity_near_changed (PhoshProximity *self, + PhoshSensorProxyManager *sensor) + { + gboolean near; +- int ps_mode; ++ int ps_mode; + PhoshShell *shell = phosh_shell_get_default (); ++ PhoshWayland *wl = phosh_wayland_get_default (); + PhoshMonitor *monitor = phosh_shell_get_builtin_monitor (shell); + + near = phosh_dbus_sensor_proxy_get_proximity_near ( +@@ -157,8 +165,15 @@ on_proximity_near_changed (PhoshProximity *self, + + g_debug ("Proximity near changed: %d", near); + if (near) { +- ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_OFF; ++ if (!self->fader) { ++ self->fader = phosh_fader_new (phosh_wayland_get_zwlr_layer_shell_v1 (wl), ++ monitor->wl_output); ++ gtk_widget_show (GTK_WIDGET (self->fader)); ++ } ++ g_timeout_add_seconds (5, continue, self); ++ ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_OFF; + } else { ++ g_clear_pointer (&self->fader, phosh_cp_widget_destroy); + ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_ON; + } + phosh_monitor_set_power_save_mode (monitor, ps_mode); diff --git a/gui-wm/phosh/files/0002-fix-locale-issue.patch b/gui-wm/phosh/files/0002-fix-locale-issue.patch new file mode 100644 index 0000000..9d2d3a0 --- /dev/null +++ b/gui-wm/phosh/files/0002-fix-locale-issue.patch @@ -0,0 +1,14 @@ +diff -Npur a/data/phosh.in b/data/phosh.in +--- a/data/phosh.in 2021-03-20 13:53:32.367786000 +0100 ++++ b/data/phosh.in 2021-03-20 13:55:19.327789721 +0100 +@@ -56,6 +56,10 @@ elif [ -f /etc/phosh/rootston.ini ]; th + PHOC_INI=/etc/phosh/rootston.ini + fi + ++# Set proper locale according to /etc/locale.conf ++source /etc/locale.conf ++export LANG=$LANG ++ + # Run gnome-session through a login shell so it picks + # variables from /etc/profile.d (XDG_*) + [ -n "$WLR_BACKENDS" ] || WLR_BACKENDS=drm,libinput diff --git a/gui-wm/phosh/files/0002-only-lock-when-not-near.patch b/gui-wm/phosh/files/0002-only-lock-when-not-near.patch new file mode 100644 index 0000000..3bbe690 --- /dev/null +++ b/gui-wm/phosh/files/0002-only-lock-when-not-near.patch @@ -0,0 +1,26 @@ +diff --git a/src/shell.c b/src/shell.c +index 324b261..4a66866 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -535,15 +535,18 @@ static void + on_builtin_monitor_power_mode_changed (PhoshShell *self, GParamSpec *pspec, PhoshMonitor *monitor) + { + PhoshMonitorPowerSaveMode mode; ++ PhoshSensorProxyManager *sensor_proxy_manager; ++ gboolean near; ++ ++ near = phosh_dbus_sensor_proxy_get_proximity_near ( ++ PHOSH_DBUS_SENSOR_PROXY (sensor_proxy_manager)); + + g_return_if_fail (PHOSH_IS_SHELL (self)); + g_return_if_fail (PHOSH_IS_MONITOR (monitor)); + + g_object_get (monitor, "power-mode", &mode, NULL); +-#if 0 +- if (mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF) ++ if (!near && mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF) + phosh_shell_lock (self); +-#endif + + phosh_shell_set_state (self, PHOSH_STATE_BLANKED, mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF); + } diff --git a/gui-wm/phosh/files/0002-shell-honor-configured-rotation.patch b/gui-wm/phosh/files/0002-shell-honor-configured-rotation.patch new file mode 100644 index 0000000..5bf1649 --- /dev/null +++ b/gui-wm/phosh/files/0002-shell-honor-configured-rotation.patch @@ -0,0 +1,30 @@ +From a85bf76c9c19a8f54657b7973a4b1ec50176f395 Mon Sep 17 00:00:00 2001 +From: Arnaud Ferraris +Date: Fri, 23 Oct 2020 13:40:44 +0200 +Subject: [PATCH 44/47] shell: honor configured rotation + +Resetting the default transform causes the user-configured rotation to +be ignored. In cases where the transform needs to be reset, this is +already done in lockscreen manager. +--- + src/shell.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/src/shell.c b/src/shell.c +index 42893d4..19a41fb 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -484,10 +484,6 @@ setup_idle_cb (PhoshShell *self) + + phosh_session_register (PHOSH_APP_ID); + +- /* If we start rotated, fix this up */ +- if (phosh_shell_get_transform (self) != PHOSH_MONITOR_TRANSFORM_NORMAL) +- phosh_shell_set_transform (self, PHOSH_MONITOR_TRANSFORM_NORMAL); +- + priv->startup_finished = TRUE; + + return FALSE; +-- +2.28.0 + diff --git a/gui-wm/phosh/files/0002-turn-off-monitor-on-proximity.patch b/gui-wm/phosh/files/0002-turn-off-monitor-on-proximity.patch new file mode 100644 index 0000000..4933bb5 --- /dev/null +++ b/gui-wm/phosh/files/0002-turn-off-monitor-on-proximity.patch @@ -0,0 +1,57 @@ +--- a/src/proximity.c 2021-03-04 10:51:32.765179000 +0100 ++++ b/src/proximity.c 2021-03-04 12:01:32.618475761 +0100 +@@ -148,24 +148,24 @@ on_proximity_near_changed (PhoshProximit + PhoshSensorProxyManager *sensor) + { + gboolean near; ++ int ps_mode; ++ PhoshShell *shell = phosh_shell_get_default (); ++ PhoshMonitor *monitor = phosh_shell_get_builtin_monitor (shell); + + near = phosh_dbus_sensor_proxy_get_proximity_near ( + PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager)); + + g_debug ("Proximity near changed: %d", near); ++ + if (near) { +- PhoshShell *shell = phosh_shell_get_default (); +- PhoshWayland *wl = phosh_wayland_get_default (); +- PhoshMonitor *monitor = phosh_shell_get_builtin_monitor (shell); +- +- if (!self->fader) { +- self->fader = phosh_fader_new (phosh_wayland_get_zwlr_layer_shell_v1 (wl), +- monitor->wl_output); +- gtk_widget_show (GTK_WIDGET (self->fader)); +- } ++ ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_OFF; ++ g_object_set(monitor, "proximity", TRUE, NULL); + } else { +- g_clear_pointer (&self->fader, phosh_cp_widget_destroy); ++ ps_mode = PHOSH_MONITOR_POWER_SAVE_MODE_ON; ++ g_object_set(monitor, "proximity", FALSE, NULL); + } ++ ++ phosh_monitor_set_power_save_mode (monitor, ps_mode); + } + + static void +--- a/src/shell.c 2021-03-04 15:50:24.291677177 +0100 ++++ b/src/shell.c 2021-03-04 15:50:54.228343514 +0100 +@@ -529,13 +533,15 @@ static void + on_builtin_monitor_power_mode_changed (PhoshShell *self, GParamSpec *pspec, PhoshMonitor *monitor) + { + PhoshMonitorPowerSaveMode mode; ++ gboolean proximity; + + g_return_if_fail (PHOSH_IS_SHELL (self)); + g_return_if_fail (PHOSH_IS_MONITOR (monitor)); + ++ g_object_get (monitor, "proximity", &proximity, NULL); + g_object_get (monitor, "power-mode", &mode, NULL); +- if (mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF) +- phosh_shell_lock (self); ++ if (!proximity && mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF) ++ //phosh_shell_lock (self); + + phosh_shell_set_state (self, PHOSH_STATE_BLANKED, mode == PHOSH_MONITOR_POWER_SAVE_MODE_OFF); + } diff --git a/gui-wm/phosh/files/0003-fix-locale-issue-in-service-file.patch b/gui-wm/phosh/files/0003-fix-locale-issue-in-service-file.patch new file mode 100644 index 0000000..115834b --- /dev/null +++ b/gui-wm/phosh/files/0003-fix-locale-issue-in-service-file.patch @@ -0,0 +1,22 @@ +From: Daniel Dehennin +Date: Wed, 17 Mar 2021 17:38:58 +0100 +Subject: Fix locale issue in Service file + +* data/phosh.service (Environment): do not override user language + setting. +--- + data/phosh.service | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/data/phosh.service b/data/phosh.service +index fa18137..a585696 100644 +--- a/data/phosh.service ++++ b/data/phosh.service +@@ -25,7 +25,6 @@ Before=graphical.target + ConditionPathExists=/dev/tty0 + + [Service] +-Environment=LANG=C.UTF-8 + Environment=XDG_CURRENT_DESKTOP=GNOME + Environment=XDG_SESSION_DESKTOP=phosh + Environment=XDG_SESSION_TYPE=wayland diff --git a/gui-wm/phosh/files/0003-shell-add-an-accessor-for-the-mode-manager.patch b/gui-wm/phosh/files/0003-shell-add-an-accessor-for-the-mode-manager.patch new file mode 100644 index 0000000..7ad625e --- /dev/null +++ b/gui-wm/phosh/files/0003-shell-add-an-accessor-for-the-mode-manager.patch @@ -0,0 +1,50 @@ +From 50cffaa899230af7ac3d24c7e76f3a7e4dbac519 Mon Sep 17 00:00:00 2001 +From: Arnaud Ferraris +Date: Tue, 27 Oct 2020 15:07:37 +0100 +Subject: [PATCH 45/47] 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 19a41fb..48dd4c2 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -815,6 +815,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 65680a5..541203d 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.28.0 + diff --git a/gui-wm/phosh/files/0004-lockscreen-manager-undo-transform-only-for-phones.patch b/gui-wm/phosh/files/0004-lockscreen-manager-undo-transform-only-for-phones.patch new file mode 100644 index 0000000..b389c3b --- /dev/null +++ b/gui-wm/phosh/files/0004-lockscreen-manager-undo-transform-only-for-phones.patch @@ -0,0 +1,44 @@ +From 29f0773b1e60736c193b6e3118b5f93030a52bc5 Mon Sep 17 00:00:00 2001 +From: Arnaud Ferraris +Date: Tue, 27 Oct 2020 17:14:07 +0100 +Subject: [PATCH 46/47] 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 | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c +index dac21e8..cc09026 100644 +--- a/src/lockscreen-manager.c ++++ b/src/lockscreen-manager.c +@@ -146,6 +146,7 @@ on_monitor_added (PhoshLockscreenManager *self, + static void + lockscreen_lock (PhoshLockscreenManager *self) + { ++ PhoshModeManager *mode_manager; + PhoshMonitor *primary_monitor; + PhoshWayland *wl = phosh_wayland_get_default (); + PhoshShell *shell = phosh_shell_get_default (); +@@ -156,9 +157,16 @@ lockscreen_lock (PhoshLockscreenManager *self) + primary_monitor = phosh_shell_get_primary_monitor (shell); + g_return_if_fail (primary_monitor); + +- /* Undo any transform on the primary display so the keypad becomes usable */ ++ mode_manager = phosh_shell_get_mode_manager(shell); + self->transform = phosh_shell_get_transform (shell); +- phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL); ++ ++ /* ++ * The lockscreen won't likely fit on phones, so we have to undo any transform ++ * on the primary display to make the keypad usable on such devices ++ */ ++ if (phosh_mode_manager_get_device_type(mode_manager) == PHOSH_MODE_DEVICE_TYPE_PHONE) { ++ phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL); ++ } + + /* Listen for monitor changes */ + g_signal_connect_object (monitor_manager, "monitor-added", +-- +2.28.0 diff --git a/gui-wm/phosh/files/0004-wlroots-0.10-rotation.patch b/gui-wm/phosh/files/0004-wlroots-0.10-rotation.patch new file mode 100644 index 0000000..67cfadc --- /dev/null +++ b/gui-wm/phosh/files/0004-wlroots-0.10-rotation.patch @@ -0,0 +1,18 @@ +diff --git a/src/rotation-manager.c b/src/rotation-manager.c +index 9fa8abd..a627935 100644 +--- a/src/rotation-manager.c ++++ b/src/rotation-manager.c +@@ -110,11 +110,11 @@ match_orientation (PhoshRotationManager *self) + if (!g_strcmp0 ("normal", orient)) { + transform = PHOSH_MONITOR_TRANSFORM_NORMAL; + } else if (!g_strcmp0 ("right-up", orient)) { +- transform = PHOSH_MONITOR_TRANSFORM_270; ++ transform = PHOSH_MONITOR_TRANSFORM_90; + } else if (!g_strcmp0 ("bottom-up", orient)) { + transform = PHOSH_MONITOR_TRANSFORM_180; + } else if (!g_strcmp0 ("left-up", orient)) { +- transform = PHOSH_MONITOR_TRANSFORM_90; ++ transform = PHOSH_MONITOR_TRANSFORM_270; + } else if (!g_strcmp0 ("undefined", orient)) { + return; /* just leave as is */ + } else { diff --git a/gui-wm/phosh/files/0005-rotate-to-potrait-on-lockscreen.patch b/gui-wm/phosh/files/0005-rotate-to-potrait-on-lockscreen.patch new file mode 100644 index 0000000..3425e62 --- /dev/null +++ b/gui-wm/phosh/files/0005-rotate-to-potrait-on-lockscreen.patch @@ -0,0 +1,27 @@ +--- a/src/lockscreen.c 2020-11-13 14:57:08.191840783 +0100 ++++ b/src/lockscreen.c 2020-11-13 14:55:38.355171909 +0100 +@@ -21,6 +21,8 @@ + #include + #include + ++#include ++ + #define HANDY_USE_UNSTABLE_API + #include + +@@ -402,6 +404,7 @@ carousel_position_notified_cb (PhoshLock + GParamSpec *pspec, + HdyCarousel *carousel) + { ++ PhoshShell *shell = phosh_shell_get_default (); + PhoshLockscreenPrivate *priv = phosh_lockscreen_get_instance_private (self); + double position; + +@@ -418,6 +421,7 @@ carousel_position_notified_cb (PhoshLock + priv->idle_timer = g_timeout_add_seconds (LOCKSCREEN_IDLE_SECONDS, + (GSourceFunc) keypad_check_idle, + self); ++ phosh_shell_set_transform (shell, 0); + } + + return; diff --git a/gui-wm/phosh/files/777.patch b/gui-wm/phosh/files/777.patch new file mode 100644 index 0000000..b099d4c --- /dev/null +++ b/gui-wm/phosh/files/777.patch @@ -0,0 +1,1395 @@ +From ebecb70a3049d6f538cce30e64026d0929c05ace Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 14 May 2021 18:53:38 +0200 +Subject: [PATCH 1/9] screenshot-manager: Remove opaque handler in dispose +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Guido Günther +--- + src/screenshot-manager.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/src/screenshot-manager.c b/src/screenshot-manager.c +index 00ff5efa..51df85dc 100644 +--- a/src/screenshot-manager.c ++++ b/src/screenshot-manager.c +@@ -55,8 +55,9 @@ typedef struct _PhoshScreenshotManager { + ScreencopyFrame *frame; + + PhoshFader *fader; +- PhoshFader *opaque; + guint fader_id; ++ PhoshFader *opaque; ++ guint opaque_id; + } PhoshScreenshotManager; + + +@@ -188,9 +189,10 @@ on_opaque_timeout (PhoshScreenshotManager *self) + gtk_clipboard_set_image (clipboard, self->frame->pixbuf); + g_debug ("Updated clipboard with %p", self->frame); + screencopy_done (self, TRUE); ++ + out: + g_clear_pointer (&self->opaque, phosh_cp_widget_destroy); +- ++ self->opaque_id = 0; + return G_SOURCE_REMOVE; + } + +@@ -288,7 +290,9 @@ screencopy_frame_handle_ready (void *data, + self->frame->pixbuf = g_steal_pointer (&pixbuf); + /* FIXME: Would be better to trigger when the opaque window is up and got + input focus but all such attempts failed */ +- g_timeout_add_seconds (1, (GSourceFunc) on_opaque_timeout, self); ++ self->opaque_id = g_timeout_add_seconds (1, (GSourceFunc) on_opaque_timeout, self); ++ g_source_set_name_by_id (self->opaque_id, "[phosh] screenshot opaque"); ++ + gtk_widget_show (GTK_WIDGET (self->opaque)); + } + return; +@@ -493,6 +497,7 @@ phosh_screenshot_manager_dispose (GObject *object) + g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self)); + + g_clear_handle_id (&self->fader_id, g_source_remove); ++ g_clear_handle_id (&self->opaque_id, g_source_remove); + g_clear_pointer (&self->fader, phosh_cp_widget_destroy); + + G_OBJECT_CLASS (phosh_screenshot_manager_parent_class)->dispose (object); +-- +GitLab + + +From 116a4fe763073b9c01126a6b069f17761e31d262 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 14 May 2021 18:57:01 +0200 +Subject: [PATCH 2/9] screenshot-manager: Actually set fader_id +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It got cleared but never set. + +Signed-off-by: Guido Günther +--- + src/screenshot-manager.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/screenshot-manager.c b/src/screenshot-manager.c +index 51df85dc..8bb64c0a 100644 +--- a/src/screenshot-manager.c ++++ b/src/screenshot-manager.c +@@ -121,6 +121,7 @@ on_fader_timeout (gpointer user_data) + + g_clear_pointer (&self->fader, phosh_cp_widget_destroy); + ++ self->fader_id = 0; + return G_SOURCE_REMOVE; + } + +@@ -130,7 +131,8 @@ show_fader (PhoshScreenshotManager *self) + { + PhoshMonitor *monitor = phosh_shell_get_primary_monitor (phosh_shell_get_default ()); + +- g_timeout_add (FLASH_FADER_TIMEOUT, on_fader_timeout, self); ++ self->fader_id = g_timeout_add (FLASH_FADER_TIMEOUT, on_fader_timeout, self); ++ g_source_set_name_by_id (self->fader_id, "[phosh] screenshot fader"); + self->fader = g_object_new (PHOSH_TYPE_FADER, + "monitor", monitor, + "style-class", "phosh-fader-flash-fade", +-- +GitLab + + +From e6808f57ece2cec5b6265e7678f6f3c6edef0f06 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 14 May 2021 18:12:34 +0200 +Subject: [PATCH 3/9] lockscreen-manager: Shorten property enum values +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is what we recommend in Hacking.md. + +Signed-off-by: Guido Günther +--- + src/lockscreen-manager.c | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c +index e34fb4b4..afcdb6ba 100644 +--- a/src/lockscreen-manager.c ++++ b/src/lockscreen-manager.c +@@ -42,11 +42,11 @@ enum { + static guint signals[N_SIGNALS] = { 0 }; + + enum { +- PHOSH_LOCKSCREEN_MANAGER_PROP_0, +- PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED, +- PHOSH_LOCKSCREEN_MANAGER_PROP_LAST_PROP ++ PROP_0, ++ PROP_LOCKED, ++ PROP_LAST_PROP + }; +-static GParamSpec *props[PHOSH_LOCKSCREEN_MANAGER_PROP_LAST_PROP]; ++static GParamSpec *props[PROP_LAST_PROP]; + + + struct _PhoshLockscreenManager { +@@ -84,7 +84,7 @@ lockscreen_unlock_cb (PhoshLockscreenManager *self, PhoshLockscreen *lockscreen) + + self->locked = FALSE; + self->active_time = 0; +- g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED]); ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_LOCKED]); + } + + +@@ -248,7 +248,7 @@ lockscreen_lock (PhoshLockscreenManager *self) + + self->locked = TRUE; + self->active_time = g_get_monotonic_time (); +- g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED]); ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_LOCKED]); + } + + +@@ -272,7 +272,7 @@ phosh_lockscreen_manager_set_property (GObject *object, + PhoshLockscreenManager *self = PHOSH_LOCKSCREEN_MANAGER (object); + + switch (property_id) { +- case PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED: ++ case PROP_LOCKED: + phosh_lockscreen_manager_set_locked (self, g_value_get_boolean (value)); + break; + default: +@@ -291,7 +291,7 @@ phosh_lockscreen_manager_get_property (GObject *object, + PhoshLockscreenManager *self = PHOSH_LOCKSCREEN_MANAGER (object); + + switch (property_id) { +- case PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED: ++ case PROP_LOCKED: + g_value_set_boolean (value, self->locked); + break; + default: +@@ -341,13 +341,14 @@ phosh_lockscreen_manager_class_init (PhoshLockscreenManagerClass *klass) + object_class->set_property = phosh_lockscreen_manager_set_property; + object_class->get_property = phosh_lockscreen_manager_get_property; + +- props[PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED] = ++ props[PROP_LOCKED] = + g_param_spec_boolean ("locked", + "Locked", + "Whether the screen is locked", + FALSE, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); +- g_object_class_install_properties (object_class, PHOSH_LOCKSCREEN_MANAGER_PROP_LAST_PROP, props); ++ ++ g_object_class_install_properties (object_class, PROP_LAST_PROP, props); + + /** + * PhoshLockscreenManager::wakeup-outputs +-- +GitLab + + +From 3214736fe1b5f4abd31d4dec6a2b6ae5b0033395 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Thu, 8 Apr 2021 10:21:55 +0200 +Subject: [PATCH 4/9] proximity: Fix function spacing +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Guido Günther +--- + src/proximity.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/proximity.c b/src/proximity.c +index 89e1c863..169fba3f 100644 +--- a/src/proximity.c ++++ b/src/proximity.c +@@ -65,6 +65,7 @@ on_proximity_claimed (PhoshSensorProxyManager *sensor_proxy_manager, + } + } + ++ + static void + on_proximity_released (PhoshSensorProxyManager *sensor_proxy_manager, + GAsyncResult *res, +@@ -89,6 +90,7 @@ on_proximity_released (PhoshSensorProxyManager *sensor_proxy_manager, + g_clear_pointer (&self->fader, phosh_cp_widget_destroy); + } + ++ + static void + phosh_proximity_claim_proximity (PhoshProximity *self, gboolean claim) + { +@@ -192,6 +194,7 @@ phosh_proximity_set_property (GObject *object, + } + } + ++ + static void + phosh_proximity_get_property (GObject *object, + guint property_id, +@@ -213,6 +216,7 @@ phosh_proximity_get_property (GObject *object, + } + } + ++ + static void + phosh_proximity_constructed (GObject *object) + { +@@ -237,6 +241,7 @@ phosh_proximity_constructed (GObject *object) + G_OBJECT_CLASS (phosh_proximity_parent_class)->constructed (object); + } + ++ + static void + phosh_proximity_dispose (GObject *object) + { +@@ -260,6 +265,7 @@ phosh_proximity_dispose (GObject *object) + G_OBJECT_CLASS (phosh_proximity_parent_class)->dispose (object); + } + ++ + static void + phosh_proximity_class_init (PhoshProximityClass *klass) + { +@@ -291,6 +297,7 @@ phosh_proximity_class_init (PhoshProximityClass *klass) + + } + ++ + static void + phosh_proximity_init (PhoshProximity *self) + { +-- +GitLab + + +From dac5f658ffef409c29bd45735a777e0d8d35bad8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 7 Apr 2021 15:02:13 +0200 +Subject: [PATCH 5/9] lockscreen: Drop style class +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We set it in the ui file already. + +Signed-off-by: Guido Günther +--- + src/lockscreen.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/src/lockscreen.c b/src/lockscreen.c +index 61ed356f..2992d12d 100644 +--- a/src/lockscreen.c ++++ b/src/lockscreen.c +@@ -442,10 +442,6 @@ phosh_lockscreen_constructed (GObject *object) + gtk_window_set_decorated (GTK_WINDOW (self), FALSE); + gtk_widget_realize(GTK_WIDGET (self)); + +- gtk_style_context_add_class ( +- gtk_widget_get_style_context (GTK_WIDGET (self)), +- "phosh-lockscreen"); +- + gtk_widget_add_events (GTK_WIDGET (self), GDK_KEY_PRESS_MASK); + g_signal_connect (G_OBJECT (self), + "key_press_event", +-- +GitLab + + +From c7571db13a0874dba50860c5ccb7703fcbe7bf7d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 7 Apr 2021 15:06:32 +0200 +Subject: [PATCH 6/9] Drop HANDY_USE_UNSTABLE_API +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Libhany's API isn't unstable anymore + +Signed-off-by: Guido Günther +--- + src/lockscreen.c | 1 - + src/notifications/notification-banner.c | 1 - + src/overview.c | 1 - + 3 files changed, 3 deletions(-) + +diff --git a/src/lockscreen.c b/src/lockscreen.c +index 2992d12d..d367e262 100644 +--- a/src/lockscreen.c ++++ b/src/lockscreen.c +@@ -20,7 +20,6 @@ + #include + #include + +-#define HANDY_USE_UNSTABLE_API + #include + + #define GNOME_DESKTOP_USE_UNSTABLE_API +diff --git a/src/notifications/notification-banner.c b/src/notifications/notification-banner.c +index a85f27c7..fbdda5ad 100644 +--- a/src/notifications/notification-banner.c ++++ b/src/notifications/notification-banner.c +@@ -14,7 +14,6 @@ + #include "shell.h" + #include "util.h" + +-#define HANDY_USE_UNSTABLE_API + #include + + /** +diff --git a/src/overview.c b/src/overview.c +index 790b4ee3..088bda00 100644 +--- a/src/overview.c ++++ b/src/overview.c +@@ -23,7 +23,6 @@ + + #include + +-#define HANDY_USE_UNSTABLE_API + #include + + #define OVERVIEW_ICON_SIZE 64 +-- +GitLab + + +From c0cd6cee102242fe0cfd82b3bf5d0bfd75a841cd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Tue, 6 Apr 2021 16:56:34 +0200 +Subject: [PATCH 7/9] Add calls manager +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This tracks ongoing calls via the sm.puri.Calls DBus interface. +This can be used to (e.g. activate the proximity sensor and to +unblank the screen on incoming calls). + +Signed-off-by: Guido Günther +--- + docs/phosh-docs.xml | 1 + + src/calls-manager.c | 418 ++++++++++++++++++++++++++++++++ + src/calls-manager.h | 24 ++ + src/dbus/meson.build | 6 + + src/dbus/sm.puri.Calls.Call.xml | 39 +++ + src/meson.build | 2 + + src/shell.c | 17 ++ + src/shell.h | 2 + + 8 files changed, 509 insertions(+) + create mode 100644 src/calls-manager.c + create mode 100644 src/calls-manager.h + create mode 100644 src/dbus/sm.puri.Calls.Call.xml + +diff --git a/docs/phosh-docs.xml b/docs/phosh-docs.xml +index 7a1bab7b..57ffbb8f 100644 +--- a/docs/phosh-docs.xml ++++ b/docs/phosh-docs.xml +@@ -50,6 +50,7 @@ + + + ++ + + + +diff --git a/src/calls-manager.c b/src/calls-manager.c +new file mode 100644 +index 00000000..b8ec2721 +--- /dev/null ++++ b/src/calls-manager.c +@@ -0,0 +1,418 @@ ++/* ++ * Copyright (C) 2021 Purism SPC ++ * ++ * SPDX-License-Identifier: GPL-3.0-or-later ++ * ++ * Author: Guido Günther ++ */ ++ ++#define G_LOG_DOMAIN "phosh-calls-manager" ++ ++#include "config.h" ++ ++#include "calls-manager.h" ++#include "shell.h" ++#include "util.h" ++#include "dbus/calls-dbus.h" ++ ++#define BUS_NAME "sm.puri.Calls" ++#define OBJECT_PATH "/sm/puri/Calls" ++#define OBJECT_PATHS_CALLS_PREFIX OBJECT_PATH "/Call/" ++ ++/** ++ * SECTION:calls-manager ++ * @short_description: Track ongoing phone calls ++ * @Title: PhoshCallsManager ++ * ++ * #PhoshCallsManager tracks on going calls and allows ++ * interaction with them. ++ */ ++ ++/** ++ * PhoshCallState: ++ * ++ * The call state. Must match call's CallsCallState. ++ */ ++typedef enum ++{ ++ /*< private >*/ ++ PHOSH_CALL_STATE_ACTIVE = 1, ++ PHOSH_CALL_STATE_HELD, ++ PHOSH_CALL_STATE_DIALING, ++ PHOSH_CALL_STATE_ALERTING, ++ PHOSH_CALL_STATE_INCOMING, ++ PHOSH_CALL_STATE_WAITING, ++ PHOSH_CALL_STATE_DISCONNECTED ++} PhoshCallState; ++ ++enum { ++ PROP_0, ++ PROP_PRESENT, ++ PROP_ACTIVE_CALL, ++ PROP_LAST_PROP ++}; ++static GParamSpec *props[PROP_LAST_PROP]; ++ ++ ++enum { ++ CALL_INBOUND, ++ N_SIGNALS ++}; ++static guint signals[N_SIGNALS] = { 0 }; ++ ++ ++struct _PhoshCallsManager { ++ PhoshManager parent; ++ ++ gboolean present; ++ gboolean incoming; ++ char *active_call; ++ ++ PhoshCallsDBusObjectManagerClient *om_client; ++ GCancellable *cancel; ++ GHashTable *calls; ++}; ++G_DEFINE_TYPE (PhoshCallsManager, phosh_calls_manager, PHOSH_TYPE_MANAGER); ++ ++ ++static void ++on_call_state_changed (PhoshCallsManager *self, ++ GParamSpec *pspec, ++ PhoshCallsDBusCallsCall *proxy) ++{ ++ const char *path; ++ PhoshCallState state; ++ ++ g_return_if_fail (PHOSH_IS_CALLS_MANAGER (self)); ++ g_return_if_fail (PHOSH_CALLS_DBUS_IS_CALLS_CALL (proxy)); ++ ++ path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (proxy)); ++ state = phosh_calls_dbus_calls_call_get_state (proxy); ++ ++ if (g_strcmp0 (path, self->active_call) == 0) { ++ /* current active call became inactive> */ ++ if (state != PHOSH_CALL_STATE_ACTIVE && ++ state != PHOSH_CALL_STATE_DIALING) { ++ g_debug ("No active call, was %s", path); ++ g_clear_pointer (&self->active_call, g_free); ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVE_CALL]); ++ /* TODO: pick new active call from list once calls supports multiple active calls */ ++ } ++ return; ++ } ++ ++ if (state != PHOSH_CALL_STATE_ACTIVE && state != PHOSH_CALL_STATE_DIALING) ++ return; ++ ++ /* New active call */ ++ g_free (self->active_call); ++ self->active_call = g_strdup (path); ++ g_debug ("New active call %s", path); ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVE_CALL]); ++} ++ ++ ++static void ++on_call_proxy_new_for_bus_finish (GObject *source_object, ++ GAsyncResult *res, ++ gpointer *data) ++{ ++ const char *path; ++ gboolean inbound; ++ PhoshCallsManager *self; ++ PhoshCallsDBusCallsCall *proxy; ++ ++ g_autoptr (GError) err = NULL; ++ ++ proxy = phosh_calls_dbus_calls_call_proxy_new_for_bus_finish (res, &err); ++ if (!proxy) { ++ phosh_async_error_warn (err, "Failed to get call proxy"); ++ return; ++ } ++ ++ self = PHOSH_CALLS_MANAGER (data); ++ path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (proxy)); ++ ++ if (g_hash_table_contains (self->calls, path)) ++ g_critical ("Already got a call with path %s", path); ++ else ++ g_hash_table_insert (self->calls, g_strdup (path), proxy); ++ ++ g_signal_connect_swapped (proxy, ++ "notify::state", ++ G_CALLBACK (on_call_state_changed), ++ self); ++ on_call_state_changed (self, NULL, proxy); ++ ++ inbound = phosh_calls_dbus_calls_call_get_inbound (proxy); ++ g_debug ("Added call %s, incoming: %d", path, inbound); ++ if (inbound) ++ g_signal_emit (self, signals[CALL_INBOUND], 0); ++} ++ ++ ++static void ++on_call_obj_added (PhoshCallsManager *self, ++ GDBusObject *object) ++{ ++ const char *path; ++ ++ g_return_if_fail (PHOSH_IS_CALLS_MANAGER (self)); ++ ++ path = g_dbus_object_get_object_path (object); ++ g_debug ("New call obj at %s", path); ++ if (!g_str_has_prefix (path, OBJECT_PATHS_CALLS_PREFIX)) ++ return; ++ ++ phosh_calls_dbus_calls_call_proxy_new_for_bus (G_BUS_TYPE_SESSION, ++ G_DBUS_PROXY_FLAGS_NONE, ++ BUS_NAME, ++ path, ++ self->cancel, ++ (GAsyncReadyCallback) on_call_proxy_new_for_bus_finish, ++ self); ++} ++ ++ ++static void ++on_call_obj_removed (PhoshCallsManager *self, ++ GDBusObject *object) ++{ ++ const char *path; ++ ++ g_return_if_fail (PHOSH_IS_CALLS_MANAGER (self)); ++ ++ path = g_dbus_object_get_object_path (object); ++ g_debug ("Call obj at %s gone", path); ++ if (!g_str_has_prefix (path, OBJECT_PATHS_CALLS_PREFIX)) ++ return; ++ ++ if (g_strcmp0 (path, self->active_call) == 0) { ++ g_clear_pointer (&self->active_call, g_free); ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVE_CALL]); ++ /* TODO: pick new active call from list once calls supports multiple active calls */ ++ } ++ ++ g_debug ("Removed call %s", path); ++ ++ g_return_if_fail (g_hash_table_remove (self->calls, path)); ++} ++ ++ ++static void ++phosh_calls_manager_get_property (GObject *object, ++ guint property_id, ++ GValue *value, ++ GParamSpec *pspec) ++{ ++ PhoshCallsManager *self = PHOSH_CALLS_MANAGER (object); ++ ++ switch (property_id) { ++ case PROP_PRESENT: ++ g_value_set_boolean (value, self->present); ++ break; ++ case PROP_ACTIVE_CALL: ++ g_value_set_string (value, self->active_call); ++ break; ++ default: ++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); ++ break; ++ } ++} ++ ++ ++static void ++on_name_owner_changed (PhoshCallsManager *self, ++ GParamSpec *pspec, ++ GDBusObjectManagerClient *om) ++{ ++ g_autofree char *owner = NULL; ++ gboolean present; ++ ++ g_return_if_fail (PHOSH_IS_CALLS_MANAGER (self)); ++ g_return_if_fail (G_IS_DBUS_OBJECT_MANAGER_CLIENT (om)); ++ ++ owner = g_dbus_object_manager_client_get_name_owner (om); ++ present = owner ? TRUE : FALSE; ++ ++ if (!present) { ++ g_hash_table_remove_all (self->calls); ++ } else { ++ g_autolist (GDBusObject) objs = g_dbus_object_manager_get_objects ( ++ G_DBUS_OBJECT_MANAGER (self->om_client)); ++ ++ /* Catch up on ongoing calls */ ++ for (GList *elem = objs; elem; elem = elem->next) { ++ on_call_obj_added (self, elem->data); ++ } ++ } ++ ++ if (present != self->present) { ++ self->present = present; ++ g_debug ("Calls present: %d", self->present); ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_PRESENT]); ++ } ++} ++ ++ ++static void ++on_om_new_for_bus_finish (GObject *source_object, ++ GAsyncResult *res, ++ gpointer data) ++{ ++ g_autoptr (GError) err = NULL; ++ PhoshCallsManager *self; ++ GDBusObjectManager *om; ++ GDBusObjectManagerClient *om_client; ++ ++ om = phosh_calls_dbus_object_manager_client_new_for_bus_finish (res, &err); ++ if (om == NULL) { ++ g_message ("Failed to get calls object manager client: %s", err->message); ++ return; ++ } ++ ++ self = PHOSH_CALLS_MANAGER (data); ++ self->om_client = PHOSH_CALLS_DBUS_OBJECT_MANAGER_CLIENT (om); ++ om_client = G_DBUS_OBJECT_MANAGER_CLIENT (om); ++ ++ g_signal_connect_object (self->om_client, ++ "notify::name-owner", ++ G_CALLBACK (on_name_owner_changed), ++ self, ++ G_CONNECT_SWAPPED); ++ on_name_owner_changed (self, NULL, G_DBUS_OBJECT_MANAGER_CLIENT (om)); ++ ++ g_signal_connect_object (self->om_client, ++ "object-added", ++ G_CALLBACK (on_call_obj_added), ++ self, ++ G_CONNECT_SWAPPED); ++ g_signal_connect_object (self->om_client, ++ "object-removed", ++ G_CALLBACK (on_call_obj_removed), ++ self, ++ G_CONNECT_SWAPPED); ++ ++ g_debug ("Calls manager initialized for name %s at %s", ++ g_dbus_object_manager_client_get_name (om_client), ++ g_dbus_object_manager_get_object_path (om)); ++} ++ ++ ++static void ++phosh_calls_manager_idle_init (PhoshManager *manager) ++{ ++ PhoshCallsManager *self = PHOSH_CALLS_MANAGER (manager); ++ ++ phosh_calls_dbus_object_manager_client_new_for_bus (G_BUS_TYPE_SESSION, ++ G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START, ++ BUS_NAME, ++ OBJECT_PATH, ++ self->cancel, ++ on_om_new_for_bus_finish, ++ self); ++} ++ ++ ++static void ++phosh_calls_manager_dispose (GObject *object) ++{ ++ PhoshCallsManager *self = PHOSH_CALLS_MANAGER (object); ++ ++ g_cancellable_cancel (self->cancel); ++ g_clear_object (&self->cancel); ++ g_clear_object (&self->om_client); ++ g_clear_pointer (&self->calls, g_hash_table_unref); ++ g_clear_pointer (&self->active_call, g_free); ++ ++ G_OBJECT_CLASS (phosh_calls_manager_parent_class)->dispose (object); ++} ++ ++ ++static void ++phosh_calls_manager_class_init (PhoshCallsManagerClass *klass) ++{ ++ GObjectClass *object_class = G_OBJECT_CLASS (klass); ++ PhoshManagerClass *manager_class = PHOSH_MANAGER_CLASS (klass); ++ ++ object_class->get_property = phosh_calls_manager_get_property; ++ object_class->dispose = phosh_calls_manager_dispose; ++ ++ manager_class->idle_init = phosh_calls_manager_idle_init; ++ ++ /** ++ * PhoshCallsManager:present: ++ * ++ * Whether the call interface is present on the bus ++ */ ++ props[PROP_PRESENT] = ++ g_param_spec_boolean ("present", ++ "", ++ "", ++ FALSE, ++ G_PARAM_READABLE | ++ G_PARAM_EXPLICIT_NOTIFY | ++ G_PARAM_STATIC_STRINGS); ++ ++ /** ++ * PhoshCallsManager:active-call: ++ * ++ * The currently active call ++ */ ++ props[PROP_ACTIVE_CALL] = ++ g_param_spec_string ("active-call", ++ "", ++ "", ++ NULL, ++ G_PARAM_READABLE | ++ G_PARAM_EXPLICIT_NOTIFY | ++ G_PARAM_STATIC_STRINGS); ++ ++ g_object_class_install_properties (object_class, PROP_LAST_PROP, props); ++ ++ signals[CALL_INBOUND] = g_signal_new ("call-inbound", ++ G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, ++ NULL, G_TYPE_NONE, 0); ++} ++ ++ ++static void ++phosh_calls_manager_init (PhoshCallsManager *self) ++{ ++ self->calls = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); ++ self->cancel = g_cancellable_new (); ++} ++ ++ ++PhoshCallsManager * ++phosh_calls_manager_new (void) ++{ ++ return g_object_new (PHOSH_TYPE_CALLS_MANAGER, NULL); ++} ++ ++ ++gboolean ++phosh_calls_manager_get_present (PhoshCallsManager *self) ++{ ++ g_return_val_if_fail (PHOSH_IS_CALLS_MANAGER (self), FALSE); ++ ++ return self->present; ++} ++ ++ ++int ++phosh_calls_manager_get_incoming (PhoshCallsManager *self) ++{ ++ g_return_val_if_fail (PHOSH_IS_CALLS_MANAGER (self), FALSE); ++ ++ return self->incoming; ++} ++ ++ ++const char * ++phosh_calls_manager_get_active_call (PhoshCallsManager *self) ++{ ++ g_return_val_if_fail (PHOSH_IS_CALLS_MANAGER (self), NULL); ++ ++ return self->active_call; ++} +diff --git a/src/calls-manager.h b/src/calls-manager.h +new file mode 100644 +index 00000000..193f7f1c +--- /dev/null ++++ b/src/calls-manager.h +@@ -0,0 +1,24 @@ ++/* ++ * Copyright (C) 2021 Purism SPC ++ * ++ * SPDX-License-Identifier: GPL-3.0-or-later ++ */ ++ ++#pragma once ++ ++#include "manager.h" ++ ++#include ++ ++G_BEGIN_DECLS ++ ++#define PHOSH_TYPE_CALLS_MANAGER (phosh_calls_manager_get_type ()) ++ ++G_DECLARE_FINAL_TYPE (PhoshCallsManager, phosh_calls_manager, PHOSH, CALLS_MANAGER, PhoshManager) ++ ++PhoshCallsManager *phosh_calls_manager_new (void); ++gboolean phosh_calls_manager_get_present (PhoshCallsManager *self); ++gboolean phosh_calls_manager_get_incoming (PhoshCallsManager *self); ++const char *phosh_calls_manager_get_active_call (PhoshCallsManager *self); ++ ++G_END_DECLS +diff --git a/src/dbus/meson.build b/src/dbus/meson.build +index 0424cc39..613df7e8 100644 +--- a/src/dbus/meson.build ++++ b/src/dbus/meson.build +@@ -62,6 +62,12 @@ generated_dbus_sources += gnome.gdbus_codegen('mpris-dbus', + 'org.mpris.MediaPlayer2.xml', + interface_prefix: 'org.mpris', + namespace: 'PhoshMprisDBus') ++# Calls ++generated_dbus_sources += gnome.gdbus_codegen('calls-dbus', ++ 'sm.puri.Calls.Call.xml', ++ object_manager: true, ++ interface_prefix: 'sm.puri', ++ namespace: 'PhoshCallsDBus') + + generated_dbus_sources += gnome.gdbus_codegen('phosh-wwan-ofono-dbus', + 'org.ofono.xml', +diff --git a/src/dbus/sm.puri.Calls.Call.xml b/src/dbus/sm.puri.Calls.Call.xml +new file mode 100644 +index 00000000..78ecafb5 +--- /dev/null ++++ b/src/dbus/sm.puri.Calls.Call.xml +@@ -0,0 +1,39 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ The Id identifying the call, e.g. a phone number ++ ++ ++ ++ ++ ++ ++ +diff --git a/src/meson.build b/src/meson.build +index c755f450..38c95248 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -57,6 +57,8 @@ libphosh_tool_sources = files( + 'app-list-model.h', + 'background.c', + 'background.h', ++ 'calls-manager.c', ++ 'calls-manager.h', + 'connectivity-info.c', + 'connectivity-info.h', + 'end-session-dialog.c', +diff --git a/src/shell.c b/src/shell.c +index c5894fde..2120e1f8 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -30,6 +30,7 @@ + #include "bt-info.h" + #include "bt-manager.h" + #include "connectivity-info.h" ++#include "calls-manager.h" + #include "docked-info.h" + #include "docked-manager.h" + #include "fader.h" +@@ -111,6 +112,7 @@ typedef struct + + PhoshSessionManager *session_manager; + PhoshBackgroundManager *background_manager; ++ PhoshCallsManager *calls_manager; + PhoshMonitor *primary_monitor; + PhoshMonitor *builtin_monitor; + PhoshMonitorManager *monitor_manager; +@@ -356,6 +358,7 @@ phosh_shell_dispose (GObject *object) + + /* dispose managers in opposite order of declaration */ + g_clear_object (&priv->screenshot_manager); ++ g_clear_object (&priv->calls_manager); + g_clear_object (&priv->location_manager); + g_clear_object (&priv->hks_manager); + g_clear_object (&priv->docked_manager); +@@ -723,6 +726,7 @@ phosh_shell_constructed (GObject *object) + "/sm/puri/phosh/icons"); + css_setup (self); + ++ priv->calls_manager = phosh_calls_manager_new (); + priv->lockscreen_manager = phosh_lockscreen_manager_new (); + g_object_bind_property (priv->lockscreen_manager, "locked", + self, "locked", +@@ -934,6 +938,19 @@ phosh_shell_get_background_manager (PhoshShell *self) + } + + ++PhoshCallsManager * ++phosh_shell_get_calls_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_CALLS_MANAGER (priv->calls_manager), NULL); ++ ++ return priv->calls_manager; ++} ++ ++ + PhoshWifiManager * + phosh_shell_get_wifi_manager (PhoshShell *self) + { +diff --git a/src/shell.h b/src/shell.h +index 6465fd40..e0353f02 100644 +--- a/src/shell.h ++++ b/src/shell.h +@@ -10,6 +10,7 @@ + + #include "background-manager.h" + #include "bt-manager.h" ++#include "calls-manager.h" + #include "docked-manager.h" + #include "feedback-manager.h" + #include "gtk-mount-manager.h" +@@ -77,6 +78,7 @@ PhoshBackgroundManager *phosh_shell_get_background_manager (PhoshShell *self); + PhoshFeedbackManager *phosh_shell_get_feedback_manager (PhoshShell *self); + PhoshGtkMountManager *phosh_shell_get_gtk_mount_manager (PhoshShell *self); + PhoshLockscreenManager *phosh_shell_get_lockscreen_manager (PhoshShell *self); ++PhoshCallsManager *phosh_shell_get_calls_manager (PhoshShell *self); + PhoshModeManager *phosh_shell_get_mode_manager (PhoshShell *self); + PhoshMonitorManager *phosh_shell_get_monitor_manager (PhoshShell *self); + PhoshToplevelManager *phosh_shell_get_toplevel_manager (PhoshShell *self); +-- +GitLab + + +From ac8f72dafc04d94f79d2466177b43f50943c3dad Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 7 Apr 2021 15:07:11 +0200 +Subject: [PATCH 8/9] lockscreen-manager: Unblank on incoming calls +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Do it here instead of in lockscreen-manager since +is where we'd also switch to the calls page later on. + +Signed-off-by: Guido Günther +--- + src/lockscreen-manager.c | 48 ++++++++++++++++++++++++++++++++++------ + src/lockscreen-manager.h | 3 ++- + src/shell.c | 2 +- + 3 files changed, 44 insertions(+), 9 deletions(-) + +diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c +index afcdb6ba..4b986362 100644 +--- a/src/lockscreen-manager.c ++++ b/src/lockscreen-manager.c +@@ -44,6 +44,7 @@ static guint signals[N_SIGNALS] = { 0 }; + enum { + PROP_0, + PROP_LOCKED, ++ PROP_CALLS_MANAGER, + PROP_LAST_PROP + }; + static GParamSpec *props[PROP_LAST_PROP]; +@@ -52,13 +53,15 @@ static GParamSpec *props[PROP_LAST_PROP]; + struct _PhoshLockscreenManager { + GObject parent; + +- PhoshLockscreen *lockscreen; /* phone display lock screen */ +- PhoshSessionPresence *presence; /* gnome-session's presence interface */ +- GPtrArray *shields; /* other outputs */ ++ PhoshLockscreen *lockscreen; /* phone display lock screen */ ++ PhoshSessionPresence *presence; /* gnome-session's presence interface */ ++ GPtrArray *shields; /* other outputs */ + + gboolean locked; +- gint64 active_time; /* when lock was activated (in us) */ +- int transform; /* the shell transform before locking */ ++ gint64 active_time; /* when lock was activated (in us) */ ++ int transform; /* the shell transform before locking */ ++ ++ PhoshCallsManager *calls_manager; /* Calls DBus Interface */ + }; + + G_DEFINE_TYPE (PhoshLockscreenManager, phosh_lockscreen_manager, G_TYPE_OBJECT) +@@ -275,6 +278,9 @@ phosh_lockscreen_manager_set_property (GObject *object, + case PROP_LOCKED: + phosh_lockscreen_manager_set_locked (self, g_value_get_boolean (value)); + break; ++ case PROP_CALLS_MANAGER: ++ self->calls_manager = g_value_dup_object (value); ++ break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; +@@ -294,6 +300,9 @@ phosh_lockscreen_manager_get_property (GObject *object, + case PROP_LOCKED: + g_value_set_boolean (value, self->locked); + break; ++ case PROP_CALLS_MANAGER: ++ g_value_set_object (value, self->calls_manager); ++ break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; +@@ -301,6 +310,15 @@ phosh_lockscreen_manager_get_property (GObject *object, + } + + ++static void ++on_calls_call_inbound (PhoshLockscreen *self) ++{ ++ g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self)); ++ ++ g_signal_emit (self, signals[WAKEUP_OUTPUTS], 0); ++} ++ ++ + static void + phosh_lockscreen_manager_dispose (GObject *object) + { +@@ -308,6 +326,7 @@ phosh_lockscreen_manager_dispose (GObject *object) + + g_clear_pointer (&self->shields, g_ptr_array_unref); + g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy); ++ g_clear_object (&self->calls_manager); + + G_OBJECT_CLASS (phosh_lockscreen_manager_parent_class)->dispose (object); + } +@@ -327,6 +346,12 @@ phosh_lockscreen_manager_constructed (GObject *object) + (GCallback) presence_status_changed_cb, + self); + } ++ ++ g_signal_connect_object (self->calls_manager, ++ "call-inbound", ++ G_CALLBACK (on_calls_call_inbound), ++ self, ++ G_CONNECT_SWAPPED); + } + + +@@ -348,6 +373,13 @@ phosh_lockscreen_manager_class_init (PhoshLockscreenManagerClass *klass) + FALSE, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + ++ props[PROP_CALLS_MANAGER] = ++ g_param_spec_object ("calls-manager", ++ "", ++ "", ++ PHOSH_TYPE_CALLS_MANAGER, ++ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); ++ + g_object_class_install_properties (object_class, PROP_LAST_PROP, props); + + /** +@@ -370,9 +402,11 @@ phosh_lockscreen_manager_init (PhoshLockscreenManager *self) + + + PhoshLockscreenManager * +-phosh_lockscreen_manager_new (void) ++phosh_lockscreen_manager_new (PhoshCallsManager *calls_manager) + { +- return g_object_new (PHOSH_TYPE_LOCKSCREEN_MANAGER, NULL); ++ return g_object_new (PHOSH_TYPE_LOCKSCREEN_MANAGER, ++ "calls-manager", calls_manager, ++ NULL); + } + + /** +diff --git a/src/lockscreen-manager.h b/src/lockscreen-manager.h +index 8dcfc8c0..3b0501a9 100644 +--- a/src/lockscreen-manager.h ++++ b/src/lockscreen-manager.h +@@ -6,6 +6,7 @@ + + #pragma once + ++#include "calls-manager.h" + #include "lockscreen.h" + #include + +@@ -17,7 +18,7 @@ G_DECLARE_FINAL_TYPE (PhoshLockscreenManager, + LOCKSCREEN_MANAGER, + GObject) + +-PhoshLockscreenManager *phosh_lockscreen_manager_new (void); ++PhoshLockscreenManager *phosh_lockscreen_manager_new (PhoshCallsManager *calls_manager); + void phosh_lockscreen_manager_set_locked (PhoshLockscreenManager *self, + gboolean state); + gboolean phosh_lockscreen_manager_get_locked (PhoshLockscreenManager *self); +diff --git a/src/shell.c b/src/shell.c +index 2120e1f8..99fd34b2 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -727,7 +727,7 @@ phosh_shell_constructed (GObject *object) + css_setup (self); + + priv->calls_manager = phosh_calls_manager_new (); +- priv->lockscreen_manager = phosh_lockscreen_manager_new (); ++ priv->lockscreen_manager = phosh_lockscreen_manager_new (priv->calls_manager); + g_object_bind_property (priv->lockscreen_manager, "locked", + self, "locked", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); +-- +GitLab + + +From 04ad113587f78291aa4b5613ca1e80016b6f2504 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 7 Apr 2021 16:51:49 +0200 +Subject: [PATCH 9/9] proximity: Only use proximity sensor on active calls +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +See https://source.puri.sm/Librem5/calls/-/issues/175 + +Signed-off-by: Guido Günther +--- + src/proximity.c | 65 +++++++++++++++++++++++++++---------------------- + src/proximity.h | 4 +-- + src/shell.c | 2 +- + 3 files changed, 39 insertions(+), 32 deletions(-) + +diff --git a/src/proximity.c b/src/proximity.c +index 169fba3f..1f57959f 100644 +--- a/src/proximity.c ++++ b/src/proximity.c +@@ -19,13 +19,16 @@ + * SECTION:proximity + * @short_description: Proximity sensor handling + * @Title: PhoshProximity ++ * ++ * #PhoshProximity handles enabling and disabling the proximity detection ++ * based on e.g. active calls. + */ + + + enum { + PROP_0, + PROP_SENSOR_PROXY_MANAGER, +- PROP_LOCKSCREEN_MANAGER, ++ PROP_CALLS_MANAGER, + LAST_PROP, + }; + static GParamSpec *props[LAST_PROP]; +@@ -35,7 +38,7 @@ typedef struct _PhoshProximity { + + gboolean claimed; + PhoshSensorProxyManager *sensor_proxy_manager; +- PhoshLockscreenManager *lockscreen_manager; ++ PhoshCallsManager *calls_manager; + PhoshFader *fader; + } PhoshProximity; + +@@ -120,28 +123,32 @@ on_has_proximity_changed (PhoshProximity *self, + { + gboolean has_proximity; + +- /* Don't claim if locked to save power */ +- if (phosh_lockscreen_manager_get_locked(self->lockscreen_manager)) +- return; +- + has_proximity = phosh_dbus_sensor_proxy_get_has_proximity ( + PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager)); + + g_debug ("Found %s proximity sensor", has_proximity ? "a" : "no"); ++ ++ /* If prox went a way we always unclaim but only claim on ongoing calls: */ ++ if (!phosh_calls_manager_get_active_call (self->calls_manager) && has_proximity) ++ return; ++ + phosh_proximity_claim_proximity (self, has_proximity); + } + ++ + static void +-on_lockscreen_manager_locked (PhoshProximity *self, GParamSpec *pspec, +- PhoshLockscreenManager *lockscreen_manager) ++on_calls_manager_active_call_changed (PhoshProximity *self, ++ GParamSpec *pspec, ++ PhoshCallsManager *calls_manager) + { +- gboolean locked; ++ gboolean active; + + g_return_if_fail (PHOSH_IS_PROXIMITY (self)); +- g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (lockscreen_manager)); ++ g_return_if_fail (PHOSH_IS_CALLS_MANAGER (calls_manager)); + +- locked = phosh_lockscreen_manager_get_locked(self->lockscreen_manager); +- phosh_proximity_claim_proximity (self, !locked); ++ active = !!phosh_calls_manager_get_active_call(self->calls_manager); ++ phosh_proximity_claim_proximity (self, active); ++ /* TODO: if call is over wait until we hit the threshold */ + } + + +@@ -184,9 +191,9 @@ phosh_proximity_set_property (GObject *object, + /* construct only */ + self->sensor_proxy_manager = g_value_dup_object (value); + break; +- case PROP_LOCKSCREEN_MANAGER: ++ case PROP_CALLS_MANAGER: + /* construct only */ +- self->lockscreen_manager = g_value_dup_object (value); ++ self->calls_manager = g_value_dup_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +@@ -207,8 +214,8 @@ phosh_proximity_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_CALLS_MANAGER: ++ g_value_set_object (value, self->calls_manager); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +@@ -222,9 +229,9 @@ phosh_proximity_constructed (GObject *object) + { + PhoshProximity *self = PHOSH_PROXIMITY (object); + +- g_signal_connect_swapped (self->lockscreen_manager, +- "notify::locked", +- G_CALLBACK (on_lockscreen_manager_locked), ++ g_signal_connect_swapped (self->calls_manager, ++ "notify::active-call", ++ G_CALLBACK (on_calls_manager_active_call_changed), + self); + + g_signal_connect_swapped (self->sensor_proxy_manager, +@@ -255,10 +262,10 @@ phosh_proximity_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->calls_manager) { ++ g_signal_handlers_disconnect_by_data (self->calls_manager, + self); +- g_clear_object (&self->lockscreen_manager); ++ g_clear_object (&self->calls_manager); + } + + g_clear_pointer (&self->fader, phosh_cp_widget_destroy); +@@ -285,12 +292,12 @@ phosh_proximity_class_init (PhoshProximityClass *klass) + PHOSH_TYPE_SENSOR_PROXY_MANAGER, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + +- props[PROP_LOCKSCREEN_MANAGER] = ++ props[PROP_CALLS_MANAGER] = + g_param_spec_object ( +- "lockscreen-manager", +- "Lockscren manager", +- "The object managing the lock screen", +- PHOSH_TYPE_LOCKSCREEN_MANAGER, ++ "calls-manager", ++ "", ++ "", ++ PHOSH_TYPE_CALLS_MANAGER, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, LAST_PROP, props); +@@ -306,10 +313,10 @@ phosh_proximity_init (PhoshProximity *self) + + PhoshProximity * + phosh_proximity_new (PhoshSensorProxyManager *sensor_proxy_manager, +- PhoshLockscreenManager *lockscreen_manager) ++ PhoshCallsManager *calls_manager) + { + return g_object_new (PHOSH_TYPE_PROXIMITY, + "sensor-proxy-manager", sensor_proxy_manager, +- "lockscreen-manager", lockscreen_manager, ++ "calls-manager", calls_manager, + NULL); + } +diff --git a/src/proximity.h b/src/proximity.h +index ad9a0ed1..ef2e6da7 100644 +--- a/src/proximity.h ++++ b/src/proximity.h +@@ -6,7 +6,7 @@ + + #pragma once + +-#include "lockscreen-manager.h" ++#include "calls-manager.h" + #include "sensor-proxy-manager.h" + + G_BEGIN_DECLS +@@ -16,6 +16,6 @@ G_BEGIN_DECLS + G_DECLARE_FINAL_TYPE (PhoshProximity, phosh_proximity, PHOSH, PROXIMITY, GObject); + + PhoshProximity *phosh_proximity_new (PhoshSensorProxyManager *sensor_proxy_manager, +- PhoshLockscreenManager *lockscreen_manager); ++ PhoshCallsManager *calls_manager); + + G_END_DECLS +diff --git a/src/shell.c b/src/shell.c +index 99fd34b2..9122c5ed 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -513,7 +513,7 @@ setup_idle_cb (PhoshShell *self) + phosh_shell_get_location_manager (self); + if (priv->sensor_proxy_manager) { + priv->proximity = phosh_proximity_new (priv->sensor_proxy_manager, +- priv->lockscreen_manager); ++ priv->calls_manager); + phosh_monitor_manager_set_sensor_proxy_manager (priv->monitor_manager, + priv->sensor_proxy_manager); + } +-- +GitLab + diff --git a/gui-wm/phosh/files/821.patch b/gui-wm/phosh/files/821.patch new file mode 100644 index 0000000..495c5f6 --- /dev/null +++ b/gui-wm/phosh/files/821.patch @@ -0,0 +1,211 @@ +From c11bddfedd9d62410cd64720be91b1a3a5096231 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Tue, 29 Sep 2020 16:30:24 +0200 +Subject: [PATCH] settings: Add torch brightness slider +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This adds brightness slider when the torch is enabled. + +Closes: #386 + +Signed-off-by: Guido Günther +--- + src/settings.c | 65 +++++++++++++++++++++++++++++++++++++++++ + src/ui/settings-menu.ui | 49 +++++++++++++++++++++++++++++++ + 2 files changed, 114 insertions(+) + +diff --git a/src/settings.c b/src/settings.c +index 5dd823b8..bcfbe6f9 100644 +--- a/src/settings.c ++++ b/src/settings.c +@@ -16,6 +16,8 @@ + #include "quick-setting.h" + #include "settings/brightness.h" + #include "settings/gvc-channel-bar.h" ++#include "torch-info.h" ++#include "torch-manager.h" + #include "wwan/phosh-wwan-mm.h" + #include "feedback-manager.h" + #include "notifications/notify-manager.h" +@@ -64,6 +66,11 @@ typedef struct _PhoshSettings + GtkWidget *list_notifications; + GtkWidget *sw_notifications; + LfbEvent *notify_event; ++ ++ /* Torch */ ++ PhoshTorchManager *torch_manager; ++ GtkWidget *scale_torch; ++ gboolean setting_torch; + } PhoshSettings; + + +@@ -401,6 +408,41 @@ end_notify_feedback (PhoshSettings *self) + } + + ++static void ++on_torch_scale_value_changed (PhoshSettings *self, GtkScale *scale_torch) ++{ ++ double value; ++ ++ g_return_if_fail (PHOSH_IS_SETTINGS (self)); ++ g_return_if_fail (PHOSH_IS_TORCH_MANAGER (self->torch_manager)); ++ ++ /* Only react to scale changes when torch is enabled */ ++ if (!phosh_torch_manager_get_enabled (self->torch_manager)) ++ return; ++ ++ self->setting_torch = TRUE; ++ value = gtk_range_get_value (GTK_RANGE (self->scale_torch)); ++ g_debug ("Setting torch brightness to %.2f", value); ++ phosh_torch_manager_set_scaled_brightness (self->torch_manager, value / 100.0); ++} ++ ++ ++static void ++on_torch_brightness_changed (PhoshSettings *self, GParamSpec *pspec, PhoshTorchManager *manager) ++{ ++ g_return_if_fail (PHOSH_IS_SETTINGS (self)); ++ g_return_if_fail (PHOSH_IS_TORCH_MANAGER (manager)); ++ ++ if (self->setting_torch) { ++ self->setting_torch = FALSE; ++ return; ++ } ++ ++ gtk_range_set_value (GTK_RANGE (self->scale_torch), ++ 100.0 * phosh_torch_manager_get_scaled_brightness (self->torch_manager)); ++} ++ ++ + static void + on_notifcation_items_changed (PhoshSettings *self, + guint position, +@@ -441,6 +483,24 @@ setup_brightness_range (PhoshSettings *self) + } + + ++static void ++setup_torch (PhoshSettings *self) ++{ ++ PhoshShell *shell = phosh_shell_get_default (); ++ ++ self->torch_manager = g_object_ref(phosh_shell_get_torch_manager (shell)); ++ ++ gtk_range_set_range (GTK_RANGE (self->scale_torch), 40, 100); ++ gtk_range_set_value (GTK_RANGE (self->scale_torch), ++ phosh_torch_manager_get_scaled_brightness (self->torch_manager) * 100.0); ++ g_signal_connect_object (self->torch_manager, ++ "notify::brightness", ++ G_CALLBACK(on_torch_brightness_changed), ++ self, ++ G_CONNECT_SWAPPED); ++} ++ ++ + static void + setup_volume_bar (PhoshSettings *self) + { +@@ -477,6 +537,7 @@ phosh_settings_constructed (GObject *object) + + setup_brightness_range (self); + setup_volume_bar (self); ++ setup_torch (self); + + g_signal_connect (self->quick_settings, + "child-activated", +@@ -515,6 +576,8 @@ phosh_settings_dispose (GObject *object) + g_clear_object (&self->notify_event); + } + ++ g_clear_object (&self->torch_manager); ++ + G_OBJECT_CLASS (phosh_settings_parent_class)->dispose (object); + } + +@@ -552,6 +615,7 @@ phosh_settings_class_init (PhoshSettingsClass *klass) + gtk_widget_class_bind_template_child (widget_class, PhoshSettings, list_notifications); + gtk_widget_class_bind_template_child (widget_class, PhoshSettings, quick_settings); + gtk_widget_class_bind_template_child (widget_class, PhoshSettings, scale_brightness); ++ gtk_widget_class_bind_template_child (widget_class, PhoshSettings, scale_torch); + gtk_widget_class_bind_template_child (widget_class, PhoshSettings, sw_notifications); + + gtk_widget_class_bind_template_callback (widget_class, battery_setting_clicked_cb); +@@ -568,6 +632,7 @@ phosh_settings_class_init (PhoshSettingsClass *klass) + gtk_widget_class_bind_template_callback (widget_class, wifi_setting_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, wifi_setting_long_pressed_cb); + gtk_widget_class_bind_template_callback (widget_class, wwan_setting_clicked_cb); ++ gtk_widget_class_bind_template_callback (widget_class, on_torch_scale_value_changed); + } + + +diff --git a/src/ui/settings-menu.ui b/src/ui/settings-menu.ui +index 38aa0d97..ba549be0 100644 +--- a/src/ui/settings-menu.ui ++++ b/src/ui/settings-menu.ui +@@ -200,6 +200,52 @@ + 2 + + ++ ++ ++ True ++ ++ ++ ++ True ++ False ++ 5 ++ ++ ++ True ++ False ++ 6 ++ torch-enabled-symbolic ++ ++ ++ False ++ True ++ 0 ++ ++ ++ ++ ++ True ++ True ++ adj_torch ++ 0 ++ False ++ ++ ++ ++ True ++ True ++ 1 ++ ++ ++ ++ ++ ++ ++ False ++ True ++ 3 ++ ++ + + + False +@@ -234,4 +280,7 @@ + + + ++ ++ 1 ++ + +-- +GitLab + diff --git a/gui-wm/phosh/files/822.patch b/gui-wm/phosh/files/822.patch new file mode 100644 index 0000000..d1a3865 --- /dev/null +++ b/gui-wm/phosh/files/822.patch @@ -0,0 +1,365 @@ +From 77913a24fc709cdbc1f2a91da7cf81834f1239a6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 19 May 2021 17:40:12 +0200 +Subject: [PATCH 1/6] hacking: Fix property function names +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We always use the singular form + +Signed-off-by: Guido Günther +--- + HACKING.md | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/HACKING.md b/HACKING.md +index 242cceba..bd9fdd52 100644 +--- a/HACKING.md ++++ b/HACKING.md +@@ -106,8 +106,8 @@ individual C files should be structured as (top to bottom of file): + ``` + - private methods and callbacks (these can also go at convenient + places above `phosh_thing_constructed ()` +- - `phosh_thing_set_properties ()` +- - `phosh_thing_get_properties ()` ++ - `phosh_thing_set_property ()` ++ - `phosh_thing_get_property ()` + - `phosh_thing_constructed ()` + - `phosh_thing_dispose ()` + - `phosh_thing_finalize ()` +-- +GitLab + + +From e5dc0790c0a265b4a30ad4cc04e306c31a05da3e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 19 May 2021 17:20:28 +0200 +Subject: [PATCH 2/6] batteryinfo: Drop superfluous NULL checks +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +g_clear_object() does this for us. + +Signed-off-by: Guido Günther +--- + src/batteryinfo.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/src/batteryinfo.c b/src/batteryinfo.c +index a03cac8d..d8f02158 100644 +--- a/src/batteryinfo.c ++++ b/src/batteryinfo.c +@@ -91,11 +91,8 @@ phosh_battery_info_dispose (GObject *object) + { + PhoshBatteryInfo *self = PHOSH_BATTERY_INFO (object); + +- if (self->device) +- g_clear_object (&self->device); +- +- if (self->upower) +- g_clear_object (&self->upower); ++ g_clear_object (&self->device); ++ g_clear_object (&self->upower); + + G_OBJECT_CLASS (phosh_battery_info_parent_class)->dispose (object); + } +-- +GitLab + + +From 2e0db016397b0737f5abc2ec9f4c0289412c6fa3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 19 May 2021 18:00:49 +0200 +Subject: [PATCH 3/6] panel: Always use bold font +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +So far all labels set this expicitly + +Signed-off-by: Guido Günther +--- + src/style.css | 2 +- + src/ui/top-panel.ui | 3 --- + 2 files changed, 1 insertion(+), 4 deletions(-) + +diff --git a/src/style.css b/src/style.css +index caa845fd..2e707ae4 100644 +--- a/src/style.css ++++ b/src/style.css +@@ -3,6 +3,7 @@ + */ + .phosh-panel { + font: 15px Cantarell; ++ font-weight: bold; + } + + .phosh-panel-btn { +@@ -11,7 +12,6 @@ + } + + .phosh-topbar-clock { +- font-weight: bold; + font-feature-settings: "tnum"; + } + +diff --git a/src/ui/top-panel.ui b/src/ui/top-panel.ui +index 26338b6f..e03c537e 100644 +--- a/src/ui/top-panel.ui ++++ b/src/ui/top-panel.ui +@@ -168,9 +168,6 @@ + 8 + 2 + center +- +- +- + + + False +-- +GitLab + + +From 40a57d77346d2447e349a1a215fc9897fc9309ff Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 19 May 2021 17:40:44 +0200 +Subject: [PATCH 4/6] batteryinfo: Add optional label with battery percentage +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Guido Günther +--- + src/batteryinfo.c | 100 ++++++++++++++++++++++++++++++++++++++++++++-- + src/batteryinfo.h | 2 + + 2 files changed, 99 insertions(+), 3 deletions(-) + +diff --git a/src/batteryinfo.c b/src/batteryinfo.c +index d8f02158..abd518d2 100644 +--- a/src/batteryinfo.c ++++ b/src/batteryinfo.c +@@ -22,16 +22,63 @@ + * @Title: PhoshBatteryInfo + */ + ++enum { ++ PROP_0, ++ PROP_SHOW_DETAIL, ++ PROP_LAST_PROP ++}; ++static GParamSpec *props[PROP_LAST_PROP]; ++ ++ + typedef struct _PhoshBatteryInfo { +- PhoshStatusIcon parent; +- UpClient *upower; +- UpDevice *device; ++ PhoshStatusIcon parent; ++ UpClient *upower; ++ UpDevice *device; ++ gboolean show_detail; + } PhoshBatteryInfo; + + + G_DEFINE_TYPE (PhoshBatteryInfo, phosh_battery_info, PHOSH_TYPE_STATUS_ICON) + + ++static void ++phosh_battery_info_set_property (GObject *object, ++ guint property_id, ++ const GValue *value, ++ GParamSpec *pspec) ++{ ++ PhoshBatteryInfo *self = PHOSH_BATTERY_INFO (object); ++ ++ switch (property_id) { ++ case PROP_SHOW_DETAIL: ++ phosh_battery_info_set_show_detail (self, g_value_get_boolean (value)); ++ break; ++ default: ++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); ++ break; ++ } ++} ++ ++ ++static void ++phosh_battery_info_get_property (GObject *object, ++ guint property_id, ++ GValue *value, ++ GParamSpec *pspec) ++{ ++ PhoshBatteryInfo *self = PHOSH_BATTERY_INFO (object); ++ ++ switch (property_id) { ++ case PROP_SHOW_DETAIL: ++ g_value_set_boolean (value, self->show_detail); ++ break; ++ default: ++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); ++ break; ++ } ++} ++ ++ + static void + setup_display_device (PhoshBatteryInfo *self) + { +@@ -82,6 +129,11 @@ phosh_battery_info_constructed (GObject *object) + NULL, + NULL, + NULL); ++ g_object_bind_property (self, ++ "info", ++ phosh_status_icon_get_extra_widget (PHOSH_STATUS_ICON (self)), ++ "label", ++ G_BINDING_SYNC_CREATE); + } + } + +@@ -105,12 +157,32 @@ phosh_battery_info_class_init (PhoshBatteryInfoClass *klass) + + object_class->constructed = phosh_battery_info_constructed; + object_class->dispose = phosh_battery_info_dispose; ++ object_class->get_property = phosh_battery_info_get_property; ++ object_class->set_property = phosh_battery_info_set_property; ++ ++ props[PROP_SHOW_DETAIL] = ++ g_param_spec_boolean ( ++ "show-detail", ++ "", ++ "", ++ FALSE, ++ G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); ++ ++ g_object_class_install_properties (object_class, PROP_LAST_PROP, props); + } + + + static void + phosh_battery_info_init (PhoshBatteryInfo *self) + { ++ GtkWidget *percentage = gtk_label_new (NULL); ++ phosh_status_icon_set_extra_widget (PHOSH_STATUS_ICON (self), percentage); ++ ++ g_object_bind_property (self, ++ "show-detail", ++ percentage, ++ "visible", ++ G_BINDING_SYNC_CREATE); + } + + +@@ -119,3 +191,25 @@ phosh_battery_info_new (void) + { + return g_object_new (PHOSH_TYPE_BATTERY_INFO, NULL); + } ++ ++ ++void ++phosh_battery_info_set_show_detail (PhoshBatteryInfo *self, gboolean show) ++{ ++ g_return_if_fail (PHOSH_IS_BATTERY_INFO (self)); ++ ++ if (self->show_detail == show) ++ return; ++ ++ self->show_detail = !!show; ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SHOW_DETAIL]); ++} ++ ++ ++gboolean ++phosh_battery_info_get_show_detail (PhoshBatteryInfo *self) ++{ ++ g_return_val_if_fail (PHOSH_IS_BATTERY_INFO (self), FALSE); ++ ++ return self->show_detail; ++} +diff --git a/src/batteryinfo.h b/src/batteryinfo.h +index 6d0114b6..6aef37bb 100644 +--- a/src/batteryinfo.h ++++ b/src/batteryinfo.h +@@ -17,5 +17,7 @@ G_BEGIN_DECLS + G_DECLARE_FINAL_TYPE (PhoshBatteryInfo, phosh_battery_info, PHOSH, BATTERY_INFO, PhoshStatusIcon) + + GtkWidget * phosh_battery_info_new (void); ++void phosh_battery_info_set_show_detail (PhoshBatteryInfo *self, gboolean show); ++gboolean phosh_battery_info_get_show_detail (PhoshBatteryInfo *self); + + G_END_DECLS +-- +GitLab + + +From ff137645c53a9ff9125acb4a6bc8d10731e71b26 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 19 May 2021 17:48:09 +0200 +Subject: [PATCH 5/6] panel: Honor show-battery-percentage +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This allows to show the battery percentage in the top bar + +Closes: https://source.puri.sm/Librem5/phosh/-/issues/268 + +Signed-off-by: Guido Günther +--- + src/panel.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/src/panel.c b/src/panel.c +index 71319352..c9aaeada 100644 +--- a/src/panel.c ++++ b/src/panel.c +@@ -50,10 +50,12 @@ typedef struct { + GtkWidget *lbl_clock; + GtkWidget *lbl_lang; + GtkWidget *settings; /* settings menu */ ++ GtkWidget *batteryinfo; + + GnomeWallClock *wall_clock; + GnomeXkbInfo *xkbinfo; + GSettings *input_settings; ++ GSettings *interface_settings; + GdkSeat *seat; + + GSimpleActionGroup *actions; +@@ -344,6 +346,13 @@ phosh_panel_constructed (GObject *object) + "logout"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + } ++ ++ priv->interface_settings = g_settings_new ("org.gnome.desktop.interface"); ++ g_settings_bind (priv->interface_settings, ++ "show-battery-percentage", ++ priv->batteryinfo, ++ "show-detail", ++ G_SETTINGS_BIND_GET); + } + + +@@ -356,6 +365,7 @@ phosh_panel_dispose (GObject *object) + g_clear_object (&priv->wall_clock); + g_clear_object (&priv->xkbinfo); + g_clear_object (&priv->input_settings); ++ g_clear_object (&priv->interface_settings); + g_clear_object (&priv->actions); + priv->seat = NULL; + +@@ -380,6 +390,7 @@ phosh_panel_class_init (PhoshPanelClass *klass) + "/sm/puri/phosh/ui/top-panel.ui"); + gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, menu_power); + gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, btn_top_panel); ++ gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, batteryinfo); + gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, lbl_clock); + gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, lbl_lang); + gtk_widget_class_bind_template_child_private (widget_class, PhoshPanel, box); +-- +GitLab + + diff --git a/gui-wm/phosh/files/823.patch b/gui-wm/phosh/files/823.patch new file mode 100644 index 0000000..2acced1 --- /dev/null +++ b/gui-wm/phosh/files/823.patch @@ -0,0 +1,35 @@ +From 1bdbfb9e3c1a86f659476017cb6210227c01d601 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 21 May 2021 12:41:41 +0200 +Subject: [PATCH 1/2] po: Drop string from from jp translation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The translation switches %s and %d causing a crash. + +Signed-off-by: Guido Günther +--- + po/ja.po | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/po/ja.po b/po/ja.po +index a87bf11c..19710623 100644 +--- a/po/ja.po ++++ b/po/ja.po +@@ -63,13 +63,6 @@ msgstr "ドック外" + msgid "Log Out" + msgstr "ログアウト" + +-#: src/end-session-dialog.c:165 +-#, c-format +-msgid "%s will be logged out automatically in %d second." +-msgid_plural "%s will be logged out automatically in %d seconds." +-msgstr[0] "%d秒後、%sさんは自動でログアウトされます。" +-msgstr[1] "%d秒後、%sさんは自動でログアウトされます。" +- + #: src/end-session-dialog.c:172 + #, c-format + msgid "The system will power off automatically in %d second." +-- +GitLab diff --git a/gui-wm/phosh/files/833.patch b/gui-wm/phosh/files/833.patch new file mode 100644 index 0000000..29d9fd6 --- /dev/null +++ b/gui-wm/phosh/files/833.patch @@ -0,0 +1,31 @@ +From 078854ae6b15fce4d817772de521d9a226a52704 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Sun, 30 May 2021 20:37:31 +0200 +Subject: [PATCH] data: Add gsd-wwan to required components +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This makes sure it's also started in systemd mode so the PIN request +happens. + +Signed-off-by: Guido Günther +--- + data/meson.build | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/data/meson.build b/data/meson.build +index 64f1cdec..a60eb7db 100644 +--- a/data/meson.build ++++ b/data/meson.build +@@ -14,6 +14,7 @@ gsd_required_components = [ + 'org.gnome.SettingsDaemon.Sound', + 'org.gnome.SettingsDaemon.UsbProtection', + 'org.gnome.SettingsDaemon.Wacom', ++ 'org.gnome.SettingsDaemon.Wwan', + 'org.gnome.SettingsDaemon.XSettings', + ] + +-- +GitLab + diff --git a/gui-wm/phosh/files/MR434-fix-rotation-on-a-PP.patch b/gui-wm/phosh/files/MR434-fix-rotation-on-a-PP.patch new file mode 100644 index 0000000..19f4727 --- /dev/null +++ b/gui-wm/phosh/files/MR434-fix-rotation-on-a-PP.patch @@ -0,0 +1,16 @@ +--- a/src/rotation-manager.c 2020-08-06 13:39:48.934458000 +0200 ++++ b/src/rotation-manager.c 2020-08-06 13:40:52.711124361 +0200 +@@ -79,11 +79,11 @@ match_orientation (PhoshRotationManager + + if (!g_strcmp0 ("normal", orient)) { + transform = PHOSH_MONITOR_TRANSFORM_NORMAL; +- } else if (!g_strcmp0 ("right-up", orient)) { ++ } else if (!g_strcmp0 ("left-up", orient)) { + transform = PHOSH_MONITOR_TRANSFORM_270; + } else if (!g_strcmp0 ("bottom-up", orient)) { + transform = PHOSH_MONITOR_TRANSFORM_180; +- } else if (!g_strcmp0 ("left-up", orient)) { ++ } else if (!g_strcmp0 ("right-up", orient)) { + transform = PHOSH_MONITOR_TRANSFORM_90; + } else if (!g_strcmp0 ("undefined", orient)) { + return; /* just leave as is */ diff --git a/gui-wm/phosh/files/MR434.patch b/gui-wm/phosh/files/MR434.patch new file mode 100644 index 0000000..6252ea5 --- /dev/null +++ b/gui-wm/phosh/files/MR434.patch @@ -0,0 +1,2314 @@ +From 207e7203a33781cc538b19658f19f4f14f8614a4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Wed, 5 Aug 2020 16:07:16 +0200 +Subject: [PATCH 01/19] rotateinfo: Fix indentation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Guido Günther +--- + src/rotateinfo.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/rotateinfo.c b/src/rotateinfo.c +index 5cd3ccf7..b673fa3d 100644 +--- a/src/rotateinfo.c ++++ b/src/rotateinfo.c +@@ -59,7 +59,7 @@ set_state (PhoshRotateInfo *self) + monitor_is_landscape = ((double)monitor->width / (double)monitor->height) > 1.0; + portrait = monitor_is_landscape ? !portrait : portrait; + +- g_debug ("Potrait: %d, width: %d, height: %d", portrait, monitor->width , monitor->height); ++ g_debug ("Potrait: %d, width: %d, height: %d", portrait, monitor->width, monitor->height); + if (portrait) { + phosh_status_icon_set_icon_name (PHOSH_STATUS_ICON (self), "screen-rotation-portrait-symbolic"); + phosh_status_icon_set_info (PHOSH_STATUS_ICON (self), _("Portrait")); +-- +GitLab + + +From b5545e2428c5816f9e5efd84b41c28a383988983 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 26 Mar 2021 09:37:13 +0100 +Subject: [PATCH 02/19] monitor-manager: Fix doc string +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Make function name match the actual definition. + +Signed-off-by: Guido Günther +--- + src/monitor-manager.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/monitor-manager.c b/src/monitor-manager.c +index d67f073b..6e48ce26 100644 +--- a/src/monitor-manager.c ++++ b/src/monitor-manager.c +@@ -1369,9 +1369,10 @@ phosh_monitor_manager_get_num_monitors (PhoshMonitorManager *self) + } + + /** +- * phosh_monitor_set_transform: ++ * phosh_monitor_manager_set_monitor_transform: + * @self: A #PhoshMonitor +- * @mode: The #PhoshMonitorPowerSaveMode ++ * @monitor: The #PhoshMonitor to set the tansform on ++ * @transform: The #PhoshMonitorTransform to set + * + * Sets monitor's transform. This will become active after the next + * call to #phosh_monitor_manager_apply_monitor_config(). +-- +GitLab + + +From ee3cb76591469a608d4ea2113853c9bf0e4d1be1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Thu, 7 Jan 2021 16:39:12 +0100 +Subject: [PATCH 03/19] shell: Create sensor-manager early +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We want that before the panels since those might use other +managers that need the sensor-manager (e.g. rotation-manager) + +Signed-off-by: Guido Günther +--- + src/shell.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/shell.c b/src/shell.c +index 0aad5403..cb596b45 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -469,6 +469,8 @@ setup_idle_cb (PhoshShell *self) + priv->session_manager = phosh_session_manager_new (); + priv->mode_manager = phosh_mode_manager_new (); + ++ priv->sensor_proxy_manager = phosh_sensor_proxy_manager_get_default_failable (); ++ + panels_create (self); + /* Create background after panel since it needs the panel's size */ + priv->background_manager = phosh_background_manager_new (); +@@ -502,8 +504,8 @@ setup_idle_cb (PhoshShell *self) + if (priv->sensor_proxy_manager) { + priv->proximity = phosh_proximity_new (priv->sensor_proxy_manager, + priv->lockscreen_manager); +- /* TODO: accelerometer */ + } ++ + priv->mount_manager = phosh_mount_manager_new (); + + phosh_session_manager_register (priv->session_manager, +-- +GitLab + + +From 9f3856df6f2cbe817c70cc3ce915c5117a192624 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Thu, 7 Jan 2021 16:36:12 +0100 +Subject: [PATCH 04/19] shell: Don't bother with accelerometer +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Rotation-manager takes care of that + +Signed-off-by: Guido Günther +--- + src/shell.c | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/src/shell.c b/src/shell.c +index cb596b45..0bcf6558 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -340,13 +340,6 @@ phosh_shell_dispose (GObject *object) + PhoshShell *self = PHOSH_SHELL (object); + PhoshShellPrivate *priv = phosh_shell_get_instance_private(self); + +- if (priv->sensor_proxy_manager) { +- phosh_dbus_sensor_proxy_call_release_accelerometer_sync ( +- PHOSH_DBUS_SENSOR_PROXY(priv->sensor_proxy_manager), +- NULL, NULL); +- g_clear_object (&priv->sensor_proxy_manager); +- } +- + panels_dispose (self); + g_clear_pointer (&priv->faders, g_ptr_array_unref); + +-- +GitLab + + +From 4064988c7efeb1b74ebf32bbd2df02e8154392cd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Thu, 7 Jan 2021 20:32:06 +0100 +Subject: [PATCH 05/19] shell: Decruft builtin monitor setup +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Just look it up on start since it can't change. + +Signed-off-by: Guido Günther +--- + src/shell.c | 45 +++++++++++++++++++++++++++++---------------- + 1 file changed, 29 insertions(+), 16 deletions(-) + +diff --git a/src/shell.c b/src/shell.c +index 0bcf6558..b8a71053 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -611,6 +611,32 @@ on_monitor_removed (PhoshShell *self, PhoshMonitor *monitor) + } + + ++static PhoshMonitor * ++find_builtin_monitor (PhoshShell *self) ++{ ++ PhoshShellPrivate *priv; ++ PhoshMonitor *monitor = NULL; ++ ++ g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL); ++ priv = phosh_shell_get_instance_private (self); ++ ++ if (priv->builtin_monitor) ++ return priv->builtin_monitor; ++ ++ for (int i = 0; i < phosh_monitor_manager_get_num_monitors (priv->monitor_manager); i++) { ++ monitor = phosh_monitor_manager_get_monitor (priv->monitor_manager, i); ++ if (phosh_monitor_is_builtin (monitor)) ++ break; ++ } ++ ++ if (!monitor) ++ monitor = phosh_monitor_manager_get_monitor (priv->monitor_manager, 0); ++ g_return_val_if_fail (monitor, NULL); ++ ++ return monitor; ++} ++ ++ + static void + phosh_shell_constructed (GObject *object) + { +@@ -634,7 +660,7 @@ phosh_shell_constructed (GObject *object) + phosh_wayland_roundtrip (phosh_wayland_get_default ()); + + if (phosh_monitor_manager_get_num_monitors(priv->monitor_manager)) { +- priv->builtin_monitor = phosh_shell_get_builtin_monitor (self); ++ 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)); +@@ -819,25 +845,12 @@ PhoshMonitor * + phosh_shell_get_builtin_monitor (PhoshShell *self) + { + PhoshShellPrivate *priv; +- PhoshMonitor *monitor = NULL; + + g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL); + priv = phosh_shell_get_instance_private (self); ++ g_return_val_if_fail (PHOSH_IS_MONITOR (priv->builtin_monitor), NULL); + +- if (priv->builtin_monitor) +- return priv->builtin_monitor; +- +- for (int i = 0; i < phosh_monitor_manager_get_num_monitors (priv->monitor_manager); i++) { +- monitor = phosh_monitor_manager_get_monitor (priv->monitor_manager, i); +- if (phosh_monitor_is_builtin (monitor)) +- break; +- } +- +- if (!monitor) +- monitor = phosh_monitor_manager_get_monitor (priv->monitor_manager, 0); +- g_return_val_if_fail (monitor, NULL); +- +- return monitor; ++ return priv->builtin_monitor; + } + + +-- +GitLab + + +From b8c08549e293471e07d19d06c04ebab84a111687 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Mon, 29 Mar 2021 17:51:52 +0200 +Subject: [PATCH 06/19] Avoid sensor-proxy singleton + +Treat it as regular initable that is fetched from the shell +like other managers. +--- + src/sensor-proxy-manager.c | 30 ++++++++---------------------- + src/sensor-proxy-manager.h | 2 +- + src/shell.c | 6 ++++-- + 3 files changed, 13 insertions(+), 25 deletions(-) + +diff --git a/src/sensor-proxy-manager.c b/src/sensor-proxy-manager.c +index 89b5e8f1..473a6b21 100644 +--- a/src/sensor-proxy-manager.c ++++ b/src/sensor-proxy-manager.c +@@ -52,27 +52,13 @@ phosh_sensor_proxy_manager_init (PhoshSensorProxyManager *self) + + + PhoshSensorProxyManager * +-phosh_sensor_proxy_manager_get_default_failable (void) ++phosh_sensor_proxy_manager_new (GError **err) + { +- static PhoshSensorProxyManager *instance; +- GError *err = NULL; +- GInitable *ret; +- +- if (instance == NULL) { +- ret = g_initable_new (PHOSH_TYPE_SENSOR_PROXY_MANAGER, NULL, &err, +- "g-flags", G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, +- "g-name", IIO_SENSOR_PROXY_DBUS_NAME, +- "g-bus-type", G_BUS_TYPE_SYSTEM, +- "g-object-path", IIO_SENSOR_PROXY_DBUS_OBJECT, +- "g-interface-name", IIO_SENSOR_PROXY_DBUS_IFACE_NAME, +- NULL); +- if (ret != NULL) { +- instance = PHOSH_SENSOR_PROXY_MANAGER (ret); +- } else { +- g_warning ("Can't connect to iio-sensor-sensor proxy: %s", err->message); +- return NULL; +- } +- g_object_add_weak_pointer (G_OBJECT (instance), (gpointer *)&instance); +- } +- return instance; ++ return g_initable_new (PHOSH_TYPE_SENSOR_PROXY_MANAGER, NULL, err, ++ "g-flags", G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, ++ "g-name", IIO_SENSOR_PROXY_DBUS_NAME, ++ "g-bus-type", G_BUS_TYPE_SYSTEM, ++ "g-object-path", IIO_SENSOR_PROXY_DBUS_OBJECT, ++ "g-interface-name", IIO_SENSOR_PROXY_DBUS_IFACE_NAME, ++ NULL); + } +diff --git a/src/sensor-proxy-manager.h b/src/sensor-proxy-manager.h +index 9d140bae..32664a6d 100644 +--- a/src/sensor-proxy-manager.h ++++ b/src/sensor-proxy-manager.h +@@ -13,6 +13,6 @@ + G_DECLARE_FINAL_TYPE (PhoshSensorProxyManager, phosh_sensor_proxy_manager, + PHOSH, SENSOR_PROXY_MANAGER, PhoshDBusSensorProxyProxy) + +-PhoshSensorProxyManager *phosh_sensor_proxy_manager_get_default_failable (void); ++PhoshSensorProxyManager *phosh_sensor_proxy_manager_new (GError **err); + gboolean phosh_sensor_proxy_manager_claim_proximity_sync (PhoshSensorProxyManager *self, + GError **err); +diff --git a/src/shell.c b/src/shell.c +index b8a71053..6f0d3663 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -457,12 +457,15 @@ on_fade_out_timeout (PhoshShell *self) + static gboolean + setup_idle_cb (PhoshShell *self) + { ++ g_autoptr (GError) err = NULL; + PhoshShellPrivate *priv = phosh_shell_get_instance_private (self); + + priv->session_manager = phosh_session_manager_new (); + priv->mode_manager = phosh_mode_manager_new (); + +- priv->sensor_proxy_manager = phosh_sensor_proxy_manager_get_default_failable (); ++ priv->sensor_proxy_manager = phosh_sensor_proxy_manager_new (&err); ++ if (!priv->sensor_proxy_manager) ++ g_warning ("Failed to connect to sensor-proxy: %s", err->message); + + panels_create (self); + /* Create background after panel since it needs the panel's size */ +@@ -493,7 +496,6 @@ setup_idle_cb (PhoshShell *self) + G_CONNECT_SWAPPED); + + priv->location_manager = phosh_location_manager_new (); +- priv->sensor_proxy_manager = phosh_sensor_proxy_manager_get_default_failable (); + if (priv->sensor_proxy_manager) { + priv->proximity = phosh_proximity_new (priv->sensor_proxy_manager, + priv->lockscreen_manager); +-- +GitLab + + +From f6e1b8b77fb9a13ea84735c94f8c674886f8a6ef Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Tue, 23 Jun 2020 14:05:57 +0200 +Subject: [PATCH 07/19] Add rotation-manager +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The rotation manager listens to device orientation changes +and adjusts the primary display accordingly. + +This interfaces with lockscreen, iio-sensor-proxy and +gsettings to figure out the correct screen orientation. + +The manager has two modes: off (don't rotate any output) and sensor +(adjust due to sensor values). + +Signed-off-by: Guido Günther +--- + docs/phosh-docs.xml | 1 + + src/meson.build | 3 + + src/phosh-enums.c.in | 1 + + src/rotation-manager.c | 546 +++++++++++++++++++++++++++++++++++++++++ + src/rotation-manager.h | 45 ++++ + src/shell.c | 22 ++ + src/shell.h | 2 + + 7 files changed, 620 insertions(+) + create mode 100644 src/rotation-manager.c + create mode 100644 src/rotation-manager.h + +diff --git a/docs/phosh-docs.xml b/docs/phosh-docs.xml +index e6c0a9db..9900a4ae 100644 +--- a/docs/phosh-docs.xml ++++ b/docs/phosh-docs.xml +@@ -102,6 +102,7 @@ + + + ++ + + + +diff --git a/src/meson.build b/src/meson.build +index 7935b17a..5a0ea2b3 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -23,6 +23,7 @@ phosh_enum_headers = [ + 'notifications/notification.h', + 'notifications/notify-manager.h', + 'phosh-wayland.h', ++ 'rotation-manager.h', + 'shell.h', + ] + schema_enum_headers + +@@ -162,6 +163,8 @@ libphosh_sources = [ + 'polkit-auth-prompt.h', + 'proximity.h', + 'proximity.c', ++ 'rotation-manager.h', ++ 'rotation-manager.c', + 'sensor-proxy-manager.c', + 'sensor-proxy-manager.h', + 'rotateinfo.c', +diff --git a/src/phosh-enums.c.in b/src/phosh-enums.c.in +index f001d726..293b97d9 100644 +--- a/src/phosh-enums.c.in ++++ b/src/phosh-enums.c.in +@@ -11,6 +11,7 @@ + #include "notifications/notification.h" + #include "notifications/notify-manager.h" + #include "phosh-wayland.h" ++#include "rotation-manager.h" + #include "shell.h" + #include "wwan/phosh-wwan-backend.h" + +diff --git a/src/rotation-manager.c b/src/rotation-manager.c +new file mode 100644 +index 00000000..ba847553 +--- /dev/null ++++ b/src/rotation-manager.c +@@ -0,0 +1,546 @@ ++/* ++ * Copyright (C) 2021 Purism SPC ++ * ++ * SPDX-License-Identifier: GPL-3.0-or-later ++ * Author: Guido Günther ++ */ ++ ++#define G_LOG_DOMAIN "phosh-rotation-manager" ++ ++#include "config.h" ++#include "rotation-manager.h" ++#include "shell.h" ++#include "sensor-proxy-manager.h" ++#include "util.h" ++ ++#define ORIENTATION_LOCK_SCHEMA_ID "org.gnome.settings-daemon.peripherals.touchscreen" ++#define ORIENTATION_LOCK_KEY "orientation-lock" ++ ++/** ++ * SECTION:rotation-manager ++ * @short_description: The Rotation Manager ++ * @Title: PhoshRotationManager ++ * ++ * #PhoshRotationManager is responsible for managing the rotation of ++ * a given #PhoshMonitor. Depending on the #PhoshRotationManagerMode ++ * this can happen by interfacing with a #PhoshSensorProxyManager or ++ * by setting the #PhoshMonitorTransform explicitly. ++ * It also takes the #PhoshLockscreenManager:locked status into account ++ * to ensure the lockscreen is rotated accordingly on small phones. ++ */ ++ ++enum { ++ PROP_0, ++ PROP_SENSOR_PROXY_MANAGER, ++ PROP_LOCKSCREEN_MANAGER, ++ PROP_ORIENTATION_LOCKED, ++ PROP_MONITOR, ++ PROP_MODE, ++ LAST_PROP, ++}; ++static GParamSpec *props[LAST_PROP]; ++ ++typedef struct _PhoshRotationManager { ++ GObject parent; ++ ++ gboolean claimed; ++ PhoshSensorProxyManager *sensor_proxy_manager; ++ PhoshLockscreenManager *lockscreen_manager; ++ PhoshMonitor *monitor; ++ ++ GSettings *settings; ++ gboolean orientation_locked; ++ ++ PhoshRotationManagerMode mode; ++} PhoshRotationManager; ++ ++G_DEFINE_TYPE (PhoshRotationManager, phosh_rotation_manager, G_TYPE_OBJECT); ++ ++ ++static void ++apply_transform (PhoshRotationManager *self, PhoshMonitorTransform transform) ++{ ++ PhoshMonitorTransform current; ++ 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)); ++ ++ g_debug ("Rotating %s: %d", self->monitor->name, transform); ++ ++ current = phosh_monitor_get_transform (self->monitor); ++ if (current == transform) ++ return; ++ ++ phosh_monitor_manager_set_monitor_transform (monitor_manager, ++ self->monitor, ++ transform); ++ phosh_monitor_manager_apply_monitor_config (monitor_manager); ++} ++ ++/** ++ * match_orientation: ++ * @self: The #PhoshRotationManager ++ * ++ * Match the screen orientation to the sensor output. ++ * Do nothing if orientation lock is on or there's no ++ * sensor claimed. ++ */ ++static void ++match_orientation (PhoshRotationManager *self) ++{ ++ const gchar *orient; ++ PhoshMonitorTransform transform; ++ ++ if (self->orientation_locked || !self->claimed || ++ self->mode == PHOSH_ROTATION_MANAGER_MODE_OFF) ++ return; ++ ++ orient = phosh_dbus_sensor_proxy_get_accelerometer_orientation ( ++ PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager)); ++ ++ g_debug ("Orientation changed: %s, locked: %d, claimed: %d", ++ orient, self->orientation_locked, self->claimed); ++ ++ if (!g_strcmp0 ("normal", orient)) { ++ transform = PHOSH_MONITOR_TRANSFORM_NORMAL; ++ } else if (!g_strcmp0 ("right-up", orient)) { ++ transform = PHOSH_MONITOR_TRANSFORM_270; ++ } else if (!g_strcmp0 ("bottom-up", orient)) { ++ transform = PHOSH_MONITOR_TRANSFORM_180; ++ } else if (!g_strcmp0 ("left-up", orient)) { ++ transform = PHOSH_MONITOR_TRANSFORM_90; ++ } else if (!g_strcmp0 ("undefined", orient)) { ++ return; /* just leave as is */ ++ } else { ++ g_warning ("Unknown orientation '%s'", orient); ++ return; ++ } ++ ++ apply_transform (self, transform); ++} ++ ++static void ++on_accelerometer_claimed (PhoshSensorProxyManager *sensor_proxy_manager, ++ GAsyncResult *res, ++ PhoshRotationManager *self) ++{ ++ g_autoptr (GError) err = NULL; ++ gboolean success; ++ ++ g_return_if_fail (PHOSH_IS_SENSOR_PROXY_MANAGER (sensor_proxy_manager)); ++ g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self)); ++ g_return_if_fail (sensor_proxy_manager == self->sensor_proxy_manager); ++ ++ success = phosh_dbus_sensor_proxy_call_claim_accelerometer_finish ( ++ PHOSH_DBUS_SENSOR_PROXY (sensor_proxy_manager), ++ res, &err); ++ if (success) { ++ g_debug ("Claimed accelerometer"); ++ self->claimed = TRUE; ++ } else { ++ g_warning ("Failed to claim accelerometer: %s", err->message); ++ } ++ match_orientation (self); ++ g_object_unref (self); ++} ++ ++static void ++on_accelerometer_released (PhoshSensorProxyManager *sensor_proxy_manager, ++ GAsyncResult *res, ++ PhoshRotationManager *self) ++{ ++ g_autoptr (GError) err = NULL; ++ gboolean success; ++ ++ g_return_if_fail (PHOSH_IS_SENSOR_PROXY_MANAGER (sensor_proxy_manager)); ++ g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self)); ++ g_return_if_fail (sensor_proxy_manager == self->sensor_proxy_manager); ++ ++ success = phosh_dbus_sensor_proxy_call_release_accelerometer_finish ( ++ PHOSH_DBUS_SENSOR_PROXY (sensor_proxy_manager), ++ res, &err); ++ if (success) { ++ g_debug ("Released rotation sensor"); ++ } else { ++ g_warning ("Failed to release rotation sensor: %s", err->message); ++ } ++ self->claimed = FALSE; ++ g_object_unref (self); ++} ++ ++static void ++phosh_rotation_manager_claim_accelerometer (PhoshRotationManager *self, gboolean claim) ++{ ++ if (claim == self->claimed) ++ return; ++ ++ if (!self->sensor_proxy_manager) ++ return; ++ ++ if (claim) { ++ phosh_dbus_sensor_proxy_call_claim_accelerometer ( ++ PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager), ++ NULL, ++ (GAsyncReadyCallback)on_accelerometer_claimed, ++ g_object_ref (self)); ++ } else { ++ phosh_dbus_sensor_proxy_call_release_accelerometer ( ++ PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager), ++ NULL, ++ (GAsyncReadyCallback)on_accelerometer_released, ++ g_object_ref (self)); ++ } ++} ++ ++static void ++on_has_accelerometer_changed (PhoshRotationManager *self, ++ GParamSpec *pspec, ++ PhoshSensorProxyManager *proxy) ++{ ++ gboolean has_accel; ++ PhoshRotationManagerMode mode; ++ ++ has_accel = phosh_dbus_sensor_proxy_get_has_accelerometer ( ++ PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager)); ++ ++ g_debug ("Found %s accelerometer", has_accel ? "a" : "no"); ++ ++ mode = has_accel ? PHOSH_ROTATION_MANAGER_MODE_SENSOR : PHOSH_ROTATION_MANAGER_MODE_OFF; ++ phosh_rotation_manager_set_mode (self, mode); ++} ++ ++static void ++on_lockscreen_manager_locked (PhoshRotationManager *self, GParamSpec *pspec, ++ PhoshLockscreenManager *lockscreen_manager) ++{ ++ gboolean claim; ++ ++ g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self)); ++ g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (lockscreen_manager)); ++ ++ if (self->mode == PHOSH_ROTATION_MANAGER_MODE_OFF) ++ claim = FALSE; ++ else ++ claim = !phosh_lockscreen_manager_get_locked (self->lockscreen_manager); ++ ++ phosh_rotation_manager_claim_accelerometer (self, claim); ++} ++ ++static void ++on_accelerometer_orientation_changed (PhoshRotationManager *self, ++ GParamSpec *pspec, ++ PhoshSensorProxyManager *sensor) ++{ ++ g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self)); ++ g_return_if_fail (self->sensor_proxy_manager == sensor); ++ ++ match_orientation (self); ++} ++ ++static void ++phosh_rotation_manager_set_property (GObject *object, ++ guint property_id, ++ const GValue *value, ++ GParamSpec *pspec) ++{ ++ PhoshRotationManager *self = PHOSH_ROTATION_MANAGER (object); ++ ++ switch (property_id) { ++ case PROP_SENSOR_PROXY_MANAGER: ++ /* construct only */ ++ self->sensor_proxy_manager = g_value_dup_object (value); ++ break; ++ case PROP_LOCKSCREEN_MANAGER: ++ /* construct only */ ++ self->lockscreen_manager = g_value_dup_object (value); ++ break; ++ case PROP_MONITOR: ++ /* construct only */ ++ self->monitor = g_value_dup_object (value); ++ break; ++ case PROP_ORIENTATION_LOCKED: ++ phosh_rotation_manager_set_orientation_locked (self, ++ g_value_get_boolean (value)); ++ break; ++ case PROP_MODE: ++ phosh_rotation_manager_set_mode (self, g_value_get_enum (value)); ++ break; ++ default: ++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); ++ break; ++ } ++} ++ ++static void ++phosh_rotation_manager_get_property (GObject *object, ++ guint property_id, ++ GValue *value, ++ GParamSpec *pspec) ++{ ++ PhoshRotationManager *self = PHOSH_ROTATION_MANAGER (object); ++ ++ switch (property_id) { ++ 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); ++ break; ++ case PROP_ORIENTATION_LOCKED: ++ g_value_set_boolean (value, self->orientation_locked); ++ break; ++ case PROP_MODE: ++ g_value_set_enum (value, self->mode); ++ break; ++ default: ++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); ++ break; ++ } ++} ++ ++static void ++phosh_rotation_manager_constructed (GObject *object) ++{ ++ PhoshRotationManager *self = PHOSH_ROTATION_MANAGER (object); ++ ++ G_OBJECT_CLASS (phosh_rotation_manager_parent_class)->constructed (object); ++ ++ self->settings = g_settings_new (ORIENTATION_LOCK_SCHEMA_ID); ++ ++ g_settings_bind (self->settings, ++ ORIENTATION_LOCK_KEY, ++ self, ++ "orientation-locked", ++ G_BINDING_SYNC_CREATE ++ | G_BINDING_BIDIRECTIONAL); ++ ++ g_signal_connect_swapped (self->lockscreen_manager, ++ "notify::locked", ++ (GCallback) on_lockscreen_manager_locked, ++ self); ++ on_lockscreen_manager_locked (self, NULL, self->lockscreen_manager); ++ ++ if (!self->sensor_proxy_manager) ++ return; ++ ++ g_signal_connect_swapped (self->sensor_proxy_manager, ++ "notify::accelerometer-orientation", ++ (GCallback) on_accelerometer_orientation_changed, ++ self); ++ ++ g_signal_connect_swapped (self->sensor_proxy_manager, ++ "notify::has-accelerometer", ++ (GCallback) on_has_accelerometer_changed, ++ self); ++ on_has_accelerometer_changed (self, NULL, self->sensor_proxy_manager); ++} ++ ++ ++static void ++phosh_rotation_manager_dispose (GObject *object) ++{ ++ PhoshRotationManager *self = PHOSH_ROTATION_MANAGER (object); ++ ++ g_clear_object (&self->settings); ++ ++ if (self->sensor_proxy_manager) { ++ g_signal_handlers_disconnect_by_data (self->sensor_proxy_manager, ++ self); ++ /* Sync call since we're going away */ ++ phosh_dbus_sensor_proxy_call_release_accelerometer_sync ( ++ PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager), NULL, NULL); ++ g_clear_object (&self->sensor_proxy_manager); ++ } ++ ++ if (self->lockscreen_manager) { ++ g_signal_handlers_disconnect_by_data (self->lockscreen_manager, ++ self); ++ g_clear_object (&self->lockscreen_manager); ++ } ++ g_clear_object (&self->monitor); ++ ++ G_OBJECT_CLASS (phosh_rotation_manager_parent_class)->dispose (object); ++} ++ ++static void ++phosh_rotation_manager_class_init (PhoshRotationManagerClass *klass) ++{ ++ GObjectClass *object_class = (GObjectClass *)klass; ++ ++ object_class->constructed = phosh_rotation_manager_constructed; ++ object_class->dispose = phosh_rotation_manager_dispose; ++ ++ object_class->set_property = phosh_rotation_manager_set_property; ++ object_class->get_property = phosh_rotation_manager_get_property; ++ ++ props[PROP_SENSOR_PROXY_MANAGER] = ++ g_param_spec_object ( ++ "sensor-proxy-manager", ++ "Sensor proxy manager", ++ "The object inerfacing with iio-sensor-proxy", ++ PHOSH_TYPE_SENSOR_PROXY_MANAGER, ++ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); ++ ++ props[PROP_LOCKSCREEN_MANAGER] = ++ g_param_spec_object ( ++ "lockscreen-manager", ++ "Lockscren manager", ++ "The object managing the lock screen", ++ PHOSH_TYPE_LOCKSCREEN_MANAGER, ++ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); ++ ++ props[PROP_MONITOR] = ++ g_param_spec_object ( ++ "monitor", ++ "Monitor", ++ "The monitor to rotate", ++ PHOSH_TYPE_MONITOR, ++ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); ++ ++ props[PROP_ORIENTATION_LOCKED] = ++ g_param_spec_boolean ( ++ "orientation-locked", ++ "Screen orientation locked", ++ "Whether the screen orientation is locked", ++ TRUE, ++ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); ++ ++ props[PROP_MODE] = ++ g_param_spec_enum ( ++ "mode", ++ "Rotation mode", ++ "The current rotation mode", ++ PHOSH_TYPE_ROTATION_MANAGER_MODE, ++ PHOSH_ROTATION_MANAGER_MODE_OFF, ++ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); ++ ++ g_object_class_install_properties (object_class, LAST_PROP, props); ++} ++ ++static void ++phosh_rotation_manager_init (PhoshRotationManager *self) ++{ ++} ++ ++ ++PhoshRotationManager * ++phosh_rotation_manager_new (PhoshSensorProxyManager *sensor_proxy_manager, ++ PhoshLockscreenManager *lockscreen_manager, ++ PhoshMonitor *monitor) ++{ ++ return g_object_new (PHOSH_TYPE_ROTATION_MANAGER, ++ "sensor-proxy-manager", sensor_proxy_manager, ++ "lockscreen-manager", lockscreen_manager, ++ "monitor", monitor, ++ NULL); ++} ++ ++void ++phosh_rotation_manager_set_orientation_locked (PhoshRotationManager *self, gboolean locked) ++{ ++ g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self)); ++ ++ if (locked == self->orientation_locked) ++ return; ++ ++ self->orientation_locked = locked; ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ORIENTATION_LOCKED]); ++ match_orientation (self); ++} ++ ++gboolean ++phosh_rotation_manager_get_orientation_locked (PhoshRotationManager *self) ++{ ++ g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (self), TRUE); ++ ++ return self->orientation_locked; ++} ++ ++PhoshRotationManagerMode ++phosh_rotation_manager_get_mode (PhoshRotationManager *self) ++{ ++ g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (self), PHOSH_ROTATION_MANAGER_MODE_OFF); ++ ++ return self->mode; ++} ++ ++/** ++ * phosh_rotation_manager_set_mode: ++ * @self: The #PhoshRotationManager ++ * @mode: The #PhoshRotationManagerMode to set ++ * ++ * Sets the given mode. ++ * Returns: %TRUE if setting the mode was possible, otherwise %FALSE (e.g. when trying ++ * to set %PHOSH_ROTATION_MANAGER_MODE_SENSOR without having a sensor. ++ */ ++gboolean ++phosh_rotation_manager_set_mode (PhoshRotationManager *self, PhoshRotationManagerMode mode) ++{ ++ gboolean has_accel; ++ ++ g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (self), FALSE); ++ ++ if (mode == self->mode) ++ return TRUE; ++ ++ has_accel = phosh_dbus_sensor_proxy_get_has_accelerometer ( ++ PHOSH_DBUS_SENSOR_PROXY (self->sensor_proxy_manager)); ++ ++ if (mode == PHOSH_ROTATION_MANAGER_MODE_SENSOR && !has_accel) ++ return FALSE; ++ ++ self->mode = mode; ++ ++ g_debug ("Setting mode: %d", mode); ++ switch (mode) { ++ case PHOSH_ROTATION_MANAGER_MODE_OFF: ++ phosh_rotation_manager_claim_accelerometer (self, FALSE); ++ break; ++ case PHOSH_ROTATION_MANAGER_MODE_SENSOR: ++ /* Don't claim during screen lock, enables runtime pm and will be ++ claimed on unlock */ ++ if (!phosh_lockscreen_manager_get_locked (self->lockscreen_manager)) ++ phosh_rotation_manager_claim_accelerometer (self, TRUE); ++ break; ++ default: ++ g_assert_not_reached (); ++ } ++ ++ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MODE]); ++ return TRUE; ++} ++ ++ ++void ++phosh_rotation_manager_set_transform (PhoshRotationManager *self, ++ PhoshMonitorTransform transform) ++{ ++ g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self)); ++ g_return_if_fail (self->mode == PHOSH_ROTATION_MANAGER_MODE_OFF); ++ ++ apply_transform (self, transform); ++} ++ ++PhoshMonitorTransform ++phosh_rotation_manager_get_transform (PhoshRotationManager *self) ++{ ++ g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (self), ++ PHOSH_MONITOR_TRANSFORM_NORMAL); ++ ++ return self->monitor->transform; ++} ++ ++/** ++ * phosh_rotation_manager_get_monitor: ++ * @self: The PhoshRotationManager ++ * ++ * Returns: The #PhoshMonitor this manager acts on ++ */ ++PhoshMonitor * ++phosh_rotation_manager_get_monitor (PhoshRotationManager *self) ++{ ++ g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (self), NULL); ++ ++ return self->monitor; ++} +diff --git a/src/rotation-manager.h b/src/rotation-manager.h +new file mode 100644 +index 00000000..b09926b5 +--- /dev/null ++++ b/src/rotation-manager.h +@@ -0,0 +1,45 @@ ++/* ++ * Copyright (C) 2021 Purism SPC ++ * ++ * SPDX-License-Identifier: GPL-3.0-or-later ++ */ ++#pragma once ++ ++#include "lockscreen-manager.h" ++#include "sensor-proxy-manager.h" ++#include "monitor/monitor.h" ++ ++G_BEGIN_DECLS ++ ++/** ++ * PhoshRotationManagerMode: ++ * @PHOSH_ROTATION_MANAGER_MODE_OFF: automatic rotation off ++ * @PHOSH_ROTATION_MANAGER_MODE_SENSOR: rotation driven by sensor orientation ++ * ++ * The mode of a #PhoshRotationManager ++ */ ++typedef enum { ++ PHOSH_ROTATION_MANAGER_MODE_OFF, ++ PHOSH_ROTATION_MANAGER_MODE_SENSOR, ++} PhoshRotationManagerMode; ++ ++#define PHOSH_TYPE_ROTATION_MANAGER (phosh_rotation_manager_get_type ()) ++ ++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 *monitor); ++void phosh_rotation_manager_set_orientation_locked (PhoshRotationManager *self, ++ gboolean locked); ++gboolean phosh_rotation_manager_get_orientation_locked (PhoshRotationManager *self); ++ ++PhoshRotationManagerMode phosh_rotation_manager_get_mode (PhoshRotationManager *self); ++gboolean phosh_rotation_manager_set_mode (PhoshRotationManager *self, ++ PhoshRotationManagerMode mode); ++void phosh_rotation_manager_set_transform (PhoshRotationManager *self, ++ PhoshMonitorTransform tranform); ++PhoshMonitorTransform phosh_rotation_manager_get_transform (PhoshRotationManager *self); ++PhoshMonitor *phosh_rotation_manager_get_monitor (PhoshRotationManager *self); ++ ++G_END_DECLS +diff --git a/src/shell.c b/src/shell.c +index 6f0d3663..57caff0d 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -59,6 +59,7 @@ + #include "proximity.h" + #include "quick-setting.h" + #include "rotateinfo.h" ++#include "rotation-manager.h" + #include "sensor-proxy-manager.h" + #include "screen-saver-manager.h" + #include "session-manager.h" +@@ -129,6 +130,7 @@ typedef struct + /* sensors */ + PhoshSensorProxyManager *sensor_proxy_manager; + PhoshProximity *proximity; ++ PhoshRotationManager *rotation_manager; + + gboolean startup_finished; + PhoshMonitorTransform transform; /* current rotation of primary monitor */ +@@ -372,7 +374,9 @@ phosh_shell_dispose (GObject *object) + + /* sensors */ + g_clear_object (&priv->proximity); ++ g_clear_object (&priv->rotation_manager); + g_clear_object (&priv->sensor_proxy_manager); ++ + phosh_system_prompter_unregister (); + g_clear_object (&priv->session_manager); + +@@ -1094,6 +1098,24 @@ phosh_shell_get_session_manager (PhoshShell *self) + } + + ++PhoshRotationManager * ++phosh_shell_get_rotation_manager (PhoshShell *self) ++{ ++ PhoshShellPrivate *priv; ++ ++ g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL); ++ priv = phosh_shell_get_instance_private (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); ++ ++ return priv->rotation_manager; ++} ++ + /** + * Returns the usable area in pixels usable by a client on the phone + * display +diff --git a/src/shell.h b/src/shell.h +index 1b21eef8..d7cfcdbd 100644 +--- a/src/shell.h ++++ b/src/shell.h +@@ -17,6 +17,7 @@ + #include "monitor-manager.h" + #include "monitor/monitor.h" + #include "osk-manager.h" ++#include "rotation-manager.h" + #include "session-manager.h" + #include "toplevel-manager.h" + #include "torch-manager.h" +@@ -79,6 +80,7 @@ PhoshWifiManager *phosh_shell_get_wifi_manager (PhoshShell *self); + PhoshFeedbackManager *phosh_shell_get_feedback_manager (PhoshShell *self); + PhoshBtManager *phosh_shell_get_bt_manager (PhoshShell *self); + PhoshWWan *phosh_shell_get_wwan (PhoshShell *self); ++PhoshRotationManager *phosh_shell_get_rotation_manager (PhoshShell *self); + PhoshTorchManager *phosh_shell_get_torch_manager (PhoshShell *self); + PhoshDockedManager *phosh_shell_get_docked_manager (PhoshShell *self); + PhoshHksManager * phosh_shell_get_hks_manager (PhoshShell *self); +-- +GitLab + + +From 9acef9b62ec219016b20c56640cb55bf8cfe0fd2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Tue, 23 Jun 2020 14:08:53 +0200 +Subject: [PATCH 08/19] rotateinfo: Display either rotation lock or orientation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Based on the rotation managers mode dislay appropriate information. + +Closes: #18 + +Signed-off-by: Guido Günther +--- + src/rotateinfo.c | 82 +++++++++++++++++++++++++++++++++++------------- + src/rotateinfo.h | 16 +++++++++- + 2 files changed, 76 insertions(+), 22 deletions(-) + +diff --git a/src/rotateinfo.c b/src/rotateinfo.c +index b673fa3d..1227d65d 100644 +--- a/src/rotateinfo.c ++++ b/src/rotateinfo.c +@@ -15,28 +15,35 @@ + + /** + * SECTION:rotateinfo +- * @short_description: A widget to display the rotate status ++ * @short_description: A widget to display the rotate lock status + * @Title: PhoshRotateInfo + * +- * Rotate Info widget ++ * A #PhoshStatusIcon to display the rotation lock status. ++ * It can either display whether a rotation lock is currently active or ++ * if the output is in portrait/landscape mode. + */ + + typedef struct _PhoshRotateInfo { +- PhoshStatusIcon parent; ++ PhoshStatusIcon parent; ++ ++ PhoshRotationManager *manager; + } PhoshRotateInfo; + + + G_DEFINE_TYPE (PhoshRotateInfo, phosh_rotate_info, PHOSH_TYPE_STATUS_ICON) + +- + static void +-set_state (PhoshRotateInfo *self) ++on_transform_changed (PhoshRotateInfo *self) + { + PhoshShell *shell = phosh_shell_get_default (); + PhoshMonitor *monitor = phosh_shell_get_primary_monitor (shell); + gboolean monitor_is_landscape; + gboolean portrait; + ++ if (phosh_rotation_manager_get_mode (self->manager) != PHOSH_ROTATION_MANAGER_MODE_OFF) { ++ return; ++ } ++ + switch (phosh_shell_get_transform (shell)) { + case PHOSH_MONITOR_TRANSFORM_NORMAL: + case PHOSH_MONITOR_TRANSFORM_FLIPPED: +@@ -71,37 +78,70 @@ set_state (PhoshRotateInfo *self) + + + static void +-phosh_rotate_info_finalize (GObject *object) ++on_orientation_lock_changed (PhoshRotateInfo *self) + { +- PhoshRotateInfo *self = PHOSH_ROTATE_INFO(object); ++ gboolean locked = phosh_rotation_manager_get_orientation_locked (self->manager); ++ const char *icon_name; + +- g_signal_handlers_disconnect_by_data (phosh_shell_get_default (), self); ++ if (phosh_rotation_manager_get_mode (self->manager) != PHOSH_ROTATION_MANAGER_MODE_SENSOR) ++ return; + +- G_OBJECT_CLASS (phosh_rotate_info_parent_class)->finalize (object); ++ g_debug ("Orientation locked: %d", locked); ++ ++ icon_name = locked ? "rotation-locked-symbolic" : "rotation-allowed-symbolic"; ++ phosh_status_icon_set_icon_name (PHOSH_STATUS_ICON (self), icon_name); ++ /* Translators: Automatic screen orientation is either on (enabled) or off (locked/disabled) */ ++ phosh_status_icon_set_info (PHOSH_STATUS_ICON (self), locked ? _("Off") : _("On")); ++ ++ return; + } + + + static void +-phosh_rotate_info_class_init (PhoshRotateInfoClass *klass) ++on_mode_changed (PhoshRotateInfo *self) + { +- GObjectClass *object_class = G_OBJECT_CLASS (klass); +- object_class->finalize = phosh_rotate_info_finalize; ++ PhoshRotationManagerMode mode = phosh_rotation_manager_get_mode (self->manager); ++ ++ g_debug ("Rotation manager mode: %d", mode); ++ switch (mode) { ++ case PHOSH_ROTATION_MANAGER_MODE_OFF: ++ on_transform_changed (self); ++ break; ++ case PHOSH_ROTATION_MANAGER_MODE_SENSOR: ++ on_orientation_lock_changed (self); ++ break; ++ default: ++ g_assert_not_reached (); ++ } + } + + + static void +-phosh_rotate_info_init (PhoshRotateInfo *self) ++phosh_rotate_info_class_init (PhoshRotateInfoClass *klass) + { +- g_signal_connect_swapped (phosh_shell_get_default (), +- "notify::transform", +- G_CALLBACK (set_state), +- self); +- set_state (self); + } + + +-GtkWidget * +-phosh_rotate_info_new (void) ++static void ++phosh_rotate_info_init (PhoshRotateInfo *self) + { +- return g_object_new (PHOSH_TYPE_ROTATE_INFO, NULL); ++ 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 (), ++ "notify::transform", ++ G_CALLBACK (on_transform_changed), ++ self, ++ G_CONNECT_SWAPPED); ++ g_signal_connect_object (self->manager, ++ "notify::orientation-locked", ++ G_CALLBACK (on_orientation_lock_changed), ++ self, ++ G_CONNECT_SWAPPED); ++ g_signal_connect_object (self->manager, ++ "notify::mode", ++ G_CALLBACK (on_mode_changed), ++ self, ++ G_CONNECT_SWAPPED); ++ on_mode_changed (self); + } +diff --git a/src/rotateinfo.h b/src/rotateinfo.h +index 2e05f818..1195fed6 100644 +--- a/src/rotateinfo.h ++++ b/src/rotateinfo.h +@@ -11,10 +11,24 @@ + + G_BEGIN_DECLS + ++/** ++ * PhoshRotateInfoMode: ++ * @PHOSH_ROTATE_INFO_MODE_LOCK: Button toggles rotation lock ++ * @PHOSH_ROTATE_INFO_MODE_TOGGLE: Button toggles potrait/landscape ++ * ++ * The power save mode of a monitor ++ */ ++typedef enum { ++ PHOSH_ROTATE_INFO_MODE_LOCK, ++ PHOSH_ROTATE_INFO_MODE_TOGGLE, ++} PhoshRotateInfoMode; ++ + #define PHOSH_TYPE_ROTATE_INFO (phosh_rotate_info_get_type()) + + G_DECLARE_FINAL_TYPE (PhoshRotateInfo, phosh_rotate_info, PHOSH, ROTATE_INFO, PhoshStatusIcon) + +-GtkWidget * phosh_rotate_info_new (void); ++GtkWidget *phosh_rotate_info_new (void); ++PhoshRotateInfoMode phosh_rotate_info_get_mode (PhoshRotateInfo *self); ++void phosh_rotate_info_set_mode (PhoshRotateInfo *self, PhoshRotateInfoMode mode); + + G_END_DECLS +-- +GitLab + + +From a30f0717605e0b79076da433e093774b77085b1b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Tue, 23 Jun 2020 14:10:38 +0200 +Subject: [PATCH 09/19] settings: Add orientation lock to rotate quick setting +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Long press switches between potrait/landscape and rotation lock. + +Signed-off-by: Guido Günther +--- + src/settings.c | 54 ++++++++++++++++++++++++++++++++++++++--- + src/ui/settings-menu.ui | 1 + + 2 files changed, 51 insertions(+), 4 deletions(-) + +diff --git a/src/settings.c b/src/settings.c +index eb55486e..57d48182 100644 +--- a/src/settings.c ++++ b/src/settings.c +@@ -20,6 +20,7 @@ + #include "feedback-manager.h" + #include "notifications/notify-manager.h" + #include "notifications/notification-frame.h" ++#include "rotateinfo.h" + + #include + #include "gvc-mixer-control.h" +@@ -82,16 +83,60 @@ static void + rotation_setting_clicked_cb (PhoshSettings *self) + { + PhoshShell *shell = phosh_shell_get_default (); ++ PhoshRotationManager *rotation_manager; ++ PhoshRotationManagerMode mode; + PhoshMonitorTransform transform; ++ gboolean locked; + + g_return_if_fail (PHOSH_IS_SETTINGS (self)); +- transform = phosh_shell_get_transform (shell); +- phosh_shell_set_transform (shell, transform == PHOSH_MONITOR_TRANSFORM_NORMAL +- ? PHOSH_MONITOR_TRANSFORM_270 +- : PHOSH_MONITOR_TRANSFORM_NORMAL); ++ ++ rotation_manager = phosh_shell_get_rotation_manager (shell); ++ g_return_if_fail (rotation_manager); ++ mode = phosh_rotation_manager_get_mode (PHOSH_ROTATION_MANAGER (rotation_manager)); ++ ++ switch (mode) { ++ case PHOSH_ROTATION_MANAGER_MODE_OFF: ++ transform = phosh_shell_get_transform (shell); ++ phosh_shell_set_transform (shell, transform == PHOSH_MONITOR_TRANSFORM_NORMAL ++ ? PHOSH_MONITOR_TRANSFORM_270 ++ : PHOSH_MONITOR_TRANSFORM_NORMAL); ++ break; ++ case PHOSH_ROTATION_MANAGER_MODE_SENSOR: ++ locked = phosh_rotation_manager_get_orientation_locked (rotation_manager); ++ phosh_rotation_manager_set_orientation_locked (rotation_manager, !locked); ++ break; ++ default: ++ g_assert_not_reached (); ++ } ++ + g_signal_emit (self, signals[SETTING_DONE], 0); + } + ++static void ++rotation_setting_long_pressed_cb (PhoshSettings *self) ++{ ++ PhoshShell *shell = phosh_shell_get_default (); ++ PhoshRotateInfoMode mode; ++ PhoshRotationManager *rotation_manager; ++ ++ rotation_manager = phosh_shell_get_rotation_manager (shell); ++ g_return_if_fail (rotation_manager); ++ ++ mode = phosh_rotation_manager_get_mode (rotation_manager); ++ switch (mode) { ++ case PHOSH_ROTATION_MANAGER_MODE_OFF: ++ mode = PHOSH_ROTATION_MANAGER_MODE_SENSOR; ++ break; ++ case PHOSH_ROTATION_MANAGER_MODE_SENSOR: ++ mode = PHOSH_ROTATION_MANAGER_MODE_OFF; ++ break; ++ default: ++ g_assert_not_reached (); ++ } ++ g_debug ("Rotation manager mode: %d", mode); ++ phosh_rotation_manager_set_mode (rotation_manager, mode); ++} ++ + static void + feedback_setting_clicked_cb (PhoshSettings *self) + { +@@ -481,6 +526,7 @@ phosh_settings_class_init (PhoshSettingsClass *klass) + gtk_widget_class_bind_template_callback (widget_class, feedback_setting_long_pressed_cb); + gtk_widget_class_bind_template_callback (widget_class, on_media_player_raised); + gtk_widget_class_bind_template_callback (widget_class, rotation_setting_clicked_cb); ++ gtk_widget_class_bind_template_callback (widget_class, rotation_setting_long_pressed_cb); + gtk_widget_class_bind_template_callback (widget_class, torch_setting_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, wifi_setting_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, wwan_setting_clicked_cb); +diff --git a/src/ui/settings-menu.ui b/src/ui/settings-menu.ui +index da196806..af7ee9ce 100644 +--- a/src/ui/settings-menu.ui ++++ b/src/ui/settings-menu.ui +@@ -95,6 +95,7 @@ + True + False + ++ + + + True +-- +GitLab + + +From 48235828793eb44971e59a725cfaab7a9102ea65 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 26 Mar 2021 10:00:37 +0100 +Subject: [PATCH 10/19] Move Lockscreen rotation fixup to rotation-manager +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +No need to have several objects involved. This avoids +lockscreen and rotation manager racing since we can +do it past the unclaim of the accelerometer. + +Signed-off-by: Guido Günther +--- + src/lockscreen-manager.c | 38 ------------------- + src/rotation-manager.c | 82 +++++++++++++++++++++++++++++++++++++++- + 2 files changed, 80 insertions(+), 40 deletions(-) + +diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c +index 54041c5c..0c8c16b0 100644 +--- a/src/lockscreen-manager.c ++++ b/src/lockscreen-manager.c +@@ -77,10 +77,6 @@ lockscreen_unlock_cb (PhoshLockscreenManager *self, PhoshLockscreen *lockscreen) + 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); +@@ -171,35 +167,6 @@ 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 (); +- 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; +- +- /* 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); +- break; +- case PHOSH_MONITOR_POWER_SAVE_MODE_OFF: +- break; +- default: +- g_warn_if_reached (); +- } +-} + + static void + lock_primary_monitor (PhoshLockscreenManager *self) +@@ -209,7 +176,6 @@ lock_primary_monitor (PhoshLockscreenManager *self) + PhoshShell *shell = phosh_shell_get_default (); + + primary_monitor = phosh_shell_get_primary_monitor (shell); +- self->transform = phosh_shell_get_transform (shell); + + /* The primary output gets the clock, keypad, ... */ + self->lockscreen = PHOSH_LOCKSCREEN (phosh_lockscreen_new ( +@@ -222,10 +188,6 @@ 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` */ + } +diff --git a/src/rotation-manager.c b/src/rotation-manager.c +index ba847553..b22b58de 100644 +--- a/src/rotation-manager.c ++++ b/src/rotation-manager.c +@@ -47,6 +47,7 @@ typedef struct _PhoshRotationManager { + PhoshSensorProxyManager *sensor_proxy_manager; + PhoshLockscreenManager *lockscreen_manager; + PhoshMonitor *monitor; ++ PhoshMonitorTransform prelock_transform; + + GSettings *settings; + gboolean orientation_locked; +@@ -210,6 +211,67 @@ on_has_accelerometer_changed (PhoshRotationManager *self, + phosh_rotation_manager_set_mode (self, mode); + } + ++/** ++ * fixup_lockscreen_orientation: ++ * @self: The PhoshRotationManager ++ * @force: Whether to force the monitor to normal orientation ++ * ++ * On phones the lock screen doesn't work in landscape so fix that ++ * until https://source.puri.sm/Librem5/phosh/-/issues/388 ++ * is fixed. Keep all of this local to this function. ++ */ ++static void ++fixup_lockscreen_orientation (PhoshRotationManager *self, gboolean force) ++{ ++ PhoshShell *shell = phosh_shell_get_default (); ++ 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)); ++ ++ /* Only bother on phones */ ++ if (phosh_mode_manager_get_device_type(mode_manager) != PHOSH_MODE_DEVICE_TYPE_PHONE && ++ phosh_mode_manager_get_device_type(mode_manager) != PHOSH_MODE_DEVICE_TYPE_UNKNOWN) ++ return; ++ ++ /* Don't mess with transforms on external screens either */ ++ if (!phosh_monitor_is_builtin (self->monitor)) ++ return; ++ ++ if (phosh_lockscreen_manager_get_locked (self->lockscreen_manager)) { ++ if (force) { ++ g_debug ("Forcing normal transform"); ++ apply_transform (self, PHOSH_MONITOR_TRANSFORM_NORMAL); ++ } else { ++ self->prelock_transform = phosh_monitor_get_transform (self->monitor); ++ g_debug ("Saving transform %d", self->prelock_transform); ++ } ++ } else { ++ g_debug ("Restoring transform %d", self->prelock_transform); ++ apply_transform (self, self->prelock_transform); ++ } ++} ++ ++ ++static void ++on_power_mode_changed (PhoshRotationManager *self, ++ GParamSpec *pspec, ++ PhoshMonitor *monitor) ++{ ++ PhoshMonitorPowerSaveMode mode; ++ ++ g_return_if_fail (PHOSH_IS_ROTATION_MANAGER (self)); ++ g_return_if_fail (PHOSH_IS_MONITOR (monitor)); ++ ++ mode = phosh_monitor_get_power_save_mode (monitor); ++ g_debug ("Mode: %d", mode); ++ if (mode != PHOSH_MONITOR_POWER_SAVE_MODE_ON) ++ return; ++ ++ fixup_lockscreen_orientation (self, TRUE); ++} ++ ++ + static void + on_lockscreen_manager_locked (PhoshRotationManager *self, GParamSpec *pspec, + PhoshLockscreenManager *lockscreen_manager) +@@ -225,6 +287,8 @@ on_lockscreen_manager_locked (PhoshRotationManager *self, GParamSpec *pspec, + claim = !phosh_lockscreen_manager_get_locked (self->lockscreen_manager); + + phosh_rotation_manager_claim_accelerometer (self, claim); ++ ++ fixup_lockscreen_orientation (self, FALSE); + } + + static void +@@ -321,8 +385,17 @@ phosh_rotation_manager_constructed (GObject *object) + self); + on_lockscreen_manager_locked (self, NULL, self->lockscreen_manager); + +- if (!self->sensor_proxy_manager) ++ g_signal_connect_swapped (self->monitor, ++ "notify::power-mode", ++ (GCallback) on_power_mode_changed, ++ self); ++ on_power_mode_changed (self, NULL, self->monitor); ++ ++ ++ if (!self->sensor_proxy_manager) { ++ g_warning ("Got not sensor-proxy, no automatic rotation"); + return; ++ } + + g_signal_connect_swapped (self->sensor_proxy_manager, + "notify::accelerometer-orientation", +@@ -358,7 +431,12 @@ phosh_rotation_manager_dispose (GObject *object) + self); + g_clear_object (&self->lockscreen_manager); + } +- g_clear_object (&self->monitor); ++ ++ if (self->monitor) { ++ g_signal_handlers_disconnect_by_data (self->monitor, ++ self); ++ g_clear_object (&self->monitor); ++ } + + G_OBJECT_CLASS (phosh_rotation_manager_parent_class)->dispose (object); + } +-- +GitLab + + +From e4fd28cd54c1a03c9afb1ca209eda0bd333089ee Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 26 Mar 2021 10:14:54 +0100 +Subject: [PATCH 11/19] settings: Use rotation-manager instead of shell to + rotate output +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This makes sure the same output is rotated via manual rotation and +sensor. + +Signed-off-by: Guido Günther +--- + src/settings.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/src/settings.c b/src/settings.c +index 57d48182..54a60d9a 100644 +--- a/src/settings.c ++++ b/src/settings.c +@@ -96,10 +96,9 @@ rotation_setting_clicked_cb (PhoshSettings *self) + + switch (mode) { + case PHOSH_ROTATION_MANAGER_MODE_OFF: +- transform = phosh_shell_get_transform (shell); +- phosh_shell_set_transform (shell, transform == PHOSH_MONITOR_TRANSFORM_NORMAL +- ? PHOSH_MONITOR_TRANSFORM_270 +- : PHOSH_MONITOR_TRANSFORM_NORMAL); ++ transform = phosh_rotation_manager_get_transform (rotation_manager) ? ++ PHOSH_MONITOR_TRANSFORM_NORMAL : PHOSH_MONITOR_TRANSFORM_270; ++ phosh_rotation_manager_set_transform (rotation_manager, transform); + break; + case PHOSH_ROTATION_MANAGER_MODE_SENSOR: + locked = phosh_rotation_manager_get_orientation_locked (rotation_manager); +-- +GitLab + + +From 7e574bd2ccaad5861d1c8f8d22ade1f2f96207cc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 26 Mar 2021 10:31:31 +0100 +Subject: [PATCH 12/19] rotateinfo: Use monitor form rotation-manager + consistently +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +So far this was dependent on mode + +Signed-off-by: Guido Günther +--- + src/rotateinfo.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/rotateinfo.c b/src/rotateinfo.c +index 1227d65d..ecfc9cf3 100644 +--- a/src/rotateinfo.c ++++ b/src/rotateinfo.c +@@ -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; + +-- +GitLab + + +From 9e56eb92a30f6d25d44294bc9221a1818c6ea8b6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 26 Mar 2021 10:31:31 +0100 +Subject: [PATCH 13/19] rotateinfo: Use monitor form rotation-manager + consistently +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Priort to the rotation-manager this incorrectly tracked the primary +monitor, track the rotated monitor instead. + +Signed-off-by: Guido Günther +--- + src/rotateinfo.c | 2 +- + src/rotation-manager.c | 38 ++++++++++++++++++++++++++++++++++++++ + 2 files changed, 39 insertions(+), 1 deletion(-) + +diff --git a/src/rotateinfo.c b/src/rotateinfo.c +index ecfc9cf3..149b5d4d 100644 +--- a/src/rotateinfo.c ++++ b/src/rotateinfo.c +@@ -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, +diff --git a/src/rotation-manager.c b/src/rotation-manager.c +index b22b58de..1a4263d9 100644 +--- a/src/rotation-manager.c ++++ b/src/rotation-manager.c +@@ -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); + } + +-- +GitLab + + +From 54f2e80e2a5b5e977130aaf005deb26ddf232db9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 26 Mar 2021 10:45:19 +0100 +Subject: [PATCH 14/19] shell: Drop transform handling +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is done by the rotation-manager which always acts on the +given monitor. + +Closes: #56 + +Signed-off-by: Guido Günther +--- + src/shell.c | 36 ------------------------------------ + src/shell.h | 2 -- + 2 files changed, 38 deletions(-) + +diff --git a/src/shell.c b/src/shell.c +index 57caff0d..3fcd83ba 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -512,10 +512,6 @@ setup_idle_cb (PhoshShell *self) + g_getenv ("DESKTOP_AUTOSTART_ID")); + g_unsetenv ("DESKTOP_AUTOSTART_ID"); + +- /* If we start rotated, fix this up */ +- if (phosh_shell_get_transform (self) != PHOSH_MONITOR_TRANSFORM_NORMAL) +- phosh_shell_set_transform (self, PHOSH_MONITOR_TRANSFORM_NORMAL); +- + priv->gnome_shell_manager = phosh_gnome_shell_manager_get_default (); + + priv->startup_finished = TRUE; +@@ -772,38 +768,6 @@ phosh_shell_init (PhoshShell *self) + } + + +-PhoshMonitorTransform +-phosh_shell_get_transform (PhoshShell *self) +-{ +- PhoshShellPrivate *priv; +- +- g_return_val_if_fail (PHOSH_IS_SHELL (self), PHOSH_MONITOR_TRANSFORM_NORMAL); +- priv = phosh_shell_get_instance_private (self); +- g_return_val_if_fail (priv->primary_monitor, PHOSH_MONITOR_TRANSFORM_NORMAL); +- return phosh_monitor_get_transform (priv->primary_monitor); +-} +- +- +-void +-phosh_shell_set_transform (PhoshShell *self, +- PhoshMonitorTransform transform) +-{ +- 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); +- if (current == transform) +- return; +- +- phosh_monitor_manager_set_monitor_transform (priv->monitor_manager, +- priv->primary_monitor, +- transform); +- phosh_monitor_manager_apply_monitor_config (priv->monitor_manager); +- /* Notification change signalled in on_primary_monitor_configured */ +-} +- +- + void + phosh_shell_set_primary_monitor (PhoshShell *self, PhoshMonitor *monitor) + { +diff --git a/src/shell.h b/src/shell.h +index d7cfcdbd..d7aee9d5 100644 +--- a/src/shell.h ++++ b/src/shell.h +@@ -57,8 +57,6 @@ G_BEGIN_DECLS + G_DECLARE_FINAL_TYPE (PhoshShell, phosh_shell, PHOSH, SHELL, GObject) + + PhoshShell *phosh_shell_get_default (void); +-void phosh_shell_set_transform (PhoshShell *self, PhoshMonitorTransform transform); +-PhoshMonitorTransform phosh_shell_get_transform (PhoshShell *self); + void phosh_shell_get_usable_area (PhoshShell *self, + int *x, + int *y, +-- +GitLab + + +From 1b08c29410e6eb5327b59928226e2d62e6707384 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Fri, 26 Mar 2021 15:01:24 +0100 +Subject: [PATCH 15/19] rotation-manager: Mess with transform as little as + possible +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On phones when we're already using portrait orientation don't bother +fixing this up. This allows for e.g. upside down operation. + +Signed-off-by: Guido Günther +--- + src/rotation-manager.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/rotation-manager.c b/src/rotation-manager.c +index 1a4263d9..c5d8d541 100644 +--- a/src/rotation-manager.c ++++ b/src/rotation-manager.c +@@ -216,9 +216,9 @@ on_has_accelerometer_changed (PhoshRotationManager *self, + /** + * fixup_lockscreen_orientation: + * @self: The PhoshRotationManager +- * @force: Whether to force the monitor to normal orientation ++ * @force: Whether to force the monitor to portait orientation + * +- * On phones the lock screen doesn't work in landscape so fix that ++ * On phones the lock screen doesn't work in landscape so fix that up + * until https://source.puri.sm/Librem5/phosh/-/issues/388 + * is fixed. Keep all of this local to this function. + */ +@@ -242,8 +242,12 @@ fixup_lockscreen_orientation (PhoshRotationManager *self, gboolean force) + + if (phosh_lockscreen_manager_get_locked (self->lockscreen_manager)) { + if (force) { +- g_debug ("Forcing normal transform"); +- apply_transform (self, PHOSH_MONITOR_TRANSFORM_NORMAL); ++ PhoshMonitorTransform transform; ++ /* Use prelock transform if portrait, else use normal */ ++ transform = (self->prelock_transform % 2) == 0 ? self->prelock_transform : ++ PHOSH_MONITOR_TRANSFORM_NORMAL; ++ g_debug ("Forcing portrait transform: %d", transform); ++ apply_transform (self, transform); + } else { + self->prelock_transform = phosh_monitor_get_transform (self->monitor); + g_debug ("Saving transform %d", self->prelock_transform); +-- +GitLab + + +From 6e306eca5bfa8a73f53d99bbce9de123b8e1e595 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Sun, 28 Mar 2021 19:27:06 +0200 +Subject: [PATCH 16/19] settings: Don't close menu when toggling rotation lock +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This makes it consistent with other toggles like feedback toggle. + +Signed-off-by: Guido Günther +--- + src/settings.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/src/settings.c b/src/settings.c +index 54a60d9a..81a095c9 100644 +--- a/src/settings.c ++++ b/src/settings.c +@@ -99,6 +99,7 @@ rotation_setting_clicked_cb (PhoshSettings *self) + transform = phosh_rotation_manager_get_transform (rotation_manager) ? + PHOSH_MONITOR_TRANSFORM_NORMAL : PHOSH_MONITOR_TRANSFORM_270; + phosh_rotation_manager_set_transform (rotation_manager, transform); ++ g_signal_emit (self, signals[SETTING_DONE], 0); + break; + case PHOSH_ROTATION_MANAGER_MODE_SENSOR: + locked = phosh_rotation_manager_get_orientation_locked (rotation_manager); +@@ -107,8 +108,6 @@ rotation_setting_clicked_cb (PhoshSettings *self) + default: + g_assert_not_reached (); + } +- +- g_signal_emit (self, signals[SETTING_DONE], 0); + } + + static void +-- +GitLab + + +From e7727ada0a5a9c9e3e197af914be145d1d735525 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Guido=20G=C3=BCnther?= +Date: Mon, 29 Mar 2021 17:18:16 +0200 +Subject: [PATCH 17/19] monitor: Update org.gnome.Mutter.DisplayConfig +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is from mutter's 331b5f356311f1dcfc1b580e349a60d25fc0e34f + +Signed-off-by: Guido Günther +--- + src/monitor/org.gnome.Mutter.DisplayConfig.xml | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +diff --git a/src/monitor/org.gnome.Mutter.DisplayConfig.xml b/src/monitor/org.gnome.Mutter.DisplayConfig.xml +index fe8e0229..044244e4 100644 +--- a/src/monitor/org.gnome.Mutter.DisplayConfig.xml ++++ b/src/monitor/org.gnome.Mutter.DisplayConfig.xml +@@ -101,7 +101,7 @@ + or not + - "presentation" (b): whether this output is + for presentation only +- Note: properties might be ignored if not consistenly ++ Note: properties might be ignored if not consistently + applied to all outputs in the same clone group. In + general, it's expected that presentation or primary + outputs will not be cloned. +@@ -282,6 +282,14 @@ + --> + + ++ ++ ++ +