2007-01-12 14:14:53 +00:00
|
|
|
/*****************************************************************
|
|
|
|
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.
|
2007-04-10 13:02:08 +00:00
|
|
|
#include <kwineffects.h>
|
2007-01-12 14:14:53 +00:00
|
|
|
|
|
|
|
|
2007-04-05 12:07:35 +00:00
|
|
|
namespace KWin
|
2007-01-12 14:14:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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:
|
2007-02-04 22:19:17 +00:00
|
|
|
PresentWindowsEffect();
|
2007-04-04 19:08:03 +00:00
|
|
|
virtual ~PresentWindowsEffect();
|
2007-01-12 14:14:53 +00:00
|
|
|
|
|
|
|
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
2007-03-25 10:48:07 +00:00
|
|
|
virtual void prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time );
|
2007-01-22 22:57:22 +00:00
|
|
|
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
2007-01-12 14:14:53 +00:00
|
|
|
virtual void postPaintScreen();
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
virtual void windowClosed( EffectWindow* c );
|
2007-01-12 14:14:53 +00:00
|
|
|
virtual void windowInputMouseEvent( Window w, QEvent* e );
|
2007-04-04 19:08:03 +00:00
|
|
|
virtual bool borderActivated( ElectricBorder border );
|
2007-01-12 14:14:53 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setActive(bool active);
|
2007-03-21 16:24:28 +00:00
|
|
|
void toggleActive() { mShowWindowsFromAllDesktops = false; setActive(!mActivated); }
|
|
|
|
void toggleActiveAllDesktops() { mShowWindowsFromAllDesktops = true; setActive(!mActivated); }
|
2007-01-12 14:14:53 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Updates window tranformations, i.e. destination pos and scale of the window
|
|
|
|
void rearrangeWindows();
|
2007-04-10 13:02:08 +00:00
|
|
|
void calculateWindowTransformationsDumb(EffectWindowList windowlist);
|
|
|
|
void calculateWindowTransformationsKompose(EffectWindowList windowlist);
|
2007-04-15 10:53:01 +00:00
|
|
|
void calculateWindowTransformationsClosest(EffectWindowList windowlist);
|
2007-04-15 13:25:44 +00:00
|
|
|
bool canRearrangeClosest(EffectWindowList windowlist);
|
2007-01-12 14:14:53 +00:00
|
|
|
|
|
|
|
// Helper methods for layout calculation
|
2007-04-10 13:02:08 +00:00
|
|
|
float windowAspectRatio(EffectWindow* c);
|
|
|
|
int windowWidthForHeight(EffectWindow* c, int h);
|
|
|
|
int windowHeightForWidth(EffectWindow* c, int w);
|
2007-01-12 14:14:53 +00:00
|
|
|
|
2007-04-15 10:53:01 +00:00
|
|
|
void assignSlots( const QRect& area, int columns, int rows );
|
|
|
|
void getBestAssignments();
|
|
|
|
|
2007-01-12 14:14:53 +00:00
|
|
|
// Called once the effect is activated (and wasn't activated before)
|
|
|
|
void effectActivated();
|
|
|
|
// Called once the effect has terminated
|
|
|
|
void effectTerminated();
|
|
|
|
|
|
|
|
private:
|
2007-03-21 16:24:28 +00:00
|
|
|
bool mShowWindowsFromAllDesktops;
|
|
|
|
|
2007-01-12 14:14:53 +00:00
|
|
|
// Whether the effect is currently activated by the user
|
|
|
|
bool mActivated;
|
|
|
|
// 0 = not active, 1 = fully active
|
|
|
|
float mActiveness;
|
2007-04-15 13:25:44 +00:00
|
|
|
// 0 = start of rearranging (old_area), 1 = done
|
|
|
|
float mRearranging;
|
2007-01-12 14:14:53 +00:00
|
|
|
|
|
|
|
Window mInput;
|
|
|
|
|
2007-04-15 12:38:09 +00:00
|
|
|
EffectWindowList mWindowsToPresent;
|
2007-01-12 14:14:53 +00:00
|
|
|
struct WindowData
|
|
|
|
{
|
|
|
|
QRect area;
|
2007-04-15 13:25:44 +00:00
|
|
|
QRect old_area; // when rearranging, otherwise unset
|
2007-01-12 14:14:53 +00:00
|
|
|
float scale;
|
2007-04-15 13:25:44 +00:00
|
|
|
float old_scale; // when rearranging, otherwise unset
|
2007-03-30 15:35:19 +00:00
|
|
|
float hover;
|
2007-04-15 10:53:01 +00:00
|
|
|
int slot;
|
|
|
|
int slot_distance;
|
2007-01-12 14:14:53 +00:00
|
|
|
};
|
2007-04-10 13:02:08 +00:00
|
|
|
QHash<EffectWindow*, WindowData> mWindowData;
|
2007-04-14 15:33:12 +00:00
|
|
|
EffectWindow* mHoverWindow;
|
2007-04-04 19:08:03 +00:00
|
|
|
|
|
|
|
ElectricBorder borderActivate;
|
|
|
|
ElectricBorder borderActivateAll;
|
2007-01-12 14:14:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|