diff options
Diffstat (limited to 'src/frame.c')
-rw-r--r-- | src/frame.c | 305 |
1 files changed, 254 insertions, 51 deletions
diff --git a/src/frame.c b/src/frame.c index 934c11d98bc..c7b5491500f 100644 --- a/src/frame.c +++ b/src/frame.c @@ -42,6 +42,7 @@ Boston, MA 02111-1307, USA. */ #include "fontset.h" #endif #include "blockinput.h" +#include "termchar.h" #include "termhooks.h" #include "dispextern.h" #include "window.h" @@ -106,12 +107,13 @@ Lisp_Object Qmenu_bar_lines, Qtool_bar_lines; Lisp_Object Qleft_fringe, Qright_fringe; Lisp_Object Qbuffer_predicate, Qbuffer_list; Lisp_Object Qtty_color_mode; +Lisp_Object Qtty, Qtty_type; +Lisp_Object Qwindow_system; Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; Lisp_Object Qface_set_after_frame_default; - Lisp_Object Vterminal_frame; Lisp_Object Vdefault_frame_alist; Lisp_Object Vdefault_frame_scroll_bars; @@ -121,8 +123,8 @@ Lisp_Object Vdelete_frame_functions; static void set_menu_bar_lines_1 (window, n) - Lisp_Object window; - int n; + Lisp_Object window; + int n; { struct window *w = XWINDOW (window); @@ -180,8 +182,6 @@ set_menu_bar_lines (f, value, oldval) Lisp_Object Vemacs_iconified; Lisp_Object Vframe_list; -struct x_output tty_display; - extern Lisp_Object Vminibuffer_list; extern Lisp_Object get_minibuffer (); extern Lisp_Object Fhandle_switch_frame (); @@ -203,6 +203,7 @@ See also `frame-live-p'. */) return Qnil; switch (XFRAME (object)->output_method) { + case output_initial: /* The initial frame is like a termcap frame. */ case output_termcap: return Qt; case output_x_window: @@ -233,6 +234,30 @@ return values. */) : Qnil); } +DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0, + doc: /* The name of the window system that FRAME is displaying through. +The value is a symbol---for instance, 'x' for X windows. +The value is nil if Emacs is using a text-only terminal. + +FRAME defaults to the currently selected frame. */) + (frame) + Lisp_Object frame; +{ + Lisp_Object type; + if (NILP (frame)) + frame = selected_frame; + + type = Fframep (frame); + + if (NILP (type)) + wrong_type_argument (Qframep, frame); + + if (EQ (type, Qt)) + return Qnil; + else + return type; +} + struct frame * make_frame (mini_p) int mini_p; @@ -474,18 +499,19 @@ make_minibuffer_frame () } #endif /* HAVE_WINDOW_SYSTEM */ -/* Construct a frame that refers to the terminal (stdin and stdout). */ +/* Construct a frame that refers to a terminal. */ static int terminal_frame_count; struct frame * -make_terminal_frame () +make_initial_frame (void) { - register struct frame *f; + struct frame *f; + struct display *display; Lisp_Object frame; - char name[20]; #ifdef MULTI_KBOARD + /* Create the initial keyboard. */ if (!initial_kboard) { initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); @@ -499,6 +525,52 @@ make_terminal_frame () if (! (NILP (Vframe_list) || CONSP (Vframe_list))) Vframe_list = Qnil; + display = init_initial_display (); + + f = make_frame (1); + XSETFRAME (frame, f); + + Vframe_list = Fcons (frame, Vframe_list); + + terminal_frame_count = 1; + f->name = build_string ("F1"); + + f->visible = 1; + f->async_visible = 1; + + f->output_method = display->type; + f->display = display; + f->display->reference_count++; + f->output_data.nothing = 0; + + FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; + FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR; + + 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; +} + + +struct frame * +make_terminal_frame (tty_name, tty_type) + char *tty_name; + char *tty_type; +{ + register struct frame *f; + struct display *display; + Lisp_Object frame; + char name[20]; + + /* Open the display before creating the new frame, because + create_tty_display might throw an error. */ + display = term_init (tty_name, tty_type, 0); /* Errors are not fatal. */ + f = make_frame (1); XSETFRAME (frame, f); @@ -537,12 +609,35 @@ make_terminal_frame () #else #ifdef WINDOWSNT f->output_method = output_termcap; - f->output_data.x = &tty_display; + f->output_data.x = &tty_display; /* XXX ??? */ #else #ifdef MAC_OS8 make_mac_terminal_frame (f); #else - f->output_data.x = &tty_display; + { + f->output_method = output_termcap; + f->display = display; + f->display->reference_count++; + create_tty_output (f); + + FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; + FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR; + + 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))) + XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */ + + FRAME_TTY (f)->top_frame = frame; + } + #ifdef CANNOT_DUMP FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR; FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR; @@ -559,12 +654,21 @@ make_terminal_frame () DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame, 1, 1, 0, - doc: /* Create an additional terminal frame. -You can create multiple frames on a text-only terminal in this way. -Only the selected terminal frame is actually displayed. + doc: /* Create an additional terminal frame, possibly on another terminal. This function takes one argument, an alist specifying frame parameters. -In practice, generally you don't need to specify any parameters. -Note that changing the size of one terminal frame automatically affects all. */) + +You can create multiple frames on a single text-only terminal, but +only one of them (the selected terminal frame) is actually displayed. + +In practice, generally you don't need to specify any parameters, +except when you want to create a new frame on another terminal. +In that case, the `tty' parameter specifies the device file to open, +and the `tty-type' parameter specifies the terminal type. Example: + + (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm"))) + +Note that changing the size of one terminal frame automatically +affects all frames on the same terminal device. */) (parms) Lisp_Object parms; { @@ -582,20 +686,73 @@ Note that changing the size of one terminal frame automatically affects all. */ if (sf->output_method != output_mac) error ("Not running on a Macintosh screen; cannot make a new Macintosh frame"); #else +#if 0 /* This should work now! */ if (sf->output_method != output_termcap) error ("Not using an ASCII terminal now; cannot make a new ASCII frame"); #endif +#endif #endif /* not MSDOS */ - f = make_terminal_frame (); + { + Lisp_Object tty, tty_type; + char *name = 0, *type = 0; + + /* XXX Ugh, there must be a better way to do this. */ + tty = Fassq (Qtty, parms); + if (EQ (tty, Qnil)) + tty = Fassq (Qtty, XFRAME (selected_frame)->param_alist); + if (EQ (tty, Qnil) && FRAME_TERMCAP_P (XFRAME (selected_frame)) + && FRAME_TTY (XFRAME (selected_frame))->name) + tty = build_string (FRAME_TTY (XFRAME (selected_frame))->name); + if (EQ (tty, Qnil)) + tty = Fassq (Qtty, Vdefault_frame_alist); + if (! EQ (tty, Qnil) && ! STRINGP (tty)) + tty = XCDR (tty); + if (EQ (tty, Qnil) || !STRINGP (tty)) + tty = Qnil; + + tty_type = Fassq (Qtty_type, parms); + if (EQ (tty_type, Qnil)) + tty_type = Fassq (Qtty, XFRAME (selected_frame)->param_alist); + if (EQ (tty_type, Qnil) && FRAME_TERMCAP_P (XFRAME (selected_frame)) + && FRAME_TTY (XFRAME (selected_frame))->type) + tty_type = build_string (FRAME_TTY (XFRAME (selected_frame))->type); + if (EQ (tty_type, Qnil)) + tty_type = Fassq (Qtty_type, Vdefault_frame_alist); + if (! EQ (tty_type, Qnil) && ! STRINGP (tty_type)) + tty_type = XCDR (tty_type); + if (EQ (tty_type, Qnil) || !STRINGP (tty_type)) + tty_type = Qnil; + + if (! EQ (tty, Qnil)) + { + name = (char *) alloca (SBYTES (tty) + 1); + strncpy (name, SDATA (tty), SBYTES (tty)); + name[SBYTES (tty)] = 0; + } + + if (! EQ (tty_type, Qnil)) + { + type = (char *) alloca (SBYTES (tty_type) + 1); + strncpy (type, SDATA (tty_type), SBYTES (tty_type)); + type[SBYTES (tty_type)] = 0; + } + + f = make_terminal_frame (name, type); + } - change_frame_size (f, FRAME_LINES (sf), - FRAME_COLS (sf), 0, 0, 0); + { + int width, height; + get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height); + change_frame_size (f, height, width, 0, 0, 0); + } + adjust_glyphs (f); calculate_costs (f); XSETFRAME (frame, f); Fmodify_frame_parameters (frame, Vdefault_frame_alist); Fmodify_frame_parameters (frame, parms); + Fmodify_frame_parameters (frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil)); /* Make the frame face alist be frame-specific, so that each frame could change its face definitions independently. */ @@ -694,6 +851,15 @@ do_switch_frame (frame, track, for_deletion) if (!for_deletion && FRAME_HAS_MINIBUF_P (sf)) resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1); + if (FRAME_TERMCAP_P (XFRAME (selected_frame)) + && FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_TTY (XFRAME (selected_frame)) == FRAME_TTY (XFRAME (frame))) + { + XFRAME (selected_frame)->async_visible = 2; /* obscured */ + XFRAME (frame)->async_visible = 1; + FRAME_TTY (XFRAME (frame))->top_frame = frame; + } + selected_frame = frame; if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame))) last_nonminibuf_frame = XFRAME (selected_frame); @@ -927,7 +1093,10 @@ next_frame (frame, minibuf) f = XCAR (tail); if (passed - && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) + && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) + || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame))))) { /* Decide whether this frame is eligible to be returned. */ @@ -1004,7 +1173,10 @@ prev_frame (frame, minibuf) if (EQ (frame, f) && !NILP (prev)) return prev; - if (FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) + if ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) + || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame)) + && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame)))) { /* Decide whether this frame is eligible to be returned, according to minibuf. */ @@ -1231,7 +1403,7 @@ The functions are run with one arg, the frame to be deleted. */) { FOR_EACH_FRAME (tail, frame1) { - if (! EQ (frame, frame1)) + if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1))) break; } } @@ -1298,13 +1470,26 @@ The functions are run with one arg, the frame to be deleted. */) promise that the display of the frame must be valid until we have called the window-system-dependent frame destruction routine. */ - /* I think this should be done with a hook. */ -#ifdef HAVE_WINDOW_SYSTEM - if (FRAME_WINDOW_P (f)) - x_destroy_window (f); -#endif + 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->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.) */ + display->reference_count--; + if (display->reference_count == 0) + { + if (display->delete_display_hook) + (*display->delete_display_hook) (display); + else + delete_display (display); + } + } /* If we've deleted the last_nonminibuf_frame, then try to find another one. */ @@ -1419,11 +1604,11 @@ and returns whatever that function returns. */) #ifdef HAVE_MOUSE /* It's okay for the hook to refrain from storing anything. */ - if (mouse_position_hook) - (*mouse_position_hook) (&f, -1, - &lispy_dummy, &party_dummy, - &x, &y, - &long_dummy); + if (FRAME_DISPLAY (f)->mouse_position_hook) + (*FRAME_DISPLAY (f)->mouse_position_hook) (&f, -1, + &lispy_dummy, &party_dummy, + &x, &y, + &long_dummy); if (! NILP (x)) { col = XINT (x); @@ -1462,11 +1647,11 @@ and nil for X and Y. */) #ifdef HAVE_MOUSE /* It's okay for the hook to refrain from storing anything. */ - if (mouse_position_hook) - (*mouse_position_hook) (&f, -1, - &lispy_dummy, &party_dummy, - &x, &y, - &long_dummy); + if (FRAME_DISPLAY (f)->mouse_position_hook) + (*FRAME_DISPLAY (f)->mouse_position_hook) (&f, -1, + &lispy_dummy, &party_dummy, + &x, &y, + &long_dummy); #endif XSETFRAME (lispy_dummy, f); return Fcons (lispy_dummy, Fcons (x, y)); @@ -1728,16 +1913,19 @@ doesn't support multiple overlapping frames, this function does nothing. */) (frame) Lisp_Object frame; { + struct frame *f; if (NILP (frame)) frame = selected_frame; CHECK_LIVE_FRAME (frame); + f = XFRAME (frame); + /* Do like the documentation says. */ Fmake_frame_visible (frame); - if (frame_raise_lower_hook) - (*frame_raise_lower_hook) (XFRAME (frame), 1); + if (FRAME_DISPLAY (f)->frame_raise_lower_hook) + (*FRAME_DISPLAY (f)->frame_raise_lower_hook) (f, 1); return Qnil; } @@ -1751,13 +1939,17 @@ doesn't support multiple overlapping frames, this function does nothing. */) (frame) Lisp_Object frame; { + struct frame *f; + if (NILP (frame)) frame = selected_frame; CHECK_LIVE_FRAME (frame); - if (frame_raise_lower_hook) - (*frame_raise_lower_hook) (XFRAME (frame), 0); + f = XFRAME (frame); + + if (FRAME_DISPLAY (f)->frame_raise_lower_hook) + (*FRAME_DISPLAY (f)->frame_raise_lower_hook) (f, 0); return Qnil; } @@ -1791,6 +1983,8 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */) (frame, focus_frame) Lisp_Object frame, focus_frame; { + struct frame *f; + /* Note that we don't check for a live frame here. It's reasonable to redirect the focus of a frame you're about to delete, if you know what other frame should receive those keystrokes. */ @@ -1799,10 +1993,12 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */) if (! NILP (focus_frame)) CHECK_LIVE_FRAME (focus_frame); - XFRAME (frame)->focus_frame = focus_frame; + f = XFRAME (frame); + + f->focus_frame = focus_frame; - if (frame_rehighlight_hook) - (*frame_rehighlight_hook) (XFRAME (frame)); + if (FRAME_DISPLAY (f)->frame_rehighlight_hook) + (*FRAME_DISPLAY (f)->frame_rehighlight_hook) (f); return Qnil; } @@ -2691,8 +2887,8 @@ x_set_frame_parameters (f, alist) if (NATNUMP (param_index) && (XFASTINT (param_index) < sizeof (frame_parms)/sizeof (frame_parms[0])) - && rif->frame_parm_handlers[XINT (param_index)]) - (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); + && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)]) + (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); } } } @@ -2735,8 +2931,8 @@ x_set_frame_parameters (f, alist) if (NATNUMP (param_index) && (XFASTINT (param_index) < sizeof (frame_parms)/sizeof (frame_parms[0])) - && rif->frame_parm_handlers[XINT (param_index)]) - (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); + && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)]) + (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); } } @@ -3937,7 +4133,13 @@ syms_of_frame () staticpro (&Qbackground_mode); Qtty_color_mode = intern ("tty-color-mode"); staticpro (&Qtty_color_mode); - + Qtty = intern ("tty"); + staticpro (&Qtty); + Qtty_type = intern ("tty-type"); + staticpro (&Qtty_type); + Qwindow_system = intern ("window-system"); + staticpro (&Qwindow_system); + Qface_set_after_frame_default = intern ("face-set-after-frame-default"); staticpro (&Qface_set_after_frame_default); @@ -4026,7 +4228,7 @@ Setting this variable does not affect existing frames, only new ones. */); staticpro (&Qinhibit_default_face_x_resources); DEFVAR_LISP ("terminal-frame", &Vterminal_frame, - doc: /* The initial frame-object, which represents Emacs's stdout. */); + doc: /* The initial frame-object, which represents Emacs's stdout. */); DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified, doc: /* Non-nil if all of emacs is iconified and frame updates are not needed. */); @@ -4074,6 +4276,7 @@ This variable is local to the current terminal and cannot be buffer-local. */); defsubr (&Sactive_minibuffer_window); defsubr (&Sframep); defsubr (&Sframe_live_p); + defsubr (&Swindow_system); defsubr (&Smake_terminal_frame); defsubr (&Shandle_switch_frame); defsubr (&Signore_event); |