You are not logged in.

#1 2015-04-26 00:38:00

feklee
Member
Registered: 2015-04-03
Posts: 52
Website

How to customize scrollbar in Emacs?

Emacs is linked against GTK+ 3:

$ ldd /usr/bin/emacs|grep -i gtk
        libgtk-3.so.0 => /usr/lib/libgtk-3.so.0 (0x00007f549812d000)

The scrollbar for GTK+ 3 applications I modified successfully by specifying in ~/.config/gtk-3.0/gtk.css:

.scrollbar {
    -GtkScrollbar-has-backward-stepper: 1;
    -GtkScrollbar-has-forward-stepper: 1;
    -GtkRange-slider-width: 15;
    -GtkRange-stepper-size: 20;
}

However, for Emacs that has no effect. On a HiDPI screen, its scrollbar is barely visible, and I don't see the up/down arrow buttons. (I'm actually testing via VNC which further decreases visibility.)

Last edited by feklee (2015-04-26 00:38:54)

Offline

#2 2015-04-26 04:22:10

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Offline

#3 2015-04-26 09:04:02

feklee
Member
Registered: 2015-04-03
Posts: 52
Website

Re: How to customize scrollbar in Emacs?

Thing is that on Arch, Emacs is compiled against GTK+, and adjusting scroll bar appearance most likely cannot be done from within Emacs. I tried changing the scroll-bar face, but - no surprise - that has no effect.

Anyhow, I think I ran into an Emacs bug. As it is a HiDPI screen, I specified:

export GDK_SCALE=2
export GDK_DPI_SCALE=0.5

Without these, the scroll bar renders fine, and it can be adjusted using the .scrollbar class in ~/.config/gtk-3.0/gtk.css.

I wonder what could be a workaround.

Offline

#4 2015-04-26 11:26:30

feklee
Member
Registered: 2015-04-03
Posts: 52
Website

Re: How to customize scrollbar in Emacs?

One workaround is to disable GDK scaling with Emacs, and scale only the scroll bar, manually:

  • Create ~/.emacs.d/config/gtk-3.0/gtk.css:

    .scrollbar {
        -GtkScrollbar-has-backward-stepper: 1;
        -GtkScrollbar-has-forward-stepper: 1;
        -GtkRange-slider-width: 30;
        -GtkRange-stepper-size: 40;
    }
  • Start Emacs with a custom environment:

    XDG_CONFIG_HOME=.emacs.d/xdg_config_home/ GDK_SCALE=1 GDK_DPI_SCALE=1 emacs
  • To restore pixel scaling for third party applications started from within Emacs (e.g. evince for viewing dvi files), add to your ~/.emacs:

    (setenv "GDK_SCALE" "2")
    (setenv "GDK_DPI_SCALE" "0.5")
    (setenv "XDG_CONFIG_HOME" (concat (getenv "HOME") "/.config"))

The disadvantage, of course, is that other UI elements such as check boxes are not scaled. So it's either: Get well sized UI elements, or get a working scroll bar. sad I filed a bug report.

Another workaround may be to compile Emacs against another GUI toolkit, but then one doesn't get the automatic Arch updates. I'm not interested in that.

Last edited by feklee (2015-05-15 00:19:30)

Offline

#5 2015-11-02 20:06:31

feklee
Member
Registered: 2015-04-03
Posts: 52
Website

Re: How to customize scrollbar in Emacs?

feklee wrote:
XDG_CONFIG_HOME=.emacs.d/xdg_config_home/ GDK_SCALE=1 GDK_DPI_SCALE=1 emacs

Looks like the behavior of font scaling for GTK+ 3 apps has changed during a recent update. Now, with the above line, text is too small, even with a correct DPI setting, 192 in our case. To get properly scaled fonts, change the value of GDK_DPI_SCALE:

XDG_CONFIG_HOME=.emacs.d/xdg_config_home/ GDK_SCALE=1 GDK_DPI_SCALE=2 emacs

Offline

Board footer

Powered by FluxBB