fixed check on valid win and screen pointer in setFocusedWindow

This commit is contained in:
fluxgen 2002-07-13 14:04:46 +00:00
parent 1c7a33c64c
commit b831814482

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: fluxbox.cc,v 1.60 2002/05/29 06:22:31 fluxgen Exp $
// $Id: fluxbox.cc,v 1.61 2002/07/13 14:04:46 fluxgen Exp $
//Use GNU extensions
#ifndef _GNU_SOURCE
@ -2437,7 +2437,7 @@ void Fluxbox::timeout(void) {
reconfigure_wait = reread_menu_wait = false;
}
// set focused window
void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
BScreen *old_screen = 0, *screen = 0;
FluxboxWindow *old_win = 0;
@ -2457,14 +2457,21 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
}
if (win && ! win->isIconic()) {
screen = win->getScreen();
// make sure we have a valid win pointer with a valid screen
ScreenList::iterator winscreen =
std::find(screenList.begin(), screenList.end(),
win->getScreen());
if (winscreen == screenList.end())
focused_window = 0; // the window pointer wasn't valid, mark no window focused
else {
screen = *winscreen;
tbar = screen->getToolbar();
wkspc = screen->getWorkspace(win->getWorkspaceNumber());
focused_window = win;
win->setFocusFlag(True);
focused_window = win; // update focused window
win->setFocusFlag(True); // set focus flag
// select this window in workspace menu
wkspc->menu()->setItemSelected(win->getWindowNumber(), true);
}
} else
focused_window = (FluxboxWindow *) 0;