1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-27 10:54:40 +00:00

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)
This commit is contained in:
Ken Brown 2016-05-12 15:52:26 -04:00
parent ec7a173e03
commit 6435f41f6d
4 changed files with 27 additions and 0 deletions

View File

@ -3893,6 +3893,16 @@ kbd_buffer_get_event (KBOARD **kbp,
kbd_fetch_ptr = event + 1;
}
#endif
#ifdef HAVE_NTGUI
else if (event->kind == END_SESSION_EVENT)
{
/* Make an event (end-session). */
obj = list1 (Qend_session);
kbd_fetch_ptr = event + 1;
}
#endif
#if defined (HAVE_X11) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS)
else if (event->kind == ICONIFY_EVENT)
@ -10984,6 +10994,7 @@ syms_of_keyboard (void)
#ifdef HAVE_NTGUI
DEFSYM (Qlanguage_change, "language-change");
DEFSYM (Qend_session, "end-session");
#endif
#ifdef HAVE_DBUS
@ -11758,6 +11769,10 @@ keys_of_keyboard (void)
initial_define_lispy_key (Vspecial_event_map, "delete-frame",
"handle-delete-frame");
#ifdef HAVE_NTGUI
initial_define_lispy_key (Vspecial_event_map, "end-session",
"kill-emacs");
#endif
initial_define_lispy_key (Vspecial_event_map, "ns-put-working-text",
"ns-put-working-text");
initial_define_lispy_key (Vspecial_event_map, "ns-unput-working-text",

View File

@ -158,6 +158,9 @@ enum event_kind
SELECTION_CLEAR_EVENT, /* Another X client cleared our selection. */
BUFFER_SWITCH_EVENT, /* A process filter has switched buffers. */
DELETE_WINDOW_EVENT, /* An X client said "delete this window". */
#ifdef HAVE_NTGUI
END_SESSION_EVENT, /* The user is logging out or shutting down. */
#endif
MENU_BAR_EVENT, /* An event generated by the menu bar.
The frame_or_window field's cdr holds the
Lisp-level event value.

View File

@ -4795,6 +4795,11 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
return 0;
case WM_ENDSESSION:
my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
/* If we return, the process will be terminated immediately. */
sleep (1000);
case WM_WINDOWPOSCHANGING:
/* Don't restrict the sizing of any kind of frames. If the window
manager doesn't, there's no reason to do it ourselves. */

View File

@ -5260,6 +5260,10 @@ w32_read_socket (struct terminal *terminal,
}
break;
case WM_ENDSESSION:
inev.kind = END_SESSION_EVENT;
break;
case WM_INITMENU:
f = x_window_to_frame (dpyinfo, msg.msg.hwnd);