Commit ad25316b authored by Martin Rudalics's avatar Martin Rudalics

Prevent introducing invalid scroll bar width/height values (Bug#34569)

* src/frame.c (store_frame_param): Don't store invalid values
for scroll_bar_width/height.
(x_report_frame_params): Don't report invalid values for
scroll_bar_width/height.
(x_set_scroll_bar_width, x_set_scroll_bar_height): Don't set
invalid values for scroll_bar_width/height.
parent a810a75a
Pipeline #912 failed with stage
in 51 minutes and 55 seconds
...@@ -2973,6 +2973,13 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) ...@@ -2973,6 +2973,13 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
fset_buried_buffer_list (f, Fnreverse (list)); fset_buried_buffer_list (f, Fnreverse (list));
return; return;
} }
else if ((EQ (prop, Qscroll_bar_width) || EQ (prop, Qscroll_bar_height))
&& !NILP (val) && !RANGED_FIXNUMP (1, val, INT_MAX))
{
Lisp_Object old_val = Fcdr (Fassq (prop, f->param_alist));
val = old_val;
}
/* The tty color needed to be set before the frame's parameter /* The tty color needed to be set before the frame's parameter
alist was updated with the new value. This is not true any more, alist was updated with the new value. This is not true any more,
...@@ -4117,18 +4124,14 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) ...@@ -4117,18 +4124,14 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
store_in_alist (alistptr, Qright_fringe, store_in_alist (alistptr, Qright_fringe,
make_fixnum (FRAME_RIGHT_FRINGE_WIDTH (f))); make_fixnum (FRAME_RIGHT_FRINGE_WIDTH (f)));
store_in_alist (alistptr, Qscroll_bar_width, store_in_alist (alistptr, Qscroll_bar_width,
(! FRAME_HAS_VERTICAL_SCROLL_BARS (f) (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
? make_fixnum (0)
: FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
? make_fixnum (FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
/* nil means "use default width" /* nil means "use default width"
for non-toolkit scroll bar. for non-toolkit scroll bar.
ruler-mode.el depends on this. */ ruler-mode.el depends on this. */
: Qnil)); : Qnil));
store_in_alist (alistptr, Qscroll_bar_height, store_in_alist (alistptr, Qscroll_bar_height,
(! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0
? make_fixnum (0)
: FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0
? make_fixnum (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f)) ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
/* nil means "use default height" /* nil means "use default height"
for non-toolkit scroll bar. */ for non-toolkit scroll bar. */
...@@ -4598,20 +4601,20 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) ...@@ -4598,20 +4601,20 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{ {
int unit = FRAME_COLUMN_WIDTH (f); int unit = FRAME_COLUMN_WIDTH (f);
if (NILP (arg)) if (RANGED_FIXNUMP (1, arg, INT_MAX)
&& XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
{ {
x_set_scroll_bar_default_width (f); FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg);
FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit;
if (FRAME_X_WINDOW (f)) if (FRAME_X_WINDOW (f))
adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
SET_FRAME_GARBAGED (f); SET_FRAME_GARBAGED (f);
} }
else if (RANGED_FIXNUMP (1, arg, INT_MAX) else
&& XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
{ {
FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg); x_set_scroll_bar_default_width (f);
FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit;
if (FRAME_X_WINDOW (f)) if (FRAME_X_WINDOW (f))
adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width); adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
...@@ -4628,20 +4631,20 @@ x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval) ...@@ -4628,20 +4631,20 @@ x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
#if USE_HORIZONTAL_SCROLL_BARS #if USE_HORIZONTAL_SCROLL_BARS
int unit = FRAME_LINE_HEIGHT (f); int unit = FRAME_LINE_HEIGHT (f);
if (NILP (arg)) if (RANGED_FIXNUMP (1, arg, INT_MAX)
&& XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
{ {
x_set_scroll_bar_default_height (f); FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg);
FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit;
if (FRAME_X_WINDOW (f)) if (FRAME_X_WINDOW (f))
adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height); adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
SET_FRAME_GARBAGED (f); SET_FRAME_GARBAGED (f);
} }
else if (RANGED_FIXNUMP (1, arg, INT_MAX) else
&& XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
{ {
FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg); x_set_scroll_bar_default_height (f);
FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit;
if (FRAME_X_WINDOW (f)) if (FRAME_X_WINDOW (f))
adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height); adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment