~ubuntu-branches/ubuntu/karmic/gnome-screensaver/karmic-updates

« back to all changes in this revision

Viewing changes to debian/patches/08_gs_dialog_request_to_exit.patch

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-10-16 01:32:07 UTC
  • Revision ID: james.westby@ubuntu.com-20091016013207-i9vqsl6lpbspxcbg
Tags: 2.28.0-0ubuntu2
* debian/patches/08_gs_dialog_request_to_exit.patch:
  - Don't let the dialog process exit on its own accord when the
    password is entered incorrectly 5 times. Instead, request that
    the main gnome-screensaver process terminates it when ready. This
    avoids a race where the dialog process exits during the middle
    of the auth-failure animation, leading to unhandled X errors
    (LP: #446395)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -Nur -x '*.orig' -x '*~' gnome-screensaver-2.28.0/src/gnome-screensaver-dialog.c gnome-screensaver-2.28.0.new/src/gnome-screensaver-dialog.c
 
2
--- gnome-screensaver-2.28.0/src/gnome-screensaver-dialog.c     2009-08-26 17:06:12.000000000 +0100
 
3
+++ gnome-screensaver-2.28.0.new/src/gnome-screensaver-dialog.c 2009-10-16 01:11:24.872719567 +0100
 
4
@@ -29,6 +29,7 @@
 
5
 #include <sys/types.h>
 
6
 #include <sys/wait.h>
 
7
 #include <unistd.h>
 
8
+#include <signal.h>
 
9
 
 
10
 #include <glib/gi18n.h>
 
11
 #include <gdk/gdkx.h>
 
12
@@ -326,6 +327,21 @@
 
13
 }
 
14
 
 
15
 static gboolean
 
16
+response_request_quit (void)
 
17
+{
 
18
+        printf ("REQUEST QUIT\n");
 
19
+        fflush (stdout);
 
20
+        return FALSE;
 
21
+}
 
22
+
 
23
+static gboolean
 
24
+quit_timeout_cb (gpointer data)
 
25
+{
 
26
+        gtk_main_quit ();
 
27
+        return FALSE;
 
28
+}
 
29
+
 
30
+static gboolean
 
31
 auth_check_idle (GSLockPlug *plug)
 
32
 {
 
33
         gboolean     res;
 
34
@@ -347,7 +363,11 @@
 
35
                 } else {
 
36
                         gs_debug ("Authentication failed, quitting (max failures)");
 
37
                         again = FALSE;
 
38
-                        gtk_main_quit ();
 
39
+                        /* Don't quit immediately, but rather request that gnome-screensaver
 
40
+                         * terminates us after it has finished the dialog shake. Time out
 
41
+                         * after 5 seconds and quit anyway if this doesn't happen though */
 
42
+                        g_idle_add ((GSourceFunc)response_request_quit, NULL);
 
43
+                        g_timeout_add (5000, (GSourceFunc)quit_timeout_cb, NULL);
 
44
                 }
 
45
         }
 
46
 
 
47
@@ -521,12 +541,21 @@
 
48
         return TRUE;
 
49
 }
 
50
 
 
51
+static void
 
52
+signal_handler (int signo)
 
53
+{
 
54
+        if (signo == SIGTERM) {
 
55
+                gtk_main_quit ();
 
56
+        }
 
57
+}
 
58
+
 
59
 int
 
60
 main (int    argc,
 
61
       char **argv)
 
62
 {
 
63
         GError *error = NULL;
 
64
         char   *nolock_reason = NULL;
 
65
+        struct sigaction action;
 
66
 
 
67
 #ifdef ENABLE_NLS
 
68
         bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 
69
@@ -573,6 +602,14 @@
 
70
         }
 
71
 
 
72
         gs_debug_init (verbose, FALSE);
 
73
+        
 
74
+        action.sa_handler = signal_handler;
 
75
+        sigemptyset (&action.sa_mask);
 
76
+        action.sa_flags = 0;
 
77
+
 
78
+        if (sigaction (SIGTERM, &action, NULL) != 0) {
 
79
+                fprintf (stderr, "Failed to register signal handler");
 
80
+        }
 
81
 
 
82
         g_idle_add ((GSourceFunc)popup_dialog_idle, NULL);
 
83
 
 
84
diff -Nur -x '*.orig' -x '*~' gnome-screensaver-2.28.0/src/gs-window-x11.c gnome-screensaver-2.28.0.new/src/gs-window-x11.c
 
85
--- gnome-screensaver-2.28.0/src/gs-window-x11.c        2009-10-16 01:03:12.262719055 +0100
 
86
+++ gnome-screensaver-2.28.0.new/src/gs-window-x11.c    2009-10-16 01:03:13.115223457 +0100
 
87
@@ -91,6 +91,8 @@
 
88
         gint       lock_pid;
 
89
         gint       lock_watch_id;
 
90
         gint       dialog_response;
 
91
+        gboolean   dialog_quit_requested;
 
92
+        gboolean   dialog_shake_in_progress;
 
93
 
 
94
         gint       keyboard_pid;
 
95
         gint       keyboard_watch_id;
 
96
@@ -1390,6 +1392,16 @@
 
97
         remove_key_events (window);
 
98
 }
 
99
 
 
100
+static void
 
101
+maybe_kill_dialog (GSWindow *window)
 
102
+{
 
103
+        if (!window->priv->dialog_shake_in_progress
 
104
+            && window->priv->dialog_quit_requested
 
105
+            && window->priv->lock_pid > 0) {
 
106
+                kill (window->priv->lock_pid, SIGTERM);
 
107
+        }
 
108
+}
 
109
+
 
110
 /* very rudimentary animation for indicating an auth failure */
 
111
 static void
 
112
 shake_dialog (GSWindow *window)
 
113
@@ -1398,6 +1410,8 @@
 
114
         guint left;
 
115
         guint right;
 
116
 
 
117
+        window->priv->dialog_shake_in_progress = TRUE;
 
118
+
 
119
         for (i = 0; i < 9; i++) {
 
120
                 if (i % 2 == 0) {
 
121
                         left = 30;
 
122
@@ -1422,6 +1436,9 @@
 
123
 
 
124
                 g_usleep (10000);
 
125
         }
 
126
+
 
127
+        window->priv->dialog_shake_in_progress = FALSE;
 
128
+        maybe_kill_dialog (window);
 
129
 }
 
130
 
 
131
 static gboolean
 
132
@@ -1464,6 +1481,10 @@
 
133
                                         window->priv->dialog_response = DIALOG_RESPONSE_CANCEL;
 
134
                                 }
 
135
                                 finished = TRUE;
 
136
+                        } else if (strstr (line, "REQUEST QUIT") != NULL) {
 
137
+                                gs_debug ("Got request for quit");
 
138
+                                window->priv->dialog_quit_requested = TRUE;
 
139
+                                maybe_kill_dialog (window);
 
140
                         }
 
141
                         break;
 
142
                 case G_IO_STATUS_EOF:
 
143
@@ -1577,6 +1598,9 @@
 
144
 
 
145
         set_invisible_cursor (GTK_WIDGET (window)->window, FALSE);
 
146
 
 
147
+        window->priv->dialog_quit_requested = FALSE;
 
148
+        window->priv->dialog_shake_in_progress = FALSE;
 
149
+
 
150
         result = spawn_on_window (window,
 
151
                                   command->str,
 
152
                                   &window->priv->lock_pid,