Commit ffc3882f authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Minor fixes to interfaces, avoid assertion violation under GLYPH_DEBUG.

parent 5877bb8d
......@@ -3205,7 +3205,12 @@ update_frame_with_menu (struct frame *f)
fflush (FRAME_TTY (f)->output);
/* Check window matrices for lost pointers. */
#if GLYPH_DEBUG
#if 0
/* We cannot possibly survive the matrix pointers check, since
we have overwritten parts of the frame glyph matrix without
making any updates to the window matrices. */
check_window_matrix_pointers (root_window);
#endif
add_frame_display_history (f, paused_p);
#endif
......
......@@ -1280,7 +1280,8 @@ no quit occurs and `x-popup-menu' returns nil. */)
#ifdef HAVE_MENUS
#ifdef HAVE_WINDOW_SYSTEM
/* Hide a previous tip, if any. */
Fx_hide_tip ();
if (!FRAME_TERMCAP_P (f))
Fx_hide_tip ();
#endif
#ifdef HAVE_NTGUI /* FIXME: Is it really w32-specific? --Stef */
......@@ -1289,7 +1290,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
can occur if you press ESC or click outside a menu without selecting
a menu item.
*/
if (current_popup_menu)
if (current_popup_menu && FRAME_W32_P (f))
{
discard_menu_items ();
FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
......@@ -1342,7 +1343,8 @@ no quit occurs and `x-popup-menu' returns nil. */)
#endif
#ifdef HAVE_NTGUI /* FIXME: Is it really w32-specific? --Stef */
FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
if (FRAME_W32_P (f))
FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
#endif
#endif /* HAVE_MENUS */
......
......@@ -2900,7 +2900,7 @@ tty_menu_calc_size (tty_menu *menu, int *width, int *height)
/* Display MENU at (X,Y) using FACES. */
static void
tty_menu_display (tty_menu *menu, int y, int x, int pn, int *faces,
tty_menu_display (tty_menu *menu, int x, int y, int pn, int *faces,
int disp_help)
{
int i, face, width, mx = -1, my = -1, enabled, mousehere, row, col;
......@@ -2958,7 +2958,7 @@ tty_menu_display (tty_menu *menu, int y, int x, int pn, int *faces,
menu_help_paneno = pn - 1;
menu_help_itemno = i;
}
display_tty_menu_item (menu->text[i], face, y + i, x,
display_tty_menu_item (menu->text[i], face, x, y + i,
menu->submenu[i] != NULL);
}
update_frame_with_menu (sf);
......@@ -3139,10 +3139,17 @@ screen_update (struct frame *f, struct glyph_matrix *mtx)
puts us. We only consider mouse movement and click events and
keyboard movement commands; the rest are ignored. */
static void
read_menu_input (int *x, int *y)
read_menu_input (struct frame *sf, int *x, int *y, bool *first_time)
{
Lisp_Object c;
if (*first_time)
{
*first_time = false;
sf->mouse_moved = 1;
return;
}
while (1)
{
do {
......@@ -3174,7 +3181,10 @@ read_menu_input (int *x, int *y)
break;
}
if (usable_input)
return;
{
sf->mouse_moved = 1;
return;
}
}
else if (EVENT_HAS_PARAMETERS (c))
......@@ -3232,6 +3242,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
int title_faces[4]; /* face to display the menu title */
int faces[4], buffers_num_deleted = 0;
struct frame *sf = SELECTED_FRAME ();
bool first_time;
Lisp_Object saved_echo_area_message, selectface;
/* Don't allow non-positive x0 and y0, lest the menu will wrap
......@@ -3298,8 +3309,11 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
show_cursor (0); /* FIXME: need a new hook, for w32console. */
#endif
/* Display the menu title. */
tty_menu_display (menu, y0 - 1, x0 - 1, 1, title_faces, 0);
/* Display the menu title. We subtract 1 from x0 and y0 because we
want to interpret them as zero-based column and row coordinates,
and also because we want the first item of the menu, not its
title, to appear at x0,y0. */
tty_menu_display (menu, x0 - 1, y0 - 1, 1, title_faces, 0);
if (buffers_num_deleted)
menu->text[0][7] = ' ';
if ((onepane = menu->count == 1 && menu->submenu[0]))
......@@ -3317,6 +3331,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
x = state[0].x;
y = state[0].y;
first_time = true;
leave = 0;
while (!leave)
......@@ -3324,7 +3339,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
int mouse_button_count = 3; /* FIXME */
if (!mouse_visible) mouse_on ();
read_menu_input (&x, &y);
read_menu_input (sf, &x, &y, &first_time);
if (sf->mouse_moved)
{
sf->mouse_moved = 0;
......@@ -3359,8 +3374,8 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
if (i == statecount - 1 && state[i].menu->submenu[dy])
{
tty_menu_display (state[i].menu,
state[i].y,
state[i].x,
state[i].y,
state[i].pane,
faces, 1);
state[statecount].menu = state[i].menu->submenu[dy];
......@@ -3376,8 +3391,8 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
}
}
tty_menu_display (state[statecount - 1].menu,
state[statecount - 1].y,
state[statecount - 1].x,
state[statecount - 1].y,
state[statecount - 1].pane,
faces, 1);
}
......@@ -3413,6 +3428,9 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
}
mouse_off (); /* FIXME */
sf->mouse_moved = 0;
/* FIXME: Since we set the fram's garbaged flag, do we need this
call to screen_update? */
screen_update (sf, state[0].screen_behind);
state[0].screen_behind = NULL;
#if 0
......@@ -3457,6 +3475,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
/* Allow mouse events generation by dos_rawgetc. */
mouse_preempted--;
#endif
SET_FRAME_GARBAGED (sf);
return result;
}
......
......@@ -20589,8 +20589,9 @@ display_menu_bar (struct window *w)
 
X and Y are coordinates of the first glyph in the desired matrix to
be overwritten by the menu item. Since this is a TTY, Y is the
glyph row and X is the glyph number in the row, where to start
displaying the item.
zero-based number of the glyph row and X is the zero-based glyph
number in the row, starting from left, where to start displaying
the item.
 
SUBMENU non-zero means this menu item drops down a submenu, which
should be indicated by displaying a proper visual cue after the
......@@ -20603,7 +20604,7 @@ display_tty_menu_item (const char *item_text, int face_id, int x, int y,
struct it it;
struct frame *f = SELECTED_FRAME ();
struct window *w = XWINDOW (f->selected_window);
int saved_used, saved_truncated, saved_width;
int saved_used, saved_truncated, saved_width, saved_reversed;
struct glyph_row *row;
 
eassert (FRAME_TERMCAP_P (f));
......@@ -20612,8 +20613,12 @@ display_tty_menu_item (const char *item_text, int face_id, int x, int y,
it.first_visible_x = 0;
it.last_visible_x = FRAME_COLS (f);
row = it.glyph_row;
/* Copy the row contents from the current matrix. */
*row = f->current_matrix->rows[y];
saved_width = row->full_width_p;
row->full_width_p = 1;
saved_reversed = row->reversed_p;
row->reversed_p = 0;
 
/* Arrange for the menu item glyphs to start at X and have the
desired face. */
......@@ -20630,6 +20635,8 @@ display_tty_menu_item (const char *item_text, int face_id, int x, int y,
term.c:append_glyph. */
it.paragraph_embedding = L2R;
 
/* Pad with a space on the left. */
display_string (" ", Qnil, Qnil, 0, 0, &it, 1, 0, 0, -1);
if (submenu)
{
/* Indicate with ">" that there's a submenu. */
......@@ -20646,8 +20653,9 @@ display_tty_menu_item (const char *item_text, int face_id, int x, int y,
 
row->used[TEXT_AREA] = saved_used;
row->truncated_on_right_p = saved_truncated;
row->hash - row_hash (row);
row->hash = row_hash (row);
row->full_width_p = saved_width;
row->reversed_p = saved_reversed;
}
#endif /* HAVE_MENUS */
......
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