emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xmenu.c [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/xmenu.c [lexbind]
Date: Wed, 08 Dec 2004 18:58:17 -0500

Index: emacs/src/xmenu.c
diff -c emacs/src/xmenu.c:1.230.4.10 emacs/src/xmenu.c:1.230.4.11
*** emacs/src/xmenu.c:1.230.4.10        Wed Dec  8 23:31:37 2004
--- emacs/src/xmenu.c   Wed Dec  8 23:36:22 2004
***************
*** 741,748 ****
  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.
  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.
--- 741,747 ----
  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 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,3262 ****
    char *datap;
    int ulx, uly, width, height;
    int dispwidth, dispheight;
!   int i, j;
    int maxwidth;
    int dummy_int;
    unsigned int dummy_uint;
--- 3255,3261 ----
    char *datap;
    int ulx, uly, width, height;
    int dispwidth, dispheight;
!   int i, j, lines, maxlines;
    int maxwidth;
    int dummy_int;
    unsigned int dummy_uint;
***************
*** 3287,3317 ****
  
  #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;
!       }
!   }
  #endif /* HAVE_X_WINDOWS */
  
    /* Adjust coordinates to be root-window-relative.  */
--- 3286,3293 ----
  
  #ifdef HAVE_X_WINDOWS
    /* Adjust coordinates to relative to the outer (window manager) window.  */
!   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,3325 ****
    y += f->top_pos;
  
    /* Create all the necessary panes and their items.  */
!   i = 0;
    while (i < menu_items_used)
      {
        if (EQ (XVECTOR (menu_items)->contents[i], Qt))
--- 3295,3301 ----
    y += f->top_pos;
  
    /* Create all the necessary panes and their items.  */
!   maxlines = lines = i = 0;
    while (i < menu_items_used)
      {
        if (EQ (XVECTOR (menu_items)->contents[i], Qt))
***************
*** 3328,3333 ****
--- 3304,3311 ----
          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,3428 ****
--- 3398,3409 ----
              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,3451 ****
--- 3427,3441 ----
    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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]