summaryrefslogtreecommitdiff
path: root/src/keyboard.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/keyboard.c
parent431471376440a69a2f5ca2a49e3c7e09c834c132 (diff)
downloademacs-1886246f6f40b8c376467f71605141035959cae0.tar.gz
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/keyboard.c')
-rw-r--r--src/keyboard.c52
1 files changed, 44 insertions, 8 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 3442b18409a..9e90899c569 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5127,6 +5127,17 @@ static short const scroll_bar_parts[] = {
SYMBOL_INDEX (Qrightmost), SYMBOL_INDEX (Qend_scroll), SYMBOL_INDEX (Qratio)
};
+/* An array of symbol indexes of internal border parts, indexed by an enum
+ internal_border_part value. Note that Qnil corresponds to
+ internal_border_part_none and should not appear in Lisp events. */
+static short const internal_border_parts[] = {
+ SYMBOL_INDEX (Qnil), SYMBOL_INDEX (Qleft_edge),
+ SYMBOL_INDEX (Qtop_left_corner), SYMBOL_INDEX (Qtop_edge),
+ SYMBOL_INDEX (Qtop_right_corner), SYMBOL_INDEX (Qright_edge),
+ SYMBOL_INDEX (Qbottom_right_corner), SYMBOL_INDEX (Qbottom_edge),
+ SYMBOL_INDEX (Qbottom_left_corner)
+};
+
/* A vector, indexed by button number, giving the down-going location
of currently depressed buttons, both scroll bar and non-scroll bar.
@@ -5164,15 +5175,15 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
Lisp_Object extra_info = Qnil;
/* Coordinate pixel positions to return. */
int xret = 0, yret = 0;
- /* The window under frame pixel coordinates (x,y) */
- Lisp_Object window = f
+ /* The window or frame under frame pixel coordinates (x,y) */
+ Lisp_Object window_or_frame = f
? window_from_coordinates (f, XINT (x), XINT (y), &part, 0)
: Qnil;
- if (WINDOWP (window))
+ if (WINDOWP (window_or_frame))
{
/* It's a click in window WINDOW at frame coordinates (X,Y) */
- struct window *w = XWINDOW (window);
+ struct window *w = XWINDOW (window_or_frame);
Lisp_Object string_info = Qnil;
ptrdiff_t textpos = 0;
int col = -1, row = -1;
@@ -5361,17 +5372,31 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
make_number (row)),
extra_info)));
}
- else if (f != 0)
+
+#ifdef HAVE_WINDOW_SYSTEM
+ else if (f)
{
/* Return mouse pixel coordinates here. */
- XSETFRAME (window, f);
+ XSETFRAME (window_or_frame, f);
xret = XINT (x);
yret = XINT (y);
+
+ if (FRAME_LIVE_P (f)
+ && FRAME_INTERNAL_BORDER_WIDTH (f) > 0
+ && !NILP (get_frame_param (f, Qdrag_internal_border)))
+ {
+ enum internal_border_part part
+ = frame_internal_border_part (f, xret, yret);
+
+ posn = builtin_lisp_symbol (internal_border_parts[part]);
+ }
}
+#endif
+
else
- window = Qnil;
+ window_or_frame = Qnil;
- return Fcons (window,
+ return Fcons (window_or_frame,
Fcons (posn,
Fcons (Fcons (make_number (xret),
make_number (yret)),
@@ -11159,6 +11184,17 @@ syms_of_keyboard (void)
Fset (Qinput_method_exit_on_first_char, Qnil);
Fset (Qinput_method_use_echo_area, Qnil);
+ /* Symbols for dragging internal borders. */
+ DEFSYM (Qdrag_internal_border, "drag-internal-border");
+ DEFSYM (Qleft_edge, "left-edge");
+ DEFSYM (Qtop_left_corner, "top-left-corner");
+ DEFSYM (Qtop_edge, "top-edge");
+ DEFSYM (Qtop_right_corner, "top-right-corner");
+ DEFSYM (Qright_edge, "right-edge");
+ DEFSYM (Qbottom_right_corner, "bottom-right-corner");
+ DEFSYM (Qbottom_edge, "bottom-edge");
+ DEFSYM (Qbottom_left_corner, "bottom-left-corner");
+
/* Symbols to head events. */
DEFSYM (Qmouse_movement, "mouse-movement");
DEFSYM (Qscroll_bar_movement, "scroll-bar-movement");