milkypostman / powerline

emacs powerline

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swutching frames with window manager does not update modeline

paulbdavis opened this issue · comments

If I have multiple frames open, and switch to another frame with the window manager as opposed to using C-x 5 o powerline does some weird things

  1. If the frame being switched from has the active modeline already, the new from does not get the active modeline, even though the buffer is active. The previos frame still has the active modeline
  2. Switch back, with the from frame having an inactive line, and the to frame having the active line, they now reverse, and the from frame gets the active mode line and the to frame goes inactive

it seems like the hook that watches for window changes is not being
triggered when switching via the wm.

i'm not sure what other hook we would need.

On Fri, Sep 25, 2015 at 3:09 PM, Paul Davis notifications@github.com
wrote:

If I have multiple frames open, and switch to another frame with the
window manager as opposed to using C-x 5 o powerline does some weird
things

If the frame being switched from has the active modeline already, the
new from does not get the active modeline, even though the buffer is
active. The previos frame still has the active modeline
2.

Switch back, with the from frame having an inactive line, and the to
frame having the active line, they now reverse, and the from frame gets the
active mode line and the to frame goes inactive


Reply to this email directly or view it on GitHub
#104.

I have noticed that bug from early days of using powerline and I do some discovering. But I don't know how to fix it, due to lack of elisp, emacs and powerline internals knowledge.

Actually, hooks works correctly, but the function (frame-selected-window) returns the wrong window for some reason. Correct my if I wrong, but powerline package have one function that selects active window by calling (frame-selected-window) and then, this function called as a handler of hooks (frame-in-hook), (frame-out-hook) and (window-configuration-change-hook).

When user change focus to the different frame, the (frame-selected-window) return the previously selected window causing such behaviour: http://i.imgur.com/ke3t4Gc.gif. When user change focus to the another window the (frame-selected-window) return the same window and not nil. But, if you call (frame-selected-window) some time ago (I just call it in scratch buffer after changing focus) you got right the window.

May be it is some bug in X or emacs or powerline, but I also tried powerline + emacs in xmonad, fluxbox, i3 and awesome wms and all this in different environments (debian, gentoo and ubuntu) and faced with that bug again and again, so I suppose that bug not in wm, and it is just some kind of emacs bug, or some misunderstanding of how to handling focus in powerline.

I've tried ask this question in emacs mail lists but i've got no answer (find the link below). May be my terrible language is the reason or that was the wrong mail list, I don't know. But I have some suggestions how to fix it if it is bug of powerline. The first is to wait some time (i thought ~0.25s should be enough) and only after that time call the function of selecting active widnow. It's really spiky solution but the easiest one.

The second is to set (powerline-selected-window) on focus-out-hook (and all windows and frames become gray). Then, in focus-in-hook set (powerline-selected-window) to the current frame, but not by calling (frame-selected-window). The focus-in-hook is called in frame that have gained focus, so it may helps. And in (window-configuration-change-hook) call the same code that called now in all three hooks.

I don't know how to implement the first way, so I don't even tried this one (and I really don't like it because it's not a real solution). I've tried focus-out-hook from second suggestion and it works ok. But how to check the selected frame without (frame-selected-window) I don't know, and without this all works really weird. So here I stopped and just return t for all windows that asks what window is active. Looks weird too but not so annoying.

Here some links:
syl20bnr/spacemacs#2545
https://lists.gnu.org/archive/html/help-gnu-emacs/2015-09/msg00300.html

I hope this information will helps you to fix that annoying bug.
Thanks!

The pull request seems to have made some nice improvements, but I was still having issues where the mode line doesn't update when I switch back to the Emacs app. I added a call to force-mode-line-update in the body of powerline-set-selected-window, and that seems to fix things for me.

I would suggest you to customize this behaviour and make a pull request. And may be it's a good idea to use your behaviour by default since there are problems with the current implementation. The old one (before fix window focus detection patch) is completely the same as yours.