From 403a9727ce6071bfc2812c9b2141dc3ef475c007 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 11 May 2003 15:24:09 +0000 Subject: fixed focus last crash bug, a dangling m_focused_window pointer --- src/fluxbox.cc | 61 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 64be2e8..b7727e8 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -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.135 2003/05/11 13:36:12 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.136 2003/05/11 15:24:09 fluxgen Exp $ #include "fluxbox.hh" @@ -357,11 +357,13 @@ static Window last_bad_window = None; static int handleXErrors(Display *d, XErrorEvent *e) { #ifdef DEBUG + char errtxt[128]; - + XGetErrorText(d, e->error_code, errtxt, 128); - cerr<<"Fluxbox: X Error: "<error_code<<") opcodes "<< - e->request_code<<"/"<minor_code<<" resource 0x"<resourceid<error_code<<") opcodes "<< + (int)e->request_code<<"/"<<(int)e->minor_code<<" resource 0x"<resourceid<error_code == BadWindow) @@ -748,6 +750,7 @@ void Fluxbox::handleEvent(XEvent * const e) { win = scr->createWindow(e->xmaprequest.window); else cerr<<"Fluxbox Warning! Could not find screen to map window on!"<screen()); + revertFocus(win->screen()); // finaly destroy window if empty if (win->numClients() == 0) { - delete win; win = 0; } @@ -1557,7 +1559,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) { BScreen &scr = win.screen(); scr.removeWindow(&win); if (m_focused_window == &win) - revertFocus(&scr); + revertFocus(scr); } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal for (size_t i=0; idisplay(), - tempscr->rootWindow().window(), &root, &ignorew, &ignored, - &ignored, &ignored, &ignored, (unsigned int *)&ignored); - screen = searchScreen(root); - if (screen == 0) { -#ifdef DEBUG - cerr<<"No screen to base focus revert on!"<display(), - PointerRoot, None, CurrentTime); - return; - } - } - - WinClient *next_focus = screen->getLastFocusedWindow(screen->getCurrentWorkspaceID()); + WinClient *next_focus = screen.getLastFocusedWindow(screen.getCurrentWorkspaceID()); if (next_focus && next_focus->fbwindow()) { - next_focus->fbwindow()->setInputFocus(); + setFocusedWindow(next_focus->fbwindow()); } else { - switch (screen->getFocusModel()) { + setFocusedWindow(0); // so we don't get dangling m_focused_window pointer + switch (screen.getFocusModel()) { case SLOPPYFOCUS: case SEMISLOPPYFOCUS: XSetInputFocus(FbTk::App::instance()->display(), @@ -2402,7 +2395,7 @@ void Fluxbox::revertFocus(BScreen *screen) { break; case CLICKTOFOCUS: XSetInputFocus(FbTk::App::instance()->display(), - screen->rootWindow().window(), + screen.rootWindow().window(), RevertToPointerRoot, CurrentTime); break; } -- cgit v0.11.2