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
This commit is contained in:
Martin Gräßlin 2011-04-28 13:47:53 +02:00
parent 98cc15cfac
commit 915d28d797
5 changed files with 159 additions and 0 deletions

View file

@ -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 )

View file

@ -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 )

View file

@ -0,0 +1,78 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.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 "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

View file

@ -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

51
effects/outline/outline.h Normal file
View file

@ -0,0 +1,51 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.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_OUTLINE_H
#define KWIN_OUTLINE_H
#include <kwineffects.h>
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