kwin Library API Documentation

useractions.cpp

00001 /*****************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
00006 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
00007 
00008 You can Freely distribute this program under the GNU General Public
00009 License. See the file "COPYING" for the exact licensing terms.
00010 ******************************************************************/
00011 
00012 /*
00013 
00014  This file contains things relevant to direct user actions, such as
00015  responses to global keyboard shortcuts, or selecting actions
00016  from the window operations menu.
00017 
00018 */
00019 
00020 #include "client.h"
00021 #include "workspace.h"
00022 
00023 #include <qpopupmenu.h>
00024 #include <kglobalsettings.h>
00025 #include <kiconloader.h>
00026 #include <klocale.h>
00027 #include <kconfig.h>
00028 #include <kglobalaccel.h>
00029 #include <kapplication.h>
00030 
00031 #include "popupinfo.h"
00032 #include "killwindow.h"
00033 #include "tabbox.h"
00034 
00035 namespace KWinInternal
00036 {
00037 
00038 //****************************************
00039 // Workspace
00040 //****************************************
00041 
00042 QPopupMenu* Workspace::clientPopup()
00043     {
00044     if ( !popup )
00045         {
00046         popup = new QPopupMenu;
00047         popup->setCheckable( TRUE );
00048         popup->setFont(KGlobalSettings::menuFont());
00049         connect( popup, SIGNAL( aboutToShow() ), this, SLOT( clientPopupAboutToShow() ) );
00050         connect( popup, SIGNAL( activated(int) ), this, SLOT( clientPopupActivated(int) ) );
00051 
00052         advanced_popup = new QPopupMenu( popup );
00053         advanced_popup->setCheckable( TRUE );
00054         advanced_popup->setFont(KGlobalSettings::menuFont());
00055         connect( advanced_popup, SIGNAL( activated(int) ), this, SLOT( clientPopupActivated(int) ) );
00056         advanced_popup->insertItem( SmallIconSet( "up" ), i18n("Keep &Above Others"), Options::KeepAboveOp );
00057         advanced_popup->insertItem( SmallIconSet( "down" ), i18n("Keep &Below Others"), Options::KeepBelowOp );
00058         advanced_popup->insertItem( SmallIconSet( "window_fullscreen" ), i18n("&Fullscreen"), Options::FullScreenOp );
00059         advanced_popup->insertItem( i18n("&No Border"), Options::NoBorderOp );
00060         advanced_popup->insertItem( SmallIconSet( "filesave" ), i18n("Sto&re Window Settings"), Options::ToggleStoreSettingsOp );
00061 
00062         popup->insertItem(i18n("Ad&vanced"), advanced_popup );
00063         desk_popup_index = popup->count();
00064         popup->insertItem( SmallIconSet( "move" ), i18n("&Move")+'\t'+keys->shortcut("Window Move").seq(0).toString(), Options::MoveOp );
00065         popup->insertItem( i18n("Re&size")+'\t'+keys->shortcut("Window Resize").seq(0).toString(), Options::ResizeOp );
00066         popup->insertItem( i18n("Mi&nimize")+'\t'+keys->shortcut("Window Minimize").seq(0).toString(), Options::MinimizeOp );
00067         popup->insertItem( i18n("Ma&ximize")+'\t'+keys->shortcut("Window Maximize").seq(0).toString(), Options::MaximizeOp );
00068         popup->insertItem( i18n("Sh&ade")+'\t'+keys->shortcut("Window Shade").seq(0).toString(), Options::ShadeOp );
00069 
00070         popup->insertSeparator();
00071 
00072         if (!KGlobal::config()->isImmutable())
00073             {
00074             popup->insertItem(SmallIconSet( "configure" ), i18n("Configur&e Window Behavior..."), this, SLOT( configureWM() ));
00075             popup->insertSeparator();
00076             }
00077 
00078         popup->insertItem( SmallIconSet( "fileclose" ), i18n("&Close")+'\t'+keys->shortcut("Window Close").seq(0).toString(), Options::CloseOp );
00079         }
00080     return popup;
00081     }
00082 
00088 void Workspace::clientPopupAboutToShow()
00089     {
00090     if ( !popup_client || !popup )
00091         return;
00092 
00093     if ( numberOfDesktops() == 1 )
00094         {
00095         delete desk_popup;
00096         desk_popup = 0;
00097         }
00098     else
00099         {
00100         initDesktopPopup();
00101         }
00102 
00103     popup->setItemEnabled( Options::ResizeOp, popup_client->isResizable() );
00104     popup->setItemEnabled( Options::MoveOp, popup_client->isMovable() );
00105     popup->setItemEnabled( Options::MaximizeOp, popup_client->isMaximizable() );
00106     popup->setItemChecked( Options::MaximizeOp, popup_client->maximizeMode() == Client::MaximizeFull );
00107     // This should be checked also when hover unshaded
00108     popup->setItemChecked( Options::ShadeOp, popup_client->shadeMode() != Client::ShadeNone );
00109     popup->setItemEnabled( Options::ShadeOp, popup_client->isShadeable());
00110     advanced_popup->setItemChecked( Options::KeepAboveOp, popup_client->keepAbove() );
00111     advanced_popup->setItemChecked( Options::KeepBelowOp, popup_client->keepBelow() );
00112     advanced_popup->setItemChecked( Options::FullScreenOp, popup_client->isFullScreen() );
00113     advanced_popup->setItemEnabled( Options::FullScreenOp, popup_client->userCanSetFullScreen() );
00114     advanced_popup->setItemChecked( Options::NoBorderOp, popup_client->noBorder() );
00115     advanced_popup->setItemEnabled( Options::NoBorderOp, popup_client->userCanSetNoBorder() );
00116     popup->setItemEnabled( Options::MinimizeOp, popup_client->isMinimizable() );
00117     advanced_popup->setItemChecked( Options::ToggleStoreSettingsOp, popup_client->storeSettings() );
00118     popup->setItemEnabled( Options::CloseOp, popup_client->isCloseable() );
00119     }
00120 
00121 
00122 void Workspace::initDesktopPopup()
00123     {
00124     if (desk_popup)
00125         return;
00126 
00127     desk_popup = new QPopupMenu( popup );
00128     desk_popup->setCheckable( TRUE );
00129     desk_popup->setFont(KGlobalSettings::menuFont());
00130     connect( desk_popup, SIGNAL( activated(int) ),
00131              this, SLOT( sendToDesktop(int) ) );
00132     connect( desk_popup, SIGNAL( aboutToShow() ),
00133              this, SLOT( desktopPopupAboutToShow() ) );
00134 
00135     popup->insertItem(i18n("To &Desktop"), desk_popup, -1, desk_popup_index );
00136     }
00137 
00142 void Workspace::desktopPopupAboutToShow()
00143     {
00144     if ( !desk_popup )
00145         return;
00146 
00147     desk_popup->clear();
00148     desk_popup->insertItem( i18n("&All Desktops"), 0 );
00149     if ( active_client && active_client->isOnAllDesktops() )
00150         desk_popup->setItemChecked( 0, TRUE );
00151     desk_popup->insertSeparator( -1 );
00152     int id;
00153     const int BASE = 10;
00154     for ( int i = 1; i <= numberOfDesktops(); i++ ) 
00155         {
00156         QString basic_name("%1  %2");
00157         if (i<BASE)
00158             {
00159             basic_name.prepend('&');
00160             }
00161         id = desk_popup->insertItem(
00162                 basic_name
00163                     .arg(i)
00164                     .arg( desktopName(i).replace( '&', "&&" )),
00165                 i );
00166         if ( active_client &&
00167              !active_client->isOnAllDesktops() && active_client->desktop()  == i )
00168             desk_popup->setItemChecked( id, TRUE );
00169         }
00170     }
00171 
00172 
00173 
00177 void Workspace::initShortcuts()
00178     {
00179     keys = new KGlobalAccel( this );
00180 #include "kwinbindings.cpp"
00181     readShortcuts();
00182     }
00183 
00184 void Workspace::readShortcuts()
00185     {
00186     keys->readSettings();
00187 
00188     cutWalkThroughDesktops = keys->shortcut("Walk Through Desktops");
00189     cutWalkThroughDesktopsReverse = keys->shortcut("Walk Through Desktops (Reverse)");
00190     cutWalkThroughDesktopList = keys->shortcut("Walk Through Desktop List");
00191     cutWalkThroughDesktopListReverse = keys->shortcut("Walk Through Desktop List (Reverse)");
00192     cutWalkThroughWindows = keys->shortcut("Walk Through Windows");
00193     cutWalkThroughWindowsReverse = keys->shortcut("Walk Through Windows (Reverse)");
00194 
00195     keys->updateConnections();
00196     }
00197 
00198 
00199 void Workspace::clientPopupActivated( int id )
00200     {
00201     WindowOperation op = static_cast< WindowOperation >( id );
00202     Client* c = popup_client ? popup_client : active_client;
00203     QString type;
00204     switch( op )
00205         {
00206         case FullScreenOp:
00207             if( !c->isFullScreen() && c->userCanSetFullScreen())
00208                 type = "fullscreenaltf3";
00209           break;
00210         case NoBorderOp:
00211             if( !c->noBorder() && c->userCanSetNoBorder())
00212                 type = "noborderaltf3";
00213           break;
00214         default:
00215             break;
00216         };
00217     if( !type.isEmpty())
00218         helperDialog( type, c );
00219     performWindowOperation( c, op );
00220     }
00221 
00222 
00223 void Workspace::performWindowOperation( Client* c, Options::WindowOperation op ) 
00224     {
00225     if ( !c )
00226         return;
00227 
00228     if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp )
00229         QCursor::setPos( c->geometry().center() );
00230     if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp )
00231         QCursor::setPos( c->geometry().bottomRight());
00232     switch ( op ) 
00233         {
00234         case Options::MoveOp:
00235             c->performMouseCommand( Options::MouseMove, QCursor::pos() );
00236             break;
00237         case Options::UnrestrictedMoveOp:
00238             c->performMouseCommand( Options::MouseUnrestrictedMove, QCursor::pos() );
00239             break;
00240         case Options::ResizeOp:
00241             c->performMouseCommand( Options::MouseResize, QCursor::pos() );
00242             break;
00243         case Options::UnrestrictedResizeOp:
00244             c->performMouseCommand( Options::MouseUnrestrictedResize, QCursor::pos() );
00245             break;
00246         case Options::CloseOp:
00247             c->closeWindow();
00248             break;
00249         case Options::MaximizeOp:
00250             c->maximize( c->maximizeMode() == Client::MaximizeFull
00251                 ? Client::MaximizeRestore : Client::MaximizeFull );
00252             break;
00253         case Options::HMaximizeOp:
00254             c->maximize( c->maximizeMode() ^ Client::MaximizeHorizontal );
00255             break;
00256         case Options::VMaximizeOp:
00257             c->maximize( c->maximizeMode() ^ Client::MaximizeVertical );
00258             break;
00259         case Options::MinimizeOp:
00260             c->minimize();
00261             break;
00262         case Options::ShadeOp:
00263             c->toggleShade();
00264             break;
00265         case Options::OnAllDesktopsOp:
00266             c->setOnAllDesktops( !c->isOnAllDesktops() );
00267             break;
00268         case Options::FullScreenOp:
00269             c->setFullScreen( !c->isFullScreen(), true );
00270             break;
00271         case Options::NoBorderOp:
00272             c->setUserNoBorder( !c->isUserNoBorder());
00273             break;
00274         case Options::KeepAboveOp:
00275             c->setKeepAbove( !c->keepAbove() );
00276             break;
00277         case Options::KeepBelowOp:
00278             c->setKeepBelow( !c->keepBelow() );
00279             break;
00280         case Options::ToggleStoreSettingsOp:
00281             c->setStoreSettings( !c->storeSettings() );
00282             break;
00283         case Options::LowerOp:
00284             lowerClient(c);
00285             break;
00286         default:
00287             break;
00288         }
00289     }
00290 
00294 bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPos)
00295     {
00296     bool replay = FALSE;
00297     switch (command) 
00298         {
00299         case Options::MouseRaise:
00300             workspace()->raiseClient( this );
00301             break;
00302         case Options::MouseLower:
00303             workspace()->lowerClient( this );
00304             break;
00305         case Options::MouseShade :
00306             toggleShade();
00307             break;
00308         case Options::MouseOperationsMenu:
00309             if ( isActive() & options->clickRaise )
00310                 autoRaise();
00311             workspace()->showWindowMenu( globalPos, this );
00312             break;
00313         case Options::MouseToggleRaiseAndLower:
00314             workspace()->raiseOrLowerClient( this );
00315             break;
00316         case Options::MouseActivateAndRaise:
00317             replay = isActive(); // for clickraise mode
00318             workspace()->requestFocus( this );
00319             workspace()->raiseClient( this );
00320             break;
00321         case Options::MouseActivateAndLower:
00322             workspace()->requestFocus( this );
00323             workspace()->lowerClient( this );
00324             break;
00325         case Options::MouseActivate:
00326             replay = isActive(); // for clickraise mode
00327             workspace()->requestFocus( this );
00328             break;
00329         case Options::MouseActivateRaiseAndPassClick:
00330             workspace()->requestFocus( this );
00331             workspace()->raiseClient( this );
00332             replay = TRUE;
00333             break;
00334         case Options::MouseActivateAndPassClick:
00335             workspace()->requestFocus( this );
00336             replay = TRUE;
00337             break;
00338         case Options::MouseActivateRaiseAndMove:
00339         case Options::MouseActivateRaiseAndUnrestrictedMove:
00340             workspace()->raiseClient( this );
00341             workspace()->requestFocus( this );
00342             if( options->moveMode == Options::Transparent && isMovable())
00343                 move_faked_activity = workspace()->fakeRequestedActivity( this );
00344         // fallthrough
00345         case Options::MouseMove:
00346         case Options::MouseUnrestrictedMove:
00347             {
00348             if (!isMovable())
00349                 break;
00350             if( moveResizeMode )
00351                 finishMoveResize( false );
00352             mode = PositionCenter;
00353             buttonDown = TRUE;
00354             moveOffset = QPoint( globalPos.x() - x(), globalPos.y() - y()); // map from global
00355             invertedMoveOffset = rect().bottomRight() - moveOffset;
00356             unrestrictedMoveResize = ( command == Options::MouseActivateRaiseAndUnrestrictedMove
00357                                     || command == Options::MouseUnrestrictedMove );
00358             if( !startMoveResize())
00359                 buttonDown = false;
00360             break;
00361             }
00362         case Options::MouseResize:
00363         case Options::MouseUnrestrictedResize:
00364             {
00365             if (!isResizable() || isShade()) // SHADE
00366                 break;
00367             if( moveResizeMode )
00368                 finishMoveResize( false );
00369             buttonDown = TRUE;
00370             moveOffset = QPoint( globalPos.x() - x(), globalPos.y() - y()); // map from global
00371             int x = moveOffset.x(), y = moveOffset.y();
00372             bool left = x < width() / 3;
00373             bool right = x >= 2 * width() / 3;
00374             bool top = y < height() / 3;
00375             bool bot = y >= 2 * height() / 3;
00376             if (top)
00377                 mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
00378             else if (bot)
00379                 mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
00380             else
00381                 mode = (x < width() / 2) ? PositionLeft : PositionRight;
00382             invertedMoveOffset = rect().bottomRight() - moveOffset;
00383             unrestrictedMoveResize = ( command == Options::MouseUnrestrictedResize );
00384             setCursor( mode );
00385             if( !startMoveResize())
00386                 buttonDown = false;
00387             break;
00388             }
00389         case Options::MouseMinimize:
00390             minimize();
00391             break;
00392         case Options::MouseNothing:
00393         // fall through
00394         default:
00395             replay = TRUE;
00396             break;
00397         }
00398     return replay;
00399     }
00400 
00401 // KDE4 remove me
00402 void Workspace::showWindowMenuAt( unsigned long, int, int )
00403     {
00404     slotWindowOperations();
00405     }
00406 
00407 void Workspace::slotActivateAttentionWindow()
00408     {
00409     if( attention_chain.count() > 0 )
00410         activateClient( attention_chain.first());
00411     }
00412 
00413 void Workspace::slotSwitchDesktopNext()
00414     {
00415     int d = currentDesktop() + 1;
00416      if ( d > numberOfDesktops() ) 
00417         {
00418         if ( options->rollOverDesktops ) 
00419             {
00420             d = 1;
00421             }
00422         else 
00423             {
00424             return;
00425             }
00426         }
00427     setCurrentDesktop(d);
00428     popupinfo->showInfo( desktopName(currentDesktop()) );
00429     }
00430 
00431 void Workspace::slotSwitchDesktopPrevious()
00432     {
00433     int d = currentDesktop() - 1;
00434     if ( d <= 0 ) 
00435         {
00436         if ( options->rollOverDesktops )
00437           d = numberOfDesktops();
00438       else
00439           return;
00440         }
00441     setCurrentDesktop(d);
00442     popupinfo->showInfo( desktopName(currentDesktop()) );
00443     }
00444 
00445 void Workspace::slotSwitchDesktopRight()
00446     {
00447     int x,y;
00448     calcDesktopLayout(x,y);
00449     int dt = currentDesktop()-1;
00450     if (layoutOrientation == Qt::Vertical)
00451         {
00452         dt += y;
00453         if ( dt >= numberOfDesktops() ) 
00454             {
00455             if ( options->rollOverDesktops )
00456               dt -= numberOfDesktops();
00457             else
00458               return;
00459             }
00460         }
00461     else
00462         {
00463         int d = (dt % x) + 1;
00464         if ( d >= x ) 
00465             {
00466             if ( options->rollOverDesktops )
00467               d -= x;
00468             else
00469               return;
00470             }
00471         dt = dt - (dt % x) + d;
00472         }
00473     setCurrentDesktop(dt+1);
00474     popupinfo->showInfo( desktopName(currentDesktop()) );
00475     }
00476 
00477 void Workspace::slotSwitchDesktopLeft()
00478     {
00479     int x,y;
00480     calcDesktopLayout(x,y);
00481     int dt = currentDesktop()-1;
00482     if (layoutOrientation == Qt::Vertical)
00483         {
00484         dt -= y;
00485         if ( dt < 0 ) 
00486             {
00487             if ( options->rollOverDesktops )
00488               dt += numberOfDesktops();
00489             else
00490               return;
00491             }
00492         }
00493     else
00494         {
00495         int d = (dt % x) - 1;
00496         if ( d < 0 ) 
00497             {
00498             if ( options->rollOverDesktops )
00499               d += x;
00500             else
00501               return;
00502             }
00503         dt = dt - (dt % x) + d;
00504         }
00505     setCurrentDesktop(dt+1);
00506     popupinfo->showInfo( desktopName(currentDesktop()) );
00507     }
00508 
00509 void Workspace::slotSwitchDesktopUp()
00510     {
00511     int x,y;
00512     calcDesktopLayout(x,y);
00513     int dt = currentDesktop()-1;
00514     if (layoutOrientation == Qt::Horizontal)
00515         {
00516         dt -= x;
00517         if ( dt < 0 ) 
00518             {
00519             if ( options->rollOverDesktops )
00520               dt += numberOfDesktops();
00521             else
00522               return;
00523             }
00524         }
00525     else
00526         {
00527         int d = (dt % y) - 1;
00528         if ( d < 0 ) 
00529             {
00530             if ( options->rollOverDesktops )
00531               d += y;
00532             else
00533               return;
00534             }
00535         dt = dt - (dt % y) + d;
00536         }
00537     setCurrentDesktop(dt+1);
00538     popupinfo->showInfo( desktopName(currentDesktop()) );
00539     }
00540 
00541 void Workspace::slotSwitchDesktopDown()
00542     {
00543     int x,y;
00544     calcDesktopLayout(x,y);
00545     int dt = currentDesktop()-1;
00546     if (layoutOrientation == Qt::Horizontal)
00547         {
00548         dt += x;
00549         if ( dt >= numberOfDesktops() ) 
00550             {
00551             if ( options->rollOverDesktops )
00552               dt -= numberOfDesktops();
00553             else
00554               return;
00555             }
00556         }
00557     else
00558         {
00559         int d = (dt % y) + 1;
00560         if ( d >= y ) 
00561             {
00562             if ( options->rollOverDesktops )
00563               d -= y;
00564             else
00565               return;
00566             }
00567         dt = dt - (dt % y) + d;
00568         }
00569     setCurrentDesktop(dt+1);
00570     popupinfo->showInfo( desktopName(currentDesktop()) );
00571     }
00572 
00573 void Workspace::slotSwitchToDesktop( int i )
00574     {
00575     setCurrentDesktop( i );
00576     popupinfo->showInfo( desktopName(currentDesktop()) );
00577     }
00578 
00579 
00580 void Workspace::slotWindowToDesktop( int i )
00581     {
00582     if( i >= 1 && i <= numberOfDesktops() && active_client
00583         && !active_client->isDesktop()
00584         && !active_client->isDock()
00585         && !active_client->isTopMenu())
00586             sendClientToDesktop( active_client, i, true );
00587     }
00588 
00592 void Workspace::slotWindowMaximize()
00593     {
00594     if ( active_client )
00595         performWindowOperation( active_client, Options::MaximizeOp );
00596     }
00597 
00601 void Workspace::slotWindowMaximizeVertical()
00602     {
00603     if ( active_client )
00604         performWindowOperation( active_client, Options::VMaximizeOp );
00605     }
00606 
00610 void Workspace::slotWindowMaximizeHorizontal()
00611     {
00612     if ( active_client )
00613         performWindowOperation( active_client, Options::HMaximizeOp );
00614     }
00615 
00616 
00620 void Workspace::slotWindowMinimize()
00621     {
00622     performWindowOperation( active_client, Options::MinimizeOp );
00623     }
00624 
00628 void Workspace::slotWindowShade()
00629     {
00630     performWindowOperation( active_client, Options::ShadeOp );
00631     }
00632 
00636 void Workspace::slotWindowRaise()
00637     {
00638     if ( active_client )
00639         raiseClient( active_client );
00640     }
00641 
00645 void Workspace::slotWindowLower()
00646     {
00647     if ( active_client )
00648         lowerClient( active_client );
00649     }
00650 
00654 void Workspace::slotWindowRaiseOrLower()
00655     {
00656     if  ( active_client )
00657         raiseOrLowerClient( active_client );
00658     }
00659 
00660 void Workspace::slotWindowOnAllDesktops()
00661     {
00662     if( active_client )
00663         active_client->toggleOnAllDesktops();
00664     }
00665 
00666 void Workspace::slotWindowFullScreen()
00667     {
00668     if( active_client )
00669         performWindowOperation( active_client, Options::FullScreenOp );
00670     }
00671 
00672 void Workspace::slotWindowNoBorder()
00673     {
00674     if( active_client )
00675         performWindowOperation( active_client, Options::NoBorderOp );
00676     }
00677 
00678 void Workspace::slotWindowAbove()
00679     {
00680     if( active_client )
00681         performWindowOperation( active_client, Options::KeepAboveOp );
00682     }
00683 
00684 void Workspace::slotWindowBelow()
00685     {
00686     if( active_client )
00687         performWindowOperation( active_client, Options::KeepBelowOp );
00688     }
00689 
00693 void Workspace::slotWindowToNextDesktop()
00694     {
00695     int d = currentDesktop() + 1;
00696     if ( d > numberOfDesktops() )
00697         d = 1;
00698     if (active_client && !active_client->isDesktop()
00699         && !active_client->isDock() && !active_client->isTopMenu())
00700       sendClientToDesktop(active_client,d,true);
00701     setCurrentDesktop(d);
00702     popupinfo->showInfo( desktopName(currentDesktop()) );
00703     }
00704 
00708 void Workspace::slotWindowToPreviousDesktop()
00709     {
00710     int d = currentDesktop() - 1;
00711     if ( d <= 0 )
00712         d = numberOfDesktops();
00713     if (active_client && !active_client->isDesktop()
00714         && !active_client->isDock() && !active_client->isTopMenu())
00715       sendClientToDesktop(active_client,d,true);
00716     setCurrentDesktop(d);
00717     popupinfo->showInfo( desktopName(currentDesktop()) );
00718     }
00719 
00723 void Workspace::slotKillWindow()
00724     {
00725     KillWindow kill( this );
00726     kill.start();
00727     }
00728 
00734 void Workspace::sendToDesktop( int desk )
00735     {
00736     if ( !popup_client )
00737         return;
00738     if ( desk == 0 ) 
00739         { // the 'on_all_desktops' menu entry
00740         popup_client->setOnAllDesktops( !popup_client->isOnAllDesktops());
00741         return;
00742         }
00743 
00744     sendClientToDesktop( popup_client, desk, false );
00745 
00746     }
00747 
00751 void Workspace::slotWindowOperations()
00752     {
00753     if ( !active_client )
00754         return;
00755     QPoint pos = active_client->pos() + active_client->clientPos();
00756     showWindowMenu( pos.x(), pos.y(), active_client );
00757     }
00758 
00759 void Workspace::showWindowMenu( int x, int y, Client* cl )
00760     {
00761     if (!kapp->authorizeKAction("kwin_rmb"))
00762         return;
00763     if( !cl )
00764         return;
00765     if( popup_client != NULL ) // recursion
00766         return;
00767     if ( cl->isDesktop()
00768         || cl->isDock()
00769         || cl->isTopMenu())
00770         return;
00771 
00772     popup_client = cl;
00773     QPopupMenu* p = clientPopup();
00774     p->exec( QPoint( x, y ) );
00775     popup_client = 0;
00776     }
00777 
00781 void Workspace::slotWindowClose()
00782     {
00783     if ( tab_box->isVisible() || popupinfo->isVisible() )
00784         return;
00785     performWindowOperation( active_client, Options::CloseOp );
00786     }
00787 
00791 void Workspace::slotWindowMove()
00792     {
00793     performWindowOperation( active_client, Options::UnrestrictedMoveOp );
00794     }
00795 
00799 void Workspace::slotWindowResize()
00800     {
00801     performWindowOperation( active_client, Options::UnrestrictedResizeOp );
00802     }
00803 
00804 } // namespace
KDE Logo
This file is part of the documentation for kwin Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 5 04:41:14 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003