Mercurial > emacs
diff src/xmenu.c @ 90054:f2ebccfa87d4
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-74
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-709
Update from CVS: src/indent.c (Fvertical_motion): Fix last change.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-710
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-715
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-74
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 08 Dec 2004 05:02:30 +0000 |
parents | b637c617432f 8da33d42472e |
children | 95879cc1ed20 |
line wrap: on
line diff
--- a/src/xmenu.c Mon Dec 06 12:38:25 2004 +0000 +++ b/src/xmenu.c Wed Dec 08 05:02:30 2004 +0000 @@ -741,8 +741,7 @@ or a list ((XOFFSET YOFFSET) WINDOW) where XOFFSET and YOFFSET are positions in pixels from the top left corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.) -This controls the position of the center of the first line -in the first pane of the menu, not the top left of the menu as a whole. +This controls the position of the top left of the menu as a whole. If POSITION is t, it means to use the current mouse position. MENU is a specifier for a menu. For the simplest case, MENU is a keymap. @@ -3256,7 +3255,7 @@ char *datap; int ulx, uly, width, height; int dispwidth, dispheight; - int i, j; + int i, j, lines, maxlines; int maxwidth; int dummy_int; unsigned int dummy_uint; @@ -3287,31 +3286,8 @@ #ifdef HAVE_X_WINDOWS /* Adjust coordinates to relative to the outer (window manager) window. */ - { - Window child; - int win_x = 0, win_y = 0; - - /* Find the position of the outside upper-left corner of - the inner window, with respect to the outer window. */ - if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) - { - BLOCK_INPUT; - XTranslateCoordinates (FRAME_X_DISPLAY (f), - - /* From-window, to-window. */ - f->output_data.x->window_desc, - f->output_data.x->parent_desc, - - /* From-position, to-position. */ - 0, 0, &win_x, &win_y, - - /* Child of window. */ - &child); - UNBLOCK_INPUT; - x += win_x; - y += win_y; - } - } + x += FRAME_OUTER_TO_INNER_DIFF_X (f); + y += FRAME_OUTER_TO_INNER_DIFF_Y (f); #endif /* HAVE_X_WINDOWS */ /* Adjust coordinates to be root-window-relative. */ @@ -3319,7 +3295,7 @@ y += f->top_pos; /* Create all the necessary panes and their items. */ - i = 0; + maxlines = lines = i = 0; while (i < menu_items_used) { if (EQ (XVECTOR (menu_items)->contents[i], Qt)) @@ -3328,6 +3304,8 @@ Lisp_Object pane_name, prefix; char *pane_string; + maxlines = max (maxlines, lines); + lines = 0; pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; pane_string = (NILP (pane_name) @@ -3420,9 +3398,12 @@ return Qnil; } i += MENU_ITEMS_ITEM_LENGTH; + lines++; } } + maxlines = max (maxlines, lines); + /* All set and ready to fly. */ XMenuRecompute (FRAME_X_DISPLAY (f), menu); dispwidth = DisplayWidth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)); @@ -3446,6 +3427,15 @@ if (ulx < 0) x -= ulx; if (uly < 0) y -= uly; + if (! for_click) + { + /* If position was not given by a mouse click, adjust so upper left + corner of the menu as a whole ends up at given coordinates. This + is what x-popup-menu says in its documentation. */ + x += width/2; + y += 1.5*height/(maxlines+2); + } + XMenuSetAEQ (menu, TRUE); XMenuSetFreeze (menu, TRUE); pane = selidx = 0;