diff --git a/effects/desktopgrid.cpp b/effects/desktopgrid.cpp index 3950c58680..6d9dd01ade 100644 --- a/effects/desktopgrid.cpp +++ b/effects/desktopgrid.cpp @@ -51,6 +51,14 @@ DesktopGridEffect::DesktopGridEffect() connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle())); KConfigGroup conf = effects->effectConfig("DesktopGrid"); slideEnabled = conf.readEntry( "Slide", true ); + + borderActivate = (ElectricBorder)conf.readEntry("BorderActivate", (int)ElectricNone); + effects->reserveElectricBorder( borderActivate ); + } + +DesktopGridEffect::~DesktopGridEffect() + { + effects->unreserveElectricBorder( borderActivate ); } void DesktopGridEffect::prePaintScreen( ScreenPrePaintData& data, int time ) @@ -615,6 +623,18 @@ void DesktopGridEffect::setHighlightedDesktop( int d ) effects->addRepaint( desktopRect( highlighted_desktop, true )); } +bool DesktopGridEffect::borderActivated( ElectricBorder border ) + { + if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this ) + return false; + if( border == borderActivate && !activated ) + { + toggle(); + return true; + } + return false; + } + } // namespace #include "desktopgrid.moc" diff --git a/effects/desktopgrid.h b/effects/desktopgrid.h index aed864ce96..dade2a3633 100644 --- a/effects/desktopgrid.h +++ b/effects/desktopgrid.h @@ -33,6 +33,7 @@ class DesktopGridEffect Q_OBJECT public: DesktopGridEffect(); + ~DesktopGridEffect(); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void postPaintScreen(); @@ -42,6 +43,7 @@ class DesktopGridEffect virtual void desktopChanged( int old ); virtual void windowInputMouseEvent( Window w, QEvent* e ); virtual void grabbedKeyboardEvent( QKeyEvent* e ); + virtual bool borderActivated( ElectricBorder border ); private slots: void toggle(); private: @@ -71,6 +73,7 @@ class DesktopGridEffect QPoint slide_start_pos; bool slide_painting_sticky; QPoint slide_painting_diff; + ElectricBorder borderActivate; }; } // namespace diff --git a/effects/desktopgrid_config.cpp b/effects/desktopgrid_config.cpp index 5f013a5658..19c4b48a6a 100644 --- a/effects/desktopgrid_config.cpp +++ b/effects/desktopgrid_config.cpp @@ -31,7 +31,10 @@ along with this program. If not, see . #include #include +#include #include +#include +#include #ifndef KDE_USE_FINAL KWIN_EFFECT_CONFIG_FACTORY #endif @@ -49,6 +52,25 @@ DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariant connect(mSlide, SIGNAL(toggled(bool)), this, SLOT(changed())); layout->addWidget(mSlide); + QHBoxLayout* comboLayout = new QHBoxLayout(); + QLabel* label = new QLabel(i18n("Activate when cursor is at a specific edge " + "or corner of the screen:"), this); + + mActivateCombo = new QComboBox; + mActivateCombo->addItem(i18n("Top")); + mActivateCombo->addItem(i18n("Top-right")); + mActivateCombo->addItem(i18n("Right")); + mActivateCombo->addItem(i18n("Bottom-right")); + mActivateCombo->addItem(i18n("Bottom")); + mActivateCombo->addItem(i18n("Bottom-left")); + mActivateCombo->addItem(i18n("Left")); + mActivateCombo->addItem(i18n("Top-left")); + mActivateCombo->addItem(i18n("None")); + connect(mActivateCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); + comboLayout->addWidget(label); + comboLayout->addWidget(mActivateCombo); + layout->addLayout(comboLayout); + KGlobalAccel::self()->overrideMainComponentData(componentData()); KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") ); KAction* show = static_cast(actionCollection->addAction( "ShowDesktopGrid" )); @@ -78,6 +100,11 @@ void DesktopGridEffectConfig::load() KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid"); mSlide->setChecked(conf.readEntry("Slide", true)); + int activateBorder = conf.readEntry("BorderActivate", (int)ElectricNone); + if(activateBorder == (int)ElectricNone) + activateBorder--; + mActivateCombo->setCurrentIndex(activateBorder); + emit changed(false); } @@ -89,6 +116,10 @@ void DesktopGridEffectConfig::save() KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid"); conf.writeEntry("Slide", mSlide->isChecked()); + int activateBorder = mActivateCombo->currentIndex(); + if(activateBorder == (int)ELECTRIC_COUNT) + activateBorder = (int)ElectricNone; + conf.writeEntry("BorderActivate", activateBorder); conf.sync(); emit changed(false); @@ -99,10 +130,10 @@ void DesktopGridEffectConfig::defaults() { kDebug() ; mSlide->setChecked(true); + mActivateCombo->setCurrentIndex( (int)ElectricNone ); emit changed(true); } - } // namespace #include "desktopgrid_config.moc" diff --git a/effects/desktopgrid_config.h b/effects/desktopgrid_config.h index 99e3d2ed99..01a3ca2102 100644 --- a/effects/desktopgrid_config.h +++ b/effects/desktopgrid_config.h @@ -25,6 +25,7 @@ along with this program. If not, see . #include #undef KDE3_SUPPORT +class QComboBox; class QCheckBox; namespace KWin @@ -44,6 +45,7 @@ class DesktopGridEffectConfig : public KCModule private: QCheckBox* mSlide; + QComboBox* mActivateCombo; }; } // namespace