Skip to content
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

mouse clicks select a window but don't autodim others #12

Closed
djstauffer opened this issue Feb 24, 2017 · 3 comments
Closed

mouse clicks select a window but don't autodim others #12

djstauffer opened this issue Feb 24, 2017 · 3 comments

Comments

@djstauffer
Copy link

I noticed that when I click on a window with the mouse in emacs (when auto-dim-other-buffers is turned on), that the window gets focus, but the other buffers are not set to the auto-dimmed face (they still have the normal face that they do when they have focus).

I almost never use the mouse in emacs, but sometimes I do click on the emacs window to give it focus when returning from using another application (particularly if that app is fairly mouse-centric). So this problem was irritating to me.

I was able to correct this by putting code like the following in my init:

(defun zq/mouse-click-autodim ( &rest args ) (adob--post-command-hook))

(add-function :after (symbol-function 'select-window) #'zq/mouse-click-autodim)

That works pretty well. Now there only a couple of cases I can think of when I see multiple windows all having the non-dimmed face, and that is when I click in an emacs window which is not the current window with either the 2nd or 3rd mouse buttons.

For some reason, the emacs select-window function never gets called on these mouse click events, even though the window does indeed get input focus.

I suspect that there is a better or alternative function I could advise to handle this scenario also, but so far I have not found one (admittedly, I haven't tried for terribly long yet).

@djstauffer
Copy link
Author

Actually there is another scenario where the 'normal' undimmed face will appear in two windows -- and that is when two windows are displaying the same buffer.

My workaround for this is that I have custom keybindings that I use to switch to the next/previous buffer in an emacs window, and in the functions those keybindings are bound to, I skip past any buffer that is already being displayed in a window.

I can still display the same buffer in two windows using C-x b or C-x C-b, and in that case I will see both windows having the non-dimmed face, but I just hardly ever do that.

@mina86
Copy link
Owner

mina86 commented Feb 27, 2017

There is a reason this is called ‘auto-dim-other-buffers’. ;) The mechanism the library is using operates on buffers so it’s unable to dim individual windows. Emacs sadly does not provide a way to dim a window.

For the first issue, I think using ‘buffer-list-update-hook’ instead of ‘post-command-hook’ might be a solution. I’ll test it for several days and push the change if it works.

@djstauffer
Copy link
Author

"Emacs sadly does not provide a way to dim a window".

^^ Yeah, stock emacs does not. I've tried a number of different things in an attempt to work around this.

For a long time I used the bgex patch to allow me to define a per-window custom background image, and I modified it to use a different background depending on whether the window was the "current window".

That worked OK, but the problem is, with my current setup the flicker in emacs was very hard on the eyes, since it was redrawing the display every time I switched windows. I also frequently use emacs under VNC on a different computer, and the flickering is even more noticeable there I think. I believe the bgex patch made this worse, but even without it it was noticeable.

So to fix the flicker, I compiled and set up Daniel Colascione's "buttery smooth emacs" patch, which implements double buffering to reduce flicker (https://www.facebook.com/notes/daniel-colascione/buttery-smooth-emacs/10155313440066102/ ), and that made a huge difference. Actually, that is the reason I found auto-dim-other-buffers in the first place. I considered trying to port the bgex patch to the version of emacs with Daniel's patch applied, but with the little knowledge of emacs' display code that I have, I suspected I'd have difficulty successfully combining the two patches. The bgex patch is fairly involved, and Daniel's patch is considerably more extensive (and it is on a development branch as well -- the version shows emacs 26-something).

So I looked for other solutions to change the background of non-current windows, and thus I found auto-dim-other-buffers.

I'll keep an eye on this issue and if you do make a change I'll try to test it out once you've pushed it.

Thanks for looking into it.

@mina86 mina86 closed this as completed in cedb4c4 Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants