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>
30 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
31 #include <X11/extensions/Xrender.h>
38 * Expose-like effect which shows all windows on current desktop side-by-side,
39 * letting the user select active window.
41 class PresentWindowsEffect
42 : public QObject
, public Effect
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
);
61 void setActive(bool active
);
62 void toggleActive() { mShowWindowsFromAllDesktops
= false; setActive(!mActivated
); }
63 void toggleActiveAllDesktops() { mShowWindowsFromAllDesktops
= true; setActive(!mActivated
); }
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();
96 bool mShowWindowsFromAllDesktops
;
98 // Whether the effect is currently activated by the user
100 // 0 = not active, 1 = fully active
102 // 0 = start of rearranging (old_area), 1 = done
106 bool hasKeyboardGrab
;
108 EffectWindowList mWindowsToPresent
;
112 QRect old_area
; // when rearranging, otherwise unset
114 double old_scale
; // when rearranging, otherwise unset
117 int x
, y
; // position of the slot in the grid
120 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
121 GLTexture iconTexture
;
123 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
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
;
138 ElectricBorder borderActivate
;
139 ElectricBorder borderActivateAll
;
141 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
142 XRenderPictFormat
* alphaFormat
;