Convert ShowFps effect to plugins.
svn path=/branches/work/kwin_composite/; revision=652275
This commit is contained in:
parent
04a3787213
commit
58fdb149a8
11 changed files with 152 additions and 57 deletions
60
effects.cpp
60
effects.cpp
|
@ -13,6 +13,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#include "deleted.h"
|
||||
#include "client.h"
|
||||
#include "group.h"
|
||||
#include "scene_xrender.h"
|
||||
#include "workspace.h"
|
||||
|
||||
#include "kdebug.h"
|
||||
|
@ -134,38 +135,48 @@ int EffectsHandlerImpl::currentDesktop() const
|
|||
}
|
||||
|
||||
int EffectsHandlerImpl::displayWidth() const
|
||||
{
|
||||
{
|
||||
return KWin::displayWidth();
|
||||
}
|
||||
}
|
||||
|
||||
int EffectsHandlerImpl::displayHeight() const
|
||||
{
|
||||
{
|
||||
return KWin::displayWidth();
|
||||
}
|
||||
}
|
||||
|
||||
QPoint EffectsHandlerImpl::cursorPos() const
|
||||
{
|
||||
{
|
||||
return KWin::cursorPos();
|
||||
}
|
||||
}
|
||||
|
||||
EffectWindowList EffectsHandlerImpl::stackingOrder() const
|
||||
{
|
||||
{
|
||||
ClientList list = Workspace::self()->stackingOrder();
|
||||
EffectWindowList ret;
|
||||
foreach( Client* c, list )
|
||||
ret.append( effectWindow( c ));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::addRepaintFull()
|
||||
{
|
||||
{
|
||||
Workspace::self()->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::addRepaint( const QRect& r )
|
||||
{
|
||||
Workspace::self()->addRepaint( r );
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::addRepaint( int x, int y, int w, int h )
|
||||
{
|
||||
Workspace::self()->addRepaint( x, y, w, h );
|
||||
}
|
||||
|
||||
QRect EffectsHandlerImpl::clientArea( clientAreaOption opt, const QPoint& p, int desktop ) const
|
||||
{
|
||||
{
|
||||
return Workspace::self()->clientArea( opt, p, desktop );
|
||||
}
|
||||
}
|
||||
|
||||
Window EffectsHandlerImpl::createInputWindow( Effect* e, int x, int y, int w, int h, const QCursor& cursor )
|
||||
{
|
||||
|
@ -244,24 +255,33 @@ void EffectsHandlerImpl::checkInputWindowStacking()
|
|||
}
|
||||
|
||||
void EffectsHandlerImpl::checkElectricBorder(const QPoint &pos, Time time)
|
||||
{
|
||||
{
|
||||
Workspace::self()->checkElectricBorder( pos, time );
|
||||
}
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::reserveElectricBorder( ElectricBorder border )
|
||||
{
|
||||
{
|
||||
Workspace::self()->reserveElectricBorder( border );
|
||||
}
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::unreserveElectricBorder( ElectricBorder border )
|
||||
{
|
||||
{
|
||||
Workspace::self()->unreserveElectricBorder( border );
|
||||
}
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::reserveElectricBorderSwitching( bool reserve )
|
||||
{
|
||||
{
|
||||
Workspace::self()->reserveElectricBorderSwitching( reserve );
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long EffectsHandlerImpl::xrenderBufferPicture()
|
||||
{
|
||||
#ifdef HAVE_XRENDER
|
||||
if( SceneXrender* s = dynamic_cast< SceneXrender* >( scene ))
|
||||
return s->bufferPicture();
|
||||
#endif
|
||||
return None;
|
||||
}
|
||||
|
||||
//****************************************
|
||||
// EffectWindowImpl
|
||||
|
|
|
@ -43,6 +43,8 @@ class EffectsHandlerImpl : public EffectsHandler
|
|||
virtual QPoint cursorPos() const;
|
||||
virtual EffectWindowList stackingOrder() const;
|
||||
virtual void addRepaintFull();
|
||||
virtual void addRepaint( const QRect& r );
|
||||
virtual void addRepaint( int x, int y, int w, int h );
|
||||
virtual QRect clientArea( clientAreaOption opt, const QPoint& p, int desktop ) const;
|
||||
|
||||
virtual Window createInputWindow( Effect* e, int x, int y, int w, int h, const QCursor& cursor );
|
||||
|
@ -54,6 +56,8 @@ class EffectsHandlerImpl : public EffectsHandler
|
|||
virtual void reserveElectricBorder( ElectricBorder border );
|
||||
virtual void unreserveElectricBorder( ElectricBorder border );
|
||||
virtual void reserveElectricBorderSwitching( bool reserve );
|
||||
|
||||
virtual unsigned long xrenderBufferPicture();
|
||||
};
|
||||
|
||||
class EffectWindowImpl : public EffectWindow
|
||||
|
|
|
@ -3,6 +3,12 @@ macro(KWIN4_ADD_EFFECT name)
|
|||
kde4_automoc(kwin4_effect_${name} ${ARGN})
|
||||
kde4_add_plugin(kwin4_effect_${name} ${ARGN})
|
||||
target_link_libraries(kwin4_effect_${name} kwineffects ${KDE4_KDEUI_LIBS})
|
||||
if(OPENGL_FOUND)
|
||||
target_link_libraries(kwin4_effect_${name} ${OPENGL_gl_LIBRARY})
|
||||
endif(OPENGL_FOUND)
|
||||
if (X11_Xrender_FOUND)
|
||||
target_link_libraries(kwin4_effect_${name} ${X11_Xrender_LIB})
|
||||
endif (X11_Xrender_FOUND)
|
||||
install(TARGETS kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
endmacro(KWIN4_ADD_EFFECT)
|
||||
|
||||
|
@ -11,7 +17,28 @@ include_directories(
|
|||
${CMAKE_SOURCE_DIR}/workspace/kwin/lib
|
||||
)
|
||||
|
||||
KWIN4_ADD_EFFECT(builtins presentwindows.cpp shadow.cpp diminactive.cpp)
|
||||
SET(kwin4_effect_builtins_sources
|
||||
presentwindows.cpp
|
||||
diminactive.cpp
|
||||
)
|
||||
|
||||
install( FILES presentwindows.desktop shadow.desktop diminactive.desktop
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
if(OPENGL_FOUND)
|
||||
SET(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
||||
shadow.cpp
|
||||
showfps.cpp
|
||||
)
|
||||
install( FILES
|
||||
shadow.desktop
|
||||
showfps.desktop
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
endif(OPENGL_FOUND)
|
||||
|
||||
if (X11_Xrender_FOUND)
|
||||
endif (X11_Xrender_FOUND)
|
||||
|
||||
KWIN4_ADD_EFFECT(builtins ${kwin4_effect_builtins_sources})
|
||||
|
||||
install( FILES
|
||||
presentwindows.desktop
|
||||
diminactive.desktop
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
|
|
|
@ -8,21 +8,26 @@ You can Freely distribute this program under the GNU General Public
|
|||
License. See the file "COPYING" for the exact licensing terms.
|
||||
******************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "showfps.h"
|
||||
|
||||
#include <workspace.h>
|
||||
|
||||
#include <options.h>
|
||||
#include <scene_opengl.h>
|
||||
#include <scene_xrender.h>
|
||||
#include <kconfig.h>
|
||||
#include <ksharedconfig.h>
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#ifdef HAVE_XRENDER
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#endif
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( ShowFps, ShowFpsEffect )
|
||||
|
||||
const int FPS_WIDTH = 10;
|
||||
const int MAX_TIME = 100;
|
||||
|
||||
|
@ -38,9 +43,10 @@ ShowFpsEffect::ShowFpsEffect()
|
|||
i < MAX_FPS;
|
||||
++i )
|
||||
frames[ i ] = 0;
|
||||
alpha = options->effectShowFpsAlpha;
|
||||
x = options->effectShowFpsX;
|
||||
y = options->effectShowFpsY;
|
||||
KConfigGroup config( KGlobal::config(), "EffectShowFps" );
|
||||
alpha = config.readEntry( "Alpha", 0.5 );
|
||||
x = config.readEntry( "X", -10000 );
|
||||
y = config.readEntry( "Y", 0 );
|
||||
if( x == -10000 ) // there's no -0 :(
|
||||
x = displayWidth() - NUM_PAINTS - FPS_WIDTH;
|
||||
else if ( x < 0 )
|
||||
|
@ -76,17 +82,19 @@ void ShowFpsEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data
|
|||
if( fps > MAX_TIME )
|
||||
fps = MAX_TIME; // keep it the same height
|
||||
#ifdef HAVE_OPENGL
|
||||
if( dynamic_cast< SceneOpenGL* >( scene ))
|
||||
if( effects->compositingType() == OpenGLCompositing)
|
||||
{
|
||||
paintGL( fps );
|
||||
glFinish(); // make sure all rendering is done
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef HAVE_XRENDER
|
||||
if( effects->compositingType() == XRenderCompositing)
|
||||
{
|
||||
paintX( fps );
|
||||
paintXrender( fps );
|
||||
XSync( display(), False ); // make sure all rendering is done
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShowFpsEffect::paintGL( int fps )
|
||||
|
@ -154,7 +162,7 @@ void ShowFpsEffect::paintGL( int fps )
|
|||
- differenly specified rectangles (X: width/height, O: x2,y2)
|
||||
- XRender uses pre-multiplied alpha
|
||||
*/
|
||||
void ShowFpsEffect::paintX( int fps )
|
||||
void ShowFpsEffect::paintXrender( int fps )
|
||||
{
|
||||
#ifdef HAVE_XRENDER
|
||||
Pixmap pixmap = XCreatePixmap( display(), rootWindow(), NUM_PAINTS + FPS_WIDTH, MAX_TIME, 32 );
|
||||
|
@ -214,7 +222,7 @@ void ShowFpsEffect::paintX( int fps )
|
|||
XRenderFillRectangle( display(), PictOpSrc, p, &col, FPS_WIDTH + NUM_PAINTS - i, MAX_TIME - value, 1, value );
|
||||
}
|
||||
XRenderComposite( display(), alpha != 1.0 ? PictOpOver : PictOpSrc, p, None,
|
||||
static_cast< SceneXrender* >( scene )->bufferPicture(), 0, 0, 0, 0, x, y, FPS_WIDTH + NUM_PAINTS, MAX_TIME );
|
||||
effects->xrenderBufferPicture(), 0, 0, 0, 0, x, y, FPS_WIDTH + NUM_PAINTS, MAX_TIME );
|
||||
XRenderFreePicture( display(), p );
|
||||
#endif
|
||||
}
|
||||
|
@ -225,7 +233,7 @@ void ShowFpsEffect::postPaintScreen()
|
|||
paints[ paints_pos ] = t.elapsed();
|
||||
if( ++paints_pos == NUM_PAINTS )
|
||||
paints_pos = 0;
|
||||
workspace()->addRepaint( x, y, FPS_WIDTH + NUM_PAINTS, MAX_TIME );
|
||||
effects->addRepaint( x, y, FPS_WIDTH + NUM_PAINTS, MAX_TIME );
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
4
effects/showfps.desktop
Normal file
4
effects/showfps.desktop
Normal file
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=ShowFps
|
||||
X-KDE-Library=kwin4_effect_builtins
|
|
@ -11,7 +11,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_SHOWFPS_H
|
||||
#define KWIN_SHOWFPS_H
|
||||
|
||||
#include <effects.h>
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <qdatetime.h>
|
||||
|
||||
|
@ -28,7 +28,7 @@ class ShowFpsEffect
|
|||
virtual void postPaintScreen();
|
||||
private:
|
||||
void paintGL( int fps );
|
||||
void paintX( int fps );
|
||||
void paintXrender( int fps );
|
||||
QTime t;
|
||||
enum { NUM_PAINTS = 100 }; // remember time needed to paint this many paints
|
||||
int paints[ NUM_PAINTS ]; // time needed to paint
|
||||
|
|
|
@ -185,6 +185,8 @@ class KWIN_EXPORT EffectsHandler
|
|||
|
||||
// Repaints the entire workspace
|
||||
virtual void addRepaintFull() = 0;
|
||||
virtual void addRepaint( const QRect& r ) = 0;
|
||||
virtual void addRepaint( int x, int y, int w, int h ) = 0;
|
||||
|
||||
// internal (used by kwin core or compositing code)
|
||||
virtual void startPaint();
|
||||
|
@ -207,6 +209,7 @@ class KWIN_EXPORT EffectsHandler
|
|||
virtual bool borderActivated( ElectricBorder border );
|
||||
|
||||
CompositingType compositingType() const { return compositing_type; }
|
||||
virtual unsigned long xrenderBufferPicture() = 0;
|
||||
|
||||
//void registerEffect( const QString& name, EffectFactory* factory );
|
||||
void loadEffect( const QString& name );
|
||||
|
|
|
@ -98,24 +98,36 @@ class KWIN_EXPORT ScreenPaintData
|
|||
};
|
||||
|
||||
inline
|
||||
Display* display()
|
||||
KWIN_EXPORT Display* display()
|
||||
{
|
||||
return QX11Info::display();
|
||||
}
|
||||
|
||||
inline
|
||||
int displayWidth()
|
||||
KWIN_EXPORT Window rootWindow()
|
||||
{
|
||||
return QX11Info::appRootWindow();
|
||||
}
|
||||
|
||||
inline
|
||||
KWIN_EXPORT Window xTime()
|
||||
{
|
||||
return QX11Info::appTime();
|
||||
}
|
||||
|
||||
inline
|
||||
KWIN_EXPORT int displayWidth()
|
||||
{
|
||||
return XDisplayWidth( display(), DefaultScreen( display()));
|
||||
}
|
||||
|
||||
inline
|
||||
int displayHeight()
|
||||
KWIN_EXPORT int displayHeight()
|
||||
{
|
||||
return XDisplayHeight( display(), DefaultScreen( display()));
|
||||
}
|
||||
|
||||
QPoint KWIN_EXPORT cursorPos();
|
||||
KWIN_EXPORT QPoint cursorPos();
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
19
options.cpp
19
options.cpp
|
@ -174,8 +174,8 @@ unsigned long Options::updateSettings()
|
|||
CmdAllWheel = mouseWheelCommand(config.readEntry("CommandAllWheel","Nothing"));
|
||||
|
||||
//translucency settings - TODO
|
||||
useTranslucency = _config->group("Notification Messages").readEntry("UseTranslucency", false);
|
||||
config.changeGroup("Translucency");
|
||||
useTranslucency = config.readEntry("UseTranslucency", true);
|
||||
translucentActiveWindows = config.readEntry("TranslucentActiveWindows", false);
|
||||
activeWindowOpacity = uint((config.readEntry("ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
|
||||
translucentInactiveWindows = config.readEntry("TranslucentInactiveWindows", false);
|
||||
|
@ -194,6 +194,23 @@ unsigned long Options::updateSettings()
|
|||
removeShadowsOnResize = config.readEntry("RemoveShadowsOnResize", true);
|
||||
onlyDecoTranslucent = config.readEntry("OnlyDecoTranslucent", false);
|
||||
|
||||
refreshRate = config.readEntry( "RefreshRate", 0 );
|
||||
smoothScale = qBound( -1, config.readEntry( "SmoothScale", -1 ), 2 );
|
||||
|
||||
QString glmode = config.readEntry("GLMode", "TFP" ).upper();
|
||||
if( glmode == "TFP" )
|
||||
glMode = GLTFP;
|
||||
else if( glmode == "SHM" )
|
||||
glMode = GLSHM;
|
||||
else
|
||||
glMode = GLFallback;
|
||||
glAlwaysRebind = config.readEntry("GLAlwaysRebind", false );
|
||||
glDirect = config.readEntry("GLDirect", true );
|
||||
glVSync = config.readEntry("GLVSync", true );
|
||||
|
||||
config.changeGroup( "Effects" );
|
||||
defaultEffects = config.readEntry( "Load", QStringList() << "ShowFps" << "Fade" );
|
||||
|
||||
// Read button tooltip animation effect from kdeglobals
|
||||
// Since we want to allow users to enable window decoration tooltips
|
||||
// and not kstyle tooltips and vise-versa, we don't read the
|
||||
|
|
13
options.h
13
options.h
|
@ -299,6 +299,19 @@ class Options : public KDecorationOptions
|
|||
uint inactiveWindowShadowSize;
|
||||
uint dockShadowSize;
|
||||
bool onlyDecoTranslucent;
|
||||
|
||||
uint refreshRate;
|
||||
int smoothScale; // 0 = no, 1 = yes when transformed,
|
||||
// 2 = try trilinear when transformed; else 1,
|
||||
// -1 = auto
|
||||
|
||||
enum GLMode { GLTFP, GLSHM, GLFallback };
|
||||
GLMode glMode;
|
||||
bool glAlwaysRebind;
|
||||
bool glDirect;
|
||||
bool glVSync;
|
||||
|
||||
QStringList defaultEffects;
|
||||
|
||||
private:
|
||||
WindowOperation OpTitlebarDblClick;
|
||||
|
|
13
utils.h
13
utils.h
|
@ -239,19 +239,6 @@ void grabXServer();
|
|||
void ungrabXServer();
|
||||
bool grabbedXServer();
|
||||
|
||||
inline
|
||||
Window rootWindow()
|
||||
{
|
||||
return QX11Info::appRootWindow();
|
||||
}
|
||||
|
||||
inline
|
||||
Window xTime()
|
||||
{
|
||||
return QX11Info::appTime();
|
||||
}
|
||||
|
||||
|
||||
class Scene;
|
||||
extern Scene* scene;
|
||||
inline bool compositing() { return scene != NULL; }
|
||||
|
|
Loading…
Reference in a new issue