Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kwin / effects / presentwindows.h
blob5c77f159965a9d14032eec500f47732e51e9c86d
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #ifndef KWIN_PRESENTWINDOWS_H
22 #define KWIN_PRESENTWINDOWS_H
24 // Include with base class for effects.
25 #include <kwineffects.h>
26 #include <kwinglutils.h>
28 #include <QPixmap>
30 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
31 #include <X11/extensions/Xrender.h>
32 #endif
34 namespace KWin
37 /**
38 * Expose-like effect which shows all windows on current desktop side-by-side,
39 * letting the user select active window.
40 **/
41 class PresentWindowsEffect
42 : public QObject, public Effect
44 Q_OBJECT
45 public:
46 PresentWindowsEffect();
47 virtual ~PresentWindowsEffect();
49 virtual void prePaintScreen( ScreenPrePaintData& data, int time );
50 virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
51 virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
52 virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
53 virtual void postPaintScreen();
55 virtual void windowClosed( EffectWindow* c );
56 virtual void windowInputMouseEvent( Window w, QEvent* e );
57 virtual bool borderActivated( ElectricBorder border );
58 virtual void grabbedKeyboardEvent( QKeyEvent* e );
60 public slots:
61 void setActive(bool active);
62 void toggleActive() { mShowWindowsFromAllDesktops = false; setActive(!mActivated); }
63 void toggleActiveAllDesktops() { mShowWindowsFromAllDesktops = true; setActive(!mActivated); }
65 protected:
66 // Updates window tranformations, i.e. destination pos and scale of the window
67 void rearrangeWindows();
68 void calculateWindowTransformationsDumb(EffectWindowList windowlist);
69 void calculateWindowTransformationsKompose(EffectWindowList windowlist);
70 void calculateWindowTransformationsClosest(EffectWindowList windowlist);
71 bool canRearrangeClosest(EffectWindowList windowlist);
73 // Helper methods for layout calculation
74 double windowAspectRatio(EffectWindow* c);
75 int windowWidthForHeight(EffectWindow* c, int h);
76 int windowHeightForWidth(EffectWindow* c, int w);
78 void assignSlots( const QRect& area, int columns, int rows );
79 void getBestAssignments();
81 void updateFilterTexture();
82 void discardFilterTexture();
84 void paintWindowIcon( EffectWindow* w, WindowPaintData& data );
86 void setHighlightedWindow( EffectWindow* w );
87 EffectWindow* relativeWindow( EffectWindow* w, int xdiff, int ydiff, bool wrap ) const;
88 EffectWindow* findFirstWindow() const;
90 // Called once the effect is activated (and wasn't activated before)
91 void effectActivated();
92 // Called once the effect has terminated
93 void effectTerminated();
95 private:
96 bool mShowWindowsFromAllDesktops;
98 // Whether the effect is currently activated by the user
99 bool mActivated;
100 // 0 = not active, 1 = fully active
101 double mActiveness;
102 // 0 = start of rearranging (old_area), 1 = done
103 double mRearranging;
105 Window mInput;
106 bool hasKeyboardGrab;
108 EffectWindowList mWindowsToPresent;
109 struct WindowData
111 QRect area;
112 QRect old_area; // when rearranging, otherwise unset
113 double scale;
114 double old_scale; // when rearranging, otherwise unset
115 double highlight;
116 int slot;
117 int x, y; // position of the slot in the grid
118 int slot_distance;
119 QPixmap icon;
120 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
121 GLTexture iconTexture;
122 #endif
123 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
124 Picture iconPicture;
125 #endif
127 typedef QHash<EffectWindow*, WindowData> DataHash;
128 DataHash mWindowData;
129 EffectWindow* mHighlightedWindow;
131 QString windowFilter;
132 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
133 GLTexture* filterTexture;
134 QRect filterTextureRect;
135 QRect filterFrameRect;
136 #endif
138 ElectricBorder borderActivate;
139 ElectricBorder borderActivateAll;
141 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
142 XRenderPictFormat* alphaFormat;
143 #endif
146 } // namespace
148 #endif