diff options
author | Martin Rudalics <rudalics@gmx.at> | 2021-04-27 09:53:42 +0200 |
---|---|---|
committer | Martin Rudalics <rudalics@gmx.at> | 2021-04-27 09:53:42 +0200 |
commit | a190b4cfd8b6f42a91678ac7292e1cceccd168e7 (patch) | |
tree | a9e0d6af2a038ba3d506218c2866255c90818f46 /src/w32fns.c | |
parent | 40a1e94f4c0cbe6633bc7ed42b006271c4e4b114 (diff) | |
download | emacs-a190b4cfd8b6f42a91678ac7292e1cceccd168e7.tar.gz emacs-a190b4cfd8b6f42a91678ac7292e1cceccd168e7.tar.bz2 emacs-a190b4cfd8b6f42a91678ac7292e1cceccd168e7.zip |
Major rewrite of adjust_frame_size
Have adjust_frame_size pass native frame sizes to backends
instead of text sizes. Expand frame size history management.
Drop PIXELWISE argument from change_frame_size and convert
native to text sizes only when calling adjust_frame_size. Use
convention in arguments that -1 instead of 0 means that no size
change is required. When adjusting frame sizes pick up delayed
size changes (Bug#46827).
* lisp/frame.el (frame-notice-user-settings, make-frame): Don't
set frame size history.
(frame--size-history): Rewrite doc-string. Handle new formats
of `frame-size-history' entries.
* src/dispextern.h (delayed_size_change): Extern it.
(change_frame_size): Drop last argument from extern.
* src/dispnew.c (delayed_size_change): Make it global.
(handle_window_change_signal): Reformat. Drop last argument
from change_frame_size call.
(do_pending_window_change, init_display_interactive): Drop last
argument from change_frame_size call.
(change_frame_size_1): NEW_WIDTH and NEW_HEIGHT now specify
native sizes. Drop last argument PIXELWISE. Queue a change
when it either differs from F's current pixel sizes or F's
previously queued sizes. Inject frame_size_history_extra call
when queuing. Adopt convention that for queued sizes -1 means
that no size change is required. Convert from native to text
sizes when calling adjust_frame_size.
(change_frame_size): Drop last argument PIXELWISE and drop it
also in change_frame_size_1 calls.
* src/frame.c (frame_size_history_add): Remove.
(frame_inhibit_resize): Remove call to frame_size_history_add.
(set_menu_bar_lines, set_tab_bar_lines): Simplify. Drop last
argument from change_frame_size call.
(frame_windows_min_size): No more static.
(keep_ratio): Minor rewrite using macros.
(frame_size_history_adjust, frame_size_history_plain)
(frame_size_history_extra): New functions.
(adjust_frame_size): Major rewrite. Adopt new convention that
negative values for new sizes mean no change. Pick up delayed
size changes from F's new_width and new_height slots
(Bug#46827). Call set_window_size_hook with native instead of
text sizes. Do not sanitize window sizes any more. Call
frame_size_history_adjust instead of frame_size_history_add.
Always set F's resized_p slot to true.
(make_frame): Initialize new_width and new_height slots to -1.
Simplify setup of initial sizes and an adjust_frame_size call.
(Fframe_parameters): Drop processing F's new_pixelwise slot.
(check_frame_pixels): Reorder to make declarations appear first.
(Fset_frame_height, Fset_frame_width, Fset_frame_size): Pass
explicit width and height values to adjust_frame_size instead of
-1.
(gui_set_frame_parameters): Minor rewrite making sure that
explicit sizes and the corresponding parameter are passed to
adjust_frame_size. Remove frame_size_history_add call.
(gui_figure_window_size): Drop last two arguments. Simplify
assignment of initial size. Set new_height and new_width slots
to -1. Use adjust_frame_size to set sizes instead of returning
them to caller.
(syms_of_frame): Drop symbols used by frame size history; these
are now built on-the-fly. Also drop some menu bar related
symbols in favor of Qmenu_bar_lines.
* src/frame.h (struct frame): Remove new_pixelwise.
(SET_FRAME_COLS, SET_FRAME_LINES, SET_FRAME_WIDTH)
(SET_FRAME_HEIGHT): Remove macros.
(frame_size_history_add): Remove externs.
(frame_windows_min_size, frame_size_history_plain)
(frame_size_history_extra): Add externs.
(FRAME_WINDOWS_WIDTH, FRAME_WINDOWS_HEIGHT): Rename to
FRAME_INNER_WIDTH and FRAME_INNER_HEIGHT.
(gui_figure_window_size): Drop last two arguments from
extern.
* src/gtkutil.c (xg_frame_resized): Rename arguments to WIDTH
and HEIGHT. Consult delayed_size_change to handle case where
WIDTH and HEIGHT do not match F's new_width and new_height
values. Call change_frame_size with native sizes and without
PIXELWISE argument. Instead of frame_size_history_add call
frame_size_history_extra.
(xg_frame_set_char_size): WIDTH and HEIGHT are native sizes now;
fix adjust_frame_size call accordingly. Instead of
frame_size_history_add call frame_size_history_extra.
(style_changed_cb): Call xg_frame_set_char_size with native
instead of text sizes.
(tb_size_cb): Remove frame_size_history_add call. Call
adjust_frame_size with INHIBIT 5.
(free_frame_tool_bar, xg_change_toolbar_position): Remove
frame_size_history_add call.
(update_frame_tool_bar): Call adjust_frame_size with INHIBIT 2
and let it handle frame_inhibit_implied_resize and
fullheight/-width. Remove frame_size_history_add call.
* src/keyboard.c (Fsuspend_emacs): Call change_frame_size with
native sizes.
* src/nsfns.m (ns_set_tool_bar_lines): Call adjust_frame_size
with INHIBIT 2 and let it handle frame_inhibit_implied_resize
and fullheight/-width. Remove frame_size_history_add call.
(Fx_create_frame): Drop two last arguments in
gui_figure_window_size call. Do not SET_FRAME_WIDTH and
SET_FRAME_HEIGHT, the adjust_frame_size in
gui_figure_window_size did that already.
* src/nsterm.m (ns_set_window_size): Drop PIXELWISE argument and
its processing; WIDTH and HEIGHT represent native pixel sizes
now. Call change_frame_size with native sizes. Remove call to
frame_size_history_add.
([EmacsView viewDidResize:]): Call change_frame_size with native
sizes.
* src/term.c (Fresume_tty): Call change_frame_size with native
sizes.
* src/termhooks.h (*set_window_size_hook): Drop last argument
PIXELWISE.
* src/w32fns.c (w32_change_tab_bar_height)
(w32_change_tool_bar_height): Fix handling of these in the initial
phase before they have been resized at least once.
(Fx_create_frame, w32_create_tip_frame): Drop two last arguments
in gui_figure_window_size call. Do not SET_FRAME_WIDTH and
SET_FRAME_HEIGHT (or SET_FRAME_COLS and SET_FRAME_LINES), the
adjust_frame_size in gui_figure_window_size did that already.
* src/w32inevt.c (resize_event, maybe_generate_resize_event):
Pass native sizes to change_frame_size.
* src/w32term.c (w32_read_socket): When WM_WINDOWPOSCHANGED pass
native sizes to change_frame_size.
(w32_new_font): Recalculate FRAME_TAB_BAR_HEIGHT. Simplify
code.
(w32fullscreen_hook): Call change_frame_size with native sizes.
(w32_set_window_size): Drop argument PIXELWISE and its
processing; WIDTH and HEIGHT are native sizes now. Remove
frame_size_history_add calls. Pass native sizes to
change_frame_size.
* src/widget.c (set_frame_size): Set width and height of widget
directly. Call frame_size_history_plain instead of
frame_size_history_add.
(update_from_various_frame_slots): Call
frame_size_history_extra.
(EmacsFrameRealize): Call frame_size_history_plain.
(EmacsFrameResize): Call change_frame_size with native sizes.
Call frame_size_history_extra instead of frame_size_history_add.
(EmacsFrameSetCharSize): Call frame_size_history_extra. Drop
PIXELWISE argument in x_set_window_size call and specify pixels.
(pixel_to_text_size): Remove function.
* src/xdisp.c (resize_mini_window): Replace FRAME_WINDOWS_HEIGHT
with FRAME_INNER_HEIGHT.
(redisplay_tab_bar): Don't set tab_bar_redisplayed when we did
not redisplay it.
(redisplay_tool_bar): Don't call it for external tool bar.
Don't set tool_bar_redisplayed when we did not redisplay it.
(redisplay_window): When the tool bar is external call
update_frame_tool_bar directly.
* src/xfns.c (x_set_menu_bar_lines): Call adjust_frame_size only
if number of menu bar lines changed and fix 6th argument.
(x_change_tab_bar_height, x_change_tool_bar_height): Fix
handling of these in the initial phase before they have been
resized at least once.
(Fx_create_frame, x_create_tip_frame): Drop two last arguments
in gui_figure_window_size call. Do not SET_FRAME_WIDTH and
SET_FRAME_HEIGHT (or SET_FRAME_COLS and SET_FRAME_LINES), the
adjust_frame_size in gui_figure_window_size did that already.
* src/xmenu.c (update_frame_menubar): Fix 6th arg of
adjust_frame_size call.
(free_frame_menubar): For Motif frames fix fullscreen and
`frame-inhibit-implied-resize' handling. Fix 6th arg of
adjust_frame_size calls.
* src/xterm.c (x_net_wm_state): Remove call to
frame_size_history_add.
(handle_one_xevent): For PropertyNotify and UnmapNotify events
add frame_size_history_plain calls. For MapNotify and
ConfigureNotify events add a frame_size_history_extra call. For
ConfigureNotify events also handle delayed size changes and call
change_frame_size with native sizes.
(x_new_font): Recalculate FRAME_TAB_BAR_HEIGHT. Simplify code.
(x_handle_net_wm_state): Remove frame_size_history_add call.
(x_check_fullscreen): Remove frame_size_history_add call. Call
change_frame_size with native height.
(x_set_window_size_1): WIDTH and HEIGHT are now native. Remove
some frame_size_history_add calls and add frame_size_history_extra
calls instead. If the frame is not visible call adjust_frame_size
directly instead of calling change_frame_size.
(x_set_window_size): Drop PIXELWISE argument. WIDTH and HEIGHT
represent native sizes now.
(x_make_frame_visible, x_make_frame_invisible): Call
frame_size_history_plain.
* src/xterm.h (x_set_window_size): Drop last argument from
extern declaration.
Diffstat (limited to 'src/w32fns.c')
-rw-r--r-- | src/w32fns.c | 100 |
1 files changed, 38 insertions, 62 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index c07f32ab0cc..66baeaecbdb 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -1701,7 +1701,7 @@ w32_change_tab_bar_height (struct frame *f, int height) int unit = FRAME_LINE_HEIGHT (f); int old_height = FRAME_TAB_BAR_HEIGHT (f); int lines = (height + unit - 1) / unit; - Lisp_Object fullscreen; + Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); /* Make sure we redisplay all windows in this frame. */ fset_redisplay (f); @@ -1728,25 +1728,21 @@ w32_change_tab_bar_height (struct frame *f, int height) if ((height < old_height) && WINDOWP (f->tab_bar_window)) clear_glyph_matrix (XWINDOW (f->tab_bar_window)->current_matrix); - /* Recalculate tabbar height. */ - f->n_tab_bar_rows = 0; - if (old_height == 0 - && (!f->after_make_frame - || NILP (frame_inhibit_implied_resize) - || (CONSP (frame_inhibit_implied_resize) - && NILP (Fmemq (Qtab_bar_lines, frame_inhibit_implied_resize))))) - f->tab_bar_redisplayed = f->tab_bar_resized = false; - - adjust_frame_size (f, -1, -1, - ((!f->tab_bar_resized - && (NILP (fullscreen = - get_frame_param (f, Qfullscreen)) - || EQ (fullscreen, Qfullwidth))) ? 1 - : (old_height == 0 || height == 0) ? 2 - : 4), - false, Qtab_bar_lines); - - f->tab_bar_resized = f->tab_bar_redisplayed; + if (!f->tab_bar_resized) + { + /* As long as tab_bar_resized is false, effectively try to change + F's native height. */ + if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) + adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), + 1, false, Qtab_bar_lines); + else + adjust_frame_size (f, -1, -1, 4, false, Qtab_bar_lines); + + f->tab_bar_resized = f->tab_bar_redisplayed; + } + else + /* Any other change may leave the native size of F alone. */ + adjust_frame_size (f, -1, -1, 3, false, Qtab_bar_lines); /* adjust_frame_size might not have done anything, garbage frame here. */ @@ -1790,7 +1786,7 @@ w32_change_tool_bar_height (struct frame *f, int height) int unit = FRAME_LINE_HEIGHT (f); int old_height = FRAME_TOOL_BAR_HEIGHT (f); int lines = (height + unit - 1) / unit; - Lisp_Object fullscreen; + Lisp_Object fullscreen = get_frame_param (f, Qfullscreen); /* Make sure we redisplay all windows in this frame. */ windows_or_buffers_changed = 23; @@ -1811,25 +1807,21 @@ w32_change_tool_bar_height (struct frame *f, int height) if ((height < old_height) && WINDOWP (f->tool_bar_window)) clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix); - /* Recalculate toolbar height. */ - f->n_tool_bar_rows = 0; - if (old_height == 0 - && (!f->after_make_frame - || NILP (frame_inhibit_implied_resize) - || (CONSP (frame_inhibit_implied_resize) - && NILP (Fmemq (Qtool_bar_lines, frame_inhibit_implied_resize))))) - f->tool_bar_redisplayed = f->tool_bar_resized = false; - - adjust_frame_size (f, -1, -1, - ((!f->tool_bar_resized - && (NILP (fullscreen = - get_frame_param (f, Qfullscreen)) - || EQ (fullscreen, Qfullwidth))) ? 1 - : (old_height == 0 || height == 0) ? 2 - : 4), - false, Qtool_bar_lines); - - f->tool_bar_resized = f->tool_bar_redisplayed; + if (!f->tool_bar_resized) + { + /* As long as tool_bar_resized is false, effectively try to change + F's native height. */ + if (NILP (fullscreen) || EQ (fullscreen, Qfullwidth)) + adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), + 1, false, Qtool_bar_lines); + else + adjust_frame_size (f, -1, -1, 4, false, Qtool_bar_lines); + + f->tool_bar_resized = f->tool_bar_redisplayed; + } + else + /* Any other change may leave the native size of F alone. */ + adjust_frame_size (f, -1, -1, 3, false, Qtool_bar_lines); /* adjust_frame_size might not have done anything, garbage frame here. */ @@ -5718,7 +5710,6 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, struct w32_display_info *dpyinfo = NULL; Lisp_Object parent, parent_frame; struct kboard *kb; - int x_width = 0, x_height = 0; if (!FRAME_W32_P (SELECTED_FRAME ()) && !FRAME_INITIAL_P (SELECTED_FRAME ())) @@ -6045,8 +6036,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, f->output_data.w32->current_cursor = f->output_data.w32->nontext_cursor; - window_prompting = gui_figure_window_size (f, parameters, true, true, - &x_width, &x_height); + window_prompting = gui_figure_window_size (f, parameters, true, true); tem = gui_display_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); @@ -6081,11 +6071,6 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, /* Allow set_window_size_hook, now. */ f->can_set_window_size = true; - if (x_width > 0) - SET_FRAME_WIDTH (f, x_width); - if (x_height > 0) - SET_FRAME_HEIGHT (f, x_height); - /* Tell the server what size and position, etc, we want, and how badly we want them. This should be done after we have the menu bar so that its size can be taken into account. */ @@ -6093,8 +6078,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, w32_wm_set_size_hint (f, window_prompting, false); unblock_input (); - adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true, - Qx_create_frame_2); + adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), + 0, true, Qx_create_frame_2); /* Process fullscreen parameter here in the hope that normalizing a fullheight/fullwidth frame will produce the size set by the last @@ -6888,11 +6873,9 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, Lisp_Object parms) struct frame *f; Lisp_Object frame; Lisp_Object name; - int width, height; ptrdiff_t count = SPECPDL_INDEX (); struct kboard *kb; bool face_change_before = face_change; - int x_width = 0, x_height = 0; /* Use this general default value to start with until we know if this frame has a specified name. */ @@ -7013,7 +6996,7 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, Lisp_Object parms) f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window; f->output_data.w32->explicit_parent = false; - gui_figure_window_size (f, parms, true, true, &x_width, &x_height); + gui_figure_window_size (f, parms, true, true); /* No fringes on tip frame. */ f->fringe_cols = 0; @@ -7039,15 +7022,6 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, Lisp_Object parms) gui_default_parameter (f, parms, Qalpha, Qnil, "alpha", "Alpha", RES_TYPE_NUMBER); - /* Dimensions, especially FRAME_LINES (f), must be done via - change_frame_size. Change will not be effected unless different - from the current FRAME_LINES (f). */ - width = FRAME_COLS (f); - height = FRAME_LINES (f); - SET_FRAME_COLS (f, 0); - SET_FRAME_LINES (f, 0); - adjust_frame_size (f, width * FRAME_COLUMN_WIDTH (f), - height * FRAME_LINE_HEIGHT (f), 0, true, Qtip_frame); /* Add `tooltip' frame parameter's default value. */ if (NILP (Fframe_parameter (frame, Qtooltip))) Fmodify_frame_parameters (frame, Fcons (Fcons (Qtooltip, Qt), Qnil)); @@ -7088,6 +7062,8 @@ w32_create_tip_frame (struct w32_display_info *dpyinfo, Lisp_Object parms) visible won't work. */ Vframe_list = Fcons (frame, Vframe_list); f->can_set_window_size = true; + adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), + 0, true, Qtip_frame); /* Setting attributes of faces of the tooltip frame from resources and similar will set face_change, which leads to the |