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") );
|
2006-12-22 15:09:35 +00:00
|
|
|
mKeepAboveOpAction->setIcon( SmallIconSet( "up" ) );
|
2006-12-04 20:44:12 +00:00
|
|
|
KAction *kaction = qobject_cast<KAction*>( keys->action("Window Above Other Windows") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mKeepAboveOpAction->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mKeepAboveOpAction->setCheckable( true );
|
|
|
|
mKeepAboveOpAction->setData( Options::KeepAboveOp );
|
|
|
|
|
|
|
|
mKeepBelowOpAction = advanced_popup->addAction( i18n("Keep &Below Others") );
|
2006-12-22 15:09:35 +00:00
|
|
|
mKeepBelowOpAction->setIcon( SmallIconSet( "down" ) );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window Below Other Windows") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mKeepBelowOpAction->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mKeepBelowOpAction->setCheckable( true );
|
|
|
|
mKeepBelowOpAction->setData( Options::KeepBelowOp );
|
|
|
|
|
|
|
|
mFullScreenOpAction = advanced_popup->addAction( i18n("&Fullscreen") );
|
2006-12-22 15:09:35 +00:00
|
|
|
mFullScreenOpAction->setIcon( SmallIconSet( "window_fullscreen" ) );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window Fullscreen") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mFullScreenOpAction->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mFullScreenOpAction->setCheckable( true );
|
|
|
|
mFullScreenOpAction->setData( Options::FullScreenOp );
|
|
|
|
|
|
|
|
mNoBorderOpAction = advanced_popup->addAction( i18n("&No Border") );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window No Border") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mNoBorderOpAction->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mNoBorderOpAction->setCheckable( true );
|
|
|
|
mNoBorderOpAction->setData( Options::NoBorderOp );
|
|
|
|
|
|
|
|
QAction *action = advanced_popup->addAction( i18n("Window &Shortcut...") );
|
2006-12-22 15:09:35 +00:00
|
|
|
action->setIcon( SmallIconSet("key_bindings") );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Setup Window Shortcut") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
action->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
action->setData( Options::SetupWindowShortcutOp );
|
|
|
|
|
|
|
|
action = advanced_popup->addAction( i18n("&Special Window Settings...") );
|
2006-12-22 15:09:35 +00:00
|
|
|
action->setIcon( SmallIconSet( "wizard" ) );
|
2006-04-12 15:13:31 +00:00
|
|
|
action->setData( Options::WindowRulesOp );
|
|
|
|
|
|
|
|
action = advanced_popup->addAction( i18n("&Special Application Settings...") );
|
2006-12-22 15:09:35 +00:00
|
|
|
action->setIcon( SmallIconSet( "wizard" ) );
|
2006-04-12 15:13:31 +00:00
|
|
|
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){
|
2006-12-22 15:09:35 +00:00
|
|
|
trans_popup = new QMenu( popup );
|
|
|
|
trans_popup->setFont(KGlobalSettings::menuFont());
|
|
|
|
connect( trans_popup, SIGNAL( triggered(QAction*) ), this, SLOT( setPopupClientOpacity(QAction*)));
|
|
|
|
const int levels[] = { 100, 90, 75, 50, 25, 10 };
|
|
|
|
for( unsigned int i = 0;
|
|
|
|
i < sizeof( levels ) / sizeof( levels[ 0 ] );
|
|
|
|
++i )
|
|
|
|
{
|
|
|
|
action = trans_popup->addAction( QString::number( levels[ i ] ) + "%" );
|
|
|
|
action->setCheckable( true );
|
|
|
|
action->setData( levels[ i ] );
|
|
|
|
}
|
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") );
|
2006-12-22 15:09:35 +00:00
|
|
|
mMoveOpAction->setIcon( SmallIconSet( "move" ) );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window Move") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mMoveOpAction->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mMoveOpAction->setData( Options::MoveOp );
|
|
|
|
|
|
|
|
mResizeOpAction = popup->addAction( i18n("Re&size") );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window Resize") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mResizeOpAction->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mResizeOpAction->setData( Options::ResizeOp );
|
|
|
|
|
|
|
|
mMinimizeOpAction = popup->addAction( i18n("Mi&nimize") );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window Minimize") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mMinimizeOpAction->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mMinimizeOpAction->setData( Options::MinimizeOp );
|
|
|
|
|
|
|
|
mMaximizeOpAction = popup->addAction( i18n("Ma&ximize") );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window Maximize") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mMaximizeOpAction->setShortcut( kaction->globalShortcut().primary() );
|
2006-04-12 15:13:31 +00:00
|
|
|
mMaximizeOpAction->setCheckable( true );
|
|
|
|
mMaximizeOpAction->setData( Options::MaximizeOp );
|
|
|
|
|
|
|
|
mShadeOpAction = popup->addAction( i18n("Sh&ade") );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window Shade") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mShadeOpAction->setShortcut( kaction->globalShortcut().primary() );
|
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
|
|
|
|
2006-12-04 20:44:12 +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...") );
|
2006-12-22 15:09:35 +00:00
|
|
|
action->setIcon( SmallIconSet( "configure" ) );
|
2006-04-12 15:13:31 +00:00
|
|
|
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") );
|
2006-12-22 15:09:35 +00:00
|
|
|
mCloseOpAction->setIcon( SmallIconSet( "fileclose" ) );
|
2006-12-04 20:44:12 +00:00
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Window Close") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
mCloseOpAction->setShortcut( kaction->globalShortcut().primary() );
|
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
|
|
|
|
2006-12-22 15:09:35 +00:00
|
|
|
void Workspace::setPopupClientOpacity( QAction* action )
|
2006-12-18 12:25:10 +00:00
|
|
|
{
|
2006-12-22 15:09:35 +00:00
|
|
|
if( active_popup_client == NULL )
|
|
|
|
return;
|
|
|
|
int level = action->data().toInt();
|
|
|
|
active_popup_client->setOpacity( level / 100.0 );
|
2006-12-18 12:25:10 +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() );
|
2006-12-22 15:09:35 +00:00
|
|
|
if (options->useTranslucency)
|
|
|
|
{
|
|
|
|
foreach( QAction* action, trans_popup->actions())
|
|
|
|
{
|
|
|
|
if( action->data().toInt() == qRound( active_popup_client->opacity() * 100 ))
|
|
|
|
action->setChecked( true );
|
|
|
|
else
|
|
|
|
action->setChecked( false );
|
|
|
|
}
|
|
|
|
}
|
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-12-04 20:44:12 +00:00
|
|
|
KAction *kaction = qobject_cast<KAction*>( keys->action("Walk Through Desktops") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
cutWalkThroughDesktops = kaction->globalShortcut();
|
|
|
|
|
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Walk Through Desktops (Reverse)") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
cutWalkThroughDesktopsReverse = kaction->globalShortcut();
|
|
|
|
|
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Walk Through Desktop List") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
cutWalkThroughDesktopList = kaction->globalShortcut();
|
|
|
|
|
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Walk Through Desktop List (Reverse)") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
cutWalkThroughDesktopListReverse = kaction->globalShortcut();
|
|
|
|
|
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Walk Through Windows") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
cutWalkThroughWindows = kaction->globalShortcut();
|
|
|
|
|
|
|
|
kaction = qobject_cast<KAction*>( keys->action("Walk Through Windows (Reverse)") );
|
|
|
|
if ( kaction!=0 )
|
|
|
|
cutWalkThroughWindowsReverse = kaction->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-12-04 20:44:12 +00:00
|
|
|
QAction* action = client_keys->action( key.toLatin1().constData() );
|
2006-11-27 00:32:31 +00:00
|
|
|
if( !c->shortcut().isEmpty())
|
2005-01-10 09:56:21 +00:00
|
|
|
{
|
2006-12-18 12:25:10 +00:00
|
|
|
action->setShortcuts(c->shortcut());
|
2006-04-10 11:57:13 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-22 15:09:35 +00:00
|
|
|
void Workspace::performWindowOperation( Client* c, Options::WindowOperation op )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
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());
|
2006-12-22 15:09:35 +00:00
|
|
|
switch ( op )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
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;
|
2006-12-22 15:09:35 +00:00
|
|
|
switch (command)
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
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-12-22 15:09:35 +00:00
|
|
|
setOpacity( qMin( opacity() + 0.1, 1.0 ));
|
2005-05-06 15:20:49 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseOpacityLess:
|
2006-12-22 15:09:35 +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;
|
2006-12-22 15:09:35 +00:00
|
|
|
if ( d > numberOfDesktops() )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
2006-12-22 15:09:35 +00:00
|
|
|
if ( options->rollOverDesktops )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
d = 1;
|
|
|
|
}
|
2006-12-22 15:09:35 +00:00
|
|
|
else
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setCurrentDesktop(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::slotSwitchDesktopPrevious()
|
|
|
|
{
|
|
|
|
int d = currentDesktop() - 1;
|
2006-12-22 15:09:35 +00:00
|
|
|
if ( d <= 0 )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
2006-12-22 15:09:35 +00:00
|
|
|
|
2005-05-06 15:20:49 +00:00
|
|
|
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 );
|
|
|
|
}
|
2006-12-22 15:09:35 +00:00
|
|
|
|
2005-05-06 15:20:49 +00:00
|
|
|
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;
|
2006-12-22 15:09:35 +00:00
|
|
|
if ( desk == 0 )
|
2003-09-16 19:28:03 +00:00
|
|
|
{ // 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 ] );
|
2006-11-27 00:32:31 +00:00
|
|
|
if( !c.isEmpty())
|
2005-01-17 15:53:14 +00:00
|
|
|
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 )
|
2006-12-22 15:09:35 +00:00
|
|
|
return false;
|
2005-01-17 15:53:14 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
} // namespace
|