~focus-follows-mouse/ubuntu/precise/compiz/fix-883383

« back to all changes in this revision

Viewing changes to .pc/000_fix_OOo_crash1.patch/src/privatescreen.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-12-01 13:10:41 UTC
  • mfrom: (0.150.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101201131041-iwqfke3wltkfymkq
Tags: 1:0.9.2.1+glibmainloop2-0ubuntu4
* debian/patches/065_add_bailer_and_detection_plugins.patch:
  - fix the fallback not launching gnome-panel when no 3D support
    (LP: #683356, #683531)
* debian/patches/000_fix_OOo_crash{1,2].patch:
  - cherry-pick fix crashes with random applications (LP: #675506)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2008 Dennis Kasprzyk
 
3
 * Copyright © 2007 Novell, Inc.
 
4
 *
 
5
 * Permission to use, copy, modify, distribute, and sell this software
 
6
 * and its documentation for any purpose is hereby granted without
 
7
 * fee, provided that the above copyright notice appear in all copies
 
8
 * and that both that copyright notice and this permission notice
 
9
 * appear in supporting documentation, and that the name of
 
10
 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
 
11
 * distribution of the software without specific, written prior permission.
 
12
 * Dennis Kasprzyk makes no representations about the suitability of this
 
13
 * software for any purpose. It is provided "as is" without express or
 
14
 * implied warranty.
 
15
 *
 
16
 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
18
 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
20
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
21
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
22
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
23
 *
 
24
 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
 
25
 *          David Reveman <davidr@novell.com>
 
26
 */
 
27
 
 
28
#ifndef _PRIVATESCREEN_H
 
29
#define _PRIVATESCREEN_H
 
30
 
 
31
#include <core/core.h>
 
32
#include <core/screen.h>
 
33
#include <core/size.h>
 
34
#include <core/point.h>
 
35
#include <core/timer.h>
 
36
#include <core/plugin.h>
 
37
 
 
38
#include <glibmm/main.h>
 
39
 
 
40
#include "core_options.h"
 
41
 
 
42
CompPlugin::VTable * getCoreVTable ();
 
43
 
 
44
extern bool shutDown;
 
45
extern bool restartSignal;
 
46
 
 
47
typedef struct _CompWatchFd {
 
48
    int               fd;
 
49
    FdWatchCallBack   callBack;
 
50
    CompWatchFdHandle handle;
 
51
} CompWatchFd;
 
52
 
 
53
extern CompWindow *lastFoundWindow;
 
54
extern bool       useDesktopHints;
 
55
 
 
56
extern bool inHandleEvent;
 
57
 
 
58
extern CompScreen *targetScreen;
 
59
extern CompOutput *targetOutput;
 
60
 
 
61
 
 
62
typedef struct _CompDelayedEdgeSettings
 
63
{
 
64
    CompAction::CallBack initiate;
 
65
    CompAction::CallBack terminate;
 
66
 
 
67
    unsigned int edge;
 
68
    unsigned int state;
 
69
 
 
70
    CompOption::Vector options;
 
71
} CompDelayedEdgeSettings;
 
72
 
 
73
 
 
74
#define SCREEN_EDGE_LEFT        0
 
75
#define SCREEN_EDGE_RIGHT       1
 
76
#define SCREEN_EDGE_TOP         2
 
77
#define SCREEN_EDGE_BOTTOM      3
 
78
#define SCREEN_EDGE_TOPLEFT     4
 
79
#define SCREEN_EDGE_TOPRIGHT    5
 
80
#define SCREEN_EDGE_BOTTOMLEFT  6
 
81
#define SCREEN_EDGE_BOTTOMRIGHT 7
 
82
#define SCREEN_EDGE_NUM         8
 
83
 
 
84
#define TIMEVALDIFF(tv1, tv2)                                              \
 
85
    ((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
 
86
    ((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) +                         \
 
87
     ((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 :                           \
 
88
    ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) +                     \
 
89
     (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000
 
90
 
 
91
struct CompScreenEdge {
 
92
    Window       id;
 
93
    unsigned int count;
 
94
};
 
95
 
 
96
struct CompGroup {
 
97
    unsigned int      refCnt;
 
98
    Window            id;
 
99
};
 
100
 
 
101
struct CompStartupSequence {
 
102
    SnStartupSequence           *sequence;
 
103
    unsigned int                viewportX;
 
104
    unsigned int                viewportY;
 
105
};
 
106
 
 
107
class CompEventSource:
 
108
    public Glib::Source
 
109
{
 
110
    public:
 
111
 
 
112
        static
 
113
        Glib::RefPtr <CompEventSource> create ();
 
114
 
 
115
        sigc::connection connect (const sigc::slot <bool> &slot);
 
116
 
 
117
    protected:
 
118
 
 
119
        bool prepare (int &timeout);
 
120
        bool check ();
 
121
        bool dispatch (sigc::slot_base *slot);
 
122
        bool callback ();
 
123
 
 
124
        explicit CompEventSource ();
 
125
        virtual ~CompEventSource ();
 
126
 
 
127
    private:
 
128
 
 
129
        Display       *mDpy;
 
130
        Glib::PollFD  mPollFD;
 
131
        int           mConnectionFD;
 
132
};
 
133
 
 
134
class PrivateScreen : public CoreOptions {
 
135
 
 
136
    public:
 
137
        class KeyGrab {
 
138
            public:
 
139
                int          keycode;
 
140
                unsigned int modifiers;
 
141
                int          count;
 
142
        };
 
143
 
 
144
        class ButtonGrab {
 
145
            public:
 
146
                int          button;
 
147
                unsigned int modifiers;
 
148
                int          count;
 
149
        };
 
150
 
 
151
        class Grab {
 
152
            public:
 
153
 
 
154
                friend class CompScreen;
 
155
            private:
 
156
                Cursor     cursor;
 
157
                const char *name;
 
158
        };
 
159
 
 
160
    public:
 
161
        PrivateScreen (CompScreen *screen);
 
162
        ~PrivateScreen ();
 
163
 
 
164
        bool setOption (const CompString &name, CompOption::Value &value);
 
165
 
 
166
        void processEvents ();
 
167
 
 
168
        void removeDestroyed ();
 
169
 
 
170
        void updatePassiveGrabs ();
 
171
 
 
172
        int doPoll (int timeout);
 
173
 
 
174
        void handleTimers (struct timeval *tv);
 
175
 
 
176
        void addTimer (CompTimer *timer);
 
177
        void removeTimer (CompTimer *timer);
 
178
 
 
179
        void updatePlugins ();
 
180
 
 
181
        bool triggerButtonPressBindings (CompOption::Vector &options,
 
182
                                         XButtonEvent       *event,
 
183
                                         CompOption::Vector &arguments);
 
184
 
 
185
        bool triggerButtonReleaseBindings (CompOption::Vector &options,
 
186
                                           XButtonEvent       *event,
 
187
                                           CompOption::Vector &arguments);
 
188
 
 
189
        bool triggerKeyPressBindings (CompOption::Vector &options,
 
190
                                      XKeyEvent          *event,
 
191
                                      CompOption::Vector &arguments);
 
192
 
 
193
        bool triggerKeyReleaseBindings (CompOption::Vector &options,
 
194
                                        XKeyEvent          *event,
 
195
                                        CompOption::Vector &arguments);
 
196
 
 
197
        bool triggerStateNotifyBindings (CompOption::Vector  &options,
 
198
                                         XkbStateNotifyEvent *event,
 
199
                                         CompOption::Vector  &arguments);
 
200
 
 
201
        bool triggerEdgeEnter (unsigned int       edge,
 
202
                               CompAction::State  state,
 
203
                               CompOption::Vector &arguments);
 
204
 
 
205
        void setAudibleBell (bool audible);
 
206
 
 
207
        bool handlePingTimeout ();
 
208
 
 
209
        bool handleActionEvent (XEvent *event);
 
210
 
 
211
        void handleSelectionRequest (XEvent *event);
 
212
 
 
213
        void handleSelectionClear (XEvent *event);
 
214
 
 
215
        bool desktopHintEqual (unsigned long *data,
 
216
                               int           size,
 
217
                               int           offset,
 
218
                               int           hintSize);
 
219
 
 
220
        void setDesktopHints ();
 
221
 
 
222
        void setVirtualScreenSize (int hsize, int vsize);
 
223
 
 
224
        void updateOutputDevices ();
 
225
 
 
226
        void detectOutputDevices ();
 
227
 
 
228
        void updateStartupFeedback ();
 
229
 
 
230
        void updateScreenEdges ();
 
231
 
 
232
        void reshape (int w, int h);
 
233
 
 
234
        bool handleStartupSequenceTimeout ();
 
235
 
 
236
        void addSequence (SnStartupSequence *sequence);
 
237
 
 
238
        void removeSequence (SnStartupSequence *sequence);
 
239
 
 
240
        void removeAllSequences ();
 
241
 
 
242
        void setSupportingWmCheck ();
 
243
 
 
244
        void getDesktopHints ();
 
245
 
 
246
        void grabUngrabOneKey (unsigned int modifiers,
 
247
                               int          keycode,
 
248
                               bool         grab);
 
249
 
 
250
 
 
251
        bool grabUngrabKeys (unsigned int modifiers,
 
252
                             int          keycode,
 
253
                             bool         grab);
 
254
 
 
255
        bool addPassiveKeyGrab (CompAction::KeyBinding &key);
 
256
 
 
257
        void removePassiveKeyGrab (CompAction::KeyBinding &key);
 
258
 
 
259
        void updatePassiveKeyGrabs ();
 
260
 
 
261
        bool addPassiveButtonGrab (CompAction::ButtonBinding &button);
 
262
 
 
263
        void removePassiveButtonGrab (CompAction::ButtonBinding &button);
 
264
 
 
265
        CompRect computeWorkareaForBox (const CompRect &box);
 
266
 
 
267
        void updateScreenInfo ();
 
268
 
 
269
        Window getActiveWindow (Window root);
 
270
 
 
271
        int getWmState (Window id);
 
272
 
 
273
        void setWmState (int state, Window id);
 
274
 
 
275
        unsigned int windowStateMask (Atom state);
 
276
 
 
277
        static unsigned int windowStateFromString (const char *str);
 
278
 
 
279
        unsigned int getWindowState (Window id);
 
280
 
 
281
        void setWindowState (unsigned int state, Window id);
 
282
 
 
283
        unsigned int getWindowType (Window id);
 
284
 
 
285
        void getMwmHints (Window       id,
 
286
                          unsigned int *func,
 
287
                          unsigned int *decor);
 
288
 
 
289
        unsigned int getProtocols (Window id);
 
290
 
 
291
        bool readWindowProp32 (Window         id,
 
292
                               Atom           property,
 
293
                               unsigned short *returnValue);
 
294
 
 
295
        void setCurrentOutput (unsigned int outputNum);
 
296
 
 
297
        void configure (XConfigureEvent *ce);
 
298
 
 
299
        void eraseWindowFromMap (Window id);
 
300
 
 
301
        void updateClientList ();
 
302
 
 
303
        CompGroup * addGroup (Window id);
 
304
 
 
305
        void removeGroup (CompGroup *group);
 
306
 
 
307
        CompGroup * findGroup (Window id);
 
308
 
 
309
        void applyStartupProperties (CompWindow *window);
 
310
 
 
311
        Window getTopWindow ();
 
312
 
 
313
        void setNumberOfDesktops (unsigned int nDesktop);
 
314
 
 
315
        void setCurrentDesktop (unsigned int desktop);
 
316
 
 
317
        void setCurrentActiveWindowHistory (int x, int y);
 
318
 
 
319
        void addToCurrentActiveWindowHistory (Window id);
 
320
 
 
321
        void enableEdge (int edge);
 
322
 
 
323
        void disableEdge (int edge);
 
324
 
 
325
        void addScreenActions ();
 
326
 
 
327
        CompWindow *
 
328
        focusTopMostWindow ();
 
329
 
 
330
    public:
 
331
 
 
332
        PrivateScreen *priv;
 
333
 
 
334
        Glib::RefPtr <Glib::MainLoop>  mainloop;
 
335
        Glib::RefPtr <CompEventSource> source;
 
336
        Glib::RefPtr <Glib::MainContext> ctx;
 
337
 
 
338
        CompFileWatchList   fileWatch;
 
339
        CompFileWatchHandle lastFileWatchHandle;
 
340
 
 
341
        std::list<CompTimer *> timers;
 
342
        struct timeval               lastTimeout;
 
343
 
 
344
        std::list<CompWatchFd *> watchFds;
 
345
        CompWatchFdHandle        lastWatchFdHandle;
 
346
        struct pollfd            *watchPollFds;
 
347
        int                      nWatchFds;
 
348
 
 
349
        std::map<CompString, CompPrivate> valueMap;
 
350
 
 
351
        xcb_connection_t *connection;
 
352
 
 
353
        Display    *dpy;
 
354
 
 
355
        int syncEvent, syncError;
 
356
 
 
357
        bool randrExtension;
 
358
        int  randrEvent, randrError;
 
359
 
 
360
        bool shapeExtension;
 
361
        int  shapeEvent, shapeError;
 
362
 
 
363
        bool xkbExtension;
 
364
        int  xkbEvent, xkbError;
 
365
 
 
366
        bool xineramaExtension;
 
367
        int  xineramaEvent, xineramaError;
 
368
 
 
369
        std::vector<XineramaScreenInfo> screenInfo;
 
370
 
 
371
        SnDisplay *snDisplay;
 
372
 
 
373
        unsigned int lastPing;
 
374
        CompTimer    pingTimer;
 
375
 
 
376
        Window activeWindow;
 
377
 
 
378
        Window below;
 
379
        char   displayString[256];
 
380
 
 
381
        KeyCode escapeKeyCode;
 
382
        KeyCode returnKeyCode;
 
383
 
 
384
        CompTimer autoRaiseTimer;
 
385
        Window    autoRaiseWindow;
 
386
 
 
387
        CompTimer               edgeDelayTimer;
 
388
        CompDelayedEdgeSettings edgeDelaySettings;
 
389
 
 
390
        CompOption::Value plugin;
 
391
        bool              dirtyPluginList;
 
392
 
 
393
        CompScreen  *screen;
 
394
 
 
395
        CompWindowList windows;
 
396
        CompWindow::Map windowsMap;
 
397
 
 
398
        Colormap colormap;
 
399
        int      screenNum;
 
400
 
 
401
        CompPoint    vp;
 
402
        CompSize     vpSize;
 
403
        unsigned int nDesktop;
 
404
        unsigned int currentDesktop;
 
405
        CompRegion   region;
 
406
 
 
407
        Window        root;
 
408
 
 
409
        XWindowAttributes attrib;
 
410
        Window            grabWindow;
 
411
 
 
412
        int          desktopWindowCount;
 
413
        unsigned int mapNum;
 
414
        unsigned int activeNum;
 
415
 
 
416
        CompOutput::vector outputDevs;
 
417
        int                currentOutputDev;
 
418
        CompOutput         fullscreenOutput;
 
419
        bool               hasOverlappingOutputs;
 
420
 
 
421
        XRectangle lastViewport;
 
422
 
 
423
        CompActiveWindowHistory history[ACTIVE_WINDOW_HISTORY_NUM];
 
424
        int                     currentHistory;
 
425
 
 
426
        CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
 
427
 
 
428
        SnMonitorContext                 *snContext;
 
429
        std::list<CompStartupSequence *> startupSequences;
 
430
        CompTimer                        startupSequenceTimer;
 
431
 
 
432
        std::list<CompGroup *> groups;
 
433
 
 
434
        CompIcon *defaultIcon;
 
435
 
 
436
        Window wmSnSelectionWindow;
 
437
        Atom   wmSnAtom;
 
438
        Time   wmSnTimestamp;
 
439
 
 
440
        Cursor normalCursor;
 
441
        Cursor busyCursor;
 
442
        Cursor invisibleCursor;
 
443
 
 
444
        CompWindowVector clientList;            /* clients in mapping order */
 
445
        CompWindowVector clientListStacking;    /* clients in stacking order */
 
446
 
 
447
        std::vector<Window> clientIdList;        /* client ids in mapping order */
 
448
        std::vector<Window> clientIdListStacking;/* client ids in stacking order */
 
449
 
 
450
        std::list<ButtonGrab> buttonGrabs;
 
451
        std::list<KeyGrab>    keyGrabs;
 
452
 
 
453
        std::list<Grab *> grabs;
 
454
 
 
455
        bool                  grabbed; /* true once we recieve a GrabNotify
 
456
                                          on FocusOut and false on
 
457
                                          UngrabNotify from FocusIn */
 
458
 
 
459
        unsigned int pendingDestroys;
 
460
 
 
461
        CompRect workArea;
 
462
 
 
463
        unsigned int showingDesktopMask;
 
464
 
 
465
        unsigned long *desktopHintData;
 
466
        int           desktopHintSize;
 
467
 
 
468
        bool initialized;
 
469
};
 
470
 
 
471
#endif