aboutsummaryrefslogtreecommitdiffstats
path: root/meta-xfce/recipes-xfce/xfce4-session/files/0001-Don-t-loose-xfwm4-when-closing-session-with-multiple.patch
blob: 50bade87f796b3f6dfeb7d5f8aa1894aa1fb574f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
From 64c0acb072057023870881f9fbac29ce08d357db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
Date: Wed, 5 Sep 2012 20:14:09 +0200
Subject: [PATCH] Don't loose xfwm4 when closing session with multiple windows
 waiting for user input
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When closing a session with more than one window open and waiting for unsaved
data to be closed, at the next session xfwm4 was not started properly.

The bug(fix) could be reproduced by

* opening gedit
* entering some text
* opening terminal
* closing session (no YNC-dialog / wait ~1min to close session)
* reopen session

Bugreport with this patch is found at [1] further discussion at [2].

Upstream-Status: Pending

[1] https://bugzilla.xfce.org/show_bug.cgi?id=5379
[2] http://mail.xfce.org/pipermail/xfce/2012-August/031174.html

Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
---
 xfce4-session/xfsm-manager.c |   81 ++++++++++++++++++++++++-----------------
 1 files changed, 47 insertions(+), 34 deletions(-)

diff --git a/xfce4-session/xfsm-manager.c b/xfce4-session/xfsm-manager.c
index 3078d6a..3cc4c89 100644
--- a/xfce4-session/xfsm-manager.c
+++ b/xfce4-session/xfsm-manager.c
@@ -96,6 +96,7 @@ struct _XfsmManager
 
   XfsmManagerState state;
   XfsmShutdownType shutdown_type;
+  gboolean         save_session;
 
   gboolean         session_chooser;
   gchar           *session_name;
@@ -225,6 +226,7 @@ xfsm_manager_init (XfsmManager *manager)
   manager->session_chooser = FALSE;
   manager->failsafe_mode = TRUE;
   manager->shutdown_type = XFSM_SHUTDOWN_LOGOUT;
+  manager->save_session = TRUE;
 
   manager->pending_properties = g_queue_new ();
   manager->starting_properties = g_queue_new ();
@@ -981,7 +983,9 @@ xfsm_manager_interact (XfsmManager *manager,
           XfsmClient *cl = lp->data;
           if (xfsm_client_get_state (cl) == XFSM_CLIENT_INTERACTING)
             {
-              xfsm_client_set_state (cl, XFSM_CLIENT_WAITFORINTERACT);
+              /* a client is already interacting, so new client has to wait */
+              xfsm_client_set_state (client, XFSM_CLIENT_WAITFORINTERACT);
+              xfsm_manager_cancel_client_save_timeout(manager, client);
               return;
             }
         }
@@ -1158,44 +1162,47 @@ xfsm_manager_save_yourself_global (XfsmManager     *manager,
     }
 #endif
 
-  if (!shutdown || shutdown_save)
+  /* don't save the session if shutting down without save */
+  manager->save_session = !shutdown || shutdown_save;
+
+  if (save_type == SmSaveBoth && !manager->save_session)
     {
-      xfsm_manager_set_state (manager,
-                              shutdown
-                              ? XFSM_MANAGER_SHUTDOWN
-                              : XFSM_MANAGER_CHECKPOINT);
+      /* saving the session, so clients should
+       * (prompt to) save the user data only */
+      save_type = SmSaveGlobal;
+    }
 
-      /* handle legacy applications first! */
-      xfsm_legacy_perform_session_save ();
+  xfsm_manager_set_state (manager,
+                          shutdown
+                          ? XFSM_MANAGER_SHUTDOWN
+                          : XFSM_MANAGER_CHECKPOINT);
 
-      for (lp = g_queue_peek_nth_link (manager->running_clients, 0);
-           lp;
-           lp = lp->next)
-        {
-          XfsmClient *client = lp->data;
-          XfsmProperties *properties = xfsm_client_get_properties (client);
-          const gchar *program;
+  /* handle legacy applications first! */
+  if (manager->save_session)
+      xfsm_legacy_perform_session_save ();
 
-          /* xterm's session management is broken, so we won't
-           * send a SAVE YOURSELF to xterms */
-          program = xfsm_properties_get_string (properties, SmProgram);
-          if (program != NULL && strcasecmp (program, "xterm") == 0)
-            continue;
+  for (lp = g_queue_peek_nth_link (manager->running_clients, 0);
+       lp;
+       lp = lp->next)
+    {
+      XfsmClient *client = lp->data;
+      XfsmProperties *properties = xfsm_client_get_properties (client);
+      const gchar *program;
 
-          if (xfsm_client_get_state (client) != XFSM_CLIENT_SAVINGLOCAL)
-            {
-              SmsSaveYourself (xfsm_client_get_sms_connection (client), save_type, shutdown,
-                               interact_style, fast);
-            }
+      /* xterm's session management is broken, so we won't
+       * send a SAVE YOURSELF to xterms */
+      program = xfsm_properties_get_string (properties, SmProgram);
+      if (program != NULL && strcasecmp (program, "xterm") == 0)
+        continue;
 
-          xfsm_client_set_state (client, XFSM_CLIENT_SAVING);
-          xfsm_manager_start_client_save_timeout (manager, client);
+      if (xfsm_client_get_state (client) != XFSM_CLIENT_SAVINGLOCAL)
+        {
+          SmsSaveYourself (xfsm_client_get_sms_connection (client), save_type, shutdown,
+                           interact_style, fast);
         }
-    }
-  else
-    {
-      /* shutdown session without saving */
-      xfsm_manager_perform_shutdown (manager);
+
+      xfsm_client_set_state (client, XFSM_CLIENT_SAVING);
+      xfsm_manager_start_client_save_timeout (manager, client);
     }
 }
 
@@ -1267,7 +1274,12 @@ xfsm_manager_save_yourself_done (XfsmManager *manager,
                                  XfsmClient  *client,
                                  gboolean     success)
 {
-  if (xfsm_client_get_state (client) != XFSM_CLIENT_SAVING && xfsm_client_get_state (client) != XFSM_CLIENT_SAVINGLOCAL)
+  /* In xfsm_manager_interact_done we send SmsShutdownCancelled to clients in
+     XFSM_CLIENT_WAITFORINTERACT state. They respond with SmcSaveYourselfDone
+     (xsmp_shutdown_cancelled in libxfce4ui library) so we allow it here. */
+  if (xfsm_client_get_state (client) != XFSM_CLIENT_SAVING &&
+      xfsm_client_get_state (client) != XFSM_CLIENT_SAVINGLOCAL &&
+      xfsm_client_get_state (client) != XFSM_CLIENT_WAITFORINTERACT)
     {
       xfsm_verbose ("Client Id = %s send SAVE YOURSELF DONE, while not being "
                     "in save mode. Prepare to be nuked!\n",
@@ -1539,7 +1551,8 @@ xfsm_manager_complete_saveyourself (XfsmManager *manager)
   xfsm_verbose ("Manager finished SAVE YOURSELF, session data will be stored now.\n\n");
 
   /* all clients done, store session data */
-  xfsm_manager_store_session (manager);
+  if (manager->save_session)
+    xfsm_manager_store_session (manager);
 
   if (manager->state == XFSM_MANAGER_CHECKPOINT)
     {
-- 
1.7.6.5