From f4d1af12083863f1aa63c88e3eb55a9317758fc1 Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 20 Jul 2006 03:25:28 +0000 Subject: keep tabs in same order on restart (except some extremely unlikely cases) --- src/Screen.cc | 26 ++++++++++++-------------- src/Screen.hh | 4 ++-- src/WinClient.cc | 2 ++ src/Window.cc | 4 ++++ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 73af5e9..a8f02c2 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1343,7 +1343,8 @@ FluxboxWindow *BScreen::createWindow(Window client) { // check if it should be grouped with something else FluxboxWindow *win; - if ((win = findGroupLeft(*winclient)) != 0) { + WinClient *other; + if ((other = findGroupLeft(*winclient)) && (win = other->fbwindow())) { win->attachClient(*winclient); Fluxbox::instance()->attachSignals(*winclient); } else { @@ -1369,11 +1370,10 @@ FluxboxWindow *BScreen::createWindow(Window client) { // we also need to check if another window expects this window to the left // and if so, then join it. - FluxboxWindow *otherwin = 0; - // TODO: does this do the right stuff focus-wise? - if ((otherwin = findGroupRight(*winclient)) && otherwin != win) { - win->attachClient(otherwin->winClient()); - } + if ((other = findGroupRight(*winclient)) && other->fbwindow() != win) + win->attachClient(*other); + else if (other) + win->moveClientRightOf(*other, *winclient); m_clientlist_sig.notify(); @@ -2034,10 +2034,10 @@ void BScreen::updateSize() { /** - * Find the group of windows to this window's left + * Find the winclient to this window's left * So, we check the leftgroup hint, and see if we know any windows */ -FluxboxWindow *BScreen::findGroupLeft(WinClient &winclient) { +WinClient *BScreen::findGroupLeft(WinClient &winclient) { Window w = winclient.getGroupLeftWindow(); if (w == None) return 0; @@ -2051,13 +2051,10 @@ FluxboxWindow *BScreen::findGroupLeft(WinClient &winclient) { // something is not consistent return 0; - if (have_client) - return have_client->fbwindow(); - else - return 0; + return have_client; } -FluxboxWindow *BScreen::findGroupRight(WinClient &winclient) { +WinClient *BScreen::findGroupRight(WinClient &winclient) { Groupables::iterator it = m_expecting_groups.find(winclient.window()); if (it == m_expecting_groups.end()) return 0; @@ -2073,8 +2070,9 @@ FluxboxWindow *BScreen::findGroupRight(WinClient &winclient) { other->getGroupLeftWindow() != None) return 0; - return other->fbwindow(); + return other; } + void BScreen::initXinerama() { #ifdef XINERAMA Display *display = FbTk::App::instance()->display(); diff --git a/src/Screen.hh b/src/Screen.hh index 0a96df2..0a1eaf8 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -327,8 +327,8 @@ public: // grouping - we want ordering, so we can either search for a // group to the left, or to the right (they'll be different if // they exist). - FluxboxWindow *findGroupLeft(WinClient &winclient); - FluxboxWindow *findGroupRight(WinClient &winclient); + WinClient *findGroupLeft(WinClient &winclient); + WinClient *findGroupRight(WinClient &winclient); // notify netizens void updateNetizenCurrentWorkspace(); diff --git a/src/WinClient.cc b/src/WinClient.cc index 1ede4d8..4e508fb 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -623,6 +623,8 @@ Window WinClient::getGroupLeftWindow() const { void WinClient::setGroupLeftWindow(Window win) { + if (m_screen.isShuttingdown()) + return; Atom group_left_hint = XInternAtom(display(), "_FLUXBOX_GROUP_LEFT", False); changeProperty(group_left_hint, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &win, 1); diff --git a/src/Window.cc b/src/Window.cc index f9581ed..2bb19a2 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -628,6 +628,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { WinClient *was_focused = 0; WinClient *focused_win = FocusControl::focusedWindow(); + WinClient *other = m_screen.findGroupLeft(client); // get the current window on the end of our client list Window leftwin = None; if (!clientList().empty()) @@ -691,6 +692,9 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { client.saveBlackboxAttribs(m_blackbox_attrib); m_clientlist.push_back(&client); + + if (other && other->fbwindow() == this) + moveClientRightOf(client, *other); } // make sure that the state etc etc is updated for the new client -- cgit v0.11.2