1/********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6Copyright (C) 1997 to 2002 Cristian Tibirna <tibirna@kde.org>
7Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************/
22
23#ifndef KWIN_PLACEMENT_H
24#define KWIN_PLACEMENT_H
25// KWin
26#include <kwinglobals.h>
27// Qt
28#include <QPoint>
29#include <QRect>
30#include <QList>
31
32class QObject;
33
34namespace KWin
35{
36
37class Client;
38
39class Placement
40{
41public:
42 virtual ~Placement();
43
44 /**
45 * Placement policies. How workspace decides the way windows get positioned
46 * on the screen. The better the policy, the heavier the resource use.
47 * Normally you don't have to worry. What the WM adds to the startup time
48 * is nil compared to the creation of the window itself in the memory
49 */
50 enum Policy {
51 NoPlacement, // not really a placement
52 Default, // special, means to use the global default
53 Unknown, // special, means the function should use its default
54 Random,
55 Smart,
56 Cascade,
57 Centered,
58 ZeroCornered,
59 UnderMouse, // special
60 OnMainWindow, // special
61 Maximizing
62 };
63
64 void place(Client* c, QRect& area);
65
66 void placeAtRandom(Client* c, const QRect& area, Policy next = Unknown);
67 void placeCascaded(Client* c, QRect& area, Policy next = Unknown);
68 void placeSmart(Client* c, const QRect& area, Policy next = Unknown);
69 void placeMaximizing(Client* c, QRect& area, Policy next = Unknown);
70 void placeCentered(Client* c, const QRect& area, Policy next = Unknown);
71 void placeZeroCornered(Client* c, const QRect& area, Policy next = Unknown);
72 void placeDialog(Client* c, QRect& area, Policy next = Unknown);
73 void placeUtility(Client* c, QRect& area, Policy next = Unknown);
74
75 void reinitCascading(int desktop);
76
77 /**
78 * Cascades all clients on the current desktop
79 **/
80 void cascadeDesktop();
81 /**
82 * Unclutters the current desktop by smart-placing all clients again.
83 **/
84 void unclutterDesktop();
85
86 static Policy policyFromString(const QString& policy, bool no_special);
87 static const char* policyToString(Policy policy);
88
89private:
90 void place(Client* c, QRect& area, Policy policy, Policy nextPlacement = Unknown);
91 void placeUnderMouse(Client* c, QRect& area, Policy next = Unknown);
92 void placeOnMainWindow(Client* c, QRect& area, Policy next = Unknown);
93 QRect checkArea(const Client*c, const QRect& area);
94
95 //CT needed for cascading+
96 struct DesktopCascadingInfo {
97 QPoint pos;
98 int col;
99 int row;
100 };
101
102 QList<DesktopCascadingInfo> cci;
103
104 KWIN_SINGLETON(Placement)
105};
106
107} // namespace
108
109#endif
110