21 #include <tqpushbutton.h>
23 #include <tqtooltip.h>
24 #include <tqpopupmenu.h>
25 #include <tdeglobalsettings.h>
26 #include <kiconloader.h>
27 #include <tdelocale.h>
28 #include <tdeconfig.h>
29 #include <kglobalaccel.h>
30 #include <tdeapplication.h>
34 #include "workspace.h"
37 #include "killwindow.h"
40 namespace KWinInternal
47 TQPopupMenu* Workspace::clientPopup()
51 popup =
new TQPopupMenu;
52 popup->setCheckable( TRUE );
53 popup->setFont(TDEGlobalSettings::menuFont());
54 connect( popup, TQT_SIGNAL( aboutToShow() ),
this, TQT_SLOT( clientPopupAboutToShow() ) );
55 connect( popup, TQT_SIGNAL( activated(
int) ),
this, TQT_SLOT( clientPopupActivated(
int) ) );
57 advanced_popup =
new TQPopupMenu( popup );
58 advanced_popup->setCheckable( TRUE );
59 advanced_popup->setFont(TDEGlobalSettings::menuFont());
60 connect( advanced_popup, TQT_SIGNAL( activated(
int) ),
this, TQT_SLOT( clientPopupActivated(
int) ) );
61 advanced_popup->insertItem( SmallIconSet(
"go-up" ),
62 i18n(
"Keep &Above Others")+
'\t'+keys->shortcut(
"Window Above Other Windows").seq(0).toString(), Options::KeepAboveOp );
63 advanced_popup->insertItem( SmallIconSet(
"go-down" ),
64 i18n(
"Keep &Below Others")+
'\t'+keys->shortcut(
"Window Below Other Windows").seq(0).toString(), Options::KeepBelowOp );
65 advanced_popup->insertItem( SmallIconSet(
"view-fullscreen" ),
66 i18n(
"&Fullscreen")+
'\t'+keys->shortcut(
"Window Fullscreen").seq(0).toString(), Options::FullScreenOp );
67 advanced_popup->insertItem( i18n(
"&No Border")+
'\t'+keys->shortcut(
"Window No Border").seq(0).toString(), Options::NoBorderOp );
68 advanced_popup->insertItem( i18n(
"Shad&ow"), Options::ShadowOp );
69 advanced_popup->insertItem( SmallIconSet(
"key_bindings"),
70 i18n(
"Window &Shortcut...")+
'\t'+keys->shortcut(
"Setup Window Shortcut").seq(0).toString(), Options::SetupWindowShortcutOp );
71 advanced_popup->insertSeparator();
72 advanced_popup->insertItem( SmallIconSet(
"suspend" ), i18n(
"&Suspend Application"), Options::SuspendWindowOp );
73 advanced_popup->insertItem( SmallIconSet(
"application-x-executable" ), i18n(
"&Resume Application"), Options::ResumeWindowOp );
74 advanced_popup->insertSeparator();
75 advanced_popup->insertItem( SmallIconSet(
"wizard" ), i18n(
"&Special Window Settings..."), Options::WindowRulesOp );
76 advanced_popup->insertItem( SmallIconSet(
"wizard" ), i18n(
"&Special Application Settings..."), Options::ApplicationRulesOp );
78 popup->insertItem(i18n(
"Ad&vanced"), advanced_popup );
79 desk_popup_index = popup->count();
81 if (options->useTranslucency){
82 TQPopupMenu *trans_popup =
new TQPopupMenu( popup );
83 TQVBox *transBox =
new TQVBox(trans_popup);
84 transButton =
new TQPushButton(transBox,
"transButton");
85 TQToolTip::add(transButton, i18n(
"Reset opacity to default value"));
86 transSlider =
new TQSlider(0, 100, 1, 100, Qt::Horizontal, transBox,
"transSlider");
87 TQToolTip::add(transSlider, i18n(
"Slide this to set the window's opacity"));
88 connect(transButton, TQT_SIGNAL(clicked()), TQT_SLOT(resetClientOpacity()));
89 connect(transButton, TQT_SIGNAL(clicked()), trans_popup, TQT_SLOT(hide()));
90 connect(transSlider, TQT_SIGNAL(valueChanged(
int)), TQT_SLOT(setTransButtonText(
int)));
91 connect(transSlider, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(setPopupClientOpacity(
int)));
93 trans_popup->insertItem(transBox);
94 popup->insertItem(i18n(
"&Opacity"), trans_popup );
97 popup->insertItem( SmallIconSet(
"move" ), i18n(
"&Move")+
'\t'+keys->shortcut(
"Window Move").seq(0).toString(), Options::MoveOp );
98 popup->insertItem( i18n(
"Re&size")+
'\t'+keys->shortcut(
"Window Resize").seq(0).toString(), Options::ResizeOp );
99 popup->insertItem( i18n(
"Mi&nimize")+
'\t'+keys->shortcut(
"Window Minimize").seq(0).toString(), Options::MinimizeOp );
100 popup->insertItem( i18n(
"Ma&ximize")+
'\t'+keys->shortcut(
"Window Maximize").seq(0).toString(), Options::MaximizeOp );
101 popup->insertItem( i18n(
"Sh&ade")+
'\t'+keys->shortcut(
"Window Shade").seq(0).toString(), Options::ShadeOp );
103 popup->insertSeparator();
105 if (!TDEGlobal::config()->isImmutable() &&
106 !kapp->authorizeControlModules(Workspace::configModules(
true)).isEmpty())
108 popup->insertItem(SmallIconSet(
"configure" ), i18n(
"Configur&e Window Behavior..."),
this, TQT_SLOT( configureWM() ));
109 popup->insertSeparator();
112 popup->insertItem( SmallIconSet(
"window-close" ), i18n(
"&Close")+
'\t'+keys->shortcut(
"Window Close").seq(0).toString(), Options::CloseOp );
118 void Workspace::setPopupClientOpacity(
int value)
120 active_popup_client->setCustomOpacityFlag(
true);
122 value<100?active_popup_client->setOpacity(
true, (uint)((value/100.0)*0xffffffff)):active_popup_client->setOpacity(
false,0xffffffff);
125 void Workspace::setTransButtonText(
int value)
129 transButton->setText(
" 0 %");
130 else if (value >= 100 )
131 transButton->setText(
"100 %");
133 transButton->setText(
" "+TQString::number(value)+
" %");
135 transButton->setText(
" "+TQString::number(value)+
" %");
138 void Workspace::resetClientOpacity()
140 active_popup_client->setCustomOpacityFlag(
false);
141 active_popup_client->updateOpacity();
142 transSlider->setValue(100-active_popup_client->opacityPercentage());
143 setTransButtonText(100-active_popup_client->opacityPercentage());
152 void Workspace::clientPopupAboutToShow()
154 if ( !active_popup_client || !popup )
157 if ( numberOfDesktops() == 1 )
167 popup->setItemEnabled( Options::ResizeOp, active_popup_client->isResizable() );
168 popup->setItemEnabled( Options::MoveOp, active_popup_client->isMovable() );
169 popup->setItemEnabled( Options::MaximizeOp, active_popup_client->isMaximizable() );
170 popup->setItemChecked( Options::MaximizeOp, active_popup_client->maximizeMode() == Client::MaximizeFull );
172 popup->setItemChecked( Options::ShadeOp, active_popup_client->shadeMode() != ShadeNone );
173 popup->setItemEnabled( Options::ShadeOp, active_popup_client->isShadeable());
174 advanced_popup->setItemChecked( Options::KeepAboveOp, active_popup_client->keepAbove() );
175 advanced_popup->setItemChecked( Options::KeepBelowOp, active_popup_client->keepBelow() );
176 advanced_popup->setItemChecked( Options::FullScreenOp, active_popup_client->isFullScreen() );
177 advanced_popup->setItemEnabled( Options::FullScreenOp, active_popup_client->userCanSetFullScreen() );
178 advanced_popup->setItemEnabled( Options::SuspendWindowOp, active_popup_client->isSuspendable() );
179 advanced_popup->setItemEnabled( Options::ResumeWindowOp, active_popup_client->isResumeable() );
180 advanced_popup->setItemChecked( Options::NoBorderOp, active_popup_client->noBorder() );
181 advanced_popup->setItemEnabled( Options::NoBorderOp, active_popup_client->userCanSetNoBorder() );
183 advanced_popup->setItemEnabled( Options::ShadowOp, (options->shadowWindowType(active_popup_client->windowType()) && options->shadowEnabled(active_popup_client->isActive())) );
184 advanced_popup->setItemChecked( Options::ShadowOp, active_popup_client->isShadowed() );
186 popup->setItemEnabled( Options::MinimizeOp, active_popup_client->isMinimizable() );
187 popup->setItemEnabled( Options::CloseOp, active_popup_client->isCloseable() );
188 if (options->useTranslucency)
190 transSlider->setValue(100-active_popup_client->opacityPercentage());
191 setTransButtonText(100-active_popup_client->opacityPercentage());
196 void Workspace::initDesktopPopup()
201 desk_popup =
new TQPopupMenu( popup );
202 desk_popup->setCheckable( TRUE );
203 desk_popup->setFont(TDEGlobalSettings::menuFont());
204 connect( desk_popup, TQT_SIGNAL( activated(
int) ),
205 this, TQT_SLOT( slotSendToDesktop(
int) ) );
206 connect( desk_popup, TQT_SIGNAL( aboutToShow() ),
207 this, TQT_SLOT( desktopPopupAboutToShow() ) );
209 popup->insertItem(i18n(
"To &Desktop"), desk_popup, -1, desk_popup_index );
216 void Workspace::desktopPopupAboutToShow()
222 desk_popup->insertItem( i18n(
"&All Desktops"), 0 );
223 if ( active_popup_client && active_popup_client->isOnAllDesktops() )
224 desk_popup->setItemChecked( 0, TRUE );
225 desk_popup->insertSeparator( -1 );
228 for (
int i = 1; i <= numberOfDesktops(); i++ )
230 TQString basic_name(
"%1 %2");
233 basic_name.prepend(
'&');
235 id = desk_popup->insertItem(
238 .arg( desktopName(i).replace(
'&',
"&&" )),
240 if ( active_popup_client &&
241 !active_popup_client->isOnAllDesktops() && active_popup_client->desktop() == i )
242 desk_popup->setItemChecked(
id, TRUE );
246 void Workspace::closeActivePopup()
250 active_popup->close();
252 active_popup_client = NULL;
259 void Workspace::initShortcuts()
261 keys =
new TDEGlobalAccel(
this );
264 disable_shortcuts_keys =
new TDEGlobalAccel(
this );
265 disable_shortcuts_keys->disableBlocking(
true );
267 #include "twinbindings.cpp"
271 void Workspace::readShortcuts()
273 keys->readSettings();
274 disable_shortcuts_keys->readSettings();
276 cutWalkThroughDesktops = keys->shortcut(
"Walk Through Desktops");
277 cutWalkThroughDesktopsReverse = keys->shortcut(
"Walk Through Desktops (Reverse)");
278 cutWalkThroughDesktopList = keys->shortcut(
"Walk Through Desktop List");
279 cutWalkThroughDesktopListReverse = keys->shortcut(
"Walk Through Desktop List (Reverse)");
280 cutWalkThroughWindows = keys->shortcut(
"Walk Through Windows");
281 cutWalkThroughWindowsReverse = keys->shortcut(
"Walk Through Windows (Reverse)");
282 cutWalkThroughApps = keys->shortcut(
"Walk Through Windows of Same Application");
283 cutWalkThroughAppsReverse = keys->shortcut(
"Walk Through Windows of Same Application (Reverse)");
285 keys->updateConnections();
286 disable_shortcuts_keys->updateConnections();
294 void Workspace::setupWindowShortcut( Client* c )
296 assert( client_keys_dialog == NULL );
297 keys->suspend(
true );
298 disable_shortcuts_keys->suspend(
true );
299 client_keys->suspend(
true );
300 client_keys_dialog =
new ShortcutDialog( c->shortcut());
301 client_keys_client = c;
302 connect( client_keys_dialog, TQT_SIGNAL( dialogDone(
bool )), TQT_SLOT( setupWindowShortcutDone(
bool )));
303 TQRect r = clientArea( ScreenArea, c );
304 TQSize size = client_keys_dialog->sizeHint();
305 TQPoint pos = c->pos() + c->clientPos();
306 if( pos.x() + size.width() >= r.right())
307 pos.setX( r.right() - size.width());
308 if( pos.y() + size.height() >= r.bottom())
309 pos.setY( r.bottom() - size.height());
310 client_keys_dialog->move( pos );
311 client_keys_dialog->show();
312 active_popup = client_keys_dialog;
313 active_popup_client = c;
316 void Workspace::setupWindowShortcutDone(
bool ok )
318 keys->suspend(
false );
319 disable_shortcuts_keys->suspend(
false );
320 client_keys->suspend(
false );
323 client_keys_client->setShortcut( TDEShortcut( client_keys_dialog->shortcut()).toString());
326 delete client_keys_dialog;
327 client_keys_dialog = NULL;
328 client_keys_client = NULL;
331 void Workspace::clientShortcutUpdated( Client* c )
333 TQString key = TQString::number( c->window());
334 client_keys->remove( key );
335 if( !c->shortcut().isNull())
337 client_keys->insert( key, key );
338 client_keys->setShortcut( key, c->shortcut());
339 client_keys->setSlot( key, c, TQT_SLOT( shortcutActivated()));
340 client_keys->setActionEnabled( key,
true );
342 client_keys->updateConnections();
345 void Workspace::clientPopupActivated(
int id )
347 WindowOperation op =
static_cast< WindowOperation
>( id );
348 Client* c = active_popup_client ? active_popup_client : active_client;
353 if( !c->isFullScreen() && c->userCanSetFullScreen())
354 type =
"fullscreenaltf3";
357 if( !c->noBorder() && c->userCanSetNoBorder())
358 type =
"noborderaltf3";
364 helperDialog( type, c );
365 performWindowOperation( c, op );
369 void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
374 if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp )
375 TQCursor::setPos( c->geometry().center() );
376 if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp )
377 TQCursor::setPos( c->geometry().bottomRight());
380 case Options::MoveOp:
381 c->performMouseCommand( Options::MouseMove, TQCursor::pos() );
383 case Options::UnrestrictedMoveOp:
384 c->performMouseCommand( Options::MouseUnrestrictedMove, TQCursor::pos() );
386 case Options::ResizeOp:
387 c->performMouseCommand( Options::MouseResize, TQCursor::pos() );
389 case Options::UnrestrictedResizeOp:
390 c->performMouseCommand( Options::MouseUnrestrictedResize, TQCursor::pos() );
392 case Options::CloseOp:
395 case Options::MaximizeOp:
396 c->maximize( c->maximizeMode() == Client::MaximizeFull
397 ? Client::MaximizeRestore : Client::MaximizeFull );
399 case Options::HMaximizeOp:
400 c->maximize( c->maximizeMode() ^ Client::MaximizeHorizontal );
402 case Options::VMaximizeOp:
403 c->maximize( c->maximizeMode() ^ Client::MaximizeVertical );
405 case Options::RestoreOp:
406 c->maximize( Client::MaximizeRestore );
408 case Options::MinimizeOp:
411 case Options::ShadeOp:
412 c->performMouseCommand( Options::MouseShade, TQCursor::pos());
414 case Options::ShadowOp:
415 c->setShadowed( !c->isShadowed() );
417 case Options::OnAllDesktopsOp:
418 c->setOnAllDesktops( !c->isOnAllDesktops() );
420 case Options::FullScreenOp:
421 c->setFullScreen( !c->isFullScreen(), true );
423 case Options::NoBorderOp:
424 c->setUserNoBorder( !c->isUserNoBorder());
426 case Options::KeepAboveOp:
428 StackingUpdatesBlocker blocker(
this );
429 bool was = c->keepAbove();
430 c->setKeepAbove( !c->keepAbove() );
431 if( was && !c->keepAbove())
435 case Options::KeepBelowOp:
437 StackingUpdatesBlocker blocker(
this );
438 bool was = c->keepBelow();
439 c->setKeepBelow( !c->keepBelow() );
440 if( was && !c->keepBelow())
444 case Options::OperationsOp:
445 c->performMouseCommand( Options::MouseShade, TQCursor::pos());
447 case Options::SuspendWindowOp:
450 case Options::ResumeWindowOp:
453 case Options::WindowRulesOp:
454 editWindowRules( c,
false );
456 case Options::ApplicationRulesOp:
457 editWindowRules( c,
true );
459 case Options::SetupWindowShortcutOp:
460 setupWindowShortcut( c );
462 case Options::LowerOp:
478 case Options::MouseRaise:
479 workspace()->raiseClient(
this );
481 case Options::MouseLower:
482 workspace()->lowerClient(
this );
484 case Options::MouseShade :
488 case Options::MouseSetShade:
489 setShade( ShadeNormal );
492 case Options::MouseUnsetShade:
493 setShade( ShadeNone );
496 case Options::MouseOperationsMenu:
497 if ( isActive() && options->clickRaise )
499 workspace()->showWindowMenu( globalPos,
this );
501 case Options::MouseToggleRaiseAndLower:
502 workspace()->raiseOrLowerClient(
this );
504 case Options::MouseActivateAndRaise:
506 workspace()->takeActivity(
this, ActivityFocus | ActivityRaise, handled && replay );
507 workspace()->setActiveScreenMouse( globalPos );
509 case Options::MouseActivateAndLower:
510 workspace()->requestFocus(
this );
511 workspace()->lowerClient(
this );
512 workspace()->setActiveScreenMouse( globalPos );
514 case Options::MouseActivate:
516 workspace()->takeActivity(
this, ActivityFocus, handled && replay );
517 workspace()->setActiveScreenMouse( globalPos );
519 case Options::MouseActivateRaiseAndPassClick:
520 workspace()->takeActivity(
this, ActivityFocus | ActivityRaise, handled );
521 workspace()->setActiveScreenMouse( globalPos );
524 case Options::MouseActivateAndPassClick:
525 workspace()->takeActivity(
this, ActivityFocus, handled );
526 workspace()->setActiveScreenMouse( globalPos );
529 case Options::MouseActivateRaiseAndMove:
530 case Options::MouseActivateRaiseAndUnrestrictedMove:
531 workspace()->raiseClient(
this );
532 workspace()->requestFocus(
this );
533 workspace()->setActiveScreenMouse( globalPos );
534 if( options->moveMode == Options::Transparent &&
isMovable())
535 move_faked_activity = workspace()->fakeRequestedActivity(
this );
537 case Options::MouseMove:
538 case Options::MouseUnrestrictedMove:
543 finishMoveResize(
false );
544 mode = PositionCenter;
546 moveOffset = TQPoint( globalPos.x() - x(), globalPos.y() - y());
547 invertedMoveOffset = rect().bottomRight() - moveOffset;
548 unrestrictedMoveResize = ( command == Options::MouseActivateRaiseAndUnrestrictedMove
549 || command == Options::MouseUnrestrictedMove );
551 if( !startMoveResize())
558 case Options::MouseResize:
559 case Options::MouseUnrestrictedResize:
564 finishMoveResize(
false );
566 moveOffset = TQPoint( globalPos.x() - x(), globalPos.y() - y());
567 int x = moveOffset.x(), y = moveOffset.y();
568 bool left = x < width() / 3;
569 bool right = x >= 2 * width() / 3;
570 bool top = y < height() / 3;
571 bool bot = y >= 2 * height() / 3;
573 mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
575 mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
577 mode = (x < width() / 2) ? PositionLeft : PositionRight;
578 invertedMoveOffset = rect().bottomRight() - moveOffset;
579 unrestrictedMoveResize = ( command == Options::MouseUnrestrictedResize );
581 if( !startMoveResize())
588 case Options::MouseMaximize:
589 maximize( Client::MaximizeFull );
591 case Options::MouseRestore:
592 maximize( Client::MaximizeRestore );
594 case Options::MouseMinimize:
597 case Options::MouseAbove:
599 StackingUpdatesBlocker blocker( workspace());
601 setKeepBelow(
false );
603 setKeepAbove(
true );
606 case Options::MouseBelow:
608 StackingUpdatesBlocker blocker( workspace());
610 setKeepAbove(
false );
612 setKeepBelow(
true );
615 case Options::MousePreviousDesktop:
616 workspace()->windowToPreviousDesktop(
this );
618 case Options::MouseNextDesktop:
619 workspace()->windowToNextDesktop(
this );
621 case Options::MouseOpacityMore:
622 if (opacity_ < 0xFFFFFFFF)
624 if (opacity_ < 0xF3333333)
626 setOpacity(TRUE, opacity_ + 0xCCCCCCC);
627 custom_opacity =
true;
631 setOpacity(FALSE, 0xFFFFFFFF);
632 custom_opacity =
false;
636 case Options::MouseOpacityLess:
639 setOpacity(TRUE, (opacity_ > 0xCCCCCCC) ? opacity_ - 0xCCCCCCC : 0);
640 custom_opacity =
true;
643 case Options::MouseNothing:
651 void Workspace::showWindowMenuAt(
unsigned long,
int,
int )
653 slotWindowOperations();
656 void Workspace::slotActivateAttentionWindow()
658 if( attention_chain.count() > 0 )
659 activateClient( attention_chain.first());
662 void Workspace::slotSwitchDesktopNext()
664 int d = currentDesktop() + 1;
665 if ( d > numberOfDesktops() )
667 if ( options->rollOverDesktops )
676 setCurrentDesktop(d);
679 void Workspace::slotSwitchDesktopPrevious()
681 int d = currentDesktop() - 1;
684 if ( options->rollOverDesktops )
685 d = numberOfDesktops();
689 setCurrentDesktop(d);
692 void Workspace::slotSwitchDesktopRight()
694 int desktop = desktopToRight( currentDesktop());
695 if( desktop == currentDesktop())
697 setCurrentDesktop( desktop );
700 void Workspace::slotSwitchDesktopLeft()
702 int desktop = desktopToLeft( currentDesktop());
703 if( desktop == currentDesktop())
705 setCurrentDesktop( desktop );
708 void Workspace::slotSwitchDesktopUp()
710 int desktop = desktopUp( currentDesktop());
711 if( desktop == currentDesktop())
713 setCurrentDesktop( desktop );
716 void Workspace::slotSwitchDesktopDown()
718 int desktop = desktopDown( currentDesktop());
719 if( desktop == currentDesktop())
721 setCurrentDesktop( desktop );
724 void Workspace::slotSwitchToDesktop(
int i )
726 setCurrentDesktop( i );
730 void Workspace::slotWindowToDesktop(
int i )
732 Client* c = active_popup_client ? active_popup_client : active_client;
733 if( i >= 1 && i <= numberOfDesktops() && c
737 sendClientToDesktop( c, i,
true );
740 void Workspace::slotSwitchToScreen(
int i )
742 setCurrentScreen( i );
745 void Workspace::slotSwitchToNextScreen()
747 slotSwitchToScreen(( activeScreen() + 1 ) % numScreens());
750 void Workspace::slotWindowToScreen(
int i )
752 Client* c = active_popup_client ? active_popup_client : active_client;
753 if( i >= 0 && i <= numScreens() && c
758 sendClientToScreen( c, i );
762 void Workspace::slotWindowToNextScreen()
764 Client* c = active_popup_client ? active_popup_client : active_client;
770 sendClientToScreen( c, ( c->screen() + 1 ) % numScreens());
777 void Workspace::slotWindowMaximize()
779 Client* c = active_popup_client ? active_popup_client : active_client;
781 performWindowOperation( c, Options::MaximizeOp );
787 void Workspace::slotWindowMaximizeVertical()
789 Client* c = active_popup_client ? active_popup_client : active_client;
791 performWindowOperation( c, Options::VMaximizeOp );
797 void Workspace::slotWindowMaximizeHorizontal()
799 Client* c = active_popup_client ? active_popup_client : active_client;
801 performWindowOperation( c, Options::HMaximizeOp );
808 void Workspace::slotWindowMinimize()
810 Client* c = active_popup_client ? active_popup_client : active_client;
811 performWindowOperation( c, Options::MinimizeOp );
817 void Workspace::slotWindowShade()
819 Client* c = active_popup_client ? active_popup_client : active_client;
820 performWindowOperation( c, Options::ShadeOp );
826 void Workspace::slotWindowRaise()
828 Client* c = active_popup_client ? active_popup_client : active_client;
836 void Workspace::slotWindowLower()
838 Client* c = active_popup_client ? active_popup_client : active_client;
846 void Workspace::slotWindowRaiseOrLower()
848 Client* c = active_popup_client ? active_popup_client : active_client;
850 raiseOrLowerClient( c );
853 void Workspace::slotWindowOnAllDesktops()
855 Client* c = active_popup_client ? active_popup_client : active_client;
857 c->setOnAllDesktops( !c->isOnAllDesktops());
860 void Workspace::slotWindowFullScreen()
862 Client* c = active_popup_client ? active_popup_client : active_client;
864 performWindowOperation( c, Options::FullScreenOp );
867 void Workspace::slotWindowNoBorder()
869 Client* c = active_popup_client ? active_popup_client : active_client;
871 performWindowOperation( c, Options::NoBorderOp );
874 void Workspace::slotWindowAbove()
876 Client* c = active_popup_client ? active_popup_client : active_client;
878 performWindowOperation( c, Options::KeepAboveOp );
881 void Workspace::slotWindowBelow()
883 Client* c = active_popup_client ? active_popup_client : active_client;
885 performWindowOperation( c, Options::KeepBelowOp );
887 void Workspace::slotSetupWindowShortcut()
889 Client* c = active_popup_client ? active_popup_client : active_client;
891 performWindowOperation( c, Options::SetupWindowShortcutOp );
897 void Workspace::slotWindowToNextDesktop()
899 windowToNextDesktop( active_popup_client ? active_popup_client : active_client );
902 void Workspace::windowToNextDesktop( Client* c )
904 int d = currentDesktop() + 1;
905 if ( d > numberOfDesktops() )
907 if (c && !c->isDesktop()
908 && !c->isDock() && !c->isTopMenu())
910 setClientIsMoving( c );
911 setCurrentDesktop( d );
912 setClientIsMoving( NULL );
919 void Workspace::slotWindowToPreviousDesktop()
921 windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client );
924 void Workspace::windowToPreviousDesktop( Client* c )
926 int d = currentDesktop() - 1;
928 d = numberOfDesktops();
929 if (c && !c->isDesktop()
930 && !c->isDock() && !c->isTopMenu())
932 setClientIsMoving( c );
933 setCurrentDesktop( d );
934 setClientIsMoving( NULL );
938 void Workspace::slotWindowToDesktopRight()
940 int d = desktopToRight( currentDesktop());
941 if( d == currentDesktop())
943 Client* c = active_popup_client ? active_popup_client : active_client;
944 if (c && !c->isDesktop()
945 && !c->isDock() && !c->isTopMenu())
947 setClientIsMoving( c );
948 setCurrentDesktop( d );
949 setClientIsMoving( NULL );
953 void Workspace::slotWindowToDesktopLeft()
955 int d = desktopToLeft( currentDesktop());
956 if( d == currentDesktop())
958 Client* c = active_popup_client ? active_popup_client : active_client;
959 if (c && !c->isDesktop()
960 && !c->isDock() && !c->isTopMenu())
962 setClientIsMoving( c );
963 setCurrentDesktop( d );
964 setClientIsMoving( NULL );
968 void Workspace::slotWindowToDesktopUp()
970 int d = desktopUp( currentDesktop());
971 if( d == currentDesktop())
973 Client* c = active_popup_client ? active_popup_client : active_client;
974 if (c && !c->isDesktop()
975 && !c->isDock() && !c->isTopMenu())
977 setClientIsMoving( c );
978 setCurrentDesktop( d );
979 setClientIsMoving( NULL );
983 void Workspace::slotWindowToDesktopDown()
985 int d = desktopDown( currentDesktop());
986 if( d == currentDesktop())
988 Client* c = active_popup_client ? active_popup_client : active_client;
989 if (c && !c->isDesktop()
990 && !c->isDock() && !c->isTopMenu())
992 setClientIsMoving( c );
993 setCurrentDesktop( d );
994 setClientIsMoving( NULL );
1002 void Workspace::slotKillWindow()
1004 KillWindow kill(
this );
1011 void Workspace::slotSuspendWindow()
1013 active_popup_client->suspendWindow();
1019 void Workspace::slotResumeWindow()
1021 active_popup_client->resumeWindow();
1029 void Workspace::slotSendToDesktop(
int desk )
1031 if ( !active_popup_client )
1035 active_popup_client->setOnAllDesktops( !active_popup_client->isOnAllDesktops());
1039 sendClientToDesktop( active_popup_client, desk,
false );
1046 void Workspace::slotWindowOperations()
1048 if ( !active_client )
1050 TQPoint pos = active_client->pos() + active_client->clientPos();
1051 showWindowMenu( pos.x(), pos.y(), active_client );
1054 void Workspace::showWindowMenu(
const TQRect &pos, Client* cl )
1056 if (!kapp->authorizeTDEAction(
"twin_rmb"))
1060 if( active_popup_client != NULL )
1062 if ( cl->isDesktop()
1065 || cl->isModalSystemNotification())
1068 active_popup_client = cl;
1069 TQPopupMenu* p = clientPopup();
1072 int y = pos.bottom();
1074 p->exec( TQPoint( x, y ) );
1077 TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop());
1078 clientPopupAboutToShow();
1079 int popupHeight = p->sizeHint().height();
1080 if (y + popupHeight < area.height())
1081 p->exec( TQPoint( x, y ) );
1083 p->exec( TQPoint( x, pos.top() - popupHeight ) );
1086 if( active_popup == p )
1093 void Workspace::slotWindowClose()
1095 if ( tab_box->isVisible())
1097 Client* c = active_popup_client ? active_popup_client : active_client;
1098 performWindowOperation( c, Options::CloseOp );
1104 void Workspace::slotWindowMove()
1106 Client* c = active_popup_client ? active_popup_client : active_client;
1107 performWindowOperation( c, Options::UnrestrictedMoveOp );
1113 void Workspace::slotWindowResize()
1115 Client* c = active_popup_client ? active_popup_client : active_client;
1116 performWindowOperation( c, Options::UnrestrictedResizeOp );
1119 void Client::setShortcut(
const TQString& _cut )
1121 TQString cut = rules()->checkShortcut( _cut );
1123 return setShortcutInternal( TDEShortcut());
1127 if( !cut.contains(
'(' ) && !cut.contains(
')' ) && !cut.contains(
' ' ))
1129 if( workspace()->shortcutAvailable( TDEShortcut( cut ),
this ))
1130 setShortcutInternal( TDEShortcut( cut ));
1132 setShortcutInternal( TDEShortcut());
1135 TQValueList< TDEShortcut > keys;
1136 TQStringList groups = TQStringList::split(
' ', cut );
1137 for( TQStringList::ConstIterator it = groups.begin();
1141 TQRegExp reg(
"(.*\\+)\\((.*)\\)" );
1142 if( reg.search( *it ) > -1 )
1144 TQString base = reg.cap( 1 );
1145 TQString list = reg.cap( 2 );
1146 for(
unsigned int i = 0;
1150 TDEShortcut c( base + list[ i ] );
1156 for( TQValueList< TDEShortcut >::ConstIterator it = keys.begin();
1160 if( _shortcut == *it )
1163 for( TQValueList< TDEShortcut >::ConstIterator it = keys.begin();
1167 if( workspace()->shortcutAvailable( *it,
this ))
1169 setShortcutInternal( *it );
1173 setShortcutInternal( TDEShortcut());
1176 void Client::setShortcutInternal(
const TDEShortcut& cut )
1178 if( _shortcut == cut )
1182 workspace()->clientShortcutUpdated(
this );
1185 bool Workspace::shortcutAvailable(
const TDEShortcut& cut, Client* ignore )
const
1188 for( ClientList::ConstIterator it = clients.begin();
1189 it != clients.end();
1192 if( (*it) != ignore && (*it)->shortcut() == cut )