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) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
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_PRESENTWINDOWS_H
|
|
|
|
#define KWIN_PRESENTWINDOWS_H
|
|
|
|
|
|
|
|
// Include with base class for effects.
|
|
|
|
#include <kwineffects.h>
|
|
|
|
#include <kwinglutils.h>
|
2008-05-07 14:43:13 +00:00
|
|
|
#include <kwinxrenderutils.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-07-06 12:23:34 +00:00
|
|
|
#include <QPixmap>
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
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();
|
|
|
|
|
2007-07-07 14:01:32 +00:00
|
|
|
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
|
|
|
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
2007-04-29 17:35:43 +00:00
|
|
|
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 );
|
|
|
|
|
2008-08-13 12:25:19 +00:00
|
|
|
virtual void tabBoxAdded( int mode );
|
|
|
|
virtual void tabBoxClosed();
|
|
|
|
virtual void tabBoxUpdated();
|
|
|
|
|
2008-08-25 09:17:15 +00:00
|
|
|
enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
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();
|
2008-06-10 15:49:49 +00:00
|
|
|
void prepareToRearrange();
|
2008-08-25 09:17:15 +00:00
|
|
|
void calculateWindowTransformationsKompose(EffectWindowList windowlist, int screen);
|
2008-06-10 15:49:49 +00:00
|
|
|
void calculateWindowTransformationsClosest(EffectWindowList windowlist, int screen);
|
2008-08-25 09:17:15 +00:00
|
|
|
void calculateWindowTransformationsNatural(EffectWindowList windowlist, int screen);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Helper methods for layout calculation
|
2007-09-03 15:00:43 +00:00
|
|
|
double windowAspectRatio(EffectWindow* c);
|
2007-04-29 17:35:43 +00:00
|
|
|
int windowWidthForHeight(EffectWindow* c, int h);
|
|
|
|
int windowHeightForWidth(EffectWindow* c, int w);
|
|
|
|
|
2008-06-10 15:49:49 +00:00
|
|
|
void assignSlots( EffectWindowList windowlist, const QRect& area, int columns, int rows );
|
|
|
|
void getBestAssignments( EffectWindowList windowlist );
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-08-25 09:17:15 +00:00
|
|
|
bool isOverlappingAny( EffectWindow* w, const EffectWindowList& windowlist, const QRegion& border );
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void updateFilterTexture();
|
|
|
|
void discardFilterTexture();
|
2007-07-05 11:41:02 +00:00
|
|
|
|
|
|
|
void paintWindowIcon( EffectWindow* w, WindowPaintData& data );
|
|
|
|
|
2007-11-21 11:57:09 +00:00
|
|
|
void setHighlightedWindow( EffectWindow* w );
|
|
|
|
EffectWindow* relativeWindow( EffectWindow* w, int xdiff, int ydiff, bool wrap ) const;
|
2008-08-25 09:17:15 +00:00
|
|
|
EffectWindow* relativeWindowGrid( EffectWindow* w, int xdiff, int ydiff, bool wrap ) const;
|
2007-11-21 11:57:09 +00:00
|
|
|
EffectWindow* findFirstWindow() const;
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// 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
|
2008-08-22 16:25:40 +00:00
|
|
|
TimeLine mActiveness;
|
2007-04-29 17:35:43 +00:00
|
|
|
// 0 = start of rearranging (old_area), 1 = done
|
2008-08-22 16:25:40 +00:00
|
|
|
TimeLine mRearranging;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Window mInput;
|
|
|
|
bool hasKeyboardGrab;
|
|
|
|
|
|
|
|
EffectWindowList mWindowsToPresent;
|
|
|
|
struct WindowData
|
|
|
|
{
|
|
|
|
QRect area;
|
|
|
|
QRect old_area; // when rearranging, otherwise unset
|
2007-09-03 15:00:43 +00:00
|
|
|
double scale;
|
|
|
|
double old_scale; // when rearranging, otherwise unset
|
2007-11-21 11:57:09 +00:00
|
|
|
double highlight;
|
2007-04-29 17:35:43 +00:00
|
|
|
int slot;
|
2007-11-21 11:57:09 +00:00
|
|
|
int x, y; // position of the slot in the grid
|
2007-04-29 17:35:43 +00:00
|
|
|
int slot_distance;
|
2007-07-05 11:41:02 +00:00
|
|
|
QPixmap icon;
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2008-05-07 13:05:46 +00:00
|
|
|
KSharedPtr< GLTexture > iconTexture;
|
2007-07-05 11:41:02 +00:00
|
|
|
#endif
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2008-05-07 14:43:13 +00:00
|
|
|
XRenderPicture iconPicture;
|
2007-07-05 11:41:02 +00:00
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
typedef QHash<EffectWindow*, WindowData> DataHash;
|
|
|
|
DataHash mWindowData;
|
2007-11-21 11:57:09 +00:00
|
|
|
EffectWindow* mHighlightedWindow;
|
2008-06-10 15:49:49 +00:00
|
|
|
// Grid and window remembering
|
|
|
|
struct GridSize
|
|
|
|
{
|
|
|
|
int columns;
|
|
|
|
int rows;
|
|
|
|
};
|
|
|
|
QVector<GridSize> screenGridSizes;
|
|
|
|
QVector<int> numOfWindows;
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QString windowFilter;
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2007-04-29 17:35:43 +00:00
|
|
|
GLTexture* filterTexture;
|
|
|
|
QRect filterTextureRect;
|
2007-08-24 21:27:01 +00:00
|
|
|
QRect filterFrameRect;
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
ElectricBorder borderActivate;
|
|
|
|
ElectricBorder borderActivateAll;
|
2008-08-25 09:17:15 +00:00
|
|
|
int layoutMode;
|
2008-03-28 17:26:04 +00:00
|
|
|
bool drawWindowCaptions;
|
2008-08-25 09:17:15 +00:00
|
|
|
bool drawWindowIcons;
|
2008-08-13 12:25:19 +00:00
|
|
|
bool mTabBoxMode;
|
|
|
|
bool tabBox;
|
2008-08-25 09:17:15 +00:00
|
|
|
int accuracy;
|
|
|
|
bool fillGaps;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|