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>
36 * Expose-like effect which shows all windows on current desktop side-by-side,
37 * letting the user select active window.
39 class PresentWindowsEffect
40 : public QObject
, public Effect
53 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
54 KSharedPtr
< GLTexture
> iconTexture
;
56 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
57 XRenderPicture iconPicture
;
60 typedef QHash
<EffectWindow
*, WindowData
> DataHash
;
68 PresentWindowsEffect();
69 virtual ~PresentWindowsEffect();
71 virtual void reconfigure( ReconfigureFlags
);
73 virtual void prePaintScreen( ScreenPrePaintData
&data
, int time
);
74 virtual void paintScreen( int mask
, QRegion region
, ScreenPaintData
&data
);
75 virtual void postPaintScreen();
78 virtual void prePaintWindow( EffectWindow
*w
, WindowPrePaintData
&data
, int time
);
79 virtual void paintWindow( EffectWindow
*w
, int mask
, QRegion region
, WindowPaintData
&data
);
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
);
90 virtual void tabBoxAdded( int mode
);
91 virtual void tabBoxClosed();
92 virtual void tabBoxUpdated();
94 enum { LayoutNatural
, LayoutRegularGrid
, LayoutFlexibleGrid
}; // Layout modes
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
); }
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
);
120 void updateFilterTexture();
121 void discardFilterTexture();
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?
132 // User configuration settings
133 ElectricBorder m_borderActivate
;
134 ElectricBorder m_borderActivateAll
;
138 bool m_tabBoxAllowed
;
141 double m_fadeDuration
;
147 bool m_ignoreMinimized
;
148 double m_decalOpacity
;
150 bool m_hasKeyboardGrab
;
151 bool m_tabBoxEnabled
;
154 WindowMotionManager m_motionManager
;
155 DataHash m_windowData
;
156 EffectWindow
*m_highlightedWindow
;
159 QList
<GridSize
> m_gridSizes
;
162 QString m_windowFilter
;
163 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
164 GLTexture
*m_filterTexture
;
165 QRect m_filterTextureRect
;
166 QRect m_filterFrameRect
;