From: Dmitry Antipov Date: Thu, 10 Oct 2013 06:48:42 +0000 (+0400) Subject: * keyboard.c (init_kboard): Now static. Add arg X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1303 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1afcba638a6ecf9fe6db1e52594024b323d4145e;p=emacs.git * keyboard.c (init_kboard): Now static. Add arg to denote window system. Adjust comment. (init_keyboard): Adjust user. (allocate_kboard): New function. (syms_of_keyboard): * nsterm.m (ns_term_init): * term.c (init_tty): * w32term.c (w32_create_terminal): * xterm.c (x_term_init): Use it. * keyboard.h (init_kboard): Remove prototype. (allocate_kboard): Add prototype. --- diff --git a/src/ChangeLog b/src/ChangeLog index 7e196668796..d5862485a76 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2013-10-10 Dmitry Antipov + + * keyboard.c (init_kboard): Now static. Add arg + to denote window system. Adjust comment. + (init_keyboard): Adjust user. + (allocate_kboard): New function. + (syms_of_keyboard): + * nsterm.m (ns_term_init): + * term.c (init_tty): + * w32term.c (w32_create_terminal): + * xterm.c (x_term_init): Use it. + * keyboard.h (init_kboard): Remove prototype. + (allocate_kboard): Add prototype. + 2013-10-10 Barry Fishman (tiny change) * image.c (GIFLIB_MAJOR): Ensure it's defined. @@ -29,7 +43,7 @@ so it shouldn't be used all the time. Perhaps we need two flavors of 'eassert', one for where 'assume' is far more likely to help or to hurt; but that can be done later. - Problem reported by Dmitry Andipov in + Problem reported by Dmitry Antipov in . Also, don't include ; no longer needed. diff --git a/src/keyboard.c b/src/keyboard.c index 669e85518f1..9d0ce14ce6f 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10790,12 +10790,11 @@ The `posn-' functions access elements of such lists. */) return tem; } - -/* - * Set up a new kboard object with reasonable initial values. - */ -void -init_kboard (KBOARD *kb) +/* Set up a new kboard object with reasonable initial values. + TYPE is a window system for which this keyboard is used. */ + +static void +init_kboard (KBOARD *kb, Lisp_Object type) { kset_overriding_terminal_local_map (kb, Qnil); kset_last_command (kb, Qnil); @@ -10816,13 +10815,27 @@ init_kboard (KBOARD *kb) kb->reference_count = 0; kset_system_key_alist (kb, Qnil); kset_system_key_syms (kb, Qnil); - kset_window_system (kb, Qt); /* Unset. */ + kset_window_system (kb, type); kset_input_decode_map (kb, Fmake_sparse_keymap (Qnil)); kset_local_function_key_map (kb, Fmake_sparse_keymap (Qnil)); Fset_keymap_parent (KVAR (kb, Vlocal_function_key_map), Vfunction_key_map); kset_default_minibuffer_frame (kb, Qnil); } +/* Allocate and basically initialize keyboard + object to use with window system TYPE. */ + +KBOARD * +allocate_kboard (Lisp_Object type) +{ + KBOARD *kb = xmalloc (sizeof *kb); + + init_kboard (kb, type); + kb->next_kboard = all_kboards; + all_kboards = kb; + return kb; +} + /* * Destroy the contents of a kboard object, but not the object itself. * We use this just before deleting it, or if we're going to initialize @@ -10887,10 +10900,9 @@ init_keyboard (void) current_kboard = initial_kboard; /* Re-initialize the keyboard again. */ wipe_kboard (current_kboard); - init_kboard (current_kboard); /* A value of nil for Vwindow_system normally means a tty, but we also use it for the initial terminal since there is no window system there. */ - kset_window_system (current_kboard, Qnil); + init_kboard (current_kboard, Qnil); if (!noninteractive) { @@ -11695,12 +11707,8 @@ Currently, the only supported values for this variable are `sigusr1' and `sigusr2'. */); Vdebug_on_event = intern_c_string ("sigusr2"); - /* Create the initial keyboard. */ - initial_kboard = xmalloc (sizeof *initial_kboard); - init_kboard (initial_kboard); - /* Vwindow_system is left at t for now. */ - initial_kboard->next_kboard = all_kboards; - all_kboards = initial_kboard; + /* Create the initial keyboard. Qt means 'unset'. */ + initial_kboard = allocate_kboard (Qt); } void diff --git a/src/keyboard.h b/src/keyboard.h index 49f87b20a43..26cb862e8a0 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -507,7 +507,7 @@ extern unsigned int timers_run; extern bool menu_separator_name_p (const char *); extern bool parse_menu_item (Lisp_Object, int); -extern void init_kboard (KBOARD *); +extern KBOARD *allocate_kboard (Lisp_Object); extern void delete_kboard (KBOARD *); extern void not_single_kboard_state (KBOARD *); extern void push_kboard (struct kboard *); diff --git a/src/nsterm.m b/src/nsterm.m index ce8d9b2106a..6625d09b5ca 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -4169,11 +4169,7 @@ ns_term_init (Lisp_Object display_name) ns_initialize_display_info (dpyinfo); terminal = ns_create_terminal (dpyinfo); - terminal->kboard = xmalloc (sizeof *terminal->kboard); - init_kboard (terminal->kboard); - kset_window_system (terminal->kboard, Qns); - terminal->kboard->next_kboard = all_kboards; - all_kboards = terminal->kboard; + terminal->kboard = allocate_kboard (Qns); /* Don't let the initial kboard remain current longer than necessary. That would cause problems if a file loaded on startup tries to prompt in the mini-buffer. */ diff --git a/src/term.c b/src/term.c index ad2e90dc795..a8274b19d2a 100644 --- a/src/term.c +++ b/src/term.c @@ -4301,11 +4301,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ tty->mouse_highlight.mouse_face_window = Qnil; #endif - terminal->kboard = xmalloc (sizeof *terminal->kboard); - init_kboard (terminal->kboard); - kset_window_system (terminal->kboard, Qnil); - terminal->kboard->next_kboard = all_kboards; - all_kboards = terminal->kboard; + terminal->kboard = allocate_kboard (Qnil); terminal->kboard->reference_count++; /* Don't let the initial kboard remain current longer than necessary. That would cause problems if a file loaded on startup tries to diff --git a/src/w32term.c b/src/w32term.c index be8ebfe6ab6..4587c7c0676 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -6262,11 +6262,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo) /* We don't yet support separate terminals on W32, so don't try to share keyboards between virtual terminals that are on the same physical terminal like X does. */ - terminal->kboard = xmalloc (sizeof (KBOARD)); - init_kboard (terminal->kboard); - kset_window_system (terminal->kboard, Qw32); - terminal->kboard->next_kboard = all_kboards; - all_kboards = terminal->kboard; + terminal->kboard = allocate_kboard (Qw32); /* Don't let the initial kboard remain current longer than necessary. That would cause problems if a file loaded on startup tries to prompt in the mini-buffer. */ diff --git a/src/xterm.c b/src/xterm.c index 1ccc1ae649b..3299255461f 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -9905,15 +9905,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) terminal->kboard = share->terminal->kboard; else { - terminal->kboard = xmalloc (sizeof *terminal->kboard); - init_kboard (terminal->kboard); - kset_window_system (terminal->kboard, Qx); - - /* Add the keyboard to the list before running Lisp code (via - Qvendor_specific_keysyms below), since these are not traced - via terminals but only through all_kboards. */ - terminal->kboard->next_kboard = all_kboards; - all_kboards = terminal->kboard; + terminal->kboard = allocate_kboard (Qx); if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound)) {