summaryrefslogtreecommitdiff
path: root/src/mcompositemanager_p.h
blob: 716c5c61ba9f30a9215a0c1254d3341c70ad0f01 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of mcompositor.
**
** 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_P_H
#define DUICOMPOSITEMANAGER_P_H

#include <QObject>
#include <QHash>
#include <QPixmap>
#include <QTimer>

#include <X11/Xutil.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xdamage.h>
#include <X11/Xlib-xcb.h>

class QGraphicsScene;
class QGLWidget;

class MCompositeScene;
class MSimpleWindowFrame;
class MCompAtoms;
class MCompositeWindow;
class MDeviceState;
class MWindowPropertyCache;
class MCompositeManagerExtension;

enum {
    INPUT_LAYER = 0,
    DOCK_LAYER,
    SYSTEM_LAYER,
    APPLICATION_LAYER,
    DESKTOP_LAYER,
    TOTAL_LAYERS
};

/*!
 * Internal implementation of MCompositeManager
 */

class MCompositeManagerPrivate: public QObject
{
    Q_OBJECT
public:
    enum ForcingLevel {
        NO_FORCED = 0,
        FORCED
    };

    MCompositeManagerPrivate(QObject *p);
    ~MCompositeManagerPrivate();

    static Window parentWindow(Window child);
    MCompositeWindow *bindWindow(Window w);
    QGraphicsScene *scene();

    void prepare();
    void loadPlugins();
    void activateWindow(Window w, Time timestamp,
		        bool disableCompositing = true);
    void updateWinList();
    void setWindowState(Window , int);
    void setWindowDebugProperties(Window w);
    void positionWindow(Window w, bool on_top);
    void addItem(MCompositeWindow *item);
    void damageEvent(XDamageNotifyEvent *);
    void destroyEvent(XDestroyWindowEvent *);
    void propertyEvent(XPropertyEvent *);
    void unmapEvent(XUnmapEvent *);
    void configureEvent(XConfigureEvent *);
    void configureRequestEvent(XConfigureRequestEvent *);
    void mapEvent(XMapEvent *);
    void mapRequestEvent(XMapRequestEvent *);
    void rootMessageEvent(XClientMessageEvent *);
    void clientMessageEvent(XClientMessageEvent *);
    void keyEvent(XKeyEvent*);
    void buttonEvent(XButtonEvent*);
    void installX11EventFilter(long xevent, MCompositeManagerExtension* extension);
    
    void redirectWindows();
    void showOverlayWindow(bool show);
    void enableRedirection();
    void setExposeDesktop(bool exposed);
    void checkStacking(bool force_visibility_check,
                       Time timestamp = CurrentTime);
    void checkInputFocus(Time timestamp = CurrentTime);
    void configureWindow(MCompositeWindow *cw, XConfigureRequestEvent *e);

    Window getTopmostApp(int *index_in_stacking_list = 0,
                         Window ignore_window = 0,
                         bool skip_always_mapped = false);
    Window getLastVisibleParent(MWindowPropertyCache *pc);

    bool possiblyUnredirectTopmostWindow();
    bool haveMappedWindow() const;
    bool isRedirected(Window window);
    bool x11EventFilter(XEvent *event);
    bool processX11EventFilters(XEvent *event, bool after);
    void removeWindow(Window w);
    bool needDecoration(Window w, MWindowPropertyCache *pc = 0);
    MCompositeWindow *getHighestDecorated();
    
    static bool compareWindows(Window w_a, Window w_b);
    void roughSort();
    void setCurrentApp(Window w, bool stacking_order_changed);
    void raiseTransientsOf(MWindowPropertyCache *pc, int last_i,
                           bool recursion = false);

    MCompositeScene *watch;
    Window localwin, localwin_parent;
    Window xoverlay;
    Window prev_focus;
    Window close_button_win, home_button_win, buttoned_win;
    Window current_app;
    QRect home_button_geom, close_button_geom;

    static Window stack[TOTAL_LAYERS];

    MCompAtoms *atom;
    QGLWidget *glwidget;

    QList<Window> stacking_list;
    QList<Window> windows_as_mapped;

    QHash<Window, MCompositeWindow *> windows;
    struct FrameData {
        FrameData(): frame(0), parentWindow(0), mapped(false) {}
        MSimpleWindowFrame *frame;
        Window                parentWindow;
        bool mapped;
    };
    QHash<Window, FrameData> framed_windows;
    QHash<Window, QList<XConfigureRequestEvent*> > configure_reqs;
    QHash<Window, MWindowPropertyCache*> prop_caches;
    QMultiHash<int, MCompositeManagerExtension* > m_extensions;
    QRegion dock_region;

    int damage_event;
    int damage_error;

    bool compositing;
    bool overlay_mapped;
    MDeviceState *device_state;

    xcb_connection_t *xcb_conn;

    // mechanism for lazy stacking
    QTimer stacking_timer;
    bool stacking_timeout_check_visibility;
    Time stacking_timeout_timestamp;
    void dirtyStacking(bool force_visibility_check, Time t = CurrentTime);
    void pingTopmost();

signals:
    void compositingEnabled();
    void currentAppChanged(Window w);

public slots:

    void gotHungWindow(MCompositeWindow *window);
    void enableCompositing(bool forced = false);
    void disableCompositing(ForcingLevel forced = NO_FORCED);
    void showLaunchIndicator(int timeout);
    void hideLaunchIndicator();

    void lowerHandler(MCompositeWindow *window);
    void restoreHandler(MCompositeWindow *window);
    void closeHandler(MCompositeWindow *window);
    
    void onDesktopActivated(MCompositeWindow*);
    void exposeDesktop();
    void exposeSwitcher();
    
    void displayOff(bool display_off);
    void callOngoing(bool call_ongoing);
    void stackingTimeout();
    void setupButtonWindows(Window topmost);
};

#endif