From 36989a3ba97f1919b50d8805ee60c6a6e1ae2168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 15 Jun 2024 10:41:50 +0200 Subject: [PATCH 1/8] proximity: Fix typo in comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gbp-Dch: Ignore Signed-off-by: Guido Günther Part-of: --- src/proximity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proximity.c b/src/proximity.c index 3a8ca4aa2..aa5ce72d1 100644 --- a/src/proximity.c +++ b/src/proximity.c @@ -164,7 +164,7 @@ on_has_proximity_changed (PhoshProximity *self, 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 the proxy went a way we always unclaim but only claim on ongoing calls: */ if (!phosh_calls_manager_get_active_call_handle (self->calls_manager) && has_proximity) return; -- GitLab From 392d011bbd85da8ed44be9c33aa90484b3b38949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 18 Jun 2024 17:08:48 +0200 Subject: [PATCH 2/8] calls-manager: Fix indent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gbp-Dch: Ignore Signed-off-by: Guido Günther Part-of: --- src/calls-manager.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/calls-manager.c b/src/calls-manager.c index 5cbd7316b..ab08086b3 100644 --- a/src/calls-manager.c +++ b/src/calls-manager.c @@ -111,7 +111,7 @@ on_call_state_changed (PhoshCallsManager *self, } if (!is_active (state)) - return; + return; /* New active call */ g_free (self->active_call); @@ -450,13 +450,13 @@ phosh_calls_manager_class_init (PhoshCallsManagerClass *klass) g_object_class_install_properties (object_class, PROP_LAST_PROP, props); signals[CALL_ADDED] = g_signal_new ("call-added", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, NULL, NULL, - NULL, - G_TYPE_NONE, - 1, - G_TYPE_STRING); + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + NULL, + G_TYPE_NONE, + 1, + G_TYPE_STRING); signals[CALL_REMOVED] = g_signal_new ("call-removed", G_TYPE_FROM_CLASS (klass), -- GitLab From b11b04387f91b9b3f047a50483e65372ea65eb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 14 Jun 2024 22:03:03 +0200 Subject: [PATCH 3/8] keyboard-events: Drop fallback for ancient phoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther Part-of: --- src/keyboard-events.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/keyboard-events.c b/src/keyboard-events.c index 6de0dc30a..1ae11a06f 100644 --- a/src/keyboard-events.c +++ b/src/keyboard-events.c @@ -52,17 +52,6 @@ handle_accelerator_activated_event (void *data, pressed = g_variant_new_boolean (TRUE); g_action_group_activate_action (G_ACTION_GROUP (self), action, pressed); - - /* - * Emulate key released when running against older phoc, can be - * removed once we require phoc 0.26.0 - */ - if ((phosh_private_keyboard_event_get_version (kbevent) < - PHOSH_PRIVATE_KEYBOARD_EVENT_ACCELERATOR_RELEASED_EVENT_SINCE_VERSION) && - g_action_group_get_action_parameter_type (G_ACTION_GROUP (self), action)) { - g_warning_once ("Emulating accelerator up. Please upgrade phoc"); - g_action_group_activate_action (G_ACTION_GROUP (self), action, g_variant_new_boolean (FALSE)); - } } -- GitLab From 5adcd97983e5438886366a18b075c945b110be0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 15 Jun 2024 08:48:38 +0200 Subject: [PATCH 4/8] feedback-manager: Allow to set profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther Part-of: --- src/feedback-manager.c | 13 +++++++++++-- src/feedback-manager.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/feedback-manager.c b/src/feedback-manager.c index dd1f55eb0..77362b8a2 100644 --- a/src/feedback-manager.c +++ b/src/feedback-manager.c @@ -238,6 +238,16 @@ phosh_feedback_manager_get_profile (PhoshFeedbackManager *self) } +void +phosh_feedback_manager_set_profile (PhoshFeedbackManager *self, const char *profile) +{ + g_return_if_fail (PHOSH_IS_FEEDBACK_MANAGER (self)); + + g_debug ("Setting feedback profile to %s", profile); + lfb_set_feedback_profile (profile); +} + + void phosh_feedback_manager_toggle (PhoshFeedbackManager *self) { @@ -252,8 +262,7 @@ phosh_feedback_manager_toggle (PhoshFeedbackManager *self) else if (!g_strcmp0 (old, "full")) profile = "quiet"; - g_debug ("Setting feedback profile to %s, was %s", profile, old); - lfb_set_feedback_profile (profile); + phosh_feedback_manager_set_profile (self, profile); } diff --git a/src/feedback-manager.h b/src/feedback-manager.h index de7177401..806097e09 100644 --- a/src/feedback-manager.h +++ b/src/feedback-manager.h @@ -21,6 +21,7 @@ PhoshFeedbackManager *phosh_feedback_manager_new (void); void phosh_feedback_manager_toggle (PhoshFeedbackManager *self); const char * phosh_feedback_manager_get_icon_name (PhoshFeedbackManager *self); const char * phosh_feedback_manager_get_profile (PhoshFeedbackManager *self); +void phosh_feedback_manager_set_profile (PhoshFeedbackManager *self, const char *profile); void phosh_feedback_manager_trigger_feedback (PhoshFeedbackManager *self, const char *event); void phosh_trigger_feedback (const char *name); void phosh_connect_feedback (GtkWidget *widget); -- GitLab From 9a4c1546bce17cdbee552bd01332a3feb97f3832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 15 Jun 2024 08:49:04 +0200 Subject: [PATCH 5/8] keyboard-events: Emit signal on keybinding press MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Emit a signal when a subscribed keybinding is pressed. This allows other parts of the shell to perform additional activities on global keybindings (that possibly aren't even subscribed by Phosh itself). Signed-off-by: Guido Günther Part-of: --- src/keyboard-events.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/keyboard-events.c b/src/keyboard-events.c index 1ae11a06f..f2df4cb88 100644 --- a/src/keyboard-events.c +++ b/src/keyboard-events.c @@ -19,6 +19,13 @@ * Grabs and manages special keyboard events */ +enum { + PRESSED, + RELEASED, + N_SIGNALS +}; +static guint signals[N_SIGNALS] = { 0 }; + struct _PhoshKeyboardEvents { GSimpleActionGroup parent; @@ -47,6 +54,7 @@ handle_accelerator_activated_event (void *data, g_debug ("Accelerator %d activated: %s", action_id, action); g_return_if_fail (g_action_group_has_action (G_ACTION_GROUP (self), action)); + g_signal_emit (self, signals[PRESSED], 0, action); if (g_action_group_get_action_parameter_type (G_ACTION_GROUP (self), action)) pressed = g_variant_new_boolean (TRUE); @@ -70,6 +78,7 @@ handle_accelerator_released_event (void *data, g_debug ("Accelerator %d released: %s", action_id, action); g_return_if_fail (g_action_group_has_action (G_ACTION_GROUP (self), action)); + g_signal_emit (self, signals[RELEASED], 0, action); /* Action doesn't have a parameter so we only notify press */ if (g_action_group_get_action_parameter_type (G_ACTION_GROUP (self), action) == NULL) @@ -265,6 +274,33 @@ phosh_keyboard_events_class_init (PhoshKeyboardEventsClass *klass) object_class->dispose = phosh_keyboard_events_dispose; object_class->finalize = phosh_keyboard_events_finalize; + + /** + * PhoshKeyboardEvents::pressed: + * @self: The keyboard-events instance + * @combo: The pressed global shortcut as string + * + * Emitted when a subscribed key binding was pressed. + */ + signals[PRESSED] = g_signal_new ("pressed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, + 1, G_TYPE_STRING); + /** + * PhoshKeyboardEvents::released: + * @self: The keyboard-events instance + * @combo: The released global shortcut as string + * + * Emitted when a subscribed key binding was released. + */ + signals[RELEASED] = g_signal_new ("released", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, + 1, G_TYPE_STRING); } -- GitLab From 878141b5f4c75759c94dfb07c46a713924324685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 15 Jun 2024 09:23:42 +0200 Subject: [PATCH 6/8] calls-manager: Track incoming state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to check if the active call is in incoming state. As with the rest of calls manager this will need some tweaking once calls handles multiple active calls. Signed-off-by: Guido Günther Part-of: --- src/calls-manager.c | 21 ++++++++++++++++----- src/calls-manager.h | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/calls-manager.c b/src/calls-manager.c index ab08086b3..88138f5a9 100644 --- a/src/calls-manager.c +++ b/src/calls-manager.c @@ -100,9 +100,12 @@ on_call_state_changed (PhoshCallsManager *self, g_debug ("Call %s, state %d", path, state); if (g_strcmp0 (path, self->active_call) == 0) { - /* current active call became inactive> */ + + self->incoming = state == PHOSH_CALL_STATE_INCOMING; + /* current active call became inactive */ if (!is_active (state)) { 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 */ @@ -117,6 +120,8 @@ on_call_state_changed (PhoshCallsManager *self, g_free (self->active_call); self->active_call = g_strdup (path); g_debug ("New active call %s", path); + self->incoming = state == PHOSH_CALL_STATE_INCOMING; + g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVE_CALL]); } @@ -432,7 +437,6 @@ phosh_calls_manager_class_init (PhoshCallsManagerClass *klass) G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); - /** * PhoshCallsManager:active-call: * @@ -497,9 +501,16 @@ phosh_calls_manager_get_present (PhoshCallsManager *self) return self->present; } - -int -phosh_calls_manager_get_incoming (PhoshCallsManager *self) +/** + * phosh_calls_manager_has_incoming_call: + * @self: The calls manager + * + * Whether there's currently an incoming call + * + * Returns: `TRUE` if there's an incoming call + */ +gboolean +phosh_calls_manager_has_incoming_call (PhoshCallsManager *self) { g_return_val_if_fail (PHOSH_IS_CALLS_MANAGER (self), FALSE); diff --git a/src/calls-manager.h b/src/calls-manager.h index eebc77676..a5656cee9 100644 --- a/src/calls-manager.h +++ b/src/calls-manager.h @@ -37,7 +37,7 @@ G_DECLARE_FINAL_TYPE (PhoshCallsManager, phosh_calls_manager, PHOSH, CALLS_MANAG PhoshCallsManager *phosh_calls_manager_new (void); gboolean phosh_calls_manager_get_present (PhoshCallsManager *self); -gboolean phosh_calls_manager_get_incoming (PhoshCallsManager *self); +gboolean phosh_calls_manager_has_incoming_call (PhoshCallsManager *self); const char *phosh_calls_manager_get_active_call_handle (PhoshCallsManager *self); PhoshCall *phosh_calls_manager_get_call (PhoshCallsManager *self, const char *handle); -- GitLab From 5699bc8b733900d474ad45094ddc9dee261e876d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 4 Jul 2024 11:19:08 +0200 Subject: [PATCH 7/8] build: Bump feedbackd dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want 0.4.0 as only this does end running events on profile changes. Signed-off-by: Guido Günther Part-of: --- debian/control | 4 ++-- meson.build | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index 603d78037..d8eb7e6ab 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,7 @@ Build-Depends: libjson-glib-dev, libsecret-1-dev, libsystemd-dev, - libfeedback-dev (>= 0.2.0), + libfeedback-dev (>= 0.4.0), libfribidi-dev, libgcr-3-dev, libgnome-bluetooth-3.0-dev, @@ -65,7 +65,7 @@ Depends: libcap2-bin, phoc (>= 0.33.0), Recommends: - feedbackd, + feedbackd (>= 0.4.0), fonts-cantarell, gnome-session-bin, gnome-session-common, diff --git a/meson.build b/meson.build index 3ecc7765d..af5f49691 100644 --- a/meson.build +++ b/meson.build @@ -155,7 +155,7 @@ libcall_ui = subproject('libcall-ui', 'install-i18n=@0@'.format(get_option('callui-i18n')), ]) libfeedback_dep = dependency('libfeedback-0.0', - version: '>= 0.2.0', + version: '>= 0.4.0', fallback: ['libfeedback', 'libfeedback_dep'], default_options: ['introspection=disabled', 'daemon=false', 'gtk_doc=false'] ) -- GitLab From b4fc7b5bda5cce28474b21af3fbdb303b87e0df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 15 Jun 2024 09:02:03 +0200 Subject: [PATCH 8/8] shell: Allow to silence the device on incoming calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the shell is locked and there's an incoming call pressing the button to lower the volume will put the device into silent mode. Bump copyright while at that as this didn't happen since some time. Closes: https://gitlab.gnome.org/World/Phosh/phosh/-/issues/780 Signed-off-by: Guido Günther Part-of: --- data/sm.puri.phosh.gschema.xml | 14 ++++++++++++-- src/shell.c | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/data/sm.puri.phosh.gschema.xml b/data/sm.puri.phosh.gschema.xml index e4e7f3e4d..fe0bcc37a 100644 --- a/data/sm.puri.phosh.gschema.xml +++ b/data/sm.puri.phosh.gschema.xml @@ -70,8 +70,18 @@ false Whether to enable suspend from the power menu - Setting this to true allows manually suspending the device from the power menu. - Suspend is an experimental feature on some devices and may result in crashes or instability. + Setting this to true allows manually suspending the device from the power menu. + Suspend is an experimental feature on some devices and may result in crashes or instability. + + + + + false + Allow to quickly silence the device + + Setting this to true allows to set the phone to silent by + pressing volume-down on incoming calls when the phone is locked. + This feature is experimental. diff --git a/src/shell.c b/src/shell.c index ab147d2f2..3a15d8ca7 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2018 Purism SPC + * 2023-2024 The Phosh Develpoers * * SPDX-License-Identifier: GPL-3.0-or-later * @@ -961,6 +962,25 @@ on_monitor_removed (PhoshShell *self, PhoshMonitor *monitor) } +static void +on_keyboard_events_pressed (PhoshShell *self, const char *combo) +{ + PhoshShellPrivate *priv = phosh_shell_get_instance_private (self); + + if (!phosh_calls_manager_has_incoming_call (priv->calls_manager)) + return; + + if (!g_settings_get_boolean (priv->settings, "quick-silent")) + return; + + if (g_strcmp0 (combo, "XF86AudioLowerVolume")) + return; + + g_debug ("Vol down pressed, silencing device"); + phosh_feedback_manager_set_profile (priv->feedback_manager, "silent"); +} + + static void phosh_shell_constructed (GObject *object) { @@ -1031,6 +1051,10 @@ phosh_shell_constructed (GObject *object) priv->feedback_manager = phosh_feedback_manager_new (); priv->keyboard_events = phosh_keyboard_events_new (); + g_signal_connect_swapped (priv->keyboard_events, + "pressed", + G_CALLBACK (on_keyboard_events_pressed), + self); id = g_idle_add ((GSourceFunc) setup_idle_cb, self); g_source_set_name_by_id (id, "[PhoshShell] idle"); -- GitLab