Hi plasma-devs, I had the idea to improve the appearance of the plasma dashboard by using a KWin effect for it. Currently I have some proof-of-concept code, but there are still some issues ;-)
The effect changes the brightness and satuation of all windows on the same screen as the dashboard (causing some problems for multi-screen setups, but I have some ideas to solve them ;-) ). That's the same way as dim inactive or dim screen for administration mode works. So we can have a nice animation instead of "it's just there". I changed the background of dashboard to be transparent, but nevertheless there is some black background. I have no idea where that comes from :-( My idea for the effect does not only include the way the background is changed. I would like to have a smooth transition. I have not yet tried anything but I would like to paint the windows transparent and raise the dashboard from desktop to the top and when deactivating the other way around. I think that could be a nice animation. If someone has a better idea please provide it ;-) But here is the next problem: the white flash when opening the dashboard. As long as there is this white flash an animation does not make any sense. So we have to get rid of it. What about never closing the dashboard widget? It is created during startup and just put behind the desktop. We could also use the existing effect to always hide it. Or just have it on top of the desktop and have the plasmoids live in there. That way we could also benefit in other effects. We already had requests to hide the plasmoids in e.g. coverswitch. Ah and we can use the effect to block things like present windows and desktop grid. Alt+Tab is not that easy to block but it would be possible as well. We just have to try hard enough ;-) Attached you find the current patch for dashboard and kwin. The kwin code is also available in my git branch (http://github.com/mgraesslin/kwin/tree/dashboard). The dashboard code is really just proof-of-concept ;-) Please give it a try and provide some feedback. Regards Martin
commit b9b0294b9840c8f98a50b5d899a3d6b0c8a50cfc Author: Martin Gräßlin <ubu...@martin-graesslin.com> Date: Tue Feb 10 19:26:45 2009 +0100 Initial import of dashboard effect diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 5782681..246d666 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -50,6 +50,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 ) diff --git a/effects/dashboard/CMakeLists.txt b/effects/dashboard/CMakeLists.txt new file mode 100644 index 0000000..c26be81 --- /dev/null +++ b/effects/dashboard/CMakeLists.txt @@ -0,0 +1,13 @@ +####################################### +# Effect + +# Source files +set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} + dashboard/dashboard.cpp + ) + +# .desktop files +install( FILES + dashboard/dashboard.desktop + DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) + diff --git a/effects/dashboard/dashboard.cpp b/effects/dashboard/dashboard.cpp new file mode 100644 index 0000000..a3d0e9f --- /dev/null +++ b/effects/dashboard/dashboard.cpp @@ -0,0 +1,154 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2009 Martin Gräßlin <k...@martin-graesslin.com> + +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" + +#include <kdebug.h> + + +namespace KWin +{ + +KWIN_EFFECT( dashboard, DashboardEffect ) + +DashboardEffect::DashboardEffect() + : activated( false ) + , activateAnimation( false ) + , deactivateAnimation( false ) + { + atom = XInternAtom( display(), "_KDE_PLASMA_DASHBOARD", False ); + effects->registerPropertyType( atom, true ); + // announce support + unsigned char dummy = 0; + XChangeProperty( display(), rootWindow(), atom, atom, 32, PropModeReplace, &dummy, 1 ); + reconfigure( ReconfigureAll ); + } + +DashboardEffect::~DashboardEffect() + { + XDeleteProperty( display(), rootWindow(), atom ); + effects->registerPropertyType( atom, false ); + } + +void DashboardEffect::reconfigure( ReconfigureFlags ) + { + timeline.setDuration( animationTime( 250 ) ); + } + +void DashboardEffect::prePaintScreen( ScreenPrePaintData& data, int time ) + { + if( activated ) + { + if( activateAnimation ) + timeline.addTime( time ); + if( deactivateAnimation ) + timeline.removeTime( time ); + } + effects->prePaintScreen(data, time); + } + +void DashboardEffect::postPaintScreen() + { + if( activated ) + { + if( activateAnimation ) + { + if( timeline.value() == 1.0 ) + activateAnimation = false; + effects->addRepaintFull(); + } + if( deactivateAnimation ) + { + if( timeline.value() == 0.0 ) + { + deactivateAnimation = false; + activated = false; + } + effects->addRepaintFull(); + } + } + effects->postPaintScreen(); + } + + +void DashboardEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) + { + if( activated && !dashboardWindows.contains( w ) && + ( currentDashboard && ( w->screen() == currentDashboard->screen() ) ) ) + { + // adjust brightness and saturation + data.brightness *= (1.0 - 0.7 * timeline.value() ); + data.saturation *= (1.0 - 0.7 * timeline.value() ); + } + effects->paintWindow( w, mask, region, data ); + } + +void DashboardEffect::windowAdded( EffectWindow* w ) + { + propertyNotify( w, atom ); // read initial value + } + +void DashboardEffect::propertyNotify( EffectWindow* w, long a ) + { + if( a != atom ) + return; + QByteArray byteData = w->readProperty( atom, atom, 32 ); + if( byteData.length() < 1 ) + { + dashboardWindows.remove( w ); + if( dashboardWindows.isEmpty() ) + { + activateAnimation = false; + deactivateAnimation = true; + effects->addRepaintFull(); + } + return; + } + long* data = reinterpret_cast<long*>( byteData.data() ); + + if( !data[0] ) + { + dashboardWindows.remove( w ); + if( dashboardWindows.isEmpty() ) + { + activateAnimation = false; + deactivateAnimation = true; + effects->addRepaintFull(); + } + return; + } + else + { + dashboardWindows.insert( w ); + currentDashboard = w; + activated = true; + activateAnimation = true; + deactivateAnimation = false; + timeline.setProgress( 0.0 ); + effects->addRepaintFull(); + } + } + +void DashboardEffect::windowDeleted( EffectWindow* w ) + { + if( w == currentDashboard ) + currentDashboard = NULL; + } + +} // namespace diff --git a/effects/dashboard/dashboard.desktop b/effects/dashboard/dashboard.desktop new file mode 100644 index 0000000..505cf80 --- /dev/null +++ b/effects/dashboard/dashboard.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Name=Plasma Dashboard +Icon=preferences-system-windows-effect-dashboard +Comment=Animates the Plasma dashboard + +Type=Service +X-KDE-ServiceTypes=KWin/Effect +X-KDE-PluginInfo-Author=Martin Gräßlin +x-kde-plugininfo-email=...@martin-graesslin.com +X-KDE-PluginInfo-Name=kwin4_effect_dashboard +X-KDE-PluginInfo-Version=4.3.0 +X-KDE-PluginInfo-Category=Appearance +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +X-KDE-Ordering=70 +X-KDE-Library=kwin4_effect_builtins diff --git a/effects/dashboard/dashboard.h b/effects/dashboard/dashboard.h new file mode 100644 index 0000000..9e651a7 --- /dev/null +++ b/effects/dashboard/dashboard.h @@ -0,0 +1,55 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2009 Martin Gräßlin <k...@martin-graesslin.com> + +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 <QSet> + +namespace KWin +{ + +class DashboardEffect + : public Effect + { + public: + DashboardEffect(); + virtual ~DashboardEffect(); + virtual void reconfigure( ReconfigureFlags ); + virtual void prePaintScreen( ScreenPrePaintData& data, int time ); + virtual void postPaintScreen(); + virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); + virtual void windowAdded( EffectWindow* w ); + virtual void propertyNotify( EffectWindow* w, long atom ); + virtual void windowDeleted( EffectWindow* w ); + private: + long atom; + QSet< EffectWindow* > dashboardWindows; + EffectWindow* currentDashboard; + bool activated; + bool activateAnimation; + bool deactivateAnimation; + TimeLine timeline; + }; + +} // namespace + +#endif
commit 27b4377082e0bcb04079030d19db5ccd1b648701 Author: Martin Gräßlin <ubu...@martin-graesslin.com> Date: Tue Feb 10 19:29:03 2009 +0100 Use atom _KDE_PLASMA_DASHBOARD diff --git a/shells/desktop/dashboardview.cpp b/shells/desktop/dashboardview.cpp index 6acd19f..2e60ae0 100644 --- a/shells/desktop/dashboardview.cpp +++ b/shells/desktop/dashboardview.cpp @@ -35,6 +35,13 @@ #include <kephal/screens.h> +#ifdef Q_WS_X11 +#include <QX11Info> + +#include <X11/Xlib.h> +#include <fixx11h.h> +#endif + #include "appletbrowser.h" static const int SUPPRESS_SHOW_TIMEOUT = 500; // Number of millis to prevent reshow of dashboard @@ -79,7 +86,8 @@ void DashboardView::drawBackground(QPainter * painter, const QRectF & rect) if (PlasmaApp::hasComposite()) { setWallpaperEnabled(false); painter->setCompositionMode(QPainter::CompositionMode_Source); - painter->fillRect(rect, QColor(0, 0, 0, 180)); + painter->setOpacity( 0.0 ); + painter->fillRect(rect, Qt::transparent); } else { setWallpaperEnabled(true); Plasma::View::drawBackground(painter, rect); @@ -235,6 +243,14 @@ void DashboardView::toggleVisibility() containment()->enableAction("zoom in", false); show(); + // KWin dashboard effect +#ifdef Q_WS_X11 + Display *dpy = QX11Info::display(); + Atom atom = XInternAtom(dpy, "_KDE_PLASMA_DASHBOARD", False); + long data[] = { 1 }; + XChangeProperty(dpy, winId(), atom, atom, 32, PropModeReplace, + reinterpret_cast<unsigned char *>(data), sizeof(data) / sizeof(data[0])); +#endif raise(); m_suppressShow = true; @@ -292,6 +308,13 @@ void DashboardView::hideView() m_appletBrowser->hide(); } + // KWin dashboard effect +#ifdef Q_WS_X11 + Display *dpy = QX11Info::display(); + Atom atom = XInternAtom(dpy, "_KDE_PLASMA_DASHBOARD", False); + XDeleteProperty(dpy, winId(), atom); +#endif + #ifndef Q_WS_WIN disconnect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(activeWindowChanged(WId))); #endif
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel