placement.h 2.9 KB
Newer Older
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
1
2
3
/*
    KWin - the KDE window manager
    This file is part of the KDE project.
4

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
5
6
7
    SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
    SPDX-FileCopyrightText: 1997-2002 Cristian Tibirna <tibirna@kde.org>
    SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
8

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
9
10
    SPDX-License-Identifier: GPL-2.0-or-later
*/
11
12
13

#ifndef KWIN_PLACEMENT_H
#define KWIN_PLACEMENT_H
14
15
16
// KWin
#include <kwinglobals.h>
// Qt
17
18
19
20
#include <QPoint>
#include <QRect>
#include <QList>

21
22
class QObject;

23
24
25
namespace KWin
{

26
class AbstractClient;
27

28
class KWIN_EXPORT Placement
29
30
{
public:
Martin Flöser's avatar
Martin Flöser committed
31
    virtual ~Placement();
32
33
34
35
36
37

    /**
     * Placement policies. How workspace decides the way windows get positioned
     * on the screen. The better the policy, the heavier the resource use.
     * Normally you don't have to worry. What the WM adds to the startup time
     * is nil compared to the creation of the window itself in the memory
38
     */
39
40
41
42
43
44
45
46
47
48
49
50
51
    enum Policy {
        NoPlacement, // not really a placement
        Default, // special, means to use the global default
        Unknown, // special, means the function should use its default
        Random,
        Smart,
        Cascade,
        Centered,
        ZeroCornered,
        UnderMouse, // special
        OnMainWindow, // special
        Maximizing
    };
52

53
    void place(AbstractClient *c, const QRect &area);
54

55
    void placeAtRandom(AbstractClient* c, const QRect& area, Policy next = Unknown);
56
    void placeCascaded(AbstractClient* c, const QRect& area, Policy next = Unknown);
57
    void placeSmart(AbstractClient* c, const QRect& area, Policy next = Unknown);
58
    void placeMaximizing(AbstractClient* c, const QRect& area, Policy next = Unknown);
59
    void placeCentered(AbstractClient* c, const QRect& area, Policy next = Unknown);
60
    void placeZeroCornered(AbstractClient* c, const QRect& area, Policy next = Unknown);
61
62
63
    void placeDialog(AbstractClient* c, const QRect& area, Policy next = Unknown);
    void placeUtility(AbstractClient* c, const QRect& area, Policy next = Unknown);
    void placeOnScreenDisplay(AbstractClient* c, const QRect& area);
64
65
66

    void reinitCascading(int desktop);

67
68
    /**
     * Cascades all clients on the current desktop
69
     */
70
71
72
    void cascadeDesktop();
    /**
     *   Unclutters the current desktop by smart-placing all clients again.
73
     */
74
75
    void unclutterDesktop();

76
    static const char* policyToString(Policy policy);
77

78
private:
79
80
81
    void place(AbstractClient *c, const QRect &area, Policy policy, Policy nextPlacement = Unknown);
    void placeUnderMouse(AbstractClient *c, const QRect &area, Policy next = Unknown);
    void placeOnMainWindow(AbstractClient *c, const QRect &area, Policy next = Unknown);
82
    void placeTransient(AbstractClient *c);
83
84
85
86
87
88

    //CT needed for cascading+
    struct DesktopCascadingInfo {
        QPoint pos;
        int col;
        int row;
89
90
    };

91
92
    QList<DesktopCascadingInfo> cci;

93
    KWIN_SINGLETON(Placement)
94
95
};

96
97
98
} // namespace

#endif