Subject: Re: bug#74435: Scrollbar width is not respected on Windows

From: martin rudalics <[email-masked]>
Date: Fri, 22 Nov 2024 11:13:24 +0100

> emacs -q
 >
 > and eval this twice:
 >
 > (set-frame-parameter nil 'scroll-bar-width 50)
 >
 >
 > The bar will change to 50 on first evaluation, and got back to default on second.

My bad.  Can you try the attached patch?

martin

diff --git a/src/frame.c b/src/frame.c
index 7f4bf274ad9..f6053fca3ef 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -5102,15 +5102,19 @@ gui_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   int unit = FRAME_COLUMN_WIDTH (f);
 
-  if (RANGED_FIXNUMP (1, arg, INT_MAX)
-      && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
+  if (RANGED_FIXNUMP (1, arg, INT_MAX))
     {
-      FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg);
-      FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit;
-      if (FRAME_NATIVE_WINDOW (f))
-	adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
+      if (XFIXNAT (arg) == FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
+	return;
+      else
+	{
+	  FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg);
+	  FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit;
+	  if (FRAME_NATIVE_WINDOW (f))
+	    adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
 
-      SET_FRAME_GARBAGED (f);
+	  SET_FRAME_GARBAGED (f);
+	}
     }
   else
     {
@@ -5133,15 +5137,19 @@ gui_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 #if USE_HORIZONTAL_SCROLL_BARS
   int unit = FRAME_LINE_HEIGHT (f);
 
-  if (RANGED_FIXNUMP (1, arg, INT_MAX)
-      && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
+  if (RANGED_FIXNUMP (1, arg, INT_MAX))
     {
-      FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg);
-      FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit;
-      if (FRAME_NATIVE_WINDOW (f))
-	adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
+      if (XFIXNAT (arg) == FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
+	return;
+      else
+	{
+	  FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg);
+	  FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit;
+	  if (FRAME_NATIVE_WINDOW (f))
+	    adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
 
-      SET_FRAME_GARBAGED (f);
+	  SET_FRAME_GARBAGED (f);
+	}
     }
   else
     {