From 378161e531f2ee86e4656b3154367f8d5cdb0243 Mon Sep 17 00:00:00 2001 From: Matthias Ettrich Date: Thu, 25 Nov 1999 16:38:11 +0000 Subject: [PATCH] hook for snapping functionality svn path=/trunk/kdebase/kwin/; revision=35032 --- client.cpp | 1 + workspace.cpp | 33 ++++++++++++++++++++++----------- workspace.h | 7 ++++--- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/client.cpp b/client.cpp index 71c1da9d80..bd30ac5913 100644 --- a/client.cpp +++ b/client.cpp @@ -877,6 +877,7 @@ void Client::mouseMoveEvent( QMouseEvent * e) } } else if ( isMove() && geom.topLeft() != geometry().topLeft() ) { + geom.moveTopLeft( workspace()->adjustClientPosition( this, geom.topLeft() ) ); switch ( options->moveMode ) { case Options::Opaque: move( geom.topLeft() ); diff --git a/workspace.cpp b/workspace.cpp index 398ae3dd23..44394b43ab 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -112,9 +112,9 @@ Workspace::Workspace() grabKey(XK_Tab, ControlMask); grabKey(XK_Tab, ControlMask | ShiftMask); createKeybindings(); - + init(); - + control_grab = FALSE; tab_grab = FALSE; tab_box = new TabBox( this ); @@ -806,7 +806,7 @@ void Workspace::clientHidden( Client* c ) } -QPopupMenu* Workspace::clientPopup( Client* c ) +QPopupMenu* Workspace::clientPopup( Client* c ) { popup_client = c; if ( !popup ) { @@ -861,7 +861,7 @@ void Workspace::clientPopupActivated( int id ) popup_client->iconify(); else if ( id == popupIdFullscreen ) popup_client->fullScreen(); - else if ( id == popupIdShade ) + else if ( id == popupIdShade ) popup_client->setShade( !popup_client->isShade() ); } @@ -1255,7 +1255,7 @@ void Workspace::setCurrentDesktop( int new_desktop ){ atoms->net_current_desktop, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)¤t_desktop, 1); - + // try to restore the focus on this desktop Client* c = active_client?active_client:previousClient(0); Client* stop = c; @@ -1264,7 +1264,7 @@ void Workspace::setCurrentDesktop( int new_desktop ){ if ( c == stop ) break; } - + if ( !c || !c->isVisible() ) { // there's no suitable client in the focus chain. Try to find any other client then. for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) { @@ -1452,7 +1452,7 @@ void Workspace::createKeybindings(){ keys->connectItem( "Switch to desktop 6", this, SLOT( slotSwitchDesktop6() )); keys->connectItem( "Switch to desktop 7", this, SLOT( slotSwitchDesktop7() )); keys->connectItem( "Switch to desktop 8", this, SLOT( slotSwitchDesktop8() )); - + keys->connectItem( "Pop-up window operations menu", this, SLOT( slotWindowOperations() ) ); keys->connectItem( "Window close", this, SLOT( slotWindowClose() ) ); @@ -1486,7 +1486,7 @@ void Workspace::slotSwitchDesktop8(){ void Workspace::desktopPopupAboutToShow() { - if ( !desk_popup ) + if ( !desk_popup ) return; desk_popup->clear(); desk_popup->insertItem( i18n("&All desktops"), 0 ); @@ -1516,13 +1516,13 @@ void Workspace::sendToDesktop( int desk ) popup_client->setSticky( !popup_client->isSticky() ); return; } - + if ( popup_client->isSticky() ) popup_client->setSticky( FALSE ); - + if ( popup_client->isOnDesktop( desk ) ) return; - + popup_client->setDesktop( desk ); popup_client->hide(); } @@ -1541,3 +1541,14 @@ void Workspace::slotWindowClose() return; popup_client->closeWindow(); } + + +/* + Client \a c is moved around to position \a pos. This gives the + workspace the opportunity to interveniate and to implement + snap-to-windows functionality. + */ +QPoint Workspace::adjustClientPosition( Client* c, QPoint pos ) +{ + return pos; +} diff --git a/workspace.h b/workspace.h index 3c261e09d0..4322f882f3 100644 --- a/workspace.h +++ b/workspace.h @@ -69,6 +69,7 @@ public: void requestFocus( Client* c); void doPlacement( Client* c ); + QPoint adjustClientPosition( Client* c, QPoint pos ); void raiseClient( Client* c ); void clientHidden( Client* ); @@ -91,7 +92,7 @@ public: QPopupMenu* clientPopup( Client* ); - + void setDesktopClient( Client* ); void makeFullScreen( Client* ); @@ -109,11 +110,11 @@ public slots: void slotSwitchDesktop6(); void slotSwitchDesktop7(); void slotSwitchDesktop8(); - + void slotWindowOperations(); void slotWindowClose(); - + private slots: void setDecorationStyle( int ); void desktopPopupAboutToShow();