GNOME Bugzilla – Bug 744077
Focus lost after composer is detached
Last modified: 2015-02-10 23:07:11 UTC
To reproduce: * Reply to a conversation. The editor has keyboard focus. * Press the Detach button. In the detached composer window, nothing appears to have focus. Pressing Tab causes the To: edit box to take focus. I suspect focus was given to the Detach button which is hidden in the detached window, hiding the focus in the process -- but I'm not 100% on that. What I would prefer is the focus to remain where it was at in the inline composer.
Damn. This was working at one point.
Created attachment 296398 [details] [review] Set the focus on a composer detached using the detach button Actually, I'm no longer so sure that this used to work. I didn't read carefully enough to notice that you said this only happens with the detach button, not with the accelerator. I'm not sure we ever had it working with the detach button, for the reason you note -- once we realize that the detach button has been pressed, it's too late to figure out what used to have the focus. But I think we can get it right 99% of the time by calling the set_focus() method, which puts the focus in the To box if it's empty, or the Subject box if it's empty, or the editor. I don't know if we used to get that called when the detach button was pressed, but it isn't happening any more. I put in a check if the focused widget is visible before we try to refocus it. (Actually, we look at the widget's parent, since it's the box containing the detach button that we hide.) The alternative to this would be to keep track of where the focus used to be, but I don't know that that's worth all the extra work. I also took this opportunity to tighten up the focus code. I don't know why I had the containers returning the focused widget, but we can figure it out easily directly in the composer widget itself. If you like, I can split that out into a separate patch.
Review of attachment 296398 [details] [review]: Since this is a fairly simple patch, let's get the code tightening in this commit as well. Glad to see this was so straightforward.
Attachment 296398 [details] pushed as 9ec9913 - Set the focus on a composer detached using the detach button