diff options
Diffstat (limited to 'src/frame.c')
-rw-r--r-- | src/frame.c | 114 |
1 files changed, 108 insertions, 6 deletions
diff --git a/src/frame.c b/src/frame.c index 1d42d0cb4de..d72dfec0cf8 100644 --- a/src/frame.c +++ b/src/frame.c @@ -69,6 +69,9 @@ static struct frame *last_nonminibuf_frame; /* False means there are no visible garbaged frames. */ bool frame_garbaged; +/* The default tab bar height for future frames. */ +int frame_default_tab_bar_height; + /* The default tool bar height for future frames. */ #ifdef HAVE_EXT_TOOL_BAR enum { frame_default_tool_bar_height = 0 }; @@ -230,6 +233,35 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) 0, 1, 0, 0); } } + +static void +set_tab_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) +{ + int nlines; + int olines = FRAME_TAB_BAR_LINES (f); + + /* Right now, tab bars don't work properly in minibuf-only frames; + most of the commands try to apply themselves to the minibuffer + frame itself, and get an error because you can't switch buffers + in or split the minibuffer window. */ + if (FRAME_MINIBUF_ONLY_P (f)) + return; + + if (TYPE_RANGED_FIXNUMP (int, value)) + nlines = XFIXNUM (value); + else + nlines = 0; + + if (nlines != olines) + { + windows_or_buffers_changed = 14; + FRAME_TAB_BAR_LINES (f) = nlines; + FRAME_TAB_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f); + change_frame_size (f, FRAME_COLS (f), + FRAME_LINES (f) + olines - nlines, + 0, 1, 0, 0); + } +} Lisp_Object Vframe_list; @@ -379,6 +411,7 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, if ((FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) && NILP (horizontal)) { int min_height = (FRAME_MENU_BAR_LINES (f) + + FRAME_TAB_BAR_LINES (f) + FRAME_WANTS_MODELINE_P (f) + 2); /* one text line and one echo-area line */ if (retval < min_height) @@ -719,6 +752,15 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f)) FrameCols (FRAME_TTY (f)) = new_cols; +#if defined (HAVE_WINDOW_SYSTEM) + if (WINDOWP (f->tab_bar_window)) + { + XWINDOW (f->tab_bar_window)->pixel_width = new_windows_width; + XWINDOW (f->tab_bar_window)->total_cols + = new_windows_width / unit_width; + } +#endif + #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR) if (WINDOWP (f->tool_bar_window)) { @@ -838,6 +880,8 @@ make_frame (bool mini_p) f->after_make_frame = false; f->inhibit_horizontal_resize = false; f->inhibit_vertical_resize = false; + f->tab_bar_redisplayed = false; + f->tab_bar_resized = false; f->tool_bar_redisplayed = false; f->tool_bar_resized = false; f->column_width = 1; /* !FRAME_WINDOW_P value. */ @@ -856,6 +900,7 @@ make_frame (bool mini_p) f->no_accept_focus = false; f->z_group = z_group_none; f->tooltip = false; + f->last_tab_bar_item = -1; #ifndef HAVE_EXT_TOOL_BAR f->last_tool_bar_item = -1; #endif @@ -1084,6 +1129,9 @@ make_initial_frame (void) /* The default value of menu-bar-mode is t. */ set_menu_bar_lines (f, make_fixnum (1), Qnil); + /* The default value of tab-bar-mode is nil. */ + set_tab_bar_lines (f, make_fixnum (0), Qnil); + /* Allocate glyph matrices. */ adjust_frame_glyphs (f); @@ -1142,9 +1190,13 @@ make_terminal_frame (struct terminal *terminal) #endif FRAME_MENU_BAR_LINES (f) = NILP (Vmenu_bar_mode) ? 0 : 1; - FRAME_LINES (f) = FRAME_LINES (f) - FRAME_MENU_BAR_LINES (f); + FRAME_TAB_BAR_LINES (f) = NILP (Vtab_bar_mode) ? 0 : 1; + FRAME_LINES (f) = FRAME_LINES (f) - FRAME_MENU_BAR_LINES (f) + - FRAME_TAB_BAR_LINES (f); FRAME_MENU_BAR_HEIGHT (f) = FRAME_MENU_BAR_LINES (f) * FRAME_LINE_HEIGHT (f); - FRAME_TEXT_HEIGHT (f) = FRAME_TEXT_HEIGHT (f) - FRAME_MENU_BAR_HEIGHT (f); + FRAME_TAB_BAR_HEIGHT (f) = FRAME_TAB_BAR_LINES (f) * FRAME_LINE_HEIGHT (f); + FRAME_TEXT_HEIGHT (f) = FRAME_TEXT_HEIGHT (f) - FRAME_MENU_BAR_HEIGHT (f) + - FRAME_TAB_BAR_HEIGHT (f); /* Set the top frame to the newly created frame. */ if (FRAMEP (FRAME_TTY (f)->top_frame) @@ -1266,7 +1318,8 @@ affects all frames on the same terminal device. */) { int width, height; get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height); - adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f), + adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f) + - FRAME_TAB_BAR_LINES (f), 5, 0, Qterminal_frame); } @@ -3071,6 +3124,8 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) { if (EQ (prop, Qmenu_bar_lines)) set_menu_bar_lines (f, val, make_fixnum (FRAME_MENU_BAR_LINES (f))); + else if (EQ (prop, Qtab_bar_lines)) + set_tab_bar_lines (f, val, make_fixnum (FRAME_TAB_BAR_LINES (f))); else if (EQ (prop, Qname)) set_term_frame_name (f, val); } @@ -3166,6 +3221,8 @@ If FRAME is omitted or nil, return information on the currently selected frame. Lisp_Object lines; XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f)); store_in_alist (&alist, Qmenu_bar_lines, lines); + XSETFASTINT (lines, FRAME_TAB_BAR_LINES (f)); + store_in_alist (&alist, Qtab_bar_lines, lines); } return alist; @@ -3695,6 +3752,7 @@ static const struct frame_parm_table frame_parms[] = {"vertical-scroll-bars", SYMBOL_INDEX (Qvertical_scroll_bars)}, {"horizontal-scroll-bars", SYMBOL_INDEX (Qhorizontal_scroll_bars)}, {"visibility", SYMBOL_INDEX (Qvisibility)}, + {"tab-bar-lines", SYMBOL_INDEX (Qtab_bar_lines)}, {"tool-bar-lines", SYMBOL_INDEX (Qtool_bar_lines)}, {"scroll-bar-foreground", SYMBOL_INDEX (Qscroll_bar_foreground)}, {"scroll-bar-background", SYMBOL_INDEX (Qscroll_bar_background)}, @@ -4450,6 +4508,8 @@ gui_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) #ifdef HAVE_X_WINDOWS store_frame_param (f, Qfont_parameter, font_param); #endif + /* Recalculate tabbar height. */ + f->n_tab_bar_rows = 0; /* Recalculate toolbar height. */ f->n_tool_bar_rows = 0; @@ -5390,8 +5450,8 @@ On Nextstep, this just calls `ns-parse-geometry'. */) #define DEFAULT_COLS 80 long -gui_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p, - int *x_width, int *x_height) +gui_figure_window_size (struct frame *f, Lisp_Object parms, bool tabbar_p, + bool toolbar_p, int *x_width, int *x_height) { Lisp_Object height, width, user_size, top, left, user_position; long window_prompting = 0; @@ -5411,6 +5471,36 @@ gui_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p, f->top_pos = 0; f->left_pos = 0; + /* Calculate a tab bar height so that the user gets a text display + area of the size he specified with -g or via .Xdefaults. Later + changes of the tab bar height don't change the frame size. This + is done so that users can create tall Emacs frames without having + to guess how tall the tab bar will get. */ + if (tabbar_p && FRAME_TAB_BAR_LINES (f)) + { + if (frame_default_tab_bar_height) + FRAME_TAB_BAR_HEIGHT (f) = frame_default_tab_bar_height; + else + { + int margin, relief; + + relief = (tab_bar_button_relief < 0 + ? DEFAULT_TAB_BAR_BUTTON_RELIEF + : min (tab_bar_button_relief, 1000000)); + + if (RANGED_FIXNUMP (1, Vtab_bar_button_margin, INT_MAX)) + margin = XFIXNAT (Vtab_bar_button_margin); + else if (CONSP (Vtab_bar_button_margin) + && RANGED_FIXNUMP (1, XCDR (Vtab_bar_button_margin), INT_MAX)) + margin = XFIXNAT (XCDR (Vtab_bar_button_margin)); + else + margin = 0; + + FRAME_TAB_BAR_HEIGHT (f) + = DEFAULT_TAB_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief; + } + } + /* Calculate a tool bar height so that the user gets a text display area of the size he specified with -g or via .Xdefaults. Later changes of the tool bar height don't change the frame size. This @@ -5837,6 +5927,7 @@ syms_of_frame (void) DEFSYM (Qtitle_bar_size, "title-bar-size"); DEFSYM (Qmenu_bar_external, "menu-bar-external"); DEFSYM (Qmenu_bar_size, "menu-bar-size"); + DEFSYM (Qtab_bar_size, "tab-bar-size"); DEFSYM (Qtool_bar_external, "tool-bar-external"); DEFSYM (Qtool_bar_size, "tool-bar-size"); /* The following are used for frame_size_history. */ @@ -5860,7 +5951,9 @@ syms_of_frame (void) DEFSYM (Qx_net_wm_state, "x-net-wm-state"); DEFSYM (Qx_handle_net_wm_state, "x-handle-net-wm-state"); DEFSYM (Qtb_size_cb, "tb-size-cb"); + DEFSYM (Qupdate_frame_tab_bar, "update-frame-tab-bar"); DEFSYM (Qupdate_frame_tool_bar, "update-frame-tool-bar"); + DEFSYM (Qfree_frame_tab_bar, "free-frame-tab-bar"); DEFSYM (Qfree_frame_tool_bar, "free-frame-tool-bar"); DEFSYM (Qx_set_menu_bar_lines, "x-set-menu-bar-lines"); DEFSYM (Qchange_frame_size, "change-frame-size"); @@ -5910,6 +6003,7 @@ syms_of_frame (void) DEFSYM (Qscroll_bar_width, "scroll-bar-width"); DEFSYM (Qsticky, "sticky"); DEFSYM (Qtitle, "title"); + DEFSYM (Qtab_bar_lines, "tab-bar-lines"); DEFSYM (Qtool_bar_lines, "tool-bar-lines"); DEFSYM (Qtool_bar_position, "tool-bar-position"); DEFSYM (Qunsplittable, "unsplittable"); @@ -6071,6 +6165,14 @@ either customize it (see the info node `Easy Customization') or call the function `menu-bar-mode'. */); Vmenu_bar_mode = Qt; + DEFVAR_LISP ("tab-bar-mode", Vtab_bar_mode, + doc: /* Non-nil if Tab-Bar mode is enabled. +See the command `tab-bar-mode' for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `tab-bar-mode'. */); + Vtab_bar_mode = Qnil; + DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode, doc: /* Non-nil if Tool-Bar mode is enabled. See the command `tool-bar-mode' for a description of this minor mode. @@ -6200,7 +6302,7 @@ any of the parameters listed above, Emacs may try to enlarge the frame even if this option is non-nil. */); #if defined (HAVE_WINDOW_SYSTEM) #if defined (USE_LUCID) || defined (USE_MOTIF) || defined (HAVE_NTGUI) - frame_inhibit_implied_resize = list1 (Qtool_bar_lines); + frame_inhibit_implied_resize = list2 (Qtab_bar_lines, Qtool_bar_lines); #else frame_inhibit_implied_resize = Qnil; #endif |