From 2bc2327ec11d0c6a02e9d7ef412d75bd9a55452f Mon Sep 17 00:00:00 2001
From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
Date: Thu, 17 Sep 2015 18:05:01 -0400
Subject: [PATCH] autostart: preserve last window state

Use the --restore-last-window-state option in the autostart
.desktop file in order to autostart the client in the same
state as when it was quit.

The use case is that if users log-out with their client in
a hidden state, when they log back in, it should still be
hidden.

Issue: #78993
Change-Id: I43e5c27e14749dde9cc851f29560f88263d6c9a8
---
 CMakeLists.txt                  | 10 +++++++++-
 gnome-ring.desktop.autostart.in |  9 +++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 gnome-ring.desktop.autostart.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fcb12b1c..2a4b4852 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -337,6 +337,12 @@ CONFIGURE_FILE (
    "${PROJECT_BINARY_DIR}/gnome-ring.desktop"
 )
 
+# generate .desktop file for autostart
+CONFIGURE_FILE (
+   "${PROJECT_SOURCE_DIR}/gnome-ring.desktop.autostart.in"
+   "${PROJECT_BINARY_DIR}/gnome-ring.desktop.autostart"
+)
+
 INSTALL(TARGETS gnome-ring
    RUNTIME DESTINATION bin
 )
@@ -348,7 +354,7 @@ INSTALL(FILES ${PROJECT_BINARY_DIR}/gnome-ring.desktop
 
 # install .desktop in the gnome-ring data dir, so that it can be copied to the
 # autostart dir by the client
-INSTALL(FILES ${PROJECT_BINARY_DIR}/gnome-ring.desktop
+INSTALL(FILES ${PROJECT_BINARY_DIR}/gnome-ring.desktop.autostart
    DESTINATION
       ${CMAKE_INSTALL_PREFIX}/share/gnome-ring/
    PERMISSIONS
@@ -356,6 +362,8 @@ INSTALL(FILES ${PROJECT_BINARY_DIR}/gnome-ring.desktop
       OWNER_WRITE
       OWNER_READ
       GROUP_READ
+   RENAME
+      gnome-ring.desktop
 )
 
 INSTALL(FILES pixmaps/ring.svg
diff --git a/gnome-ring.desktop.autostart.in b/gnome-ring.desktop.autostart.in
new file mode 100644
index 00000000..1dac7913
--- /dev/null
+++ b/gnome-ring.desktop.autostart.in
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=Ring
+Comment=Ring is a secured and distributed communication software.
+Exec=gnome-ring --restore-last-window-state
+Icon=@RING_INSTALL_PREFIX@/share/icons/hicolor/scalable/apps/ring.svg
+StartupNotify=true
+Terminal=false
+Type=Application
+Categories=GNOME;GTK;Network;Telephony;
-- 
GitLab