From 915d28d797d3813110fbbb7e042c393e5d36e3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 28 Apr 2011 13:47:53 +0200 Subject: [PATCH] Outline effect to replace rendering of the outline It just uses the selection of the EffectFrame for the outline. FEATURE: 247316 FIXED-IN: 4.7.0 --- effects/CMakeLists.txt | 1 + effects/outline/CMakeLists.txt | 12 +++++ effects/outline/outline.cpp | 78 +++++++++++++++++++++++++++++++++ effects/outline/outline.desktop | 17 +++++++ effects/outline/outline.h | 51 +++++++++++++++++++++ 5 files changed, 159 insertions(+) create mode 100644 effects/outline/CMakeLists.txt create mode 100644 effects/outline/outline.cpp create mode 100644 effects/outline/outline.desktop create mode 100644 effects/outline/outline.h diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index c7a5d72f34..3e2be9a5d2 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -69,6 +69,7 @@ include( login/CMakeLists.txt ) include( magiclamp/CMakeLists.txt ) include( translucency/CMakeLists.txt ) include( minimizeanimation/CMakeLists.txt ) +include( outline/CMakeLists.txt ) include( presentwindows/CMakeLists.txt ) include( resize/CMakeLists.txt ) include( scalein/CMakeLists.txt ) diff --git a/effects/outline/CMakeLists.txt b/effects/outline/CMakeLists.txt new file mode 100644 index 0000000000..1739f9bf52 --- /dev/null +++ b/effects/outline/CMakeLists.txt @@ -0,0 +1,12 @@ +####################################### +# Effect + +# Source files +set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} + outline/outline.cpp + ) + +# .desktop files +install( FILES + outline/outline.desktop + DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) diff --git a/effects/outline/outline.cpp b/effects/outline/outline.cpp new file mode 100644 index 0000000000..f69de675d4 --- /dev/null +++ b/effects/outline/outline.cpp @@ -0,0 +1,78 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2011 Martin Gräßlin + +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 . +*********************************************************************/ + +#include "outline.h" + +namespace KWin +{ + +KWIN_EFFECT(outline, OutlineEffect) + +OutlineEffect::OutlineEffect() + : Effect() + , m_active(false) +{ + m_outline = effects->effectFrame(EffectFrameNone); + connect(effects, SIGNAL(showOutline(const QRect&)), SLOT(slotShowOutline(const QRect&))); + connect(effects, SIGNAL(hideOutline()), SLOT(slotHideOutline())); +} + +OutlineEffect::~OutlineEffect() +{ + delete m_outline; +} + +void OutlineEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) +{ + effects->paintScreen(mask, region, data); + if (m_active) { + m_outline->render(); + } +} + +bool OutlineEffect::provides(Feature feature) +{ + if (feature == Outline) { + return true; + } else { + return false; + } +} + + +void OutlineEffect::slotHideOutline() +{ + m_active = false; + effects->addRepaint(m_geometry); +} + +void OutlineEffect::slotShowOutline(const QRect& geometry) +{ + if (m_active) { + effects->addRepaint(m_geometry); + } + m_active = true; + m_geometry = geometry; + m_outline->setGeometry(geometry); + m_outline->setSelection(geometry); + effects->addRepaint(geometry); +} + +} // namespace diff --git a/effects/outline/outline.desktop b/effects/outline/outline.desktop new file mode 100644 index 0000000000..a2773c99b5 --- /dev/null +++ b/effects/outline/outline.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Name=Outline +Icon=preferences-system-windows-effect-outline +Comment=Helper effect to render an outline + +Type=Service +X-KDE-ServiceTypes=KWin/Effect +X-KDE-PluginInfo-Author=Martin Gräßlin +X-KDE-PluginInfo-Email=mgraesslin@kde.org +X-KDE-PluginInfo-Name=kwin4_effect_outline +X-KDE-PluginInfo-Version=0.1.0 +X-KDE-PluginInfo-Category=Window Management +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +X-KDE-Library=kwin4_effect_builtins +X-KDE-Ordering=90 diff --git a/effects/outline/outline.h b/effects/outline/outline.h new file mode 100644 index 0000000000..9c144b4c4f --- /dev/null +++ b/effects/outline/outline.h @@ -0,0 +1,51 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2011 Martin Gräßlin + +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 . +*********************************************************************/ + +#ifndef KWIN_OUTLINE_H +#define KWIN_OUTLINE_H + +#include + +namespace KWin +{ + +class OutlineEffect : public Effect +{ + Q_OBJECT +public: + OutlineEffect(); + virtual ~OutlineEffect(); + + virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); + virtual bool provides(Feature feature); + +public Q_SLOTS: + void slotShowOutline(const QRect &geometry); + void slotHideOutline(); + +private: + QRect m_geometry; + bool m_active; + EffectFrame *m_outline; +}; + +} // namespace + +#endif // KWIN_OUTLINE_H