summaryrefslogtreecommitdiff
path: root/src/duicompositemanager.h
blob: 5b664acbbbec454444159a637700401da29ebaa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of duicompositor.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#ifndef DUICOMPOSITEMANAGER_H
#define DUICOMPOSITEMANAGER_H

#include <QApplication>
#include <QGLWidget>

class QGraphicsScene;
class DuiCompositeManagerPrivate;
class DuiCompAtoms;

/*!
 * DuiCompositeManager is responsible for managing window events.
 *
 * It catches and redirects appropriate windows to offscreen pixmaps and
 * creates a DuiTexturePixmapItem object from these windows and adds them
 * to a QGraphicsScene. The manager also ensures the items are updated
 * when their contents change and removes them from its control when they are
 * destroyed.
 *
 */
class DuiCompositeManager: public QApplication
{
    Q_OBJECT
public:

    /*!
     * Initializes the compositing manager
     *
     * \param argc number of arguments passed from the command line
     * \param argv argument of strings passed from the command line
     */
    DuiCompositeManager(int &argc, char **argv);

    /*!
     * Cleans up resources
     */
    ~DuiCompositeManager();

    /*! Prepare and start composite management. This function should get called
     * after the window of this compositor is created and mapped to the screen
     */
    void prepareEvents();

    /*! Specify the QGLWidget used by the QGraphicsView to draw the items on
     * the screen.
     *
     * \param glw The QGLWidget widget used in used by the scene's
     * QGraphicsView viewport
     */
    void setGLWidget(QGLWidget *glw);

    /*!
     * Reimplemented from QApplication::x11EventFilter() to catch X11 events
     */
    virtual bool x11EventFilter(XEvent *event);

    /*!
     * Returns the scene where the items are rendered
     */
    QGraphicsScene *scene();

    /*!
     * Specifies the toplevel window where the items are rendered. This window
     * will reparented to the composite overlay window to ensure the compositor
     * stays on top of all windows.
     *
     * \param window Window id of the toplevel window where the items are
     * rendered. Typically, this will be the window id of a toplevel
     * QGraphicsView widget where the items are drawn
     */
    void setSurfaceWindow(Qt::HANDLE window);

    /*!
     * Redirects and manages existing windows as composited items
     */
    void redirectWindows();

    /*!
     * Returns whether a Window is redirected or not
     *
     * \param w Window id of a window
     */
    bool isRedirected(Qt::HANDLE window);
    
    void topmostWindowsRaise();

public slots:
    void enableCompositing();
    void disableCompositing();

    /*! Invoked remotely by DuiRmiClient to show a launch indicator
     *
     * \param timeout seconds elapsed to hide the launch indicator in case
     * window does not yet appear.
     */
    void showLaunchIndicator(int timeout);
    void hideLaunchIndicator();

private:
    DuiCompositeManagerPrivate *d;

    friend class DuiCompositeWindow;
    friend class DuiCompWindowAnimator;
};

#endif