[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwin
Subject:    Active Border for DesktopGrid
From:       Martin Graesslin <ubuntu () martin-graesslin ! com>
Date:       2008-01-25 17:01:07
Message-ID: 200801251801.13790.ubuntu () martin-graesslin ! com
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


I just implemented the feature request from Bug 155954. With this it is 
possible to use one corner to trigger desktop grid like the one in present 
window (see attached diff).

Unfortunatelly it is possible to choose the same corner in both effects (only 
one effect is triggered). But it would be nicer, if the user would receive a 
message dialog that the corner is allready used. I have not seen any 
possibility to use such a feature at the moment, as I don't know how to check 
which corners are allready reserved.

["desktopgrid.diff" (text/x-diff)]

Index: desktopgrid_config.h
===================================================================
--- desktopgrid_config.h	(Revision 766351)
+++ desktopgrid_config.h	(Arbeitskopie)
@@ -25,6 +25,7 @@
 #include <kcmodule.h>
 #undef KDE3_SUPPORT
 
+class QComboBox;
 class QCheckBox;
 
 namespace KWin
@@ -44,6 +45,7 @@
 
     private:
         QCheckBox* mSlide;
+        QComboBox* mActivateCombo;
     };
 
 } // namespace
Index: desktopgrid_config.cpp
===================================================================
--- desktopgrid_config.cpp	(Revision 766351)
+++ desktopgrid_config.cpp	(Arbeitskopie)
@@ -31,7 +31,10 @@
 #include <kconfiggroup.h>
 
 #include <QVBoxLayout>
+#include <QHBoxLayout>
 #include <QCheckBox>
+#include <QComboBox>
+#include <QLabel>
 #ifndef KDE_USE_FINAL
 KWIN_EFFECT_CONFIG_FACTORY
 #endif
@@ -49,6 +52,25 @@
     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<KAction*>(actionCollection->addAction( "ShowDesktopGrid" ));
@@ -78,6 +100,11 @@
     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 @@
     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 @@
     {
     kDebug() ;
     mSlide->setChecked(true);
+    mActivateCombo->setCurrentIndex( (int)ElectricNone );
     emit changed(true);
     }
 
-
 } // namespace
 
 #include "desktopgrid_config.moc"
Index: desktopgrid.h
===================================================================
--- desktopgrid.h	(Revision 766351)
+++ desktopgrid.h	(Arbeitskopie)
@@ -33,6 +33,7 @@
     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 @@
         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 @@
         QPoint slide_start_pos;
         bool slide_painting_sticky;
         QPoint slide_painting_diff;
+        ElectricBorder borderActivate;
     };
 
 } // namespace
Index: desktopgrid.cpp
===================================================================
--- desktopgrid.cpp	(Revision 766351)
+++ desktopgrid.cpp	(Arbeitskopie)
@@ -51,8 +51,16 @@
     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 )
     {
     if( slide )
@@ -615,6 +623,18 @@
     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"

["signature.asc" (application/pgp-signature)]

_______________________________________________
Kwin mailing list
Kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic