Add working config modules for PresentWindows and Shadow effects.

You can configure shadow's offset and opacity and presentwindow's mouse activation areas
  (e.g. activate when mouse it at top-right corner).

svn path=/trunk/KDE/kdebase/workspace/; revision=669040
icc-effect-5.14.5
Rivo Laks 2007-05-28 11:34:12 +00:00
parent f8613ab4bd
commit c22b4809a5
10 changed files with 369 additions and 5 deletions

View File

@ -6,6 +6,13 @@ macro(KWIN4_ADD_EFFECT name)
install(TARGETS kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR})
endmacro(KWIN4_ADD_EFFECT)
macro(KWIN4_ADD_EFFECT_CONFIG name)
kde4_automoc(${ARGN})
kde4_add_plugin(kcm_kwin4_effect_${name} ${ARGN})
target_link_libraries(kcm_kwin4_effect_${name} ${KDE4_KUTILS_LIBS})
install(TARGETS kcm_kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR})
endmacro(KWIN4_ADD_EFFECT_CONFIG)
include_directories(
${CMAKE_SOURCE_DIR}/workspace/kwin/lib
)
@ -77,6 +84,15 @@ if(OPENGL_FOUND)
data/blur-render.frag
data/blur-render.vert
DESTINATION ${DATA_INSTALL_DIR}/kwin )
# config modules
KWIN4_ADD_EFFECT_CONFIG( builtins presentwindows_config.cpp shadow_config.cpp )
install( FILES
presentwindows_config.desktop
shadow_config.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
endif(OPENGL_FOUND)
# showfps - need both xrender and opengl

View File

@ -38,6 +38,8 @@ PresentWindowsEffect::PresentWindowsEffect()
, filterTexture( NULL )
#endif
{
KConfig c("kwinrc");
KConfigGroup conf(&c, "Effect-PresentWindows");
KActionCollection* actionCollection = new KActionCollection( this );
KAction* a = (KAction*)actionCollection->addAction( "Expose" );
@ -49,8 +51,8 @@ PresentWindowsEffect::PresentWindowsEffect()
b->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F11));
connect(b, SIGNAL(triggered(bool)), this, SLOT(toggleActiveAllDesktops()));
borderActivate = ElectricTopRight; // TODO config options
borderActivateAll = ElectricNone;
borderActivate = (ElectricBorder)conf.readEntry("BorderActivate", (int)ElectricTopRight);
borderActivateAll = (ElectricBorder)conf.readEntry("BorderActivateAll", (int)ElectricNone);
effects->reserveElectricBorder( borderActivate );
effects->reserveElectricBorder( borderActivateAll );

View File

@ -0,0 +1,128 @@
/*****************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#include "presentwindows_config.h"
#include <kwineffects.h>
#include <kgenericfactory.h>
#include <klocale.h>
#include <kdebug.h>
#include <QWidget>
#include <QGridLayout>
#include <QLabel>
#include <QStringList>
#include <QComboBox>
KWIN_EFFECT_CONFIG( presentwindows, KWin::PresentWindowsEffectConfig )
namespace KWin
{
PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QStringList& args) :
KCModule(KGenericFactory<PresentWindowsEffectConfig>::componentData(), parent, args)
{
kDebug() << k_funcinfo << endl;
QGridLayout* layout = new QGridLayout(this);
layout->addWidget(new QLabel(i18n("Activate when cursor is at a specific edge "
"or corner of the screen:")), 0, 0, 1, 3);
layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed), 1, 0, 2, 1);
layout->addWidget(new QLabel("for windows on current desktop: "), 1, 1);
mActivateCombo = new QComboBox;
addItems(mActivateCombo);
connect(mActivateCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
layout->addWidget(mActivateCombo, 1, 2);
layout->addWidget(new QLabel("for windows all desktop: "), 2, 1);
mActivateAllCombo = new QComboBox;
addItems(mActivateAllCombo);
connect(mActivateAllCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
layout->addWidget(mActivateAllCombo, 2, 2);
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 3, 0, 1, 3);
load();
}
PresentWindowsEffectConfig::~PresentWindowsEffectConfig()
{
kDebug() << k_funcinfo << endl;
}
void PresentWindowsEffectConfig::addItems(QComboBox* combo)
{
combo->addItem(i18n("Top"));
combo->addItem(i18n("Top-right"));
combo->addItem(i18n("Right"));
combo->addItem(i18n("Bottom-right"));
combo->addItem(i18n("Bottom"));
combo->addItem(i18n("Bottom-left"));
combo->addItem(i18n("Left"));
combo->addItem(i18n("Top-left"));
combo->addItem(i18n("None"));
}
void PresentWindowsEffectConfig::load()
{
kDebug() << k_funcinfo << endl;
KCModule::load();
KConfig c("kwinrc");
KConfigGroup conf(&c, "Effect-PresentWindows");
int activateBorder = conf.readEntry("BorderActivate", (int)ElectricTopRight);
if(activateBorder == (int)ElectricNone)
activateBorder--;
mActivateCombo->setCurrentIndex(activateBorder);
int activateAllBorder = conf.readEntry("BorderActivateAll", (int)ElectricNone);
if(activateAllBorder == (int)ElectricNone)
activateAllBorder--;
mActivateAllCombo->setCurrentIndex(activateAllBorder);
emit changed(false);
}
void PresentWindowsEffectConfig::save()
{
kDebug() << k_funcinfo << endl;
KCModule::save();
KConfig c("kwinrc");
KConfigGroup conf(&c, "Effect-PresentWindows");
int activateBorder = mActivateCombo->currentIndex();
if(activateBorder == (int)ELECTRIC_COUNT)
activateBorder = (int)ElectricNone;
conf.writeEntry("BorderActivate", activateBorder);
int activateAllBorder = mActivateAllCombo->currentIndex();
if(activateAllBorder == (int)ELECTRIC_COUNT)
activateAllBorder = (int)ElectricNone;
conf.writeEntry("BorderActivateAll", activateAllBorder);
conf.sync();
emit changed(false);
}
void PresentWindowsEffectConfig::defaults()
{
kDebug() << k_funcinfo << endl;
mActivateCombo->setCurrentIndex( (int)ElectricTopRight );
mActivateAllCombo->setCurrentIndex( (int)ElectricNone - 1 );
emit changed(true);
}
} // namespace
#include "presentwindows_config.moc"

View File

@ -0,0 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Type=Service
ServiceTypes=KCModule
X-KDE-Library=kcm_kwin4_effect_builtins
X-KDE-FactoryName=kcm_kwineffect_presentwindows
X-KDE-ParentComponents=kwin4_effect_presentwindows
Name=PresentWindows

View File

@ -0,0 +1,43 @@
/*****************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#ifndef KWIN_PRESENTWINDOWS_CONFIG_H
#define KWIN_PRESENTWINDOWS_CONFIG_H
#include <kcmodule.h>
class QComboBox;
namespace KWin
{
class PresentWindowsEffectConfig : public KCModule
{
Q_OBJECT
public:
PresentWindowsEffectConfig(QWidget* parent = 0, const QStringList& args = QStringList());
~PresentWindowsEffectConfig();
virtual void save();
virtual void load();
virtual void defaults();
protected:
void addItems(QComboBox* combo);
private:
QComboBox* mActivateCombo;
QComboBox* mActivateAllCombo;
};
} // namespace
#endif

View File

@ -12,15 +12,21 @@ License. See the file "COPYING" for the exact licensing terms.
#include <kwinglutils.h>
#include <kconfiggroup.h>
#include <kconfig.h>
namespace KWin
{
KWIN_EFFECT( shadow, ShadowEffect )
ShadowEffect::ShadowEffect()
: shadowXOffset( 10 )
, shadowYOffset( 10 )
{
KConfig c( "kwinrc" );
KConfigGroup conf( &c, "Effect-Shadow" );
shadowXOffset = conf.readEntry( "XOffset", 5 );
shadowYOffset = conf.readEntry( "YOffset", 5 );
shadowOpacity = (float)conf.readEntry( "Opacity", 0.2 );
}
void ShadowEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time )
@ -55,7 +61,7 @@ void ShadowEffect::drawShadow( EffectWindow* w, int mask, QRegion region, Window
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glColor4f( 0, 0, 0, 0.2 * data.opacity ); // black
glColor4f( 0, 0, 0, shadowOpacity * data.opacity ); // black
glPushMatrix();
if( mask & PAINT_WINDOW_TRANSFORMED )

View File

@ -28,6 +28,7 @@ class ShadowEffect
private:
void drawShadow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
int shadowXOffset, shadowYOffset;
float shadowOpacity;
};
} // namespace

107
effects/shadow_config.cpp Normal file
View File

@ -0,0 +1,107 @@
/*****************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#include "shadow_config.h"
#include <kwineffects.h>
#include <kgenericfactory.h>
#include <klocale.h>
#include <kdebug.h>
#include <QWidget>
#include <QGridLayout>
#include <QLabel>
#include <QStringList>
#include <QSpinBox>
KWIN_EFFECT_CONFIG( shadow, KWin::ShadowEffectConfig )
namespace KWin
{
ShadowEffectConfig::ShadowEffectConfig(QWidget* parent, const QStringList& args) :
KCModule(KGenericFactory<ShadowEffectConfig>::componentData(), parent, args)
{
kDebug() << k_funcinfo << endl;
QGridLayout* layout = new QGridLayout(this);
layout->addWidget(new QLabel(i18n("X offset:")), 0, 0);
mShadowXOffset = new QSpinBox;
mShadowXOffset->setRange(-20, 20);
connect(mShadowXOffset, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowXOffset, 0, 1);
layout->addWidget(new QLabel(i18n("Y offset:")), 1, 0);
mShadowYOffset = new QSpinBox;
mShadowYOffset->setRange(-20, 20);
connect(mShadowYOffset, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowYOffset, 1, 1);
layout->addWidget(new QLabel(i18n("Shadow opacity:")), 2, 0);
mShadowOpacity = new QSpinBox;
mShadowOpacity->setRange(0, 100);
mShadowOpacity->setSuffix("%");
connect(mShadowOpacity, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowOpacity, 2, 1);
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 3, 0, 1, 2);
load();
}
ShadowEffectConfig::~ShadowEffectConfig()
{
kDebug() << k_funcinfo << endl;
}
void ShadowEffectConfig::load()
{
kDebug() << k_funcinfo << endl;
KCModule::load();
KConfig c("kwinrc");
KConfigGroup conf(&c, "Effect-Shadow");
mShadowXOffset->setValue( conf.readEntry( "XOffset", 5 ) );
mShadowYOffset->setValue( conf.readEntry( "YOffset", 5 ) );
mShadowOpacity->setValue( (int)( conf.readEntry( "Opacity", 0.2 ) * 100 ) );
emit changed(false);
}
void ShadowEffectConfig::save()
{
kDebug() << k_funcinfo << endl;
KCModule::save();
KConfig c("kwinrc");
KConfigGroup conf(&c, "Effect-Shadow");
conf.writeEntry( "XOffset", mShadowXOffset->value() );
conf.writeEntry( "YOffset", mShadowYOffset->value() );
conf.writeEntry( "Opacity", mShadowOpacity->value() / 100.0 );
conf.sync();
emit changed(false);
}
void ShadowEffectConfig::defaults()
{
kDebug() << k_funcinfo << endl;
mShadowXOffset->setValue( 5 );
mShadowYOffset->setValue( 5 );
mShadowOpacity->setValue( 20 );
emit changed(true);
}
} // namespace
#include "shadow_config.moc"

View File

@ -0,0 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Type=Service
ServiceTypes=KCModule
X-KDE-Library=kcm_kwin4_effect_builtins
X-KDE-FactoryName=kcm_kwineffect_shadow
X-KDE-ParentComponents=kwin4_effect_shadow
Name=Shadow

41
effects/shadow_config.h Normal file
View File

@ -0,0 +1,41 @@
/*****************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#ifndef KWIN_SHADOW_CONFIG_H
#define KWIN_SHADOW_CONFIG_H
#include <kcmodule.h>
class QSpinBox;
namespace KWin
{
class ShadowEffectConfig : public KCModule
{
Q_OBJECT
public:
ShadowEffectConfig(QWidget* parent = 0, const QStringList& args = QStringList());
~ShadowEffectConfig();
virtual void save();
virtual void load();
virtual void defaults();
private:
QSpinBox* mShadowXOffset;
QSpinBox* mShadowYOffset;
QSpinBox* mShadowOpacity;
};
} // namespace
#endif