21#include <tqpushbutton.h>
24#include <tqpopupmenu.h>
25#include <tdeglobalsettings.h>
26#include <kiconloader.h>
29#include <tdeglobalaccel.h>
30#include <tdeapplication.h>
37#include "killwindow.h"
47TQPopupMenu* 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 );
74TQPopupMenu* 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(setPopupClientTransparancy(
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 !tdeApp->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 );
146void Workspace::setPopupClientTransparancy(
int value)
148 active_popup_client->setCustomOpacityFlag(
true);
149 int opacityPercent = 100 - value;
150 active_popup_client->setOpacity(percentToUint(opacityPercent));
153void 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)+
" %");
166void 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());
180void 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());
225void 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 );
245void 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 );
275void Workspace::closeActivePopup()
279 active_popup->close();
281 active_popup_client = NULL;
288void Workspace::initShortcuts()
290 keys =
new TDEGlobalAccel(
this );
293 disable_shortcuts_keys =
new TDEGlobalAccel(
this );
294 disable_shortcuts_keys->disableBlocking(
true );
296#include "twinbindings.cpp"
300void 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();
323void 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;
345void 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;
360void 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();
374void 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 );
398void 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_ < Opacity::Opaque)
653 if (opacity_ < Opacity::Opaque - Opacity::MouseStep)
655 custom_opacity =
true;
656 setOpacity(opacity_ + Opacity::MouseStep);
660 if (defaultOpacity() == Opacity::Opaque)
661 custom_opacity =
false;
662 setOpacity(Opacity::Opaque);
666 case Options::MouseOpacityLess:
667 if (opacity_ > Opacity::Transparent)
669 custom_opacity =
true;
670 setOpacity((opacity_ > Opacity::MouseStep) ? opacity_ - Opacity::MouseStep : Opacity::Transparent);
673 case Options::MouseNothing:
680void Workspace::showWindowMenuAt(
unsigned long window,
int x,
int y )
683 if ((client = findClient(WindowMatchPredicate((WId)window))))
684 showWindowMenu( x, y, client );
687void Workspace::showWindowMenu(
unsigned long window )
690 if ((client = findClient(WindowMatchPredicate((WId)window))))
692 TQPoint pos = client->pos() + client->clientPos();
693 showWindowMenu( pos, client );
697void Workspace::tileCurrentWindowToBorder(
int position)
699 Client *c = active_popup_client ? active_popup_client : active_client;
702 c->tileToBorder((ActiveBorder)position);
705void Workspace::tileWindowToBorder(
unsigned long w1,
int location) {
706 if (location < ActiveTop || location >= ACTIVE_BORDER_COUNT)
return;
708 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
711 c1->tileToBorder((ActiveBorder)location);
714void Workspace::tileTwoWindowsHorizontally(
unsigned long w1,
unsigned long w2) {
715 if (w1 == w2)
return;
717 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
718 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
719 if (!c1 || !c2)
return;
721 c1->tileToBorder(ActiveTop);
722 c2->tileToBorder(ActiveBottom);
725void Workspace::tileTwoWindowsVertically(
unsigned long w1,
unsigned long w2) {
726 if (w1 == w2)
return;
728 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
729 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
730 if (!c1 || !c2)
return;
732 c1->tileToBorder(ActiveLeft);
733 c2->tileToBorder(ActiveRight);
736void Workspace::tileFourWindowsInGrid(
unsigned long w1,
unsigned long w2,
unsigned long w3,
unsigned long w4) {
737 if (w1 == w2 || w1 == w3 || w1 == w4 || w2 == w3 || w2 == w4 || w3 == w4)
740 Client *c1 = findClient(WindowMatchPredicate((WId)w1));
741 Client *c2 = findClient(WindowMatchPredicate((WId)w2));
742 Client *c3 = findClient(WindowMatchPredicate((WId)w3));
743 Client *c4 = findClient(WindowMatchPredicate((WId)w4));
744 if (!c1 || !c2 || !c3 || !c4)
return;
746 c1->tileToBorder(ActiveTopLeft);
747 c2->tileToBorder(ActiveTopRight);
748 c3->tileToBorder(ActiveBottomLeft);
749 c4->tileToBorder(ActiveBottomRight);
752void Workspace::slotActivateAttentionWindow()
754 if( attention_chain.count() > 0 )
755 activateClient( attention_chain.first());
758void Workspace::slotSwitchDesktopNext()
760 int d = currentDesktop() + 1;
761 if ( d > numberOfDesktops() )
763 if ( options->rollOverDesktops )
772 setCurrentDesktop(d);
775void Workspace::slotSwitchDesktopPrevious()
777 int d = currentDesktop() - 1;
780 if ( options->rollOverDesktops )
781 d = numberOfDesktops();
785 setCurrentDesktop(d);
788void Workspace::slotSwitchDesktopRight()
790 int desktop = desktopToRight( currentDesktop());
791 if( desktop == currentDesktop())
793 setCurrentDesktop( desktop );
796void Workspace::slotSwitchDesktopLeft()
798 int desktop = desktopToLeft( currentDesktop());
799 if( desktop == currentDesktop())
801 setCurrentDesktop( desktop );
804void Workspace::slotSwitchDesktopUp()
806 int desktop = desktopUp( currentDesktop());
807 if( desktop == currentDesktop())
809 setCurrentDesktop( desktop );
812void Workspace::slotSwitchDesktopDown()
814 int desktop = desktopDown( currentDesktop());
815 if( desktop == currentDesktop())
817 setCurrentDesktop( desktop );
820void Workspace::slotSwitchToDesktop(
int i )
822 setCurrentDesktop( i );
826void Workspace::slotWindowToDesktop(
int i )
828 Client* c = active_popup_client ? active_popup_client : active_client;
829 if( i >= 1 && i <= numberOfDesktops() && c
833 sendClientToDesktop( c, i,
true );
836void Workspace::slotSwitchToScreen(
int i )
838 setCurrentScreen( i );
841void Workspace::slotSwitchToNextScreen()
843 slotSwitchToScreen(( activeScreen() + 1 ) % numScreens());
846void Workspace::slotWindowToScreen(
int i )
848 Client* c = active_popup_client ? active_popup_client : active_client;
849 if( i >= 0 && i <= numScreens() && c
854 sendClientToScreen( c, i );
858void Workspace::slotWindowToNextScreen()
860 Client* c = active_popup_client ? active_popup_client : active_client;
866 sendClientToScreen( c, ( c->screen() + 1 ) % numScreens());
873void Workspace::slotWindowMaximize()
875 Client* c = active_popup_client ? active_popup_client : active_client;
877 performWindowOperation( c, Options::MaximizeOp );
883void Workspace::slotWindowMaximizeVertical()
885 Client* c = active_popup_client ? active_popup_client : active_client;
887 performWindowOperation( c, Options::VMaximizeOp );
893void Workspace::slotWindowMaximizeHorizontal()
895 Client* c = active_popup_client ? active_popup_client : active_client;
897 performWindowOperation( c, Options::HMaximizeOp );
904void Workspace::slotWindowMinimize()
906 Client* c = active_popup_client ? active_popup_client : active_client;
907 performWindowOperation( c, Options::MinimizeOp );
913void Workspace::slotWindowShade()
915 Client* c = active_popup_client ? active_popup_client : active_client;
916 performWindowOperation( c, Options::ShadeOp );
922void Workspace::slotWindowRaise()
924 Client* c = active_popup_client ? active_popup_client : active_client;
932void Workspace::slotWindowLower()
934 Client* c = active_popup_client ? active_popup_client : active_client;
942void Workspace::slotWindowRaiseOrLower()
944 Client* c = active_popup_client ? active_popup_client : active_client;
946 raiseOrLowerClient( c );
949void Workspace::slotWindowOnAllDesktops()
951 Client* c = active_popup_client ? active_popup_client : active_client;
953 c->setOnAllDesktops( !c->isOnAllDesktops());
956void Workspace::slotWindowFullScreen()
958 Client* c = active_popup_client ? active_popup_client : active_client;
960 performWindowOperation( c, Options::FullScreenOp );
963void Workspace::slotWindowNoBorder()
965 Client* c = active_popup_client ? active_popup_client : active_client;
967 performWindowOperation( c, Options::NoBorderOp );
970void Workspace::slotWindowAbove()
972 Client* c = active_popup_client ? active_popup_client : active_client;
974 performWindowOperation( c, Options::KeepAboveOp );
977void Workspace::slotWindowBelow()
979 Client* c = active_popup_client ? active_popup_client : active_client;
981 performWindowOperation( c, Options::KeepBelowOp );
983void Workspace::slotSetupWindowShortcut()
985 Client* c = active_popup_client ? active_popup_client : active_client;
987 performWindowOperation( c, Options::SetupWindowShortcutOp );
993void Workspace::slotWindowToNextDesktop()
995 windowToNextDesktop( active_popup_client ? active_popup_client : active_client );
998void Workspace::windowToNextDesktop( Client* c )
1000 int d = currentDesktop() + 1;
1001 if ( d > numberOfDesktops() )
1003 if (c && !c->isDesktop()
1004 && !c->isDock() && !c->isTopMenu())
1006 setClientIsMoving( c );
1007 setCurrentDesktop( d );
1008 setClientIsMoving( NULL );
1015void Workspace::slotWindowToPreviousDesktop()
1017 windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client );
1020void Workspace::windowToPreviousDesktop( Client* c )
1022 int d = currentDesktop() - 1;
1024 d = numberOfDesktops();
1025 if (c && !c->isDesktop()
1026 && !c->isDock() && !c->isTopMenu())
1028 setClientIsMoving( c );
1029 setCurrentDesktop( d );
1030 setClientIsMoving( NULL );
1034void Workspace::slotWindowToDesktopRight()
1036 int d = desktopToRight( currentDesktop());
1037 if( d == currentDesktop())
1039 Client* c = active_popup_client ? active_popup_client : active_client;
1040 if (c && !c->isDesktop()
1041 && !c->isDock() && !c->isTopMenu())
1043 setClientIsMoving( c );
1044 setCurrentDesktop( d );
1045 setClientIsMoving( NULL );
1049void Workspace::slotWindowToDesktopLeft()
1051 int d = desktopToLeft( currentDesktop());
1052 if( d == currentDesktop())
1054 Client* c = active_popup_client ? active_popup_client : active_client;
1055 if (c && !c->isDesktop()
1056 && !c->isDock() && !c->isTopMenu())
1058 setClientIsMoving( c );
1059 setCurrentDesktop( d );
1060 setClientIsMoving( NULL );
1064void Workspace::slotWindowToDesktopUp()
1066 int d = desktopUp( currentDesktop());
1067 if( d == currentDesktop())
1069 Client* c = active_popup_client ? active_popup_client : active_client;
1070 if (c && !c->isDesktop()
1071 && !c->isDock() && !c->isTopMenu())
1073 setClientIsMoving( c );
1074 setCurrentDesktop( d );
1075 setClientIsMoving( NULL );
1079void Workspace::slotWindowToDesktopDown()
1081 int d = desktopDown( currentDesktop());
1082 if( d == currentDesktop())
1084 Client* c = active_popup_client ? active_popup_client : active_client;
1085 if (c && !c->isDesktop()
1086 && !c->isDock() && !c->isTopMenu())
1088 setClientIsMoving( c );
1089 setCurrentDesktop( d );
1090 setClientIsMoving( NULL );
1098void Workspace::slotKillWindow()
1100 KillWindow kill(
this );
1107void Workspace::slotSuspendWindow()
1109 active_popup_client->suspendWindow();
1115void Workspace::slotResumeWindow()
1117 active_popup_client->resumeWindow();
1125void Workspace::slotSendToDesktop(
int desk )
1127 if ( !active_popup_client )
1131 active_popup_client->setOnAllDesktops( !active_popup_client->isOnAllDesktops());
1135 sendClientToDesktop( active_popup_client, desk,
false );
1142void Workspace::slotWindowOperations()
1144 if ( !active_client )
1146 TQPoint pos = active_client->pos() + active_client->clientPos();
1147 showWindowMenu( pos.x(), pos.y(), active_client );
1150void Workspace::showWindowMenu(
const TQRect &pos, Client* cl )
1152 if (!tdeApp->authorizeTDEAction(
"twin_rmb"))
1156 if( active_popup_client != NULL )
1158 if ( cl->isDesktop()
1161 || cl->isModalSystemNotification())
1164 active_popup_client = cl;
1165 TQPopupMenu* p = clientPopup();
1168 int y = pos.bottom();
1169 clientPopupAboutToShow();
1171 TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop());
1172 TQSize hint = p->sizeHint();
1173 if (x < 0) x = area.right() - hint.width() + x;
1174 if (y < 0) y = area.bottom() - hint.height() + y;
1176 if (pos.bottom() == pos.top())
1177 p->exec( TQPoint( x, y ) );
1180 if (y + hint.height() < area.height())
1181 p->exec( TQPoint( x, y ) );
1183 p->exec( TQPoint( x, pos.top() - hint.height() ) );
1186 if( active_popup == p )
1193void Workspace::slotWindowClose()
1195 if ( tab_box->isVisible())
1197 Client* c = active_popup_client ? active_popup_client : active_client;
1198 performWindowOperation( c, Options::CloseOp );
1204void Workspace::slotWindowMove()
1206 Client* c = active_popup_client ? active_popup_client : active_client;
1207 performWindowOperation( c, Options::UnrestrictedMoveOp );
1213void Workspace::slotWindowResize()
1215 Client* c = active_popup_client ? active_popup_client : active_client;
1216 performWindowOperation( c, Options::UnrestrictedResizeOp );
1219void Client::setShortcut(
const TQString& _cut )
1221 TQString cut = rules()->checkShortcut( _cut );
1223 return setShortcutInternal( TDEShortcut());
1227 if( !cut.contains(
'(' ) && !cut.contains(
')' ) && !cut.contains(
' ' ))
1229 if( workspace()->shortcutAvailable( TDEShortcut( cut ),
this ))
1230 setShortcutInternal( TDEShortcut( cut ));
1232 setShortcutInternal( TDEShortcut());
1235 TQValueList< TDEShortcut > keys;
1236 TQStringList groups = TQStringList::split(
' ', cut );
1237 for( TQStringList::ConstIterator it = groups.begin();
1241 TQRegExp reg(
"(.*\\+)\\((.*)\\)" );
1242 if( reg.search( *it ) > -1 )
1244 TQString base = reg.cap( 1 );
1245 TQString list = reg.cap( 2 );
1246 for(
unsigned int i = 0;
1250 TDEShortcut c( base + list[ i ] );
1256 for( TQValueList< TDEShortcut >::ConstIterator it = keys.begin();
1260 if( _shortcut == *it )
1263 for( TQValueList< TDEShortcut >::ConstIterator it = keys.begin();
1267 if( workspace()->shortcutAvailable( *it,
this ))
1269 setShortcutInternal( *it );
1273 setShortcutInternal( TDEShortcut());
1276void Client::setShortcutInternal(
const TDEShortcut& cut )
1278 if( _shortcut == cut )
1282 workspace()->clientShortcutUpdated(
this );
1285bool Workspace::shortcutAvailable(
const TDEShortcut& cut, Client* ignore )
const
1288 for( ClientList::ConstIterator it = clients.begin();
1289 it != clients.end();
1292 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)