fix up a number of things for when a window hides while moving,

including a crash bug
This commit is contained in:
rathnor 2004-05-13 01:48:18 +00:00
parent 7ed9104ea8
commit 9069ae0d80
6 changed files with 66 additions and 47 deletions

View file

@ -1,5 +1,10 @@
(Format: Year/Month/Day) (Format: Year/Month/Day)
Changes for 0.9.10: 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: *04/05/04:
* Fix EventManager bug/memory leak (possibly caused crash) (Simon) * Fix EventManager bug/memory leak (possibly caused crash) (Simon)
EventManager.hh/cc EventManager.hh/cc

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "Screen.hh"
@ -851,7 +851,7 @@ void BScreen::changeWorkspaceID(unsigned int id) {
} }
} }
currentWorkspace()->hideAll(); currentWorkspace()->hideAll(false);
// set new workspace // set new workspace
m_current_workspace = getWorkspace(id); m_current_workspace = getWorkspace(id);
@ -903,7 +903,7 @@ void BScreen::sendToWorkspace(unsigned int id, FluxboxWindow *win, bool changeWS
// if the window isn't on current workspace, hide it // if the window isn't on current workspace, hide it
if (id != currentWorkspace()->workspaceID()) if (id != currentWorkspace()->workspaceID())
win->withdraw(); win->withdraw(true);
reassociateWindow(win, id, true); reassociateWindow(win, id, true);

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "Window.hh"
@ -302,11 +302,12 @@ FluxboxWindow::~FluxboxWindow() {
cerr<<__FILE__<<"("<<__LINE__<<"): m_labelbuttons.size = "<<m_labelbuttons.size()<<endl; cerr<<__FILE__<<"("<<__LINE__<<"): m_labelbuttons.size = "<<m_labelbuttons.size()<<endl;
#endif // DEBUG #endif // DEBUG
if (moving || resizing || m_attaching_tab) { if (moving)
screen().hideGeometry(); stopMoving(true);
screen().hidePosition(); if (resizing)
ungrabPointer(CurrentTime); stopResizing(true);
} if (m_attaching_tab)
attachTo(0, 0, true);
// no longer a valid window to do stuff with // no longer a valid window to do stuff with
Fluxbox::instance()->removeWindowSearchGroup(frame().window().window()); Fluxbox::instance()->removeWindowSearchGroup(frame().window().window());
@ -1265,10 +1266,22 @@ bool FluxboxWindow::setInputFocus() {
return ret; return ret;
} }
void FluxboxWindow::hide() { // don't hide the frame directly, use this function
void FluxboxWindow::hide(bool interrupt_moving) {
#ifdef DEBUG #ifdef DEBUG
cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl; cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl;
#endif // DEBUG #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(); menu().hide();
frame().hide(); frame().hide();
} }
@ -1284,12 +1297,11 @@ void FluxboxWindow::iconify() {
if (isIconic()) // no need to iconify if we're already if (isIconic()) // no need to iconify if we're already
return; return;
menu().hide();
iconic = true; iconic = true;
setState(IconicState); setState(IconicState);
frame().hide(); hide(true);
ClientList::iterator client_it = m_clientlist.begin(); ClientList::iterator client_it = m_clientlist.begin();
const ClientList::iterator client_it_end = m_clientlist.end(); const ClientList::iterator client_it_end = m_clientlist.end();
@ -1374,15 +1386,10 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
/** /**
Set window in withdrawn state Set window in withdrawn state
*/ */
void FluxboxWindow::withdraw() { void FluxboxWindow::withdraw(bool interrupt_moving) {
iconic = false; iconic = false;
if (isResizing()) hide(interrupt_moving);
stopResizing();
frame().hide();
menu().hide();
} }
/** /**
@ -2083,7 +2090,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) {
break; break;
case WithdrawnState: case WithdrawnState:
withdraw(); withdraw(true);
break; break;
case NormalState: { case NormalState: {
@ -2176,7 +2183,7 @@ void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent &de) {
cerr<<__FILE__<<"("<<__LINE__<<"): DestroyNotifyEvent this="<<this<<endl; cerr<<__FILE__<<"("<<__LINE__<<"): DestroyNotifyEvent this="<<this<<endl;
#endif // DEBUG #endif // DEBUG
if (numClients() == 1) if (numClients() == 1)
frame().hide(); hide();
} }
} }
@ -2847,7 +2854,7 @@ void FluxboxWindow::startMoving(Window win) {
} }
} }
void FluxboxWindow::stopMoving() { void FluxboxWindow::stopMoving(bool interrupted) {
moving = false; moving = false;
Fluxbox *fluxbox = Fluxbox::instance(); Fluxbox *fluxbox = Fluxbox::instance();
@ -2859,13 +2866,15 @@ void FluxboxWindow::stopMoving() {
m_last_move_x, m_last_move_y, m_last_move_x, m_last_move_y,
frame().width() + 2*frame().window().borderWidth()-1, frame().width() + 2*frame().window().borderWidth()-1,
frame().height() + 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 (!interrupted) {
if (m_workspace_number != screen().currentWorkspaceID()) { moveResize(m_last_move_x, m_last_move_y, frame().width(), frame().height());
screen().reassociateWindow(this, screen().currentWorkspaceID(), true); if (m_workspace_number != screen().currentWorkspaceID()) {
frame().show(); screen().reassociateWindow(this, screen().currentWorkspaceID(), true);
frame().show();
}
} }
fluxbox->ungrab(); fluxbox->ungrab();
} else { } else if (!interrupted) {
moveResize(frame().x(), frame().y(), frame().width(), frame().height()); moveResize(frame().x(), frame().y(), frame().width(), frame().height());
sendConfigureNotify(); sendConfigureNotify();
} }
@ -2873,7 +2882,7 @@ void FluxboxWindow::stopMoving() {
screen().hidePosition(); screen().hidePosition();
ungrabPointer(CurrentTime); ungrabPointer(CurrentTime);
FbTk::App::instance()->sync(false); //make sure the redraw is made before we continue FbTk::App::instance()->sync(false); //make sure the redraw is made before we continue
} }
@ -3048,7 +3057,7 @@ void FluxboxWindow::startResizing(Window win, int x, int y) {
m_last_resize_h - 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; resizing = false;
parent().drawRectangle(screen().rootTheme().opGC(), parent().drawRectangle(screen().rootTheme().opGC(),
@ -3058,26 +3067,31 @@ void FluxboxWindow::stopResizing(Window win) {
screen().hideGeometry(); screen().hideGeometry();
fixsize(); if (!interrupted) {
fixsize();
moveResize(m_last_resize_x, m_last_resize_y,
moveResize(m_last_resize_x, m_last_resize_y,
m_last_resize_w, m_last_resize_h); m_last_resize_w, m_last_resize_h);
}
ungrabPointer(CurrentTime); ungrabPointer(CurrentTime);
} }
void FluxboxWindow::attachTo(int x, int y) { void FluxboxWindow::attachTo(int x, int y, bool interrupted) {
if (m_attaching_tab == 0) if (m_attaching_tab == 0)
return; return;
ungrabPointer(CurrentTime); ungrabPointer(CurrentTime);
parent().drawRectangle(screen().rootTheme().opGC(), parent().drawRectangle(screen().rootTheme().opGC(),
m_last_move_x, m_last_move_y, m_last_move_x, m_last_move_y,
m_labelbuttons[m_attaching_tab]->width(), m_labelbuttons[m_attaching_tab]->width(),
m_labelbuttons[m_attaching_tab]->height()); m_labelbuttons[m_attaching_tab]->height());
Fluxbox::instance()->ungrab(); Fluxbox::instance()->ungrab();
if (interrupted)
return;
int dest_x = 0, dest_y = 0; int dest_x = 0, dest_y = 0;
Window child = 0; Window child = 0;
@ -3160,8 +3174,7 @@ void FluxboxWindow::restore(WinClient *client, bool remap) {
cerr<<__FILE__<<"("<<__FUNCTION__<<"): numClients() = "<<numClients()<<endl; cerr<<__FILE__<<"("<<__FUNCTION__<<"): numClients() = "<<numClients()<<endl;
#endif // DEBUG #endif // DEBUG
if (numClients() == 0) { if (numClients() == 0) {
hide(true);
frame().hide();
} }
} }
@ -3260,7 +3273,7 @@ void FluxboxWindow::changeBlackboxHints(const BlackboxHints &net) {
screen().reassociateWindow(this, net.workspace, true); screen().reassociateWindow(this, net.workspace, true);
if (screen().currentWorkspaceID() != net.workspace) if (screen().currentWorkspaceID() != net.workspace)
withdraw(); withdraw(true);
else else
deiconify(); deiconify();
} }

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 #ifndef WINDOW_HH
#define WINDOW_HH #define WINDOW_HH
@ -184,13 +184,14 @@ public:
// map this window // map this window
void show(); void show();
// unmap this window // unmap this window
void hide(); void hide() { hide(true); }
void hide(bool interrupt_moving);
void iconify(); void iconify();
void deiconify(bool reassoc = true, bool do_raise = true); void deiconify(bool reassoc = true, bool do_raise = true);
/// close current client /// close current client
void close(); void close();
/// set the window in withdrawn state /// set the window in withdrawn state
void withdraw(); void withdraw(bool interrupt_moving);
/// toggle maximize /// toggle maximize
void maximize(int type = MAX_FULL); void maximize(int type = MAX_FULL);
/// maximizes the window horizontal /// maximizes the window horizontal
@ -384,11 +385,11 @@ private:
void grabButtons(); void grabButtons();
void startMoving(Window win); void startMoving(Window win);
void stopMoving(); void stopMoving(bool interrupted = false);
void startResizing(Window win, int x, int y); 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 /// 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(); bool getState();
/// gets title string from client window and updates frame's title /// gets title string from client window and updates frame's title

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "Workspace.hh"
@ -218,12 +218,12 @@ void Workspace::showAll() {
} }
void Workspace::hideAll() { void Workspace::hideAll(bool interrupt_moving) {
Windows::reverse_iterator it = m_windowlist.rbegin(); Windows::reverse_iterator it = m_windowlist.rbegin();
Windows::reverse_iterator it_end = m_windowlist.rend(); Windows::reverse_iterator it_end = m_windowlist.rend();
for (; it != it_end; ++it) { for (; it != it_end; ++it) {
if (! (*it)->isStuck()) if (! (*it)->isStuck())
(*it)->withdraw(); (*it)->withdraw(interrupt_moving);
} }
} }

View file

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