2003-09-16 19:28:03 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file contains things relevant to direct user actions, such as
|
|
|
|
responses to global keyboard shortcuts, or selecting actions
|
|
|
|
from the window operations menu.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "client.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
#include <fixx11h.h>
|
2006-05-11 08:04:23 +00:00
|
|
|
#include <QPushButton>
|
2006-05-13 16:33:18 +00:00
|
|
|
#include <QSlider>
|
2006-05-11 08:04:23 +00:00
|
|
|
#include <QToolTip>
|
2003-09-16 19:28:03 +00:00
|
|
|
#include <kglobalsettings.h>
|
|
|
|
#include <kiconloader.h>
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kglobalaccel.h>
|
|
|
|
#include <kapplication.h>
|
2006-05-11 08:04:23 +00:00
|
|
|
#include <QRegExp>
|
2005-11-30 21:17:50 +00:00
|
|
|
#include <QMenu>
|
2005-07-28 14:59:42 +00:00
|
|
|
#include <QVBoxLayout>
|
2005-10-03 15:13:54 +00:00
|
|
|
#include <kauthorized.h>
|
2006-04-10 11:57:13 +00:00
|
|
|
#include <kactioncollection.h>
|
|
|
|
#include <kaction.h>
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
#include "killwindow.h"
|
|
|
|
#include "tabbox.h"
|
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// Workspace
|
|
|
|
//****************************************
|
|
|
|
|
2005-11-30 21:17:50 +00:00
|
|
|
QMenu* Workspace::clientPopup()
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2003-09-26 21:32:49 +00:00
|
|
|
if ( !popup )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2005-11-30 21:17:50 +00:00
|
|
|
popup = new QMenu;
|
2003-09-16 19:28:03 +00:00
|
|
|
popup->setFont(KGlobalSettings::menuFont());
|
|
|
|
connect( popup, SIGNAL( aboutToShow() ), this, SLOT( clientPopupAboutToShow() ) );
|
2006-04-12 15:13:31 +00:00
|
|
|
connect( popup, SIGNAL( triggered(QAction*) ), this, SLOT( clientPopupActivated(QAction*) ) );
|
|
|
|
|
2005-11-30 21:17:50 +00:00
|
|
|
advanced_popup = new QMenu( popup );
|
2004-02-13 15:15:37 +00:00
|
|
|
advanced_popup->setFont(KGlobalSettings::menuFont());
|
2006-04-12 15:13:31 +00:00
|
|
|
|
|
|
|
mKeepAboveOpAction = advanced_popup->addAction( i18n("Keep &Above Others") );
|
|
|
|
mKeepAboveOpAction->setIcon( SmallIconSet( "up" ) );
|
2006-10-28 02:01:19 +00:00
|
|
|
mKeepAboveOpAction->setShortcut( keys->action("Window Above Other Windows")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mKeepAboveOpAction->setCheckable( true );
|
|
|
|
mKeepAboveOpAction->setData( Options::KeepAboveOp );
|
|
|
|
|
|
|
|
mKeepBelowOpAction = advanced_popup->addAction( i18n("Keep &Below Others") );
|
|
|
|
mKeepBelowOpAction->setIcon( SmallIconSet( "down" ) );
|
2006-10-28 02:01:19 +00:00
|
|
|
mKeepBelowOpAction->setShortcut( keys->action("Window Below Other Windows")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mKeepBelowOpAction->setCheckable( true );
|
|
|
|
mKeepBelowOpAction->setData( Options::KeepBelowOp );
|
|
|
|
|
|
|
|
mFullScreenOpAction = advanced_popup->addAction( i18n("&Fullscreen") );
|
|
|
|
mFullScreenOpAction->setIcon( SmallIconSet( "window_fullscreen" ) );
|
2006-10-28 02:01:19 +00:00
|
|
|
mFullScreenOpAction->setShortcut( keys->action("Window Fullscreen")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mFullScreenOpAction->setCheckable( true );
|
|
|
|
mFullScreenOpAction->setData( Options::FullScreenOp );
|
|
|
|
|
|
|
|
mNoBorderOpAction = advanced_popup->addAction( i18n("&No Border") );
|
2006-10-28 02:01:19 +00:00
|
|
|
mNoBorderOpAction->setShortcut( keys->action("Window No Border")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mNoBorderOpAction->setCheckable( true );
|
|
|
|
mNoBorderOpAction->setData( Options::NoBorderOp );
|
|
|
|
|
|
|
|
QAction *action = advanced_popup->addAction( i18n("Window &Shortcut...") );
|
|
|
|
action->setIcon( SmallIconSet("key_bindings") );
|
2006-10-28 02:01:19 +00:00
|
|
|
action->setShortcut( keys->action("Setup Window Shortcut")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
action->setData( Options::SetupWindowShortcutOp );
|
|
|
|
|
|
|
|
action = advanced_popup->addAction( i18n("&Special Window Settings...") );
|
|
|
|
action->setIcon( SmallIconSet( "wizard" ) );
|
|
|
|
action->setData( Options::WindowRulesOp );
|
|
|
|
|
|
|
|
action = advanced_popup->addAction( i18n("&Special Application Settings...") );
|
|
|
|
action->setIcon( SmallIconSet( "wizard" ) );
|
|
|
|
action->setData( Options::ApplicationRulesOp );
|
|
|
|
|
|
|
|
action = popup->addMenu( advanced_popup );
|
|
|
|
action->setText( i18n("Ad&vanced") );
|
|
|
|
|
|
|
|
desk_popup_index = popup->actions().count();
|
|
|
|
|
2005-01-15 17:07:48 +00:00
|
|
|
if (options->useTranslucency){
|
2005-11-30 21:17:50 +00:00
|
|
|
QMenu *trans_popup = new QMenu( popup );
|
2006-04-12 15:13:31 +00:00
|
|
|
QVBoxLayout *transLayout = new QVBoxLayout(trans_popup);
|
|
|
|
trans_popup->setLayout( transLayout );
|
|
|
|
transButton = new QPushButton(trans_popup);
|
|
|
|
transButton->setObjectName("transButton");
|
2005-09-21 09:14:36 +00:00
|
|
|
transButton->setToolTip( i18n("Reset opacity to default value"));
|
2006-04-12 15:13:31 +00:00
|
|
|
transSlider = new QSlider(trans_popup);
|
|
|
|
transSlider->setObjectName( "transSlider" );
|
|
|
|
transSlider->setRange( 0, 100 );
|
|
|
|
transSlider->setValue( 100 );
|
|
|
|
transSlider->setOrientation( Qt::Vertical );
|
2005-09-21 09:14:36 +00:00
|
|
|
transSlider->setToolTip( i18n("Slide this to set the window's opacity"));
|
2005-01-15 17:07:48 +00:00
|
|
|
connect(transButton, SIGNAL(clicked()), SLOT(resetClientOpacity()));
|
|
|
|
connect(transButton, SIGNAL(clicked()), trans_popup, SLOT(hide()));
|
|
|
|
connect(transSlider, SIGNAL(valueChanged(int)), SLOT(setTransButtonText(int)));
|
2005-02-20 23:04:19 +00:00
|
|
|
connect(transSlider, SIGNAL(valueChanged(int)), this, SLOT(setPopupClientOpacity(int)));
|
2006-04-12 15:13:31 +00:00
|
|
|
action = popup->addMenu( trans_popup );
|
|
|
|
action->setText( i18n("&Opacity") );
|
2005-01-15 17:07:48 +00:00
|
|
|
}
|
2003-09-26 21:32:49 +00:00
|
|
|
|
2006-04-12 15:13:31 +00:00
|
|
|
mMoveOpAction = popup->addAction( i18n("&Move") );
|
|
|
|
mMoveOpAction->setIcon( SmallIconSet( "move" ) );
|
2006-10-28 02:01:19 +00:00
|
|
|
mMoveOpAction->setShortcut( keys->action("Window Move")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mMoveOpAction->setData( Options::MoveOp );
|
|
|
|
|
|
|
|
mResizeOpAction = popup->addAction( i18n("Re&size") );
|
2006-10-28 02:01:19 +00:00
|
|
|
mResizeOpAction->setShortcut( keys->action("Window Resize")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mResizeOpAction->setData( Options::ResizeOp );
|
|
|
|
|
|
|
|
mMinimizeOpAction = popup->addAction( i18n("Mi&nimize") );
|
2006-10-28 02:01:19 +00:00
|
|
|
mMinimizeOpAction->setShortcut( keys->action("Window Minimize")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mMinimizeOpAction->setData( Options::MinimizeOp );
|
|
|
|
|
|
|
|
mMaximizeOpAction = popup->addAction( i18n("Ma&ximize") );
|
2006-10-28 02:01:19 +00:00
|
|
|
mMaximizeOpAction->setShortcut( keys->action("Window Maximize")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mMaximizeOpAction->setCheckable( true );
|
|
|
|
mMaximizeOpAction->setData( Options::MaximizeOp );
|
|
|
|
|
|
|
|
mShadeOpAction = popup->addAction( i18n("Sh&ade") );
|
2006-10-28 02:01:19 +00:00
|
|
|
mShadeOpAction->setShortcut( keys->action("Window Shade")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mShadeOpAction->setCheckable( true );
|
|
|
|
mShadeOpAction->setData( Options::ShadeOp );
|
|
|
|
|
|
|
|
popup->addSeparator();
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2004-03-18 13:18:41 +00:00
|
|
|
if (!KGlobal::config()->isImmutable() &&
|
2005-10-22 18:13:37 +00:00
|
|
|
!KAuthorized::authorizeControlModules(Workspace::configModules(true)).isEmpty())
|
2004-02-13 15:15:37 +00:00
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
action = popup->addAction( i18n("Configur&e Window Behavior...") );
|
|
|
|
action->setIcon( SmallIconSet( "configure" ) );
|
|
|
|
connect( action, SIGNAL( triggered() ), this, SLOT( configureWM() ) );
|
|
|
|
popup->addSeparator();
|
2004-02-13 15:15:37 +00:00
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
|
2006-04-12 15:13:31 +00:00
|
|
|
mCloseOpAction = popup->addAction( i18n("&Close") );
|
|
|
|
mCloseOpAction->setIcon( SmallIconSet( "fileclose" ) );
|
2006-10-28 02:01:19 +00:00
|
|
|
mCloseOpAction->setShortcut( keys->action("Window Close")->globalShortcut() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mCloseOpAction->setData( Options::CloseOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
return popup;
|
|
|
|
}
|
2006-04-12 15:13:31 +00:00
|
|
|
|
2005-01-15 17:07:48 +00:00
|
|
|
void Workspace::setPopupClientOpacity(int value)
|
|
|
|
{
|
2006-10-29 19:40:24 +00:00
|
|
|
if( active_popup_client == NULL )
|
|
|
|
return;
|
|
|
|
active_popup_client->setOpacity( value / 100.0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::resetClientOpacity()
|
|
|
|
{
|
|
|
|
if( active_popup_client == NULL )
|
|
|
|
return;
|
|
|
|
active_popup_client->setOpacity( 1.0 );
|
2005-01-15 17:07:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::setTransButtonText(int value)
|
|
|
|
{
|
|
|
|
value = 100 - value;
|
|
|
|
if(value < 0)
|
|
|
|
transButton->setText("000 %");
|
|
|
|
else if (value >= 100 )
|
|
|
|
transButton->setText("100 %");
|
|
|
|
else if(value < 10)
|
|
|
|
transButton->setText("00"+QString::number(value)+" %");
|
|
|
|
else if(value < 100)
|
2006-05-20 15:56:37 +00:00
|
|
|
transButton->setText('0'+QString::number(value)+" %");
|
2005-01-15 17:07:48 +00:00
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
The client popup menu will become visible soon.
|
|
|
|
|
|
|
|
Adjust the items according to the respective popup client.
|
|
|
|
*/
|
|
|
|
void Workspace::clientPopupAboutToShow()
|
|
|
|
{
|
2005-01-10 09:56:21 +00:00
|
|
|
if ( !active_popup_client || !popup )
|
2003-09-16 19:28:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ( numberOfDesktops() == 1 )
|
|
|
|
{
|
|
|
|
delete desk_popup;
|
|
|
|
desk_popup = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
initDesktopPopup();
|
|
|
|
}
|
|
|
|
|
2006-04-12 15:13:31 +00:00
|
|
|
mResizeOpAction->setEnabled( active_popup_client->isResizable() );
|
|
|
|
mMoveOpAction->setEnabled( active_popup_client->isMovable() );
|
|
|
|
mMaximizeOpAction->setEnabled( active_popup_client->isMaximizable() );
|
|
|
|
mMaximizeOpAction->setChecked( active_popup_client->maximizeMode() == Client::MaximizeFull );
|
|
|
|
mShadeOpAction->setEnabled( active_popup_client->isShadeable() );
|
|
|
|
mShadeOpAction->setChecked( active_popup_client->shadeMode() != ShadeNone );
|
|
|
|
mKeepAboveOpAction->setChecked( active_popup_client->keepAbove() );
|
|
|
|
mKeepBelowOpAction->setChecked( active_popup_client->keepBelow() );
|
|
|
|
mFullScreenOpAction->setEnabled( active_popup_client->userCanSetFullScreen() );
|
|
|
|
mFullScreenOpAction->setChecked( active_popup_client->isFullScreen() );
|
|
|
|
mNoBorderOpAction->setEnabled( active_popup_client->userCanSetNoBorder() );
|
|
|
|
mNoBorderOpAction->setChecked( active_popup_client->noBorder() );
|
|
|
|
mMinimizeOpAction->setEnabled( active_popup_client->isMinimizable() );
|
|
|
|
mCloseOpAction->setEnabled( active_popup_client->isCloseable() );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::initDesktopPopup()
|
|
|
|
{
|
|
|
|
if (desk_popup)
|
|
|
|
return;
|
|
|
|
|
2005-11-30 21:17:50 +00:00
|
|
|
desk_popup = new QMenu( popup );
|
2003-09-16 19:28:03 +00:00
|
|
|
desk_popup->setFont(KGlobalSettings::menuFont());
|
2006-04-12 15:13:31 +00:00
|
|
|
connect( desk_popup, SIGNAL( triggered(QAction*) ),
|
|
|
|
this, SLOT( slotSendToDesktop(QAction*) ) );
|
2003-09-16 19:28:03 +00:00
|
|
|
connect( desk_popup, SIGNAL( aboutToShow() ),
|
|
|
|
this, SLOT( desktopPopupAboutToShow() ) );
|
|
|
|
|
2006-04-12 15:13:31 +00:00
|
|
|
QAction *action = popup->addMenu( desk_popup );
|
|
|
|
action->setText( i18n("To &Desktop") );
|
|
|
|
action->setData( desk_popup_index );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Adjusts the desktop popup to the current values and the location of
|
|
|
|
the popup client.
|
|
|
|
*/
|
|
|
|
void Workspace::desktopPopupAboutToShow()
|
|
|
|
{
|
|
|
|
if ( !desk_popup )
|
|
|
|
return;
|
|
|
|
|
|
|
|
desk_popup->clear();
|
2006-04-12 15:13:31 +00:00
|
|
|
QAction *action = desk_popup->addAction( i18n("&All Desktops") );
|
|
|
|
action->setData( 0 );
|
|
|
|
action->setCheckable( true );
|
|
|
|
|
2005-01-20 15:10:03 +00:00
|
|
|
if ( active_popup_client && active_popup_client->isOnAllDesktops() )
|
2006-04-12 15:13:31 +00:00
|
|
|
action->setChecked( true );
|
|
|
|
desk_popup->addSeparator();
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
const int BASE = 10;
|
2006-04-12 15:13:31 +00:00
|
|
|
for ( int i = 1; i <= numberOfDesktops(); i++ ) {
|
2003-09-16 19:28:03 +00:00
|
|
|
QString basic_name("%1 %2");
|
2006-04-12 15:13:31 +00:00
|
|
|
if (i<BASE) {
|
2003-09-16 19:28:03 +00:00
|
|
|
basic_name.prepend('&');
|
2006-04-12 15:13:31 +00:00
|
|
|
}
|
|
|
|
action = desk_popup->addAction( basic_name.arg(i).arg( desktopName(i).replace( '&', "&&" ) ) );
|
|
|
|
action->setData( i );
|
|
|
|
action->setCheckable( true );
|
|
|
|
|
2005-01-20 15:10:03 +00:00
|
|
|
if ( active_popup_client &&
|
|
|
|
!active_popup_client->isOnAllDesktops() && active_popup_client->desktop() == i )
|
2006-04-12 15:13:31 +00:00
|
|
|
action->setChecked( true );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-10 09:56:21 +00:00
|
|
|
void Workspace::closeActivePopup()
|
|
|
|
{
|
|
|
|
if( active_popup )
|
|
|
|
{
|
|
|
|
active_popup->close();
|
|
|
|
active_popup = NULL;
|
|
|
|
active_popup_client = NULL;
|
|
|
|
}
|
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Create the global accel object \c keys.
|
|
|
|
*/
|
|
|
|
void Workspace::initShortcuts()
|
|
|
|
{
|
2006-04-10 11:57:13 +00:00
|
|
|
keys = new KActionCollection( this );
|
|
|
|
KActionCollection* actionCollection = keys;
|
|
|
|
KAction* a = 0L;
|
|
|
|
|
|
|
|
// a separate KActionCollection is needed for the shortcut for disabling global shortcuts,
|
2005-08-02 13:25:20 +00:00
|
|
|
// otherwise it would also disable itself
|
2006-04-10 11:57:13 +00:00
|
|
|
disable_shortcuts_keys = new KActionCollection( this );
|
|
|
|
// FIXME KAccel port... needed?
|
|
|
|
//disable_shortcuts_keys->disableBlocking( true );
|
2005-08-02 13:25:20 +00:00
|
|
|
#define IN_KWIN
|
2003-09-16 19:28:03 +00:00
|
|
|
#include "kwinbindings.cpp"
|
|
|
|
readShortcuts();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::readShortcuts()
|
|
|
|
{
|
2006-04-10 11:57:13 +00:00
|
|
|
KGlobalAccel::self()->readSettings();
|
|
|
|
|
2006-10-28 01:40:01 +00:00
|
|
|
cutWalkThroughDesktops = keys->action("Walk Through Desktops")->globalShortcut();
|
|
|
|
cutWalkThroughDesktopsReverse = keys->action("Walk Through Desktops (Reverse)")->globalShortcut();
|
|
|
|
cutWalkThroughDesktopList = keys->action("Walk Through Desktop List")->globalShortcut();
|
|
|
|
cutWalkThroughDesktopListReverse = keys->action("Walk Through Desktop List (Reverse)")->globalShortcut();
|
|
|
|
cutWalkThroughWindows = keys->action("Walk Through Windows")->globalShortcut();
|
|
|
|
cutWalkThroughWindowsReverse = keys->action("Walk Through Windows (Reverse)")->globalShortcut();
|
2006-04-10 11:57:13 +00:00
|
|
|
|
2004-06-28 13:15:05 +00:00
|
|
|
delete popup;
|
|
|
|
popup = NULL; // so that it's recreated next time
|
2004-06-28 14:02:32 +00:00
|
|
|
desk_popup = NULL;
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-10 09:56:21 +00:00
|
|
|
void Workspace::setupWindowShortcut( Client* c )
|
|
|
|
{
|
|
|
|
assert( client_keys_dialog == NULL );
|
|
|
|
keys->setEnabled( false );
|
2005-08-02 13:25:20 +00:00
|
|
|
disable_shortcuts_keys->setEnabled( false );
|
2005-01-10 09:56:21 +00:00
|
|
|
client_keys->setEnabled( false );
|
|
|
|
client_keys_dialog = new ShortcutDialog( c->shortcut());
|
|
|
|
client_keys_client = c;
|
|
|
|
connect( client_keys_dialog, SIGNAL( dialogDone( bool )), SLOT( setupWindowShortcutDone( bool )));
|
|
|
|
QRect r = clientArea( ScreenArea, c );
|
|
|
|
QSize size = client_keys_dialog->sizeHint();
|
|
|
|
QPoint pos = c->pos() + c->clientPos();
|
|
|
|
if( pos.x() + size.width() >= r.right())
|
|
|
|
pos.setX( r.right() - size.width());
|
|
|
|
if( pos.y() + size.height() >= r.bottom())
|
|
|
|
pos.setY( r.bottom() - size.height());
|
|
|
|
client_keys_dialog->move( pos );
|
|
|
|
client_keys_dialog->show();
|
|
|
|
active_popup = client_keys_dialog;
|
|
|
|
active_popup_client = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::setupWindowShortcutDone( bool ok )
|
|
|
|
{
|
|
|
|
keys->setEnabled( true );
|
2005-08-02 13:25:20 +00:00
|
|
|
disable_shortcuts_keys->setEnabled( true );
|
2005-01-10 09:56:21 +00:00
|
|
|
client_keys->setEnabled( true );
|
|
|
|
if( ok )
|
|
|
|
{
|
2005-01-17 15:53:14 +00:00
|
|
|
client_keys_client->setShortcut( KShortcut( client_keys_dialog->shortcut()).toString());
|
2005-01-10 09:56:21 +00:00
|
|
|
}
|
|
|
|
closeActivePopup();
|
|
|
|
delete client_keys_dialog;
|
|
|
|
client_keys_dialog = NULL;
|
|
|
|
client_keys_client = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::clientShortcutUpdated( Client* c )
|
|
|
|
{
|
|
|
|
QString key = QString::number( c->window());
|
2006-04-10 11:57:13 +00:00
|
|
|
KAction* action = client_keys->action( key.toLatin1().constData() );
|
2005-01-10 09:56:21 +00:00
|
|
|
if( !c->shortcut().isNull())
|
|
|
|
{
|
2006-04-10 11:57:13 +00:00
|
|
|
action->setShortcut(c->shortcut());
|
|
|
|
connect(action, SIGNAL(triggered(bool)), c, SLOT(shortcutActivated()));
|
|
|
|
action->setEnabled( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete action;
|
2005-01-10 09:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-12 15:13:31 +00:00
|
|
|
void Workspace::clientPopupActivated( QAction *action )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
if ( !action->data().isValid() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
WindowOperation op = static_cast< WindowOperation >( action->data().toInt() );
|
2005-01-10 09:56:21 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
2003-10-13 16:22:39 +00:00
|
|
|
QString type;
|
|
|
|
switch( op )
|
|
|
|
{
|
|
|
|
case FullScreenOp:
|
|
|
|
if( !c->isFullScreen() && c->userCanSetFullScreen())
|
|
|
|
type = "fullscreenaltf3";
|
|
|
|
break;
|
|
|
|
case NoBorderOp:
|
|
|
|
if( !c->noBorder() && c->userCanSetNoBorder())
|
|
|
|
type = "noborderaltf3";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
if( !type.isEmpty())
|
|
|
|
helperDialog( type, c );
|
|
|
|
performWindowOperation( c, op );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
|
|
|
|
{
|
|
|
|
if ( !c )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (op == Options::MoveOp || op == Options::UnrestrictedMoveOp )
|
|
|
|
QCursor::setPos( c->geometry().center() );
|
|
|
|
if (op == Options::ResizeOp || op == Options::UnrestrictedResizeOp )
|
|
|
|
QCursor::setPos( c->geometry().bottomRight());
|
|
|
|
switch ( op )
|
|
|
|
{
|
|
|
|
case Options::MoveOp:
|
|
|
|
c->performMouseCommand( Options::MouseMove, QCursor::pos() );
|
|
|
|
break;
|
|
|
|
case Options::UnrestrictedMoveOp:
|
|
|
|
c->performMouseCommand( Options::MouseUnrestrictedMove, QCursor::pos() );
|
|
|
|
break;
|
|
|
|
case Options::ResizeOp:
|
|
|
|
c->performMouseCommand( Options::MouseResize, QCursor::pos() );
|
|
|
|
break;
|
|
|
|
case Options::UnrestrictedResizeOp:
|
|
|
|
c->performMouseCommand( Options::MouseUnrestrictedResize, QCursor::pos() );
|
|
|
|
break;
|
|
|
|
case Options::CloseOp:
|
|
|
|
c->closeWindow();
|
|
|
|
break;
|
|
|
|
case Options::MaximizeOp:
|
|
|
|
c->maximize( c->maximizeMode() == Client::MaximizeFull
|
|
|
|
? Client::MaximizeRestore : Client::MaximizeFull );
|
|
|
|
break;
|
|
|
|
case Options::HMaximizeOp:
|
|
|
|
c->maximize( c->maximizeMode() ^ Client::MaximizeHorizontal );
|
|
|
|
break;
|
|
|
|
case Options::VMaximizeOp:
|
|
|
|
c->maximize( c->maximizeMode() ^ Client::MaximizeVertical );
|
|
|
|
break;
|
2005-05-06 15:20:49 +00:00
|
|
|
case Options::RestoreOp:
|
|
|
|
c->maximize( Client::MaximizeRestore );
|
2006-04-09 09:43:31 +00:00
|
|
|
break;
|
2003-09-16 19:28:03 +00:00
|
|
|
case Options::MinimizeOp:
|
|
|
|
c->minimize();
|
|
|
|
break;
|
|
|
|
case Options::ShadeOp:
|
2005-01-28 13:44:08 +00:00
|
|
|
c->performMouseCommand( Options::MouseShade, QCursor::pos());
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
case Options::OnAllDesktopsOp:
|
|
|
|
c->setOnAllDesktops( !c->isOnAllDesktops() );
|
|
|
|
break;
|
|
|
|
case Options::FullScreenOp:
|
|
|
|
c->setFullScreen( !c->isFullScreen(), true );
|
|
|
|
break;
|
|
|
|
case Options::NoBorderOp:
|
|
|
|
c->setUserNoBorder( !c->isUserNoBorder());
|
|
|
|
break;
|
|
|
|
case Options::KeepAboveOp:
|
2005-05-02 12:49:06 +00:00
|
|
|
{
|
|
|
|
StackingUpdatesBlocker blocker( this );
|
|
|
|
bool was = c->keepAbove();
|
2003-09-16 19:28:03 +00:00
|
|
|
c->setKeepAbove( !c->keepAbove() );
|
2005-05-02 12:49:06 +00:00
|
|
|
if( was && !c->keepAbove())
|
|
|
|
raiseClient( c );
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
2005-05-02 12:49:06 +00:00
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
case Options::KeepBelowOp:
|
2005-05-02 12:49:06 +00:00
|
|
|
{
|
|
|
|
StackingUpdatesBlocker blocker( this );
|
|
|
|
bool was = c->keepBelow();
|
2005-05-06 13:07:23 +00:00
|
|
|
c->setKeepBelow( !c->keepBelow() );
|
2005-05-02 12:49:06 +00:00
|
|
|
if( was && !c->keepBelow())
|
|
|
|
lowerClient( c );
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
2005-05-02 12:49:06 +00:00
|
|
|
}
|
2005-05-06 15:20:49 +00:00
|
|
|
case Options::OperationsOp:
|
|
|
|
c->performMouseCommand( Options::MouseShade, QCursor::pos());
|
|
|
|
break;
|
2004-05-28 13:51:11 +00:00
|
|
|
case Options::WindowRulesOp:
|
2005-08-16 17:46:42 +00:00
|
|
|
editWindowRules( c, false );
|
|
|
|
break;
|
|
|
|
case Options::ApplicationRulesOp:
|
|
|
|
editWindowRules( c, true );
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
2005-01-10 09:56:21 +00:00
|
|
|
case Options::SetupWindowShortcutOp:
|
|
|
|
setupWindowShortcut( c );
|
|
|
|
break;
|
2003-09-16 19:28:03 +00:00
|
|
|
case Options::LowerOp:
|
|
|
|
lowerClient(c);
|
|
|
|
break;
|
2005-05-06 15:20:49 +00:00
|
|
|
case Options::NoOp:
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Performs a mouse command on this client (see options.h)
|
|
|
|
*/
|
2004-04-16 10:23:42 +00:00
|
|
|
bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPos, bool handled )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2006-02-19 01:33:48 +00:00
|
|
|
bool replay = false;
|
2003-09-16 19:28:03 +00:00
|
|
|
switch (command)
|
|
|
|
{
|
|
|
|
case Options::MouseRaise:
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseLower:
|
|
|
|
workspace()->lowerClient( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseShade :
|
|
|
|
toggleShade();
|
2005-05-06 15:20:49 +00:00
|
|
|
cancelShadeHover();
|
|
|
|
break;
|
|
|
|
case Options::MouseSetShade:
|
|
|
|
setShade( ShadeNormal );
|
|
|
|
cancelShadeHover();
|
|
|
|
break;
|
|
|
|
case Options::MouseUnsetShade:
|
|
|
|
setShade( ShadeNone );
|
|
|
|
cancelShadeHover();
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseOperationsMenu:
|
2006-04-09 09:50:56 +00:00
|
|
|
if ( isActive() && options->clickRaise )
|
2003-09-16 19:28:03 +00:00
|
|
|
autoRaise();
|
|
|
|
workspace()->showWindowMenu( globalPos, this );
|
|
|
|
break;
|
|
|
|
case Options::MouseToggleRaiseAndLower:
|
|
|
|
workspace()->raiseOrLowerClient( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseActivateAndRaise:
|
|
|
|
replay = isActive(); // for clickraise mode
|
2004-04-16 10:23:42 +00:00
|
|
|
workspace()->takeActivity( this, ActivityFocus | ActivityRaise, handled && replay );
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseActivateAndLower:
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
workspace()->lowerClient( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseActivate:
|
|
|
|
replay = isActive(); // for clickraise mode
|
2004-04-16 10:23:42 +00:00
|
|
|
workspace()->takeActivity( this, ActivityFocus, handled && replay );
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseActivateRaiseAndPassClick:
|
2004-04-16 10:23:42 +00:00
|
|
|
workspace()->takeActivity( this, ActivityFocus | ActivityRaise, handled );
|
2006-02-19 01:33:48 +00:00
|
|
|
replay = true;
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseActivateAndPassClick:
|
2004-04-16 10:23:42 +00:00
|
|
|
workspace()->takeActivity( this, ActivityFocus, handled );
|
2006-02-19 01:33:48 +00:00
|
|
|
replay = true;
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseActivateRaiseAndMove:
|
|
|
|
case Options::MouseActivateRaiseAndUnrestrictedMove:
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
if( options->moveMode == Options::Transparent && isMovable())
|
|
|
|
move_faked_activity = workspace()->fakeRequestedActivity( this );
|
|
|
|
// fallthrough
|
|
|
|
case Options::MouseMove:
|
|
|
|
case Options::MouseUnrestrictedMove:
|
|
|
|
{
|
|
|
|
if (!isMovable())
|
|
|
|
break;
|
|
|
|
if( moveResizeMode )
|
|
|
|
finishMoveResize( false );
|
2003-12-15 15:10:17 +00:00
|
|
|
mode = PositionCenter;
|
2006-02-19 01:33:48 +00:00
|
|
|
buttonDown = true;
|
2003-09-16 19:28:03 +00:00
|
|
|
moveOffset = QPoint( globalPos.x() - x(), globalPos.y() - y()); // map from global
|
|
|
|
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
|
|
|
unrestrictedMoveResize = ( command == Options::MouseActivateRaiseAndUnrestrictedMove
|
|
|
|
|| command == Options::MouseUnrestrictedMove );
|
2004-03-05 14:22:11 +00:00
|
|
|
setCursor( mode );
|
2003-11-24 14:24:34 +00:00
|
|
|
if( !startMoveResize())
|
2004-03-05 14:22:11 +00:00
|
|
|
{
|
2003-11-24 14:24:34 +00:00
|
|
|
buttonDown = false;
|
2004-03-05 14:22:11 +00:00
|
|
|
setCursor( mode );
|
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Options::MouseResize:
|
|
|
|
case Options::MouseUnrestrictedResize:
|
|
|
|
{
|
2004-11-29 18:46:04 +00:00
|
|
|
if (!isResizable() || isShade())
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
if( moveResizeMode )
|
|
|
|
finishMoveResize( false );
|
2006-02-19 01:33:48 +00:00
|
|
|
buttonDown = true;
|
2003-09-16 19:28:03 +00:00
|
|
|
moveOffset = QPoint( globalPos.x() - x(), globalPos.y() - y()); // map from global
|
|
|
|
int x = moveOffset.x(), y = moveOffset.y();
|
|
|
|
bool left = x < width() / 3;
|
|
|
|
bool right = x >= 2 * width() / 3;
|
|
|
|
bool top = y < height() / 3;
|
|
|
|
bool bot = y >= 2 * height() / 3;
|
|
|
|
if (top)
|
2003-12-15 15:10:17 +00:00
|
|
|
mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
|
2003-09-16 19:28:03 +00:00
|
|
|
else if (bot)
|
2003-12-15 15:10:17 +00:00
|
|
|
mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
|
2003-09-16 19:28:03 +00:00
|
|
|
else
|
2003-12-15 15:10:17 +00:00
|
|
|
mode = (x < width() / 2) ? PositionLeft : PositionRight;
|
2003-09-16 19:28:03 +00:00
|
|
|
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
|
|
|
unrestrictedMoveResize = ( command == Options::MouseUnrestrictedResize );
|
|
|
|
setCursor( mode );
|
2003-11-24 14:24:34 +00:00
|
|
|
if( !startMoveResize())
|
2004-03-05 14:22:11 +00:00
|
|
|
{
|
2003-11-24 14:24:34 +00:00
|
|
|
buttonDown = false;
|
2004-03-05 14:22:11 +00:00
|
|
|
setCursor( mode );
|
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-05-06 15:20:49 +00:00
|
|
|
case Options::MouseMaximize:
|
|
|
|
maximize( Client::MaximizeFull );
|
|
|
|
break;
|
|
|
|
case Options::MouseRestore:
|
|
|
|
maximize( Client::MaximizeRestore );
|
|
|
|
break;
|
2003-09-16 19:28:03 +00:00
|
|
|
case Options::MouseMinimize:
|
|
|
|
minimize();
|
|
|
|
break;
|
2005-05-06 15:20:49 +00:00
|
|
|
case Options::MouseAbove:
|
|
|
|
{
|
|
|
|
StackingUpdatesBlocker blocker( workspace());
|
|
|
|
if( keepBelow())
|
|
|
|
setKeepBelow( false );
|
|
|
|
else
|
|
|
|
setKeepAbove( true );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Options::MouseBelow:
|
|
|
|
{
|
|
|
|
StackingUpdatesBlocker blocker( workspace());
|
|
|
|
if( keepAbove())
|
|
|
|
setKeepAbove( false );
|
|
|
|
else
|
|
|
|
setKeepBelow( true );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Options::MousePreviousDesktop:
|
|
|
|
workspace()->windowToPreviousDesktop( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseNextDesktop:
|
|
|
|
workspace()->windowToNextDesktop( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseOpacityMore:
|
2006-10-29 19:40:24 +00:00
|
|
|
setOpacity( qMin( opacity() + 0.1, 1.0 ));
|
2005-05-06 15:20:49 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseOpacityLess:
|
2006-10-29 19:40:24 +00:00
|
|
|
setOpacity( qMax( opacity() - 0.1, 0.0 ));
|
2005-05-06 15:20:49 +00:00
|
|
|
break;
|
2003-09-16 19:28:03 +00:00
|
|
|
case Options::MouseNothing:
|
2006-02-19 01:33:48 +00:00
|
|
|
replay = true;
|
2003-09-16 19:28:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return replay;
|
|
|
|
}
|
|
|
|
|
|
|
|
// KDE4 remove me
|
|
|
|
void Workspace::showWindowMenuAt( unsigned long, int, int )
|
|
|
|
{
|
|
|
|
slotWindowOperations();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotActivateAttentionWindow()
|
|
|
|
{
|
|
|
|
if( attention_chain.count() > 0 )
|
|
|
|
activateClient( attention_chain.first());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotSwitchDesktopNext()
|
|
|
|
{
|
|
|
|
int d = currentDesktop() + 1;
|
|
|
|
if ( d > numberOfDesktops() )
|
|
|
|
{
|
|
|
|
if ( options->rollOverDesktops )
|
|
|
|
{
|
|
|
|
d = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setCurrentDesktop(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotSwitchDesktopPrevious()
|
|
|
|
{
|
|
|
|
int d = currentDesktop() - 1;
|
|
|
|
if ( d <= 0 )
|
|
|
|
{
|
|
|
|
if ( options->rollOverDesktops )
|
|
|
|
d = numberOfDesktops();
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setCurrentDesktop(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotSwitchDesktopRight()
|
|
|
|
{
|
2004-09-22 16:49:41 +00:00
|
|
|
int desktop = desktopToRight( currentDesktop());
|
|
|
|
if( desktop == currentDesktop())
|
|
|
|
return;
|
|
|
|
setCurrentDesktop( desktop );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotSwitchDesktopLeft()
|
|
|
|
{
|
2004-09-22 16:49:41 +00:00
|
|
|
int desktop = desktopToLeft( currentDesktop());
|
|
|
|
if( desktop == currentDesktop())
|
|
|
|
return;
|
|
|
|
setCurrentDesktop( desktop );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotSwitchDesktopUp()
|
|
|
|
{
|
2004-09-22 16:49:41 +00:00
|
|
|
int desktop = desktopUp( currentDesktop());
|
|
|
|
if( desktop == currentDesktop())
|
|
|
|
return;
|
|
|
|
setCurrentDesktop( desktop );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotSwitchDesktopDown()
|
|
|
|
{
|
2004-09-22 16:49:41 +00:00
|
|
|
int desktop = desktopDown( currentDesktop());
|
|
|
|
if( desktop == currentDesktop())
|
|
|
|
return;
|
|
|
|
setCurrentDesktop( desktop );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotSwitchToDesktop( int i )
|
|
|
|
{
|
|
|
|
setCurrentDesktop( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::slotWindowToDesktop( int i )
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if( i >= 1 && i <= numberOfDesktops() && c
|
|
|
|
&& !c->isDesktop()
|
|
|
|
&& !c->isDock()
|
|
|
|
&& !c->isTopMenu())
|
|
|
|
sendClientToDesktop( c, i, true );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Maximizes the popup client
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowMaximize()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if ( c )
|
|
|
|
performWindowOperation( c, Options::MaximizeOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Maximizes the popup client vertically
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowMaximizeVertical()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if ( c )
|
|
|
|
performWindowOperation( c, Options::VMaximizeOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Maximizes the popup client horiozontally
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowMaximizeHorizontal()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if ( c )
|
|
|
|
performWindowOperation( c, Options::HMaximizeOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Minimizes the popup client
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowMinimize()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
performWindowOperation( c, Options::MinimizeOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Shades/unshades the popup client respectively
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowShade()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
performWindowOperation( c, Options::ShadeOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Raises the popup client
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowRaise()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if ( c )
|
|
|
|
raiseClient( c );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Lowers the popup client
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowLower()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if ( c )
|
|
|
|
lowerClient( c );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Does a toggle-raise-and-lower on the popup client;
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowRaiseOrLower()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if ( c )
|
|
|
|
raiseOrLowerClient( c );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotWindowOnAllDesktops()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if( c )
|
|
|
|
c->setOnAllDesktops( !c->isOnAllDesktops());
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotWindowFullScreen()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if( c )
|
|
|
|
performWindowOperation( c, Options::FullScreenOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
2003-09-17 10:57:28 +00:00
|
|
|
void Workspace::slotWindowNoBorder()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if( c )
|
|
|
|
performWindowOperation( c, Options::NoBorderOp );
|
2003-09-17 10:57:28 +00:00
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
void Workspace::slotWindowAbove()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if( c )
|
|
|
|
performWindowOperation( c, Options::KeepAboveOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotWindowBelow()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if( c )
|
|
|
|
performWindowOperation( c, Options::KeepBelowOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
2005-01-10 09:56:21 +00:00
|
|
|
void Workspace::slotSetupWindowShortcut()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if( c )
|
|
|
|
performWindowOperation( c, Options::SetupWindowShortcutOp );
|
2005-01-10 09:56:21 +00:00
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Move window to next desktop
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowToNextDesktop()
|
2005-05-06 15:20:49 +00:00
|
|
|
{
|
|
|
|
windowToNextDesktop( active_popup_client ? active_popup_client : active_client );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::windowToNextDesktop( Client* c )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
int d = currentDesktop() + 1;
|
|
|
|
if ( d > numberOfDesktops() )
|
|
|
|
d = 1;
|
2005-01-20 15:10:03 +00:00
|
|
|
if (c && !c->isDesktop()
|
|
|
|
&& !c->isDock() && !c->isTopMenu())
|
2004-08-28 14:33:28 +00:00
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
setClientIsMoving( c );
|
2004-08-28 14:33:28 +00:00
|
|
|
setCurrentDesktop( d );
|
|
|
|
setClientIsMoving( NULL );
|
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Move window to previous desktop
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowToPreviousDesktop()
|
2005-05-06 15:20:49 +00:00
|
|
|
{
|
|
|
|
windowToPreviousDesktop( active_popup_client ? active_popup_client : active_client );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::windowToPreviousDesktop( Client* c )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
int d = currentDesktop() - 1;
|
|
|
|
if ( d <= 0 )
|
|
|
|
d = numberOfDesktops();
|
2005-01-20 15:10:03 +00:00
|
|
|
if (c && !c->isDesktop()
|
|
|
|
&& !c->isDock() && !c->isTopMenu())
|
2004-08-28 14:33:28 +00:00
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
setClientIsMoving( c );
|
2004-08-28 14:33:28 +00:00
|
|
|
setCurrentDesktop( d );
|
|
|
|
setClientIsMoving( NULL );
|
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
2004-09-22 16:49:41 +00:00
|
|
|
void Workspace::slotWindowToDesktopRight()
|
|
|
|
{
|
|
|
|
int d = desktopToRight( currentDesktop());
|
|
|
|
if( d == currentDesktop())
|
|
|
|
return;
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if (c && !c->isDesktop()
|
|
|
|
&& !c->isDock() && !c->isTopMenu())
|
2004-09-22 16:49:41 +00:00
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
setClientIsMoving( c );
|
2004-09-22 16:49:41 +00:00
|
|
|
setCurrentDesktop( d );
|
|
|
|
setClientIsMoving( NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotWindowToDesktopLeft()
|
|
|
|
{
|
|
|
|
int d = desktopToLeft( currentDesktop());
|
|
|
|
if( d == currentDesktop())
|
|
|
|
return;
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if (c && !c->isDesktop()
|
|
|
|
&& !c->isDock() && !c->isTopMenu())
|
2004-09-22 16:49:41 +00:00
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
setClientIsMoving( c );
|
2004-09-22 16:49:41 +00:00
|
|
|
setCurrentDesktop( d );
|
|
|
|
setClientIsMoving( NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotWindowToDesktopUp()
|
|
|
|
{
|
|
|
|
int d = desktopUp( currentDesktop());
|
|
|
|
if( d == currentDesktop())
|
|
|
|
return;
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if (c && !c->isDesktop()
|
|
|
|
&& !c->isDock() && !c->isTopMenu())
|
2004-09-22 16:49:41 +00:00
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
setClientIsMoving( c );
|
2004-09-22 16:49:41 +00:00
|
|
|
setCurrentDesktop( d );
|
|
|
|
setClientIsMoving( NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotWindowToDesktopDown()
|
|
|
|
{
|
|
|
|
int d = desktopDown( currentDesktop());
|
|
|
|
if( d == currentDesktop())
|
|
|
|
return;
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
if (c && !c->isDesktop()
|
|
|
|
&& !c->isDock() && !c->isTopMenu())
|
2004-09-22 16:49:41 +00:00
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
setClientIsMoving( c );
|
2004-09-22 16:49:41 +00:00
|
|
|
setCurrentDesktop( d );
|
|
|
|
setClientIsMoving( NULL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
/*!
|
|
|
|
Kill Window feature, similar to xkill
|
|
|
|
*/
|
|
|
|
void Workspace::slotKillWindow()
|
|
|
|
{
|
|
|
|
KillWindow kill( this );
|
|
|
|
kill.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sends the popup client to desktop \a desk
|
|
|
|
|
|
|
|
Internal slot for the window operation menu
|
|
|
|
*/
|
2006-04-12 15:13:31 +00:00
|
|
|
void Workspace::slotSendToDesktop( QAction *action )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
int desk = action->data().toInt();
|
2005-01-10 09:56:21 +00:00
|
|
|
if ( !active_popup_client )
|
2003-09-16 19:28:03 +00:00
|
|
|
return;
|
|
|
|
if ( desk == 0 )
|
|
|
|
{ // the 'on_all_desktops' menu entry
|
2005-01-10 09:56:21 +00:00
|
|
|
active_popup_client->setOnAllDesktops( !active_popup_client->isOnAllDesktops());
|
2003-09-16 19:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-01-10 09:56:21 +00:00
|
|
|
sendClientToDesktop( active_popup_client, desk, false );
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Shows the window operations popup menu for the activeClient()
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowOperations()
|
|
|
|
{
|
|
|
|
if ( !active_client )
|
|
|
|
return;
|
|
|
|
QPoint pos = active_client->pos() + active_client->clientPos();
|
|
|
|
showWindowMenu( pos.x(), pos.y(), active_client );
|
|
|
|
}
|
|
|
|
|
2004-06-02 09:47:36 +00:00
|
|
|
void Workspace::showWindowMenu( const QRect &pos, Client* cl )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2005-10-03 15:13:54 +00:00
|
|
|
if (!KAuthorized::authorizeKAction("kwin_rmb"))
|
2003-09-16 19:28:03 +00:00
|
|
|
return;
|
|
|
|
if( !cl )
|
|
|
|
return;
|
2005-01-10 09:56:21 +00:00
|
|
|
if( active_popup_client != NULL ) // recursion
|
2003-09-16 19:28:03 +00:00
|
|
|
return;
|
|
|
|
if ( cl->isDesktop()
|
|
|
|
|| cl->isDock()
|
|
|
|
|| cl->isTopMenu())
|
|
|
|
return;
|
|
|
|
|
2005-01-10 09:56:21 +00:00
|
|
|
active_popup_client = cl;
|
2005-11-30 21:17:50 +00:00
|
|
|
QMenu* p = clientPopup();
|
2005-01-10 09:56:21 +00:00
|
|
|
active_popup = p;
|
2004-06-02 09:47:36 +00:00
|
|
|
int x = pos.left();
|
|
|
|
int y = pos.bottom();
|
2005-01-10 09:56:21 +00:00
|
|
|
if (y == pos.top())
|
2004-06-02 09:47:36 +00:00
|
|
|
p->exec( QPoint( x, y ) );
|
2005-01-10 09:56:21 +00:00
|
|
|
else
|
|
|
|
{
|
2004-06-02 09:47:36 +00:00
|
|
|
QRect area = clientArea(ScreenArea, QPoint(x, y), currentDesktop());
|
2005-10-24 14:00:26 +00:00
|
|
|
clientPopupAboutToShow(); // needed for sizeHint() to be correct :-/
|
2004-06-02 09:47:36 +00:00
|
|
|
int popupHeight = p->sizeHint().height();
|
2005-01-10 09:56:21 +00:00
|
|
|
if (y + popupHeight < area.height())
|
2004-06-02 09:47:36 +00:00
|
|
|
p->exec( QPoint( x, y ) );
|
2005-01-10 09:56:21 +00:00
|
|
|
else
|
2004-06-02 09:47:36 +00:00
|
|
|
p->exec( QPoint( x, pos.top() - popupHeight ) );
|
2005-01-10 09:56:21 +00:00
|
|
|
}
|
2005-01-17 16:19:33 +00:00
|
|
|
// active popup may be already changed (e.g. the window shortcut dialog)
|
|
|
|
if( active_popup == p )
|
|
|
|
closeActivePopup();
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Closes the popup client
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowClose()
|
|
|
|
{
|
2005-05-06 09:24:51 +00:00
|
|
|
if ( tab_box->isVisible())
|
2003-09-16 19:28:03 +00:00
|
|
|
return;
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
performWindowOperation( c, Options::CloseOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Starts keyboard move mode for the popup client
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowMove()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
performWindowOperation( c, Options::UnrestrictedMoveOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Starts keyboard resize mode for the popup client
|
|
|
|
*/
|
|
|
|
void Workspace::slotWindowResize()
|
|
|
|
{
|
2005-01-20 15:10:03 +00:00
|
|
|
Client* c = active_popup_client ? active_popup_client : active_client;
|
|
|
|
performWindowOperation( c, Options::UnrestrictedResizeOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
2005-01-17 15:53:14 +00:00
|
|
|
void Client::setShortcut( const QString& _cut )
|
|
|
|
{
|
|
|
|
QString cut = rules()->checkShortcut( _cut );
|
|
|
|
if( cut.isEmpty())
|
|
|
|
return setShortcutInternal( KShortcut());
|
|
|
|
// Format:
|
2005-02-02 18:57:21 +00:00
|
|
|
// base+(abcdef)<space>base+(abcdef)
|
|
|
|
// E.g. Alt+Ctrl+(ABCDEF) Win+X,Win+(ABCDEF)
|
|
|
|
if( !cut.contains( '(' ) && !cut.contains( ')' ) && !cut.contains( ' ' ))
|
2005-01-17 15:53:14 +00:00
|
|
|
{
|
2005-02-03 15:59:57 +00:00
|
|
|
if( workspace()->shortcutAvailable( KShortcut( cut ), this ))
|
2005-01-17 15:53:14 +00:00
|
|
|
setShortcutInternal( KShortcut( cut ));
|
|
|
|
else
|
|
|
|
setShortcutInternal( KShortcut());
|
|
|
|
return;
|
|
|
|
}
|
2005-07-28 14:59:42 +00:00
|
|
|
QList< KShortcut > keys;
|
2005-09-23 16:46:47 +00:00
|
|
|
QStringList groups = cut.split( ' ');
|
2005-01-17 15:53:14 +00:00
|
|
|
for( QStringList::ConstIterator it = groups.begin();
|
|
|
|
it != groups.end();
|
|
|
|
++it )
|
|
|
|
{
|
2005-02-02 18:57:21 +00:00
|
|
|
QRegExp reg( "(.*\\+)\\((.*)\\)" );
|
2006-04-11 17:12:05 +00:00
|
|
|
if( reg.indexIn( *it ) > -1 )
|
2005-01-17 15:53:14 +00:00
|
|
|
{
|
|
|
|
QString base = reg.cap( 1 );
|
|
|
|
QString list = reg.cap( 2 );
|
2005-07-28 14:59:42 +00:00
|
|
|
for( int i = 0;
|
2005-01-17 15:53:14 +00:00
|
|
|
i < list.length();
|
|
|
|
++i )
|
|
|
|
{
|
|
|
|
KShortcut c( base + list[ i ] );
|
|
|
|
if( !c.isNull())
|
|
|
|
keys.append( c );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-07-28 14:59:42 +00:00
|
|
|
for( QList< KShortcut >::ConstIterator it = keys.begin();
|
2005-01-17 15:53:14 +00:00
|
|
|
it != keys.end();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
if( _shortcut == *it ) // current one is in the list
|
|
|
|
return;
|
|
|
|
}
|
2005-07-28 14:59:42 +00:00
|
|
|
for( QList< KShortcut >::ConstIterator it = keys.begin();
|
2005-01-17 15:53:14 +00:00
|
|
|
it != keys.end();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
if( workspace()->shortcutAvailable( *it, this ))
|
|
|
|
{
|
|
|
|
setShortcutInternal( *it );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setShortcutInternal( KShortcut());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::setShortcutInternal( const KShortcut& cut )
|
|
|
|
{
|
|
|
|
if( _shortcut == cut )
|
|
|
|
return;
|
|
|
|
_shortcut = cut;
|
2005-02-07 15:17:26 +00:00
|
|
|
updateCaption();
|
2005-01-17 15:53:14 +00:00
|
|
|
workspace()->clientShortcutUpdated( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Workspace::shortcutAvailable( const KShortcut& cut, Client* ignore ) const
|
|
|
|
{
|
|
|
|
// TODO check global shortcuts etc.
|
|
|
|
for( ClientList::ConstIterator it = clients.begin();
|
|
|
|
it != clients.end();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
if( (*it) != ignore && (*it)->shortcut() == cut )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
} // namespace
|