2006-07-05 12:30:03 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_SCENE_H
|
|
|
|
#define KWIN_SCENE_H
|
|
|
|
|
2006-10-24 19:17:48 +00:00
|
|
|
#include <qdatetime.h>
|
|
|
|
|
2006-10-15 08:58:38 +00:00
|
|
|
#include "toplevel.h"
|
2006-10-16 21:06:34 +00:00
|
|
|
#include "utils.h"
|
2006-07-05 12:30:03 +00:00
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
class Workspace;
|
2007-01-22 22:51:30 +00:00
|
|
|
class Deleted;
|
2006-10-16 10:12:48 +00:00
|
|
|
class WindowPaintData;
|
|
|
|
class ScreenPaintData;
|
2007-01-22 22:57:22 +00:00
|
|
|
class EffectWindow;
|
2006-07-05 12:30:03 +00:00
|
|
|
|
2006-10-29 19:23:45 +00:00
|
|
|
// The base class for compositing backends.
|
2006-07-05 12:30:03 +00:00
|
|
|
class Scene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Scene( Workspace* ws );
|
2006-10-07 21:18:36 +00:00
|
|
|
virtual ~Scene() = 0;
|
2006-10-16 10:12:48 +00:00
|
|
|
class Window;
|
2006-10-29 19:23:45 +00:00
|
|
|
// Repaints the given screen areas, windows provides the stacking order.
|
|
|
|
// The entry point for the main part of the painting pass.
|
2006-09-30 15:40:03 +00:00
|
|
|
virtual void paint( QRegion damage, ToplevelList windows ) = 0;
|
2006-10-29 19:23:45 +00:00
|
|
|
|
|
|
|
// Notification function - KWin core informs about changes.
|
|
|
|
// Used to mainly discard cached data.
|
|
|
|
|
2006-10-01 21:14:53 +00:00
|
|
|
// shape/size of a window changed
|
2006-10-29 19:23:45 +00:00
|
|
|
virtual void windowGeometryShapeChanged( Toplevel* ) = 0;
|
2006-10-01 21:14:53 +00:00
|
|
|
// opacity of a window changed
|
2006-10-29 19:23:45 +00:00
|
|
|
virtual void windowOpacityChanged( Toplevel* ) = 0;
|
2006-10-01 21:14:53 +00:00
|
|
|
// a new window has been created
|
2006-10-29 19:23:45 +00:00
|
|
|
virtual void windowAdded( Toplevel* ) = 0;
|
2007-01-22 22:51:30 +00:00
|
|
|
// a window has been closed
|
|
|
|
virtual void windowClosed( Toplevel*, Deleted* ) = 0;
|
2006-10-01 21:14:53 +00:00
|
|
|
// a window has been destroyed
|
2007-01-22 22:51:30 +00:00
|
|
|
virtual void windowDeleted( Deleted* ) = 0;
|
2006-10-29 19:23:45 +00:00
|
|
|
// Flags controlling how painting is done.
|
2006-10-15 08:58:38 +00:00
|
|
|
enum
|
|
|
|
{
|
2006-10-29 19:23:45 +00:00
|
|
|
// Window (or at least part of it) will be painted opaque.
|
2006-10-16 18:46:07 +00:00
|
|
|
PAINT_WINDOW_OPAQUE = 1 << 0,
|
2006-10-29 19:23:45 +00:00
|
|
|
// Window (or at least part of it) will be painted translucent.
|
2006-10-21 18:07:00 +00:00
|
|
|
PAINT_WINDOW_TRANSLUCENT = 1 << 1,
|
2006-10-29 19:23:45 +00:00
|
|
|
// Window will be painted with transformed geometry.
|
2006-10-21 18:07:00 +00:00
|
|
|
PAINT_WINDOW_TRANSFORMED = 1 << 2,
|
2007-01-08 17:05:58 +00:00
|
|
|
// When set, the window won't be painted (set by default
|
|
|
|
// for hidden windows, can be unset in pre-paint).
|
|
|
|
PAINT_WINDOW_DISABLED = 1 << 3,
|
2006-10-29 19:23:45 +00:00
|
|
|
// Paint only a region of the screen (can be optimized, cannot
|
|
|
|
// be used together with TRANSFORMED flags).
|
2007-01-08 17:05:58 +00:00
|
|
|
PAINT_SCREEN_REGION = 1 << 4,
|
2006-10-29 19:23:45 +00:00
|
|
|
// Whole screen will be painted with transformed geometry.
|
2007-01-08 17:05:58 +00:00
|
|
|
PAINT_SCREEN_TRANSFORMED = 1 << 5,
|
2006-10-16 18:46:07 +00:00
|
|
|
};
|
2006-10-24 19:17:48 +00:00
|
|
|
// there's nothing to paint (adjust time_diff later)
|
|
|
|
void idle();
|
2006-12-03 13:29:14 +00:00
|
|
|
bool waitSyncAvailable() { return has_waitSync; }
|
2006-10-21 18:07:00 +00:00
|
|
|
protected:
|
2006-10-29 19:23:45 +00:00
|
|
|
// shared implementation, starts painting the screen
|
2006-10-24 13:38:31 +00:00
|
|
|
void paintScreen( int* mask, QRegion* region );
|
2006-10-29 19:06:32 +00:00
|
|
|
friend class EffectsHandler;
|
2006-10-29 19:23:45 +00:00
|
|
|
// called after all effects had their paintScreen() called
|
2006-10-29 19:06:32 +00:00
|
|
|
void finalPaintScreen( int mask, QRegion region, ScreenPaintData& data );
|
2006-10-29 19:23:45 +00:00
|
|
|
// shared implementation of painting the screen in the generic
|
|
|
|
// (unoptimized) way
|
2006-10-21 18:07:00 +00:00
|
|
|
virtual void paintGenericScreen( int mask, ScreenPaintData data );
|
2006-10-29 19:23:45 +00:00
|
|
|
// shared implementation of painting the screen in an optimized way
|
2006-10-21 18:07:00 +00:00
|
|
|
virtual void paintSimpleScreen( int mask, QRegion region );
|
2006-10-29 19:23:45 +00:00
|
|
|
// paint the background (not the desktop background - the whole background)
|
2006-10-16 21:06:34 +00:00
|
|
|
virtual void paintBackground( QRegion region ) = 0;
|
2006-10-29 19:23:45 +00:00
|
|
|
// called after all effects had their paintWindow() called
|
2007-01-22 22:57:22 +00:00
|
|
|
void finalPaintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
2006-10-29 19:23:45 +00:00
|
|
|
// shared implementation, starts painting the window
|
2006-10-16 21:06:34 +00:00
|
|
|
virtual void paintWindow( Window* w, int mask, QRegion region );
|
2006-10-29 19:23:45 +00:00
|
|
|
// infinite region, i.e. everything
|
2006-10-15 08:58:38 +00:00
|
|
|
static QRegion infiniteRegion();
|
2006-10-29 19:23:45 +00:00
|
|
|
// compute time since the last repaint
|
2006-10-24 19:17:48 +00:00
|
|
|
void updateTimeDiff();
|
2006-10-29 19:23:45 +00:00
|
|
|
// saved data for 2nd pass of optimized screen painting
|
2006-10-15 08:58:38 +00:00
|
|
|
struct Phase2Data
|
|
|
|
{
|
2006-10-22 10:15:19 +00:00
|
|
|
Phase2Data( Window* w, QRegion r, int m ) : window( w ), region( r ), mask( m ) {}
|
2006-10-16 21:06:34 +00:00
|
|
|
Window* window;
|
2006-10-15 08:58:38 +00:00
|
|
|
QRegion region;
|
2006-10-22 10:15:19 +00:00
|
|
|
int mask;
|
2006-10-15 08:58:38 +00:00
|
|
|
};
|
2006-10-29 19:23:45 +00:00
|
|
|
// windows in their stacking order
|
2006-10-16 21:06:34 +00:00
|
|
|
QVector< Window* > stacking_order;
|
2006-10-29 19:23:45 +00:00
|
|
|
// time since last repaint
|
2006-10-24 19:17:48 +00:00
|
|
|
int time_diff;
|
|
|
|
QTime last_time;
|
2006-07-05 12:30:03 +00:00
|
|
|
Workspace* wspace;
|
2006-12-03 13:29:14 +00:00
|
|
|
bool has_waitSync;
|
2006-07-05 12:30:03 +00:00
|
|
|
};
|
|
|
|
|
2006-10-29 19:23:45 +00:00
|
|
|
// The base class for windows representations in composite backends
|
2006-10-15 08:58:38 +00:00
|
|
|
class Scene::Window
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window( Toplevel* c );
|
2006-10-16 10:12:48 +00:00
|
|
|
virtual ~Window();
|
2006-10-29 19:23:45 +00:00
|
|
|
// this class is often copied by value, use manually instead of dtor
|
|
|
|
virtual void free();
|
|
|
|
// perform the actual painting of the window
|
2006-10-22 10:15:19 +00:00
|
|
|
virtual void performPaint( int mask, QRegion region, WindowPaintData data ) = 0;
|
2007-01-24 11:51:38 +00:00
|
|
|
virtual void prepareForPainting() {}
|
2006-10-15 08:58:38 +00:00
|
|
|
int x() const;
|
|
|
|
int y() const;
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
2006-10-29 19:23:45 +00:00
|
|
|
// access to the internal window class
|
|
|
|
// TODO eventually get rid of this
|
2006-10-29 19:07:10 +00:00
|
|
|
Toplevel* window();
|
2006-10-29 19:23:45 +00:00
|
|
|
// is the window visible at all
|
2006-10-15 08:58:38 +00:00
|
|
|
bool isVisible() const;
|
2006-10-29 19:23:45 +00:00
|
|
|
// is the window fully opaque
|
2006-10-15 08:58:38 +00:00
|
|
|
bool isOpaque() const;
|
2006-10-29 19:23:45 +00:00
|
|
|
// shape of the window
|
2006-10-15 08:58:38 +00:00
|
|
|
QRegion shape() const;
|
|
|
|
void discardShape();
|
2007-01-22 22:51:30 +00:00
|
|
|
void updateToplevel( Toplevel* c );
|
2006-10-15 08:58:38 +00:00
|
|
|
Window() {} // QMap sucks even in Qt4
|
|
|
|
protected:
|
|
|
|
Toplevel* toplevel;
|
|
|
|
private:
|
|
|
|
mutable QRegion shape_region;
|
|
|
|
mutable bool shape_valid;
|
|
|
|
};
|
|
|
|
|
2006-07-05 12:30:03 +00:00
|
|
|
extern Scene* scene;
|
|
|
|
|
2006-10-15 08:58:38 +00:00
|
|
|
inline
|
|
|
|
QRegion Scene::infiniteRegion()
|
2006-10-29 19:23:45 +00:00
|
|
|
{ // INT_MIN / 2 because width/height is used (INT_MIN+INT_MAX==-1)
|
2006-10-15 08:58:38 +00:00
|
|
|
return QRegion( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX );
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2006-10-22 10:15:19 +00:00
|
|
|
|
|
|
|
inline
|
2006-10-29 19:07:10 +00:00
|
|
|
Toplevel* Scene::Window::window()
|
2006-10-22 10:15:19 +00:00
|
|
|
{
|
|
|
|
return toplevel;
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:51:30 +00:00
|
|
|
inline
|
|
|
|
void Scene::Window::updateToplevel( Toplevel* c )
|
|
|
|
{
|
|
|
|
toplevel = c;
|
|
|
|
}
|
|
|
|
|
2006-07-05 12:30:03 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|