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, TQ_SIGNAL( aboutToShow() ),
this, TQ_SLOT( clientPopupAboutToShow() ) );
55 connect( popup, TQ_SIGNAL( activated(
int) ),
this, TQ_SLOT( clientPopupActivated(
int) ) );
57 advanced_popup =
new TQPopupMenu( popup );
58 advanced_popup->setCheckable( TRUE );
59 advanced_popup->setFont(TDEGlobalSettings::menuFont());
60 connect( advanced_popup, TQ_SIGNAL( activated(
int) ),
this, TQ_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, TQt::Horizontal, transBox,
"transSlider");
87 TQToolTip::add(transSlider, i18n(
"Slide this to set the window's opacity"));
88 connect(transButton, TQ_SIGNAL(clicked()), TQ_SLOT(resetClientOpacity()));
89 connect(transButton, TQ_SIGNAL(clicked()), trans_popup, TQ_SLOT(hide()));
90 connect(transSlider, TQ_SIGNAL(valueChanged(
int)), TQ_SLOT(setTransButtonText(
int)));
91 connect(transSlider, TQ_SIGNAL(valueChanged(
int)),
this, TQ_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, TQ_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, TQ_SIGNAL( activated(
int) ),
205 this, TQ_SLOT( slotSendToDesktop(
int) ) );
206 connect( desk_popup, TQ_SIGNAL( aboutToShow() ),
207 this, TQ_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, TQ_SIGNAL( dialogDone(
bool )), TQ_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, TQ_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:
650 void Workspace::showWindowMenuAt(
unsigned long window,
int x,
int y )
653 if ((client = findClient(WindowMatchPredicate((WId)window))))
654 showWindowMenu( x, y, client );
657 void Workspace::showWindowMenu(
unsigned long window )
660 if ((client = findClient(WindowMatchPredicate((WId)window))))
662 TQPoint pos = client->pos() + client->clientPos();
663 showWindowMenu( pos, client );
667 void Workspace::tileWindowToBorder(
unsigned long w1,
int location) {
668 if (location < ActiveTop || location >= ACTIVE_BORDER_COUNT)
return;
670 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
673 c1->tileToBorder((ActiveBorder)location);
676 void Workspace::tileTwoWindowsHorizontally(
unsigned long w1,
unsigned long w2) {
677 if (w1 == w2)
return;
679 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
680 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
681 if (!c1 || !c2)
return;
683 c1->tileToBorder(ActiveTop);
684 c2->tileToBorder(ActiveBottom);
687 void Workspace::tileTwoWindowsVertically(
unsigned long w1,
unsigned long w2) {
688 if (w1 == w2)
return;
690 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
691 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
692 if (!c1 || !c2)
return;
694 c1->tileToBorder(ActiveLeft);
695 c2->tileToBorder(ActiveRight);
698 void Workspace::tileFourWindowsInGrid(
unsigned long w1,
unsigned long w2,
unsigned long w3,
unsigned long w4) {
699 if (w1 == w2 || w1 == w3 || w1 == w4 || w2 == w3 || w2 == w4 || w3 == w4)
702 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
703 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
704 Client *c3 = findClient(WindowMatchPredicate((WId)w3));
705 Client *c4 = findClient(WindowMatchPredicate((WId)w4));
706 if (!c1 || !c2 || !c3 || !c4)
return;
708 c1->tileToBorder(ActiveTopLeft);
709 c2->tileToBorder(ActiveTopRight);
710 c3->tileToBorder(ActiveBottomLeft);
711 c4->tileToBorder(ActiveBottomRight);
714 void Workspace::slotActivateAttentionWindow()
716 if( attention_chain.count() > 0 )
717 activateClient( attention_chain.first());
720 void Workspace::slotSwitchDesktopNext()
722 int d = currentDesktop() + 1;
723 if ( d > numberOfDesktops() )
725 if ( options->rollOverDesktops )
734 setCurrentDesktop(d);
737 void Workspace::slotSwitchDesktopPrevious()
739 int d = currentDesktop() - 1;
742 if ( options->rollOverDesktops )
743 d = numberOfDesktops();
747 setCurrentDesktop(d);
750 void Workspace::slotSwitchDesktopRight()
752 int desktop = desktopToRight( currentDesktop());
753 if( desktop == currentDesktop())
755 setCurrentDesktop( desktop );
758 void Workspace::slotSwitchDesktopLeft()
760 int desktop = desktopToLeft( currentDesktop());
761 if( desktop == currentDesktop())
763 setCurrentDesktop( desktop );
766 void Workspace::slotSwitchDesktopUp()
768 int desktop = desktopUp( currentDesktop());
769 if( desktop == currentDesktop())
771 setCurrentDesktop( desktop );
774 void Workspace::slotSwitchDesktopDown()
776 int desktop = desktopDown( currentDesktop());
777 if( desktop == currentDesktop())
779 setCurrentDesktop( desktop );
782 void Workspace::slotSwitchToDesktop(
int i )
784 setCurrentDesktop( i );
788 void Workspace::slotWindowToDesktop(
int i )
790 Client* c = active_popup_client ? active_popup_client : active_client;
791 if( i >= 1 && i <= numberOfDesktops() && c
795 sendClientToDesktop( c, i,
true );
798 void Workspace::slotSwitchToScreen(
int i )
800 setCurrentScreen( i );
803 void Workspace::slotSwitchToNextScreen()
805 slotSwitchToScreen(( activeScreen() + 1 ) % numScreens());
808 void Workspace::slotWindowToScreen(
int i )
810 Client* c = active_popup_client ? active_popup_client : active_client;
811 if( i >= 0 && i <= numScreens() && c
816 sendClientToScreen( c, i );
820 void Workspace::slotWindowToNextScreen()
822 Client* c = active_popup_client ? active_popup_client : active_client;
828 sendClientToScreen( c, ( c->screen() + 1 ) % numScreens());
835 void Workspace::slotWindowMaximize()
837 Client* c = active_popup_client ? active_popup_client : active_client;
839 performWindowOperation( c, Options::MaximizeOp );
845 void Workspace::slotWindowMaximizeVertical()
847 Client* c = active_popup_client ? active_popup_client : active_client;
849 performWindowOperation( c, Options::VMaximizeOp );
855 void Workspace::slotWindowMaximizeHorizontal()
857 Client* c = active_popup_client ? active_popup_client : active_client;
859 performWindowOperation( c, Options::HMaximizeOp );
866 void Workspace::slotWindowMinimize()
868 Client* c = active_popup_client ? active_popup_client : active_client;
869 performWindowOperation( c, Options::MinimizeOp );
875 void Workspace::slotWindowShade()
877 Client* c = active_popup_client ? active_popup_client : active_client;
878 performWindowOperation( c, Options::ShadeOp );
884 void Workspace::slotWindowRaise()
886 Client* c = active_popup_client ? active_popup_client : active_client;
894 void Workspace::slotWindowLower()
896 Client* c = active_popup_client ? active_popup_client : active_client;
904 void Workspace::slotWindowRaiseOrLower()
906 Client* c = active_popup_client ? active_popup_client : active_client;
908 raiseOrLowerClient( c );
911 void Workspace::slotWindowOnAllDesktops()
913 Client* c = active_popup_client ? active_popup_client : active_client;
915 c->setOnAllDesktops( !c->isOnAllDesktops());
918 void Workspace::slotWindowFullScreen()
920 Client* c = active_popup_client ? active_popup_client : active_client;
922 performWindowOperation( c, Options::FullScreenOp );
925 void Workspace::slotWindowNoBorder()
927 Client* c = active_popup_client ? active_popup_client : active_client;
929 performWindowOperation( c, Options::NoBorderOp );
932 void Workspace::slotWindowAbove()
934 Client* c = active_popup_client ? active_popup_client : active_client;
936 performWindowOperation( c, Options::KeepAboveOp );
939 void Workspace::slotWindowBelow()
941 Client* c = active_popup_client ? active_popup_client : active_client;
943 performWindowOperation( c, Options::KeepBelowOp );
945 void Workspace::slotSetupWindowShortcut()
947 Client* c = active_popup_client ? active_popup_client : active_client;
949 performWindowOperation( c, Options::SetupWindowShortcutOp );
955 void Workspace::slotWindowToNextDesktop()
957 windowToNextDesktop( active_popup_client ? active_popup_client : active_client );
960 void Workspace::windowToNextDesktop( Client* c )
962 int d = currentDesktop() + 1;
963 if ( d > numberOfDesktops() )
965 if (c && !c->isDesktop()
966 && !c->isDock() && !c->isTopMenu())
968 setClientIsMoving( c );
969 setCurrentDesktop( d );
970 setClientIsMoving( NULL );
977 void Workspace::slotWindowToPreviousDesktop()
979 windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client );
982 void Workspace::windowToPreviousDesktop( Client* c )
984 int d = currentDesktop() - 1;
986 d = numberOfDesktops();
987 if (c && !c->isDesktop()
988 && !c->isDock() && !c->isTopMenu())
990 setClientIsMoving( c );
991 setCurrentDesktop( d );
992 setClientIsMoving( NULL );
996 void Workspace::slotWindowToDesktopRight()
998 int d = desktopToRight( currentDesktop());
999 if( d == currentDesktop())
1001 Client* c = active_popup_client ? active_popup_client : active_client;
1002 if (c && !c->isDesktop()
1003 && !c->isDock() && !c->isTopMenu())
1005 setClientIsMoving( c );
1006 setCurrentDesktop( d );
1007 setClientIsMoving( NULL );
1011 void Workspace::slotWindowToDesktopLeft()
1013 int d = desktopToLeft( currentDesktop());
1014 if( d == currentDesktop())
1016 Client* c = active_popup_client ? active_popup_client : active_client;
1017 if (c && !c->isDesktop()
1018 && !c->isDock() && !c->isTopMenu())
1020 setClientIsMoving( c );
1021 setCurrentDesktop( d );
1022 setClientIsMoving( NULL );
1026 void Workspace::slotWindowToDesktopUp()
1028 int d = desktopUp( currentDesktop());
1029 if( d == currentDesktop())
1031 Client* c = active_popup_client ? active_popup_client : active_client;
1032 if (c && !c->isDesktop()
1033 && !c->isDock() && !c->isTopMenu())
1035 setClientIsMoving( c );
1036 setCurrentDesktop( d );
1037 setClientIsMoving( NULL );
1041 void Workspace::slotWindowToDesktopDown()
1043 int d = desktopDown( currentDesktop());
1044 if( d == currentDesktop())
1046 Client* c = active_popup_client ? active_popup_client : active_client;
1047 if (c && !c->isDesktop()
1048 && !c->isDock() && !c->isTopMenu())
1050 setClientIsMoving( c );
1051 setCurrentDesktop( d );
1052 setClientIsMoving( NULL );
1060 void Workspace::slotKillWindow()
1062 KillWindow kill(
this );
1069 void Workspace::slotSuspendWindow()
1071 active_popup_client->suspendWindow();
1077 void Workspace::slotResumeWindow()
1079 active_popup_client->resumeWindow();
1087 void Workspace::slotSendToDesktop(
int desk )
1089 if ( !active_popup_client )
1093 active_popup_client->setOnAllDesktops( !active_popup_client->isOnAllDesktops());
1097 sendClientToDesktop( active_popup_client, desk,
false );
1104 void Workspace::slotWindowOperations()
1106 if ( !active_client )
1108 TQPoint pos = active_client->pos() + active_client->clientPos();
1109 showWindowMenu( pos.x(), pos.y(), active_client );
1112 void Workspace::showWindowMenu(
const TQRect &pos, Client* cl )
1114 if (!kapp->authorizeTDEAction(
"twin_rmb"))
1118 if( active_popup_client != NULL )
1120 if ( cl->isDesktop()
1123 || cl->isModalSystemNotification())
1126 active_popup_client = cl;
1127 TQPopupMenu* p = clientPopup();
1130 int y = pos.bottom();
1131 clientPopupAboutToShow();
1133 TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop());
1134 TQSize hint = p->sizeHint();
1135 if (x < 0) x = area.right() - hint.width() + x;
1136 if (y < 0) y = area.bottom() - hint.height() + y;
1138 if (pos.bottom() == pos.top())
1139 p->exec( TQPoint( x, y ) );
1142 if (y + hint.height() < area.height())
1143 p->exec( TQPoint( x, y ) );
1145 p->exec( TQPoint( x, pos.top() - hint.height() ) );
1148 if( active_popup == p )
1155 void Workspace::slotWindowClose()
1157 if ( tab_box->isVisible())
1159 Client* c = active_popup_client ? active_popup_client : active_client;
1160 performWindowOperation( c, Options::CloseOp );
1166 void Workspace::slotWindowMove()
1168 Client* c = active_popup_client ? active_popup_client : active_client;
1169 performWindowOperation( c, Options::UnrestrictedMoveOp );
1175 void Workspace::slotWindowResize()
1177 Client* c = active_popup_client ? active_popup_client : active_client;
1178 performWindowOperation( c, Options::UnrestrictedResizeOp );
1181 void Client::setShortcut(
const TQString& _cut )
1183 TQString cut = rules()->checkShortcut( _cut );
1185 return setShortcutInternal( TDEShortcut());
1189 if( !cut.contains(
'(' ) && !cut.contains(
')' ) && !cut.contains(
' ' ))
1191 if( workspace()->shortcutAvailable( TDEShortcut( cut ),
this ))
1192 setShortcutInternal( TDEShortcut( cut ));
1194 setShortcutInternal( TDEShortcut());
1197 TQValueList< TDEShortcut > keys;
1198 TQStringList groups = TQStringList::split(
' ', cut );
1199 for( TQStringList::ConstIterator it = groups.begin();
1203 TQRegExp reg(
"(.*\\+)\\((.*)\\)" );
1204 if( reg.search( *it ) > -1 )
1206 TQString base = reg.cap( 1 );
1207 TQString list = reg.cap( 2 );
1208 for(
unsigned int i = 0;
1212 TDEShortcut c( base + list[ i ] );
1218 for( TQValueList< TDEShortcut >::ConstIterator it = keys.begin();
1222 if( _shortcut == *it )
1225 for( TQValueList< TDEShortcut >::ConstIterator it = keys.begin();
1229 if( workspace()->shortcutAvailable( *it,
this ))
1231 setShortcutInternal( *it );
1235 setShortcutInternal( TDEShortcut());
1238 void Client::setShortcutInternal(
const TDEShortcut& cut )
1240 if( _shortcut == cut )
1244 workspace()->clientShortcutUpdated(
this );
1247 bool Workspace::shortcutAvailable(
const TDEShortcut& cut, Client* ignore )
const
1250 for( ClientList::ConstIterator it = clients.begin();
1251 it != clients.end();
1254 if( (*it) != ignore && (*it)->shortcut() == cut )
The Client class encapsulates a window decoration frame.
bool performMouseCommand(Options::MouseCommand, TQPoint globalPos, bool handled=false)
void minimize(bool avoid_animation=false)