add more spacing
[personal-kdebase.git] / workspace / kwin / effects / presentwindows.h
blob34bd16ffdb793a3949e1bf00f028983f3decbc36
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>
6 Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *********************************************************************/
22 #ifndef KWIN_PRESENTWINDOWS_H
23 #define KWIN_PRESENTWINDOWS_H
25 // Include with base class for effects.
26 #include <kwineffects.h>
27 #include <kwinglutils.h>
28 #include <kwinxrenderutils.h>
30 #include <QPixmap>
32 namespace KWin
35 /**
36 * Expose-like effect which shows all windows on current desktop side-by-side,
37 * letting the user select active window.
38 **/
39 class PresentWindowsEffect
40 : public QObject, public Effect
42 Q_OBJECT
43 private:
44 // Structures
45 struct WindowData
47 bool visible;
48 double opacity;
49 double highlight;
50 int slot;
51 int slot_distance;
52 QPixmap icon;
53 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
54 KSharedPtr< GLTexture > iconTexture;
55 #endif
56 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
57 XRenderPicture iconPicture;
58 #endif
60 typedef QHash<EffectWindow*, WindowData> DataHash;
61 struct GridSize
63 int columns;
64 int rows;
67 public:
68 PresentWindowsEffect();
69 virtual ~PresentWindowsEffect();
71 virtual void reconfigure( ReconfigureFlags );
72 // Screen painting
73 virtual void prePaintScreen( ScreenPrePaintData &data, int time );
74 virtual void paintScreen( int mask, QRegion region, ScreenPaintData &data );
75 virtual void postPaintScreen();
77 // Window painting
78 virtual void prePaintWindow( EffectWindow *w, WindowPrePaintData &data, int time );
79 virtual void paintWindow( EffectWindow *w, int mask, QRegion region, WindowPaintData &data );
81 // User interaction
82 virtual void windowAdded( EffectWindow *w );
83 virtual void windowClosed( EffectWindow *w );
84 virtual void windowDeleted( EffectWindow *w );
85 virtual bool borderActivated( ElectricBorder border );
86 virtual void windowInputMouseEvent( Window w, QEvent *e );
87 virtual void grabbedKeyboardEvent( QKeyEvent *e );
89 // Tab box
90 virtual void tabBoxAdded( int mode );
91 virtual void tabBoxClosed();
92 virtual void tabBoxUpdated();
94 enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes
96 public slots:
97 void setActive( bool active, bool closingTab = false ); // HACK: closingTab shouldn't be needed
98 void toggleActive() { m_allDesktops = false; setActive( !m_activated ); }
99 void toggleActiveAllDesktops() { m_allDesktops = true; setActive( !m_activated ); }
101 protected:
102 // Window rearranging
103 void rearrangeWindows();
104 void calculateWindowTransformationsClosest( EffectWindowList windowlist, int screen );
105 void calculateWindowTransformationsKompose( EffectWindowList windowlist, int screen );
106 void calculateWindowTransformationsNatural( EffectWindowList windowlist, int screen );
108 // Helper functions for window rearranging
109 inline double aspectRatio( EffectWindow *w )
110 { return w->width() / double( w->height() ); }
111 inline int widthForHeight( EffectWindow *w, int height )
112 { return int(( height / double( w->height() )) * w->width() ); }
113 inline int heightForWidth( EffectWindow *w, int width )
114 { return int(( width / double( w->width() )) * w->height() ); }
115 void assignSlots( EffectWindowList windowlist, const QRect &area, int columns, int rows );
116 void getBestAssignments( EffectWindowList windowlist );
117 bool isOverlappingAny( EffectWindow *w, const QHash<EffectWindow*, QRect> &targets, const QRegion &border );
119 // Filter box
120 void updateFilterTexture();
121 void discardFilterTexture();
123 // Helper functions
124 bool isSelectableWindow( EffectWindow *w );
125 bool isVisibleWindow( EffectWindow *w );
126 void setHighlightedWindow( EffectWindow *w );
127 EffectWindow* relativeWindow( EffectWindow *w, int xdiff, int ydiff, bool wrap ) const;
128 EffectWindow* findFirstWindow() const;
129 void paintWindowIcon( EffectWindow *w, WindowPaintData &data ); // TODO: Do we need this?
131 private:
132 // User configuration settings
133 ElectricBorder m_borderActivate;
134 ElectricBorder m_borderActivateAll;
135 int m_layoutMode;
136 bool m_showCaptions;
137 bool m_showIcons;
138 bool m_tabBoxAllowed;
139 int m_accuracy;
140 bool m_fillGaps;
141 double m_fadeDuration;
142 bool m_showPanel;
144 // Activation
145 bool m_activated;
146 bool m_allDesktops;
147 bool m_ignoreMinimized;
148 double m_decalOpacity;
149 Window m_input;
150 bool m_hasKeyboardGrab;
151 bool m_tabBoxEnabled;
153 // Window data
154 WindowMotionManager m_motionManager;
155 DataHash m_windowData;
156 EffectWindow *m_highlightedWindow;
158 // Grid layout info
159 QList<GridSize> m_gridSizes;
161 // Filter box
162 QString m_windowFilter;
163 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
164 GLTexture *m_filterTexture;
165 QRect m_filterTextureRect;
166 QRect m_filterFrameRect;
167 #endif
170 } // namespace
172 #endif