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 "presentwindows_proxy.h"
27
#include <kwineffects.h>
28
#include <kshortcut.h>
29
#include <QtGui/QGraphicsView>
41
class CloseWindowView : public QGraphicsView
45
CloseWindowView(QWidget* parent = 0);
46
void windowInputMouseEvent(QMouseEvent* e);
47
virtual void drawBackground(QPainter* painter, const QRectF& rect);
56
Plasma::PushButton* m_closeButton;
57
Plasma::FrameSvg* m_frame;
58
QTimer* m_delayedShowTimer;
62
* Expose-like effect which shows all windows on current desktop side-by-side,
63
* letting the user select active window.
65
class PresentWindowsEffect
77
EffectFrame* textFrame;
78
EffectFrame* iconFrame;
80
typedef QHash<EffectWindow*, WindowData> DataHash;
87
PresentWindowsEffect();
88
virtual ~PresentWindowsEffect();
90
virtual void reconfigure(ReconfigureFlags);
91
virtual void* proxy();
94
virtual void prePaintScreen(ScreenPrePaintData &data, int time);
95
virtual void paintScreen(int mask, QRegion region, ScreenPaintData &data);
96
virtual void postPaintScreen();
99
virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time);
100
virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data);
103
virtual bool borderActivated(ElectricBorder border);
104
virtual void windowInputMouseEvent(Window w, QEvent *e);
105
virtual void grabbedKeyboardEvent(QKeyEvent *e);
107
enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes
108
enum PresentWindowsMode {
109
ModeAllDesktops, // Shows windows of all desktops
110
ModeCurrentDesktop, // Shows windows on current desktop
111
ModeSelectedDesktop, // Shows windows of selected desktop via property (m_desktop)
112
ModeWindowGroup, // Shows windows selected via property
113
ModeWindowClass // Shows all windows of same class as selected class
115
enum WindowMouseAction {
116
WindowNoAction = 0, // Nothing
117
WindowActivateAction = 1, // Activates the window and deactivates the effect
118
WindowExitAction = 2, // Deactivates the effect without activating new window
119
WindowToCurrentDesktopAction = 3, // Brings window to current desktop
120
WindowToAllDesktopsAction = 4, // Brings window to all desktops
121
WindowMinimizeAction = 5, // Minimize the window
122
WindowCloseAction = 6 // Closes the window
124
enum DesktopMouseAction {
125
DesktopNoAction = 0, // nothing
126
DesktopActivateAction = 1, // Activates the window and deactivates the effect
127
DesktopExitAction = 2, // Deactivates the effect without activating new window
128
DesktopShowDesktopAction = 3 // Minimizes all windows
132
void setActive(bool active, bool closingTab = false); // HACK: closingTab shouldn't be needed
133
void toggleActive() {
134
m_mode = ModeCurrentDesktop;
135
setActive(!m_activated);
137
void toggleActiveAllDesktops() {
138
m_mode = ModeAllDesktops;
139
setActive(!m_activated);
141
void toggleActiveClass();
143
// slots for global shortcut changed
144
// needed to toggle the effect
145
void globalShortcutChanged(const QKeySequence& seq);
146
void globalShortcutChangedAll(const QKeySequence& seq);
147
void globalShortcutChangedClass(const QKeySequence& seq);
149
void slotWindowAdded(EffectWindow *w);
150
void slotWindowClosed(EffectWindow *w);
151
void slotWindowDeleted(EffectWindow *w);
152
void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old);
154
void slotTabBoxAdded(int mode);
155
void slotTabBoxClosed();
156
void slotTabBoxUpdated();
157
void slotTabBoxKeyEvent(QKeyEvent* event);
159
void slotPropertyNotify(EffectWindow* w, long atom);
165
// Window rearranging
166
void rearrangeWindows();
167
void calculateWindowTransformations(EffectWindowList windowlist, int screen,
168
WindowMotionManager& motionManager, bool external = false);
169
void calculateWindowTransformationsClosest(EffectWindowList windowlist, int screen,
170
WindowMotionManager& motionManager);
171
void calculateWindowTransformationsKompose(EffectWindowList windowlist, int screen,
172
WindowMotionManager& motionManager);
173
void calculateWindowTransformationsNatural(EffectWindowList windowlist, int screen,
174
WindowMotionManager& motionManager);
176
// Helper functions for window rearranging
177
inline double aspectRatio(EffectWindow *w) {
178
return w->width() / double(w->height());
180
inline int widthForHeight(EffectWindow *w, int height) {
181
return int((height / double(w->height())) * w->width());
183
inline int heightForWidth(EffectWindow *w, int width) {
184
return int((width / double(w->width())) * w->height());
186
bool isOverlappingAny(EffectWindow *w, const QHash<EffectWindow*, QRect> &targets, const QRegion &border);
189
void updateFilterFrame();
192
bool isSelectableWindow(EffectWindow *w);
193
bool isVisibleWindow(EffectWindow *w);
194
void setHighlightedWindow(EffectWindow *w);
195
EffectWindow* relativeWindow(EffectWindow *w, int xdiff, int ydiff, bool wrap) const;
196
EffectWindow* findFirstWindow() const;
197
void updateCloseWindow();
199
// Helper functions for mouse actions
200
void mouseActionWindow(WindowMouseAction& action);
201
void mouseActionDesktop(DesktopMouseAction& action);
204
PresentWindowsEffectProxy m_proxy;
205
friend class PresentWindowsEffectProxy;
207
// User configuration settings
208
QList<ElectricBorder> m_borderActivate;
209
QList<ElectricBorder> m_borderActivateAll;
213
bool m_doNotCloseWindows;
214
bool m_tabBoxAllowed;
215
bool m_tabBoxAlternativeAllowed;
218
double m_fadeDuration;
223
bool m_ignoreMinimized;
224
double m_decalOpacity;
226
bool m_hasKeyboardGrab;
227
bool m_tabBoxEnabled;
228
PresentWindowsMode m_mode;
230
EffectWindowList m_selectedWindows;
231
EffectWindow *m_managerWindow;
235
WindowMotionManager m_motionManager;
236
DataHash m_windowData;
237
EffectWindow *m_highlightedWindow;
240
QList<GridSize> m_gridSizes;
243
EffectFrame* m_filterFrame;
244
QString m_windowFilter;
246
// Shortcut - needed to toggle the effect
248
KShortcut shortcutAll;
249
KShortcut shortcutClass;
252
// Present windows for all windows of given desktop
253
// -1 for all desktops
255
// Present windows for group of window ids
259
WindowMouseAction m_leftButtonWindow;
260
WindowMouseAction m_middleButtonWindow;
261
WindowMouseAction m_rightButtonWindow;
262
DesktopMouseAction m_leftButtonDesktop;
263
DesktopMouseAction m_middleButtonDesktop;
264
DesktopMouseAction m_rightButtonDesktop;
266
CloseWindowView* m_closeView;
267
EffectWindow* m_closeWindow;
271
bool m_dragInProgress;
272
EffectWindow *m_dragWindow;
273
QList<EffectFrame*> m_dropTargets;
274
EffectFrame *m_highlightedDropTarget;