21 #include <tqpushbutton.h>
23 #include <tqtooltip.h>
24 #include <tqpopupmenu.h>
25 #include <kglobalsettings.h>
26 #include <kiconloader.h>
29 #include <kglobalaccel.h>
30 #include <kapplication.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(KGlobalSettings::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(KGlobalSettings::menuFont());
60 connect( advanced_popup, TQT_SIGNAL( activated(
int) ),
this, TQT_SLOT( clientPopupActivated(
int) ) );
61 advanced_popup->insertItem( SmallIconSet(
"up" ),
62 i18n(
"Keep &Above Others")+
'\t'+keys->shortcut(
"Window Above Other Windows").seq(0).toString(), Options::KeepAboveOp );
63 advanced_popup->insertItem( SmallIconSet(
"down" ),
64 i18n(
"Keep &Below Others")+
'\t'+keys->shortcut(
"Window Below Other Windows").seq(0).toString(), Options::KeepBelowOp );
65 advanced_popup->insertItem( SmallIconSet(
"window_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->insertItem( SmallIconSet(
"wizard" ), i18n(
"&Special Window Settings..."), Options::WindowRulesOp );
72 advanced_popup->insertItem( SmallIconSet(
"wizard" ), i18n(
"&Special Application Settings..."), Options::ApplicationRulesOp );
74 popup->insertItem(i18n(
"Ad&vanced"), advanced_popup );
75 desk_popup_index = popup->count();
77 if (options->useTranslucency){
78 TQPopupMenu *trans_popup =
new TQPopupMenu( popup );
79 TQVBox *transBox =
new TQVBox(trans_popup);
80 transButton =
new TQPushButton(transBox,
"transButton");
81 TQToolTip::add(transButton, i18n(
"Reset opacity to default value"));
82 transSlider =
new TQSlider(0, 100, 1, 100, Qt::Horizontal, transBox,
"transSlider");
83 TQToolTip::add(transSlider, i18n(
"Slide this to set the window's opacity"));
84 connect(transButton, TQT_SIGNAL(clicked()), TQT_SLOT(resetClientOpacity()));
85 connect(transButton, TQT_SIGNAL(clicked()), trans_popup, TQT_SLOT(hide()));
86 connect(transSlider, TQT_SIGNAL(valueChanged(
int)), TQT_SLOT(setTransButtonText(
int)));
87 connect(transSlider, TQT_SIGNAL(valueChanged(
int)),
this, TQT_SLOT(setPopupClientOpacity(
int)));
89 trans_popup->insertItem(transBox);
90 popup->insertItem(i18n(
"&Opacity"), trans_popup );
93 popup->insertItem( SmallIconSet(
"move" ), i18n(
"&Move")+
'\t'+keys->shortcut(
"Window Move").seq(0).toString(), Options::MoveOp );
94 popup->insertItem( i18n(
"Re&size")+
'\t'+keys->shortcut(
"Window Resize").seq(0).toString(), Options::ResizeOp );
95 popup->insertItem( i18n(
"Mi&nimize")+
'\t'+keys->shortcut(
"Window Minimize").seq(0).toString(), Options::MinimizeOp );
96 popup->insertItem( i18n(
"Ma&ximize")+
'\t'+keys->shortcut(
"Window Maximize").seq(0).toString(), Options::MaximizeOp );
97 popup->insertItem( i18n(
"Sh&ade")+
'\t'+keys->shortcut(
"Window Shade").seq(0).toString(), Options::ShadeOp );
99 popup->insertSeparator();
101 if (!KGlobal::config()->isImmutable() &&
102 !kapp->authorizeControlModules(Workspace::configModules(
true)).isEmpty())
104 popup->insertItem(SmallIconSet(
"configure" ), i18n(
"Configur&e Window Behavior..."),
this, TQT_SLOT( configureWM() ));
105 popup->insertSeparator();
108 popup->insertItem( SmallIconSet(
"fileclose" ), i18n(
"&Close")+
'\t'+keys->shortcut(
"Window Close").seq(0).toString(), Options::CloseOp );
114 void Workspace::setPopupClientOpacity(
int value)
116 active_popup_client->setCustomOpacityFlag(
true);
118 value<100?active_popup_client->setOpacity(
true, (uint)((value/100.0)*0xffffffff)):active_popup_client->setOpacity(
false,0xffffffff);
121 void Workspace::setTransButtonText(
int value)
125 transButton->setText(
" 0 %");
126 else if (value >= 100 )
127 transButton->setText(
"100 %");
129 transButton->setText(
" "+TQString::number(value)+
" %");
131 transButton->setText(
" "+TQString::number(value)+
" %");
134 void Workspace::resetClientOpacity()
136 active_popup_client->setCustomOpacityFlag(
false);
137 active_popup_client->updateOpacity();
138 transSlider->setValue(100-active_popup_client->opacityPercentage());
139 setTransButtonText(100-active_popup_client->opacityPercentage());
148 void Workspace::clientPopupAboutToShow()
150 if ( !active_popup_client || !popup )
153 if ( numberOfDesktops() == 1 )
163 popup->setItemEnabled( Options::ResizeOp, active_popup_client->isResizable() );
164 popup->setItemEnabled( Options::MoveOp, active_popup_client->isMovable() );
165 popup->setItemEnabled( Options::MaximizeOp, active_popup_client->isMaximizable() );
166 popup->setItemChecked( Options::MaximizeOp, active_popup_client->maximizeMode() == Client::MaximizeFull );
168 popup->setItemChecked( Options::ShadeOp, active_popup_client->shadeMode() != ShadeNone );
169 popup->setItemEnabled( Options::ShadeOp, active_popup_client->isShadeable());
170 advanced_popup->setItemChecked( Options::KeepAboveOp, active_popup_client->keepAbove() );
171 advanced_popup->setItemChecked( Options::KeepBelowOp, active_popup_client->keepBelow() );
172 advanced_popup->setItemChecked( Options::FullScreenOp, active_popup_client->isFullScreen() );
173 advanced_popup->setItemEnabled( Options::FullScreenOp, active_popup_client->userCanSetFullScreen() );
174 advanced_popup->setItemChecked( Options::NoBorderOp, active_popup_client->noBorder() );
175 advanced_popup->setItemEnabled( Options::NoBorderOp, active_popup_client->userCanSetNoBorder() );
177 advanced_popup->setItemEnabled( Options::ShadowOp, (options->shadowWindowType(active_popup_client->windowType()) && options->shadowEnabled(active_popup_client->isActive())) );
178 advanced_popup->setItemChecked( Options::ShadowOp, active_popup_client->isShadowed() );
180 popup->setItemEnabled( Options::MinimizeOp, active_popup_client->isMinimizable() );
181 popup->setItemEnabled( Options::CloseOp, active_popup_client->isCloseable() );
182 if (options->useTranslucency)
184 transSlider->setValue(100-active_popup_client->opacityPercentage());
185 setTransButtonText(100-active_popup_client->opacityPercentage());
190 void Workspace::initDesktopPopup()
195 desk_popup =
new TQPopupMenu( popup );
196 desk_popup->setCheckable( TRUE );
197 desk_popup->setFont(KGlobalSettings::menuFont());
198 connect( desk_popup, TQT_SIGNAL( activated(
int) ),
199 this, TQT_SLOT( slotSendToDesktop(
int) ) );
200 connect( desk_popup, TQT_SIGNAL( aboutToShow() ),
201 this, TQT_SLOT( desktopPopupAboutToShow() ) );
203 popup->insertItem(i18n(
"To &Desktop"), desk_popup, -1, desk_popup_index );
210 void Workspace::desktopPopupAboutToShow()
216 desk_popup->insertItem( i18n(
"&All Desktops"), 0 );
217 if ( active_popup_client && active_popup_client->isOnAllDesktops() )
218 desk_popup->setItemChecked( 0, TRUE );
219 desk_popup->insertSeparator( -1 );
222 for (
int i = 1; i <= numberOfDesktops(); i++ )
224 TQString basic_name(
"%1 %2");
227 basic_name.prepend(
'&');
229 id = desk_popup->insertItem(
232 .arg( desktopName(i).replace(
'&',
"&&" )),
234 if ( active_popup_client &&
235 !active_popup_client->isOnAllDesktops() && active_popup_client->desktop() == i )
236 desk_popup->setItemChecked(
id, TRUE );
240 void Workspace::closeActivePopup()
244 active_popup->close();
246 active_popup_client = NULL;
253 void Workspace::initShortcuts()
255 keys =
new KGlobalAccel(
this );
258 disable_shortcuts_keys =
new KGlobalAccel(
this );
259 disable_shortcuts_keys->disableBlocking(
true );
261 #include "kwinbindings.cpp"
265 void Workspace::readShortcuts()
267 keys->readSettings();
268 disable_shortcuts_keys->readSettings();
270 cutWalkThroughDesktops = keys->shortcut(
"Walk Through Desktops");
271 cutWalkThroughDesktopsReverse = keys->shortcut(
"Walk Through Desktops (Reverse)");
272 cutWalkThroughDesktopList = keys->shortcut(
"Walk Through Desktop List");
273 cutWalkThroughDesktopListReverse = keys->shortcut(
"Walk Through Desktop List (Reverse)");
274 cutWalkThroughWindows = keys->shortcut(
"Walk Through Windows");
275 cutWalkThroughWindowsReverse = keys->shortcut(
"Walk Through Windows (Reverse)");
277 keys->updateConnections();
278 disable_shortcuts_keys->updateConnections();
286 void Workspace::setupWindowShortcut( Client* c )
288 assert( client_keys_dialog == NULL );
289 keys->suspend(
true );
290 disable_shortcuts_keys->suspend(
true );
291 client_keys->suspend(
true );
292 client_keys_dialog =
new ShortcutDialog( c->shortcut());
293 client_keys_client = c;
294 connect( client_keys_dialog, TQT_SIGNAL( dialogDone(
bool )), TQT_SLOT( setupWindowShortcutDone(
bool )));
295 TQRect r = clientArea( ScreenArea, c );
296 TQSize size = client_keys_dialog->sizeHint();
297 TQPoint pos = c->pos() + c->clientPos();
298 if( pos.x() + size.width() >= r.right())
299 pos.setX( r.right() - size.width());
300 if( pos.y() + size.height() >= r.bottom())
301 pos.setY( r.bottom() - size.height());
302 client_keys_dialog->move( pos );
303 client_keys_dialog->show();
304 active_popup = client_keys_dialog;
305 active_popup_client = c;
308 void Workspace::setupWindowShortcutDone(
bool ok )
310 keys->suspend(
false );
311 disable_shortcuts_keys->suspend(
false );
312 client_keys->suspend(
false );
315 client_keys_client->setShortcut( KShortcut( client_keys_dialog->shortcut()).toString());
318 delete client_keys_dialog;
319 client_keys_dialog = NULL;
320 client_keys_client = NULL;
323 void Workspace::clientShortcutUpdated( Client* c )
325 TQString key = TQString::number( c->window());
326 client_keys->remove( key );
327 if( !c->shortcut().isNull())
329 client_keys->insert( key, key );
330 client_keys->setShortcut( key, c->shortcut());
331 client_keys->setSlot( key, c, TQT_SLOT( shortcutActivated()));
332 client_keys->setActionEnabled( key,
true );
334 client_keys->updateConnections();
337 void Workspace::clientPopupActivated(
int id )
339 WindowOperation op =
static_cast< WindowOperation
>( id );
340 Client* c = active_popup_client ? active_popup_client : active_client;
345 if( !c->isFullScreen() && c->userCanSetFullScreen())
346 type =
"fullscreenaltf3";
349 if( !c->noBorder() && c->userCanSetNoBorder())
350 type =
"noborderaltf3";
356 helperDialog( type, c );
357 performWindowOperation( c, op );
361 void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
366 if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp )
367 TQCursor::setPos( c->geometry().center() );
368 if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp )
369 TQCursor::setPos( c->geometry().bottomRight());
372 case Options::MoveOp:
373 c->performMouseCommand( Options::MouseMove, TQCursor::pos() );
375 case Options::UnrestrictedMoveOp:
376 c->performMouseCommand( Options::MouseUnrestrictedMove, TQCursor::pos() );
378 case Options::ResizeOp:
379 c->performMouseCommand( Options::MouseResize, TQCursor::pos() );
381 case Options::UnrestrictedResizeOp:
382 c->performMouseCommand( Options::MouseUnrestrictedResize, TQCursor::pos() );
384 case Options::CloseOp:
387 case Options::MaximizeOp:
388 c->maximize( c->maximizeMode() == Client::MaximizeFull
389 ? Client::MaximizeRestore : Client::MaximizeFull );
391 case Options::HMaximizeOp:
392 c->maximize( c->maximizeMode() ^ Client::MaximizeHorizontal );
394 case Options::VMaximizeOp:
395 c->maximize( c->maximizeMode() ^ Client::MaximizeVertical );
397 case Options::RestoreOp:
398 c->maximize( Client::MaximizeRestore );
400 case Options::MinimizeOp:
403 case Options::ShadeOp:
404 c->performMouseCommand( Options::MouseShade, TQCursor::pos());
406 case Options::ShadowOp:
407 c->setShadowed( !c->isShadowed() );
409 case Options::OnAllDesktopsOp:
410 c->setOnAllDesktops( !c->isOnAllDesktops() );
412 case Options::FullScreenOp:
413 c->setFullScreen( !c->isFullScreen(), true );
415 case Options::NoBorderOp:
416 c->setUserNoBorder( !c->isUserNoBorder());
418 case Options::KeepAboveOp:
420 StackingUpdatesBlocker blocker(
this );
421 bool was = c->keepAbove();
422 c->setKeepAbove( !c->keepAbove() );
423 if( was && !c->keepAbove())
427 case Options::KeepBelowOp:
429 StackingUpdatesBlocker blocker(
this );
430 bool was = c->keepBelow();
431 c->setKeepBelow( !c->keepBelow() );
432 if( was && !c->keepBelow())
436 case Options::OperationsOp:
437 c->performMouseCommand( Options::MouseShade, TQCursor::pos());
439 case Options::WindowRulesOp:
440 editWindowRules( c,
false );
442 case Options::ApplicationRulesOp:
443 editWindowRules( c,
true );
445 case Options::SetupWindowShortcutOp:
446 setupWindowShortcut( c );
448 case Options::LowerOp:
464 case Options::MouseRaise:
465 workspace()->raiseClient(
this );
467 case Options::MouseLower:
468 workspace()->lowerClient(
this );
470 case Options::MouseShade :
474 case Options::MouseSetShade:
475 setShade( ShadeNormal );
478 case Options::MouseUnsetShade:
479 setShade( ShadeNone );
482 case Options::MouseOperationsMenu:
483 if ( isActive() && options->clickRaise )
485 workspace()->showWindowMenu( globalPos,
this );
487 case Options::MouseToggleRaiseAndLower:
488 workspace()->raiseOrLowerClient(
this );
490 case Options::MouseActivateAndRaise:
492 workspace()->takeActivity(
this, ActivityFocus | ActivityRaise, handled && replay );
493 workspace()->setActiveScreenMouse( globalPos );
495 case Options::MouseActivateAndLower:
496 workspace()->requestFocus(
this );
497 workspace()->lowerClient(
this );
498 workspace()->setActiveScreenMouse( globalPos );
500 case Options::MouseActivate:
502 workspace()->takeActivity(
this, ActivityFocus, handled && replay );
503 workspace()->setActiveScreenMouse( globalPos );
505 case Options::MouseActivateRaiseAndPassClick:
506 workspace()->takeActivity(
this, ActivityFocus | ActivityRaise, handled );
507 workspace()->setActiveScreenMouse( globalPos );
510 case Options::MouseActivateAndPassClick:
511 workspace()->takeActivity(
this, ActivityFocus, handled );
512 workspace()->setActiveScreenMouse( globalPos );
515 case Options::MouseActivateRaiseAndMove:
516 case Options::MouseActivateRaiseAndUnrestrictedMove:
517 workspace()->raiseClient(
this );
518 workspace()->requestFocus(
this );
519 workspace()->setActiveScreenMouse( globalPos );
520 if( options->moveMode == Options::Transparent &&
isMovable())
521 move_faked_activity = workspace()->fakeRequestedActivity(
this );
523 case Options::MouseMove:
524 case Options::MouseUnrestrictedMove:
529 finishMoveResize(
false );
530 mode = PositionCenter;
532 moveOffset = TQPoint( globalPos.x() - x(), globalPos.y() - y());
533 invertedMoveOffset = rect().bottomRight() - moveOffset;
534 unrestrictedMoveResize = ( command == Options::MouseActivateRaiseAndUnrestrictedMove
535 || command == Options::MouseUnrestrictedMove );
537 if( !startMoveResize())
544 case Options::MouseResize:
545 case Options::MouseUnrestrictedResize:
550 finishMoveResize(
false );
552 moveOffset = TQPoint( globalPos.x() - x(), globalPos.y() - y());
553 int x = moveOffset.x(), y = moveOffset.y();
554 bool left = x < width() / 3;
555 bool right = x >= 2 * width() / 3;
556 bool top = y < height() / 3;
557 bool bot = y >= 2 * height() / 3;
559 mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
561 mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
563 mode = (x < width() / 2) ? PositionLeft : PositionRight;
564 invertedMoveOffset = rect().bottomRight() - moveOffset;
565 unrestrictedMoveResize = ( command == Options::MouseUnrestrictedResize );
567 if( !startMoveResize())
574 case Options::MouseMaximize:
575 maximize( Client::MaximizeFull );
577 case Options::MouseRestore:
578 maximize( Client::MaximizeRestore );
580 case Options::MouseMinimize:
583 case Options::MouseAbove:
585 StackingUpdatesBlocker blocker( workspace());
587 setKeepBelow(
false );
589 setKeepAbove(
true );
592 case Options::MouseBelow:
594 StackingUpdatesBlocker blocker( workspace());
596 setKeepAbove(
false );
598 setKeepBelow(
true );
601 case Options::MousePreviousDesktop:
602 workspace()->windowToPreviousDesktop(
this );
604 case Options::MouseNextDesktop:
605 workspace()->windowToNextDesktop(
this );
607 case Options::MouseOpacityMore:
608 if (opacity_ < 0xFFFFFFFF)
610 if (opacity_ < 0xF3333333)
612 setOpacity(TRUE, opacity_ + 0xCCCCCCC);
613 custom_opacity =
true;
617 setOpacity(FALSE, 0xFFFFFFFF);
618 custom_opacity =
false;
622 case Options::MouseOpacityLess:
625 setOpacity(TRUE, (opacity_ > 0xCCCCCCC) ? opacity_ - 0xCCCCCCC : 0);
626 custom_opacity =
true;
629 case Options::MouseNothing:
637 void Workspace::showWindowMenuAt(
unsigned long,
int,
int )
639 slotWindowOperations();
642 void Workspace::slotActivateAttentionWindow()
644 if( attention_chain.count() > 0 )
645 activateClient( attention_chain.first());
648 void Workspace::slotSwitchDesktopNext()
650 int d = currentDesktop() + 1;
651 if ( d > numberOfDesktops() )
653 if ( options->rollOverDesktops )
662 setCurrentDesktop(d);
665 void Workspace::slotSwitchDesktopPrevious()
667 int d = currentDesktop() - 1;
670 if ( options->rollOverDesktops )
671 d = numberOfDesktops();
675 setCurrentDesktop(d);
678 void Workspace::slotSwitchDesktopRight()
680 int desktop = desktopToRight( currentDesktop());
681 if( desktop == currentDesktop())
683 setCurrentDesktop( desktop );
686 void Workspace::slotSwitchDesktopLeft()
688 int desktop = desktopToLeft( currentDesktop());
689 if( desktop == currentDesktop())
691 setCurrentDesktop( desktop );
694 void Workspace::slotSwitchDesktopUp()
696 int desktop = desktopUp( currentDesktop());
697 if( desktop == currentDesktop())
699 setCurrentDesktop( desktop );
702 void Workspace::slotSwitchDesktopDown()
704 int desktop = desktopDown( currentDesktop());
705 if( desktop == currentDesktop())
707 setCurrentDesktop( desktop );
710 void Workspace::slotSwitchToDesktop(
int i )
712 setCurrentDesktop( i );
716 void Workspace::slotWindowToDesktop(
int i )
718 Client* c = active_popup_client ? active_popup_client : active_client;
719 if( i >= 1 && i <= numberOfDesktops() && c
723 sendClientToDesktop( c, i,
true );
726 void Workspace::slotSwitchToScreen(
int i )
728 setCurrentScreen( i );
731 void Workspace::slotSwitchToNextScreen()
733 slotSwitchToScreen(( activeScreen() + 1 ) % numScreens());
736 void Workspace::slotWindowToScreen(
int i )
738 Client* c = active_popup_client ? active_popup_client : active_client;
739 if( i >= 0 && i <= numScreens() && c
744 sendClientToScreen( c, i );
748 void Workspace::slotWindowToNextScreen()
750 Client* c = active_popup_client ? active_popup_client : active_client;
756 sendClientToScreen( c, ( c->screen() + 1 ) % numScreens());
763 void Workspace::slotWindowMaximize()
765 Client* c = active_popup_client ? active_popup_client : active_client;
767 performWindowOperation( c, Options::MaximizeOp );
773 void Workspace::slotWindowMaximizeVertical()
775 Client* c = active_popup_client ? active_popup_client : active_client;
777 performWindowOperation( c, Options::VMaximizeOp );
783 void Workspace::slotWindowMaximizeHorizontal()
785 Client* c = active_popup_client ? active_popup_client : active_client;
787 performWindowOperation( c, Options::HMaximizeOp );
794 void Workspace::slotWindowMinimize()
796 Client* c = active_popup_client ? active_popup_client : active_client;
797 performWindowOperation( c, Options::MinimizeOp );
803 void Workspace::slotWindowShade()
805 Client* c = active_popup_client ? active_popup_client : active_client;
806 performWindowOperation( c, Options::ShadeOp );
812 void Workspace::slotWindowRaise()
814 Client* c = active_popup_client ? active_popup_client : active_client;
822 void Workspace::slotWindowLower()
824 Client* c = active_popup_client ? active_popup_client : active_client;
832 void Workspace::slotWindowRaiseOrLower()
834 Client* c = active_popup_client ? active_popup_client : active_client;
836 raiseOrLowerClient( c );
839 void Workspace::slotWindowOnAllDesktops()
841 Client* c = active_popup_client ? active_popup_client : active_client;
843 c->setOnAllDesktops( !c->isOnAllDesktops());
846 void Workspace::slotWindowFullScreen()
848 Client* c = active_popup_client ? active_popup_client : active_client;
850 performWindowOperation( c, Options::FullScreenOp );
853 void Workspace::slotWindowNoBorder()
855 Client* c = active_popup_client ? active_popup_client : active_client;
857 performWindowOperation( c, Options::NoBorderOp );
860 void Workspace::slotWindowAbove()
862 Client* c = active_popup_client ? active_popup_client : active_client;
864 performWindowOperation( c, Options::KeepAboveOp );
867 void Workspace::slotWindowBelow()
869 Client* c = active_popup_client ? active_popup_client : active_client;
871 performWindowOperation( c, Options::KeepBelowOp );
873 void Workspace::slotSetupWindowShortcut()
875 Client* c = active_popup_client ? active_popup_client : active_client;
877 performWindowOperation( c, Options::SetupWindowShortcutOp );
883 void Workspace::slotWindowToNextDesktop()
885 windowToNextDesktop( active_popup_client ? active_popup_client : active_client );
888 void Workspace::windowToNextDesktop( Client* c )
890 int d = currentDesktop() + 1;
891 if ( d > numberOfDesktops() )
893 if (c && !c->isDesktop()
894 && !c->isDock() && !c->isTopMenu())
896 setClientIsMoving( c );
897 setCurrentDesktop( d );
898 setClientIsMoving( NULL );
905 void Workspace::slotWindowToPreviousDesktop()
907 windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client );
910 void Workspace::windowToPreviousDesktop( Client* c )
912 int d = currentDesktop() - 1;
914 d = numberOfDesktops();
915 if (c && !c->isDesktop()
916 && !c->isDock() && !c->isTopMenu())
918 setClientIsMoving( c );
919 setCurrentDesktop( d );
920 setClientIsMoving( NULL );
924 void Workspace::slotWindowToDesktopRight()
926 int d = desktopToRight( currentDesktop());
927 if( d == currentDesktop())
929 Client* c = active_popup_client ? active_popup_client : active_client;
930 if (c && !c->isDesktop()
931 && !c->isDock() && !c->isTopMenu())
933 setClientIsMoving( c );
934 setCurrentDesktop( d );
935 setClientIsMoving( NULL );
939 void Workspace::slotWindowToDesktopLeft()
941 int d = desktopToLeft( currentDesktop());
942 if( d == currentDesktop())
944 Client* c = active_popup_client ? active_popup_client : active_client;
945 if (c && !c->isDesktop()
946 && !c->isDock() && !c->isTopMenu())
948 setClientIsMoving( c );
949 setCurrentDesktop( d );
950 setClientIsMoving( NULL );
954 void Workspace::slotWindowToDesktopUp()
956 int d = desktopUp( currentDesktop());
957 if( d == currentDesktop())
959 Client* c = active_popup_client ? active_popup_client : active_client;
960 if (c && !c->isDesktop()
961 && !c->isDock() && !c->isTopMenu())
963 setClientIsMoving( c );
964 setCurrentDesktop( d );
965 setClientIsMoving( NULL );
969 void Workspace::slotWindowToDesktopDown()
971 int d = desktopDown( currentDesktop());
972 if( d == currentDesktop())
974 Client* c = active_popup_client ? active_popup_client : active_client;
975 if (c && !c->isDesktop()
976 && !c->isDock() && !c->isTopMenu())
978 setClientIsMoving( c );
979 setCurrentDesktop( d );
980 setClientIsMoving( NULL );
988 void Workspace::slotKillWindow()
990 KillWindow kill(
this );
999 void Workspace::slotSendToDesktop(
int desk )
1001 if ( !active_popup_client )
1005 active_popup_client->setOnAllDesktops( !active_popup_client->isOnAllDesktops());
1009 sendClientToDesktop( active_popup_client, desk,
false );
1016 void Workspace::slotWindowOperations()
1018 if ( !active_client )
1020 TQPoint pos = active_client->pos() + active_client->clientPos();
1021 showWindowMenu( pos.x(), pos.y(), active_client );
1024 void Workspace::showWindowMenu(
const TQRect &pos, Client* cl )
1026 if (!kapp->authorizeKAction(
"kwin_rmb"))
1030 if( active_popup_client != NULL )
1032 if ( cl->isDesktop()
1035 || cl->isModalSystemNotification())
1038 active_popup_client = cl;
1039 TQPopupMenu* p = clientPopup();
1042 int y = pos.bottom();
1044 p->exec( TQPoint( x, y ) );
1047 TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop());
1048 clientPopupAboutToShow();
1049 int popupHeight = p->sizeHint().height();
1050 if (y + popupHeight < area.height())
1051 p->exec( TQPoint( x, y ) );
1053 p->exec( TQPoint( x, pos.top() - popupHeight ) );
1056 if( active_popup == p )
1063 void Workspace::slotWindowClose()
1065 if ( tab_box->isVisible())
1067 Client* c = active_popup_client ? active_popup_client : active_client;
1068 performWindowOperation( c, Options::CloseOp );
1074 void Workspace::slotWindowMove()
1076 Client* c = active_popup_client ? active_popup_client : active_client;
1077 performWindowOperation( c, Options::UnrestrictedMoveOp );
1083 void Workspace::slotWindowResize()
1085 Client* c = active_popup_client ? active_popup_client : active_client;
1086 performWindowOperation( c, Options::UnrestrictedResizeOp );
1089 void Client::setShortcut(
const TQString& _cut )
1091 TQString cut = rules()->checkShortcut( _cut );
1093 return setShortcutInternal( KShortcut());
1097 if( !cut.contains(
'(' ) && !cut.contains(
')' ) && !cut.contains(
' ' ))
1099 if( workspace()->shortcutAvailable( KShortcut( cut ),
this ))
1100 setShortcutInternal( KShortcut( cut ));
1102 setShortcutInternal( KShortcut());
1105 TQValueList< KShortcut > keys;
1106 TQStringList groups = TQStringList::split(
' ', cut );
1107 for( TQStringList::ConstIterator it = groups.begin();
1111 TQRegExp reg(
"(.*\\+)\\((.*)\\)" );
1112 if( reg.search( *it ) > -1 )
1114 TQString base = reg.cap( 1 );
1115 TQString list = reg.cap( 2 );
1116 for(
unsigned int i = 0;
1120 KShortcut c( base + list[ i ] );
1126 for( TQValueList< KShortcut >::ConstIterator it = keys.begin();
1130 if( _shortcut == *it )
1133 for( TQValueList< KShortcut >::ConstIterator it = keys.begin();
1137 if( workspace()->shortcutAvailable( *it,
this ))
1139 setShortcutInternal( *it );
1143 setShortcutInternal( KShortcut());
1146 void Client::setShortcutInternal(
const KShortcut& cut )
1148 if( _shortcut == cut )
1152 workspace()->clientShortcutUpdated(
this );
1155 bool Workspace::shortcutAvailable(
const KShortcut& cut, Client* ignore )
const
1158 for( ClientList::ConstIterator it = clients.begin();
1159 it != clients.end();
1162 if( (*it) != ignore && (*it)->shortcut() == cut )