initial commit of the KWin dashboard effect

svn path=/trunk/KDE/kdebase/workspace/; revision=1153704
This commit is contained in:
Andreas Demmer 2010-07-23 19:52:20 +00:00
parent a11fe5349b
commit 2bedb6bba9
12 changed files with 708 additions and 12 deletions

View file

@ -25,7 +25,7 @@ macro( KWIN4_ADD_EFFECT_CONFIG name )
kde4_add_ui_files( kwin4_effect_src ${kwin4_effect_ui} )
kde4_add_plugin( kcm_kwin4_effect_${name} ${kwin4_effect_src} )
target_link_libraries( kcm_kwin4_effect_${name} kwineffects ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS} kephal )
target_link_libraries( kcm_kwin4_effect_${name} kwineffects ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} kephal )
install( TARGETS kcm_kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR} )
endmacro( KWIN4_ADD_EFFECT_CONFIG )
@ -53,6 +53,7 @@ set( kwin4_effect_include_directories )
# Common effects
include( boxswitch/CMakeLists.txt )
include( dashboard/CMakeLists.txt )
include( desktopgrid/CMakeLists.txt )
include( dialogparent/CMakeLists.txt )
include( diminactive/CMakeLists.txt )

View file

@ -25,12 +25,6 @@
namespace KWin
{
enum {
BlurRegionRole = 0x1C50A74B
};
KWIN_EFFECT(blur, BlurEffect)
KWIN_EFFECT_SUPPORTED(blur, BlurEffect::supported())
@ -97,9 +91,9 @@ void BlurEffect::updateBlurRegion(EffectWindow *w) const
// Set the data to a dummy value.
// This is needed to be able to distinguish between the value not
// being set, and being set to an empty region.
w->setData(BlurRegionRole, 1);
w->setData(WindowBlurBehindRole, 1);
} else
w->setData(BlurRegionRole, region);
w->setData(WindowBlurBehindRole, region);
}
void BlurEffect::windowAdded(EffectWindow *w)
@ -152,7 +146,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const
{
QRegion region;
const QVariant value = w->data(BlurRegionRole);
const QVariant value = w->data(WindowBlurBehindRole);
if (value.isValid()) {
const QRegion appRegion = qvariant_cast<QRegion>(value);
if (!appRegion.isEmpty()) {
@ -229,7 +223,7 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
bool valid = target->valid() && shader->isValid();
QRegion shape;
const QVariant forceBlur = w->data( WindowForceBlurRole );
const QVariant forceBlur = w->data( WindowBlurBehindRole );
if ((!effects->activeFullScreenEffect() || (forceBlur.isValid() && forceBlur.toBool() ))
&& hasAlpha && !w->isDesktop() && !transformed)
shape = blurRegion(w).translated(w->geometry().topLeft()) & screen;

View file

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kwinconfig.h>
#include "boxswitch/boxswitch_config.h"
#include "dashboard/dashboard_config.h"
#include "desktopgrid/desktopgrid_config.h"
#include "diminactive/diminactive_config.h"
#include "magiclamp/magiclamp_config.h"
@ -59,6 +60,7 @@ namespace KWin
KWIN_EFFECT_CONFIG_MULTIPLE( builtins,
KWIN_EFFECT_CONFIG_SINGLE( boxswitch, BoxSwitchEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( dashboard, DashboardEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( desktopgrid, DesktopGridEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( diminactive, DimInactiveEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( magiclamp, MagicLampEffectConfig )

View file

@ -0,0 +1,24 @@
#######################################
# Effect
# Source files
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
dashboard/dashboard.cpp
dashboard/dashboard.cpp )
# .desktop files
install( FILES
dashboard/dashboard.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
#######################################
# Config
# Source files
set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources}
dashboard/dashboard_config.cpp
dashboard/dashboard_config.ui )
install( FILES
dashboard/dashboard_config.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )

View file

@ -0,0 +1,136 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2010 Andreas Demmer <ademmer@opensuse.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "dashboard.h"
namespace KWin
{
KWIN_EFFECT(dashboard, DashboardEffect)
DashboardEffect::DashboardEffect()
: transformWindow( false )
{
// propagate that the effect is loaded
propagate();
// read settings
reconfigure(ReconfigureAll);
}
DashboardEffect::~DashboardEffect()
{
unpropagate();
}
void DashboardEffect::propagate()
{
// TODO: better namespacing for atoms
atom = XInternAtom( display(), "_WM_EFFECT_KDE_DASHBOARD", false );
effects->registerPropertyType( atom, true );
// TODO: maybe not the best way to propagate the loaded effect
unsigned char dummy = 0;
XChangeProperty( display(), rootWindow(), atom, atom, 8, PropModeReplace, &dummy, 1 );
}
void DashboardEffect::unpropagate()
{
effects->registerPropertyType(atom, false);
XDeleteProperty(display(), rootWindow(), atom);
}
void DashboardEffect::reconfigure( ReconfigureFlags )
{
// read settings again
KConfigGroup config = EffectsHandler::effectConfig("Dashboard");
brightness = config.readEntry("Brightness", "50");
saturation = config.readEntry("Saturation", "50");
blur = config.readEntry("Blur", false);
}
void DashboardEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
{
if( transformWindow && ( w != window ) && w->isManaged() )
{
// dashboard active, transform other windows
data.brightness = brightness.toDouble() / 100;
data.saturation = saturation.toDouble() / 100;
}
effects->paintWindow( w, mask, region, data );
}
void DashboardEffect::postPaintScreen()
{
if( transformWindow )
{
if( retransformWindow )
{
retransformWindow = false;
transformWindow = false;
effects->addRepaintFull();
}
}
effects->postPaintScreen();
}
bool DashboardEffect::isDashboard ( EffectWindow *w )
{
if( w->windowClass() == "dashboard dashboard")
{
return true;
}
else
{
return false;
}
}
void DashboardEffect::windowActivated( EffectWindow *w )
{
if( !w )
return;
// apply effect on dashboard activation
if( isDashboard( w ) )
{
transformWindow = true;
window = w;
if ( blur )
{
w->setData( WindowBlurBehindRole, w->geometry() );
}
effects->addRepaintFull();
}
else
{
if( transformWindow)
{
retransformWindow = true;
effects->addRepaintFull();
}
}
}
} // namespace

View file

@ -0,0 +1,17 @@
[Desktop Entry]
Name=Dashboard
Icon=preferences-system-windows-effect-dashboard
Comment=Desaturate the desktop when displaying the Plasma dashboard
Type=Service
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-Author=Andreas Demmer
X-KDE-PluginInfo-Email=ademmer@opensuse.org
X-KDE-PluginInfo-Name=kwin4_effect_dashboard
X-KDE-PluginInfo-Version=0.1.0
X-KDE-PluginInfo-Category=Appearance
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-Library=kwin4_effect_builtins
X-KDE-Ordering=85

View file

@ -0,0 +1,59 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2010 Andreas Demmer <ademmer@opensuse.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_DASHBOARD_H
#define KWIN_DASHBOARD_H
#include <kwineffects.h>
#include <QGraphicsView>
#include <QGraphicsItem>
#include <Plasma/WindowEffects>
namespace KWin
{
class GLRenderTarget;
class GLTexture;
class DashboardEffect : public KWin::Effect
{
public:
DashboardEffect();
~DashboardEffect();
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
virtual void postPaintScreen();
virtual void propagate();
virtual void reconfigure( ReconfigureFlags );
virtual void unpropagate();
virtual void windowActivated( EffectWindow *w );
private:
bool blur;
bool isDashboard( EffectWindow* w );
bool transformWindow;
bool retransformWindow;
long atom;
QString brightness;
QString saturation;
EffectWindow* window;
};
} // namespace
#endif

View file

@ -0,0 +1,89 @@
/*
* Copyright © 2010 Andreas Demmer <ademmer@opensuse.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. if not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "dashboard_config.h"
#include <kwineffects.h>
namespace KWin
{
KWIN_EFFECT_CONFIG_FACTORY
DashboardEffectConfig::DashboardEffectConfig(QWidget *parent, const QVariantList &args)
: KCModule(EffectFactory::componentData(), parent, args)
{
ui.setupUi(this);
connect(ui.brightness, SIGNAL(valueChanged(int)), SLOT(valueChanged(int)));
connect(ui.saturation, SIGNAL(valueChanged(int)), SLOT(valueChanged(int)));
connect(ui.blur, SIGNAL(stateChanged(int)), SLOT(valueChanged(int)));
load();
}
DashboardEffectConfig::~DashboardEffectConfig()
{
}
void DashboardEffectConfig::load()
{
KCModule::load();
KConfigGroup config = EffectsHandler::effectConfig("Dashboard");
QString brightness = config.readEntry("Brightness", "5");
ui.brightness->setValue(brightness.toInt());
QString saturation = config.readEntry("Saturation", "5");
ui.saturation->setValue(saturation.toInt());
bool blur = config.readEntry("Blur", false);
ui.blur->setChecked(blur);
emit changed(false);
}
void DashboardEffectConfig::save()
{
KCModule::save();
KConfigGroup config = EffectsHandler::effectConfig("Dashboard");
config.writeEntry("Brightness", ui.brightness->value());
config.writeEntry("Saturation", ui.saturation->value());
config.writeEntry("Blur", ui.blur->isChecked());
config.sync();
emit changed(false);
EffectsHandler::sendReloadMessage("dashboard");
}
void DashboardEffectConfig::valueChanged(int value)
{
Q_UNUSED(value)
emit changed(true);
}
void DashboardEffectConfig::defaults()
{
emit changed(true);
}
} // namespace KWin

View file

@ -0,0 +1,9 @@
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_kwin4_effect_builtins
X-KDE-ParentComponents=kwin4_effect_dashboard
X-KDE-PluginKeyword=dashboard
Name=Dashboard

View file

@ -0,0 +1,54 @@
/*
* Copyright © 2010 Andreas Demmer <ademmer@opensuse.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. if not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KWIN_DASHBOARD_CONFIG_H
#define KWIN_DASHBOARD_CONFIG_H
#include <KCModule>
#include "ui_dashboard_config.h"
namespace KWin
{
class DashboardEffectConfig : public KCModule
{
Q_OBJECT
public:
explicit DashboardEffectConfig(QWidget *parent = 0, const QVariantList& args = QVariantList());
~DashboardEffectConfig();
void save();
void load();
void defaults();
private:
bool isBlurEffectAvailable ();
long net_wm_dashboard;
::Ui::DashboardEffectConfig ui;
private slots:
void valueChanged(int value);
};
} // namespace KWin
#endif

View file

@ -0,0 +1,310 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DashboardEffectConfig</class>
<widget class="QWidget" name="DashboardEffectConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>260</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>260</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>260</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>381</width>
<height>241</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBoxBrightness">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Background brightness</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
<rect>
<x>20</x>
<y>28</y>
<width>341</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelBrightnessDarker">
<property name="text">
<string>darker</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="brightness">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>150</horstretch>
<verstretch>35</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>35</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>25</height>
</size>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelBrightnessLighter">
<property name="text">
<string>lighter</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxSaturation">
<property name="title">
<string>Background saturation</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_4">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>339</width>
<height>50</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelSaturationGray">
<property name="text">
<string>gray</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="saturation">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>150</horstretch>
<verstretch>35</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>35</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>25</height>
</size>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelSaturationColored">
<property name="text">
<string>colored</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxEffects">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Effects</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>341</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="blur">
<property name="text">
<string>Blur background (depends on &quot;Blur&quot; effect)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -194,7 +194,8 @@ enum DataRole
WindowClosedGrabRole,
WindowMinimizedGrabRole,
WindowUnminimizedGrabRole,
WindowForceBlurRole ///< For fullscreen effects to enforce blurring of windows
WindowForceBlurRole, ///< For fullscreen effects to enforce blurring of windows,
WindowBlurBehindRole ///< For single windows to blur behind
};
/**