Commit bedb9c0e authored by Karoly Lorentey's avatar Karoly Lorentey

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
parent d66d64bc
...@@ -6734,9 +6734,6 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ ...@@ -6734,9 +6734,6 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
abort (); abort ();
f->output_method = d->type; f->output_method = d->type;
f->display = d; f->display = d;
#ifdef MULTI_KBOARD
f->kboard = d->display_info.tty->kboard;
#endif
d->reference_count++; d->reference_count++;
d->display_info.tty->top_frame = selected_frame; d->display_info.tty->top_frame = selected_frame;
......
...@@ -303,9 +303,6 @@ make_frame (mini_p) ...@@ -303,9 +303,6 @@ make_frame (mini_p)
f->menu_bar_items_used = 0; f->menu_bar_items_used = 0;
f->buffer_predicate = Qnil; f->buffer_predicate = Qnil;
f->buffer_list = Qnil; f->buffer_list = Qnil;
#ifdef MULTI_KBOARD
f->kboard = initial_kboard;
#endif
f->namebuf = 0; f->namebuf = 0;
f->title = Qnil; f->title = Qnil;
f->menu_bar_window = Qnil; f->menu_bar_window = Qnil;
...@@ -425,7 +422,7 @@ make_frame_without_minibuffer (mini_window, kb, display) ...@@ -425,7 +422,7 @@ make_frame_without_minibuffer (mini_window, kb, display)
#ifdef MULTI_KBOARD #ifdef MULTI_KBOARD
if (!NILP (mini_window) 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"); error ("Frame and minibuffer must be on the same display");
#endif #endif
...@@ -552,10 +549,6 @@ make_initial_frame (void) ...@@ -552,10 +549,6 @@ make_initial_frame (void)
FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
#ifdef MULTI_KBOARD
f->kboard = initial_kboard;
#endif
return f; return f;
} }
...@@ -622,10 +615,6 @@ make_terminal_frame (struct display *display) ...@@ -622,10 +615,6 @@ make_terminal_frame (struct display *display)
FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; 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. */ /* Set the top frame to the newly created frame. */
if (FRAME_TTY (f)->top_frame if (FRAME_TTY (f)->top_frame
&& FRAME_LIVE_P (XFRAME (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. */) ...@@ -1358,6 +1347,8 @@ The functions are run with one arg, the frame to be deleted. */)
{ {
struct frame *f; struct frame *f;
struct frame *sf = SELECTED_FRAME (); struct frame *sf = SELECTED_FRAME ();
struct kboard *kb;
int minibuffer_selected; int minibuffer_selected;
if (EQ (frame, Qnil)) if (EQ (frame, Qnil))
...@@ -1513,23 +1504,25 @@ The functions are run with one arg, the frame to be deleted. */) ...@@ -1513,23 +1504,25 @@ The functions are run with one arg, the frame to be deleted. */)
if (FRAME_DISPLAY (f)->delete_frame_hook) if (FRAME_DISPLAY (f)->delete_frame_hook)
(*FRAME_DISPLAY (f)->delete_frame_hook) (f); (*FRAME_DISPLAY (f)->delete_frame_hook) (f);
{ {
struct display *display = FRAME_DISPLAY (f); struct display *display = FRAME_DISPLAY (f);
f->output_data.nothing = 0; f->output_data.nothing = 0;
f->display = 0; /* Now the frame is dead. */ f->display = 0; /* Now the frame is dead. */
/* If needed, delete the device that this frame was on. /* 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--; display->reference_count--;
if (display->reference_count == 0) if (display->reference_count == 0)
{ {
if (display->delete_display_hook) kb = NULL;
(*display->delete_display_hook) (display); if (display->delete_display_hook)
else (*display->delete_display_hook) (display);
delete_display (display); else
} delete_display (display);
}
else
kb = display->kboard;
} }
/* If we've deleted the last_nonminibuf_frame, then try to find /* 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. */) ...@@ -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 /* If there's no other frame on the same kboard, get out of
single-kboard state if we're in it for this kboard. */ single-kboard state if we're in it for this kboard. */
{ if (kb != NULL)
Lisp_Object frames; {
/* Some frame we found on the same kboard, or nil if there are none. */ Lisp_Object frames;
Lisp_Object frame_on_same_kboard; /* 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; for (frames = Vframe_list;
CONSP (frames); CONSP (frames);
frames = XCDR (frames)) frames = XCDR (frames))
{ {
Lisp_Object this; Lisp_Object this;
struct frame *f1; struct frame *f1;
this = XCAR (frames); this = XCAR (frames);
if (!FRAMEP (this)) if (!FRAMEP (this))
abort (); abort ();
f1 = XFRAME (this); f1 = XFRAME (this);
if (FRAME_KBOARD (f) == FRAME_KBOARD (f1)) if (kb == FRAME_KBOARD (f1))
frame_on_same_kboard = this; frame_on_same_kboard = this;
} }
if (NILP (frame_on_same_kboard)) if (NILP (frame_on_same_kboard))
not_single_kboard_state (FRAME_KBOARD (f)); not_single_kboard_state (kb);
} }
/* If we've deleted this keyboard's default_minibuffer_frame, try to /* If we've deleted this keyboard's default_minibuffer_frame, try to
find another one. Prefer minibuffer-only frames, but also notice find another one. Prefer minibuffer-only frames, but also notice
frames with other windows. */ 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; Lisp_Object frames;
...@@ -1612,7 +1606,7 @@ The functions are run with one arg, the frame to be deleted. */) ...@@ -1612,7 +1606,7 @@ The functions are run with one arg, the frame to be deleted. */)
/* Consider only frames on the same kboard /* Consider only frames on the same kboard
and only those with minibuffers. */ and only those with minibuffers. */
if (FRAME_KBOARD (f) == FRAME_KBOARD (f1) if (kb == FRAME_KBOARD (f1)
&& FRAME_HAS_MINIBUF_P (f1)) && FRAME_HAS_MINIBUF_P (f1))
{ {
frame_with_minibuf = this; frame_with_minibuf = this;
...@@ -1620,7 +1614,7 @@ The functions are run with one arg, the frame to be deleted. */) ...@@ -1620,7 +1614,7 @@ The functions are run with one arg, the frame to be deleted. */)
break; break;
} }
if (FRAME_KBOARD (f) == FRAME_KBOARD (f1)) if (kb == FRAME_KBOARD (f1))
frame_on_same_kboard = this; frame_on_same_kboard = this;
} }
...@@ -1635,11 +1629,11 @@ The functions are run with one arg, the frame to be deleted. */) ...@@ -1635,11 +1629,11 @@ The functions are run with one arg, the frame to be deleted. */)
if (NILP (frame_with_minibuf)) if (NILP (frame_with_minibuf))
abort (); abort ();
FRAME_KBOARD (f)->Vdefault_minibuffer_frame = frame_with_minibuf; kb->Vdefault_minibuffer_frame = frame_with_minibuf;
} }
else else
/* No frames left on this kboard--say no minibuffer either. */ /* 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. */ /* Cause frame titles to update--necessary if we now have just one frame. */
......
...@@ -292,16 +292,6 @@ struct frame ...@@ -292,16 +292,6 @@ struct frame
/* The extra width (in pixels) currently allotted for fringes. */ /* The extra width (in pixels) currently allotted for fringes. */
int left_fringe_width, right_fringe_width; 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 */ /* See FULLSCREEN_ enum below */
int want_fullscreen; int want_fullscreen;
...@@ -456,7 +446,7 @@ struct frame ...@@ -456,7 +446,7 @@ struct frame
}; };
#ifdef MULTI_KBOARD #ifdef MULTI_KBOARD
#define FRAME_KBOARD(f) ((f)->kboard) #define FRAME_KBOARD(f) ((f)->display->kboard)
#else #else
#define FRAME_KBOARD(f) (&the_only_kboard) #define FRAME_KBOARD(f) (&the_only_kboard)
#endif #endif
......
...@@ -2285,10 +2285,11 @@ init_initial_display (void) ...@@ -2285,10 +2285,11 @@ init_initial_display (void)
initial_display = create_display (); initial_display = create_display ();
initial_display->type = output_initial; initial_display->type = output_initial;
initial_display->name = xstrdup ("initial_display"); initial_display->name = xstrdup ("initial_display");
initial_display->kboard = initial_kboard;
initial_display->delete_display_hook = &delete_initial_display; initial_display->delete_display_hook = &delete_initial_display;
/* All other hooks are NULL. */ /* All other hooks are NULL. */
return initial_display; return initial_display;
} }
...@@ -2682,19 +2683,19 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", ...@@ -2682,19 +2683,19 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
tty->TF_teleray = tgetflag ("xt"); tty->TF_teleray = tgetflag ("xt");
#ifdef MULTI_KBOARD #ifdef MULTI_KBOARD
tty->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); display->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
init_kboard (tty->kboard); init_kboard (display->kboard);
tty->kboard->next_kboard = all_kboards; display->kboard->next_kboard = all_kboards;
all_kboards = tty->kboard; all_kboards = display->kboard;
display->kboard->reference_count++;
/* Don't let the initial kboard remain current longer than necessary. /* Don't let the initial kboard remain current longer than necessary.
That would cause problems if a file loaded on startup tries to That would cause problems if a file loaded on startup tries to
prompt in the mini-buffer. */ prompt in the mini-buffer. */
if (current_kboard == initial_kboard) if (current_kboard == initial_kboard)
current_kboard = tty->kboard; current_kboard = display->kboard;
tty->kboard->reference_count++;
#endif #endif
term_get_fkeys (address, tty->kboard); term_get_fkeys (address, display->kboard);
/* Get frame size from system, or else from termcap. */ /* Get frame size from system, or else from termcap. */
{ {
...@@ -3051,13 +3052,6 @@ delete_tty (struct display *display) ...@@ -3051,13 +3052,6 @@ delete_tty (struct display *display)
if (tty->Wcm) if (tty->Wcm)
xfree (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)); bzero (tty, sizeof (struct tty_display_info));
xfree (tty); xfree (tty);
deleting_tty = 0; deleting_tty = 0;
...@@ -3170,6 +3164,11 @@ delete_display (struct display *display) ...@@ -3170,6 +3164,11 @@ delete_display (struct display *display)
if (display->name) if (display->name)
xfree (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)); bzero (display, sizeof (struct display));
xfree (display); xfree (display);
} }
......
...@@ -70,11 +70,6 @@ struct tty_display_info ...@@ -70,11 +70,6 @@ struct tty_display_info
/* The previous terminal frame we displayed on this tty. */ /* The previous terminal frame we displayed on this tty. */
struct frame *previous_terminal_frame; 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. */ /* Strings, numbers and flags taken from the termcap entry. */
char *TS_ins_line; /* "al" */ char *TS_ins_line; /* "al" */
......
...@@ -295,6 +295,11 @@ struct display ...@@ -295,6 +295,11 @@ struct display
/* The name of the display device. Do not use this to identify the display. */ /* The name of the display device. Do not use this to identify the display. */
char *name; 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. */ /* Display-type dependent data shared amongst all frames on this display. */
union display_info union display_info
{ {
......
...@@ -3014,7 +3014,7 @@ This function is an internal primitive--use `make-frame' instead. */) ...@@ -3014,7 +3014,7 @@ This function is an internal primitive--use `make-frame' instead. */)
display = Qnil; display = Qnil;
dpyinfo = check_x_display_info (display); dpyinfo = check_x_display_info (display);
#ifdef MULTI_KBOARD #ifdef MULTI_KBOARD
kb = dpyinfo->kboard; kb = dpyinfo->frame_display->kboard;
#else #else
kb = &the_only_kboard; kb = &the_only_kboard;
#endif #endif
...@@ -3086,9 +3086,6 @@ This function is an internal primitive--use `make-frame' instead. */) ...@@ -3086,9 +3086,6 @@ This function is an internal primitive--use `make-frame' instead. */)
image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count; dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */ #endif /* GLYPH_DEBUG */
#ifdef MULTI_KBOARD
FRAME_KBOARD (f) = kb;
#endif
/* These colors will be set anyway later, but it's important /* These colors will be set anyway later, but it's important
to get the color reference counts right, so initialize them! */ to get the color reference counts right, so initialize them! */
...@@ -4598,20 +4595,12 @@ x_create_tip_frame (dpyinfo, parms, text) ...@@ -4598,20 +4595,12 @@ x_create_tip_frame (dpyinfo, parms, text)
int width, height; int width, height;
int count = SPECPDL_INDEX (); int count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3; struct gcpro gcpro1, gcpro2, gcpro3;
struct kboard *kb;
int face_change_count_before = face_change_count; int face_change_count_before = face_change_count;
Lisp_Object buffer; Lisp_Object buffer;
struct buffer *old_buffer; struct buffer *old_buffer;
check_x (); 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. */ /* Get the name of the frame to use for resource lookup. */
name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING); name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
if (!STRINGP (name) if (!STRINGP (name)
...@@ -4662,9 +4651,6 @@ x_create_tip_frame (dpyinfo, parms, text) ...@@ -4662,9 +4651,6 @@ x_create_tip_frame (dpyinfo, parms, text)
image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count; dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */ #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->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
f->output_data.x->explicit_parent = 0; f->output_data.x->explicit_parent = 0;
......
...@@ -1010,7 +1010,7 @@ x_handle_selection_clear (event) ...@@ -1010,7 +1010,7 @@ x_handle_selection_clear (event)
to see if this Emacs job now owns the selection to see if this Emacs job now owns the selection
through that display. */ through that display. */
for (t_dpyinfo = x_display_list; t_dpyinfo; t_dpyinfo = t_dpyinfo->next) 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 Window owner_window
= XGetSelectionOwner (t_dpyinfo->display, selection); = XGetSelectionOwner (t_dpyinfo->display, selection);
......
...@@ -10277,30 +10277,30 @@ x_term_init (display_name, xrm_option, resource_name) ...@@ -10277,30 +10277,30 @@ x_term_init (display_name, xrm_option, resource_name)
SDATA (display_name))) SDATA (display_name)))
break; break;
if (share) if (share)
dpyinfo->kboard = share->kboard; display->kboard = share->frame_display->kboard;
else else
{ {
dpyinfo->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); display->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
init_kboard (dpyinfo->kboard); init_kboard (display->kboard);
if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound)) if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound))
{ {
char *vendor = ServerVendor (dpy); char *vendor = ServerVendor (dpy);
UNBLOCK_INPUT; UNBLOCK_INPUT;
dpyinfo->kboard->Vsystem_key_alist display->kboard->Vsystem_key_alist
= call1 (Qvendor_specific_keysyms, = call1 (Qvendor_specific_keysyms,
build_string (vendor ? vendor : "")); build_string (vendor ? vendor : ""));
BLOCK_INPUT; BLOCK_INPUT;
} }
dpyinfo->kboard->next_kboard = all_kboards; display->kboard->next_kboard = all_kboards;
all_kboards = dpyinfo->kboard; all_kboards = display->kboard;
/* Don't let the initial kboard remain current longer than necessary. /* Don't let the initial kboard remain current longer than necessary.
That would cause problems if a file loaded on startup tries to That would cause problems if a file loaded on startup tries to
prompt in the mini-buffer. */ prompt in the mini-buffer. */
if (current_kboard == initial_kboard) if (current_kboard == initial_kboard)
current_kboard = dpyinfo->kboard; current_kboard = display->kboard;
} }
dpyinfo->kboard->reference_count++; display->kboard->reference_count++;
} }
#endif #endif
...@@ -10677,10 +10677,6 @@ x_delete_display (dpyinfo) ...@@ -10677,10 +10677,6 @@ x_delete_display (dpyinfo)
XrmDestroyDatabase (dpyinfo->xrdb); XrmDestroyDatabase (dpyinfo->xrdb);
#endif #endif
#endif #endif
#ifdef MULTI_KBOARD
if (--dpyinfo->kboard->reference_count == 0)
delete_kboard (dpyinfo->kboard);
#endif
#ifdef HAVE_X_I18N #ifdef HAVE_X_I18N
if (dpyinfo->xim) if (dpyinfo->xim)
xim_close_dpy (dpyinfo); xim_close_dpy (dpyinfo);
...@@ -10811,6 +10807,8 @@ x_create_frame_display (struct x_display_info *dpyinfo) ...@@ -10811,6 +10807,8 @@ x_create_frame_display (struct x_display_info *dpyinfo)
display->type = output_x_window; display->type = output_x_window;
display->display_info.x = dpyinfo; display->display_info.x = dpyinfo;
dpyinfo->frame_display = display; dpyinfo->frame_display = display;
/* kboard is initialized in x_term_init. */
display->clear_frame_hook = x_clear_frame; display->clear_frame_hook = x_clear_frame;
display->ins_del_lines_hook = x_ins_del_lines; display->ins_del_lines_hook = x_ins_del_lines;
......
...@@ -327,9 +327,6 @@ struct x_display_info ...@@ -327,9 +327,6 @@ struct x_display_info
/* Atom used in toolkit scroll bar client messages. */ /* Atom used in toolkit scroll bar client messages. */
Atom Xatom_Scrollbar; Atom Xatom_Scrollbar;
#ifdef MULTI_KBOARD
struct kboard *kboard;
#endif
int cut_buffers_initialized; /* Whether we're sure they all exist */ int cut_buffers_initialized; /* Whether we're sure they all exist */
/* The frame (if any) which has the X window that has keyboard focus. /* The frame (if any) which has the X window that has keyboard focus.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment