summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2021-02-06 18:22:29 +0100
committerMartin Rudalics <rudalics@gmx.at>2021-02-06 18:22:29 +0100
commit29e9cf291eb35a77ad782e56effddf2fa00ee96c (patch)
tree24af9288415937b1ef1cfef2fa40de7cb8a800ef
parentc0d504eb7e0922be9f9ec6d9b7f1a27c5fc31b33 (diff)
downloademacs-29e9cf291eb35a77ad782e56effddf2fa00ee96c.tar.gz
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.
-rw-r--r--doc/lispref/frames.texi2
-rw-r--r--src/frame.c16
-rw-r--r--src/frame.h10
-rw-r--r--src/nsfns.m25
-rw-r--r--src/w32fns.c30
-rw-r--r--src/xfns.c36
6 files changed, 71 insertions, 48 deletions
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index a15511dc9f5..f4316b753d8 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -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
diff --git a/src/frame.c b/src/frame.c
index a2167ce1e49..635fc945604 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -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,
diff --git a/src/frame.h b/src/frame.h
index 21148fe94c9..9ddcb4c6810 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -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
diff --git a/src/nsfns.m b/src/nsfns.m
index c7857eac731..5c4cc915e7c 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -690,17 +690,24 @@ ns_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
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 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
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),
diff --git a/src/w32fns.c b/src/w32fns.c
index 5704f1d3c33..86c3db64e7b 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -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),
diff --git a/src/xfns.c b/src/xfns.c
index cac41ee4856..481ee0e2255 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -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,36 +3927,31 @@ This function is an internal primitive--use `make-frame' instead. */)
parms);
}
+ gui_default_parameter (f, parms, Qinternal_border_width,
+#ifdef USE_GTK /* We used to impose 0 in xg_create_frame_widgets. */
+ make_fixnum (0),
+#else
+ make_fixnum (1),
+#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,
- "childFrameBorderWidth", "childFrameBorderWidth",
+ "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,
-#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, parms, Qchild_frame_border_width, Qnil,
"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),
-#else
- make_fixnum (1),
-#endif
- "internalBorderWidth", "internalBorderWidth",
- 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),