diff options
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r-- | src/fluxbox.cc | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index dd70d6c..d32840a 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: fluxbox.cc,v 1.234 2004/03/03 12:53:06 rathnor Exp $ | 25 | // $Id: fluxbox.cc,v 1.235 2004/03/21 09:00:25 rathnor Exp $ |
26 | 26 | ||
27 | #include "fluxbox.hh" | 27 | #include "fluxbox.hh" |
28 | 28 | ||
@@ -1321,7 +1321,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) { | |||
1321 | if (win.isIconic()) { | 1321 | if (win.isIconic()) { |
1322 | Workspace *space = win.screen().getWorkspace(win.workspaceNumber()); | 1322 | Workspace *space = win.screen().getWorkspace(win.workspaceNumber()); |
1323 | if (space != 0) | 1323 | if (space != 0) |
1324 | space->removeWindow(&win); | 1324 | space->removeWindow(&win, true); |
1325 | win.screen().addIcon(&win); | 1325 | win.screen().addIcon(&win); |
1326 | } | 1326 | } |
1327 | 1327 | ||
@@ -1409,8 +1409,14 @@ void Fluxbox::update(FbTk::Subject *changedsub) { | |||
1409 | // finaly send notify signal | 1409 | // finaly send notify signal |
1410 | screen.updateNetizenWindowDel(client.window()); | 1410 | screen.updateNetizenWindowDel(client.window()); |
1411 | 1411 | ||
1412 | if (m_focused_window == &client) | 1412 | // At this point, we trust that this client is no longer in the |
1413 | revertFocus(screen); | 1413 | // client list of its frame (but it still has reference to the frame) |
1414 | // We also assume that any remaining active one is the last focused one | ||
1415 | |||
1416 | // This is where we revert focus on window close | ||
1417 | // NOWHERE ELSE!!! | ||
1418 | if (m_focused_window == &client) | ||
1419 | unfocusWindow(client); | ||
1414 | 1420 | ||
1415 | // failed to revert focus? | 1421 | // failed to revert focus? |
1416 | if (m_focused_window == &client) | 1422 | if (m_focused_window == &client) |
@@ -1992,6 +1998,54 @@ void Fluxbox::revertFocus(BScreen &screen) { | |||
1992 | } | 1998 | } |
1993 | } | 1999 | } |
1994 | 2000 | ||
2001 | /* | ||
2002 | * Like revertFocus, but specifically related to this window (transients etc) | ||
2003 | * if full_revert, we fallback to a full revertFocus if we can't find anything | ||
2004 | * local to the client. | ||
2005 | * If unfocus_frame is true, we won't focus anything in the same frame | ||
2006 | * as the client. | ||
2007 | * | ||
2008 | * So, we first prefer to choose a transient parent, then the last | ||
2009 | * client in this window, and if no luck (or unfocus_frame), then | ||
2010 | * we just use the normal revertFocus on the screen. | ||
2011 | * | ||
2012 | * assumption: client has focus | ||
2013 | */ | ||
2014 | void Fluxbox::unfocusWindow(WinClient &client, bool full_revert, bool unfocus_frame) { | ||
2015 | // go up the transient tree looking for a focusable window | ||
2016 | |||
2017 | FluxboxWindow *fbwin = client.fbwindow(); | ||
2018 | if (fbwin == 0) | ||
2019 | unfocus_frame = false; | ||
2020 | |||
2021 | WinClient *trans_parent = client.transientFor(); | ||
2022 | while (trans_parent) { | ||
2023 | if (trans_parent->fbwindow() && // can't focus if no fbwin | ||
2024 | (!unfocus_frame || trans_parent->fbwindow() != fbwin) && // can't be this window | ||
2025 | trans_parent->fbwindow()->isVisible() && | ||
2026 | trans_parent->fbwindow()->setCurrentClient(*trans_parent, m_focused_window == &client)) { | ||
2027 | return; | ||
2028 | } | ||
2029 | trans_parent = trans_parent->transientFor(); | ||
2030 | } | ||
2031 | |||
2032 | if (fbwin == 0) | ||
2033 | return; // nothing more we can do | ||
2034 | |||
2035 | BScreen &screen = fbwin->screen(); | ||
2036 | |||
2037 | if (!unfocus_frame) { | ||
2038 | WinClient *last_focus = screen.getLastFocusedWindow(*fbwin, &client); | ||
2039 | if (last_focus != 0 && | ||
2040 | fbwin->setCurrentClient(*last_focus, m_focused_window == &client)) { | ||
2041 | return; | ||
2042 | } | ||
2043 | } | ||
2044 | |||
2045 | if (full_revert && m_focused_window == &client) | ||
2046 | revertFocus(screen); | ||
2047 | |||
2048 | } | ||
1995 | 2049 | ||
1996 | 2050 | ||
1997 | void Fluxbox::watchKeyRelease(BScreen &screen, unsigned int mods) { | 2051 | void Fluxbox::watchKeyRelease(BScreen &screen, unsigned int mods) { |