From f503c6cbb0da3fff30ebeb151fe23a4b87a48f40 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 19 Feb 2006 07:38:02 +0000 Subject: added safety counter for the loops in nextFocus --- src/FocusControl.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/FocusControl.cc b/src/FocusControl.cc index 6e98fc4..f0d19d2 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -1,4 +1,4 @@ -// FocusControl.hh +// FocusControl.cc // Copyright (c) 2006 Fluxbox Team (fluxgen at fluxbox dot org) // // Permission is hereby granted, free of charge, to any person obtaining a @@ -252,7 +252,7 @@ void FocusControl::nextFocus(int opts) { if (!(opts & CYCLELINEAR)) { if (!m_cycling_focus) { - m_cycling_focus = True; + m_cycling_focus = true; m_cycling_window = m_focused_list.begin(); m_cycling_last = 0; } else { @@ -263,11 +263,14 @@ void FocusControl::nextFocus(int opts) { // that is on the same workspace FocusedWindows::iterator it = m_cycling_window; const FocusedWindows::iterator it_end = m_focused_list.end(); - + int safety_counter = 0; while (true) { ++it; if (it == it_end) { it = m_focused_list.begin(); + safety_counter++; + if (safety_counter > 3) + break; } // give up [do nothing] if we reach the current focused again if ((*it) == (*m_cycling_window)) { @@ -323,10 +326,15 @@ void FocusControl::nextFocus(int opts) { continue; } + int safety_counter = 0; do { ++it; - if (it == wins.end()) + if (it == wins.end()) { it = wins.begin(); + safety_counter++; + if (safety_counter > 3) + break; + } // see if the window should be skipped if (! (doSkipWindow((*it)->winClient(), opts) || !(*it)->setInputFocus()) ) break; -- cgit v0.11.2