]> git.eshelyaron.com Git - emacs.git/commitdiff
Permit zero value for 'child-frame-border-width' parameter (Bug#46184)
authorMartin Rudalics <rudalics@gmx.at>
Sat, 6 Feb 2021 17:22:29 +0000 (18:22 +0100)
committerMartin Rudalics <rudalics@gmx.at>
Sat, 6 Feb 2021 17:22:29 +0000 (18:22 +0100)
* 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.

doc/lispref/frames.texi
src/frame.c
src/frame.h
src/nsfns.m
src/w32fns.c
src/xfns.c

index a15511dc9f5a3958d5a2872107e3f2830930a38e..f4316b753d833412a28e7c4560967555456e9ba8 100644 (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
index a2167ce1e4955aab60e07fff7516849a999a39d4..635fc94560492f1b4743682b99dba9455a31aa2b 100644 (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,
index 21148fe94c9dc4f5160399c6e76636c1e3b83696..9ddcb4c6810b64e6083b12f3e7ae88f33cd0ce0d 100644 (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
index c7857eac731b1e100e9bb5c2a3268d8ed9e38564..5c4cc915e7c410f960826a8acfb05d3e859bd47b 100644 (file)
@@ -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),
index 5704f1d3c33954d940cad95a80cfc0479e890ff0..86c3db64e7b1da5186a06a30466464007bfcf7e2 100644 (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),
index cac41ee4856128ee42454dbb101edd8ebc300bf0..481ee0e2255a694bba268325f744f8bb24c9c444 100644 (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,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),