all repos — fluxbox @ 9069ae0d80c278fcba837d50f75a49f18ea44c15

custom fork of the fluxbox windowmanager

fix up a number of things for when a window hides while moving,
including a crash bug
rathnor rathnor
commit

9069ae0d80c278fcba837d50f75a49f18ea44c15

parent

7ed9104ea85e3f7d23e0a523c71ad8dbe7c281c2

6 files changed, 66 insertions(+), 47 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,5 +1,10 @@

(Format: Year/Month/Day) Changes for 0.9.10: +*04/05/13: + * Fix a crash when a window closes while [opaque] moving (Simon) + - also tidy up several related things when a window hides + - don't call frame().hide() explicitly, use FBW.hide(bool) + Window.hh/cc Workspace.hh/cc Screen.cc *04/05/04: * Fix EventManager bug/memory leak (possibly caused crash) (Simon) EventManager.hh/cc
M src/Screen.ccsrc/Screen.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.277 2004/05/02 21:12:22 fluxgen Exp $ +// $Id: Screen.cc,v 1.278 2004/05/13 01:48:17 rathnor Exp $ #include "Screen.hh"

@@ -851,7 +851,7 @@ reassociateWindow(*it, id, true);

} } - currentWorkspace()->hideAll(); + currentWorkspace()->hideAll(false); // set new workspace m_current_workspace = getWorkspace(id);

@@ -903,7 +903,7 @@ win->deiconify();

// if the window isn't on current workspace, hide it if (id != currentWorkspace()->workspaceID()) - win->withdraw(); + win->withdraw(true); reassociateWindow(win, id, true);
M src/Window.ccsrc/Window.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.286 2004/05/03 13:45:23 rathnor Exp $ +// $Id: Window.cc,v 1.287 2004/05/13 01:48:18 rathnor Exp $ #include "Window.hh"

@@ -302,11 +302,12 @@ cerr<<__FILE__<<"("<<__LINE__<<"): curr client = "<<m_client<<endl;

cerr<<__FILE__<<"("<<__LINE__<<"): m_labelbuttons.size = "<<m_labelbuttons.size()<<endl; #endif // DEBUG - if (moving || resizing || m_attaching_tab) { - screen().hideGeometry(); - screen().hidePosition(); - ungrabPointer(CurrentTime); - } + if (moving) + stopMoving(true); + if (resizing) + stopResizing(true); + if (m_attaching_tab) + attachTo(0, 0, true); // no longer a valid window to do stuff with Fluxbox::instance()->removeWindowSearchGroup(frame().window().window());

@@ -1265,10 +1266,22 @@

return ret; } -void FluxboxWindow::hide() { +// don't hide the frame directly, use this function +void FluxboxWindow::hide(bool interrupt_moving) { #ifdef DEBUG cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl; #endif // DEBUG + // resizing always stops on hides + if (resizing) + stopResizing(true); + + if (interrupt_moving) { + if (moving) + stopMoving(true); + if (m_attaching_tab) + attachTo(0, 0, true); + } + menu().hide(); frame().hide(); }

@@ -1284,12 +1297,11 @@ void FluxboxWindow::iconify() {

if (isIconic()) // no need to iconify if we're already return; - menu().hide(); iconic = true; setState(IconicState); - frame().hide(); + hide(true); ClientList::iterator client_it = m_clientlist.begin(); const ClientList::iterator client_it_end = m_clientlist.end();

@@ -1374,15 +1386,10 @@

/** Set window in withdrawn state */ -void FluxboxWindow::withdraw() { +void FluxboxWindow::withdraw(bool interrupt_moving) { iconic = false; - if (isResizing()) - stopResizing(); - - frame().hide(); - - menu().hide(); + hide(interrupt_moving); } /**

@@ -2083,7 +2090,7 @@ iconify();

break; case WithdrawnState: - withdraw(); + withdraw(true); break; case NormalState: {

@@ -2176,7 +2183,7 @@ #ifdef DEBUG

cerr<<__FILE__<<"("<<__LINE__<<"): DestroyNotifyEvent this="<<this<<endl; #endif // DEBUG if (numClients() == 1) - frame().hide(); + hide(); } }

@@ -2847,7 +2854,7 @@ screen().showPosition(frame().x(), frame().y());

} } -void FluxboxWindow::stopMoving() { +void FluxboxWindow::stopMoving(bool interrupted) { moving = false; Fluxbox *fluxbox = Fluxbox::instance();

@@ -2859,13 +2866,15 @@ parent().drawRectangle(screen().rootTheme().opGC(),

m_last_move_x, m_last_move_y, frame().width() + 2*frame().window().borderWidth()-1, frame().height() + 2*frame().window().borderWidth()-1); - moveResize(m_last_move_x, m_last_move_y, frame().width(), frame().height()); - if (m_workspace_number != screen().currentWorkspaceID()) { - screen().reassociateWindow(this, screen().currentWorkspaceID(), true); - frame().show(); + if (!interrupted) { + moveResize(m_last_move_x, m_last_move_y, frame().width(), frame().height()); + if (m_workspace_number != screen().currentWorkspaceID()) { + screen().reassociateWindow(this, screen().currentWorkspaceID(), true); + frame().show(); + } } fluxbox->ungrab(); - } else { + } else if (!interrupted) { moveResize(frame().x(), frame().y(), frame().width(), frame().height()); sendConfigureNotify(); }

@@ -2873,7 +2882,7 @@

screen().hidePosition(); ungrabPointer(CurrentTime); - + FbTk::App::instance()->sync(false); //make sure the redraw is made before we continue }

@@ -3048,7 +3057,7 @@ m_last_resize_w - 1 + 2 * frame().window().borderWidth(),

m_last_resize_h - 1 + 2 * frame().window().borderWidth()); } -void FluxboxWindow::stopResizing(Window win) { +void FluxboxWindow::stopResizing(bool interrupted) { resizing = false; parent().drawRectangle(screen().rootTheme().opGC(),

@@ -3058,26 +3067,31 @@ m_last_resize_h - 1 + 2 * frame().window().borderWidth());

screen().hideGeometry(); - fixsize(); - - moveResize(m_last_resize_x, m_last_resize_y, + if (!interrupted) { + fixsize(); + + moveResize(m_last_resize_x, m_last_resize_y, m_last_resize_w, m_last_resize_h); + } ungrabPointer(CurrentTime); } -void FluxboxWindow::attachTo(int x, int y) { +void FluxboxWindow::attachTo(int x, int y, bool interrupted) { if (m_attaching_tab == 0) return; ungrabPointer(CurrentTime); - parent().drawRectangle(screen().rootTheme().opGC(), m_last_move_x, m_last_move_y, m_labelbuttons[m_attaching_tab]->width(), m_labelbuttons[m_attaching_tab]->height()); Fluxbox::instance()->ungrab(); + + if (interrupted) + return; + int dest_x = 0, dest_y = 0; Window child = 0;

@@ -3160,8 +3174,7 @@ #ifdef DEBUG

cerr<<__FILE__<<"("<<__FUNCTION__<<"): numClients() = "<<numClients()<<endl; #endif // DEBUG if (numClients() == 0) { - - frame().hide(); + hide(true); } }

@@ -3260,7 +3273,7 @@

screen().reassociateWindow(this, net.workspace, true); if (screen().currentWorkspaceID() != net.workspace) - withdraw(); + withdraw(true); else deiconify(); }
M src/Window.hhsrc/Window.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.113 2004/05/02 21:06:27 fluxgen Exp $ +// $Id: Window.hh,v 1.114 2004/05/13 01:48:18 rathnor Exp $ #ifndef WINDOW_HH #define WINDOW_HH

@@ -184,13 +184,14 @@ void setFocusFlag(bool flag);

// map this window void show(); // unmap this window - void hide(); + void hide() { hide(true); } + void hide(bool interrupt_moving); void iconify(); void deiconify(bool reassoc = true, bool do_raise = true); /// close current client void close(); /// set the window in withdrawn state - void withdraw(); + void withdraw(bool interrupt_moving); /// toggle maximize void maximize(int type = MAX_FULL); /// maximizes the window horizontal

@@ -384,11 +385,11 @@ void updateClientLeftWindow();

void grabButtons(); void startMoving(Window win); - void stopMoving(); + void stopMoving(bool interrupted = false); void startResizing(Window win, int x, int y); - void stopResizing(Window win=0); + void stopResizing(bool interrupted = false); /// try to attach current attaching client to a window at pos x, y - void attachTo(int x, int y); + void attachTo(int x, int y, bool interrupted = false); bool getState(); /// gets title string from client window and updates frame's title
M src/Workspace.ccsrc/Workspace.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Workspace.cc,v 1.95 2004/03/21 09:00:25 rathnor Exp $ +// $Id: Workspace.cc,v 1.96 2004/05/13 01:48:18 rathnor Exp $ #include "Workspace.hh"

@@ -218,12 +218,12 @@ (*it)->deiconify(false, false);

} -void Workspace::hideAll() { +void Workspace::hideAll(bool interrupt_moving) { Windows::reverse_iterator it = m_windowlist.rbegin(); Windows::reverse_iterator it_end = m_windowlist.rend(); for (; it != it_end; ++it) { if (! (*it)->isStuck()) - (*it)->withdraw(); + (*it)->withdraw(interrupt_moving); } }
M src/Workspace.hhsrc/Workspace.hh

@@ -57,7 +57,7 @@

/// Set workspace name void setName(const std::string &name); void showAll(); - void hideAll(); + void hideAll(bool interrupt_moving); void removeAll(); void reconfigure(); void shutdown();