diff options
| author | Martin Rudalics | 2014-10-21 08:57:28 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2014-10-21 08:57:28 +0200 |
| commit | e5b3b7d3f387c992e6507bef3885056c5235e9ee (patch) | |
| tree | 1c5a839d4ce8ae158c0aa35f784bf5d37b2b20bb /src | |
| parent | 80aabe42436b909018c98a8a87ccbe614e72ef25 (diff) | |
| download | emacs-e5b3b7d3f387c992e6507bef3885056c5235e9ee.tar.gz emacs-e5b3b7d3f387c992e6507bef3885056c5235e9ee.zip | |
Handle wrapped menu bar lines when resizing frames with Windows API.
* w32fns.c (Fw32_frame_menu_bar_size): New function.
* w32term.c (x_set_window_size): Account for wrapped menu bar
lines when setting up frame height (Bug#15174 and Bug#18720).
(w32_add_wrapped_menu_bar_lines): New variable.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/w32fns.c | 29 | ||||
| -rw-r--r-- | src/w32term.c | 39 |
3 files changed, 75 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 075e41f9bd1..c7070c8000b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-10-21 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * w32fns.c (Fw32_frame_menu_bar_size): New function. | ||
| 4 | * w32term.c (x_set_window_size): Account for wrapped menu bar | ||
| 5 | lines when setting up frame height (Bug#15174 and Bug#18720). | ||
| 6 | (w32_add_wrapped_menu_bar_lines): New variable. | ||
| 7 | |||
| 1 | 2014-10-21 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2014-10-21 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * xdisp.c (redisplay_window): Re-run pre-redisplay-function after we | 10 | * xdisp.c (redisplay_window): Re-run pre-redisplay-function after we |
diff --git a/src/w32fns.c b/src/w32fns.c index 05da2a5c1d1..829347b2c6c 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -7366,6 +7366,34 @@ This is a direct interface to the Windows API FindWindow function. */) | |||
| 7366 | return Qt; | 7366 | return Qt; |
| 7367 | } | 7367 | } |
| 7368 | 7368 | ||
| 7369 | DEFUN ("w32-frame-menu-bar-size", Fw32_frame_menu_bar_size, Sw32_frame_menu_bar_size, 0, 1, 0, | ||
| 7370 | doc: /* Return sizes of menu bar on frame FRAME. | ||
| 7371 | The return value is a list of three elements: The current width and | ||
| 7372 | height of FRAME's menu bar in pixels and the default height of the menu | ||
| 7373 | bar in pixels. If FRAME is omitted or nil, the selected frame is | ||
| 7374 | used. */) | ||
| 7375 | (Lisp_Object frame) | ||
| 7376 | { | ||
| 7377 | struct frame *f = decode_any_frame (frame); | ||
| 7378 | MENUBARINFO info; | ||
| 7379 | int width, height, default_height; | ||
| 7380 | |||
| 7381 | block_input (); | ||
| 7382 | |||
| 7383 | default_height = GetSystemMetrics (SM_CYMENUSIZE); | ||
| 7384 | info.cbSize = sizeof (info); | ||
| 7385 | info.rcBar.right = info.rcBar.left = 0; | ||
| 7386 | info.rcBar.top = info.rcBar.bottom = 0; | ||
| 7387 | GetMenuBarInfo (FRAME_W32_WINDOW (f), 0xFFFFFFFD, 0, &info); | ||
| 7388 | width = info.rcBar.right - info.rcBar.left; | ||
| 7389 | height = info.rcBar.bottom - info.rcBar.top; | ||
| 7390 | |||
| 7391 | unblock_input (); | ||
| 7392 | |||
| 7393 | return list3 (make_number (width), make_number (height), | ||
| 7394 | make_number (default_height)); | ||
| 7395 | } | ||
| 7396 | |||
| 7369 | DEFUN ("w32-frame-rect", Fw32_frame_rect, Sw32_frame_rect, 0, 2, 0, | 7397 | DEFUN ("w32-frame-rect", Fw32_frame_rect, Sw32_frame_rect, 0, 2, 0, |
| 7370 | doc: /* Return boundary rectangle of FRAME in screen coordinates. | 7398 | doc: /* Return boundary rectangle of FRAME in screen coordinates. |
| 7371 | FRAME must be a live frame and defaults to the selected one. | 7399 | FRAME must be a live frame and defaults to the selected one. |
| @@ -8399,6 +8427,7 @@ only be necessary if the default setting causes problems. */); | |||
| 8399 | defsubr (&Sw32_toggle_lock_key); | 8427 | defsubr (&Sw32_toggle_lock_key); |
| 8400 | defsubr (&Sw32_window_exists_p); | 8428 | defsubr (&Sw32_window_exists_p); |
| 8401 | defsubr (&Sw32_frame_rect); | 8429 | defsubr (&Sw32_frame_rect); |
| 8430 | defsubr (&Sw32_frame_menu_bar_size); | ||
| 8402 | defsubr (&Sw32_battery_status); | 8431 | defsubr (&Sw32_battery_status); |
| 8403 | 8432 | ||
| 8404 | #ifdef WINDOWSNT | 8433 | #ifdef WINDOWSNT |
diff --git a/src/w32term.c b/src/w32term.c index e8bcf3ef639..4cffa3818ce 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -6119,6 +6119,30 @@ x_set_window_size (struct frame *f, int change_gravity, int width, int height, b | |||
| 6119 | pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height); | 6119 | pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height); |
| 6120 | } | 6120 | } |
| 6121 | 6121 | ||
| 6122 | if (w32_add_wrapped_menu_bar_lines) | ||
| 6123 | { | ||
| 6124 | /* When the menu bar wraps sending a SetWindowPos shrinks the | ||
| 6125 | height of the frame when the wrapped menu bar lines are not | ||
| 6126 | accounted for (Bug#15174 and Bug#18720). Here we add these | ||
| 6127 | extra lines to the frame height. */ | ||
| 6128 | MENUBARINFO info; | ||
| 6129 | int default_menu_bar_height; | ||
| 6130 | int menu_bar_height; | ||
| 6131 | |||
| 6132 | /* Why is (apparently) SM_CYMENUSIZE needed here instead of | ||
| 6133 | SM_CYMENU ?? */ | ||
| 6134 | default_menu_bar_height = GetSystemMetrics (SM_CYMENUSIZE); | ||
| 6135 | info.cbSize = sizeof (info); | ||
| 6136 | info.rcBar.top = info.rcBar.bottom = 0; | ||
| 6137 | GetMenuBarInfo (FRAME_W32_WINDOW (f), 0xFFFFFFFD, 0, &info); | ||
| 6138 | menu_bar_height = info.rcBar.bottom - info.rcBar.top; | ||
| 6139 | |||
| 6140 | if ((default_menu_bar_height > 0) | ||
| 6141 | && (menu_bar_height > default_menu_bar_height) | ||
| 6142 | && ((menu_bar_height % default_menu_bar_height) == 0)) | ||
| 6143 | pixelheight = pixelheight + menu_bar_height - default_menu_bar_height; | ||
| 6144 | } | ||
| 6145 | |||
| 6122 | f->win_gravity = NorthWestGravity; | 6146 | f->win_gravity = NorthWestGravity; |
| 6123 | x_wm_set_size_hint (f, (long) 0, 0); | 6147 | x_wm_set_size_hint (f, (long) 0, 0); |
| 6124 | 6148 | ||
| @@ -7080,6 +7104,21 @@ systems of the NT family, including W2K, XP, Vista, Windows 7 and | |||
| 7080 | Windows 8. It is set to nil on Windows 9X. */); | 7104 | Windows 8. It is set to nil on Windows 9X. */); |
| 7081 | w32_unicode_filenames = 0; | 7105 | w32_unicode_filenames = 0; |
| 7082 | 7106 | ||
| 7107 | |||
| 7108 | /* FIXME: The following two variables will be (hopefully) removed | ||
| 7109 | before Emacs 25.1 gets released. */ | ||
| 7110 | |||
| 7111 | DEFVAR_BOOL ("w32-add-wrapped-menu-bar-lines", | ||
| 7112 | w32_add_wrapped_menu_bar_lines, | ||
| 7113 | doc: /* Non-nil means frame resizing accounts for wrapped menu bar lines. | ||
| 7114 | A value of nil means frame resizing does not add the height of wrapped | ||
| 7115 | menu bar lines when sending a frame resize request to the Windows API. | ||
| 7116 | This usually means that the resulting frame height is off by the number | ||
| 7117 | of wrapped menu bar lines. If this is non-nil, Emacs adds the height of | ||
| 7118 | wrapped menu bar lines when sending frame resize requests to the Windows | ||
| 7119 | API. */); | ||
| 7120 | w32_add_wrapped_menu_bar_lines = 1; | ||
| 7121 | |||
| 7083 | DEFVAR_BOOL ("w32-enable-frame-resize-hack", | 7122 | DEFVAR_BOOL ("w32-enable-frame-resize-hack", |
| 7084 | w32_enable_frame_resize_hack, | 7123 | w32_enable_frame_resize_hack, |
| 7085 | doc: /* Non-nil means enable hack for frame resizing on Windows. | 7124 | doc: /* Non-nil means enable hack for frame resizing on Windows. |