00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include "client.h"
00021
#include "workspace.h"
00022
00023
#include <fixx11h.h>
00024
#include <qpopupmenu.h>
00025
#include <kglobalsettings.h>
00026
#include <kiconloader.h>
00027
#include <klocale.h>
00028
#include <kconfig.h>
00029
#include <kglobalaccel.h>
00030
#include <kapplication.h>
00031
00032
#include "popupinfo.h"
00033
#include "killwindow.h"
00034
#include "tabbox.h"
00035
00036
namespace KWinInternal
00037 {
00038
00039
00040
00041
00042
00043 QPopupMenu* Workspace::clientPopup()
00044 {
00045
if ( !popup )
00046 {
00047 popup =
new QPopupMenu;
00048 popup->setCheckable( TRUE );
00049 popup->setFont(KGlobalSettings::menuFont());
00050 connect( popup, SIGNAL( aboutToShow() ),
this, SLOT( clientPopupAboutToShow() ) );
00051 connect( popup, SIGNAL( activated(
int) ),
this, SLOT( clientPopupActivated(
int) ) );
00052
00053 advanced_popup =
new QPopupMenu( popup );
00054 advanced_popup->setCheckable( TRUE );
00055 advanced_popup->setFont(KGlobalSettings::menuFont());
00056 connect( advanced_popup, SIGNAL( activated(
int) ),
this, SLOT( clientPopupActivated(
int) ) );
00057 advanced_popup->insertItem( SmallIconSet(
"up" ),
00058 i18n(
"Keep &Above Others")+
'\t'+keys->shortcut(
"Window Above Other Windows").seq(0).toString(), Options::KeepAboveOp );
00059 advanced_popup->insertItem( SmallIconSet(
"down" ),
00060 i18n(
"Keep &Below Others")+
'\t'+keys->shortcut(
"Window Below Other Windows").seq(0).toString(), Options::KeepBelowOp );
00061 advanced_popup->insertItem( SmallIconSet(
"window_fullscreen" ),
00062 i18n(
"&Fullscreen")+
'\t'+keys->shortcut(
"Window Fullscreen").seq(0).toString(), Options::FullScreenOp );
00063 advanced_popup->insertItem( i18n(
"&No Border")+
'\t'+keys->shortcut(
"Window No Border").seq(0).toString(), Options::NoBorderOp );
00064 advanced_popup->insertItem( SmallIconSet(
"filesave" ), i18n(
"&Special Window Settings..."), Options::WindowRulesOp );
00065
00066 popup->insertItem(i18n(
"Ad&vanced"), advanced_popup );
00067 desk_popup_index = popup->count();
00068 popup->insertItem( SmallIconSet(
"move" ), i18n(
"&Move")+
'\t'+keys->shortcut(
"Window Move").seq(0).toString(), Options::MoveOp );
00069 popup->insertItem( i18n(
"Re&size")+
'\t'+keys->shortcut(
"Window Resize").seq(0).toString(), Options::ResizeOp );
00070 popup->insertItem( i18n(
"Mi&nimize")+
'\t'+keys->shortcut(
"Window Minimize").seq(0).toString(), Options::MinimizeOp );
00071 popup->insertItem( i18n(
"Ma&ximize")+
'\t'+keys->shortcut(
"Window Maximize").seq(0).toString(), Options::MaximizeOp );
00072 popup->insertItem( i18n(
"Sh&ade")+
'\t'+keys->shortcut(
"Window Shade").seq(0).toString(), Options::ShadeOp );
00073
00074 popup->insertSeparator();
00075
00076
if (!KGlobal::config()->isImmutable() &&
00077 !kapp->authorizeControlModules(Workspace::configModules(
true)).isEmpty())
00078 {
00079 popup->insertItem(SmallIconSet(
"configure" ), i18n(
"Configur&e Window Behavior..."),
this, SLOT( configureWM() ));
00080 popup->insertSeparator();
00081 }
00082
00083 popup->insertItem( SmallIconSet(
"fileclose" ), i18n(
"&Close")+
'\t'+keys->shortcut(
"Window Close").seq(0).toString(), Options::CloseOp );
00084 }
00085
return popup;
00086 }
00087
00093
void Workspace::clientPopupAboutToShow()
00094 {
00095
if ( !popup_client || !popup )
00096
return;
00097
00098
if ( numberOfDesktops() == 1 )
00099 {
00100
delete desk_popup;
00101 desk_popup = 0;
00102 }
00103
else
00104 {
00105 initDesktopPopup();
00106 }
00107
00108 popup->setItemEnabled( Options::ResizeOp, popup_client->isResizable() );
00109 popup->setItemEnabled( Options::MoveOp, popup_client->isMovable() );
00110 popup->setItemEnabled( Options::MaximizeOp, popup_client->isMaximizable() );
00111 popup->setItemChecked( Options::MaximizeOp, popup_client->maximizeMode() == Client::MaximizeFull );
00112
00113 popup->setItemChecked( Options::ShadeOp, popup_client->shadeMode() != ShadeNone );
00114 popup->setItemEnabled( Options::ShadeOp, popup_client->isShadeable());
00115 advanced_popup->setItemChecked( Options::KeepAboveOp, popup_client->keepAbove() );
00116 advanced_popup->setItemChecked( Options::KeepBelowOp, popup_client->keepBelow() );
00117 advanced_popup->setItemChecked( Options::FullScreenOp, popup_client->isFullScreen() );
00118 advanced_popup->setItemEnabled( Options::FullScreenOp, popup_client->userCanSetFullScreen() );
00119 advanced_popup->setItemChecked( Options::NoBorderOp, popup_client->noBorder() );
00120 advanced_popup->setItemEnabled( Options::NoBorderOp, popup_client->userCanSetNoBorder() );
00121 popup->setItemEnabled( Options::MinimizeOp, popup_client->isMinimizable() );
00122 popup->setItemEnabled( Options::CloseOp, popup_client->isCloseable() );
00123 }
00124
00125
00126
void Workspace::initDesktopPopup()
00127 {
00128
if (desk_popup)
00129
return;
00130
00131 desk_popup =
new QPopupMenu( popup );
00132 desk_popup->setCheckable( TRUE );
00133 desk_popup->setFont(KGlobalSettings::menuFont());
00134 connect( desk_popup, SIGNAL( activated(
int) ),
00135
this, SLOT( slotSendToDesktop(
int) ) );
00136 connect( desk_popup, SIGNAL( aboutToShow() ),
00137
this, SLOT( desktopPopupAboutToShow() ) );
00138
00139 popup->insertItem(i18n(
"To &Desktop"), desk_popup, -1, desk_popup_index );
00140 }
00141
00146
void Workspace::desktopPopupAboutToShow()
00147 {
00148
if ( !desk_popup )
00149
return;
00150
00151 desk_popup->clear();
00152 desk_popup->insertItem( i18n(
"&All Desktops"), 0 );
00153
if ( active_client && active_client->isOnAllDesktops() )
00154 desk_popup->setItemChecked( 0, TRUE );
00155 desk_popup->insertSeparator( -1 );
00156
int id;
00157
const int BASE = 10;
00158
for (
int i = 1; i <= numberOfDesktops(); i++ )
00159 {
00160 QString basic_name(
"%1 %2");
00161
if (i<BASE)
00162 {
00163 basic_name.prepend(
'&');
00164 }
00165
id = desk_popup->insertItem(
00166 basic_name
00167 .arg(i)
00168 .arg( desktopName(i).replace(
'&',
"&&" )),
00169 i );
00170
if ( active_client &&
00171 !active_client->isOnAllDesktops() && active_client->desktop() == i )
00172 desk_popup->setItemChecked(
id, TRUE );
00173 }
00174 }
00175
00176
00177
00181
void Workspace::initShortcuts()
00182 {
00183 keys =
new KGlobalAccel(
this );
00184
#include "kwinbindings.cpp"
00185 readShortcuts();
00186 }
00187
00188
void Workspace::readShortcuts()
00189 {
00190 keys->readSettings();
00191
00192 cutWalkThroughDesktops = keys->shortcut(
"Walk Through Desktops");
00193 cutWalkThroughDesktopsReverse = keys->shortcut(
"Walk Through Desktops (Reverse)");
00194 cutWalkThroughDesktopList = keys->shortcut(
"Walk Through Desktop List");
00195 cutWalkThroughDesktopListReverse = keys->shortcut(
"Walk Through Desktop List (Reverse)");
00196 cutWalkThroughWindows = keys->shortcut(
"Walk Through Windows");
00197 cutWalkThroughWindowsReverse = keys->shortcut(
"Walk Through Windows (Reverse)");
00198
00199 keys->updateConnections();
00200
00201
delete popup;
00202 popup = NULL;
00203 desk_popup = NULL;
00204 }
00205
00206
00207
void Workspace::clientPopupActivated(
int id )
00208 {
00209
WindowOperation op = static_cast< WindowOperation >(
id );
00210
Client* c = popup_client ? popup_client : active_client;
00211 QString type;
00212
switch( op )
00213 {
00214
case FullScreenOp:
00215
if( !c->isFullScreen() && c->userCanSetFullScreen())
00216 type =
"fullscreenaltf3";
00217
break;
00218
case NoBorderOp:
00219
if( !c->noBorder() && c->userCanSetNoBorder())
00220 type =
"noborderaltf3";
00221
break;
00222
default:
00223
break;
00224 };
00225
if( !type.isEmpty())
00226 helperDialog( type, c );
00227 performWindowOperation( c, op );
00228 }
00229
00230
00231
void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
00232 {
00233
if ( !c )
00234
return;
00235
00236
if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp )
00237 QCursor::setPos( c->geometry().center() );
00238
if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp )
00239 QCursor::setPos( c->geometry().bottomRight());
00240
switch ( op )
00241 {
00242
case Options::MoveOp:
00243 c->performMouseCommand( Options::MouseMove, QCursor::pos() );
00244
break;
00245
case Options::UnrestrictedMoveOp:
00246 c->performMouseCommand( Options::MouseUnrestrictedMove, QCursor::pos() );
00247
break;
00248
case Options::ResizeOp:
00249 c->performMouseCommand( Options::MouseResize, QCursor::pos() );
00250
break;
00251
case Options::UnrestrictedResizeOp:
00252 c->performMouseCommand( Options::MouseUnrestrictedResize, QCursor::pos() );
00253
break;
00254
case Options::CloseOp:
00255 c->closeWindow();
00256
break;
00257
case Options::MaximizeOp:
00258 c->maximize( c->maximizeMode() == Client::MaximizeFull
00259 ? Client::MaximizeRestore : Client::MaximizeFull );
00260
break;
00261
case Options::HMaximizeOp:
00262 c->maximize( c->maximizeMode() ^ Client::MaximizeHorizontal );
00263
break;
00264
case Options::VMaximizeOp:
00265 c->maximize( c->maximizeMode() ^ Client::MaximizeVertical );
00266
break;
00267
case Options::MinimizeOp:
00268 c->minimize();
00269
break;
00270
case Options::ShadeOp:
00271 c->toggleShade();
00272
break;
00273
case Options::OnAllDesktopsOp:
00274 c->setOnAllDesktops( !c->isOnAllDesktops() );
00275
break;
00276
case Options::FullScreenOp:
00277 c->setFullScreen( !c->isFullScreen(),
true );
00278
break;
00279
case Options::NoBorderOp:
00280 c->setUserNoBorder( !c->isUserNoBorder());
00281
break;
00282
case Options::KeepAboveOp:
00283 c->setKeepAbove( !c->keepAbove() );
00284
break;
00285
case Options::KeepBelowOp:
00286 c->setKeepBelow( !c->keepBelow() );
00287
break;
00288
case Options::WindowRulesOp:
00289 editWindowRules( c );
00290
break;
00291
case Options::LowerOp:
00292 lowerClient(c);
00293
break;
00294
default:
00295
break;
00296 }
00297 }
00298
00302
bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPos,
bool handled )
00303 {
00304
bool replay = FALSE;
00305
switch (command)
00306 {
00307
case Options::MouseRaise:
00308 workspace()->raiseClient(
this );
00309
break;
00310
case Options::MouseLower:
00311 workspace()->lowerClient(
this );
00312
break;
00313
case Options::MouseShade :
00314 toggleShade();
00315
break;
00316
case Options::MouseOperationsMenu:
00317
if ( isActive() & options->clickRaise )
00318 autoRaise();
00319 workspace()->showWindowMenu( globalPos,
this );
00320
break;
00321
case Options::MouseToggleRaiseAndLower:
00322 workspace()->raiseOrLowerClient(
this );
00323
break;
00324
case Options::MouseActivateAndRaise:
00325 replay = isActive();
00326 workspace()->takeActivity(
this, ActivityFocus | ActivityRaise, handled && replay );
00327
break;
00328
case Options::MouseActivateAndLower:
00329 workspace()->requestFocus(
this );
00330 workspace()->lowerClient(
this );
00331
break;
00332
case Options::MouseActivate:
00333 replay = isActive();
00334 workspace()->takeActivity(
this, ActivityFocus, handled && replay );
00335
break;
00336
case Options::MouseActivateRaiseAndPassClick:
00337 workspace()->takeActivity(
this, ActivityFocus | ActivityRaise, handled );
00338 replay = TRUE;
00339
break;
00340
case Options::MouseActivateAndPassClick:
00341 workspace()->takeActivity(
this, ActivityFocus, handled );
00342 replay = TRUE;
00343
break;
00344
case Options::MouseActivateRaiseAndMove:
00345
case Options::MouseActivateRaiseAndUnrestrictedMove:
00346 workspace()->raiseClient(
this );
00347 workspace()->requestFocus(
this );
00348
if( options->moveMode == Options::Transparent &&
isMovable())
00349 move_faked_activity = workspace()->fakeRequestedActivity(
this );
00350
00351
case Options::MouseMove:
00352
case Options::MouseUnrestrictedMove:
00353 {
00354
if (!
isMovable())
00355
break;
00356
if( moveResizeMode )
00357 finishMoveResize(
false );
00358 mode = PositionCenter;
00359 buttonDown = TRUE;
00360 moveOffset = QPoint( globalPos.x() - x(), globalPos.y() - y());
00361 invertedMoveOffset = rect().bottomRight() - moveOffset;
00362 unrestrictedMoveResize = ( command == Options::MouseActivateRaiseAndUnrestrictedMove
00363 || command == Options::MouseUnrestrictedMove );
00364 setCursor( mode );
00365
if( !startMoveResize())
00366 {
00367 buttonDown =
false;
00368 setCursor( mode );
00369 }
00370
break;
00371 }
00372
case Options::MouseResize:
00373
case Options::MouseUnrestrictedResize:
00374 {
00375
if (!
isResizable() || isShade())
00376
break;
00377
if( moveResizeMode )
00378 finishMoveResize(
false );
00379 buttonDown = TRUE;
00380 moveOffset = QPoint( globalPos.x() - x(), globalPos.y() - y());
00381
int x = moveOffset.x(), y = moveOffset.y();
00382
bool left = x < width() / 3;
00383
bool right = x >= 2 * width() / 3;
00384
bool top = y < height() / 3;
00385
bool bot = y >= 2 * height() / 3;
00386
if (top)
00387 mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
00388
else if (bot)
00389 mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
00390
else
00391 mode = (x < width() / 2) ? PositionLeft : PositionRight;
00392 invertedMoveOffset = rect().bottomRight() - moveOffset;
00393 unrestrictedMoveResize = ( command == Options::MouseUnrestrictedResize );
00394 setCursor( mode );
00395
if( !startMoveResize())
00396 {
00397 buttonDown =
false;
00398 setCursor( mode );
00399 }
00400
break;
00401 }
00402
case Options::MouseMinimize:
00403
minimize();
00404
break;
00405
case Options::MouseNothing:
00406
00407
default:
00408 replay = TRUE;
00409
break;
00410 }
00411
return replay;
00412 }
00413
00414
00415
void Workspace::showWindowMenuAt(
unsigned long,
int,
int )
00416 {
00417 slotWindowOperations();
00418 }
00419
00420
void Workspace::slotActivateAttentionWindow()
00421 {
00422
if( attention_chain.count() > 0 )
00423 activateClient( attention_chain.first());
00424 }
00425
00426
void Workspace::slotSwitchDesktopNext()
00427 {
00428
int d = currentDesktop() + 1;
00429
if ( d > numberOfDesktops() )
00430 {
00431
if ( options->rollOverDesktops )
00432 {
00433 d = 1;
00434 }
00435
else
00436 {
00437
return;
00438 }
00439 }
00440 setCurrentDesktop(d);
00441 popupinfo->showInfo( desktopName(currentDesktop()) );
00442 }
00443
00444
void Workspace::slotSwitchDesktopPrevious()
00445 {
00446
int d = currentDesktop() - 1;
00447
if ( d <= 0 )
00448 {
00449
if ( options->rollOverDesktops )
00450 d = numberOfDesktops();
00451
else
00452
return;
00453 }
00454 setCurrentDesktop(d);
00455 popupinfo->showInfo( desktopName(currentDesktop()) );
00456 }
00457
00458
void Workspace::slotSwitchDesktopRight()
00459 {
00460
int x,y;
00461 calcDesktopLayout(x,y);
00462
int dt = currentDesktop()-1;
00463
if (layoutOrientation == Qt::Vertical)
00464 {
00465 dt += y;
00466 if ( dt >= numberOfDesktops() )
00467 {
00468
if ( options->rollOverDesktops )
00469 dt -= numberOfDesktops();
00470
else
00471
return;
00472 }
00473 }
00474
else
00475 {
00476
int d = (dt % x) + 1;
00477
if ( d >= x )
00478 {
00479
if ( options->rollOverDesktops )
00480 d -= x;
00481
else
00482
return;
00483 }
00484 dt = dt - (dt % x) + d;
00485 }
00486 setCurrentDesktop(dt+1);
00487 popupinfo->showInfo( desktopName(currentDesktop()) );
00488 }
00489
00490
void Workspace::slotSwitchDesktopLeft()
00491 {
00492
int x,y;
00493 calcDesktopLayout(x,y);
00494
int dt = currentDesktop()-1;
00495
if (layoutOrientation == Qt::Vertical)
00496 {
00497 dt -= y;
00498
if ( dt < 0 )
00499 {
00500
if ( options->rollOverDesktops )
00501 dt += numberOfDesktops();
00502
else
00503
return;
00504 }
00505 }
00506
else
00507 {
00508
int d = (dt % x) - 1;
00509
if ( d < 0 )
00510 {
00511
if ( options->rollOverDesktops )
00512 d += x;
00513
else
00514
return;
00515 }
00516 dt = dt - (dt % x) + d;
00517 }
00518 setCurrentDesktop(dt+1);
00519 popupinfo->showInfo( desktopName(currentDesktop()) );
00520 }
00521
00522
void Workspace::slotSwitchDesktopUp()
00523 {
00524
int x,y;
00525 calcDesktopLayout(x,y);
00526
int dt = currentDesktop()-1;
00527
if (layoutOrientation == Qt::Horizontal)
00528 {
00529 dt -= x;
00530
if ( dt < 0 )
00531 {
00532
if ( options->rollOverDesktops )
00533 dt += numberOfDesktops();
00534
else
00535
return;
00536 }
00537 }
00538
else
00539 {
00540
int d = (dt % y) - 1;
00541
if ( d < 0 )
00542 {
00543
if ( options->rollOverDesktops )
00544 d += y;
00545
else
00546
return;
00547 }
00548 dt = dt - (dt % y) + d;
00549 }
00550 setCurrentDesktop(dt+1);
00551 popupinfo->showInfo( desktopName(currentDesktop()) );
00552 }
00553
00554
void Workspace::slotSwitchDesktopDown()
00555 {
00556
int x,y;
00557 calcDesktopLayout(x,y);
00558
int dt = currentDesktop()-1;
00559
if (layoutOrientation == Qt::Horizontal)
00560 {
00561 dt += x;
00562
if ( dt >= numberOfDesktops() )
00563 {
00564
if ( options->rollOverDesktops )
00565 dt -= numberOfDesktops();
00566
else
00567
return;
00568 }
00569 }
00570
else
00571 {
00572
int d = (dt % y) + 1;
00573
if ( d >= y )
00574 {
00575
if ( options->rollOverDesktops )
00576 d -= y;
00577
else
00578
return;
00579 }
00580 dt = dt - (dt % y) + d;
00581 }
00582 setCurrentDesktop(dt+1);
00583 popupinfo->showInfo( desktopName(currentDesktop()) );
00584 }
00585
00586
void Workspace::slotSwitchToDesktop(
int i )
00587 {
00588 setCurrentDesktop( i );
00589 popupinfo->showInfo( desktopName(currentDesktop()) );
00590 }
00591
00592
00593
void Workspace::slotWindowToDesktop(
int i )
00594 {
00595
if( i >= 1 && i <= numberOfDesktops() && active_client
00596 && !active_client->isDesktop()
00597 && !active_client->isDock()
00598 && !active_client->isTopMenu())
00599 sendClientToDesktop( active_client, i,
true );
00600 }
00601
00605
void Workspace::slotWindowMaximize()
00606 {
00607
if ( active_client )
00608 performWindowOperation( active_client, Options::MaximizeOp );
00609 }
00610
00614
void Workspace::slotWindowMaximizeVertical()
00615 {
00616
if ( active_client )
00617 performWindowOperation( active_client, Options::VMaximizeOp );
00618 }
00619
00623
void Workspace::slotWindowMaximizeHorizontal()
00624 {
00625
if ( active_client )
00626 performWindowOperation( active_client, Options::HMaximizeOp );
00627 }
00628
00629
00633
void Workspace::slotWindowMinimize()
00634 {
00635 performWindowOperation( active_client, Options::MinimizeOp );
00636 }
00637
00641
void Workspace::slotWindowShade()
00642 {
00643 performWindowOperation( active_client, Options::ShadeOp );
00644 }
00645
00649
void Workspace::slotWindowRaise()
00650 {
00651
if ( active_client )
00652 raiseClient( active_client );
00653 }
00654
00658
void Workspace::slotWindowLower()
00659 {
00660
if ( active_client )
00661 lowerClient( active_client );
00662 }
00663
00667
void Workspace::slotWindowRaiseOrLower()
00668 {
00669
if ( active_client )
00670 raiseOrLowerClient( active_client );
00671 }
00672
00673
void Workspace::slotWindowOnAllDesktops()
00674 {
00675
if( active_client )
00676 active_client->setOnAllDesktops( !active_client->isOnAllDesktops());
00677 }
00678
00679
void Workspace::slotWindowFullScreen()
00680 {
00681
if( active_client )
00682 performWindowOperation( active_client, Options::FullScreenOp );
00683 }
00684
00685
void Workspace::slotWindowNoBorder()
00686 {
00687
if( active_client )
00688 performWindowOperation( active_client, Options::NoBorderOp );
00689 }
00690
00691
void Workspace::slotWindowAbove()
00692 {
00693
if( active_client )
00694 performWindowOperation( active_client, Options::KeepAboveOp );
00695 }
00696
00697
void Workspace::slotWindowBelow()
00698 {
00699
if( active_client )
00700 performWindowOperation( active_client, Options::KeepBelowOp );
00701 }
00702
00706
void Workspace::slotWindowToNextDesktop()
00707 {
00708
int d = currentDesktop() + 1;
00709
if ( d > numberOfDesktops() )
00710 d = 1;
00711
if (active_client && !active_client->isDesktop()
00712 && !active_client->isDock() && !active_client->isTopMenu())
00713 sendClientToDesktop(active_client,d,
true);
00714 setCurrentDesktop(d);
00715 popupinfo->showInfo( desktopName(currentDesktop()) );
00716 }
00717
00721
void Workspace::slotWindowToPreviousDesktop()
00722 {
00723
int d = currentDesktop() - 1;
00724
if ( d <= 0 )
00725 d = numberOfDesktops();
00726
if (active_client && !active_client->isDesktop()
00727 && !active_client->isDock() && !active_client->isTopMenu())
00728 sendClientToDesktop(active_client,d,
true);
00729 setCurrentDesktop(d);
00730 popupinfo->showInfo( desktopName(currentDesktop()) );
00731 }
00732
00736
void Workspace::slotKillWindow()
00737 {
00738 KillWindow kill(
this );
00739 kill.start();
00740 }
00741
00747
void Workspace::slotSendToDesktop(
int desk )
00748 {
00749
if ( !popup_client )
00750
return;
00751
if ( desk == 0 )
00752 {
00753 popup_client->setOnAllDesktops( !popup_client->isOnAllDesktops());
00754
return;
00755 }
00756
00757 sendClientToDesktop( popup_client, desk,
false );
00758
00759 }
00760
00764
void Workspace::slotWindowOperations()
00765 {
00766
if ( !active_client )
00767
return;
00768 QPoint pos = active_client->pos() + active_client->clientPos();
00769 showWindowMenu( pos.x(), pos.y(), active_client );
00770 }
00771
00772
void Workspace::showWindowMenu(
const QRect &pos, Client* cl )
00773 {
00774
if (!kapp->authorizeKAction(
"kwin_rmb"))
00775
return;
00776
if( !cl )
00777
return;
00778
if( popup_client != NULL )
00779
return;
00780
if ( cl->isDesktop()
00781 || cl->isDock()
00782 || cl->isTopMenu())
00783
return;
00784
00785 popup_client = cl;
00786 QPopupMenu* p = clientPopup();
00787
int x = pos.left();
00788
int y = pos.bottom();
00789
if (y == pos.top()) {
00790 p->exec( QPoint( x, y ) );
00791 }
else {
00792 QRect area = clientArea(ScreenArea, QPoint(x, y), currentDesktop());
00793
int popupHeight = p->sizeHint().height();
00794
if (y + popupHeight < area.height()) {
00795 p->exec( QPoint( x, y ) );
00796 }
else {
00797 p->exec( QPoint( x, pos.top() - popupHeight ) );
00798 }
00799 }
00800 popup_client = 0;
00801 }
00802
00806
void Workspace::slotWindowClose()
00807 {
00808
if ( tab_box->isVisible() || popupinfo->isVisible() )
00809
return;
00810 performWindowOperation( active_client, Options::CloseOp );
00811 }
00812
00816
void Workspace::slotWindowMove()
00817 {
00818 performWindowOperation( active_client, Options::UnrestrictedMoveOp );
00819 }
00820
00824
void Workspace::slotWindowResize()
00825 {
00826 performWindowOperation( active_client, Options::UnrestrictedResizeOp );
00827 }
00828
00829 }