aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKen Brown2016-05-12 15:52:26 -0400
committerKen Brown2016-05-12 15:52:26 -0400
commit6435f41f6d444243c87b7b52e5e7c0b5a40195ad (patch)
tree28f4ae0b8ffe047faea4198baba0ff8bb2b13baf /src
parentec7a173e03729450bb9117e98d7e696c15994a84 (diff)
downloademacs-6435f41f6d444243c87b7b52e5e7c0b5a40195ad.tar.gz
emacs-6435f41f6d444243c87b7b52e5e7c0b5a40195ad.zip
Autosave buffers on logout if HAVE_NTGUI
* src/w32fns.c (w32_wnd_proc): Pass a WM_ENDSESSION message on to w32_read_socket. * src/w32term.c (w32_read_socket): Create an event of type END_SESSION_EVENT if a WM_ENDSESSION message is received. * src/termhooks.h [HAVE_NTGUI]: New event kind END_SESSION_EVENT. * src/keyboard.c [HAVE_NTGUI] (syms_of_keyboard): New symbol `end-session'. (kbd_buffer_get_event): Return an end-session event if an event of type END_SESSION_EVENT is read. (keys_of_keyboard): Bind the end-session event to kill-emacs in special-event-map. (Bug#23483)
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c15
-rw-r--r--src/termhooks.h3
-rw-r--r--src/w32fns.c5
-rw-r--r--src/w32term.c4
4 files changed, 27 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 92d5c3053a7..fe04b3f2b5e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3893,6 +3893,16 @@ kbd_buffer_get_event (KBOARD **kbp,
3893 kbd_fetch_ptr = event + 1; 3893 kbd_fetch_ptr = event + 1;
3894 } 3894 }
3895#endif 3895#endif
3896
3897#ifdef HAVE_NTGUI
3898 else if (event->kind == END_SESSION_EVENT)
3899 {
3900 /* Make an event (end-session). */
3901 obj = list1 (Qend_session);
3902 kbd_fetch_ptr = event + 1;
3903 }
3904#endif
3905
3896#if defined (HAVE_X11) || defined (HAVE_NTGUI) \ 3906#if defined (HAVE_X11) || defined (HAVE_NTGUI) \
3897 || defined (HAVE_NS) 3907 || defined (HAVE_NS)
3898 else if (event->kind == ICONIFY_EVENT) 3908 else if (event->kind == ICONIFY_EVENT)
@@ -10984,6 +10994,7 @@ syms_of_keyboard (void)
10984 10994
10985#ifdef HAVE_NTGUI 10995#ifdef HAVE_NTGUI
10986 DEFSYM (Qlanguage_change, "language-change"); 10996 DEFSYM (Qlanguage_change, "language-change");
10997 DEFSYM (Qend_session, "end-session");
10987#endif 10998#endif
10988 10999
10989#ifdef HAVE_DBUS 11000#ifdef HAVE_DBUS
@@ -11758,6 +11769,10 @@ keys_of_keyboard (void)
11758 11769
11759 initial_define_lispy_key (Vspecial_event_map, "delete-frame", 11770 initial_define_lispy_key (Vspecial_event_map, "delete-frame",
11760 "handle-delete-frame"); 11771 "handle-delete-frame");
11772#ifdef HAVE_NTGUI
11773 initial_define_lispy_key (Vspecial_event_map, "end-session",
11774 "kill-emacs");
11775#endif
11761 initial_define_lispy_key (Vspecial_event_map, "ns-put-working-text", 11776 initial_define_lispy_key (Vspecial_event_map, "ns-put-working-text",
11762 "ns-put-working-text"); 11777 "ns-put-working-text");
11763 initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text", 11778 initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text",
diff --git a/src/termhooks.h b/src/termhooks.h
index d21d6ce588a..ff74d99b7c1 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -158,6 +158,9 @@ enum event_kind
158 SELECTION_CLEAR_EVENT, /* Another X client cleared our selection. */ 158 SELECTION_CLEAR_EVENT, /* Another X client cleared our selection. */
159 BUFFER_SWITCH_EVENT, /* A process filter has switched buffers. */ 159 BUFFER_SWITCH_EVENT, /* A process filter has switched buffers. */
160 DELETE_WINDOW_EVENT, /* An X client said "delete this window". */ 160 DELETE_WINDOW_EVENT, /* An X client said "delete this window". */
161#ifdef HAVE_NTGUI
162 END_SESSION_EVENT, /* The user is logging out or shutting down. */
163#endif
161 MENU_BAR_EVENT, /* An event generated by the menu bar. 164 MENU_BAR_EVENT, /* An event generated by the menu bar.
162 The frame_or_window field's cdr holds the 165 The frame_or_window field's cdr holds the
163 Lisp-level event value. 166 Lisp-level event value.
diff --git a/src/w32fns.c b/src/w32fns.c
index ede8f6be292..7a1f84a7bac 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -4795,6 +4795,11 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
4795 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 4795 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4796 return 0; 4796 return 0;
4797 4797
4798 case WM_ENDSESSION:
4799 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4800 /* If we return, the process will be terminated immediately. */
4801 sleep (1000);
4802
4798 case WM_WINDOWPOSCHANGING: 4803 case WM_WINDOWPOSCHANGING:
4799 /* Don't restrict the sizing of any kind of frames. If the window 4804 /* Don't restrict the sizing of any kind of frames. If the window
4800 manager doesn't, there's no reason to do it ourselves. */ 4805 manager doesn't, there's no reason to do it ourselves. */
diff --git a/src/w32term.c b/src/w32term.c
index 74ea6b543bd..72e1245ae59 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -5260,6 +5260,10 @@ w32_read_socket (struct terminal *terminal,
5260 } 5260 }
5261 break; 5261 break;
5262 5262
5263 case WM_ENDSESSION:
5264 inev.kind = END_SESSION_EVENT;
5265 break;
5266
5263 case WM_INITMENU: 5267 case WM_INITMENU:
5264 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 5268 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
5265 5269