Commit c29f96fa authored by Martin Rudalics's avatar Martin Rudalics

Fix handling of menu bar line on TTY frames (Bug#18136) (Bug#18196).

* dispnew.c (handle_window_change_signal):
* keyboard.c (Fsuspend_emacs): Call change_frame_size with
frame's menu bar lines subtracted from height.
* frame.c (frame_inhibit_resize): Inhibit resizing of TTY
frames.
(adjust_frame_size): Count in menu bar when setting FrameRows.
(make_terminal_frame): When setting up the frame's lines and
text height don't count in the menu bar.
(Fmake_terminal_frame): Call adjust_frame_size with menu bar
lines subtracted from height.
(do_switch_frame): Set tty's FrameRows to number of total lines
of frame.
(Fframe_pixel_height, Fframe_pixel_width): If no window system
is used, return total number of lines and columns.
* menu.c (emulate_dialog_with_menu): Use FRAME_TOTAL_LINES instead
of FRAME_LINES.
* term.c (OUTPUT, tty_set_terminal_modes)
(tty_set_terminal_window, tty_set_scroll_region)
(tty_clear_to_end, tty_write_glyphs, tty_write_glyphs_with_face)
(tty_ins_del_lines, tty_menu_display, tty_menu_activate): Use
FRAME_TOTAL_LINES instead of FRAME_LINES.
(Fresume_tty): Use FRAME_TOTAL_LINES instead of FRAME_LINES.
Call change_frame_size with frame's menu bar lines subtracted
from height.
* w32console.c (w32con_clear_to_end, w32con_clear_frame)
(w32con_ins_del_lines): Use FRAME_TOTAL_LINES instead of
FRAME_LINES.
parent aa400809
2014-08-10 Martin Rudalics <rudalics@gmx.at>
Fix handling of menu bar line on TTY frames (Bug#18136)
(Bug#18196).
* dispnew.c (handle_window_change_signal):
* keyboard.c (Fsuspend_emacs): Call change_frame_size with
frame's menu bar lines subtracted from height.
* frame.c (frame_inhibit_resize): Inhibit resizing of TTY
frames.
(adjust_frame_size): Count in menu bar when setting FrameRows.
(make_terminal_frame): When setting up the frame's lines and
text height don't count in the menu bar.
(Fmake_terminal_frame): Call adjust_frame_size with menu bar
lines subtracted from height.
(do_switch_frame): Set tty's FrameRows to number of total lines
of frame.
(Fframe_pixel_height, Fframe_pixel_width): If no window system
is used, return total number of lines and columns.
* menu.c (emulate_dialog_with_menu): Use FRAME_TOTAL_LINES instead
of FRAME_LINES.
* term.c (OUTPUT, tty_set_terminal_modes)
(tty_set_terminal_window, tty_set_scroll_region)
(tty_clear_to_end, tty_write_glyphs, tty_write_glyphs_with_face)
(tty_ins_del_lines, tty_menu_display, tty_menu_activate): Use
FRAME_TOTAL_LINES instead of FRAME_LINES.
(Fresume_tty): Use FRAME_TOTAL_LINES instead of FRAME_LINES.
Call change_frame_size with frame's menu bar lines subtracted
from height.
* w32console.c (w32con_clear_to_end, w32con_clear_frame)
(w32con_ins_del_lines): Use FRAME_TOTAL_LINES instead of
FRAME_LINES.
2014-08-09 Reuben Thomas <rrt@sc3d.org>
* alloc.c (Fmemory_info): Remove a stray brace.
......
......@@ -5444,7 +5444,9 @@ handle_window_change_signal (int sig)
/* Record the new sizes, but don't reallocate the data
structures now. Let that be done later outside of the
signal handler. */
change_frame_size (XFRAME (frame), width, height, 0, 1, 0, 0);
change_frame_size (XFRAME (frame), width,
height - FRAME_MENU_BAR_LINES (XFRAME (frame)),
0, 1, 0, 0);
}
}
}
......
......@@ -215,7 +215,8 @@ frame_inhibit_resize (struct frame *f, bool horizontal)
{
return (frame_inhibit_implied_resize
|| !NILP (get_frame_param (f, Qfullscreen)));
|| !NILP (get_frame_param (f, Qfullscreen))
|| FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
}
#if 0
......@@ -563,7 +564,7 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit,
/* MSDOS frames cannot PRETEND, as they change frame size by
manipulating video hardware. */
if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
FrameRows (FRAME_TTY (f)) = new_lines;
FrameRows (FRAME_TTY (f)) = new_lines + FRAME_TOP_MARGIN (f);
}
/* Assign new sizes. */
......@@ -917,7 +918,9 @@ 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_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);
/* Set the top frame to the newly created frame. */
if (FRAMEP (FRAME_TTY (f)->top_frame)
......@@ -1037,7 +1040,7 @@ 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, 5, 0);
adjust_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f), 5, 0);
}
adjust_frame_glyphs (f);
......@@ -1168,8 +1171,8 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
frame's data. */
if (FRAME_COLS (f) != FrameCols (tty))
FrameCols (tty) = FRAME_COLS (f);
if (FRAME_LINES (f) != FrameRows (tty))
FrameRows (tty) = FRAME_LINES (f);
if (FRAME_TOTAL_LINES (f) != FrameRows (tty))
FrameRows (tty) = FRAME_TOTAL_LINES (f);
}
tty->top_frame = frame;
}
......@@ -2733,7 +2736,7 @@ to `frame-height'). */)
return make_number (FRAME_PIXEL_HEIGHT (f));
else
#endif
return make_number (FRAME_LINES (f));
return make_number (FRAME_TOTAL_LINES (f));
}
DEFUN ("frame-pixel-width", Fframe_pixel_width,
......@@ -2750,7 +2753,7 @@ If FRAME is omitted or nil, the selected frame is used. */)
return make_number (FRAME_PIXEL_WIDTH (f));
else
#endif
return make_number (FRAME_COLS (f));
return make_number (FRAME_TOTAL_COLS (f));
}
DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width,
......
......@@ -1868,7 +1868,7 @@ static Lisp_Object
safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args)
{
Lisp_Object hook, fun, msgargs[4];
eassert (nargs == 2);
hook = args[0];
fun = args[1];
......@@ -10221,8 +10221,9 @@ On such systems, Emacs starts a subshell instead of suspending. */)
with a window system; but suspend should be disabled in that case. */
get_tty_size (fileno (CURTTY ()->input), &width, &height);
if (width != old_width || height != old_height)
change_frame_size (SELECTED_FRAME (), width, height
- FRAME_MENU_BAR_LINES (SELECTED_FRAME ()), 0, 0, 0, 0);
change_frame_size (SELECTED_FRAME (), width,
height - FRAME_MENU_BAR_LINES (SELECTED_FRAME ()),
0, 0, 0, 0);
/* Run suspend-resume-hook. */
hook = intern ("suspend-resume-hook");
......
......@@ -1455,7 +1455,7 @@ emulate_dialog_with_menu (struct frame *f, Lisp_Object contents)
their upper-left corner at the given position.) */
if (STRINGP (prompt))
x_coord -= SCHARS (prompt);
y_coord = FRAME_LINES (f);
y_coord = FRAME_TOTAL_LINES (f);
}
XSETFRAME (frame, f);
......
......@@ -91,7 +91,7 @@ static _Noreturn void vfatal (const char *str, va_list ap)
#define OUTPUT(tty, a) \
emacs_tputs ((tty), a, \
FRAME_LINES (XFRAME (selected_frame)) - curY (tty), \
FRAME_TOTAL_LINES (XFRAME (selected_frame)) - curY (tty), \
cmputc)
#define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc)
......@@ -201,7 +201,7 @@ tty_set_terminal_modes (struct terminal *terminal)
off the screen, so it won't be overwritten and lost. */
int i;
current_tty = tty;
for (i = 0; i < FRAME_LINES (XFRAME (selected_frame)); i++)
for (i = 0; i < FRAME_TOTAL_LINES (XFRAME (selected_frame)); i++)
cmputc ('\n');
}
......@@ -257,7 +257,7 @@ tty_set_terminal_window (struct frame *f, int size)
{
struct tty_display_info *tty = FRAME_TTY (f);
tty->specified_window = size ? size : FRAME_LINES (f);
tty->specified_window = size ? size : FRAME_TOTAL_LINES (f);
if (FRAME_SCROLL_REGION_OK (f))
tty_set_scroll_region (f, 0, tty->specified_window);
}
......@@ -272,9 +272,9 @@ tty_set_scroll_region (struct frame *f, int start, int stop)
buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1, 0, 0);
else if (tty->TS_set_scroll_region_1)
buf = tparam (tty->TS_set_scroll_region_1, 0, 0,
FRAME_LINES (f), start,
FRAME_LINES (f) - stop,
FRAME_LINES (f));
FRAME_TOTAL_LINES (f), start,
FRAME_TOTAL_LINES (f) - stop,
FRAME_TOTAL_LINES (f));
else
buf = tparam (tty->TS_set_window, 0, 0, start, 0, stop, FRAME_COLS (f));
......@@ -446,7 +446,7 @@ tty_clear_to_end (struct frame *f)
}
else
{
for (i = curY (tty); i < FRAME_LINES (f); i++)
for (i = curY (tty); i < FRAME_TOTAL_LINES (f); i++)
{
cursor_to (f, i, 0);
clear_end_of_line (f, FRAME_COLS (f));
......@@ -748,7 +748,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
since that would scroll the whole frame on some terminals. */
if (AutoWrap (tty)
&& curY (tty) + 1 == FRAME_LINES (f)
&& curY (tty) + 1 == FRAME_TOTAL_LINES (f)
&& (curX (tty) + len) == FRAME_COLS (f))
len --;
if (len <= 0)
......@@ -820,7 +820,7 @@ tty_write_glyphs_with_face (register struct frame *f, register struct glyph *str
since that would scroll the whole frame on some terminals. */
if (AutoWrap (tty)
&& curY (tty) + 1 == FRAME_LINES (f)
&& curY (tty) + 1 == FRAME_TOTAL_LINES (f)
&& (curX (tty) + len) == FRAME_COLS (f))
len --;
if (len <= 0)
......@@ -1009,7 +1009,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
&& vpos + i >= tty->specified_window)
return;
if (!FRAME_MEMORY_BELOW_FRAME (f)
&& vpos + i >= FRAME_LINES (f))
&& vpos + i >= FRAME_TOTAL_LINES (f))
return;
if (multi)
......@@ -1046,7 +1046,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
&& FRAME_MEMORY_BELOW_FRAME (f)
&& n < 0)
{
cursor_to (f, FRAME_LINES (f) + n, 0);
cursor_to (f, FRAME_TOTAL_LINES (f) + n, 0);
clear_to_end (f);
}
}
......@@ -2405,13 +2405,14 @@ frame's terminal). */)
struct frame *f = XFRAME (t->display_info.tty->top_frame);
int width, height;
int old_height = FRAME_COLS (f);
int old_width = FRAME_LINES (f);
int old_width = FRAME_TOTAL_LINES (f);
/* Check if terminal/window size has changed while the frame
was suspended. */
get_tty_size (fileno (t->display_info.tty->input), &width, &height);
if (width != old_width || height != old_height)
change_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f), 0, 0, 0, 0);
change_frame_size (f, width, height - FRAME_MENU_BAR_LINES (f),
0, 0, 0, 0);
SET_FRAME_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
}
......@@ -2894,7 +2895,7 @@ tty_menu_display (tty_menu *menu, int x, int y, int pn, int *faces,
/* Don't try to display more menu items than the console can display
using the available screen lines. Exclude the echo area line, as
it will be overwritten by the help-echo anyway. */
int max_items = min (menu->count - first_item, FRAME_LINES (sf) - 1 - y);
int max_items = min (menu->count - first_item, FRAME_TOTAL_LINES (sf) - 1 - y);
menu_help_message = NULL;
......@@ -3274,7 +3275,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
{
mi_result input_status;
int min_y = state[0].y;
int max_y = min (min_y + state[0].menu->count, FRAME_LINES (sf) - 1) - 1;
int max_y = min (min_y + state[0].menu->count, FRAME_TOTAL_LINES (sf) - 1) - 1;
input_status = read_menu_input (sf, &x, &y, min_y, max_y, &first_time);
if (input_status)
......
......@@ -118,7 +118,7 @@ static void
w32con_clear_to_end (struct frame *f)
{
w32con_clear_end_of_line (f, FRAME_COLS (f) - 1);
w32con_ins_del_lines (f, cursor_coords.Y, FRAME_LINES (f) - cursor_coords.Y - 1);
w32con_ins_del_lines (f, cursor_coords.Y, FRAME_TOTAL_LINES (f) - cursor_coords.Y - 1);
}
/* Clear the frame. */
......@@ -133,7 +133,7 @@ w32con_clear_frame (struct frame *f)
GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info);
/* Remember that the screen buffer might be wider than the window. */
n = FRAME_LINES (f) * info.dwSize.X;
n = FRAME_TOTAL_LINES (f) * info.dwSize.X;
dest.X = dest.Y = 0;
FillConsoleOutputAttribute (cur_screen, char_attr_normal, n, dest, &r);
......@@ -175,18 +175,18 @@ w32con_ins_del_lines (struct frame *f, int vpos, int n)
if (n < 0)
{
scroll.Top = vpos - n;
scroll.Bottom = FRAME_LINES (f);
scroll.Bottom = FRAME_TOTAL_LINES (f);
dest.Y = vpos;
}
else
{
scroll.Top = vpos;
scroll.Bottom = FRAME_LINES (f) - n;
scroll.Bottom = FRAME_TOTAL_LINES (f) - n;
dest.Y = vpos + n;
}
clip.Top = clip.Left = scroll.Left = 0;
clip.Right = scroll.Right = FRAME_COLS (f);
clip.Bottom = FRAME_LINES (f);
clip.Bottom = FRAME_TOTAL_LINES (f);
dest.X = 0;
......
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