diff options
author | Martin Rudalics <rudalics@gmx.at> | 2013-11-30 10:25:31 +0100 |
---|---|---|
committer | Martin Rudalics <rudalics@gmx.at> | 2013-11-30 10:25:31 +0100 |
commit | 880e615853d4074937795850b279338720618431 (patch) | |
tree | 9ff3cbd92ec5963cf80315a4fb912ed73dc89be3 /src/frame.c | |
parent | 3e2fb4db3f517dd051cd35c742355c492e085333 (diff) |
Support resizing frames and windows pixelwise.
* dispextern.h (enum window_part): Add ON_SCROLL_BAR,
ON_RIGHT_DIVIDER and ON_BOTTOM_DIVIDER.
(struct glyph_matrix): Replace window_left_col and
window_top_line by window_pixel_left and window_pixel_top.
(WINDOW_WANTS_MODELINE_P, WINDOW_WANTS_HEADER_LINE_P): Minor
rewrite.
(enum face_id): Add WINDOW_DIVIDER_FACE_ID.
(draw_window_divider, move_it_to, x_draw_right_divider)
(x_draw_bottom_divider, change_frame_size): Add or fix
declarations.
* dispnew.c (change_frame_size_1): Change prototype.
(adjust_glyph_matrix, required_matrix_width)
(adjust_frame_glyphs_for_window_redisplay): Use pixel
values instead of lines and columns.
(marginal_area_string): Use WINDOW_FRINGES_WIDTH instead of
WINDOW_TOTAL_FRINGE_WIDTH.
(handle_window_change_signal, do_pending_window_change)
(init_display): Adjusts calls of change_frame_size.
(change_frame_size, change_frame_size_1): Handle pixelwise
changes.
* frame.c (Qright_divider_width, Qbottom_divider_width): New
Lisp objects.
(set_menu_bar_lines_1, set_menu_bar_lines, make_frame)
(make_terminal_frame, Fmake_terminal_frame, Fframe_parameters)
(x_set_internal_border_width, x_set_vertical_scroll_bars)
(x_set_scroll_bar_width, x_figure_window_size): Handle pixel
values.
(set_frame_param): New function.
(Fframe_text_cols, Fframe_text_lines, Fframe_total_cols)
(Fframe_text_width, Fframe_text_height, Fscroll_bar_width)
(Ffringe_width, Fborder_width, Fright_divider_width)
(Fbottom_divider_width): New functions, defsubr them.
(Fset_frame_height, Fset_frame_width, Fset_frame_size): New
argument pixelwise.
(struct frame_parm_table): New members Qright_divider_width and
Qbottom_divider_width.
(x_set_frame_parameters): Handle parameters for pixelwise sizes.
(x_report_frame_params): Handle Qright_divider_width and
Qbottom_divider_width.
(x_set_right_divider_width, x_set_bottom_divider_width): New
functions.
(frame_resize_pixelwise): New option.
* frame.h (struct frame): Add tool_bar_height, menu_bar_height,
new_pixelwise, right_divider_width and bottom_divider_width;
remove total_lines; rename text_lines, text_cols, new_text_lines
and new_text_cols to text_height, text_width, new_height and
new_width respectively.
(FRAME_LINES, FRAME_COLS): Rename to FRAME_TEXT_HEIGHT and
FRAME_TEXT_WIDTH respectively.
(FRAME_MENU_BAR_HEIGHT, FRAME_TOOL_BAR_HEIGHT)
(FRAME_RIGHT_DIVIDER_WIDTH, FRAME_BOTTOM_DIVIDER_WIDTH)
(FRAME_TEXT_TO_PIXEL_WIDTH, FRAME_PIXEL_TO_TEXT_WIDTH): New
macros.
(FRAME_TOP_MARGIN_HEIGHT, FRAME_LEFT_SCROLL_BAR_AREA_WIDTH)
(FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH, FRAME_SCROLL_BAR_AREA_WIDTH)
(SET_FRAME_COLS, SET_FRAME_WIDTH, SET_FRAME_HEIGHT)
(FRAME_TEXT_COLS_TO_PIXEL_WIDTH, FRAME_PIXEL_WIDTH_TO_TEXT_COLS)
(FRAME_TEXT_COLS_TO_PIXEL_WIDTH): Rewrite macros.
(FRAME_TOTAL_COLS_ARG): Remove macro.
* fringe.c (draw_fringe_bitmap_1): Handle right divder.
* gtkutil.c (xg_frame_resized, xg_frame_set_char_size)
(x_wm_set_size_hint): Handle frame pixel sizes.
* indent.c (compute_motion, Fcompute_motion): Call
window_body_width instead of window_body_cols.
* keyboard.c (Qright_divider, Qbottom_divider): New symbols.
(make_lispy_position): Handle right and bottom dividers.
(Fsuspend_emacs): Pixelize call of change_frame_size.
* keyboard.h: Extern Qright_divider, Qbottom_divider.
* lisp.h: Extern set_frame_param.
* nsfns.m (x_set_tool_bar_lines): Pixelize call of
x_set_window_size.
(Fx_create_frame): Add entry for vertical_drag_cursor. Pixelize
call of change_frame_size.
* nsterm.h (struct ns_output): Add vertical_drag_cursor.
* nsterm.m (ns_update_window_end): Optionally draw right
divider.
(x_set_window_size): Add argument pixelwise. Call
check_frame_size and change_frame_size with pixelwise zero.
(ns_draw_window_divider): New function.
(ns_redisplay_interface): Add ns_draw_window_divider.
(updateFrameSize:): Call change_frame_size with pixelwise zero.
(x_new_font): Call x_set_window_size with pixelwise zero.
* print.c (print_object): For a window print its sequence
number again.
* term.c (Fresume_tty): Pixelize call of change_frame_size.
* w32fns.c (x_set_mouse_color): Handle vertical drag cursor.
(x_set_menu_bar_lines, x_set_tool_bar_lines): Calculate pixelwise.
(w32_createwindow): Use scroll bar area width.
(w32_wnd_proc): Handle bottom divider width. For
WM_WINDOWPOSCHANGING return zero if we resize pixelwise.
(Fx_create_frame): Default divider width parameters. Caclulate
sizes pixelwise. Add vertical drag cursor support.
(x_create_tip_frame): Default divider widths to zero. Pixelize
call to change_frame_size.
(Fx_show_tip): Add handling of divider widths. Pixelize window
position and sizes.
(Fw32_frame_rect): New function.
(frame_parm_handler w32_frame_parm_handlers): Add divider
widths.
(Vx_window_vertical_drag_shape): Add variable.
* w32inevt.c (resize_event, maybe_generate_resize_event):
Pixelize change_frame_size calls.
* w32menu.c (set_frame_menubar): Pixelize x_set_window_size
call.
* w32term.c (w32_draw_window_divider): New function.
(x_update_window_end): Handle right divider.
(w32_draw_fringe_bitmap, x_scroll_run)
(w32_set_vertical_scroll_bar): Pixelize scrollbar widths.
(w32_read_socket): Handle SIZE_MAXIMIZED separately. Calculate
new frame sizes pixelwise.
(x_new_font): Pixelize call to x_set_window_size.
(x_check_fullscreen): Pixelize call to change_frame_size.
(x_set_window_size_1, x_set_window_size): New argument
pixelwise. Calculate pixelwise.
(x_wm_set_size_hint): Use scroll bar area width.
(w32_redisplay_interface): Add w32_draw_window_divider.
* w32term.h (struct w32_output): Add vertical drag cursor.
* widget.c (set_frame_size, update_wm_hints)
(EmacsFrameResize, EmacsFrameSetValues): Pixelize calls of
change_frame_size.
(EmacsFrameSetCharSize): Pixelize call of x_set_window_size.
* window.c (sequence_number): Restore.
(Fwindow_pixel_width, Fwindow_pixel_height)
(Fwindow_mode_line_height, Fwindow_header_line_height)
(window_pixel_to_total, Frun_window_scroll_functions)
(Fset_window_new_pixel, window_resize_apply_total)
(Fwindow_resize_apply_total): New functions.
(window_body_height, window_body_width): Rename from
window_body_lines. New argument PIXELWISE. Calculate
pixelwise.
(Fwindow_body_height, Fwindow_body_width): New argument
PIXELWISE.
(coordinates_in_window, window_relative_x_coord): Use window's
pixel width instead of total width.
(replace_window, recombine_windows): Initialize pixel values.
(resize_root_window, resize_frame_windows, grow_mini_window)
(shrink_mini_window): New argument PIXELWISE. Calculate
pixelwise.
(Fdelete_other_windows_internal, adjust_window_margins)
(window_resize_check, window_resize_apply)
(Fdelete_window_internal, Fresize_mini_window_internal)
(Fwindow_text_width, Fwindow_text_height): Calculate pixelwise.
(check_frame_size): Rename arguments. New argument PIXELWISE.
Calculate pixelwise.
(set_window_buffer): Make samebuf bool. Run configuration change
hook only if buffer changed.
(Fset_window_buffer): Rewrite doc-string.
(make_window): Initialize new_pixel slot.
(Fwindow_resize_apply): Check pixel size of root window.
(Fsplit_window_internal): Call 2nd argument pixel_size.
Calculate pixelwise.
(Fscroll_left, Fscroll_right): Call window_body_width instead of
window_body_cols.
(save_window_data): New slots frame_text_width,
frame_text_height, frame_menu_bar_height, frame_tool_bar_height.
(saved_window): New slots pixel_left, pixel_top, pixel_height,
pixel_width.
(Fcurrent_window_configuration, Fset_window_configuration)
(save_window_save, compare_window_configurations): Handle new
slots in save_window_data and saved_window.
(Fset_window_scroll_bars): Fix doc-string.
(window_resize_pixelwise): New variable.
(coordinates_in_window, Fcoordinates_in_window_p): Handle
dividers.
(make_parent_window): Adjust sequence_number.
(Fwindow_right_divider_width, Fwindow_bottom_divider_width): New
functions.
* window.h (struct window): New members new_pixel, pixel_left,
pixel_top, pixel_width, pixel_height. Restore sequence_number.
(wset_new_pixel): New function.
(WINDOW_PIXEL_WIDTH, WINDOW_PIXEL_HEIGHT)
(MIN_SAFE_WINDOW_PIXEL_WIDTH, MIN_SAFE_WINDOW_PIXEL_HEIGHT)
(WINDOW_LEFT_PIXEL_EDGE, WINDOW_RIGHT_PIXEL_EDGE)
(WINDOW_TOP_PIXEL_EDGE, WINDOW_BOTTOM_PIXEL_EDGE)
(WINDOW_BOTTOMMOST_P, WINDOW_BOX_LEFT_PIXEL_EDGE)
(WINDOW_BOX_RIGHT_PIXEL_EDGE, WINDOW_MARGINS_COLS)
(WINDOW_MARGINS_WIDTH, WINDOW_RIGHT_DIVIDER_WIDTH)
(WINDOW_BOTTOM_DIVIDER_WIDTH): New macros.
(WINDOW_TOTAL_FRINGE_WIDTH): Rename to WINDOW_FRINGES_WIDTH.
(WINDOW_TOTAL_WIDTH, WINDOW_TOTAL_HEIGHT): Remove macros.
(WINDOW_RIGHT_EDGE_X, WINDOW_LEFT_EDGE_X, WINDOW_TOP_EDGE_Y)
(WINDOW_BOTTOM_EDGE_Y, WINDOW_FULL_WIDTH_P, WINDOW_LEFTMOST_P)
(WINDOW_RIGHTMOST_P, WINDOW_BOX_LEFT_EDGE_X)
(WINDOW_BOX_RIGHT_EDGE_X, WINDOW_FRINGE_COLS)
(WINDOW_BOX_HEIGHT_NO_MODE_LINE, WINDOW_BOX_TEXT_HEIGHT):
Rewrite.
(resize_frame_windows, grow_mini_window, shrink_mini_window)
(window_body_width, check_frame_size): Adapt external declarations.
* xdisp.c (last_max_ascent): New integer.
(window_text_bottom_y): Handle bottom divider.
(window_box_width, window_box_height): Calculate pixelwise.
(get_glyph_string_clip_rects): Handle right divider.
(remember_mouse_glyph): When windows are resized pixelwise
proceed with width and height set to 1.
(init_iterator): Use WINDOW_PIXEL_WIDTH instead of
WINDOW_TOTAL_WIDTH.
(move_it_to): Calculate and return maximum x position
encountered.
(Fwindow_text_pixel_size): New function.
(resize_mini_window, update_tool_bar): Calculate pixelwise.
(tool_bar_lines_needed): Rename to tool_bar_height. Calculate
pixelwise.
(Ftool_bar_lines_needed): Rename to Ftool_bar_height. Calculate
pixelwise.
(redisplay_tool_bar): Calculate pixelwise.
(redisplay_window): Calculate pixelwise. Handle dividers.
(draw_glyphs, x_clear_end_of_line, note_mouse_highlight)
(x_draw_vertical_border): Handle dividers.
(define_frame_cursor1): Handle vertical drag cursor.
(x_draw_right_divider, x_draw_bottom_divider): New functions.
(expose_window): Calculate pixelwise. Handle dividers.
(init_xdisp): Initialize pixel values.
* xfaces.c (Qwindow_divider): New face.
(realize_basic_faces): Realize it.
* xfns.c (x_set_mouse_color): Handle vertical_drag_cursor.
(x_set_menu_bar_lines, x_set_tool_bar_lines): Calculate pixelwise.
(x_set_scroll_bar_default_width): Default actual width to 16.
(Fx_create_frame): Set sizes pixelwise.
(x_create_tip_frame): Default divider widths to zero. Pixelize
call of change_frame_size.
(Fx_show_tip): Handle divider widths. Initial pixel position
and sizes.
(frame_parm_handler x_frame_parm_handlers): Add divider widths.
(Vx_window_vertical_drag_shape): New option.
* xmenu.c (free_frame_menubar): Pixelize call of
x_set_window_size.
* xterm.c (x_draw_window_divider): New function.
(x_update_window_end): Optionally draw right divider.
(x_draw_fringe_bitmap, x_scroll_run, x_scroll_bar_create)
(XTset_vertical_scroll_bar): Use scroll bar pixel width.
(handle_one_xevent, x_new_font): Calculate pixelwise.
(x_set_window_size_1, x_set_window_size): New argument
pixelwise. Calculate pixelwise.
(x_wm_set_size_hint): Pixelize call of check_frame_size.
(struct x_redisplay_interface): Add x_draw_window_divider.
* xterm.h (struct x_output): Add vertical_drag_cursor.
* cus-start.el (frame-resize-pixelwise)
(window-resize-pixelwise): New entries.
* emacs-lisp/debug.el (debug): Use window-total-height instead
of window-total-size.
* frame.el (tool-bar-lines-needed): Defalias to tool-bar-height.
* help.el (describe-bindings-internal): Call help-buffer
(temp-buffer-max-width): New option.
(resize-temp-buffer-window, help-window-setup)
(with-help-window): Rewrite.
* mouse.el (mouse-drag-line): Rewrite. Add key bindings for
dragging dividers.
* window.el (frame-char-size, window-min-pixel-height)
(window-safe-min-pixel-height, window-safe-min-pixel-width)
(window-min-pixel-width, window-safe-min-pixel-size)
(window-combination-p, window-safe-min-size)
(window-resizable-p, window--size-to-pixel)
(window--pixel-to-size, window--resize-apply-p): New functions.
(window-safe-min-height): Fix doc-string.
(window-size, window-min-size, window--min-size-1)
(window-sizable, window-sizable-p, window--min-delta-1)
(window-min-delta, window--max-delta-1, window-max-delta)
(window--resizable, window--resizable-p, window-resizable)
(window-full-height-p, window-full-width-p, window-at-side-p)
(window--in-direction-2, window-in-direction)
(window--resize-reset-1, window--resize-mini-window)
(window-resize, window-resize-no-error)
(window--resize-child-windows-normal)
(window--resize-child-windows, window--resize-siblings)
(window--resize-this-window, window--resize-root-window)
(window--resize-root-window-vertically)
(adjust-window-trailing-edge, enlarge-window, shrink-window)
(maximize-window, minimize-window, delete-window)
(quit-restore-window, window-split-min-size, split-window)
(balance-windows-2, balance-windows)
(balance-windows-area-adjust, balance-windows-area)
(window--state-get-1, window-state-get, window--state-put-1)
(window--state-put-2, window-state-put)
(display-buffer-record-window, window--display-buffer): Make
functions handle pixelwise sizing of windows.
(display-buffer--action-function-custom-type)
(display-buffer-fallback-action): Add
display-buffer-in-previous-window.
(display-buffer-use-some-window): Resize window to height it had
before.
(fit-window-to-buffer-horizontally): New option.
(fit-frame-to-buffer): Describe new values.
(fit-frame-to-buffer-bottom-margin): Replace with
fit-frame-to-buffer-margins.
(window--sanitize-margin): New function.
(fit-frame-to-buffer, fit-window-to-buffer): Rewrite completely
using window-text-pixel-size.
Diffstat (limited to 'src/frame.c')
-rw-r--r-- | src/frame.c | 352 |
1 files changed, 286 insertions, 66 deletions
diff --git a/src/frame.c b/src/frame.c index 35e7ff1fbb..df41822f91 100644 --- a/src/frame.c +++ b/src/frame.c @@ -78,6 +78,7 @@ Lisp_Object Qleft, Qright; Lisp_Object Qicon_left, Qicon_top, Qicon_type, Qicon_name; Lisp_Object Qtooltip; Lisp_Object Qinternal_border_width; +Lisp_Object Qright_divider_width, Qbottom_divider_width; Lisp_Object Qmouse_color; Lisp_Object Qminibuffer; Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars; @@ -197,9 +198,12 @@ static void set_menu_bar_lines_1 (Lisp_Object window, int n) { struct window *w = XWINDOW (window); + struct frame *f = XFRAME (WINDOW_FRAME (w)); w->top_line += n; + w->pixel_top += n * FRAME_LINE_HEIGHT (f); w->total_lines -= n; + w->pixel_height -= n * FRAME_LINE_HEIGHT (f); /* Handle just the top child in a vertical split. */ if (WINDOW_VERTICAL_COMBINATION_P (w)) @@ -236,6 +240,7 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) windows_or_buffers_changed = 14; FRAME_WINDOW_SIZES_CHANGED (f) = 1; FRAME_MENU_BAR_LINES (f) = nlines; + FRAME_MENU_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f); set_menu_bar_lines_1 (f->root_window, nlines - olines); adjust_frame_glyphs (f); } @@ -325,6 +330,7 @@ make_frame (bool mini_p) { Lisp_Object frame; register struct frame *f; + register struct window *rw, *mw; register Lisp_Object root_window; register Lisp_Object mini_window; @@ -350,23 +356,25 @@ make_frame (bool mini_p) #endif root_window = make_window (); + rw = XWINDOW (root_window); if (mini_p) { mini_window = make_window (); - wset_next (XWINDOW (root_window), mini_window); - wset_prev (XWINDOW (mini_window), root_window); - XWINDOW (mini_window)->mini = 1; - wset_frame (XWINDOW (mini_window), frame); + mw = XWINDOW (mini_window); + wset_next (rw, mini_window); + wset_prev (mw, root_window); + mw->mini = 1; + wset_frame (mw, frame); fset_minibuffer_window (f, mini_window); } else { mini_window = Qnil; - wset_next (XWINDOW (root_window), Qnil); + wset_next (rw, Qnil); fset_minibuffer_window (f, Qnil); } - wset_frame (XWINDOW (root_window), frame); + wset_frame (rw, frame); /* 10 is arbitrary, just so that there is "something there." @@ -374,15 +382,22 @@ make_frame (bool mini_p) SET_FRAME_COLS (f, 10); FRAME_LINES (f) = 10; + SET_FRAME_WIDTH (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f)); + SET_FRAME_HEIGHT (f, FRAME_LINES (f) * FRAME_LINE_HEIGHT (f)); - XWINDOW (root_window)->total_cols = 10; - XWINDOW (root_window)->total_lines = mini_p ? 9 : 10; + rw->total_cols = 10; + rw->pixel_width = rw->total_cols * FRAME_COLUMN_WIDTH (f); + rw->total_lines = mini_p ? 9 : 10; + rw->pixel_height = rw->total_lines * FRAME_LINE_HEIGHT (f); if (mini_p) { - XWINDOW (mini_window)->total_cols = 10; - XWINDOW (mini_window)->top_line = 9; - XWINDOW (mini_window)->total_lines = 1; + mw->top_line = rw->total_lines; + mw->pixel_top = rw->pixel_height; + mw->total_cols = rw->total_cols; + mw->pixel_width = rw->pixel_width; + mw->total_lines = 1; + mw->pixel_height = FRAME_LINE_HEIGHT (f); } /* Choose a buffer for the frame's root window. */ @@ -603,7 +618,8 @@ make_terminal_frame (struct terminal *terminal) #endif /* not MSDOS */ FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; - FRAME_MENU_BAR_LINES(f) = NILP (Vmenu_bar_mode) ? 0 : 1; + FRAME_MENU_BAR_LINES (f) = NILP (Vmenu_bar_mode) ? 0 : 1; + FRAME_MENU_BAR_HEIGHT (f) = FRAME_MENU_BAR_LINES (f) * FRAME_LINE_HEIGHT (f); /* Set the top frame to the newly created frame. */ if (FRAMEP (FRAME_TTY (f)->top_frame) @@ -723,7 +739,7 @@ affects all frames on the same terminal device. */) { int width, height; get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height); - change_frame_size (f, height, width, 0, 0, 0); + change_frame_size (f, width, height, 0, 0, 0, 0); } adjust_frame_glyphs (f); @@ -2012,6 +2028,18 @@ set_term_frame_name (struct frame *f, Lisp_Object name) } void +set_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) +{ + register Lisp_Object old_alist_elt; + + old_alist_elt = Fassq (prop, f->param_alist); + if (EQ (old_alist_elt, Qnil)) + fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist)); + else + Fsetcdr (old_alist_elt, val); +} + +void store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) { register Lisp_Object old_alist_elt; @@ -2164,9 +2192,17 @@ If FRAME is omitted or nil, return information on the currently selected frame. :"tty")); } store_in_alist (&alist, Qname, f->name); - height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f)); + height = (f->new_height + ? (f->new_pixelwise + ? (f->new_height / FRAME_LINE_HEIGHT (f)) + : f->new_height) + : FRAME_LINES (f)); store_in_alist (&alist, Qheight, make_number (height)); - width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f)); + width = (f->new_width + ? (f->new_pixelwise + ? (f->new_width / FRAME_COLUMN_WIDTH (f)) + : f->new_width) + : FRAME_COLS (f)); store_in_alist (&alist, Qwidth, make_number (width)); store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil)); store_in_alist (&alist, Qminibuffer, @@ -2437,80 +2473,180 @@ is used. */) #endif return make_number (0); } + +DEFUN ("frame-text-cols", Fframe_text_cols, Sframe_text_cols, 0, 1, 0, + doc: /* Return width in columns of FRAME's text area. */) + (Lisp_Object frame) +{ + return make_number (FRAME_COLS (decode_any_frame (frame))); +} + +DEFUN ("frame-text-lines", Fframe_text_lines, Sframe_text_lines, 0, 1, 0, + doc: /* Return height in lines of FRAME's text area. */) + (Lisp_Object frame) +{ + return make_number (FRAME_LINES (decode_any_frame (frame))); +} + +DEFUN ("frame-total-cols", Fframe_total_cols, Sframe_total_cols, 0, 1, 0, + doc: /* Return total columns of FRAME. */) + (Lisp_Object frame) +{ + return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame))); +} + +DEFUN ("frame-text-width", Fframe_text_width, Sframe_text_width, 0, 1, 0, + doc: /* Return text area width of FRAME in pixels. */) + (Lisp_Object frame) +{ + return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame))); +} + +DEFUN ("frame-text-height", Fframe_text_height, Sframe_text_height, 0, 1, 0, + doc: /* Return text area height of FRAME in pixels. */) + (Lisp_Object frame) +{ + return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame))); +} + +DEFUN ("frame-scroll-bar-width", Fscroll_bar_width, Sscroll_bar_width, 0, 1, 0, + doc: /* Return scroll bar width of FRAME in pixels. */) + (Lisp_Object frame) +{ + return make_number (decode_any_frame (frame)->scroll_bar_actual_width); +} + +DEFUN ("frame-fringe-width", Ffringe_width, Sfringe_width, 0, 1, 0, + doc: /* Return fringe width of FRAME in pixels. */) + (Lisp_Object frame) +{ + return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame))); +} + +DEFUN ("frame-border-width", Fborder_width, Sborder_width, 0, 1, 0, + doc: /* Return border width of FRAME in pixels. */) + (Lisp_Object frame) +{ + return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame))); +} + +DEFUN ("frame-right-divider-width", Fright_divider_width, Sright_divider_width, 0, 1, 0, + doc: /* Return width (in pixels) of vertical window dividers on FRAME. */) + (Lisp_Object frame) +{ + return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame))); +} + +DEFUN ("frame-bottom-divider-width", Fbottom_divider_width, Sbottom_divider_width, 0, 1, 0, + doc: /* Return width (in pixels) of horizontal window dividers on FRAME. */) + (Lisp_Object frame) +{ + return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame))); +} -DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0, - doc: /* Specify that the frame FRAME has LINES lines. -If FRAME is nil, the selected frame is used. Optional third arg -non-nil means that redisplay should use LINES lines but that the -idea of the actual height of the frame should not be changed. */) - (Lisp_Object frame, Lisp_Object lines, Lisp_Object pretend) +DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 4, 0, + doc: /* Specify that the frame FRAME has HEIGHT text lines. +Optional third arg PRETEND non-nil means that redisplay should use +HEIGHT lines but that the idea of the actual height of the frame should +not be changed. Optional fourth argument PIXELWISE non-nil means that +FRAME should be HEIGHT pixels high. */) + (Lisp_Object frame, Lisp_Object height, Lisp_Object pretend, Lisp_Object pixelwise) { register struct frame *f = decode_live_frame (frame); - CHECK_TYPE_RANGED_INTEGER (int, lines); + CHECK_TYPE_RANGED_INTEGER (int, height); /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) { - if (XINT (lines) != FRAME_LINES (f)) - x_set_window_size (f, 1, FRAME_COLS (f), XINT (lines)); - do_pending_window_change (0); + if (NILP (pixelwise)) + { + if (XINT (height) != FRAME_LINES (f)) + x_set_window_size (f, 1, FRAME_COLS (f), XINT (height), 0); + + do_pending_window_change (0); + } + else if (XINT (height) != FRAME_TEXT_HEIGHT (f)) + { + x_set_window_size (f, 1, FRAME_TEXT_WIDTH (f), XINT (height), 1); + do_pending_window_change (0); + } } else #endif - change_frame_size (f, XINT (lines), 0, !NILP (pretend), 0, 0); + change_frame_size (f, 0, XINT (height), !NILP (pretend), 0, 0, + NILP (pixelwise) ? 0 : 1); return Qnil; } -DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0, - doc: /* Specify that the frame FRAME has COLS columns. -If FRAME is nil, the selected frame is used. Optional third arg -non-nil means that redisplay should use COLS columns but that the -idea of the actual width of the frame should not be changed. */) - (Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend) +DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 4, 0, + doc: /* Specify that the frame FRAME has WIDTH columns. +Optional third arg PRETEND non-nil means that redisplay should use WIDTH +columns but that the idea of the actual width of the frame should not +be changed. Optional fourth argument PIXELWISE non-nil means that FRAME +should be WIDTH pixels wide. */) + (Lisp_Object frame, Lisp_Object width, Lisp_Object pretend, Lisp_Object pixelwise) { register struct frame *f = decode_live_frame (frame); - CHECK_TYPE_RANGED_INTEGER (int, cols); + CHECK_TYPE_RANGED_INTEGER (int, width); /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) { - if (XINT (cols) != FRAME_COLS (f)) - x_set_window_size (f, 1, XINT (cols), FRAME_LINES (f)); - do_pending_window_change (0); + if (NILP (pixelwise)) + { + if (XINT (width) != FRAME_COLS (f)) + x_set_window_size (f, 1, XINT (width), FRAME_LINES (f), 0); + + do_pending_window_change (0); + } + else if (XINT (width) != FRAME_TEXT_WIDTH (f)) + { + x_set_window_size (f, 1, XINT (width), FRAME_TEXT_HEIGHT (f), 1); + do_pending_window_change (0); + } } else #endif - change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0, 0); + change_frame_size (f, XINT (width), 0, !NILP (pretend), 0, 0, + NILP (pixelwise) ? 0 : 1); return Qnil; } -DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0, - doc: /* Sets size of FRAME to COLS by ROWS, measured in characters. -If FRAME is nil, the selected frame is used. */) - (Lisp_Object frame, Lisp_Object cols, Lisp_Object rows) +DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 4, 0, + doc: /* Sets size of FRAME to WIDTH by HEIGHT, measured in characters. +Optional argument PIXELWISE non-nil means to measure in pixels. */) + (Lisp_Object frame, Lisp_Object width, Lisp_Object height, Lisp_Object pixelwise) { register struct frame *f = decode_live_frame (frame); - CHECK_TYPE_RANGED_INTEGER (int, cols); - CHECK_TYPE_RANGED_INTEGER (int, rows); + CHECK_TYPE_RANGED_INTEGER (int, width); + CHECK_TYPE_RANGED_INTEGER (int, height); /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) { - if (XINT (rows) != FRAME_LINES (f) - || XINT (cols) != FRAME_COLS (f) - || f->new_text_lines || f->new_text_cols) - x_set_window_size (f, 1, XINT (cols), XINT (rows)); - do_pending_window_change (0); + if (!NILP (pixelwise) + ? (XINT (width) != FRAME_TEXT_WIDTH (f) + || XINT (height) != FRAME_TEXT_HEIGHT (f) + || f->new_height || f->new_width) + : (XINT (width) != FRAME_COLS (f) + || XINT (height) != FRAME_LINES (f) + || f->new_height || f->new_width)) + { + x_set_window_size (f, 1, XINT (width), XINT (height), + NILP (pixelwise) ? 0 : 1); + do_pending_window_change (0); + } } else #endif - change_frame_size (f, XINT (rows), XINT (cols), 0, 0, 0); + change_frame_size (f, XINT (width), XINT (height), 0, 0, 0, + NILP (pixelwise) ? 0 : 1); return Qnil; } @@ -2569,6 +2705,8 @@ static const struct frame_parm_table frame_parms[] = {"icon-name", &Qicon_name}, {"icon-type", &Qicon_type}, {"internal-border-width", &Qinternal_border_width}, + {"right-divider-width", &Qright_divider_width}, + {"bottom-divider-width", &Qbottom_divider_width}, {"menu-bar-lines", &Qmenu_bar_lines}, {"mouse-color", &Qmouse_color}, {"name", &Qname}, @@ -2703,8 +2841,16 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist) icon_left = icon_top = Qunbound; /* Provide default values for HEIGHT and WIDTH. */ - width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f)); - height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f)); + width = (f->new_width + ? (f->new_pixelwise + ? (f->new_width / FRAME_COLUMN_WIDTH (f)) + : f->new_width) + : FRAME_COLS (f)); + height = (f->new_height + ? (f->new_pixelwise + ? (f->new_height / FRAME_LINE_HEIGHT (f)) + : f->new_height) + : FRAME_LINES (f)); /* Process foreground_color and background_color before anything else. They are independent of other properties, but other properties (e.g., @@ -2830,15 +2976,16 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist) { Lisp_Object frame; - check_frame_size (f, &height, &width); + /* Make this 1, eventually. */ + check_frame_size (f, &width, &height, 0); XSETFRAME (frame, f); if (size_changed && (width != FRAME_COLS (f) || height != FRAME_LINES (f) - || f->new_text_lines || f->new_text_cols)) - Fset_frame_size (frame, make_number (width), make_number (height)); + || f->new_height || f->new_width)) + Fset_frame_size (frame, make_number (width), make_number (height), Qnil); if ((!NILP (left) || !NILP (top)) && ! (left_no_change && top_no_change) @@ -2946,6 +3093,10 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) make_number (f->border_width)); store_in_alist (alistptr, Qinternal_border_width, make_number (FRAME_INTERNAL_BORDER_WIDTH (f))); + store_in_alist (alistptr, Qright_divider_width, + make_number (FRAME_RIGHT_DIVIDER_WIDTH (f))); + store_in_alist (alistptr, Qbottom_divider_width, + make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f))); store_in_alist (alistptr, Qleft_fringe, make_number (FRAME_LEFT_FRINGE_WIDTH (f))); store_in_alist (alistptr, Qright_fringe, @@ -3278,7 +3429,53 @@ x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldva if (FRAME_X_WINDOW (f) != 0) { - x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); + x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 1); + SET_FRAME_GARBAGED (f); + do_pending_window_change (0); + } + else + SET_FRAME_GARBAGED (f); +} + +void +x_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +{ + int old = FRAME_RIGHT_DIVIDER_WIDTH (f); + + CHECK_TYPE_RANGED_INTEGER (int, arg); + FRAME_RIGHT_DIVIDER_WIDTH (f) = XINT (arg); + if (FRAME_RIGHT_DIVIDER_WIDTH (f) < 0) + FRAME_RIGHT_DIVIDER_WIDTH (f) = 0; + + if (FRAME_RIGHT_DIVIDER_WIDTH (f) == old) + return; + + if (FRAME_X_WINDOW (f) != 0) + { + x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 1); + SET_FRAME_GARBAGED (f); + do_pending_window_change (0); + } + else + SET_FRAME_GARBAGED (f); +} + +void +x_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) +{ + int old = FRAME_BOTTOM_DIVIDER_WIDTH (f); + + CHECK_TYPE_RANGED_INTEGER (int, arg); + FRAME_BOTTOM_DIVIDER_WIDTH (f) = XINT (arg); + if (FRAME_BOTTOM_DIVIDER_WIDTH (f) < 0) + FRAME_BOTTOM_DIVIDER_WIDTH (f) = 0; + + if (FRAME_BOTTOM_DIVIDER_WIDTH (f) == old) + return; + + if (FRAME_X_WINDOW (f) != 0) + { + x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 1); SET_FRAME_GARBAGED (f); do_pending_window_change (0); } @@ -3344,7 +3541,8 @@ x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval However, if the window hasn't been created yet, we shouldn't call x_set_window_size. */ if (FRAME_X_WINDOW (f)) - x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); + x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), + FRAME_TEXT_HEIGHT (f), 1); do_pending_window_change (0); } } @@ -3352,27 +3550,29 @@ x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval void x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { - int wid = FRAME_COLUMN_WIDTH (f); + int unit = FRAME_COLUMN_WIDTH (f); if (NILP (arg)) { x_set_scroll_bar_default_width (f); if (FRAME_X_WINDOW (f)) - x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); + x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), + FRAME_TEXT_HEIGHT (f), 1); do_pending_window_change (0); } else if (RANGED_INTEGERP (1, arg, INT_MAX) && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) { FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFASTINT (arg); - FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid; + FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + unit - 1) / unit; if (FRAME_X_WINDOW (f)) - x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); + x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), + FRAME_TEXT_HEIGHT (f), 1); do_pending_window_change (0); } - change_frame_size (f, 0, FRAME_COLS (f), 0, 0, 0); + change_frame_size (f, 0, 0, 0, 0, 0, 1); XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0; XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0; } @@ -3985,17 +4185,20 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p) /* Default values if we fall through. Actually, if that happens we should get window manager prompting. */ + SET_FRAME_WIDTH (f, DEFAULT_COLS * FRAME_COLUMN_WIDTH (f)); SET_FRAME_COLS (f, DEFAULT_COLS); + SET_FRAME_HEIGHT (f, DEFAULT_ROWS * FRAME_LINE_HEIGHT (f)); FRAME_LINES (f) = DEFAULT_ROWS; + /* Window managers expect that if program-specified positions are not (0,0), they're intentional, not defaults. */ f->top_pos = 0; f->left_pos = 0; - /* Ensure that old new_text_cols and new_text_lines will not override the + /* Ensure that old new_width and new_height will not override the values set here. */ /* ++KFS: This was specific to W32, but seems ok for all platforms */ - f->new_text_cols = f->new_text_lines = 0; + f->new_width = f->new_height = f->new_pixelwise = 0; tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER); tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER); @@ -4036,7 +4239,7 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p) change the frame size. This is done so that users can create tall Emacs frames without having to guess how tall the tool-bar will get. */ - if (toolbar_p && FRAME_TOOL_BAR_LINES (f)) + if (toolbar_p && FRAME_TOOL_BAR_HEIGHT (f)) { int margin, relief, bar_height; @@ -4052,14 +4255,15 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p) else margin = 0; + /* PXW: We should be able to not round here. */ bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief; FRAME_LINES (f) += (bar_height + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f); } compute_fringe_widths (f, 0); - FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, FRAME_COLS (f)); - FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f)); + SET_FRAME_WIDTH (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f)); + SET_FRAME_HEIGHT(f, FRAME_LINES (f) * FRAME_LINE_HEIGHT (f)); tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER); tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER); @@ -4512,6 +4716,12 @@ handles focus, since there is no way in general for Emacs to find out automatically. See also `mouse-autoselect-window'. */); focus_follows_mouse = 0; + DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise, + doc: /* Non-nil means frames are resized pixelwise. +If this is nil, resizing a frame will round sizes to the frame's +current values of `frame-char-height' and `frame-char-width'. */); + frame_resize_pixelwise = 0; + staticpro (&Vframe_list); defsubr (&Sframep); @@ -4551,6 +4761,16 @@ automatically. See also `mouse-autoselect-window'. */); defsubr (&Sframe_char_width); defsubr (&Sframe_pixel_height); defsubr (&Sframe_pixel_width); + defsubr (&Sframe_text_cols); + defsubr (&Sframe_text_lines); + defsubr (&Sframe_total_cols); + defsubr (&Sframe_text_width); + defsubr (&Sframe_text_height); + defsubr (&Sscroll_bar_width); + defsubr (&Sfringe_width); + defsubr (&Sborder_width); + defsubr (&Sright_divider_width); + defsubr (&Sbottom_divider_width); defsubr (&Stool_bar_pixel_width); defsubr (&Sset_frame_height); defsubr (&Sset_frame_width); |