kwin/effects/presentwindows.h
Luboš Luňák 5faa397849 Vertex redesign - redo the way windows are split into smaller parts
for use in effects (and not only). Now a list of window quads (=window areas)
is created at the beginning of the paint pass, prepaint calls can modify
the split itself (i.e. divide it into more parts). The actual paint calls
can then modify these quads (i.e. transform their geometry). This will allow
better control of how the split is done and also allow painting e.g. only
the decoration differently. Still work in progress, but it works.
Also pass data to prepaint functions in a struct, as there is
already quite a number of them.


svn path=/trunk/KDE/kdebase/workspace/; revision=684893
2007-07-07 14:01:32 +00:00

132 lines
4.1 KiB
C++

/*****************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
You can Freely distribute this program under the GNU General Public
License. See the file "COPYING" for the exact licensing terms.
******************************************************************/
#ifndef KWIN_PRESENTWINDOWS_H
#define KWIN_PRESENTWINDOWS_H
// Include with base class for effects.
#include <kwineffects.h>
#include <kwinglutils.h>
#include <QPixmap>
#ifdef HAVE_XRENDER
#include <X11/extensions/Xrender.h>
#endif
namespace KWin
{
/**
* Expose-like effect which shows all windows on current desktop side-by-side,
* letting the user select active window.
**/
class PresentWindowsEffect
: public QObject, public Effect
{
Q_OBJECT
public:
PresentWindowsEffect();
virtual ~PresentWindowsEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
virtual void postPaintScreen();
virtual void windowClosed( EffectWindow* c );
virtual void windowInputMouseEvent( Window w, QEvent* e );
virtual bool borderActivated( ElectricBorder border );
virtual void grabbedKeyboardEvent( QKeyEvent* e );
public slots:
void setActive(bool active);
void toggleActive() { mShowWindowsFromAllDesktops = false; setActive(!mActivated); }
void toggleActiveAllDesktops() { mShowWindowsFromAllDesktops = true; setActive(!mActivated); }
protected:
// Updates window tranformations, i.e. destination pos and scale of the window
void rearrangeWindows();
void calculateWindowTransformationsDumb(EffectWindowList windowlist);
void calculateWindowTransformationsKompose(EffectWindowList windowlist);
void calculateWindowTransformationsClosest(EffectWindowList windowlist);
bool canRearrangeClosest(EffectWindowList windowlist);
// Helper methods for layout calculation
float windowAspectRatio(EffectWindow* c);
int windowWidthForHeight(EffectWindow* c, int h);
int windowHeightForWidth(EffectWindow* c, int w);
void assignSlots( const QRect& area, int columns, int rows );
void getBestAssignments();
void updateFilterTexture();
void discardFilterTexture();
void paintWindowIcon( EffectWindow* w, WindowPaintData& data );
// Called once the effect is activated (and wasn't activated before)
void effectActivated();
// Called once the effect has terminated
void effectTerminated();
private:
bool mShowWindowsFromAllDesktops;
// Whether the effect is currently activated by the user
bool mActivated;
// 0 = not active, 1 = fully active
float mActiveness;
// 0 = start of rearranging (old_area), 1 = done
float mRearranging;
Window mInput;
bool hasKeyboardGrab;
EffectWindowList mWindowsToPresent;
struct WindowData
{
QRect area;
QRect old_area; // when rearranging, otherwise unset
float scale;
float old_scale; // when rearranging, otherwise unset
float hover;
int slot;
int slot_distance;
QPixmap icon;
#ifdef HAVE_OPENGL
GLTexture iconTexture;
#endif
#ifdef HAVE_XRENDER
Picture iconPicture;
#endif
};
typedef QHash<EffectWindow*, WindowData> DataHash;
DataHash mWindowData;
EffectWindow* mHoverWindow;
QString windowFilter;
#ifdef HAVE_OPENGL
GLTexture* filterTexture;
QRect filterTextureRect;
#endif
ElectricBorder borderActivate;
ElectricBorder borderActivateAll;
#ifdef HAVE_XRENDER
XRenderPictFormat* alphaFormat;
#endif
};
} // namespace
#endif