From: Karoly Lorentey Date: Mon, 27 Jun 2005 00:56:21 +0000 (+0000) Subject: Cleanup: Move kboard fields from struct frame and device-specific descriptors to... X-Git-Tag: emacs-pretest-23.0.90~11236^2~141^2~237 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bedb9c0eda660f7dc516543be25db37b5f95e03b;p=emacs.git Cleanup: Move kboard fields from struct frame and device-specific descriptors to struct display. * src/termhooks.h (display): New field: kboard. * src/xterm.h (x_display_info): Remove kboard field. * src/termchar.h (tty_display_info): Ditto. * src/frame.h (frame): Ditto. (FRAME_KBOARD): Update. * src/dispnew.c (init_display): Don't initialize kboard. * src/frame.c (make_frame, make_initial_frame, make_terminal_frame): Ditto. * src/frame.c (make_frame_without_minibuffer, Fdelete_frame): Update kboard access. * src/keyboard.c (delete_kboard): Ditto. * src/term.c (term_init): Ditto. * src/xfns.c (Fx_create_frame, x_create_tip_frame): Ditto. * src/xselect.c (x_handle_selection_clear): Ditto. * src/xterm.c (x_term_init): Ditto. * src/term.c (init_initial_display): Initialize kboard. * src/xterm.c (x_term_init): Ditto. * src/term.c (delete_tty): Remove kboard deletion. (delete_display): Delete kboard as well. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-363 --- diff --git a/src/dispnew.c b/src/dispnew.c index cc9e6152d1a..6a95d2e38d3 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -6734,9 +6734,6 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ abort (); f->output_method = d->type; f->display = d; -#ifdef MULTI_KBOARD - f->kboard = d->display_info.tty->kboard; -#endif d->reference_count++; d->display_info.tty->top_frame = selected_frame; diff --git a/src/frame.c b/src/frame.c index 6a54e26121f..52ae3191299 100644 --- a/src/frame.c +++ b/src/frame.c @@ -303,9 +303,6 @@ make_frame (mini_p) f->menu_bar_items_used = 0; f->buffer_predicate = Qnil; f->buffer_list = Qnil; -#ifdef MULTI_KBOARD - f->kboard = initial_kboard; -#endif f->namebuf = 0; f->title = Qnil; f->menu_bar_window = Qnil; @@ -425,7 +422,7 @@ make_frame_without_minibuffer (mini_window, kb, display) #ifdef MULTI_KBOARD if (!NILP (mini_window) - && XFRAME (XWINDOW (mini_window)->frame)->kboard != kb) + && XFRAME (XWINDOW (mini_window)->frame)->display->kboard != kb) error ("Frame and minibuffer must be on the same display"); #endif @@ -552,10 +549,6 @@ make_initial_frame (void) FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; -#ifdef MULTI_KBOARD - f->kboard = initial_kboard; -#endif - return f; } @@ -622,10 +615,6 @@ make_terminal_frame (struct display *display) FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; -#ifdef MULTI_KBOARD - f->kboard = FRAME_TTY (f)->kboard; -#endif - /* Set the top frame to the newly created frame. */ if (FRAME_TTY (f)->top_frame && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame))) @@ -1358,6 +1347,8 @@ The functions are run with one arg, the frame to be deleted. */) { struct frame *f; struct frame *sf = SELECTED_FRAME (); + struct kboard *kb; + int minibuffer_selected; if (EQ (frame, Qnil)) @@ -1513,23 +1504,25 @@ The functions are run with one arg, the frame to be deleted. */) if (FRAME_DISPLAY (f)->delete_frame_hook) (*FRAME_DISPLAY (f)->delete_frame_hook) (f); - + { struct display *display = FRAME_DISPLAY (f); - f->output_data.nothing = 0; f->display = 0; /* Now the frame is dead. */ /* If needed, delete the device that this frame was on. - (This must be done after the frame is killed.) */ + (This must be done after the frame is killed.) */ display->reference_count--; if (display->reference_count == 0) - { - if (display->delete_display_hook) - (*display->delete_display_hook) (display); - else - delete_display (display); - } + { + kb = NULL; + if (display->delete_display_hook) + (*display->delete_display_hook) (display); + else + delete_display (display); + } + else + kb = display->kboard; } /* If we've deleted the last_nonminibuf_frame, then try to find @@ -1555,38 +1548,39 @@ The functions are run with one arg, the frame to be deleted. */) /* If there's no other frame on the same kboard, get out of single-kboard state if we're in it for this kboard. */ - { - Lisp_Object frames; - /* Some frame we found on the same kboard, or nil if there are none. */ - Lisp_Object frame_on_same_kboard; + if (kb != NULL) + { + Lisp_Object frames; + /* Some frame we found on the same kboard, or nil if there are none. */ + Lisp_Object frame_on_same_kboard; - frame_on_same_kboard = Qnil; + frame_on_same_kboard = Qnil; - for (frames = Vframe_list; - CONSP (frames); - frames = XCDR (frames)) - { - Lisp_Object this; - struct frame *f1; + for (frames = Vframe_list; + CONSP (frames); + frames = XCDR (frames)) + { + Lisp_Object this; + struct frame *f1; - this = XCAR (frames); - if (!FRAMEP (this)) - abort (); - f1 = XFRAME (this); + this = XCAR (frames); + if (!FRAMEP (this)) + abort (); + f1 = XFRAME (this); - if (FRAME_KBOARD (f) == FRAME_KBOARD (f1)) - frame_on_same_kboard = this; - } + if (kb == FRAME_KBOARD (f1)) + frame_on_same_kboard = this; + } - if (NILP (frame_on_same_kboard)) - not_single_kboard_state (FRAME_KBOARD (f)); - } + if (NILP (frame_on_same_kboard)) + not_single_kboard_state (kb); + } /* If we've deleted this keyboard's default_minibuffer_frame, try to find another one. Prefer minibuffer-only frames, but also notice frames with other windows. */ - if (EQ (frame, FRAME_KBOARD (f)->Vdefault_minibuffer_frame)) + if (kb != NULL && EQ (frame, kb->Vdefault_minibuffer_frame)) { Lisp_Object frames; @@ -1612,7 +1606,7 @@ The functions are run with one arg, the frame to be deleted. */) /* Consider only frames on the same kboard and only those with minibuffers. */ - if (FRAME_KBOARD (f) == FRAME_KBOARD (f1) + if (kb == FRAME_KBOARD (f1) && FRAME_HAS_MINIBUF_P (f1)) { frame_with_minibuf = this; @@ -1620,7 +1614,7 @@ The functions are run with one arg, the frame to be deleted. */) break; } - if (FRAME_KBOARD (f) == FRAME_KBOARD (f1)) + if (kb == FRAME_KBOARD (f1)) frame_on_same_kboard = this; } @@ -1635,11 +1629,11 @@ The functions are run with one arg, the frame to be deleted. */) if (NILP (frame_with_minibuf)) abort (); - FRAME_KBOARD (f)->Vdefault_minibuffer_frame = frame_with_minibuf; + kb->Vdefault_minibuffer_frame = frame_with_minibuf; } else /* No frames left on this kboard--say no minibuffer either. */ - FRAME_KBOARD (f)->Vdefault_minibuffer_frame = Qnil; + kb->Vdefault_minibuffer_frame = Qnil; } /* Cause frame titles to update--necessary if we now have just one frame. */ diff --git a/src/frame.h b/src/frame.h index 9f0c830ca86..c4190255b72 100644 --- a/src/frame.h +++ b/src/frame.h @@ -292,16 +292,6 @@ struct frame /* The extra width (in pixels) currently allotted for fringes. */ int left_fringe_width, right_fringe_width; -#ifdef MULTI_KBOARD - /* XXX Maybe this should be moved to struct display, too. */ - /* A pointer to the kboard structure associated with this frame. - For termcap frames, it will be the same as - display->display_info.tty->kboard. - For X frames, it will be the same as - display->display_info.x->kboard. */ - struct kboard *kboard; -#endif - /* See FULLSCREEN_ enum below */ int want_fullscreen; @@ -456,7 +446,7 @@ struct frame }; #ifdef MULTI_KBOARD -#define FRAME_KBOARD(f) ((f)->kboard) +#define FRAME_KBOARD(f) ((f)->display->kboard) #else #define FRAME_KBOARD(f) (&the_only_kboard) #endif diff --git a/src/term.c b/src/term.c index 55d1741873c..8f541816798 100644 --- a/src/term.c +++ b/src/term.c @@ -2285,10 +2285,11 @@ init_initial_display (void) initial_display = create_display (); initial_display->type = output_initial; initial_display->name = xstrdup ("initial_display"); + initial_display->kboard = initial_kboard; initial_display->delete_display_hook = &delete_initial_display; /* All other hooks are NULL. */ - + return initial_display; } @@ -2682,19 +2683,19 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", tty->TF_teleray = tgetflag ("xt"); #ifdef MULTI_KBOARD - tty->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); - init_kboard (tty->kboard); - tty->kboard->next_kboard = all_kboards; - all_kboards = tty->kboard; + display->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); + init_kboard (display->kboard); + display->kboard->next_kboard = all_kboards; + all_kboards = display->kboard; + display->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 prompt in the mini-buffer. */ if (current_kboard == initial_kboard) - current_kboard = tty->kboard; - tty->kboard->reference_count++; + current_kboard = display->kboard; #endif - term_get_fkeys (address, tty->kboard); + term_get_fkeys (address, display->kboard); /* Get frame size from system, or else from termcap. */ { @@ -3051,13 +3052,6 @@ delete_tty (struct display *display) if (tty->Wcm) xfree (tty->Wcm); -#ifdef MULTI_KBOARD - if (tty->kboard && --tty->kboard->reference_count > 0) - abort (); - if (tty->kboard) - delete_kboard (tty->kboard); -#endif - bzero (tty, sizeof (struct tty_display_info)); xfree (tty); deleting_tty = 0; @@ -3170,6 +3164,11 @@ delete_display (struct display *display) if (display->name) xfree (display->name); +#ifdef MULTI_KBOARD + if (display->kboard && --display->kboard->reference_count == 0) + delete_kboard (display->kboard); +#endif + bzero (display, sizeof (struct display)); xfree (display); } diff --git a/src/termchar.h b/src/termchar.h index 5502ca22949..58d0ba24232 100644 --- a/src/termchar.h +++ b/src/termchar.h @@ -70,11 +70,6 @@ struct tty_display_info /* The previous terminal frame we displayed on this tty. */ struct frame *previous_terminal_frame; -#ifdef MULTI_KBOARD - /* The terminal's keyboard object. */ - struct kboard *kboard; -#endif - /* Strings, numbers and flags taken from the termcap entry. */ char *TS_ins_line; /* "al" */ diff --git a/src/termhooks.h b/src/termhooks.h index 788b57e9d1e..86e9fd3469b 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -295,6 +295,11 @@ struct display /* The name of the display device. Do not use this to identify the display. */ char *name; +#ifdef MULTI_KBOARD + /* The device's keyboard object. */ + struct kboard *kboard; +#endif + /* Display-type dependent data shared amongst all frames on this display. */ union display_info { diff --git a/src/xfns.c b/src/xfns.c index 2910d0f3cd4..a8fa726f23d 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -3014,7 +3014,7 @@ This function is an internal primitive--use `make-frame' instead. */) display = Qnil; dpyinfo = check_x_display_info (display); #ifdef MULTI_KBOARD - kb = dpyinfo->kboard; + kb = dpyinfo->frame_display->kboard; #else kb = &the_only_kboard; #endif @@ -3086,9 +3086,6 @@ This function is an internal primitive--use `make-frame' instead. */) image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; dpyinfo_refcount = dpyinfo->reference_count; #endif /* GLYPH_DEBUG */ -#ifdef MULTI_KBOARD - FRAME_KBOARD (f) = kb; -#endif /* These colors will be set anyway later, but it's important to get the color reference counts right, so initialize them! */ @@ -4598,20 +4595,12 @@ x_create_tip_frame (dpyinfo, parms, text) int width, height; int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3; - struct kboard *kb; int face_change_count_before = face_change_count; Lisp_Object buffer; struct buffer *old_buffer; check_x (); - -#ifdef MULTI_KBOARD - kb = dpyinfo->kboard; -#else - kb = &the_only_kboard; -#endif - /* Get the name of the frame to use for resource lookup. */ name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING); if (!STRINGP (name) @@ -4662,9 +4651,6 @@ x_create_tip_frame (dpyinfo, parms, text) image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; dpyinfo_refcount = dpyinfo->reference_count; #endif /* GLYPH_DEBUG */ -#ifdef MULTI_KBOARD - FRAME_KBOARD (f) = kb; -#endif f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; f->output_data.x->explicit_parent = 0; diff --git a/src/xselect.c b/src/xselect.c index b0bd0bc97c9..c60c12c3b67 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -1010,7 +1010,7 @@ x_handle_selection_clear (event) to see if this Emacs job now owns the selection through that display. */ for (t_dpyinfo = x_display_list; t_dpyinfo; t_dpyinfo = t_dpyinfo->next) - if (t_dpyinfo->kboard == dpyinfo->kboard) + if (t_dpyinfo->frame_display->kboard == dpyinfo->frame_display->kboard) { Window owner_window = XGetSelectionOwner (t_dpyinfo->display, selection); diff --git a/src/xterm.c b/src/xterm.c index 71e1e2de1e8..68d2e46cc77 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10277,30 +10277,30 @@ x_term_init (display_name, xrm_option, resource_name) SDATA (display_name))) break; if (share) - dpyinfo->kboard = share->kboard; + display->kboard = share->frame_display->kboard; else { - dpyinfo->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); - init_kboard (dpyinfo->kboard); + display->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); + init_kboard (display->kboard); if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound)) { char *vendor = ServerVendor (dpy); UNBLOCK_INPUT; - dpyinfo->kboard->Vsystem_key_alist + display->kboard->Vsystem_key_alist = call1 (Qvendor_specific_keysyms, build_string (vendor ? vendor : "")); BLOCK_INPUT; } - dpyinfo->kboard->next_kboard = all_kboards; - all_kboards = dpyinfo->kboard; + display->kboard->next_kboard = all_kboards; + all_kboards = display->kboard; /* 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. */ if (current_kboard == initial_kboard) - current_kboard = dpyinfo->kboard; + current_kboard = display->kboard; } - dpyinfo->kboard->reference_count++; + display->kboard->reference_count++; } #endif @@ -10677,10 +10677,6 @@ x_delete_display (dpyinfo) XrmDestroyDatabase (dpyinfo->xrdb); #endif #endif -#ifdef MULTI_KBOARD - if (--dpyinfo->kboard->reference_count == 0) - delete_kboard (dpyinfo->kboard); -#endif #ifdef HAVE_X_I18N if (dpyinfo->xim) xim_close_dpy (dpyinfo); @@ -10811,6 +10807,8 @@ x_create_frame_display (struct x_display_info *dpyinfo) display->type = output_x_window; display->display_info.x = dpyinfo; dpyinfo->frame_display = display; + + /* kboard is initialized in x_term_init. */ display->clear_frame_hook = x_clear_frame; display->ins_del_lines_hook = x_ins_del_lines; diff --git a/src/xterm.h b/src/xterm.h index 5f568af935a..85cfe942586 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -327,9 +327,6 @@ struct x_display_info /* Atom used in toolkit scroll bar client messages. */ Atom Xatom_Scrollbar; -#ifdef MULTI_KBOARD - struct kboard *kboard; -#endif int cut_buffers_initialized; /* Whether we're sure they all exist */ /* The frame (if any) which has the X window that has keyboard focus.