diff --git a/kcmkwin/kwintabbox/main.cpp b/kcmkwin/kwintabbox/main.cpp index 8367e7e3c4..cf1917322e 100644 --- a/kcmkwin/kwintabbox/main.cpp +++ b/kcmkwin/kwintabbox/main.cpp @@ -144,6 +144,7 @@ KWinTabBoxConfig::KWinTabBoxConfig( QWidget* parent, const QVariantList& args ) connect( m_primaryTabBoxUi->showOutlineCheck, SIGNAL(stateChanged(int)), this, SLOT(changed())); connect( m_primaryTabBoxUi->showTabBox, SIGNAL(toggled(bool)), this, SLOT(changed())); connect( m_primaryTabBoxUi->highlightWindowCheck, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect( m_primaryTabBoxUi->showDesktopBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); // combo boxes alternative connect( m_alternativeTabBoxUi->listModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); connect( m_alternativeTabBoxUi->switchingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); @@ -152,6 +153,7 @@ KWinTabBoxConfig::KWinTabBoxConfig( QWidget* parent, const QVariantList& args ) connect( m_alternativeTabBoxUi->showOutlineCheck, SIGNAL(stateChanged(int)), this, SLOT(changed())); connect( m_alternativeTabBoxUi->showTabBox, SIGNAL(toggled(bool)), this, SLOT(changed())); connect( m_alternativeTabBoxUi->highlightWindowCheck, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect( m_alternativeTabBoxUi->showDesktopBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); // effects connect( m_primaryTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEffectSelectionChanged(int))); @@ -249,6 +251,8 @@ void KWinTabBoxConfig::loadConfig( const KConfigGroup& config, KWin::TabBox::Tab config.readEntry( "LayoutMode", TabBox::TabBoxConfig::defaultLayoutMode() ))); tabBoxConfig.setSelectedItemViewPosition( TabBox::TabBoxConfig::SelectedItemViewPosition( config.readEntry( "SelectedItem", TabBox::TabBoxConfig::defaultSelectedItemViewPosition()))); + tabBoxConfig.setShowDesktop( config.readEntry( "ShowDesktop", + TabBox::TabBoxConfig::defaultShowDesktop())); tabBoxConfig.setShowOutline( config.readEntry( "ShowOutline", TabBox::TabBoxConfig::defaultShowOutline())); @@ -275,6 +279,7 @@ void KWinTabBoxConfig::saveConfig( KConfigGroup& config, const KWin::TabBox::Tab config.writeEntry( "SelectedItem", int(tabBoxConfig.selectedItemViewPosition()) ); config.writeEntry( "LayoutName", tabBoxConfig.layoutName() ); config.writeEntry( "SelectedLayoutName", tabBoxConfig.selectedItemLayoutName() ); + config.writeEntry( "ShowDesktop", tabBoxConfig.isShowDesktop() ); // check boxes config.writeEntry( "ShowOutline", tabBoxConfig.isShowOutline() ); @@ -389,6 +394,7 @@ void KWinTabBoxConfig::defaults() m_primaryTabBoxUi->showOutlineCheck->setChecked( TabBox::TabBoxConfig::defaultShowOutline() ); m_primaryTabBoxUi->showTabBox->setChecked( TabBox::TabBoxConfig::defaultShowTabBox() ); m_primaryTabBoxUi->highlightWindowCheck->setChecked( TabBox::TabBoxConfig::defaultHighlightWindow() ); + m_primaryTabBoxUi->showDesktopBox->setChecked( TabBox::TabBoxConfig::defaultShowDesktop() ); // effects m_primaryTabBoxUi->effectCombo->setCurrentIndex( 1 ); @@ -402,6 +408,7 @@ void KWinTabBoxConfig::defaults() m_alternativeTabBoxUi->showOutlineCheck->setChecked( TabBox::TabBoxConfig::defaultShowOutline() ); m_alternativeTabBoxUi->showTabBox->setChecked( TabBox::TabBoxConfig::defaultShowTabBox() ); m_alternativeTabBoxUi->highlightWindowCheck->setChecked( TabBox::TabBoxConfig::defaultHighlightWindow() ); + m_alternativeTabBoxUi->showDesktopBox->setChecked( TabBox::TabBoxConfig::defaultShowDesktop() ); // effects m_alternativeTabBoxUi->effectCombo->setCurrentIndex( 0 ); @@ -431,6 +438,7 @@ void KWinTabBoxConfig::updateUiFromConfig( KWinTabBoxConfigForm* ui, const KWin: ui->showOutlineCheck->setChecked( config.isShowOutline() ); ui->showTabBox->setChecked( config.isShowTabBox()); ui->highlightWindowCheck->setChecked( config.isHighlightWindows() ); + ui->showDesktopBox->setChecked( config.isShowDesktop() ); } void KWinTabBoxConfig::updateConfigFromUi( const KWin::KWinTabBoxConfigForm* ui, TabBox::TabBoxConfig& config ) @@ -441,6 +449,7 @@ void KWinTabBoxConfig::updateConfigFromUi( const KWin::KWinTabBoxConfigForm* ui, config.setShowOutline( ui->showOutlineCheck->isChecked() ); config.setShowTabBox( ui->showTabBox->isChecked() ); config.setHighlightWindows( ui->highlightWindowCheck->isChecked() ); + config.setShowDesktop( ui->showDesktopBox->isChecked() ); } void KWinTabBoxConfig::slotEffectSelectionChanged( int index ) diff --git a/kcmkwin/kwintabbox/main.ui b/kcmkwin/kwintabbox/main.ui index 82fc0d8c57..ddaa03b4bb 100644 --- a/kcmkwin/kwintabbox/main.ui +++ b/kcmkwin/kwintabbox/main.ui @@ -6,8 +6,8 @@ 0 0 - 445 - 288 + 490 + 332 @@ -97,14 +97,14 @@ - + Show outline of selected window - + Effect: @@ -114,7 +114,7 @@ - + @@ -144,6 +144,16 @@ + + + + Adds an entry to minimize all windows. + + + Include desktop + + + diff --git a/kcmkwin/kwintabbox/previewhandlerimpl.cpp b/kcmkwin/kwintabbox/previewhandlerimpl.cpp index 73310d151b..470cd2f2a3 100644 --- a/kcmkwin/kwintabbox/previewhandlerimpl.cpp +++ b/kcmkwin/kwintabbox/previewhandlerimpl.cpp @@ -175,5 +175,11 @@ int PreviewHandlerImpl::activeScreen() const return 0; } +TabBoxClient* PreviewHandlerImpl::desktopClient() const + { + return 0; + } + + } // namespace TabBox } // namespace KWin diff --git a/kcmkwin/kwintabbox/previewhandlerimpl.h b/kcmkwin/kwintabbox/previewhandlerimpl.h index 28c0cb8edb..b8f51fe01b 100644 --- a/kcmkwin/kwintabbox/previewhandlerimpl.h +++ b/kcmkwin/kwintabbox/previewhandlerimpl.h @@ -65,6 +65,7 @@ class PreviewHandlerImpl : virtual KWin::TabBox::TabBoxClient* nextClientFocusChain(KWin::TabBox::TabBoxClient* client) const; virtual KWin::TabBox::TabBoxClient* activeClient() const; virtual int activeScreen() const; + virtual TabBoxClient* desktopClient() const; private: TabBoxClientList m_stackingOrder; diff --git a/tabbox.cpp b/tabbox.cpp index 0c7b8d20fb..b5c0e341df 100644 --- a/tabbox.cpp +++ b/tabbox.cpp @@ -180,6 +180,18 @@ TabBoxClientList TabBoxHandlerImpl::stackingOrder() const return ret; } +TabBoxClient* TabBoxHandlerImpl::desktopClient() const + { + foreach( const Client* client, Workspace::self()->stackingOrder() ) + { + if( client->isDesktop() ) + { + return client->tabBoxClient(); + } + } + return NULL; + } + /********************************************************* * TabBoxClientImpl *********************************************************/ @@ -195,6 +207,9 @@ TabBoxClientImpl::~TabBoxClientImpl() QString TabBoxClientImpl::caption() const { + if( m_client->isDesktop() ) + return i18nc( "Special entry in alt+tab list for minimizing all windows", + "Show Desktop" ); return m_client->caption(); } @@ -258,12 +273,14 @@ TabBox::TabBox( Workspace *ws ) m_desktopConfig = TabBoxConfig(); m_desktopConfig.setTabBoxMode( TabBoxConfig::DesktopTabBox ); m_desktopConfig.setShowTabBox( true ); + m_desktopConfig.setShowDesktop( false ); m_desktopConfig.setDesktopSwitchingMode( TabBoxConfig::MostRecentlyUsedDesktopSwitching ); m_desktopConfig.setLayout( TabBoxConfig::VerticalLayout ); m_desktopListConfig = TabBoxConfig(); m_desktopListConfig.setTabBoxMode( TabBoxConfig::DesktopTabBox ); m_desktopListConfig.setShowTabBox( true ); + m_desktopListConfig.setShowDesktop( false ); m_desktopListConfig.setDesktopSwitchingMode( TabBoxConfig::StaticDesktopSwitching ); m_desktopListConfig.setLayout( TabBoxConfig::VerticalLayout ); m_tabBox = new TabBoxHandlerImpl(); @@ -523,6 +540,8 @@ void TabBox::loadConfig( const KConfigGroup& config, TabBoxConfig& tabBoxConfig TabBoxConfig::defaultShowTabBox())); tabBoxConfig.setHighlightWindows( config.readEntry( "HighlightWindows", TabBoxConfig::defaultHighlightWindow())); + tabBoxConfig.setShowDesktop( config.readEntry( "ShowDesktop", + TabBoxConfig::defaultShowDesktop())); tabBoxConfig.setMinWidth( config.readEntry( "MinWidth", TabBoxConfig::defaultMinWidth())); @@ -1156,6 +1175,8 @@ void Workspace::tabBoxKeyRelease( const XKeyEvent& ev ) activateClient( c ); if( c->isShade() && options->shadeHover ) c->setShade( ShadeActivated ); + if( c->isDesktop() ) + setShowingDesktop( !showingDesktop() ); } } if (control_grab) diff --git a/tabbox.h b/tabbox.h index c75c2bda41..90e42b1f71 100644 --- a/tabbox.h +++ b/tabbox.h @@ -55,6 +55,7 @@ class TabBoxHandlerImpl : public TabBoxHandler virtual int numberOfDesktops() const; virtual TabBoxClientList stackingOrder() const; virtual TabBoxClient* clientToAddToList( TabBoxClient* client, int desktop, bool allDesktops ) const; + virtual TabBoxClient* desktopClient() const; }; class TabBoxClientImpl : public TabBoxClient diff --git a/tabbox/clientmodel.cpp b/tabbox/clientmodel.cpp index 12f9444f36..559a66517f 100644 --- a/tabbox/clientmodel.cpp +++ b/tabbox/clientmodel.cpp @@ -226,6 +226,12 @@ void ClientModel::createClientList( int desktop, bool partialReset ) break; } } + if( tabBox->config().isShowDesktop() ) + { + TabBoxClient* desktopClient = tabBox->desktopClient(); + if( desktopClient ) + m_clientList.append( desktopClient ); + } reset(); } diff --git a/tabbox/tabboxconfig.cpp b/tabbox/tabboxconfig.cpp index 931b0193d9..39488c907d 100644 --- a/tabbox/tabboxconfig.cpp +++ b/tabbox/tabboxconfig.cpp @@ -41,6 +41,7 @@ class TabBoxConfigPrivate , minHeight( TabBoxConfig::defaultMinHeight() ) , layoutName( TabBoxConfig::defaultLayoutName() ) , selectedItemLayoutName( TabBoxConfig::defaultSelectedItemLayoutName() ) + , showDesktop( TabBoxConfig::defaultShowDesktop() ) { } ~TabBoxConfigPrivate() @@ -60,6 +61,7 @@ class TabBoxConfigPrivate int minHeight; QString layoutName; QString selectedItemLayoutName; + bool showDesktop; }; TabBoxConfig::TabBoxConfig() @@ -78,6 +80,7 @@ TabBoxConfig& TabBoxConfig::operator=( const KWin::TabBox::TabBoxConfig& object d->highlightWindows = object.isHighlightWindows(); d->showOutline = object.isShowOutline(); d->tabBoxMode = object.tabBoxMode(); + d->showDesktop = object.isShowDesktop(); d->layout = object.layout(); d->clientListMode = object.clientListMode(); d->clientSwitchingMode = object.clientSwitchingMode(); @@ -220,5 +223,15 @@ void TabBoxConfig::setSelectedItemLayoutName( const QString& name ) d->selectedItemLayoutName = name; } +bool TabBoxConfig::isShowDesktop() const + { + return d->showDesktop; + } + +void TabBoxConfig::setShowDesktop( bool show ) + { + d->showDesktop = show; + } + } // namespace TabBox } // namespace KWin diff --git a/tabbox/tabboxconfig.h b/tabbox/tabboxconfig.h index ed5f595544..da70cc79b7 100644 --- a/tabbox/tabboxconfig.h +++ b/tabbox/tabboxconfig.h @@ -199,6 +199,11 @@ class TabBoxConfig * @see setlayoutName */ QString& selectedItemLayoutName() const; + /** + * @return If an item for minimizing all windows to the desktop should be included. + * @see setShowDesktop + */ + bool isShowDesktop() const; // setters /** @@ -272,6 +277,11 @@ class TabBoxConfig * @see selectedItemLayoutName */ void setSelectedItemLayoutName( const QString& name ); + /** + * @param show Include item to minimize all windows to the desktop + * @see isShowDesktop + */ + void setShowDesktop( bool show ); // some static methods to access default values static ClientListMode defaultListMode() { return CurrentDesktopClientList; } @@ -285,6 +295,7 @@ class TabBoxConfig static int defaultMinHeight() { return 20; } static QString defaultLayoutName() { return QString( "Default" ); } static QString defaultSelectedItemLayoutName() { return QString( "Text" ); } + static bool defaultShowDesktop() { return false; } private: TabBoxConfigPrivate* d; }; diff --git a/tabbox/tabboxhandler.h b/tabbox/tabboxhandler.h index 68118d7dde..bd24888a18 100644 --- a/tabbox/tabboxhandler.h +++ b/tabbox/tabboxhandler.h @@ -157,6 +157,10 @@ class TabBoxHandler : public QObject * @return The client to be included in the list or NULL if it isn't to be included */ virtual TabBoxClient* clientToAddToList( TabBoxClient* client, int desktop, bool allDesktops ) const = 0; + /** + * @return The first desktop window in the stacking order. + */ + virtual TabBoxClient* desktopClient() const = 0; /** * @return The currently used TabBoxConfig