Subject: bug#37359: [PATCH] Fix ignored Motif scrollbar resources.

From: Matt Bisson <[email-masked]>
Date: Mon, 9 Sep 2019 14:27:07 -0400 (EDT)

Hi Emacs maintainers,

I noticed that I was only able to set the "truck" color for scrollbars on Motif.  I tried a variety of methods, including explicitly setting resources for the scrollbar class as documented by the libXm API, and using foreground and background faces, but to no avail.  After looking at the code in src/xterm.c, I noticed that the creation code was not quite correct, so I patched the code (attached):

On Motif scrollbars, "foreground" has no meaning, while "background" means the truck and arrow colors, and "trough" means the background of the entire widget.  I have hooked up the Emacs scrollbar "foreground" color to the XmNbackground resource, and the "background" color to XmNtroughColor.  This is more in line with how Xaw scrollbars behave.

I am still a little flummoxed as to why the more sweeping resource settings like "*XmScrollBar*troughColor" seem to have no effect, but that's an issue for another day, and I may look into it further as I have time.

My Emacs environment is 26.3 (but I noticed this code has been like this a long time) running on 64-bit Linux (Gentoo).  The Motif version is 2.3.8.

Thanks,
-Matt

From 60cf87f9fc6104ae44c31125b2f5050cb31b9e4a Mon Sep 17 00:00:00 2001
From: Matt Bisson <[email-masked]>
Date: Mon, 9 Sep 2019 10:46:20 -0400
Subject: [PATCH] Fix ignored Motif scrollbar resources.

On Motif scrollbars, "foreground" has no meaning, while "background"
means the truck and arrow colors, and "trough" means the background of
the entire widget.  I have hooked up the Emacs scrollbar "foreground"
color to the XmNbackground resource, and the "background" color to
XmNtroughColor.  This is more in line with how Xaw scrollbars behave.
---
 src/xterm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 3cadf69380..70e45a964b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5925,17 +5925,19 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
   XtSetArg (av[ac], XmNincrement, 1); ++ac;
   XtSetArg (av[ac], XmNpageIncrement, 1); ++ac;
 
+  /* Note: "background" is the thumb color, and "trough" is the color behind
+     everything. */
   pixel = f->output_data.x->scroll_bar_foreground_pixel;
   if (pixel != -1)
     {
-      XtSetArg (av[ac], XmNforeground, pixel);
+      XtSetArg (av[ac], XmNbackground, pixel);
       ++ac;
     }
 
   pixel = f->output_data.x->scroll_bar_background_pixel;
   if (pixel != -1)
     {
-      XtSetArg (av[ac], XmNbackground, pixel);
+      XtSetArg (av[ac], XmNtroughColor, pixel);
       ++ac;
     }
 
-- 
2.23.0