2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
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/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef KWIN_SCENE_H
|
|
|
|
#define KWIN_SCENE_H
|
|
|
|
|
2008-02-02 20:54:19 +00:00
|
|
|
#include <QDateTime>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "toplevel.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "kwineffects.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class Workspace;
|
|
|
|
class Deleted;
|
2010-07-18 16:32:37 +00:00
|
|
|
class EffectFrameImpl;
|
2007-04-29 17:35:43 +00:00
|
|
|
class EffectWindowImpl;
|
2010-06-02 20:04:54 +00:00
|
|
|
class LanczosFilter;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// The base class for compositing backends.
|
|
|
|
class Scene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Scene( Workspace* ws );
|
|
|
|
virtual ~Scene() = 0;
|
2010-07-18 16:32:37 +00:00
|
|
|
class EffectFrame;
|
2007-04-29 17:35:43 +00:00
|
|
|
class Window;
|
|
|
|
|
2007-05-30 14:22:09 +00:00
|
|
|
// Returns true if the ctor failed to properly initialize.
|
|
|
|
virtual bool initFailed() const = 0;
|
2007-04-29 17:35:43 +00:00
|
|
|
virtual CompositingType compositingType() const = 0;
|
|
|
|
// Repaints the given screen areas, windows provides the stacking order.
|
|
|
|
// The entry point for the main part of the painting pass.
|
|
|
|
virtual void paint( QRegion damage, ToplevelList windows ) = 0;
|
|
|
|
|
|
|
|
// Notification function - KWin core informs about changes.
|
|
|
|
// Used to mainly discard cached data.
|
|
|
|
|
|
|
|
// shape/size of a window changed
|
|
|
|
virtual void windowGeometryShapeChanged( Toplevel* ) = 0;
|
|
|
|
// opacity of a window changed
|
|
|
|
virtual void windowOpacityChanged( Toplevel* ) = 0;
|
|
|
|
// a new window has been created
|
|
|
|
virtual void windowAdded( Toplevel* ) = 0;
|
|
|
|
// a window has been closed
|
|
|
|
virtual void windowClosed( Toplevel*, Deleted* ) = 0;
|
|
|
|
// a window has been destroyed
|
|
|
|
virtual void windowDeleted( Deleted* ) = 0;
|
|
|
|
// Flags controlling how painting is done.
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
// Window (or at least part of it) will be painted opaque.
|
|
|
|
PAINT_WINDOW_OPAQUE = 1 << 0,
|
|
|
|
// Window (or at least part of it) will be painted translucent.
|
|
|
|
PAINT_WINDOW_TRANSLUCENT = 1 << 1,
|
|
|
|
// Window will be painted with transformed geometry.
|
|
|
|
PAINT_WINDOW_TRANSFORMED = 1 << 2,
|
|
|
|
// Paint only a region of the screen (can be optimized, cannot
|
|
|
|
// be used together with TRANSFORMED flags).
|
|
|
|
PAINT_SCREEN_REGION = 1 << 3,
|
|
|
|
// Whole screen will be painted with transformed geometry.
|
|
|
|
PAINT_SCREEN_TRANSFORMED = 1 << 4,
|
|
|
|
// At least one window will be painted with transformed geometry.
|
|
|
|
PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5,
|
|
|
|
// Clear whole background as the very first step, without optimizing it
|
2009-04-22 17:29:56 +00:00
|
|
|
PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6,
|
|
|
|
// Temporary solution since (_OPAQUE | _TRANSLUCENT) is not working currently.
|
2010-06-02 20:04:54 +00:00
|
|
|
PAINT_DECORATION_ONLY = 1 << 7,
|
|
|
|
// Window will be painted with a lanczos filter.
|
2010-08-03 21:33:27 +00:00
|
|
|
PAINT_WINDOW_LANCZOS = 1 << 8,
|
|
|
|
// same as PAINT_SCREEN_TRANSFORMED without full repainting
|
|
|
|
PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS = 1 << 9
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
// types of filtering available
|
|
|
|
enum ImageFilterType { ImageFilterFast, ImageFilterGood };
|
|
|
|
// there's nothing to paint (adjust time_diff later)
|
|
|
|
void idle();
|
|
|
|
bool waitSyncAvailable() { return has_waitSync; }
|
|
|
|
protected:
|
|
|
|
// shared implementation, starts painting the screen
|
|
|
|
void paintScreen( int* mask, QRegion* region );
|
|
|
|
friend class EffectsHandlerImpl;
|
|
|
|
// called after all effects had their paintScreen() called
|
|
|
|
void finalPaintScreen( int mask, QRegion region, ScreenPaintData& data );
|
|
|
|
// shared implementation of painting the screen in the generic
|
|
|
|
// (unoptimized) way
|
|
|
|
virtual void paintGenericScreen( int mask, ScreenPaintData data );
|
|
|
|
// shared implementation of painting the screen in an optimized way
|
|
|
|
virtual void paintSimpleScreen( int mask, QRegion region );
|
|
|
|
// paint the background (not the desktop background - the whole background)
|
|
|
|
virtual void paintBackground( QRegion region ) = 0;
|
|
|
|
// called after all effects had their paintWindow() called
|
|
|
|
void finalPaintWindow( EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data );
|
|
|
|
// shared implementation, starts painting the window
|
2007-07-07 14:01:32 +00:00
|
|
|
virtual void paintWindow( Window* w, int mask, QRegion region, WindowQuadList quads );
|
2007-04-29 17:35:43 +00:00
|
|
|
// called after all effects had their drawWindow() called
|
|
|
|
void finalDrawWindow( EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data );
|
|
|
|
// compute time since the last repaint
|
|
|
|
void updateTimeDiff();
|
2008-09-18 15:27:13 +00:00
|
|
|
QList< QPoint > selfCheckPoints() const;
|
2009-02-09 14:51:11 +00:00
|
|
|
QRegion selfCheckRegion() const;
|
|
|
|
// dimensions of the test pixmap for selfcheck
|
|
|
|
int selfCheckWidth() const;
|
|
|
|
int selfCheckHeight() const;
|
2007-04-29 17:35:43 +00:00
|
|
|
// saved data for 2nd pass of optimized screen painting
|
|
|
|
struct Phase2Data
|
|
|
|
{
|
2007-12-07 17:03:59 +00:00
|
|
|
Phase2Data( Window* w, QRegion r, QRegion c, int m, const WindowQuadList& q )
|
|
|
|
: window( w ), region( r ), clip( c ), mask( m ), quads( q ) {}
|
|
|
|
Phase2Data() { window = 0; mask = 0; }
|
2007-04-29 17:35:43 +00:00
|
|
|
Window* window;
|
|
|
|
QRegion region;
|
2007-12-07 17:03:59 +00:00
|
|
|
QRegion clip;
|
2007-04-29 17:35:43 +00:00
|
|
|
int mask;
|
2007-07-07 14:01:32 +00:00
|
|
|
WindowQuadList quads;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
// windows in their stacking order
|
|
|
|
QVector< Window* > stacking_order;
|
|
|
|
// The region which actually has been painted by paintScreen() and should be
|
|
|
|
// copied from the buffer to the screen. I.e. the region returned from Scene::paintScreen().
|
|
|
|
// Since prePaintWindow() can extend areas to paint, these changes would have to propagate
|
|
|
|
// up all the way from paintSimpleScreen() up to paintScreen(), so save them here rather
|
|
|
|
// than propagate them up in arguments.
|
|
|
|
QRegion painted_region;
|
|
|
|
// time since last repaint
|
|
|
|
int time_diff;
|
|
|
|
QTime last_time;
|
|
|
|
Workspace* wspace;
|
|
|
|
bool has_waitSync;
|
2009-02-09 14:51:11 +00:00
|
|
|
bool selfCheckDone;
|
2010-06-02 20:04:54 +00:00
|
|
|
LanczosFilter* lanczos_filter;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// The base class for windows representations in composite backends
|
|
|
|
class Scene::Window
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window( Toplevel* c );
|
|
|
|
virtual ~Window();
|
|
|
|
// perform the actual painting of the window
|
|
|
|
virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0;
|
2007-07-05 19:59:55 +00:00
|
|
|
// do any cleanup needed when the window's composite pixmap is discarded
|
|
|
|
virtual void pixmapDiscarded() {}
|
2007-04-29 17:35:43 +00:00
|
|
|
int x() const;
|
|
|
|
int y() const;
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
|
|
|
QRect geometry() const;
|
|
|
|
QPoint pos() const;
|
|
|
|
QSize size() const;
|
|
|
|
QRect rect() const;
|
|
|
|
// access to the internal window class
|
|
|
|
// TODO eventually get rid of this
|
|
|
|
Toplevel* window();
|
|
|
|
// should the window be painted
|
|
|
|
bool isPaintingEnabled() const;
|
|
|
|
void resetPaintingEnabled();
|
|
|
|
// Flags explaining why painting should be disabled
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
// Window will not be painted
|
2009-12-23 01:44:23 +00:00
|
|
|
PAINT_DISABLED = 1 << 0,
|
2007-04-29 17:35:43 +00:00
|
|
|
// Window will not be painted because it is deleted
|
2009-12-23 01:44:23 +00:00
|
|
|
PAINT_DISABLED_BY_DELETE = 1 << 1,
|
2007-04-29 17:35:43 +00:00
|
|
|
// Window will not be painted because of which desktop it's on
|
2009-12-23 01:44:23 +00:00
|
|
|
PAINT_DISABLED_BY_DESKTOP = 1 << 2,
|
2007-04-29 17:35:43 +00:00
|
|
|
// Window will not be painted because it is minimized
|
2009-12-23 01:44:23 +00:00
|
|
|
PAINT_DISABLED_BY_MINIMIZE = 1 << 3,
|
|
|
|
// Window will not be painted because it is not the active window in a client group
|
2010-05-15 20:18:57 +00:00
|
|
|
PAINT_DISABLED_BY_CLIENT_GROUP = 1 << 4,
|
|
|
|
// Window will not be painted because it's not on the current activity
|
|
|
|
PAINT_DISABLED_BY_ACTIVITY = 1 << 5
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
void enablePainting( int reason );
|
|
|
|
void disablePainting( int reason );
|
|
|
|
// is the window visible at all
|
|
|
|
bool isVisible() const;
|
|
|
|
// is the window fully opaque
|
|
|
|
bool isOpaque() const;
|
|
|
|
// shape of the window
|
|
|
|
QRegion shape() const;
|
2009-05-27 16:04:58 +00:00
|
|
|
QRegion clientShape() const;
|
2007-04-29 17:35:43 +00:00
|
|
|
void discardShape();
|
|
|
|
void updateToplevel( Toplevel* c );
|
2007-07-18 15:01:59 +00:00
|
|
|
// creates initial quad list for the window
|
2008-10-18 10:31:59 +00:00
|
|
|
virtual WindowQuadList buildQuads( bool force = false ) const;
|
2008-08-24 13:32:57 +00:00
|
|
|
void suspendUnredirect( bool suspend );
|
2007-04-29 17:35:43 +00:00
|
|
|
protected:
|
2007-07-18 15:01:59 +00:00
|
|
|
WindowQuadList makeQuads( WindowQuadType type, const QRegion& reg ) const;
|
2007-04-29 17:35:43 +00:00
|
|
|
Toplevel* toplevel;
|
|
|
|
ImageFilterType filter;
|
|
|
|
private:
|
|
|
|
int disable_painting;
|
|
|
|
mutable QRegion shape_region;
|
|
|
|
mutable bool shape_valid;
|
2008-03-20 11:17:50 +00:00
|
|
|
mutable WindowQuadList* cached_quad_list;
|
2007-04-29 17:35:43 +00:00
|
|
|
Q_DISABLE_COPY(Window)
|
|
|
|
};
|
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
class Scene::EffectFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EffectFrame( EffectFrameImpl* frame );
|
|
|
|
virtual ~EffectFrame();
|
|
|
|
virtual void render( QRegion region, double opacity, double frameOpacity ) = 0;
|
|
|
|
virtual void free() = 0;
|
2010-07-20 21:11:03 +00:00
|
|
|
virtual void freeIconFrame() = 0;
|
2010-07-18 16:32:37 +00:00
|
|
|
virtual void freeTextFrame() = 0;
|
2010-07-26 20:00:04 +00:00
|
|
|
virtual void freeSelection() = 0;
|
2010-08-07 14:08:34 +00:00
|
|
|
virtual void crossFadeIcon() = 0;
|
|
|
|
virtual void crossFadeText() = 0;
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
EffectFrameImpl* m_effectFrame;
|
|
|
|
};
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
extern Scene* scene;
|
|
|
|
|
2009-02-09 14:51:11 +00:00
|
|
|
inline
|
|
|
|
int Scene::selfCheckWidth() const
|
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int Scene::selfCheckHeight() const
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
inline
|
|
|
|
int Scene::Window::x() const
|
|
|
|
{
|
|
|
|
return toplevel->x();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int Scene::Window::y() const
|
|
|
|
{
|
|
|
|
return toplevel->y();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int Scene::Window::width() const
|
|
|
|
{
|
|
|
|
return toplevel->width();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int Scene::Window::height() const
|
|
|
|
{
|
|
|
|
return toplevel->height();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
QRect Scene::Window::geometry() const
|
|
|
|
{
|
|
|
|
return toplevel->geometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
QSize Scene::Window::size() const
|
|
|
|
{
|
|
|
|
return toplevel->size();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
QPoint Scene::Window::pos() const
|
|
|
|
{
|
|
|
|
return toplevel->pos();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
QRect Scene::Window::rect() const
|
|
|
|
{
|
|
|
|
return toplevel->rect();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
Toplevel* Scene::Window::window()
|
|
|
|
{
|
|
|
|
return toplevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
void Scene::Window::updateToplevel( Toplevel* c )
|
|
|
|
{
|
|
|
|
toplevel = c;
|
|
|
|
}
|
|
|
|
|
2008-08-24 13:32:57 +00:00
|
|
|
inline
|
|
|
|
void Scene::Window::suspendUnredirect( bool suspend )
|
|
|
|
{
|
|
|
|
toplevel->suspendUnredirect( suspend );
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|