From 40d026ff99bab25b7aa52e8e6c413277eb27006b Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 29 Apr 2005 02:49:24 +0000 Subject: transient window fix --- src/Window.cc | 93 ++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 36 deletions(-) diff --git a/src/Window.cc b/src/Window.cc index f72075a..e899300 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -163,11 +163,12 @@ WinClient *getRootTransientFor(WinClient *client) { /// raise window and do the same for each transient of the current window void raiseFluxboxWindow(FluxboxWindow &win) { - if (win.oplock) return; + if (win.oplock) + return; + win.oplock = true; -#ifdef DEBUG - cerr<<"raiseFluxboxWindow("<fbwindow()); } + win.oplock = false; + if (!win.winClient().transientList().empty()) win.screen().layerManager().unlock(); -#ifdef DEBUG - cerr<<"window("<setCurrentClient(m_client); + if (m_client.fbwindow() != 0) + m_client.fbwindow()->setCurrentClient(m_client); } private: WinClient &m_client; @@ -386,7 +391,7 @@ void FluxboxWindow::init() { m_old_pos_x = 0; assert(m_client); - m_client->m_win = this; + m_client->setFluxboxWindow(this); m_client->setGroupLeftWindow(None); // nothing to the left. // check for shape extension and whether the window is shaped @@ -492,6 +497,8 @@ void FluxboxWindow::init() { return; } + + Fluxbox::instance()->saveWindowSearchGroup(frame().window().window(), this); /**************************************************/ @@ -516,7 +523,6 @@ void FluxboxWindow::init() { decorations.tab = false; //no tab for this window } - associateClientWindow(true, wattrib.x, wattrib.y, wattrib.width, wattrib.height); @@ -525,6 +531,8 @@ void FluxboxWindow::init() { // this window is managed, we are now allowed to modify actual state m_initialized = true; + + applyDecorations(true); grabButtons(); @@ -560,6 +568,8 @@ void FluxboxWindow::init() { if (wattrib.height <= 0) wattrib.height = 1; + + // if we're a transient then we should be on the same layer as our parent if (m_client->isTransient() && m_client->transientFor()->fbwindow() && @@ -576,12 +586,16 @@ void FluxboxWindow::init() { } #endif // DEBUG + if (!place_window) moveResize(frame().x(), frame().y(), frame().width(), frame().height()); + + screen().getWorkspace(m_workspace_number)->addWindow(*this, place_window); setWorkspace(m_workspace_number); + if (shaded) { // start shaded shaded = false; shade(); @@ -633,7 +647,7 @@ void FluxboxWindow::shape() { /// attach a client to this window and destroy old window void FluxboxWindow::attachClient(WinClient &client, int x, int y) { //!! TODO: check for isGroupable in client - if (client.m_win == this) + if (client.fbwindow() == this) return; menu().hide(); @@ -678,7 +692,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { frame().clientArea().width(), frame().clientArea().height()); - (*client_it)->m_win = this; + (*client_it)->setFluxboxWindow(this); // create a labelbutton for this client and // associate it with the pointer FbTk::TextButton *btn = new FbTk::TextButton(frame().label(), @@ -736,7 +750,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { if (&client == focused_win) was_focused = focused_win; - client.m_win = this; + client.setFluxboxWindow(this); client.saveBlackboxAttribs(m_blackbox_attrib); m_clientlist.push_back(&client); @@ -764,7 +778,7 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) { /// detach client from window and create a new window for it bool FluxboxWindow::detachClient(WinClient &client) { - if (client.m_win != this || numClients() <= 1) + if (client.fbwindow() != this || numClients() <= 1) return false; // I'm not sure how to do this bit better @@ -811,7 +825,7 @@ bool FluxboxWindow::detachClient(WinClient &client) { // m_client must be valid as there should be at least one other window // otherwise this wouldn't be here (refer numClients() <= 1 return) - client.m_win = screen().createWindow(client); + client.setFluxboxWindow(screen().createWindow(client)); m_client->raise(); setInputFocus(); return true; @@ -826,7 +840,7 @@ void FluxboxWindow::detachCurrentClient() { /// removes client from client list, does not create new fluxboxwindow for it bool FluxboxWindow::removeClient(WinClient &client) { - if (client.m_win != this || numClients() == 0) + if (client.fbwindow() != this || numClients() == 0) return false; #ifdef DEBUG @@ -1111,7 +1125,7 @@ void FluxboxWindow::updateClientLeftWindow() { bool FluxboxWindow::setCurrentClient(WinClient &client, bool setinput) { // make sure it's in our list - if (client.m_win != this) + if (client.fbwindow() != this) return false; m_client = &client; @@ -1870,7 +1884,7 @@ void FluxboxWindow::raise() { if (isIconic()) deiconify(); #ifdef DEBUG - cerr<<"FluxboxWindow("<transientFor() && m_client != m_client->transientFor()->transientList().back()) { + // remove and push back so this window gets raised last + m_client->transientFor()->transientList().remove(m_client); + m_client->transientFor()->transientList().push_back(m_client); + } + // raise this window and every transient in it with this one last if (client->fbwindow()) raiseFluxboxWindow(*client->fbwindow()); + } void FluxboxWindow::lower() { @@ -2178,13 +2199,11 @@ bool FluxboxWindow::getState() { bool ret = false; int foo; unsigned long *state, ulfoo, nitems; - if ((XGetWindowProperty(display, m_client->window(), FbAtoms::instance()->getWMStateAtom(), - 0l, 2l, false, FbAtoms::instance()->getWMStateAtom(), - &atom_return, &foo, &nitems, &ulfoo, - (unsigned char **) &state) != Success) || - (! state)) { + if (!m_client->property(FbAtoms::instance()->getWMStateAtom(), + 0l, 2l, false, FbAtoms::instance()->getWMStateAtom(), + &atom_return, &foo, &nitems, &ulfoo, + (unsigned char **) &state) || !state) return false; - } if (nitems >= 1) { m_current_state = static_cast(state[0]); @@ -2342,15 +2361,17 @@ void FluxboxWindow::handleEvent(XEvent &event) { // mapRequestEvent(event.xmaprequest); //break; case PropertyNotify: { + #ifdef DEBUG char *atomname = XGetAtomName(display, event.xproperty.atom); cerr<<"PropertyNotify("<