summaryrefslogtreecommitdiffstats
path: root/twin/useractions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'twin/useractions.cpp')
-rw-r--r--twin/useractions.cpp197
1 files changed, 148 insertions, 49 deletions
diff --git a/twin/useractions.cpp b/twin/useractions.cpp
index 85e76e4cd..fe60c4d04 100644
--- a/twin/useractions.cpp
+++ b/twin/useractions.cpp
@@ -26,7 +26,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <kiconloader.h>
#include <tdelocale.h>
#include <tdeconfig.h>
-#include <kglobalaccel.h>
+#include <tdeglobalaccel.h>
#include <tdeapplication.h>
#include <tqregexp.h>
@@ -44,20 +44,47 @@ namespace KWinInternal
// Workspace
//****************************************
+TQPopupMenu* Workspace::makeTileMenu()
+{
+ TQPopupMenu *m = new TQPopupMenu;
+
+ // Tile to side (the menu id matched the ActiveBorder index used for tiling)
+ int id = m->insertItem( SmallIconSet("tile_left"), i18n("&Left"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
+ m->setItemParameter( id, 6 );
+ id = m->insertItem( SmallIconSet("tile_right"), i18n("&Right"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
+ m->setItemParameter( id, 2 );
+ id = m->insertItem( SmallIconSet("tile_top"), i18n("&Top"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
+ m->setItemParameter( id, 0 );
+ id = m->insertItem( SmallIconSet("tile_bottom"), i18n("&Bottom"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
+ m->setItemParameter( id, 4 );
+
+ // Tile to corner (the menu id matched the ActiveBorder index used for tiling)
+ id = m->insertItem( SmallIconSet("tile_topleft"), i18n("Top &Left"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
+ m->setItemParameter( id, 7 );
+ id = m->insertItem( SmallIconSet("tile_topright"), i18n("Top &Right"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
+ m->setItemParameter( id, 1 );
+ id = m->insertItem( SmallIconSet("tile_bottomleft"), i18n("Bottom L&eft"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
+ m->setItemParameter( id, 5 );
+ id = m->insertItem( SmallIconSet("tile_bottomright"), i18n("&Bottom R&ight"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
+ m->setItemParameter( id, 3 );
+
+ return m;
+}
+
TQPopupMenu* Workspace::clientPopup()
{
if ( !popup )
{
popup = new TQPopupMenu;
- popup->setCheckable( TRUE );
+ popup->setCheckable( true );
popup->setFont(TDEGlobalSettings::menuFont());
- connect( popup, TQT_SIGNAL( aboutToShow() ), this, TQT_SLOT( clientPopupAboutToShow() ) );
- connect( popup, TQT_SIGNAL( activated(int) ), this, TQT_SLOT( clientPopupActivated(int) ) );
+ connect( popup, TQ_SIGNAL( aboutToShow() ), this, TQ_SLOT( clientPopupAboutToShow() ) );
+ connect( popup, TQ_SIGNAL( activated(int) ), this, TQ_SLOT( clientPopupActivated(int) ) );
advanced_popup = new TQPopupMenu( popup );
- advanced_popup->setCheckable( TRUE );
+ advanced_popup->setCheckable( true );
advanced_popup->setFont(TDEGlobalSettings::menuFont());
- connect( advanced_popup, TQT_SIGNAL( activated(int) ), this, TQT_SLOT( clientPopupActivated(int) ) );
+ connect( advanced_popup, TQ_SIGNAL( activated(int) ), this, TQ_SLOT( clientPopupActivated(int) ) );
advanced_popup->insertItem( SmallIconSet( "go-up" ),
i18n("Keep &Above Others")+'\t'+keys->shortcut("Window Above Other Windows").seq(0).toString(), Options::KeepAboveOp );
advanced_popup->insertItem( SmallIconSet( "go-down" ),
@@ -67,15 +94,16 @@ TQPopupMenu* Workspace::clientPopup()
advanced_popup->insertItem( i18n("&No Border")+'\t'+keys->shortcut("Window No Border").seq(0).toString(), Options::NoBorderOp );
advanced_popup->insertItem( i18n("Shad&ow"), Options::ShadowOp );
advanced_popup->insertItem( SmallIconSet("key_bindings"),
- i18n("Window &Shortcut...")+'\t'+keys->shortcut("Setup Window Shortcut").seq(0).toString(), Options::SetupWindowShortcutOp );
+ i18n("Window &Shortcut…")+'\t'+keys->shortcut("Setup Window Shortcut").seq(0).toString(), Options::SetupWindowShortcutOp );
advanced_popup->insertSeparator();
advanced_popup->insertItem( SmallIconSet( "suspend" ), i18n("&Suspend Application"), Options::SuspendWindowOp );
advanced_popup->insertItem( SmallIconSet( "application-x-executable" ), i18n("&Resume Application"), Options::ResumeWindowOp );
advanced_popup->insertSeparator();
- advanced_popup->insertItem( SmallIconSet( "wizard" ), i18n("&Special Window Settings..."), Options::WindowRulesOp );
- advanced_popup->insertItem( SmallIconSet( "wizard" ), i18n("&Special Application Settings..."), Options::ApplicationRulesOp );
+ advanced_popup->insertItem( SmallIconSet( "wizard" ), i18n("&Special Window Settings…"), Options::WindowRulesOp );
+ advanced_popup->insertItem( SmallIconSet( "wizard" ), i18n("&Special Application Settings…"), Options::ApplicationRulesOp );
popup->insertItem(i18n("Ad&vanced"), advanced_popup );
+ tile_popup_index = popup->insertItem(i18n("T&ile"), makeTileMenu());
desk_popup_index = popup->count();
if (options->useTranslucency){
@@ -83,13 +111,13 @@ TQPopupMenu* Workspace::clientPopup()
TQVBox *transBox = new TQVBox(trans_popup);
transButton = new TQPushButton(transBox, "transButton");
TQToolTip::add(transButton, i18n("Reset opacity to default value"));
- transSlider = new TQSlider(0, 100, 1, 100, Qt::Horizontal, transBox, "transSlider");
+ transSlider = new TQSlider(0, 100, 1, 100, TQt::Horizontal, transBox, "transSlider");
TQToolTip::add(transSlider, i18n("Slide this to set the window's opacity"));
- connect(transButton, TQT_SIGNAL(clicked()), TQT_SLOT(resetClientOpacity()));
- connect(transButton, TQT_SIGNAL(clicked()), trans_popup, TQT_SLOT(hide()));
- connect(transSlider, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(setTransButtonText(int)));
- connect(transSlider, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(setPopupClientOpacity(int)));
-// connect(transSlider, TQT_SIGNAL(sliderReleased()), trans_popup, TQT_SLOT(hide()));
+ connect(transButton, TQ_SIGNAL(clicked()), TQ_SLOT(resetClientOpacity()));
+ connect(transButton, TQ_SIGNAL(clicked()), trans_popup, TQ_SLOT(hide()));
+ connect(transSlider, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(setTransButtonText(int)));
+ connect(transSlider, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(setPopupClientOpacity(int)));
+// connect(transSlider, TQ_SIGNAL(sliderReleased()), trans_popup, TQ_SLOT(hide()));
trans_popup->insertItem(transBox);
popup->insertItem(i18n("&Opacity"), trans_popup );
}
@@ -103,9 +131,9 @@ TQPopupMenu* Workspace::clientPopup()
popup->insertSeparator();
if (!TDEGlobal::config()->isImmutable() &&
- !kapp->authorizeControlModules(Workspace::configModules(true)).isEmpty())
+ !tdeApp->authorizeControlModules(Workspace::configModules(true)).isEmpty())
{
- popup->insertItem(SmallIconSet( "configure" ), i18n("Configur&e Window Behavior..."), this, TQT_SLOT( configureWM() ));
+ popup->insertItem(SmallIconSet( "configure" ), i18n("Configur&e Window Behavior…"), this, TQ_SLOT( configureWM() ));
popup->insertSeparator();
}
@@ -179,10 +207,11 @@ void Workspace::clientPopupAboutToShow()
advanced_popup->setItemEnabled( Options::ResumeWindowOp, active_popup_client->isResumeable() );
advanced_popup->setItemChecked( Options::NoBorderOp, active_popup_client->noBorder() );
advanced_popup->setItemEnabled( Options::NoBorderOp, active_popup_client->userCanSetNoBorder() );
-
advanced_popup->setItemEnabled( Options::ShadowOp, (options->shadowWindowType(active_popup_client->windowType()) && options->shadowEnabled(active_popup_client->isActive())) );
advanced_popup->setItemChecked( Options::ShadowOp, active_popup_client->isShadowed() );
+ popup->setItemEnabled( tile_popup_index, active_popup_client->isMovable() && active_popup_client->isResizable());
+
popup->setItemEnabled( Options::MinimizeOp, active_popup_client->isMinimizable() );
popup->setItemEnabled( Options::CloseOp, active_popup_client->isCloseable() );
if (options->useTranslucency)
@@ -199,12 +228,12 @@ void Workspace::initDesktopPopup()
return;
desk_popup = new TQPopupMenu( popup );
- desk_popup->setCheckable( TRUE );
+ desk_popup->setCheckable( true );
desk_popup->setFont(TDEGlobalSettings::menuFont());
- connect( desk_popup, TQT_SIGNAL( activated(int) ),
- this, TQT_SLOT( slotSendToDesktop(int) ) );
- connect( desk_popup, TQT_SIGNAL( aboutToShow() ),
- this, TQT_SLOT( desktopPopupAboutToShow() ) );
+ connect( desk_popup, TQ_SIGNAL( activated(int) ),
+ this, TQ_SLOT( slotSendToDesktop(int) ) );
+ connect( desk_popup, TQ_SIGNAL( aboutToShow() ),
+ this, TQ_SLOT( desktopPopupAboutToShow() ) );
popup->insertItem(i18n("To &Desktop"), desk_popup, -1, desk_popup_index );
}
@@ -221,7 +250,7 @@ void Workspace::desktopPopupAboutToShow()
desk_popup->clear();
desk_popup->insertItem( i18n("&All Desktops"), 0 );
if ( active_popup_client && active_popup_client->isOnAllDesktops() )
- desk_popup->setItemChecked( 0, TRUE );
+ desk_popup->setItemChecked( 0, true );
desk_popup->insertSeparator( -1 );
int id;
const int BASE = 10;
@@ -239,7 +268,7 @@ void Workspace::desktopPopupAboutToShow()
i );
if ( active_popup_client &&
!active_popup_client->isOnAllDesktops() && active_popup_client->desktop() == i )
- desk_popup->setItemChecked( id, TRUE );
+ desk_popup->setItemChecked( id, true );
}
}
@@ -299,7 +328,7 @@ void Workspace::setupWindowShortcut( Client* c )
client_keys->suspend( true );
client_keys_dialog = new ShortcutDialog( c->shortcut());
client_keys_client = c;
- connect( client_keys_dialog, TQT_SIGNAL( dialogDone( bool )), TQT_SLOT( setupWindowShortcutDone( bool )));
+ connect( client_keys_dialog, TQ_SIGNAL( dialogDone( bool )), TQ_SLOT( setupWindowShortcutDone( bool )));
TQRect r = clientArea( ScreenArea, c );
TQSize size = client_keys_dialog->sizeHint();
TQPoint pos = c->pos() + c->clientPos();
@@ -336,7 +365,7 @@ void Workspace::clientShortcutUpdated( Client* c )
{
client_keys->insert( key, key );
client_keys->setShortcut( key, c->shortcut());
- client_keys->setSlot( key, c, TQT_SLOT( shortcutActivated()));
+ client_keys->setSlot( key, c, TQ_SLOT( shortcutActivated()));
client_keys->setActionEnabled( key, true );
}
client_keys->updateConnections();
@@ -472,7 +501,7 @@ void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
*/
bool Client::performMouseCommand( Options::MouseCommand command, TQPoint globalPos, bool handled )
{
- bool replay = FALSE;
+ bool replay = false;
switch (command)
{
case Options::MouseRaise:
@@ -519,12 +548,12 @@ bool Client::performMouseCommand( Options::MouseCommand command, TQPoint globalP
case Options::MouseActivateRaiseAndPassClick:
workspace()->takeActivity( this, ActivityFocus | ActivityRaise, handled );
workspace()->setActiveScreenMouse( globalPos );
- replay = TRUE;
+ replay = true;
break;
case Options::MouseActivateAndPassClick:
workspace()->takeActivity( this, ActivityFocus, handled );
workspace()->setActiveScreenMouse( globalPos );
- replay = TRUE;
+ replay = true;
break;
case Options::MouseActivateRaiseAndMove:
case Options::MouseActivateRaiseAndUnrestrictedMove:
@@ -542,7 +571,7 @@ bool Client::performMouseCommand( Options::MouseCommand command, TQPoint globalP
if( moveResizeMode )
finishMoveResize( false );
mode = PositionCenter;
- buttonDown = TRUE;
+ buttonDown = true;
moveOffset = TQPoint( globalPos.x() - x(), globalPos.y() - y()); // map from global
invertedMoveOffset = rect().bottomRight() - moveOffset;
unrestrictedMoveResize = ( command == Options::MouseActivateRaiseAndUnrestrictedMove
@@ -562,7 +591,7 @@ bool Client::performMouseCommand( Options::MouseCommand command, TQPoint globalP
break;
if( moveResizeMode )
finishMoveResize( false );
- buttonDown = TRUE;
+ buttonDown = true;
moveOffset = TQPoint( globalPos.x() - x(), globalPos.y() - y()); // map from global
int x = moveOffset.x(), y = moveOffset.y();
bool left = x < width() / 3;
@@ -623,12 +652,12 @@ bool Client::performMouseCommand( Options::MouseCommand command, TQPoint globalP
{
if (opacity_ < 0xF3333333)
{
- setOpacity(TRUE, opacity_ + 0xCCCCCCC);
+ setOpacity(true, opacity_ + 0xCCCCCCC);
custom_opacity = true;
}
else
{
- setOpacity(FALSE, 0xFFFFFFFF);
+ setOpacity(false, 0xFFFFFFFF);
custom_opacity = false;
}
}
@@ -636,23 +665,89 @@ bool Client::performMouseCommand( Options::MouseCommand command, TQPoint globalP
case Options::MouseOpacityLess:
if (opacity_ > 0)
{
- setOpacity(TRUE, (opacity_ > 0xCCCCCCC) ? opacity_ - 0xCCCCCCC : 0);
+ setOpacity(true, (opacity_ > 0xCCCCCCC) ? opacity_ - 0xCCCCCCC : 0);
custom_opacity = true;
}
break;
case Options::MouseNothing:
- replay = TRUE;
+ replay = true;
break;
}
return replay;
}
-// KDE4 remove me
-void Workspace::showWindowMenuAt( unsigned long, int, int )
+void Workspace::showWindowMenuAt( unsigned long window, int x, int y )
+ {
+ Client *client;
+ if ((client = findClient(WindowMatchPredicate((WId)window))))
+ showWindowMenu( x, y, client );
+ }
+
+void Workspace::showWindowMenu( unsigned long window )
{
- slotWindowOperations();
+ Client *client;
+ if ((client = findClient(WindowMatchPredicate((WId)window))))
+ {
+ TQPoint pos = client->pos() + client->clientPos();
+ showWindowMenu( pos, client );
+ }
}
+void Workspace::tileCurrentWindowToBorder(int position)
+{
+ Client *c = active_popup_client ? active_popup_client : active_client;
+ if (!c) return;
+
+ c->tileToBorder((ActiveBorder)position);
+}
+
+void Workspace::tileWindowToBorder(unsigned long w1, int location) {
+ if (location < ActiveTop || location >= ACTIVE_BORDER_COUNT) return;
+
+ Client *c1 = findClient(WindowMatchPredicate((WId)w1));
+ if (!c1) return;
+
+ c1->tileToBorder((ActiveBorder)location);
+}
+
+void Workspace::tileTwoWindowsHorizontally(unsigned long w1, unsigned long w2) {
+ if (w1 == w2) return;
+
+ Client *c1 = findClient(WindowMatchPredicate((WId)w1));
+ Client *c2 = findClient(WindowMatchPredicate((WId)w2));
+ if (!c1 || !c2) return;
+
+ c1->tileToBorder(ActiveTop);
+ c2->tileToBorder(ActiveBottom);
+}
+
+void Workspace::tileTwoWindowsVertically(unsigned long w1, unsigned long w2) {
+ if (w1 == w2) return;
+
+ Client *c1 = findClient(WindowMatchPredicate((WId)w1));
+ Client *c2 = findClient(WindowMatchPredicate((WId)w2));
+ if (!c1 || !c2) return;
+
+ c1->tileToBorder(ActiveLeft);
+ c2->tileToBorder(ActiveRight);
+}
+
+void Workspace::tileFourWindowsInGrid(unsigned long w1, unsigned long w2, unsigned long w3, unsigned long w4) {
+ if (w1 == w2 || w1 == w3 || w1 == w4 || w2 == w3 || w2 == w4 || w3 == w4)
+ return;
+
+ Client *c1 = findClient(WindowMatchPredicate((WId)w1));
+ Client *c2 = findClient(WindowMatchPredicate((WId)w2));
+ Client *c3 = findClient(WindowMatchPredicate((WId)w3));
+ Client *c4 = findClient(WindowMatchPredicate((WId)w4));
+ if (!c1 || !c2 || !c3 || !c4) return;
+
+ c1->tileToBorder(ActiveTopLeft);
+ c2->tileToBorder(ActiveTopRight);
+ c3->tileToBorder(ActiveBottomLeft);
+ c4->tileToBorder(ActiveBottomRight);
+}
+
void Workspace::slotActivateAttentionWindow()
{
if( attention_chain.count() > 0 )
@@ -1053,7 +1148,7 @@ void Workspace::slotWindowOperations()
void Workspace::showWindowMenu( const TQRect &pos, Client* cl )
{
- if (!kapp->authorizeTDEAction("twin_rmb"))
+ if (!tdeApp->authorizeTDEAction("twin_rmb"))
return;
if( !cl )
return;
@@ -1070,17 +1165,21 @@ void Workspace::showWindowMenu( const TQRect &pos, Client* cl )
active_popup = p;
int x = pos.left();
int y = pos.bottom();
- if (y == pos.top())
- p->exec( TQPoint( x, y ) );
+ clientPopupAboutToShow(); // needed for sizeHint() to be correct :-/
+
+ TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop());
+ TQSize hint = p->sizeHint();
+ if (x < 0) x = area.right() - hint.width() + x;
+ if (y < 0) y = area.bottom() - hint.height() + y;
+
+ if (pos.bottom() == pos.top())
+ p->exec( TQPoint( x, y ) );
else
{
- TQRect area = clientArea(ScreenArea, TQPoint(x, y), currentDesktop());
- clientPopupAboutToShow(); // needed for sizeHint() to be correct :-/
- int popupHeight = p->sizeHint().height();
- if (y + popupHeight < area.height())
- p->exec( TQPoint( x, y ) );
- else
- p->exec( TQPoint( x, pos.top() - popupHeight ) );
+ if (y + hint.height() < area.height())
+ p->exec( TQPoint( x, y ) );
+ else
+ p->exec( TQPoint( x, pos.top() - hint.height() ) );
}
// active popup may be already changed (e.g. the window shortcut dialog)
if( active_popup == p )