mina86 / auto-dim-other-buffers.el

Visually makes non-selected windows less prominent
GNU General Public License v3.0
93 stars 13 forks source link

Making fringes dim as well #27

Open titibandit opened 3 years ago

titibandit commented 3 years ago

Hey, I'm trying to get the fringes to dim as well when unfocused. Right now, using the package unmodified, I have this behavior: bad The fringes are correctly set only for the initial window that was selected (the one on the right in that case). As soon as I change window focus, fringes are messed up.

I tried to implement the good behavior by adding

(face-remap-add-relative 'fringe adob--remap-face)

to the adob--remap-face function, but to no avail. I could get it to work by cycling the fringe-mode in the abod--update function:

...
        (when (and (window-live-p adob--last-window)
                   (not (window-minibuffer-p adob--last-window)))
          (set-window-parameter adob--last-window 'adob--dim t)
          (force-window-update adob--last-window))
        (setq adob--last-window wnd)
        (unless (window-minibuffer-p adob--last-window)
          (set-window-parameter adob--last-window 'adob--dim nil)
          (force-window-update adob--last-window)
                    (fringe-mode 0)
                    (fringe-mode nil)))
...

As you can see here: good

However, cycling the fringe-mode is a little bit laggy: switching windows is not as fluid. So I wonder if there is a more efficient way of doing this? Cheers,

mina86 commented 3 years ago

My first guess is that we need to tell Emacs that fringes need to be refreshed somewhere similarly to how force-window-update is called. That’s just speculation though.

mina86 commented 3 years ago
(defun adob--force-update (object)
  (force-window-update object)
  ;; Force fringes to be updated
  (when fringe-mode
    (dolist (wnd (if (windowp object)
                     (list object)
                   (get-buffer-window-list object nil t)))
      (let* ((frame  (window-frame wnd))
             (params (frame-parameters frame))
             (left   (alist-get 'left-fringe  params))
             (right  (alist-get 'right-fringe params)))
        (when (and left right)
          (modify-frame-parameters
           frame '((left-fringe nil) (right-fringe nil)))
          (modify-frame-parameters
           frame `((left-fringe . ,left) (right-fringe . ,right))))))))

with all calls to force-window-update replaced by calls to adob--force-update seems to be doing the trick. It is rather inelegant function though and definitely not what we should be doing.

titibandit commented 3 years ago

I've recently tried some more to look into this issue, but I really don't see a better solution as what we mentioned already. I don't see a more lightweight way to selectively change the background's color of a fringe. I'll settle for the time being with deactivating the fringes on my setup.