~3v1n0/ubuntu/precise/compiz/scale-hotkeys-change

« back to all changes in this revision

Viewing changes to .pc/fix-866752.patch/src/privatescreen.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-10-06 17:57:36 UTC
  • Revision ID: james.westby@ubuntu.com-20111006175736-ra3xnpa8tyy3z7vn
Tags: 1:0.9.6+bzr20110929-0ubuntu4
* debian/control:
  - don't suggest nvidia-glx, it's part of the old initial packaging
    and probably a bad hint on non nvidia system (LP: #844218)
* Cherry-pick upstream patches:
  - Windows should not automatically be focused when opened if the focus
    is on another application (LP: #748840)
  - Launcher - If a spread contains minimised windows, when the spread
    exits, the minimised windows momentarily appear on the desktop
    before disappearing (LP: #863328)
  - reproducible stacking bug in compiz (LP: #869316)
  - Click-dragging a window that's stacked above a fullscreen window will
    cause it to go underneath the fullscreen window (LP: #869919)
  - sometimes the keyboard input doesn't go to the apparently focussed
    dialog (LP: #869967)
  - Opening mumble can cause it to be stacked above the dash if you
    open the dash at the same time (LP: #865863)
  - Sometimes configure events are missed and windows move slow as a result
    (LP: #866752)
  - Workaround ubuntu desktop unity. Mouse at the left side doesn't reveal
    launcher (LP: #832150)

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
#include <time.h>
 
38
 
 
39
#include <glibmm/main.h>
 
40
 
 
41
#include "privatetimeoutsource.h"
 
42
#include "privateiosource.h"
 
43
#include "privateeventsource.h"
 
44
 
 
45
#include "core_options.h"
 
46
 
 
47
CompPlugin::VTable * getCoreVTable ();
 
48
 
 
49
class CoreWindow;
 
50
 
 
51
extern bool shutDown;
 
52
extern bool restartSignal;
 
53
 
 
54
extern CompWindow *lastFoundWindow;
 
55
extern bool       useDesktopHints;
 
56
 
 
57
extern bool inHandleEvent;
 
58
 
 
59
extern CompScreen *targetScreen;
 
60
extern CompOutput *targetOutput;
 
61
 
 
62
extern std::list <CompString> initialPlugins;
 
63
 
 
64
 
 
65
typedef struct _CompDelayedEdgeSettings
 
66
{
 
67
    CompAction::CallBack initiate;
 
68
    CompAction::CallBack terminate;
 
69
 
 
70
    unsigned int edge;
 
71
    unsigned int state;
 
72
 
 
73
    CompOption::Vector options;
 
74
} CompDelayedEdgeSettings;
 
75
 
 
76
 
 
77
#define SCREEN_EDGE_LEFT        0
 
78
#define SCREEN_EDGE_RIGHT       1
 
79
#define SCREEN_EDGE_TOP         2
 
80
#define SCREEN_EDGE_BOTTOM      3
 
81
#define SCREEN_EDGE_TOPLEFT     4
 
82
#define SCREEN_EDGE_TOPRIGHT    5
 
83
#define SCREEN_EDGE_BOTTOMLEFT  6
 
84
#define SCREEN_EDGE_BOTTOMRIGHT 7
 
85
#define SCREEN_EDGE_NUM         8
 
86
 
 
87
struct CompScreenEdge {
 
88
    Window       id;
 
89
    unsigned int count;
 
90
};
 
91
 
 
92
struct CompGroup {
 
93
    unsigned int      refCnt;
 
94
    Window            id;
 
95
};
 
96
 
 
97
struct CompStartupSequence {
 
98
    SnStartupSequence           *sequence;
 
99
    unsigned int                viewportX;
 
100
    unsigned int                viewportY;
 
101
};
 
102
 
 
103
class PrivateScreen :
 
104
    public ValueHolder,
 
105
    public CoreOptions
 
106
{
 
107
 
 
108
    public:
 
109
        class KeyGrab {
 
110
            public:
 
111
                int          keycode;
 
112
                unsigned int modifiers;
 
113
                int          count;
 
114
        };
 
115
 
 
116
        class ButtonGrab {
 
117
            public:
 
118
                int          button;
 
119
                unsigned int modifiers;
 
120
                int          count;
 
121
        };
 
122
 
 
123
        class Grab {
 
124
            public:
 
125
 
 
126
                friend class CompScreen;
 
127
                friend class SpewScreen;
 
128
            private:
 
129
                Cursor     cursor;
 
130
                const char *name;
 
131
        };
 
132
 
 
133
    public:
 
134
        PrivateScreen (CompScreen *screen);
 
135
        ~PrivateScreen ();
 
136
 
 
137
        bool setOption (const CompString &name, CompOption::Value &value);
 
138
 
 
139
        std::list <XEvent> queueEvents ();
 
140
        void processEvents ();
 
141
 
 
142
        void removeDestroyed ();
 
143
 
 
144
        void updatePassiveGrabs ();
 
145
 
 
146
        void updatePlugins ();
 
147
 
 
148
        bool triggerButtonPressBindings (CompOption::Vector &options,
 
149
                                         XButtonEvent       *event,
 
150
                                         CompOption::Vector &arguments);
 
151
 
 
152
        bool triggerButtonReleaseBindings (CompOption::Vector &options,
 
153
                                           XButtonEvent       *event,
 
154
                                           CompOption::Vector &arguments);
 
155
 
 
156
        bool triggerKeyPressBindings (CompOption::Vector &options,
 
157
                                      XKeyEvent          *event,
 
158
                                      CompOption::Vector &arguments);
 
159
 
 
160
        bool triggerKeyReleaseBindings (CompOption::Vector &options,
 
161
                                        XKeyEvent          *event,
 
162
                                        CompOption::Vector &arguments);
 
163
 
 
164
        bool triggerStateNotifyBindings (CompOption::Vector  &options,
 
165
                                         XkbStateNotifyEvent *event,
 
166
                                         CompOption::Vector  &arguments);
 
167
 
 
168
        bool triggerEdgeEnter (unsigned int       edge,
 
169
                               CompAction::State  state,
 
170
                               CompOption::Vector &arguments);
 
171
 
 
172
        void setAudibleBell (bool audible);
 
173
 
 
174
        bool handlePingTimeout ();
 
175
 
 
176
        bool handleActionEvent (XEvent *event);
 
177
 
 
178
        void handleSelectionRequest (XEvent *event);
 
179
 
 
180
        void handleSelectionClear (XEvent *event);
 
181
 
 
182
        bool desktopHintEqual (unsigned long *data,
 
183
                               int           size,
 
184
                               int           offset,
 
185
                               int           hintSize);
 
186
 
 
187
        void setDesktopHints ();
 
188
 
 
189
        void setVirtualScreenSize (int hsize, int vsize);
 
190
 
 
191
        void updateOutputDevices ();
 
192
 
 
193
        void detectOutputDevices ();
 
194
 
 
195
        void updateStartupFeedback ();
 
196
 
 
197
        void updateScreenEdges ();
 
198
 
 
199
        void reshape (int w, int h);
 
200
 
 
201
        bool handleStartupSequenceTimeout ();
 
202
 
 
203
        void addSequence (SnStartupSequence *sequence);
 
204
 
 
205
        void removeSequence (SnStartupSequence *sequence);
 
206
 
 
207
        void removeAllSequences ();
 
208
 
 
209
        void setSupportingWmCheck ();
 
210
 
 
211
        void getDesktopHints ();
 
212
 
 
213
        void grabUngrabOneKey (unsigned int modifiers,
 
214
                               int          keycode,
 
215
                               bool         grab);
 
216
 
 
217
 
 
218
        bool grabUngrabKeys (unsigned int modifiers,
 
219
                             int          keycode,
 
220
                             bool         grab);
 
221
 
 
222
        bool addPassiveKeyGrab (CompAction::KeyBinding &key);
 
223
 
 
224
        void removePassiveKeyGrab (CompAction::KeyBinding &key);
 
225
 
 
226
        void updatePassiveKeyGrabs ();
 
227
 
 
228
        bool addPassiveButtonGrab (CompAction::ButtonBinding &button);
 
229
 
 
230
        void removePassiveButtonGrab (CompAction::ButtonBinding &button);
 
231
 
 
232
        CompRect computeWorkareaForBox (const CompRect &box);
 
233
 
 
234
        void updateScreenInfo ();
 
235
 
 
236
        Window getActiveWindow (Window root);
 
237
 
 
238
        int getWmState (Window id);
 
239
 
 
240
        void setWmState (int state, Window id);
 
241
 
 
242
        unsigned int windowStateMask (Atom state);
 
243
 
 
244
        static unsigned int windowStateFromString (const char *str);
 
245
 
 
246
        unsigned int getWindowState (Window id);
 
247
 
 
248
        void setWindowState (unsigned int state, Window id);
 
249
 
 
250
        unsigned int getWindowType (Window id);
 
251
 
 
252
        void getMwmHints (Window       id,
 
253
                          unsigned int *func,
 
254
                          unsigned int *decor);
 
255
 
 
256
        unsigned int getProtocols (Window id);
 
257
 
 
258
        bool readWindowProp32 (Window         id,
 
259
                               Atom           property,
 
260
                               unsigned short *returnValue);
 
261
 
 
262
        void setCurrentOutput (unsigned int outputNum);
 
263
 
 
264
        void configure (XConfigureEvent *ce);
 
265
 
 
266
        void eraseWindowFromMap (Window id);
 
267
 
 
268
        void updateClientList ();
 
269
 
 
270
        CompGroup * addGroup (Window id);
 
271
 
 
272
        void removeGroup (CompGroup *group);
 
273
 
 
274
        CompGroup * findGroup (Window id);
 
275
 
 
276
        void applyStartupProperties (CompWindow *window);
 
277
 
 
278
        Window getTopWindow ();
 
279
 
 
280
        void setNumberOfDesktops (unsigned int nDesktop);
 
281
 
 
282
        void setCurrentDesktop (unsigned int desktop);
 
283
 
 
284
        void setCurrentActiveWindowHistory (int x, int y);
 
285
 
 
286
        void addToCurrentActiveWindowHistory (Window id);
 
287
 
 
288
        void enableEdge (int edge);
 
289
 
 
290
        void disableEdge (int edge);
 
291
 
 
292
        void addScreenActions ();
 
293
 
 
294
        CompWindow *
 
295
        focusTopMostWindow ();
 
296
 
 
297
        bool
 
298
        createFailed ();
 
299
        
 
300
        void setDefaultWindowAttributes (XWindowAttributes *);
 
301
 
 
302
    public:
 
303
 
 
304
        PrivateScreen *priv;
 
305
 
 
306
        Glib::RefPtr <Glib::MainLoop>  mainloop;
 
307
        // See https://bugzilla.gnome.org/show_bug.cgi?id=561885
 
308
        // Glib::RefPtr <CompEventSource> source;
 
309
        CompEventSource* source;
 
310
        Glib::RefPtr <CompTimeoutSource> timeout;
 
311
        Glib::RefPtr <Glib::MainContext> ctx;
 
312
 
 
313
        CompFileWatchList   fileWatch;
 
314
        CompFileWatchHandle lastFileWatchHandle;
 
315
 
 
316
        std::list<Glib::RefPtr <CompWatchFd> > watchFds;
 
317
        CompWatchFdHandle        lastWatchFdHandle;
 
318
 
 
319
        std::map<CompString, CompPrivate> valueMap;
 
320
 
 
321
        xcb_connection_t *connection;
 
322
 
 
323
        Display    *dpy;
 
324
 
 
325
        int syncEvent, syncError;
 
326
 
 
327
        bool randrExtension;
 
328
        int  randrEvent, randrError;
 
329
 
 
330
        bool shapeExtension;
 
331
        int  shapeEvent, shapeError;
 
332
 
 
333
        bool xkbExtension;
 
334
        int  xkbEvent, xkbError;
 
335
 
 
336
        bool xineramaExtension;
 
337
        int  xineramaEvent, xineramaError;
 
338
 
 
339
        std::vector<XineramaScreenInfo> screenInfo;
 
340
 
 
341
        SnDisplay *snDisplay;
 
342
 
 
343
        unsigned int lastPing;
 
344
        CompTimer    pingTimer;
 
345
 
 
346
        Window activeWindow;
 
347
        Window nextActiveWindow;
 
348
 
 
349
        Window below;
 
350
        char   displayString[256];
 
351
 
 
352
        KeyCode escapeKeyCode;
 
353
        KeyCode returnKeyCode;
 
354
 
 
355
        CompTimer autoRaiseTimer;
 
356
        Window    autoRaiseWindow;
 
357
 
 
358
        CompTimer               edgeDelayTimer;
 
359
        CompDelayedEdgeSettings edgeDelaySettings;
 
360
 
 
361
        CompOption::Value plugin;
 
362
        bool              dirtyPluginList;
 
363
 
 
364
        CompScreen  *screen;
 
365
 
 
366
        std::list <CoreWindow *> createdWindows;
 
367
 
 
368
        /* Window list last sent to server */
 
369
        CompWindowList serverWindows;
 
370
 
 
371
        /* Window list last recv from server */
 
372
        CompWindowList windows;
 
373
        CompWindowList destroyedWindows;
 
374
        bool           stackIsFresh;
 
375
 
 
376
        CompWindow::Map windowsMap;
 
377
 
 
378
        std::map <CompWindow *, CompWindow *> detachedFrameWindows;
 
379
 
 
380
        Colormap colormap;
 
381
        int      screenNum;
 
382
 
 
383
        CompPoint    vp;
 
384
        CompSize     vpSize;
 
385
        unsigned int nDesktop;
 
386
        unsigned int currentDesktop;
 
387
        CompRegion   region;
 
388
 
 
389
        Window        root;
 
390
 
 
391
        XWindowAttributes attrib;
 
392
        Window            grabWindow;
 
393
 
 
394
        int          desktopWindowCount;
 
395
        unsigned int mapNum;
 
396
        unsigned int activeNum;
 
397
 
 
398
        CompOutput::vector outputDevs;
 
399
        int                currentOutputDev;
 
400
        CompOutput         fullscreenOutput;
 
401
        bool               hasOverlappingOutputs;
 
402
 
 
403
        XRectangle lastViewport;
 
404
 
 
405
        CompActiveWindowHistory history[ACTIVE_WINDOW_HISTORY_NUM];
 
406
        int                     currentHistory;
 
407
 
 
408
        CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
 
409
 
 
410
        SnMonitorContext                 *snContext;
 
411
        std::list<CompStartupSequence *> startupSequences;
 
412
        CompTimer                        startupSequenceTimer;
 
413
 
 
414
        std::list<CompGroup *> groups;
 
415
 
 
416
        CompIcon *defaultIcon;
 
417
 
 
418
        Window wmSnSelectionWindow;
 
419
        Atom   wmSnAtom;
 
420
        Time   wmSnTimestamp;
 
421
 
 
422
        Cursor normalCursor;
 
423
        Cursor busyCursor;
 
424
        Cursor invisibleCursor;
 
425
 
 
426
        CompWindowVector clientList;            /* clients in mapping order */
 
427
        CompWindowVector clientListStacking;    /* clients in stacking order */
 
428
 
 
429
        std::vector<Window> clientIdList;        /* client ids in mapping order */
 
430
        std::vector<Window> clientIdListStacking;/* client ids in stacking order */
 
431
 
 
432
        std::list<ButtonGrab> buttonGrabs;
 
433
        std::list<KeyGrab>    keyGrabs;
 
434
 
 
435
        std::list<Grab *> grabs;
 
436
 
 
437
        bool                  grabbed; /* true once we recieve a GrabNotify
 
438
                                          on FocusOut and false on
 
439
                                          UngrabNotify from FocusIn */
 
440
 
 
441
        unsigned int pendingDestroys;
 
442
 
 
443
        CompRect workArea;
 
444
 
 
445
        unsigned int showingDesktopMask;
 
446
 
 
447
        unsigned long *desktopHintData;
 
448
        int           desktopHintSize;
 
449
 
 
450
        Window        edgeWindow;
 
451
        Window        xdndWindow;
 
452
 
 
453
        bool initialized;
 
454
};
 
455
 
 
456
class CompManager
 
457
{
 
458
    public:
 
459
 
 
460
        CompManager ();
 
461
 
 
462
        bool init ();
 
463
        void run ();
 
464
        void fini ();
 
465
 
 
466
        bool parseArguments (int, char **);
 
467
        void usage ();
 
468
 
 
469
        static bool initPlugin (CompPlugin *p);
 
470
        static void finiPlugin (CompPlugin *p);
 
471
 
 
472
    private:
 
473
 
 
474
        std::list <CompString> plugins;
 
475
        bool                   disableSm;
 
476
        char                   *clientId;
 
477
        char                   *displayName;
 
478
};
 
479
 
 
480
#endif