diff options
| author | Martin Rudalics | 2015-10-13 12:11:43 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2015-10-13 12:11:43 +0200 |
| commit | d4fe840df0b5fdb3aed538fae2ced143a471f60a (patch) | |
| tree | 13ff9d7115616a99af7e0257277a1ca6edf31f72 /src/w32fns.c | |
| parent | e53e1a0426539aa3f2902632fdd8025da8f710f2 (diff) | |
| download | emacs-d4fe840df0b5fdb3aed538fae2ced143a471f60a.tar.gz emacs-d4fe840df0b5fdb3aed538fae2ced143a471f60a.zip | |
Allow setting frame pixel sizes from frame parameters (Bug#21415)
Also fix some misfeatures in frame (re-)sizing code, add more
debugging information and remove some dead code.
* lisp/frame.el (frame-notice-user-settings, make-frame): Change
parameter names when setting `frame-size-history'.
(frame--size-history): New function.
* src/frame.c (frame_inhibit_resize): If frame has not been made
yet, return t if inhibit_horizontal_resize or
inhibit_vertical_resize bit have been set.
(adjust_frame_size): Simplify.
(make_frame): Initialize inhibit_horizontal_resize,
inhibit_vertical_resize, tool_bar_redisplayed, tool_bar_resized.
(Fframe_after_make_frame): Reset inhibit_horizontal_resize and
inhibit_vertical_resize slots.
(x_set_frame_parameters): Handle `text-pixels' specification for
width and height parameters. Don't consider new_height or
new_width changes. Call adjust_frame_size instead of
Fset_frame_size.
(x_figure_window_size): Two new arguments x_width and y_width
returning frame's figures width and height. Calculate tool bar
height before frame sizes so SET_FRAME_HEIGHT can pick it up.
Handle `text-pixels' specification for width and height
parameters.
(Qtext_pixels, Qx_set_frame_parameters, Qset_frame_size)
(Qx_set_window_size_1, Qx_set_window_size_2)
(Qx_set_window_size_3, Qx_set_menu_bar_lines)
(Qupdate_frame_menubar, Qfree_frame_menubar_1)
(Qfree_frame_menubar_2): New symbols.
* src/frame.h (structure frame): New booleans
tool_bar_redisplayed, tool_bar_resized,
inhibit_horizontal_resize, inhibit_vertical_resize.
(x_figure_window_size): Update external declaration.
* src/gtkutil.c (xg_frame_set_char_size): Set size hints before
calling gtk_window_resize.
(update_frame_tool_bar): Make inhibiting of frame resizing more
discriminative. Set tool_bar_resized bit.
* src/nsfns.m (x_set_tool_bar_lines): Make inhibiting of frame
resizing more discriminative. Call adjust_frame_size instead of
x_set_window_size.
(Fx_create_frame): Handle x_width and x_height if
set by x_figure_window_size.
* src/nsterm.m (x_set_window_size): For GNUSTEP build don't
subtract 3 from tool bar height.
(x_set_window_size): Add frame_size_history_add call.
(x_new_font): Call adjust_frame_size instead of
x_set_window_size.
* src/w32fns.c (x_change_tool_bar_height): Reset
tool_bar_redisplayed and tool_bar_resized bits when adding tool
bar. Make inhibiting of frame resizing more discriminative.
(w32_wnd_proc): Remove dead code in WM_WINDOWPOSCHANGING case.
(Fx_create_frame): Handle x_width and x_height if set by
x_figure_window_size. Set size hints before adjusting frame size.
(x_create_tip_frame): Adjust x_figure_window_size call.
* src/w32term.c (x_set_window_size): Add frame_size_history_add
call.
* src/widget.c (set_frame_size): Remove dead code. Add
frame_size_history_add call. When frame_resize_pixelwise is t
use FRAME_PIXEL_WIDTH and FRAME_PIXEL_HEIGHT instead of
pixel_width and pixel_height.
(update_various_frame_slots): Remove dead code.
(EmacsFrameResize): Add more information in
frame_size_history_add call.
(EmacsFrameQueryGeometry): Round only when frame_resize_pixelwise
is not set.
* src/xdisp.c (redisplay_tool_bar): Set tool_bar_redisplayed bits.
* src/xfns.c (x_set_menu_bar_lines): Change argument name.
(x_change_tool_bar_height): Reset tool_bar_redisplayed and
tool_bar_resized bits when adding tool bar. Make inhibiting of
frame resizing more discriminative.
(Fx_create_frame): Handle x_width and x_height if set by
x_figure_window_size. Set size hints before adjusting frame size.
(x_create_tip_frame): Adjust x_figure_window_size call.
* src/xmenu.c (update_frame_menubar): Don't handle Lucid specially.
(set_frame_menubar): On Lucid never add core-border-width to
avoid that adding XtNinternalBorderWidth adds it again.
(free_frame_menubar): Handle frame_inhibit_resize true for Motif.
* src/xterm.c (x_new_font): In non-toolkit case handle size
change of menu bar.
(x_set_window_size_1): Fix calls to frame_size_history_add.
(x_wm_set_size_hint): Remove dead code. Set
size_hints.min_width and size_hints.min_height to base_width and
base_height.
Diffstat (limited to 'src/w32fns.c')
| -rw-r--r-- | src/w32fns.c | 121 |
1 files changed, 24 insertions, 97 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 97dd40ba262..3773923fe9d 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1762,14 +1762,24 @@ x_change_tool_bar_height (struct frame *f, int height) | |||
| 1762 | 1762 | ||
| 1763 | /* Recalculate toolbar height. */ | 1763 | /* Recalculate toolbar height. */ |
| 1764 | f->n_tool_bar_rows = 0; | 1764 | f->n_tool_bar_rows = 0; |
| 1765 | if (old_height == 0 | ||
| 1766 | && (!f->after_make_frame | ||
| 1767 | || NILP (frame_inhibit_implied_resize) | ||
| 1768 | || (CONSP (frame_inhibit_implied_resize) | ||
| 1769 | && NILP (Fmemq (Qtool_bar_lines, frame_inhibit_implied_resize))))) | ||
| 1770 | f->tool_bar_redisplayed = f->tool_bar_resized = false; | ||
| 1765 | 1771 | ||
| 1766 | adjust_frame_size (f, -1, -1, | 1772 | adjust_frame_size (f, -1, -1, |
| 1767 | ((NILP (fullscreen = get_frame_param (f, Qfullscreen)) | 1773 | ((!f->tool_bar_resized |
| 1768 | || EQ (fullscreen, Qfullwidth)) ? 1 | 1774 | && (NILP (fullscreen = |
| 1775 | get_frame_param (f, Qfullscreen)) | ||
| 1776 | || EQ (fullscreen, Qfullwidth))) ? 1 | ||
| 1769 | : (old_height == 0 || height == 0) ? 2 | 1777 | : (old_height == 0 || height == 0) ? 2 |
| 1770 | : 4), | 1778 | : 4), |
| 1771 | false, Qtool_bar_lines); | 1779 | false, Qtool_bar_lines); |
| 1772 | 1780 | ||
| 1781 | f->tool_bar_resized = f->tool_bar_redisplayed; | ||
| 1782 | |||
| 1773 | /* adjust_frame_size might not have done anything, garbage frame | 1783 | /* adjust_frame_size might not have done anything, garbage frame |
| 1774 | here. */ | 1784 | here. */ |
| 1775 | adjust_frame_glyphs (f); | 1785 | adjust_frame_glyphs (f); |
| @@ -4368,97 +4378,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |||
| 4368 | case WM_WINDOWPOSCHANGING: | 4378 | case WM_WINDOWPOSCHANGING: |
| 4369 | /* Don't restrict the sizing of any kind of frames. If the window | 4379 | /* Don't restrict the sizing of any kind of frames. If the window |
| 4370 | manager doesn't, there's no reason to do it ourselves. */ | 4380 | manager doesn't, there's no reason to do it ourselves. */ |
| 4371 | #if 0 | 4381 | return 0; |
| 4372 | if (frame_resize_pixelwise || hwnd == tip_window) | ||
| 4373 | #endif | ||
| 4374 | return 0; | ||
| 4375 | |||
| 4376 | #if 0 | ||
| 4377 | /* Don't restrict the sizing of fullscreened frames, allowing them to be | ||
| 4378 | flush with the sides of the screen. */ | ||
| 4379 | f = x_window_to_frame (dpyinfo, hwnd); | ||
| 4380 | if (f && FRAME_PREV_FSMODE (f) != FULLSCREEN_NONE) | ||
| 4381 | return 0; | ||
| 4382 | |||
| 4383 | { | ||
| 4384 | WINDOWPLACEMENT wp; | ||
| 4385 | LPWINDOWPOS lppos = (WINDOWPOS *) lParam; | ||
| 4386 | |||
| 4387 | wp.length = sizeof (WINDOWPLACEMENT); | ||
| 4388 | GetWindowPlacement (hwnd, &wp); | ||
| 4389 | |||
| 4390 | if (wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED | ||
| 4391 | && (lppos->flags & SWP_NOSIZE) == 0) | ||
| 4392 | { | ||
| 4393 | RECT rect; | ||
| 4394 | int wdiff; | ||
| 4395 | int hdiff; | ||
| 4396 | DWORD font_width; | ||
| 4397 | DWORD line_height; | ||
| 4398 | DWORD internal_border; | ||
| 4399 | DWORD vscrollbar_extra; | ||
| 4400 | DWORD hscrollbar_extra; | ||
| 4401 | RECT wr; | ||
| 4402 | |||
| 4403 | wp.length = sizeof (wp); | ||
| 4404 | GetWindowRect (hwnd, &wr); | ||
| 4405 | |||
| 4406 | enter_crit (); | ||
| 4407 | |||
| 4408 | font_width = GetWindowLong (hwnd, WND_FONTWIDTH_INDEX); | ||
| 4409 | line_height = GetWindowLong (hwnd, WND_LINEHEIGHT_INDEX); | ||
| 4410 | internal_border = GetWindowLong (hwnd, WND_BORDER_INDEX); | ||
| 4411 | vscrollbar_extra = GetWindowLong (hwnd, WND_VSCROLLBAR_INDEX); | ||
| 4412 | hscrollbar_extra = GetWindowLong (hwnd, WND_HSCROLLBAR_INDEX); | ||
| 4413 | |||
| 4414 | leave_crit (); | ||
| 4415 | |||
| 4416 | memset (&rect, 0, sizeof (rect)); | ||
| 4417 | AdjustWindowRect (&rect, GetWindowLong (hwnd, GWL_STYLE), | ||
| 4418 | GetMenu (hwnd) != NULL); | ||
| 4419 | |||
| 4420 | /* Force width and height of client area to be exact | ||
| 4421 | multiples of the character cell dimensions. */ | ||
| 4422 | wdiff = (lppos->cx - (rect.right - rect.left) | ||
| 4423 | - 2 * internal_border - vscrollbar_extra) | ||
| 4424 | % font_width; | ||
| 4425 | hdiff = (lppos->cy - (rect.bottom - rect.top) | ||
| 4426 | - 2 * internal_border - hscrollbar_extra) | ||
| 4427 | % line_height; | ||
| 4428 | |||
| 4429 | if (wdiff || hdiff) | ||
| 4430 | { | ||
| 4431 | /* For right/bottom sizing we can just fix the sizes. | ||
| 4432 | However for top/left sizing we will need to fix the X | ||
| 4433 | and Y positions as well. */ | ||
| 4434 | |||
| 4435 | int cx_mintrack = GetSystemMetrics (SM_CXMINTRACK); | ||
| 4436 | int cy_mintrack = GetSystemMetrics (SM_CYMINTRACK); | ||
| 4437 | |||
| 4438 | lppos->cx = max (lppos->cx - wdiff, cx_mintrack); | ||
| 4439 | lppos->cy = max (lppos->cy - hdiff, cy_mintrack); | ||
| 4440 | |||
| 4441 | if (wp.showCmd != SW_SHOWMAXIMIZED | ||
| 4442 | && (lppos->flags & SWP_NOMOVE) == 0) | ||
| 4443 | { | ||
| 4444 | if (lppos->x != wr.left || lppos->y != wr.top) | ||
| 4445 | { | ||
| 4446 | lppos->x += wdiff; | ||
| 4447 | lppos->y += hdiff; | ||
| 4448 | } | ||
| 4449 | else | ||
| 4450 | { | ||
| 4451 | lppos->flags |= SWP_NOMOVE; | ||
| 4452 | } | ||
| 4453 | } | ||
| 4454 | |||
| 4455 | return 0; | ||
| 4456 | } | ||
| 4457 | } | ||
| 4458 | } | ||
| 4459 | |||
| 4460 | goto dflt; | ||
| 4461 | #endif | ||
| 4462 | 4382 | ||
| 4463 | case WM_GETMINMAXINFO: | 4383 | case WM_GETMINMAXINFO: |
| 4464 | /* Hack to allow resizing the Emacs frame above the screen size. | 4384 | /* Hack to allow resizing the Emacs frame above the screen size. |
| @@ -4977,6 +4897,7 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 4977 | struct w32_display_info *dpyinfo = NULL; | 4897 | struct w32_display_info *dpyinfo = NULL; |
| 4978 | Lisp_Object parent; | 4898 | Lisp_Object parent; |
| 4979 | struct kboard *kb; | 4899 | struct kboard *kb; |
| 4900 | int x_width = 0, x_height = 0; | ||
| 4980 | 4901 | ||
| 4981 | if (!FRAME_W32_P (SELECTED_FRAME ()) | 4902 | if (!FRAME_W32_P (SELECTED_FRAME ()) |
| 4982 | && !FRAME_INITIAL_P (SELECTED_FRAME ())) | 4903 | && !FRAME_INITIAL_P (SELECTED_FRAME ())) |
| @@ -5199,7 +5120,7 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 5199 | 5120 | ||
| 5200 | f->output_data.w32->current_cursor = f->output_data.w32->nontext_cursor; | 5121 | f->output_data.w32->current_cursor = f->output_data.w32->nontext_cursor; |
| 5201 | 5122 | ||
| 5202 | window_prompting = x_figure_window_size (f, parameters, true); | 5123 | window_prompting = x_figure_window_size (f, parameters, true, &x_width, &x_height); |
| 5203 | 5124 | ||
| 5204 | tem = x_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); | 5125 | tem = x_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); |
| 5205 | f->no_split = minibuffer_only || EQ (tem, Qt); | 5126 | f->no_split = minibuffer_only || EQ (tem, Qt); |
| @@ -5233,8 +5154,10 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 5233 | /* Allow x_set_window_size, now. */ | 5154 | /* Allow x_set_window_size, now. */ |
| 5234 | f->can_x_set_window_size = true; | 5155 | f->can_x_set_window_size = true; |
| 5235 | 5156 | ||
| 5236 | adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true, | 5157 | if (x_width > 0) |
| 5237 | Qx_create_frame_2); | 5158 | SET_FRAME_WIDTH (f, x_width); |
| 5159 | if (x_height > 0) | ||
| 5160 | SET_FRAME_HEIGHT (f, x_height); | ||
| 5238 | 5161 | ||
| 5239 | /* Tell the server what size and position, etc, we want, and how | 5162 | /* Tell the server what size and position, etc, we want, and how |
| 5240 | badly we want them. This should be done after we have the menu | 5163 | badly we want them. This should be done after we have the menu |
| @@ -5243,6 +5166,9 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 5243 | x_wm_set_size_hint (f, window_prompting, false); | 5166 | x_wm_set_size_hint (f, window_prompting, false); |
| 5244 | unblock_input (); | 5167 | unblock_input (); |
| 5245 | 5168 | ||
| 5169 | adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true, | ||
| 5170 | Qx_create_frame_2); | ||
| 5171 | |||
| 5246 | /* Process fullscreen parameter here in the hope that normalizing a | 5172 | /* Process fullscreen parameter here in the hope that normalizing a |
| 5247 | fullheight/fullwidth frame will produce the size set by the last | 5173 | fullheight/fullwidth frame will produce the size set by the last |
| 5248 | adjust_frame_size call. */ | 5174 | adjust_frame_size call. */ |
| @@ -6179,6 +6105,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, | |||
| 6179 | bool face_change_before = face_change; | 6105 | bool face_change_before = face_change; |
| 6180 | Lisp_Object buffer; | 6106 | Lisp_Object buffer; |
| 6181 | struct buffer *old_buffer; | 6107 | struct buffer *old_buffer; |
| 6108 | int x_width = 0, x_height = 0; | ||
| 6182 | 6109 | ||
| 6183 | /* Use this general default value to start with until we know if | 6110 | /* Use this general default value to start with until we know if |
| 6184 | this frame has a specified name. */ | 6111 | this frame has a specified name. */ |
| @@ -6309,7 +6236,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, | |||
| 6309 | f->output_data.w32->dwStyle = WS_BORDER | WS_POPUP | WS_DISABLED; | 6236 | f->output_data.w32->dwStyle = WS_BORDER | WS_POPUP | WS_DISABLED; |
| 6310 | f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window; | 6237 | f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window; |
| 6311 | 6238 | ||
| 6312 | window_prompting = x_figure_window_size (f, parms, false); | 6239 | window_prompting = x_figure_window_size (f, parms, true, &x_width, &x_height); |
| 6313 | 6240 | ||
| 6314 | /* No fringes on tip frame. */ | 6241 | /* No fringes on tip frame. */ |
| 6315 | f->fringe_cols = 0; | 6242 | f->fringe_cols = 0; |