New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Survey of scrollbar colors in Motif #9933
Comments
It looks like I can make it work by also setting the XmNbackground:
At least then the color of the thumb is red. |
I haven't tried it, but perhaps it is also possible to both call XmChangeColor() and then call XtVaSetValues() to set the XmNtroughColor as well? Not sure if that would make any difference. |
True, but we also need to
otherwise the through won't honor the background color (it will get slightly altered, such as that dark grey look instead of black in one of the pictures above). Also, the initialization of the scrollbar colors is lacking
Putting it all in this patch, the result is good for all the forms I tested, as long as one gets rid of shadowThickness in a dark theme: From top to bottom:
|
> It looks like I can make it work by also setting the XmNbackground:
>
> ```
> if (gui.scroll_fg_pixel != INVALCOLOR)
> XtVaSetValues(sb->id,
> XmNforeground, gui.scroll_fg_pixel,
> //#if (XmVersion<1002)
> XmNbackground, gui.scroll_fg_pixel,
> //#endif
> NULL);
> ```
>
> At least then the color of the thumb is red.
True, but we also need to
> both call XmChangeColor() and then call XtVaSetValues() to set the
> XmNtroughColor as well
otherwise the through won't honor the background color (it will get
slightly altered, such as that dark grey look instead of black in one
of the pictures above).
OK, that matches with what I'm seeing.
Also, the initialization of the scrollbar colors is lacking `gui_get_color`, so it currently doesn't pull color definitions from the X server database. As such, we need
```
- gui.menu_fg_pixel = gui.menu_def_fg_pixel;
- gui.menu_bg_pixel = gui.menu_def_bg_pixel;
- gui.scroll_fg_pixel = gui.scroll_def_fg_pixel;
- gui.scroll_bg_pixel = gui.scroll_def_bg_pixel;
+ gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name);
+ gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name);
+ gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name);
+ gui.scroll_bg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_bg_name);
```
That is what Athena does. I would think gui.menu_def_fg_pixel has the
value from gui.rsrc_menu_fg_name. They are set in
gui_x11_create_widgets() and gui_mch_create_scrollbar().
What is missing here? The color may have been overruled by the
"Scrollbar" highlight group, after using the resources.
…--
"Marriage is a wonderful institution...
but who wants to live in an institution?"
- Groucho Marx
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Sorry, I don't quite understand what you mean. As far as I know, one can't just do
(and similarly for the scrollbar) and expect to retrieve what the user has chosen as |
> That is what Athena does. I would think gui.menu_def_fg_pixel has the
> value from gui.rsrc_menu_fg_name. They are set in
> gui_x11_create_widgets() and gui_mch_create_scrollbar().
> What is missing here? The color may have been overruled by the
> "Scrollbar" highlight group, after using the resources.
Sorry, I don't quite understand what you mean. `gui_athena.c` does
this, but `gui_motif.c` doesn't.
As far as I know, one can't just do
```
XtVaGetValues(menuBar,
XmNbackground, &gui.menu_def_bg_pixel,
XmNforeground, &gui.menu_def_fg_pixel,
NULL);
```
(and similarly for the scrollbar) and expect to retrieve what the user
has chosen as `Vim.{menu,scrollbar}{Background,Foreground}` in its X
resources file because that is not a canonical resource structure and
therefore Xt is oblivious to them. So Xt always retrieves the default,
hardcoded value instead of the user defined one. The canonical
structure would be of the kind `Vim*scrollBar.background: color` and
`Vim*menuBar.background: color`, and if you set that in your
X-resources, you won't need `gui_get_color`; but the former structure,
not the latter, is what `:h gui-resources` documents.
Using vim.scrollbarBackground only looks at the X resources. In Vim the
normal way to set colors (from .gvimrc) is:
highlight Scrollbar guibg=lightblue guifg=blue
That should have higher priority than X resources (which are not that
easy to figure out for an averge Vim user).
…--
"After a few years of marriage a man can look right at a woman
without seeing her and a woman can see right through a man
without looking at him."
- Helen Rowland
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
According to my tests, the patch does exactly that. Did you observe a different behavior? |
Steps to reproduce
Expected behaviour
As per
:h gui-resources
,So the slider and arrow should be red in both cases.
The root of the problem
Is Motif's style of giving things a 3D (?) look with fancy borders and shades. By default, sliderVisual (see XmScrollBar) takes
So, you might think, the solution is simple, just use XmFOREGROUND_COLOR instead, which yields
Might look good enough, but if you look closely, the area of the trough is of a darker blue, and things get ugly in a dark background:
One way to decrease the ugliness a bit this is by suppressing shadows by passing
-xrm 'Vim*scrollBar.shadowThickness: 0'
:Too bad, the trough is somewhat gray (not the mention the scroll arrows that became almost invisible; but I don't really like them and use the
Vim*showArrows: NONE
X-resource to make them disappear).This all you caused by
vim/src/gui_motif.c
Lines 1897 to 1903 in fb43cfc
So, the natural question is: What if we always go with XtVaSetValues (which is not deprecated)? Then we have this picture below, with the top window being the new default look of Gvim, and beneath it we have
gvim -xrm 'Vim.scrollForeground: red' -xrm 'Vim.scrollBackground: black' -xrm 'Vim*scrollBar.shadowThickness: 0'
, with a dark colorscheme.The simplest solution is to take away
scrollForeground
from Motif, but as we've seen the result is very ugly for dark themes. If we don't, then we either have to take away the Motif look from the scrollbar (by using XmFOREGROUND_COLOR and removing XmChangeColor, entirely removing its shadows, giving a sane default foreground color, etc.):or let dark theme users live with its ugliness. Unless someone can envisage a simpler solution.
By the way, this is a reason I prefer Athena with its no frills interface. The scrollbar is easily and completely customizable by the end user via X-resources.
Version of Vim
8.2.4318
Environment
OS: Gentoo
Motif: 2.3.8
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: