From 83cbfe3acb0531c62383893fa1893d02672f8095 Mon Sep 17 00:00:00 2001 From: Waldo Bastian Date: Mon, 27 Aug 2001 23:56:15 +0000 Subject: [PATCH] Window follows mind^H^H^H^Hdesktop. svn path=/trunk/kdebase/kwin/; revision=112163 --- client.cpp | 12 ++++++------ workspace.cpp | 27 ++++++++++++++++++++++++++- workspace.h | 9 +++++++-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/client.cpp b/client.cpp index 2c26e6481d..8c5e278494 100644 --- a/client.cpp +++ b/client.cpp @@ -574,7 +574,7 @@ Client::~Client() { releaseWindow(); if (moveResizeMode) - workspace()->setFocusChangeEnabled(true); + workspace()->setClientIsMoving(0); delete info; delete d; @@ -1436,7 +1436,7 @@ void Client::mouseReleaseEvent( QMouseEvent * e) moveResizeMode = FALSE; setGeometry( geom ); Events::raise( isResize() ? Events::ResizeEnd : Events::MoveEnd ); - workspace()->setFocusChangeEnabled(true); + workspace()->setClientIsMoving(0); releaseMouse(); releaseKeyboard(); } @@ -1485,7 +1485,7 @@ void Client::mouseMoveEvent( QMouseEvent * e) Events::raise( Events::UnMaximize ); info->setState( 0, NET::Max ); } - workspace()->setFocusChangeEnabled(false); + workspace()->setClientIsMoving(this); Events::raise( isResize() ? Events::ResizeStart : Events::MoveStart ); grabMouse( cursor() ); // to keep the right cursor if ( ( isMove() && options->moveMode != Options::Opaque ) @@ -2518,7 +2518,7 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo Events::raise( Events::UnMaximize ); info->setState( 0, NET::Max ); } - workspace()->setFocusChangeEnabled(false); + workspace()->setClientIsMoving(this); buttonDown = TRUE; moveOffset = mapFromGlobal( globalPos ); invertedMoveOffset = rect().bottomRight() - moveOffset; @@ -2539,7 +2539,7 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo Events::raise( Events::UnMaximize ); info->setState( 0, NET::Max ); } - workspace()->setFocusChangeEnabled(false); + workspace()->setClientIsMoving(this); buttonDown = TRUE; moveOffset = mapFromGlobal( globalPos ); int x = moveOffset.x(), y = moveOffset.y(); @@ -2673,7 +2673,7 @@ void Client::keyPressEvent( QKeyEvent * e ) XUngrabServer( qt_xdisplay() ); setGeometry( geom ); moveResizeMode = FALSE; - workspace()->setFocusChangeEnabled(true); + workspace()->setClientIsMoving(0); releaseMouse(); releaseKeyboard(); buttonDown = FALSE; diff --git a/workspace.cpp b/workspace.cpp index f760afd075..3b9b468ccb 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -100,7 +100,8 @@ public: electric_left_border(None), electric_right_border(None), electric_time_first(0), - electric_time_last(0) + electric_time_last(0), + movingClient(0) { }; ~WorkspacePrivate() {}; KStartupInfo* startup; @@ -112,6 +113,7 @@ public: WId electric_right_border; Time electric_time_first; Time electric_time_last; + Client *movingClient; }; }; @@ -1883,6 +1885,19 @@ void Workspace::cascadePlacement (Client* c, bool re_init) { cci[d].pos = QPoint( xp + delta_x, yp + delta_y ); } +/*! + Marks the client as being moved around by the user. + */ +void Workspace::setClientIsMoving( Client *c ) +{ +// assert(!c || !d->movingClient); // Catch attempts to move a second + // window while still moving the first one. + d->movingClient = c; + if (d->movingClient) + focus_change = false; + else + focus_change = true; +} /*! Cascades all clients on the current desktop @@ -2340,6 +2355,11 @@ void Workspace::setCurrentDesktop( int new_desktop ){ ObscuringWindows obs_wins; + if (d->movingClient && !d->movingClient->isSticky()) + { + d->movingClient->setDesktop(-1); // All desktops + } + for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) { if ( (*it)->isVisible() && !(*it)->isOnDesktop( new_desktop ) ) { obs_wins.create( *it ); @@ -2356,6 +2376,11 @@ void Workspace::setCurrentDesktop( int new_desktop ){ mapList += (*it); } } + + if (d->movingClient && !d->movingClient->isSticky()) + { + d->movingClient->setDesktop(new_desktop); + } } current_desktop = new_desktop; KIPC::sendMessageAll(KIPC::BackgroundChanged, current_desktop); diff --git a/workspace.h b/workspace.h index 570dea2d39..9cb3da015a 100644 --- a/workspace.h +++ b/workspace.h @@ -144,8 +144,13 @@ public: void updateColormap(); - void setFocusChangeEnabled(bool b) { focus_change = b; } - bool focusChangeEnabled() { return focus_change; } + void setFocusChangeEnabled(bool b) { focus_change = b; } // KDE 3.0: No longer used + bool focusChangeEnabled() { return focus_change; } // KDE 3.0: No longer used + + /** + * Indicates that the client c is being moved around by the user. + */ + void setClientIsMoving( Client *c ); void doPlacement( Client* c ); QPoint adjustClientPosition( Client* c, QPoint pos );