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::makeTileMenu()
49 TQPopupMenu *m =
new TQPopupMenu;
52 int id = m->insertItem( SmallIconSet(
"tile_left"), i18n(
"&Left"),
this, TQ_SLOT( tileCurrentWindowToBorder(
int) ) );
53 m->setItemParameter(
id, 6 );
54 id = m->insertItem( SmallIconSet(
"tile_right"), i18n(
"&Right"),
this, TQ_SLOT( tileCurrentWindowToBorder(
int) ) );
55 m->setItemParameter(
id, 2 );
56 id = m->insertItem( SmallIconSet(
"tile_top"), i18n(
"&Top"),
this, TQ_SLOT( tileCurrentWindowToBorder(
int) ) );
57 m->setItemParameter(
id, 0 );
58 id = m->insertItem( SmallIconSet(
"tile_bottom"), i18n(
"&Bottom"),
this, TQ_SLOT( tileCurrentWindowToBorder(
int) ) );
59 m->setItemParameter(
id, 4 );
62 id = m->insertItem( SmallIconSet(
"tile_topleft"), i18n(
"Top &Left"),
this, TQ_SLOT( tileCurrentWindowToBorder(
int) ) );
63 m->setItemParameter(
id, 7 );
64 id = m->insertItem( SmallIconSet(
"tile_topright"), i18n(
"Top &Right"),
this, TQ_SLOT( tileCurrentWindowToBorder(
int) ) );
65 m->setItemParameter(
id, 1 );
66 id = m->insertItem( SmallIconSet(
"tile_bottomleft"), i18n(
"Bottom L&eft"),
this, TQ_SLOT( tileCurrentWindowToBorder(
int) ) );
67 m->setItemParameter(
id, 5 );
68 id = m->insertItem( SmallIconSet(
"tile_bottomright"), i18n(
"&Bottom R&ight"),
this, TQ_SLOT( tileCurrentWindowToBorder(
int) ) );
69 m->setItemParameter(
id, 3 );
74 TQPopupMenu* Workspace::clientPopup()
78 popup =
new TQPopupMenu;
79 popup->setCheckable( TRUE );
80 popup->setFont(TDEGlobalSettings::menuFont());
81 connect( popup, TQ_SIGNAL( aboutToShow() ),
this, TQ_SLOT( clientPopupAboutToShow() ) );
82 connect( popup, TQ_SIGNAL( activated(
int) ),
this, TQ_SLOT( clientPopupActivated(
int) ) );
84 advanced_popup =
new TQPopupMenu( popup );
85 advanced_popup->setCheckable( TRUE );
86 advanced_popup->setFont(TDEGlobalSettings::menuFont());
87 connect( advanced_popup, TQ_SIGNAL( activated(
int) ),
this, TQ_SLOT( clientPopupActivated(
int) ) );
88 advanced_popup->insertItem( SmallIconSet(
"go-up" ),
89 i18n(
"Keep &Above Others")+
'\t'+keys->shortcut(
"Window Above Other Windows").seq(0).toString(), Options::KeepAboveOp );
90 advanced_popup->insertItem( SmallIconSet(
"go-down" ),
91 i18n(
"Keep &Below Others")+
'\t'+keys->shortcut(
"Window Below Other Windows").seq(0).toString(), Options::KeepBelowOp );
92 advanced_popup->insertItem( SmallIconSet(
"view-fullscreen" ),
93 i18n(
"&Fullscreen")+
'\t'+keys->shortcut(
"Window Fullscreen").seq(0).toString(), Options::FullScreenOp );
94 advanced_popup->insertItem( i18n(
"&No Border")+
'\t'+keys->shortcut(
"Window No Border").seq(0).toString(), Options::NoBorderOp );
95 advanced_popup->insertItem( i18n(
"Shad&ow"), Options::ShadowOp );
96 advanced_popup->insertItem( SmallIconSet(
"key_bindings"),
97 i18n(
"Window &Shortcut…")+
'\t'+keys->shortcut(
"Setup Window Shortcut").seq(0).toString(), Options::SetupWindowShortcutOp );
98 advanced_popup->insertSeparator();
99 advanced_popup->insertItem( SmallIconSet(
"suspend" ), i18n(
"&Suspend Application"), Options::SuspendWindowOp );
100 advanced_popup->insertItem( SmallIconSet(
"application-x-executable" ), i18n(
"&Resume Application"), Options::ResumeWindowOp );
101 advanced_popup->insertSeparator();
102 advanced_popup->insertItem( SmallIconSet(
"wizard" ), i18n(
"&Special Window Settings…"), Options::WindowRulesOp );
103 advanced_popup->insertItem( SmallIconSet(
"wizard" ), i18n(
"&Special Application Settings…"), Options::ApplicationRulesOp );
105 popup->insertItem(i18n(
"Ad&vanced"), advanced_popup );
106 tile_popup_index = popup->insertItem(i18n(
"T&ile"), makeTileMenu());
107 desk_popup_index = popup->count();
109 if (options->useTranslucency){
110 TQPopupMenu *trans_popup =
new TQPopupMenu( popup );
111 TQVBox *transBox =
new TQVBox(trans_popup);
112 transButton =
new TQPushButton(transBox,
"transButton");
113 TQToolTip::add(transButton, i18n(
"Reset opacity to default value"));
114 transSlider =
new TQSlider(0, 100, 1, 100, TQt::Horizontal, transBox,
"transSlider");
115 TQToolTip::add(transSlider, i18n(
"Slide this to set the window's opacity"));
116 connect(transButton, TQ_SIGNAL(clicked()), TQ_SLOT(resetClientOpacity()));
117 connect(transButton, TQ_SIGNAL(clicked()), trans_popup, TQ_SLOT(hide()));
118 connect(transSlider, TQ_SIGNAL(valueChanged(
int)), TQ_SLOT(setTransButtonText(
int)));
119 connect(transSlider, TQ_SIGNAL(valueChanged(
int)),
this, TQ_SLOT(setPopupClientOpacity(
int)));
121 trans_popup->insertItem(transBox);
122 popup->insertItem(i18n(
"&Opacity"), trans_popup );
125 popup->insertItem( SmallIconSet(
"move" ), i18n(
"&Move")+
'\t'+keys->shortcut(
"Window Move").seq(0).toString(), Options::MoveOp );
126 popup->insertItem( i18n(
"Re&size")+
'\t'+keys->shortcut(
"Window Resize").seq(0).toString(), Options::ResizeOp );
127 popup->insertItem( i18n(
"Mi&nimize")+
'\t'+keys->shortcut(
"Window Minimize").seq(0).toString(), Options::MinimizeOp );
128 popup->insertItem( i18n(
"Ma&ximize")+
'\t'+keys->shortcut(
"Window Maximize").seq(0).toString(), Options::MaximizeOp );
129 popup->insertItem( i18n(
"Sh&ade")+
'\t'+keys->shortcut(
"Window Shade").seq(0).toString(), Options::ShadeOp );
131 popup->insertSeparator();
133 if (!TDEGlobal::config()->isImmutable() &&
134 !kapp->authorizeControlModules(Workspace::configModules(
true)).isEmpty())
136 popup->insertItem(SmallIconSet(
"configure" ), i18n(
"Configur&e Window Behavior…"),
this, TQ_SLOT( configureWM() ));
137 popup->insertSeparator();
140 popup->insertItem( SmallIconSet(
"window-close" ), i18n(
"&Close")+
'\t'+keys->shortcut(
"Window Close").seq(0).toString(), Options::CloseOp );
146 void Workspace::setPopupClientOpacity(
int value)
148 active_popup_client->setCustomOpacityFlag(
true);
150 value<100?active_popup_client->setOpacity(
true, (uint)((value/100.0)*0xffffffff)):active_popup_client->setOpacity(
false,0xffffffff);
153 void Workspace::setTransButtonText(
int value)
157 transButton->setText(
" 0 %");
158 else if (value >= 100 )
159 transButton->setText(
"100 %");
161 transButton->setText(
" "+TQString::number(value)+
" %");
163 transButton->setText(
" "+TQString::number(value)+
" %");
166 void Workspace::resetClientOpacity()
168 active_popup_client->setCustomOpacityFlag(
false);
169 active_popup_client->updateOpacity();
170 transSlider->setValue(100-active_popup_client->opacityPercentage());
171 setTransButtonText(100-active_popup_client->opacityPercentage());
180 void Workspace::clientPopupAboutToShow()
182 if ( !active_popup_client || !popup )
185 if ( numberOfDesktops() == 1 )
195 popup->setItemEnabled( Options::ResizeOp, active_popup_client->isResizable() );
196 popup->setItemEnabled( Options::MoveOp, active_popup_client->isMovable() );
197 popup->setItemEnabled( Options::MaximizeOp, active_popup_client->isMaximizable() );
198 popup->setItemChecked( Options::MaximizeOp, active_popup_client->maximizeMode() == Client::MaximizeFull );
200 popup->setItemChecked( Options::ShadeOp, active_popup_client->shadeMode() != ShadeNone );
201 popup->setItemEnabled( Options::ShadeOp, active_popup_client->isShadeable());
202 advanced_popup->setItemChecked( Options::KeepAboveOp, active_popup_client->keepAbove() );
203 advanced_popup->setItemChecked( Options::KeepBelowOp, active_popup_client->keepBelow() );
204 advanced_popup->setItemChecked( Options::FullScreenOp, active_popup_client->isFullScreen() );
205 advanced_popup->setItemEnabled( Options::FullScreenOp, active_popup_client->userCanSetFullScreen() );
206 advanced_popup->setItemEnabled( Options::SuspendWindowOp, active_popup_client->isSuspendable() );
207 advanced_popup->setItemEnabled( Options::ResumeWindowOp, active_popup_client->isResumeable() );
208 advanced_popup->setItemChecked( Options::NoBorderOp, active_popup_client->noBorder() );
209 advanced_popup->setItemEnabled( Options::NoBorderOp, active_popup_client->userCanSetNoBorder() );
210 advanced_popup->setItemEnabled( Options::ShadowOp, (options->shadowWindowType(active_popup_client->windowType()) && options->shadowEnabled(active_popup_client->isActive())) );
211 advanced_popup->setItemChecked( Options::ShadowOp, active_popup_client->isShadowed() );
213 popup->setItemEnabled( tile_popup_index, active_popup_client->isMovable() && active_popup_client->isResizable());
215 popup->setItemEnabled( Options::MinimizeOp, active_popup_client->isMinimizable() );
216 popup->setItemEnabled( Options::CloseOp, active_popup_client->isCloseable() );
217 if (options->useTranslucency)
219 transSlider->setValue(100-active_popup_client->opacityPercentage());
220 setTransButtonText(100-active_popup_client->opacityPercentage());
225 void Workspace::initDesktopPopup()
230 desk_popup =
new TQPopupMenu( popup );
231 desk_popup->setCheckable( TRUE );
232 desk_popup->setFont(TDEGlobalSettings::menuFont());
233 connect( desk_popup, TQ_SIGNAL( activated(
int) ),
234 this, TQ_SLOT( slotSendToDesktop(
int) ) );
235 connect( desk_popup, TQ_SIGNAL( aboutToShow() ),
236 this, TQ_SLOT( desktopPopupAboutToShow() ) );
238 popup->insertItem(i18n(
"To &Desktop"), desk_popup, -1, desk_popup_index );
245 void Workspace::desktopPopupAboutToShow()
251 desk_popup->insertItem( i18n(
"&All Desktops"), 0 );
252 if ( active_popup_client && active_popup_client->isOnAllDesktops() )
253 desk_popup->setItemChecked( 0, TRUE );
254 desk_popup->insertSeparator( -1 );
257 for (
int i = 1; i <= numberOfDesktops(); i++ )
259 TQString basic_name(
"%1 %2");
262 basic_name.prepend(
'&');
264 id = desk_popup->insertItem(
267 .arg( desktopName(i).replace(
'&',
"&&" )),
269 if ( active_popup_client &&
270 !active_popup_client->isOnAllDesktops() && active_popup_client->desktop() == i )
271 desk_popup->setItemChecked(
id, TRUE );
275 void Workspace::closeActivePopup()
279 active_popup->close();
281 active_popup_client = NULL;
288 void Workspace::initShortcuts()
290 keys =
new TDEGlobalAccel(
this );
293 disable_shortcuts_keys =
new TDEGlobalAccel(
this );
294 disable_shortcuts_keys->disableBlocking(
true );
296 #include "twinbindings.cpp"
300 void Workspace::readShortcuts()
302 keys->readSettings();
303 disable_shortcuts_keys->readSettings();
305 cutWalkThroughDesktops = keys->shortcut(
"Walk Through Desktops");
306 cutWalkThroughDesktopsReverse = keys->shortcut(
"Walk Through Desktops (Reverse)");
307 cutWalkThroughDesktopList = keys->shortcut(
"Walk Through Desktop List");
308 cutWalkThroughDesktopListReverse = keys->shortcut(
"Walk Through Desktop List (Reverse)");
309 cutWalkThroughWindows = keys->shortcut(
"Walk Through Windows");
310 cutWalkThroughWindowsReverse = keys->shortcut(
"Walk Through Windows (Reverse)");
311 cutWalkThroughApps = keys->shortcut(
"Walk Through Windows of Same Application");
312 cutWalkThroughAppsReverse = keys->shortcut(
"Walk Through Windows of Same Application (Reverse)");
314 keys->updateConnections();
315 disable_shortcuts_keys->updateConnections();
323 void Workspace::setupWindowShortcut( Client* c )
325 assert( client_keys_dialog == NULL );
326 keys->suspend(
true );
327 disable_shortcuts_keys->suspend(
true );
328 client_keys->suspend(
true );
329 client_keys_dialog =
new ShortcutDialog( c->shortcut());
330 client_keys_client = c;
331 connect( client_keys_dialog, TQ_SIGNAL( dialogDone(
bool )), TQ_SLOT( setupWindowShortcutDone(
bool )));
332 TQRect r = clientArea( ScreenArea, c );
333 TQSize size = client_keys_dialog->sizeHint();
334 TQPoint pos = c->pos() + c->clientPos();
335 if( pos.x() + size.width() >= r.right())
336 pos.setX( r.right() - size.width());
337 if( pos.y() + size.height() >= r.bottom())
338 pos.setY( r.bottom() - size.height());
339 client_keys_dialog->move( pos );
340 client_keys_dialog->show();
341 active_popup = client_keys_dialog;
342 active_popup_client = c;
345 void Workspace::setupWindowShortcutDone(
bool ok )
347 keys->suspend(
false );
348 disable_shortcuts_keys->suspend(
false );
349 client_keys->suspend(
false );
352 client_keys_client->setShortcut( TDEShortcut( client_keys_dialog->shortcut()).toString());
355 delete client_keys_dialog;
356 client_keys_dialog = NULL;
357 client_keys_client = NULL;
360 void Workspace::clientShortcutUpdated( Client* c )
362 TQString key = TQString::number( c->window());
363 client_keys->remove( key );
364 if( !c->shortcut().isNull())
366 client_keys->insert( key, key );
367 client_keys->setShortcut( key, c->shortcut());
368 client_keys->setSlot( key, c, TQ_SLOT( shortcutActivated()));
369 client_keys->setActionEnabled( key,
true );
371 client_keys->updateConnections();
374 void Workspace::clientPopupActivated(
int id )
376 WindowOperation op =
static_cast< WindowOperation
>( id );
377 Client* c = active_popup_client ? active_popup_client : active_client;
382 if( !c->isFullScreen() && c->userCanSetFullScreen())
383 type =
"fullscreenaltf3";
386 if( !c->noBorder() && c->userCanSetNoBorder())
387 type =
"noborderaltf3";
393 helperDialog( type, c );
394 performWindowOperation( c, op );
398 void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
403 if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp )
404 TQCursor::setPos( c->geometry().center() );
405 if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp )
406 TQCursor::setPos( c->geometry().bottomRight());
409 case Options::MoveOp:
410 c->performMouseCommand( Options::MouseMove, TQCursor::pos() );
412 case Options::UnrestrictedMoveOp:
413 c->performMouseCommand( Options::MouseUnrestrictedMove, TQCursor::pos() );
415 case Options::ResizeOp:
416 c->performMouseCommand( Options::MouseResize, TQCursor::pos() );
418 case Options::UnrestrictedResizeOp:
419 c->performMouseCommand( Options::MouseUnrestrictedResize, TQCursor::pos() );
421 case Options::CloseOp:
424 case Options::MaximizeOp:
425 c->maximize( c->maximizeMode() == Client::MaximizeFull
426 ? Client::MaximizeRestore : Client::MaximizeFull );
428 case Options::HMaximizeOp:
429 c->maximize( c->maximizeMode() ^ Client::MaximizeHorizontal );
431 case Options::VMaximizeOp:
432 c->maximize( c->maximizeMode() ^ Client::MaximizeVertical );
434 case Options::RestoreOp:
435 c->maximize( Client::MaximizeRestore );
437 case Options::MinimizeOp:
440 case Options::ShadeOp:
441 c->performMouseCommand( Options::MouseShade, TQCursor::pos());
443 case Options::ShadowOp:
444 c->setShadowed( !c->isShadowed() );
446 case Options::OnAllDesktopsOp:
447 c->setOnAllDesktops( !c->isOnAllDesktops() );
449 case Options::FullScreenOp:
450 c->setFullScreen( !c->isFullScreen(),
true );
452 case Options::NoBorderOp:
453 c->setUserNoBorder( !c->isUserNoBorder());
455 case Options::KeepAboveOp:
457 StackingUpdatesBlocker blocker(
this );
458 bool was = c->keepAbove();
459 c->setKeepAbove( !c->keepAbove() );
460 if( was && !c->keepAbove())
464 case Options::KeepBelowOp:
466 StackingUpdatesBlocker blocker(
this );
467 bool was = c->keepBelow();
468 c->setKeepBelow( !c->keepBelow() );
469 if( was && !c->keepBelow())
473 case Options::OperationsOp:
474 c->performMouseCommand( Options::MouseShade, TQCursor::pos());
476 case Options::SuspendWindowOp:
479 case Options::ResumeWindowOp:
482 case Options::WindowRulesOp:
483 editWindowRules( c,
false );
485 case Options::ApplicationRulesOp:
486 editWindowRules( c,
true );
488 case Options::SetupWindowShortcutOp:
489 setupWindowShortcut( c );
491 case Options::LowerOp:
507 case Options::MouseRaise:
508 workspace()->raiseClient(
this );
510 case Options::MouseLower:
511 workspace()->lowerClient(
this );
513 case Options::MouseShade :
517 case Options::MouseSetShade:
518 setShade( ShadeNormal );
521 case Options::MouseUnsetShade:
522 setShade( ShadeNone );
525 case Options::MouseOperationsMenu:
526 if ( isActive() && options->clickRaise )
528 workspace()->showWindowMenu( globalPos,
this );
530 case Options::MouseToggleRaiseAndLower:
531 workspace()->raiseOrLowerClient(
this );
533 case Options::MouseActivateAndRaise:
535 workspace()->takeActivity(
this, ActivityFocus | ActivityRaise, handled && replay );
536 workspace()->setActiveScreenMouse( globalPos );
538 case Options::MouseActivateAndLower:
539 workspace()->requestFocus(
this );
540 workspace()->lowerClient(
this );
541 workspace()->setActiveScreenMouse( globalPos );
543 case Options::MouseActivate:
545 workspace()->takeActivity(
this, ActivityFocus, handled && replay );
546 workspace()->setActiveScreenMouse( globalPos );
548 case Options::MouseActivateRaiseAndPassClick:
549 workspace()->takeActivity(
this, ActivityFocus | ActivityRaise, handled );
550 workspace()->setActiveScreenMouse( globalPos );
553 case Options::MouseActivateAndPassClick:
554 workspace()->takeActivity(
this, ActivityFocus, handled );
555 workspace()->setActiveScreenMouse( globalPos );
558 case Options::MouseActivateRaiseAndMove:
559 case Options::MouseActivateRaiseAndUnrestrictedMove:
560 workspace()->raiseClient(
this );
561 workspace()->requestFocus(
this );
562 workspace()->setActiveScreenMouse( globalPos );
563 if( options->moveMode == Options::Transparent &&
isMovable())
564 move_faked_activity = workspace()->fakeRequestedActivity(
this );
566 case Options::MouseMove:
567 case Options::MouseUnrestrictedMove:
572 finishMoveResize(
false );
573 mode = PositionCenter;
575 moveOffset = TQPoint( globalPos.x() - x(), globalPos.y() - y());
576 invertedMoveOffset = rect().bottomRight() - moveOffset;
577 unrestrictedMoveResize = ( command == Options::MouseActivateRaiseAndUnrestrictedMove
578 || command == Options::MouseUnrestrictedMove );
580 if( !startMoveResize())
587 case Options::MouseResize:
588 case Options::MouseUnrestrictedResize:
593 finishMoveResize(
false );
595 moveOffset = TQPoint( globalPos.x() - x(), globalPos.y() - y());
596 int x = moveOffset.x(), y = moveOffset.y();
597 bool left = x < width() / 3;
598 bool right = x >= 2 * width() / 3;
599 bool top = y < height() / 3;
600 bool bot = y >= 2 * height() / 3;
602 mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
604 mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
606 mode = (x < width() / 2) ? PositionLeft : PositionRight;
607 invertedMoveOffset = rect().bottomRight() - moveOffset;
608 unrestrictedMoveResize = ( command == Options::MouseUnrestrictedResize );
610 if( !startMoveResize())
617 case Options::MouseMaximize:
618 maximize( Client::MaximizeFull );
620 case Options::MouseRestore:
621 maximize( Client::MaximizeRestore );
623 case Options::MouseMinimize:
626 case Options::MouseAbove:
628 StackingUpdatesBlocker blocker( workspace());
630 setKeepBelow(
false );
632 setKeepAbove(
true );
635 case Options::MouseBelow:
637 StackingUpdatesBlocker blocker( workspace());
639 setKeepAbove(
false );
641 setKeepBelow(
true );
644 case Options::MousePreviousDesktop:
645 workspace()->windowToPreviousDesktop(
this );
647 case Options::MouseNextDesktop:
648 workspace()->windowToNextDesktop(
this );
650 case Options::MouseOpacityMore:
651 if (opacity_ < 0xFFFFFFFF)
653 if (opacity_ < 0xF3333333)
655 setOpacity(TRUE, opacity_ + 0xCCCCCCC);
656 custom_opacity =
true;
660 setOpacity(FALSE, 0xFFFFFFFF);
661 custom_opacity =
false;
665 case Options::MouseOpacityLess:
668 setOpacity(TRUE, (opacity_ > 0xCCCCCCC) ? opacity_ - 0xCCCCCCC : 0);
669 custom_opacity =
true;
672 case Options::MouseNothing:
679 void Workspace::showWindowMenuAt(
unsigned long window,
int x,
int y )
682 if ((client = findClient(WindowMatchPredicate((WId)window))))
683 showWindowMenu( x, y, client );
686 void Workspace::showWindowMenu(
unsigned long window )
689 if ((client = findClient(WindowMatchPredicate((WId)window))))
691 TQPoint pos = client->pos() + client->clientPos();
692 showWindowMenu( pos, client );
696 void Workspace::tileCurrentWindowToBorder(
int position)
698 Client *c = active_popup_client ? active_popup_client : active_client;
701 c->tileToBorder((ActiveBorder)position);
704 void Workspace::tileWindowToBorder(
unsigned long w1,
int location) {
705 if (location < ActiveTop || location >= ACTIVE_BORDER_COUNT)
return;
707 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
710 c1->tileToBorder((ActiveBorder)location);
713 void Workspace::tileTwoWindowsHorizontally(
unsigned long w1,
unsigned long w2) {
714 if (w1 == w2)
return;
716 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
717 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
718 if (!c1 || !c2)
return;
720 c1->tileToBorder(ActiveTop);
721 c2->tileToBorder(ActiveBottom);
724 void Workspace::tileTwoWindowsVertically(
unsigned long w1,
unsigned long w2) {
725 if (w1 == w2)
return;
727 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
728 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
729 if (!c1 || !c2)
return;
731 c1->tileToBorder(ActiveLeft);
732 c2->tileToBorder(ActiveRight);
735 void Workspace::tileFourWindowsInGrid(
unsigned long w1,
unsigned long w2,
unsigned long w3,
unsigned long w4) {
736 if (w1 == w2 || w1 == w3 || w1 == w4 || w2 == w3 || w2 == w4 || w3 == w4)
739 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
740 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
741 Client *c3 = findClient(WindowMatchPredicate((WId)w3));
742 Client *c4 = findClient(WindowMatchPredicate((WId)w4));
743 if (!c1 || !c2 || !c3 || !c4)
return;
745 c1->tileToBorder(ActiveTopLeft);
746 c2->tileToBorder(ActiveTopRight);
747 c3->tileToBorder(ActiveBottomLeft);
748 c4->tileToBorder(ActiveBottomRight);
751 void Workspace::slotActivateAttentionWindow()
753 if( attention_chain.count() > 0 )
754 activateClient( attention_chain.first());
757 void Workspace::slotSwitchDesktopNext()
759 int d = currentDesktop() + 1;
760 if ( d > numberOfDesktops() )
762 if ( options->rollOverDesktops )
771 setCurrentDesktop(d);
774 void Workspace::slotSwitchDesktopPrevious()
776 int d = currentDesktop() - 1;
779 if ( options->rollOverDesktops )
780 d = numberOfDesktops();
784 setCurrentDesktop(d);
787 void Workspace::slotSwitchDesktopRight()
789 int desktop = desktopToRight( currentDesktop());
790 if( desktop == currentDesktop())
792 setCurrentDesktop( desktop );
795 void Workspace::slotSwitchDesktopLeft()
797 int desktop = desktopToLeft( currentDesktop());
798 if( desktop == currentDesktop())
800 setCurrentDesktop( desktop );
803 void Workspace::slotSwitchDesktopUp()
805 int desktop = desktopUp( currentDesktop());
806 if( desktop == currentDesktop())
808 setCurrentDesktop( desktop );
811 void Workspace::slotSwitchDesktopDown()
813 int desktop = desktopDown( currentDesktop());
814 if( desktop == currentDesktop())
816 setCurrentDesktop( desktop );
819 void Workspace::slotSwitchToDesktop(
int i )
821 setCurrentDesktop( i );
825 void Workspace::slotWindowToDesktop(
int i )
827 Client* c = active_popup_client ? active_popup_client : active_client;
828 if( i >= 1 && i <= numberOfDesktops() && c
832 sendClientToDesktop( c, i,
true );
835 void Workspace::slotSwitchToScreen(
int i )
837 setCurrentScreen( i );
840 void Workspace::slotSwitchToNextScreen()
842 slotSwitchToScreen(( activeScreen() + 1 ) % numScreens());
845 void Workspace::slotWindowToScreen(
int i )
847 Client* c = active_popup_client ? active_popup_client : active_client;
848 if( i >= 0 && i <= numScreens() && c
853 sendClientToScreen( c, i );
857 void Workspace::slotWindowToNextScreen()
859 Client* c = active_popup_client ? active_popup_client : active_client;
865 sendClientToScreen( c, ( c->screen() + 1 ) % numScreens());
872 void Workspace::slotWindowMaximize()
874 Client* c = active_popup_client ? active_popup_client : active_client;
876 performWindowOperation( c, Options::MaximizeOp );
882 void Workspace::slotWindowMaximizeVertical()
884 Client* c = active_popup_client ? active_popup_client : active_client;
886 performWindowOperation( c, Options::VMaximizeOp );
892 void Workspace::slotWindowMaximizeHorizontal()
894 Client* c = active_popup_client ? active_popup_client : active_client;
896 performWindowOperation( c, Options::HMaximizeOp );
903 void Workspace::slotWindowMinimize()
905 Client* c = active_popup_client ? active_popup_client : active_client;
906 performWindowOperation( c, Options::MinimizeOp );
912 void Workspace::slotWindowShade()
914 Client* c = active_popup_client ? active_popup_client : active_client;
915 performWindowOperation( c, Options::ShadeOp );
921 void Workspace::slotWindowRaise()
923 Client* c = active_popup_client ? active_popup_client : active_client;
931 void Workspace::slotWindowLower()
933 Client* c = active_popup_client ? active_popup_client : active_client;
941 void Workspace::slotWindowRaiseOrLower()
943 Client* c = active_popup_client ? active_popup_client : active_client;
945 raiseOrLowerClient( c );
948 void Workspace::slotWindowOnAllDesktops()
950 Client* c = active_popup_client ? active_popup_client : active_client;
952 c->setOnAllDesktops( !c->isOnAllDesktops());
955 void Workspace::slotWindowFullScreen()
957 Client* c = active_popup_client ? active_popup_client : active_client;
959 performWindowOperation( c, Options::FullScreenOp );
962 void Workspace::slotWindowNoBorder()
964 Client* c = active_popup_client ? active_popup_client : active_client;
966 performWindowOperation( c, Options::NoBorderOp );
969 void Workspace::slotWindowAbove()
971 Client* c = active_popup_client ? active_popup_client : active_client;
973 performWindowOperation( c, Options::KeepAboveOp );
976 void Workspace::slotWindowBelow()
978 Client* c = active_popup_client ? active_popup_client : active_client;
980 performWindowOperation( c, Options::KeepBelowOp );
982 void Workspace::slotSetupWindowShortcut()
984 Client* c = active_popup_client ? active_popup_client : active_client;
986 performWindowOperation( c, Options::SetupWindowShortcutOp );
992 void Workspace::slotWindowToNextDesktop()
994 windowToNextDesktop( active_popup_client ? active_popup_client : active_client );
997 void Workspace::windowToNextDesktop( Client* c )
999 int d = currentDesktop() + 1;
1000 if ( d > numberOfDesktops() )
1002 if (c && !c->isDesktop()
1003 && !c->isDock() && !c->isTopMenu())
1005 setClientIsMoving( c );
1006 setCurrentDesktop( d );
1007 setClientIsMoving( NULL );
1014 void Workspace::slotWindowToPreviousDesktop()
1016 windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client );
1019 void Workspace::windowToPreviousDesktop( Client* c )
1021 int d = currentDesktop() - 1;
1023 d = numberOfDesktops();
1024 if (c && !c->isDesktop()
1025 && !c->isDock() && !c->isTopMenu())
1027 setClientIsMoving( c );
1028 setCurrentDesktop( d );
1029 setClientIsMoving( NULL );
1033 void Workspace::slotWindowToDesktopRight()
1035 int d = desktopToRight( currentDesktop());
1036 if( d == currentDesktop())
1038 Client* c = active_popup_client ? active_popup_client : active_client;
1039 if (c && !c->isDesktop()
1040 && !c->isDock() && !c->isTopMenu())
1042 setClientIsMoving( c );
1043 setCurrentDesktop( d );
1044 setClientIsMoving( NULL );
1048 void Workspace::slotWindowToDesktopLeft()
1050 int d = desktopToLeft( currentDesktop());
1051 if( d == currentDesktop())
1053 Client* c = active_popup_client ? active_popup_client : active_client;
1054 if (c && !c->isDesktop()
1055 && !c->isDock() && !c->isTopMenu())
1057 setClientIsMoving( c );
1058 setCurrentDesktop( d );
1059 setClientIsMoving( NULL );
1063 void Workspace::slotWindowToDesktopUp()
1065 int d = desktopUp( currentDesktop());
1066 if( d == currentDesktop())
1068 Client* c = active_popup_client ? active_popup_client : active_client;
1069 if (c && !c->isDesktop()
1070 && !c->isDock() && !c->isTopMenu())
1072 setClientIsMoving( c );
1073 setCurrentDesktop( d );
1074 setClientIsMoving( NULL );
1078 void Workspace::slotWindowToDesktopDown()
1080 int d = desktopDown( currentDesktop());
1081 if( d == currentDesktop())
1083 Client* c = active_popup_client ? active_popup_client : active_client;
1084 if (c && !c->isDesktop()
1085 && !c->isDock() && !c->isTopMenu())
1087 setClientIsMoving( c );
1088 setCurrentDesktop( d );
1089 setClientIsMoving( NULL );
1097 void Workspace::slotKillWindow()
1099 KillWindow kill(
this );
1106 void Workspace::slotSuspendWindow()
1108 active_popup_client->suspendWindow();
1114 void Workspace::slotResumeWindow()
1116 active_popup_client->resumeWindow();
1124 void Workspace::slotSendToDesktop(
int desk )
1126 if ( !active_popup_client )
1130 active_popup_client->setOnAllDesktops( !active_popup_client->isOnAllDesktops());
1134 sendClientToDesktop( active_popup_client, desk,
false );
1141 void Workspace::slotWindowOperations()
1143 if ( !active_client )
1145 TQPoint pos = active_client->pos() + active_client->clientPos();
1146 showWindowMenu( pos.x(), pos.y(), active_client );
1149 void Workspace::showWindowMenu(
const TQRect &pos, Client* cl )
1151 if (!kapp->authorizeTDEAction(
"twin_rmb"))
1155 if( active_popup_client != NULL )
1157 if ( cl->isDesktop()
1160 || cl->isModalSystemNotification())
1163 active_popup_client = cl;
1164 TQPopupMenu* p = clientPopup();
1167 int y = pos.bottom();
1168 clientPopupAboutToShow();
1170 TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop());
1171 TQSize hint = p->sizeHint();
1172 if (x < 0) x = area.right() - hint.width() + x;
1173 if (y < 0) y = area.bottom() - hint.height() + y;
1175 if (pos.bottom() == pos.top())
1176 p->exec( TQPoint( x, y ) );
1179 if (y + hint.height() < area.height())
1180 p->exec( TQPoint( x, y ) );
1182 p->exec( TQPoint( x, pos.top() - hint.height() ) );
1185 if( active_popup == p )
1192 void Workspace::slotWindowClose()
1194 if ( tab_box->isVisible())
1196 Client* c = active_popup_client ? active_popup_client : active_client;
1197 performWindowOperation( c, Options::CloseOp );
1203 void Workspace::slotWindowMove()
1205 Client* c = active_popup_client ? active_popup_client : active_client;
1206 performWindowOperation( c, Options::UnrestrictedMoveOp );
1212 void Workspace::slotWindowResize()
1214 Client* c = active_popup_client ? active_popup_client : active_client;
1215 performWindowOperation( c, Options::UnrestrictedResizeOp );
1218 void Client::setShortcut(
const TQString& _cut )
1220 TQString cut = rules()->checkShortcut( _cut );
1222 return setShortcutInternal( TDEShortcut());
1226 if( !cut.contains(
'(' ) && !cut.contains(
')' ) && !cut.contains(
' ' ))
1228 if( workspace()->shortcutAvailable( TDEShortcut( cut ),
this ))
1229 setShortcutInternal( TDEShortcut( cut ));
1231 setShortcutInternal( TDEShortcut());
1234 TQValueList< TDEShortcut > keys;
1235 TQStringList groups = TQStringList::split(
' ', cut );
1236 for( TQStringList::ConstIterator it = groups.begin();
1240 TQRegExp reg(
"(.*\\+)\\((.*)\\)" );
1241 if( reg.search( *it ) > -1 )
1243 TQString base = reg.cap( 1 );
1244 TQString list = reg.cap( 2 );
1245 for(
unsigned int i = 0;
1249 TDEShortcut c( base + list[ i ] );
1255 for( TQValueList< TDEShortcut >::ConstIterator it = keys.begin();
1259 if( _shortcut == *it )
1262 for( TQValueList< TDEShortcut >::ConstIterator it = keys.begin();
1266 if( workspace()->shortcutAvailable( *it,
this ))
1268 setShortcutInternal( *it );
1272 setShortcutInternal( TDEShortcut());
1275 void Client::setShortcutInternal(
const TDEShortcut& cut )
1277 if( _shortcut == cut )
1281 workspace()->clientShortcutUpdated(
this );
1284 bool Workspace::shortcutAvailable(
const TDEShortcut& cut, Client* ignore )
const
1287 for( ClientList::ConstIterator it = clients.begin();
1288 it != clients.end();
1291 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)