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>
|
2005-01-15 17:07:48 +00:00
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qslider.h>
|
|
|
|
#include <qtooltip.h>
|
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>
|
2005-01-17 15:53:14 +00:00
|
|
|
#include <qregexp.h>
|
2005-07-28 14:59:42 +00:00
|
|
|
#include <Q3PopupMenu>
|
|
|
|
#include <QVBoxLayout>
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
#include "killwindow.h"
|
|
|
|
#include "tabbox.h"
|
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// Workspace
|
|
|
|
//****************************************
|
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
Q3PopupMenu* 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-07-28 14:59:42 +00:00
|
|
|
popup = new Q3PopupMenu;
|
2003-09-16 19:28:03 +00:00
|
|
|
popup->setCheckable( TRUE );
|
|
|
|
popup->setFont(KGlobalSettings::menuFont());
|
|
|
|
connect( popup, SIGNAL( aboutToShow() ), this, SLOT( clientPopupAboutToShow() ) );
|
|
|
|
connect( popup, SIGNAL( activated(int) ), this, SLOT( clientPopupActivated(int) ) );
|
2005-01-15 17:07:48 +00:00
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
advanced_popup = new Q3PopupMenu( popup );
|
2004-02-13 15:15:37 +00:00
|
|
|
advanced_popup->setCheckable( TRUE );
|
|
|
|
advanced_popup->setFont(KGlobalSettings::menuFont());
|
|
|
|
connect( advanced_popup, SIGNAL( activated(int) ), this, SLOT( clientPopupActivated(int) ) );
|
2004-06-28 13:15:05 +00:00
|
|
|
advanced_popup->insertItem( SmallIconSet( "up" ),
|
|
|
|
i18n("Keep &Above Others")+'\t'+keys->shortcut("Window Above Other Windows").seq(0).toString(), Options::KeepAboveOp );
|
|
|
|
advanced_popup->insertItem( SmallIconSet( "down" ),
|
|
|
|
i18n("Keep &Below Others")+'\t'+keys->shortcut("Window Below Other Windows").seq(0).toString(), Options::KeepBelowOp );
|
|
|
|
advanced_popup->insertItem( SmallIconSet( "window_fullscreen" ),
|
|
|
|
i18n("&Fullscreen")+'\t'+keys->shortcut("Window Fullscreen").seq(0).toString(), Options::FullScreenOp );
|
|
|
|
advanced_popup->insertItem( i18n("&No Border")+'\t'+keys->shortcut("Window No Border").seq(0).toString(), Options::NoBorderOp );
|
2005-01-10 09:56:21 +00:00
|
|
|
advanced_popup->insertItem( SmallIconSet("key_bindings"),
|
|
|
|
i18n("Window &Shortcut...")+'\t'+keys->shortcut("Setup Window Shortcut").seq(0).toString(), Options::SetupWindowShortcutOp );
|
2005-01-27 12:31:24 +00:00
|
|
|
advanced_popup->insertItem( SmallIconSet( "wizard" ), i18n("&Special Window Settings..."), Options::WindowRulesOp );
|
2005-08-16 17:46:42 +00:00
|
|
|
advanced_popup->insertItem( SmallIconSet( "wizard" ), i18n("&Special Application Settings..."), Options::ApplicationRulesOp );
|
2004-02-13 15:15:37 +00:00
|
|
|
|
|
|
|
popup->insertItem(i18n("Ad&vanced"), advanced_popup );
|
|
|
|
desk_popup_index = popup->count();
|
2005-01-15 17:07:48 +00:00
|
|
|
|
|
|
|
if (options->useTranslucency){
|
2005-07-28 14:59:42 +00:00
|
|
|
Q3PopupMenu *trans_popup = new Q3PopupMenu( popup );
|
|
|
|
QVBoxLayout *transLayout = new QVBoxLayout(trans_popup);
|
|
|
|
trans_popup->setLayout( transLayout );
|
|
|
|
transButton = new QPushButton(trans_popup, "transButton");
|
2005-09-21 09:14:36 +00:00
|
|
|
transButton->setToolTip( i18n("Reset opacity to default value"));
|
2005-07-28 14:59:42 +00:00
|
|
|
transSlider = new QSlider(0, 100, 1, 100, Qt::Vertical, trans_popup, "transSlider");
|
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)));
|
2005-02-18 23:11:39 +00:00
|
|
|
// connect(transSlider, SIGNAL(sliderReleased()), trans_popup, SLOT(hide()));
|
2005-01-15 17:07:48 +00:00
|
|
|
popup->insertItem(i18n("&Opacity"), trans_popup );
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
popup->insertItem( SmallIconSet( "move" ), i18n("&Move")+'\t'+keys->shortcut("Window Move").seq(0).toString(), Options::MoveOp );
|
2003-10-13 16:18:04 +00:00
|
|
|
popup->insertItem( i18n("Re&size")+'\t'+keys->shortcut("Window Resize").seq(0).toString(), Options::ResizeOp );
|
2003-09-16 19:28:03 +00:00
|
|
|
popup->insertItem( i18n("Mi&nimize")+'\t'+keys->shortcut("Window Minimize").seq(0).toString(), Options::MinimizeOp );
|
|
|
|
popup->insertItem( i18n("Ma&ximize")+'\t'+keys->shortcut("Window Maximize").seq(0).toString(), Options::MaximizeOp );
|
|
|
|
popup->insertItem( i18n("Sh&ade")+'\t'+keys->shortcut("Window Shade").seq(0).toString(), Options::ShadeOp );
|
2003-09-26 21:32:49 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
popup->insertSeparator();
|
|
|
|
|
2004-03-18 13:18:41 +00:00
|
|
|
if (!KGlobal::config()->isImmutable() &&
|
|
|
|
!kapp->authorizeControlModules(Workspace::configModules(true)).isEmpty())
|
2004-02-13 15:15:37 +00:00
|
|
|
{
|
2003-09-16 19:28:03 +00:00
|
|
|
popup->insertItem(SmallIconSet( "configure" ), i18n("Configur&e Window Behavior..."), this, SLOT( configureWM() ));
|
2004-02-13 15:15:37 +00:00
|
|
|
popup->insertSeparator();
|
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
popup->insertItem( SmallIconSet( "fileclose" ), i18n("&Close")+'\t'+keys->shortcut("Window Close").seq(0).toString(), Options::CloseOp );
|
|
|
|
}
|
|
|
|
return popup;
|
|
|
|
}
|
2005-01-15 17:07:48 +00:00
|
|
|
|
|
|
|
//sets the transparency of the client to given value(given by slider)
|
|
|
|
void Workspace::setPopupClientOpacity(int value)
|
|
|
|
{
|
2005-01-16 09:12:28 +00:00
|
|
|
active_popup_client->setCustomOpacityFlag(true);
|
2005-01-15 17:07:48 +00:00
|
|
|
value = 100 - value;
|
2005-01-16 09:12:28 +00:00
|
|
|
value<100?active_popup_client->setOpacity(true, (uint)((value/100.0)*0xffffffff)):active_popup_client->setOpacity(false,0xffffffff);
|
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)
|
|
|
|
transButton->setText("0"+QString::number(value)+" %");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::resetClientOpacity()
|
|
|
|
{
|
2005-01-16 09:12:28 +00:00
|
|
|
active_popup_client->setCustomOpacityFlag(false);
|
|
|
|
active_popup_client->updateOpacity();
|
2005-02-17 21:12:01 +00:00
|
|
|
transSlider->setValue(100-active_popup_client->opacityPercentage());
|
|
|
|
setTransButtonText(100-active_popup_client->opacityPercentage());
|
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();
|
|
|
|
}
|
|
|
|
|
2005-01-10 09:56:21 +00:00
|
|
|
popup->setItemEnabled( Options::ResizeOp, active_popup_client->isResizable() );
|
|
|
|
popup->setItemEnabled( Options::MoveOp, active_popup_client->isMovable() );
|
|
|
|
popup->setItemEnabled( Options::MaximizeOp, active_popup_client->isMaximizable() );
|
|
|
|
popup->setItemChecked( Options::MaximizeOp, active_popup_client->maximizeMode() == Client::MaximizeFull );
|
2003-11-25 15:26:50 +00:00
|
|
|
// This should be checked also when hover unshaded
|
2005-01-10 09:56:21 +00:00
|
|
|
popup->setItemChecked( Options::ShadeOp, active_popup_client->shadeMode() != ShadeNone );
|
|
|
|
popup->setItemEnabled( Options::ShadeOp, active_popup_client->isShadeable());
|
|
|
|
advanced_popup->setItemChecked( Options::KeepAboveOp, active_popup_client->keepAbove() );
|
|
|
|
advanced_popup->setItemChecked( Options::KeepBelowOp, active_popup_client->keepBelow() );
|
|
|
|
advanced_popup->setItemChecked( Options::FullScreenOp, active_popup_client->isFullScreen() );
|
|
|
|
advanced_popup->setItemEnabled( Options::FullScreenOp, active_popup_client->userCanSetFullScreen() );
|
|
|
|
advanced_popup->setItemChecked( Options::NoBorderOp, active_popup_client->noBorder() );
|
|
|
|
advanced_popup->setItemEnabled( Options::NoBorderOp, active_popup_client->userCanSetNoBorder() );
|
|
|
|
popup->setItemEnabled( Options::MinimizeOp, active_popup_client->isMinimizable() );
|
|
|
|
popup->setItemEnabled( Options::CloseOp, active_popup_client->isCloseable() );
|
2005-01-15 17:07:48 +00:00
|
|
|
if (options->useTranslucency)
|
|
|
|
{
|
2005-01-16 09:12:28 +00:00
|
|
|
transSlider->setValue(100-active_popup_client->opacityPercentage());
|
2005-02-17 20:48:11 +00:00
|
|
|
setTransButtonText(100-active_popup_client->opacityPercentage());
|
2005-01-15 17:07:48 +00:00
|
|
|
}
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::initDesktopPopup()
|
|
|
|
{
|
|
|
|
if (desk_popup)
|
|
|
|
return;
|
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
desk_popup = new Q3PopupMenu( popup );
|
2003-09-16 19:28:03 +00:00
|
|
|
desk_popup->setCheckable( TRUE );
|
|
|
|
desk_popup->setFont(KGlobalSettings::menuFont());
|
|
|
|
connect( desk_popup, SIGNAL( activated(int) ),
|
2004-05-28 13:51:11 +00:00
|
|
|
this, SLOT( slotSendToDesktop(int) ) );
|
2003-09-16 19:28:03 +00:00
|
|
|
connect( desk_popup, SIGNAL( aboutToShow() ),
|
|
|
|
this, SLOT( desktopPopupAboutToShow() ) );
|
|
|
|
|
|
|
|
popup->insertItem(i18n("To &Desktop"), desk_popup, -1, desk_popup_index );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
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();
|
|
|
|
desk_popup->insertItem( i18n("&All Desktops"), 0 );
|
2005-01-20 15:10:03 +00:00
|
|
|
if ( active_popup_client && active_popup_client->isOnAllDesktops() )
|
2003-09-16 19:28:03 +00:00
|
|
|
desk_popup->setItemChecked( 0, TRUE );
|
|
|
|
desk_popup->insertSeparator( -1 );
|
|
|
|
int id;
|
|
|
|
const int BASE = 10;
|
|
|
|
for ( int i = 1; i <= numberOfDesktops(); i++ )
|
|
|
|
{
|
|
|
|
QString basic_name("%1 %2");
|
2003-09-26 21:32:49 +00:00
|
|
|
if (i<BASE)
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
basic_name.prepend('&');
|
|
|
|
}
|
|
|
|
id = desk_popup->insertItem(
|
|
|
|
basic_name
|
|
|
|
.arg(i)
|
|
|
|
.arg( desktopName(i).replace( '&', "&&" )),
|
|
|
|
i );
|
2005-01-20 15:10:03 +00:00
|
|
|
if ( active_popup_client &&
|
|
|
|
!active_popup_client->isOnAllDesktops() && active_popup_client->desktop() == i )
|
2003-09-16 19:28:03 +00:00
|
|
|
desk_popup->setItemChecked( id, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
keys = new KGlobalAccel( this );
|
2005-08-02 13:25:20 +00:00
|
|
|
// a separate KGlobalAccel is needed for the shortcut for disabling global shortcuts,
|
|
|
|
// otherwise it would also disable itself
|
|
|
|
disable_shortcuts_keys = new KGlobalAccel( this );
|
|
|
|
disable_shortcuts_keys->disableBlocking( true );
|
|
|
|
#define IN_KWIN
|
2003-09-16 19:28:03 +00:00
|
|
|
#include "kwinbindings.cpp"
|
|
|
|
readShortcuts();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::readShortcuts()
|
|
|
|
{
|
|
|
|
keys->readSettings();
|
2005-08-02 13:25:20 +00:00
|
|
|
disable_shortcuts_keys->readSettings();
|
2003-09-16 19:28:03 +00:00
|
|
|
|
|
|
|
cutWalkThroughDesktops = keys->shortcut("Walk Through Desktops");
|
|
|
|
cutWalkThroughDesktopsReverse = keys->shortcut("Walk Through Desktops (Reverse)");
|
|
|
|
cutWalkThroughDesktopList = keys->shortcut("Walk Through Desktop List");
|
|
|
|
cutWalkThroughDesktopListReverse = keys->shortcut("Walk Through Desktop List (Reverse)");
|
|
|
|
cutWalkThroughWindows = keys->shortcut("Walk Through Windows");
|
|
|
|
cutWalkThroughWindowsReverse = keys->shortcut("Walk Through Windows (Reverse)");
|
|
|
|
|
|
|
|
keys->updateConnections();
|
2005-08-02 13:25:20 +00:00
|
|
|
disable_shortcuts_keys->updateConnections();
|
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());
|
|
|
|
client_keys->remove( key );
|
|
|
|
if( !c->shortcut().isNull())
|
|
|
|
{
|
|
|
|
client_keys->insert( key, key );
|
|
|
|
client_keys->setShortcut( key, c->shortcut());
|
|
|
|
client_keys->setSlot( key, c, SLOT( shortcutActivated()));
|
|
|
|
client_keys->setActionEnabled( key, true );
|
|
|
|
}
|
|
|
|
client_keys->updateConnections();
|
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
void Workspace::clientPopupActivated( int id )
|
|
|
|
{
|
2003-10-13 16:22:39 +00:00
|
|
|
WindowOperation op = static_cast< WindowOperation >( id );
|
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 );
|
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
|
|
|
{
|
|
|
|
bool replay = FALSE;
|
|
|
|
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:
|
|
|
|
if ( isActive() & options->clickRaise )
|
|
|
|
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 );
|
2003-09-16 19:28:03 +00:00
|
|
|
replay = TRUE;
|
|
|
|
break;
|
|
|
|
case Options::MouseActivateAndPassClick:
|
2004-04-16 10:23:42 +00:00
|
|
|
workspace()->takeActivity( this, ActivityFocus, handled );
|
2003-09-16 19:28:03 +00:00
|
|
|
replay = TRUE;
|
|
|
|
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;
|
2003-09-16 19:28:03 +00:00
|
|
|
buttonDown = TRUE;
|
|
|
|
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 );
|
|
|
|
buttonDown = TRUE;
|
|
|
|
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:
|
|
|
|
if (opacity_ < 0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
if (opacity_ < 0xF3333333)
|
|
|
|
{
|
|
|
|
setOpacity(TRUE, opacity_ + 0xCCCCCCC);
|
|
|
|
custom_opacity = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setOpacity(FALSE, 0xFFFFFFFF);
|
|
|
|
custom_opacity = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Options::MouseOpacityLess:
|
|
|
|
if (opacity_ > 0)
|
|
|
|
{
|
|
|
|
setOpacity(TRUE, (opacity_ > 0xCCCCCCC) ? opacity_ - 0xCCCCCCC : 0);
|
|
|
|
custom_opacity = true;
|
|
|
|
}
|
|
|
|
break;
|
2003-09-16 19:28:03 +00:00
|
|
|
case Options::MouseNothing:
|
|
|
|
replay = TRUE;
|
|
|
|
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
|
|
|
|
*/
|
2004-05-28 13:51:11 +00:00
|
|
|
void Workspace::slotSendToDesktop( int desk )
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
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
|
|
|
{
|
|
|
|
if (!kapp->authorizeKAction("kwin_rmb"))
|
|
|
|
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-07-28 14:59:42 +00:00
|
|
|
Q3PopupMenu* 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());
|
|
|
|
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( "(.*\\+)\\((.*)\\)" );
|
2005-01-17 15:53:14 +00:00
|
|
|
if( reg.search( *it ) > -1 )
|
|
|
|
{
|
|
|
|
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
|