X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/7c8b0b3644ada886dfde4032fdf38687a5968089..0a2aedfe6d650e825a50f25f972bac20d669f5cb:/src/xmenu.c diff --git a/src/xmenu.c b/src/xmenu.c index fdf1f6f4d8..9e1a817946 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1,14 +1,14 @@ /* X Communication module for terminals which understand the X protocol. -Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2015 Free Software +Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2016 Free Software Foundation, Inc. This file is part of GNU Emacs. GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -36,14 +36,12 @@ along with GNU Emacs. If not, see . */ #include "lisp.h" #include "keyboard.h" -#include "keymap.h" #include "frame.h" +#include "systime.h" #include "termhooks.h" #include "window.h" #include "blockinput.h" -#include "character.h" #include "buffer.h" -#include "charset.h" #include "coding.h" #include "sysselect.h" @@ -63,8 +61,6 @@ along with GNU Emacs. If not, see . */ #include #endif -#include "dispextern.h" - #ifdef HAVE_X_WINDOWS /* Defining HAVE_MULTILINGUAL_MENU would mean that the toolkit menu code accepts the Emacs internal encoding. */ @@ -325,7 +321,7 @@ If FRAME is nil or not given, use the selected frame. */) /* Child of win. */ &child); error_p = x_had_errors_p (FRAME_X_DISPLAY (f)); - x_uncatch_errors (); + x_uncatch_errors_after_check (); if (! error_p) { @@ -636,13 +632,7 @@ update_frame_menubar (struct frame *f) lw_refigure_widget (x->column_widget, True); /* Force the pane widget to resize itself. */ - int new_height = -1; -#ifdef USE_LUCID - /* For reasons I don't know Lucid wants to add one pixel to the frame - height when adding the menu bar. Compensate that here. */ - new_height = FRAME_TEXT_HEIGHT (f) - 1; -#endif /* USE_LUCID */ - adjust_frame_size (f, -1, new_height, 2, false, Qmenu_bar_lines); + adjust_frame_size (f, -1, -1, 2, false, Qupdate_frame_menubar); unblock_input (); #endif /* USE_GTK */ } @@ -979,7 +969,15 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) menubar_size = (f->output_data.x->menubar_widget ? (f->output_data.x->menubar_widget->core.height - + f->output_data.x->menubar_widget->core.border_width) +#ifndef USE_LUCID + /* Damn me... With Lucid I get a core.border_width of 1 + only the first time this is called and an ibw of 1 every + time this is called. So the first time this is called I + was off by one. Fix that here by never adding + core.border_width for Lucid. */ + + f->output_data.x->menubar_widget->core.border_width +#endif /* USE_LUCID */ + ) : 0); #ifdef USE_LUCID @@ -990,9 +988,10 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) if (FRAME_EXTERNAL_MENU_BAR (f)) { Dimension ibw = 0; + XtVaGetValues (f->output_data.x->column_widget, XtNinternalBorderWidth, &ibw, NULL); - menubar_size += ibw; + menubar_size += ibw; } #endif /* USE_LUCID */ @@ -1073,21 +1072,24 @@ free_frame_menubar (struct frame *f) if (f->output_data.x->widget) { - int new_height = -1; #ifdef USE_MOTIF XtVaGetValues (f->output_data.x->widget, XtNx, &x1, XtNy, &y1, NULL); if (x1 == 0 && y1 == 0) XtVaSetValues (f->output_data.x->widget, XtNx, x0, XtNy, y0, NULL); if (frame_inhibit_resize (f, false, Qmenu_bar_lines)) - new_height = old_height; + adjust_frame_size (f, -1, old_height, 1, false, Qfree_frame_menubar_1); + else + adjust_frame_size (f, -1, -1, 2, false, Qfree_frame_menubar_1); +#else + adjust_frame_size (f, -1, -1, 2, false, Qfree_frame_menubar_1); #endif /* USE_MOTIF */ - adjust_frame_size (f, -1, new_height, 2, false, Qmenu_bar_lines); } else { #ifdef USE_MOTIF - if (frame_inhibit_resize (f, false, Qmenu_bar_lines)) - adjust_frame_size (f, -1, old_height, 1, false, Qmenu_bar_lines); + if (WINDOWP (FRAME_ROOT_WINDOW (f)) + && frame_inhibit_resize (f, false, Qmenu_bar_lines)) + adjust_frame_size (f, -1, old_height, 1, false, Qfree_frame_menubar_2); #endif } @@ -1211,13 +1213,25 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, if (use_pos_func) { + Window dummy_window; + /* Not invoked by a click. pop up at x/y. */ pos_func = menu_position_func; /* Adjust coordinates to be root-window-relative. */ - x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); - y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); + block_input (); + XTranslateCoordinates (FRAME_X_DISPLAY (f), + /* From-window, to-window. */ + FRAME_X_WINDOW (f), + FRAME_DISPLAY_INFO (f)->root_window, + + /* From-position, to-position. */ + x, y, &x, &y, + + /* Child of win. */ + &dummy_window); + unblock_input (); popup_x_y.x = x; popup_x_y.y = y; popup_x_y.f = f; @@ -1301,6 +1315,7 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, XButtonPressedEvent *event = &(dummy.xbutton); LWLIB_ID menu_id; Widget menu; + Window dummy_window; eassert (FRAME_X_P (f)); @@ -1326,8 +1341,20 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, event->y = y; /* Adjust coordinates to be root-window-relative. */ - x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); - y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); + block_input (); + x += FRAME_LEFT_SCROLL_BAR_AREA_WIDTH (f); + XTranslateCoordinates (FRAME_X_DISPLAY (f), + + /* From-window, to-window. */ + FRAME_X_WINDOW (f), + FRAME_DISPLAY_INFO (f)->root_window, + + /* From-position, to-position. */ + x, y, &x, &y, + + /* Child of win. */ + &dummy_window); + unblock_input (); event->x_root = x; event->y_root = y; @@ -2047,12 +2074,18 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, inhibit_garbage_collection (); #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); + { + /* Adjust coordinates to relative to the outer (window manager) window. */ + int left_off, top_off; + + x_real_pos_and_offsets (f, &left_off, NULL, &top_off, NULL, + NULL, NULL, NULL, NULL, NULL); + + x += left_off; + y += top_off; + } #endif /* HAVE_X_WINDOWS */ - /* Adjust coordinates to be root-window-relative. */ x += f->left_pos; y += f->top_pos;