From 68bc012e8486a1af5f4423d6226f9f7ca7ddfc8b Mon Sep 17 00:00:00 2001
From: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com>
Date: Wed, 11 Apr 2018 16:43:07 -0400
Subject: [PATCH] fix: close preferences when going to background
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Whenever we go to background and preferences are open, close
the preferences view before. This avoids the annoying situation
where ring is in preview mode and the camera continues recording
the user.

Change-Id: I10bcb2f8b46c5750757763913fcd6b0e1e635302
Tuleap: #1851
Reviewed-by: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
---
 src/ring_client.cpp    | 1 +
 src/ringmainwindow.cpp | 9 +++++++++
 src/ringmainwindow.h   | 1 +
 3 files changed, 11 insertions(+)

diff --git a/src/ring_client.cpp b/src/ring_client.cpp
index f123c8d5..ed2f33f5 100644
--- a/src/ring_client.cpp
+++ b/src/ring_client.cpp
@@ -253,6 +253,7 @@ on_close_window(GtkWidget *window, G_GNUC_UNUSED GdkEvent *event, RingClient *cl
     if (g_settings_get_boolean(priv->settings, "show-status-icon")) {
         /* we want to simply hide the window and keep the client running */
         ring_window_hide(client);
+        ring_main_window_reset(RING_MAIN_WINDOW(window));
         return TRUE; /* do not propogate event */
     } else {
         /* we want to quit the application, so just propogate the event */
diff --git a/src/ringmainwindow.cpp b/src/ringmainwindow.cpp
index eac63185..cd434c98 100644
--- a/src/ringmainwindow.cpp
+++ b/src/ringmainwindow.cpp
@@ -1452,6 +1452,15 @@ CppImpl::slotShowIncomingCallView(const std::string& id, lrc::api::conversation:
 
 }} // namespace <anonymous>::details
 
+void
+ring_main_window_reset(RingMainWindow* self)
+{
+    g_return_if_fail(IS_RING_MAIN_WINDOW(self));
+    auto* priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self));
+    if (priv->cpp->show_settings)
+        priv->cpp->leaveSettingsView();
+}
+
 //==============================================================================
 
 static void
diff --git a/src/ringmainwindow.h b/src/ringmainwindow.h
index 38195095..d7e7f033 100644
--- a/src/ringmainwindow.h
+++ b/src/ringmainwindow.h
@@ -37,6 +37,7 @@ typedef struct _RingMainWindowClass RingMainWindowClass;
 
 GType      ring_main_window_get_type (void) G_GNUC_CONST;
 GtkWidget *ring_main_window_new      (GtkApplication *app);
+void       ring_main_window_reset    (RingMainWindow *win);
 
 G_END_DECLS
 
-- 
GitLab