summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2017-06-25 11:33:25 +0200
committerMartin Rudalics <rudalics@gmx.at>2017-06-25 11:33:25 +0200
commit1886246f6f40b8c376467f71605141035959cae0 (patch)
tree74bf775484482a19c182d1c6ad2d984a8c610eb1 /src/window.c
parent431471376440a69a2f5ca2a49e3c7e09c834c132 (diff)
downloademacs-1886246f6f40b8c376467f71605141035959cae0.tar.gz
emacs-1886246f6f40b8c376467f71605141035959cae0.tar.bz2
emacs-1886246f6f40b8c376467f71605141035959cae0.zip
Provide additional support for child frames
Provide mouse dragging and resizing of frames. Allow resizing frames proportionally. Provide additional functionality for child frames. Minor bug fixes. * lisp/frame.el (frame-border-width, frame-pixel-width) (frame-pixel-height): Alias to `frame-internal-border-width', `frame-native-width' and `frame-native-height'. (frame-inner-width, frame-inner-height, frame-outer-width) (frame-outer-height): New functions. * lisp/minibuffer.el (completion-auto-help): Fix typo. * lisp/mouse.el (mouse-drag-line, mouse-drag-mode-line) (mouse-drag-header-line): Allow moving a frame by dragging the mode line of its bottommost window (on a minibuffer-less frame) or the header line of its topmost window. (mouse-drag-vertical-line): Mention argument in doc-string. (mouse-resize-frame, mouse-drag-frame, mouse-drag-left-edge) (mouse-drag-top-left-corner, mouse-drag-top-edge) (mouse-drag-top-right-corner, mouse-drag-right-edge) (mouse-drag-bottom-right-corner, mouse-drag-bottom-edge) (mouse-drag-bottom-left-corner): New functions for resizing a frame by dragging its internal border together with corresponding key bindings. * lisp/tooltip.el (tooltip-frame-parameters): Add 'no-special-glyphs' to default parameters and update version tag. * lisp/window.el (frame-auto-hide-function): Add choice to make frame invisible and update version tag. (window--delete): Handle 'auto-hide-function' frame parameter. (window--maybe-raise-frame): Respect 'no-focus-on-map' and 'no-accept-focus' frame parameters. (display-buffer--action-function-custom-type): Add `display-buffer-in-child-frame'. (display-buffer): Mention `display-buffer-in-child-frame' in doc-string. (display-buffer-in-child-frame): New action function for `display-buffer'. (window--sanitize-margin): Return zero when MARGIN cannot be sanitized. (fit-frame-to-buffer): Major rewrite to handle child frames and 'fit-frame-to-buffer-sizes' and 'fit-frame-to-buffer-margins' frame parameters. (window-largest-empty-rectangle--maximums-1) (window-largest-empty-rectangle--maximums) (window-largest-empty-rectangle--disjoint-maximums) (window-largest-empty-rectangle): New functions. * src/dispextern.h (WINDOW_WANTS_MODELINE_P) (WINDOW_WANTS_HEADER_LINE_P): Remove. Functionality is now provided by corresponding functions window_wants_modeline and window_wants_header_line in window.c. Adjust users. * src/dispnew.c (adjust_glyph_matrix) (buffer_posn_from_coords): Use window_wants_modeline and window_wants_header_line instead of WINDOW_WANTS_MODELINE_P and WINDOW_WANTS_HEADER_LINE_P. * src/frame.c (keep_ratio): New function. (adjust_frame_size): Call keep_ratio for each of F's child frames. (make_frame): Initialize no_special_glyphs slot. (frame_internal_border_part): New function. (Fframe_pixel_width, Fframe_pixel_height, Fborder_width): Rename to Fframe_native_width, Fframe_native_height mand Fframe_internal_border_width. (frame_parm_table): Add Qno_special_glyphs entry. (frame_float_type): New enumeration type. (frame_float): New function to handle frame size and position ratios. (x_set_frame_parameters): Handle size and position ratios. (x_set_no_special_glyphs): New function (x_figure_window_size): Handle size and position ratios. (syms_of_frame): Add Qdisplay_monitor_attributes_list, Qno_special_glyphs, Qframe_edges, Qkeep_ratio, Qwidth_only, Qheight_only, Qleft_only and Qtop_only. * src/frame.h (internal_border_part): New enumeration type. (struct frame): New slot no_special_glyphs. (FRAME_NO_SPECIAL_GLYPHS): New macro. * src/gtkutil.c (xg_frame_restack): Return immediately for GTK versions before 2.18.0. * src/keyboard.c (internal_border_parts): New array constant. (make_lispy_position): For frames with border dragging enabled return internal border part. (syms_of_keyboard): New symbols Qdrag_internal_border, Qleft_edge, Qtop_left_corner, Qtop_edge, Qtop_right_corner, Qright_edge, Qbottom_right_corner, Qbottom_edge and Qbottom_left_corner. * src/minibuf.c (read_minibuf_unwind): When exiting the minibuffer deal with frames that have the 'minibuffer-exit' parameter set. (syms_of_minibuf): New symbol Qminibuffer_exit. * src/nsfns.m (frame_parm_handler): Add entry for x_set_no_special_glyphs. (Fx_create_frame): Handle 'no-special-glyphs' parameter. Intitialize new cursor types for dragging frame borders. * src/nsterm.h (struct ns_output): Add new cursor types for dragging frame borders. * src/w32fns.c (w32_frame_parm_handlers): Add entry for x_set_no_special_glyphs. (Fx_create_frame): Handle 'no-special-glyphs' parameter. Intitialize new cursor types for dragging frame borders. * src/w32term.h (struct w32_output): Add new cursor types for dragging frame borders. * src/window.c (coordinates_in_window) (Fwindow_line_height, window_internal_height): Use window_wants_modeline and window_wants_header_line instead of WINDOW_WANTS_MODELINE_P and WINDOW_WANTS_HEADER_LINE_P. (Fwindow_lines_pixel_dimensions): New function. (window_parameter): New function. (Fwindow_parameter): Call window_parameter. (window_wants_mode_line, window_wants_header_line): New functions replacing the macros WINDOW_WANTS_MODELINE_P and WINDOW_WANTS_HEADER_LINE_P from dispextern.h. (syms_of_window): New symbols Qmode_line_format and Qheader_line_format. * src/window.h: Reorganize and re-comment macros. Use window_wants_modeline and window_wants_header_line instead of WINDOW_WANTS_MODELINE_P and WINDOW_WANTS_HEADER_LINE_P. (MINI_NON_ONLY_WINDOW_P, MINI_ONLY_WINDOW_P): Minor rewrite. (WINDOW_BUFFER): New macro. (WINDOW_BOX_LEFT_EDGE_COL, WINDOW_BOX_RIGHT_EDGE_COL): Remove. * src/xdisp.c (window_text_bottom_y, window_box_height) (window_box, start_display) (compute_window_start_on_continuation_line) (try_cursor_movement, redisplay_window) (try_window_reusing_current_matrix, try_window_id) (display_line, expose_window): Use window_wants_modeline and window_wants_header_line instead of WINDOW_WANTS_MODELINE_P and WINDOW_WANTS_HEADER_LINE_P. (pos_visible_p, display_mode_lines): Respect W's 'mode-line-format' and 'header-line-format' window parameters. (init_iterator): Use window_wants_modeline and window_wants_header_line instead of WINDOW_WANTS_MODELINE_P and WINDOW_WANTS_HEADER_LINE_P. For tip frames respect no_special_glyphs value. (note_mouse_highlight): Set frame border cursors when on internal border. (x_draw_right_divider, x_draw_bottom_divider): Try to improve drawing of window dividers. * src/xfns.c (mouse_cursor): Add entries for border parts. (mouse_cursor_types): Add entries for cursor types to drag frame borders. (INSTALL_CURSOR): Add entries for new cursor types to drag frame borders. (Fx_create_frame): Handle 'no-special-glyphs' parameter. (x_frame_parm_handlers): Add entry for x_set_no_special_glyphs. (Vx_window_left_edge_shape, Vx_window_top_left_corner_shape) (Vx_window_top_edge_shape, Vx_window_top_right_corner_shape) (Vx_window_right_edge_shape) (Vx_window_bottom_right_corner_shape) (Vx_window_bottom_edge_shape) (Vx_window_bottom_left_corner_shape): New variables. (x_frame_restack): Call xg_frame_restack only for GTK versions starting with 2.18.0. * src/xterm.c (x_free_frame_resources): Remove new cursors for dragging frame borders. * src/xterm.h (struct x_output): Add new cursor types for dragging frame borders. * doc/lispref/display.texi (Size of Displayed Text): Document `window-lines-pixel-dimensions'. * doc/lispref/elisp.texi (Top): Add entry for "Mouse Dragging Parameters". * doc/lispref/frames.texi (Frame Size): Replace frame-pixel-width/-height by frame-native-width/-height. Add frame-inner-width/-height and frame-outer-width/-height docs. (Position Parameters): Describe specifying position as ratios. Clarify remark about positions relative to bottom/ridge display edge. (Size Parameters): Describe specifying sizes as ratios. Describe 'fit-frame-to-buffer-margins' and 'fit-frame-to-buffer-sizes' parameters. (Layout Parameters): Describe 'no-special-glyphs' parameter. (Frame Interaction Parameters): Describe 'auto-hide-function', 'minibuffer-exit' and 'keep-ratio' parameters. (Mouse Dragging Parameters): New section describing 'drag-internal-border', 'drag-with-header-line', 'drag-with-mode-line', 'snap-width', 'top-visible' and 'bottom-visible' parameters. (Management Parameters): Mention that `override-redirect' has no effect on MS Windows. (Font and Color Parameters): Mention child frames for `alpha' parameter. (Child Frames): Rewrite section with description and cross references to new frame parameters added. * doc/lispref/modes.texi (Mode Line Basics): Mention 'mode-line-format' and 'header-line-format' window parameters. * doc/lispref/windows.texi (Resizing Windows): Mention effect of `fit-frame-to-buffer-margins' for child frames. (Display Action Functions): New action function `display-buffer-in-child-frame'. (Quitting Windows): Mention `make-frame-invisible' as optional value of `frame-auto-hide-function' and `auto-hide-function' frame paameter. (Coordinates and Windows): Describe new function `window-largest-empty-rectangle'. (Window Parameters): Describe new parameters 'mode-line-format' and 'header-line-format'. Index all window parameters described in this section.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c213
1 files changed, 205 insertions, 8 deletions
diff --git a/src/window.c b/src/window.c
index bf89f0e488b..4816bd69909 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1208,13 +1208,13 @@ coordinates_in_window (register struct window *w, int x, int y)
- WINDOW_BOTTOM_DIVIDER_WIDTH (w))))
return ON_HORIZONTAL_SCROLL_BAR;
/* On the mode or header line? */
- else if ((WINDOW_WANTS_MODELINE_P (w)
+ else if ((window_wants_mode_line (w)
&& y >= (bottom_y
- CURRENT_MODE_LINE_HEIGHT (w)
- WINDOW_BOTTOM_DIVIDER_WIDTH (w))
&& y <= bottom_y - WINDOW_BOTTOM_DIVIDER_WIDTH (w)
&& (part = ON_MODE_LINE))
- || (WINDOW_WANTS_HEADER_LINE_P (w)
+ || (window_wants_header_line (w)
&& y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)
&& (part = ON_HEADER_LINE)))
{
@@ -1851,7 +1851,7 @@ Return nil if window display is not up-to-date. In that case, use
if (EQ (line, Qheader_line))
{
- if (!WINDOW_WANTS_HEADER_LINE_P (w))
+ if (!window_wants_header_line (w))
return Qnil;
row = MATRIX_HEADER_LINE_ROW (w->current_matrix);
return row->enabled_p ? list4i (row->height, 0, 0, 0) : Qnil;
@@ -1898,6 +1898,129 @@ Return nil if window display is not up-to-date. In that case, use
return list4i (row->height + min (0, row->y) - crop, i, row->y, crop);
}
+DEFUN ("window-lines-pixel-dimensions", Fwindow_lines_pixel_dimensions, Swindow_lines_pixel_dimensions, 0, 6, 0,
+ doc: /* Return pixel dimensions of WINDOW's lines.
+The return value is a list of the x- and y-coordinates of the lower
+right corner of the last character of each line. Return nil if the
+current glyph matrix of WINDOW is not up-to-date.
+
+Optional argument WINDOW specifies the window whose lines' dimensions
+shall be returned. Nil or omitted means to return the dimensions for
+the selected window.
+
+FIRST, if non-nil, specifies the index of the first line whose
+dimensions shall be returned. If FIRST is nil and BODY is non-nil,
+start with the first text line of WINDOW. Otherwise, start with the
+first line of WINDOW.
+
+LAST, if non-nil, specifies the last line whose dimensions shall be
+returned. If LAST is nil and BODY is non-nil, the last line is the last
+line of the body (text area) of WINDOW. Otherwise, last is the last
+line of WINDOW.
+
+INVERSE, if nil, means that the y-pixel value returned for a specific
+line specifies the distance in pixels from the left edge (body edge if
+BODY is non-nil) of WINDOW to the right edge of the last glyph of that
+line. INVERSE non-nil means that the y-pixel value returned for a
+specific line specifies the distance in pixels from the right edge of
+the last glyph of that line to the right edge (body edge if BODY is
+non-nil) of WINDOW.
+
+LEFT non-nil means to return the x- and y-coordinates of the lower left
+corner of the leftmost character on each line. This is the value that
+should be used for buffers that mostly display text from right to left.
+
+If LEFT is non-nil and INVERSE is nil, this means that the y-pixel value
+returned for a specific line specifies the distance in pixels from the
+left edge of the last (leftmost) glyph of that line to the right edge
+(body edge if BODY is non-nil) of WINDOW. If LEFT and INVERSE are both
+non-nil, the y-pixel value returned for a specific line specifies the
+distance in pixels from the left edge (body edge if BODY is non-nil) of
+WINDOW to the left edge of the last (leftmost) glyph of that line.
+
+Normally, the value of this function is not available while Emacs is
+busy, for example, when processing a command. It should be retrievable
+though when run from an idle timer with a delay of zero seconds. */)
+ (Lisp_Object window, Lisp_Object first, Lisp_Object last, Lisp_Object body, Lisp_Object inverse, Lisp_Object left)
+{
+ struct window *w = decode_live_window (window);
+ struct buffer *b;
+ struct glyph_row *row, *end_row;
+ int max_y = NILP (body) ? WINDOW_PIXEL_HEIGHT (w) : window_text_bottom_y (w);
+ Lisp_Object rows = Qnil;
+ int window_width = NILP (body) ? w->pixel_width : window_body_width (w, true);
+ int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
+ int subtract = NILP (body) ? 0 : header_line_height;
+ bool invert = !NILP (inverse);
+ bool left_flag = !NILP (left);
+
+ if (noninteractive || w->pseudo_window_p)
+ return Qnil;
+
+ CHECK_BUFFER (w->contents);
+ b = XBUFFER (w->contents);
+
+ /* Fail if current matrix is not up-to-date. */
+ if (!w->window_end_valid
+ || windows_or_buffers_changed
+ || b->clip_changed
+ || b->prevent_redisplay_optimizations_p
+ || window_outdated (w))
+ return Qnil;
+
+ if (NILP (first))
+ row = (NILP (body)
+ ? MATRIX_ROW (w->current_matrix, 0)
+ : MATRIX_FIRST_TEXT_ROW (w->current_matrix));
+ else if (NUMBERP (first))
+ {
+ CHECK_RANGED_INTEGER (first, 0, w->current_matrix->nrows);
+ row = MATRIX_ROW (w->current_matrix, XINT (first));
+ }
+ else
+ error ("Invalid specification of first line");
+
+ if (NILP (last))
+
+ end_row = (NILP (body)
+ ? MATRIX_ROW (w->current_matrix, w->current_matrix->nrows)
+ : MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w));
+ else if (NUMBERP (last))
+ {
+ CHECK_RANGED_INTEGER (last, 0, w->current_matrix->nrows);
+ end_row = MATRIX_ROW (w->current_matrix, XINT (last));
+ }
+ else
+ error ("Invalid specification of last line");
+
+ while (row <= end_row && row->enabled_p
+ && row->y + row->height < max_y)
+ {
+
+ if (left_flag)
+ {
+ struct glyph *glyph = row->glyphs[TEXT_AREA];
+
+ rows = Fcons (Fcons (make_number
+ (invert
+ ? glyph->pixel_width
+ : window_width - glyph->pixel_width),
+ make_number (row->y + row->height - subtract)),
+ rows);
+ }
+ else
+ rows = Fcons (Fcons (make_number
+ (invert
+ ? window_width - row->pixel_width
+ : row->pixel_width),
+ make_number (row->y + row->height - subtract)),
+ rows);
+ row++;
+ }
+
+ return Fnreverse (rows);
+}
+
DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p,
0, 1, 0,
doc: /* Return non-nil when WINDOW is dedicated to its buffer.
@@ -2003,16 +2126,24 @@ return value is a list of elements of the form (PARAMETER . VALUE). */)
return Fcopy_alist (decode_valid_window (window)->window_parameters);
}
+Lisp_Object
+window_parameter (struct window *w, Lisp_Object parameter)
+{
+ Lisp_Object result = Fassq (parameter, w->window_parameters);
+
+ return CDR_SAFE (result);
+}
+
+
DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter,
2, 2, 0,
doc: /* Return WINDOW's value for PARAMETER.
WINDOW can be any window and defaults to the selected one. */)
(Lisp_Object window, Lisp_Object parameter)
{
- Lisp_Object result;
+ struct window *w = decode_any_window (window);
- result = Fassq (parameter, decode_any_window (window)->window_parameters);
- return CDR_SAFE (result);
+ return window_parameter (w, parameter);
}
DEFUN ("set-window-parameter", Fset_window_parameter,
@@ -4740,6 +4871,69 @@ mark_window_cursors_off (struct window *w)
}
+/**
+ * window_wants_mode_line:
+ *
+ * Return 1 if window W wants a mode line and is high enough to
+ * accomodate it, 0 otherwise.
+ *
+ * W wants a mode line if it's a leaf window and neither a minibuffer
+ * nor a pseudo window. Moreover, its 'window-mode-line-format'
+ * parameter must not be 'none' and either that parameter or W's
+ * buffer's 'mode-line-format' value must be non-nil. Finally, W must
+ * be higher than its frame's canonical character height.
+ */
+bool
+window_wants_mode_line (struct window *w)
+{
+ Lisp_Object window_mode_line_format =
+ window_parameter (w, Qmode_line_format);
+
+ return ((WINDOW_LEAF_P (w)
+ && !MINI_WINDOW_P (w)
+ && !WINDOW_PSEUDO_P (w)
+ && !EQ (window_mode_line_format, Qnone)
+ && (!NILP (window_mode_line_format)
+ || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), mode_line_format)))
+ && WINDOW_PIXEL_HEIGHT (w) > WINDOW_FRAME_LINE_HEIGHT (w))
+ ? 1
+ : 0);
+}
+
+
+/**
+ * window_wants_header_line:
+ *
+ * Return 1 if window W wants a header line and is high enough to
+ * accomodate it, 0 otherwise.
+ *
+ * W wants a header line if it's a leaf window and neither a minibuffer
+ * nor a pseudo window. Moreover, its 'window-mode-line-format'
+ * parameter must not be 'none' and either that parameter or W's
+ * buffer's 'mode-line-format' value must be non-nil. Finally, W must
+ * be higher than its frame's canonical character height and be able to
+ * accomodate a mode line too if necessary (the mode line prevails).
+ */
+bool
+window_wants_header_line (struct window *w)
+{
+ Lisp_Object window_header_line_format =
+ window_parameter (w, Qheader_line_format);
+
+ return ((WINDOW_LEAF_P (w)
+ && !MINI_WINDOW_P (w)
+ && !WINDOW_PSEUDO_P (w)
+ && !EQ (window_header_line_format, Qnone)
+ && (!NILP (window_header_line_format)
+ || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), header_line_format)))
+ && (WINDOW_PIXEL_HEIGHT (w)
+ > (window_wants_mode_line (w)
+ ? 2 * WINDOW_FRAME_LINE_HEIGHT (w)
+ : WINDOW_FRAME_LINE_HEIGHT (w))))
+ ? 1
+ : 0);
+}
+
/* Return number of lines of text (not counting mode lines) in W. */
int
@@ -4753,10 +4947,10 @@ window_internal_height (struct window *w)
|| WINDOWP (w->contents)
|| !NILP (w->next)
|| !NILP (w->prev)
- || WINDOW_WANTS_MODELINE_P (w))
+ || window_wants_mode_line (w))
--ht;
- if (WINDOW_WANTS_HEADER_LINE_P (w))
+ if (window_wants_header_line (w))
--ht;
}
@@ -7354,6 +7548,8 @@ syms_of_window (void)
DEFSYM (Qfloor, "floor");
DEFSYM (Qceiling, "ceiling");
DEFSYM (Qmark_for_redisplay, "mark-for-redisplay");
+ DEFSYM (Qmode_line_format, "mode-line-format");
+ DEFSYM (Qheader_line_format, "header-line-format");
staticpro (&Vwindow_list);
@@ -7603,6 +7799,7 @@ displayed after a scrolling operation to be somewhat inaccurate. */);
defsubr (&Sset_window_point);
defsubr (&Sset_window_start);
defsubr (&Swindow_dedicated_p);
+ defsubr (&Swindow_lines_pixel_dimensions);
defsubr (&Sset_window_dedicated_p);
defsubr (&Swindow_display_table);
defsubr (&Sset_window_display_table);