Permit zero value for 'child-frame-border-width' parameter (Bug#46184)

* doc/lispref/frames.texi (Layout Parameters): Update entry on
'child-frame-border-width' parameter.
* src/frame.c (make_frame): Init child_frame_border_width to -1.
(Fframe_child_frame_border_width): Return internal border width if
child frame border width parameter is nil.
(gui_report_frame_params): Report nil as child frame border
width parameter if the frame value is negative.
* src/frame.h (FRAME_INTERNAL_BORDER_WIDTH): Return value of
child frame border width only if it is not negative.
* src/xfns.c (Fx_create_frame): Default child frame border to -1
when recording it in its frame slot via gui_default_parameter.
* src/nsfns.m (ns_set_child_frame_border_width): Handle nil ARG.
(Fx_create_frame): Default child frame border width parameter to
nil.
* src/w32fns.c (w32_set_child_frame_border_width): Handle nil ARG.
(Fx_create_frame): Default child frame border width parameter to
nil.
* src/xfns.c (x_set_child_frame_border_width): Handle nil ARG.
(Fx_create_frame): Default child frame border width parameter to
nil.
This commit is contained in:
Martin Rudalics 2021-02-06 18:22:29 +01:00
parent c0d504eb7e
commit 29e9cf291e
6 changed files with 77 additions and 54 deletions

View file

@ -1802,6 +1802,8 @@ Geometry}).
@item child-frame-border-width
The width in pixels of the frame's internal border (@pxref{Frame
Geometry}) if the given frame is a child frame (@pxref{Child Frames}).
If this is @code{nil}, the value specified by the
@code{internal-border-width} parameter is used instead.
@vindex vertical-scroll-bars@r{, a frame parameter}
@item vertical-scroll-bars

View file

@ -898,6 +898,7 @@ make_frame (bool mini_p)
f->no_accept_focus = false;
f->z_group = z_group_none;
f->tooltip = false;
f->child_frame_border_width = -1;
f->last_tab_bar_item = -1;
#ifndef HAVE_EXT_TOOL_BAR
f->last_tool_bar_item = -1;
@ -3544,10 +3545,17 @@ DEFUN ("frame-fringe-width", Ffringe_width, Sfringe_width, 0, 1, 0,
}
DEFUN ("frame-child-frame-border-width", Fframe_child_frame_border_width, Sframe_child_frame_border_width, 0, 1, 0,
doc: /* Return width of FRAME's child-frame border in pixels. */)
doc: /* Return width of FRAME's child-frame border in pixels.
If FRAME's 'child-frame-border-width' parameter is nil, return FRAME's
internal border width instead. */)
(Lisp_Object frame)
{
return make_fixnum (FRAME_CHILD_FRAME_BORDER_WIDTH (decode_any_frame (frame)));
int width = FRAME_CHILD_FRAME_BORDER_WIDTH (decode_any_frame (frame));
if (width < 0)
return make_fixnum (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame)));
else
return make_fixnum (FRAME_CHILD_FRAME_BORDER_WIDTH (decode_any_frame (frame)));
}
DEFUN ("frame-internal-border-width", Fframe_internal_border_width, Sframe_internal_border_width, 0, 1, 0,
@ -4311,7 +4319,9 @@ gui_report_frame_params (struct frame *f, Lisp_Object *alistptr)
store_in_alist (alistptr, Qborder_width,
make_fixnum (f->border_width));
store_in_alist (alistptr, Qchild_frame_border_width,
make_fixnum (FRAME_CHILD_FRAME_BORDER_WIDTH (f)));
FRAME_CHILD_FRAME_BORDER_WIDTH (f) >= 0
? make_fixnum (FRAME_CHILD_FRAME_BORDER_WIDTH (f))
: Qnil);
store_in_alist (alistptr, Qinternal_border_width,
make_fixnum (FRAME_INTERNAL_BORDER_WIDTH (f)));
store_in_alist (alistptr, Qright_divider_width,

View file

@ -1449,11 +1449,11 @@ INLINE int
FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
{
#ifdef HAVE_WINDOW_SYSTEM
return FRAME_PARENT_FRAME(f)
? (f->child_frame_border_width
? FRAME_CHILD_FRAME_BORDER_WIDTH(f)
: frame_dimension (f->internal_border_width))
: frame_dimension (f->internal_border_width);
return (FRAME_PARENT_FRAME(f)
? (FRAME_CHILD_FRAME_BORDER_WIDTH(f) >= 0
? FRAME_CHILD_FRAME_BORDER_WIDTH(f)
: frame_dimension (f->internal_border_width))
: frame_dimension (f->internal_border_width));
#else
return frame_dimension (f->internal_border_width);
#endif

View file

@ -690,17 +690,24 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
static void
ns_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
int old_width = FRAME_CHILD_FRAME_BORDER_WIDTH (f);
int new_width = check_int_nonnegative (arg);
int border;
if (new_width == old_width)
return;
f->child_frame_border_width = new_width;
if (NILP (arg))
border = -1;
else if (RANGED_FIXNUMP (0, arg, INT_MAX))
border = XFIXNAT (arg);
else
signal_error ("Invalid child frame border width", arg);
if (FRAME_NATIVE_WINDOW (f) != 0)
adjust_frame_size (f, -1, -1, 3, 0, Qchild_frame_border_width);
if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f))
{
f->child_frame_border_width = border;
SET_FRAME_GARBAGED (f);
if (FRAME_NATIVE_WINDOW (f) != 0)
adjust_frame_size (f, -1, -1, 3, 0, Qchild_frame_border_width);
SET_FRAME_GARBAGED (f);
}
}
static void
@ -1213,7 +1220,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (2),
"internalBorderWidth", "InternalBorderWidth",
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qchild_frame_border_width, make_fixnum (2),
gui_default_parameter (f, parms, Qchild_frame_border_width, Qnil,
"childFrameBorderWidth", "childFrameBorderWidth",
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),

View file

@ -1561,8 +1561,14 @@ w32_clear_under_internal_border (struct frame *f)
static void
w32_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
int argval = check_integer_range (arg, INT_MIN, INT_MAX);
int border = max (argval, 0);
int border;
if (NILP (arg))
border = -1;
else if (RANGED_FIXNUMP (0, arg, INT_MAX))
border = XFIXNAT (arg);
else
signal_error ("Invalid child frame border width", arg);
if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f))
{
@ -5896,37 +5902,33 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
Lisp_Object value;
value = gui_display_get_arg (dpyinfo, parameters, Qinternal_border_width,
"internalBorder", "InternalBorder",
"internalBorder", "internalBorder",
RES_TYPE_NUMBER);
if (! EQ (value, Qunbound))
parameters = Fcons (Fcons (Qinternal_border_width, value),
parameters);
}
gui_default_parameter (f, parameters, Qinternal_border_width, make_fixnum (0),
"internalBorderWidth", "internalBorderWidth",
RES_TYPE_NUMBER);
/* Same for child frames. */
if (NILP (Fassq (Qchild_frame_border_width, parameters)))
{
Lisp_Object value;
value = gui_display_get_arg (dpyinfo, parameters, Qchild_frame_border_width,
"childFrameBorderWidth", "childFrameBorderWidth",
"childFrameBorder", "childFrameBorder",
RES_TYPE_NUMBER);
if (! EQ (value, Qunbound))
if (!EQ (value, Qunbound))
parameters = Fcons (Fcons (Qchild_frame_border_width, value),
parameters);
}
gui_default_parameter (f, parameters, Qchild_frame_border_width,
#ifdef USE_GTK /* We used to impose 0 in xg_create_frame_widgets. */
make_fixnum (0),
#else
make_fixnum (1),
#endif
gui_default_parameter (f, parameters, Qchild_frame_border_width, Qnil,
"childFrameBorderWidth", "childFrameBorderWidth",
RES_TYPE_NUMBER);
gui_default_parameter (f, parameters, Qinternal_border_width, make_fixnum (0),
"internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER);
gui_default_parameter (f, parameters, Qright_divider_width, make_fixnum (0),
NULL, NULL, RES_TYPE_NUMBER);
gui_default_parameter (f, parameters, Qbottom_divider_width, make_fixnum (0),

View file

@ -1803,7 +1803,14 @@ x_change_tool_bar_height (struct frame *f, int height)
static void
x_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
int border = check_int_nonnegative (arg);
int border;
if (NILP (arg))
border = -1;
else if (RANGED_FIXNUMP (0, arg, INT_MAX))
border = XFIXNAT (arg);
else
signal_error ("Invalid child frame border width", arg);
if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f))
{
@ -3920,28 +3927,6 @@ This function is an internal primitive--use `make-frame' instead. */)
parms);
}
/* Same for child frames. */
if (NILP (Fassq (Qchild_frame_border_width, parms)))
{
Lisp_Object value;
value = gui_display_get_arg (dpyinfo, parms, Qchild_frame_border_width,
"childFrameBorderWidth", "childFrameBorderWidth",
RES_TYPE_NUMBER);
if (! EQ (value, Qunbound))
parms = Fcons (Fcons (Qchild_frame_border_width, value),
parms);
}
gui_default_parameter (f, parms, Qchild_frame_border_width,
#ifdef USE_GTK /* We used to impose 0 in xg_create_frame_widgets. */
make_fixnum (0),
#else
make_fixnum (1),
#endif
"childFrameBorderWidth", "childFrameBorderWidth",
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qinternal_border_width,
#ifdef USE_GTK /* We used to impose 0 in xg_create_frame_widgets. */
make_fixnum (0),
@ -3950,6 +3935,23 @@ This function is an internal primitive--use `make-frame' instead. */)
#endif
"internalBorderWidth", "internalBorderWidth",
RES_TYPE_NUMBER);
/* Same for child frames. */
if (NILP (Fassq (Qchild_frame_border_width, parms)))
{
Lisp_Object value;
value = gui_display_get_arg (dpyinfo, parms, Qchild_frame_border_width,
"childFrameBorder", "childFrameBorder",
RES_TYPE_NUMBER);
if (! EQ (value, Qunbound))
parms = Fcons (Fcons (Qchild_frame_border_width, value),
parms);
}
gui_default_parameter (f, parms, Qchild_frame_border_width, Qnil,
"childFrameBorderWidth", "childFrameBorderWidth",
RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
NULL, NULL, RES_TYPE_NUMBER);
gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),