~hypodermia/ubuntu/oneiric/compiz/fix-for-bug-301174

« back to all changes in this revision

Viewing changes to .pc/13_fix_window_geometries_and_properties.patch/src/event.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-02-24 17:31:29 UTC
  • mfrom: (0.167.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110224173129-hsczyk7yw7s21flf
Tags: 1:0.9.4-0ubuntu1
* New upstream release:
  - Fix no windows receiving the focus if someone got the focus then was
    destroyed
  - Fix crash when resizing using keybindings
  - Fix unresponsive inactive decorations (LP: #703755) 
  - Fix the long awaited gconf crash (LP: #691561)
  - gtk-window-decorator doesn't respect special decoration styles
    (LP: #290835)
* debian/compiz-core.links,
  debian/source_compiz.py,
  debian/compiz-core.install:
  - install again a richer apport hook to redirect nux/libunity/unityshell
    crash. It also asks the user to redirect unity issues against unity (still
    incuding xorg info when needed)
* Removed a bunch of patches either cherry-picked or pushed upstream. With the
  other fixes, the gconf workaround is hopefully not needed anymore.
* refresh existing patches to still apply
* debian/control:
  - rename dep on compiz-fusion* to compiz*
* debian/patches/085_add_grid_plugin.patch:
  - refresh the grid plugin from new release
* debian/patches/086_new_grid_defaults.patch
  - separate tweaking the default settings to only have the effect that were
    specified:
    top -> maximize, left (top or bottom left) -> window half left of the
    screen, right (top or bottom right) -> window half right of the screen,
    bottom -> do nothing

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2005 Novell, Inc.
3
 
 *
4
 
 * Permission to use, copy, modify, distribute, and sell this software
5
 
 * and its documentation for any purpose is hereby granted without
6
 
 * fee, provided that the above copyright notice appear in all copies
7
 
 * and that both that copyright notice and this permission notice
8
 
 * appear in supporting documentation, and that the name of
9
 
 * Novell, Inc. not be used in advertising or publicity pertaining to
10
 
 * distribution of the software without specific, written prior permission.
11
 
 * Novell, Inc. makes no representations about the suitability of this
12
 
 * software for any purpose. It is provided "as is" without express or
13
 
 * implied warranty.
14
 
 *
15
 
 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
 
 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
 
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
 
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
 
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
 
 *
23
 
 * Author: David Reveman <davidr@novell.com>
24
 
 */
25
 
 
26
 
#include <stdlib.h>
27
 
#include <string.h>
28
 
 
29
 
#include <boost/bind.hpp>
30
 
#include <boost/foreach.hpp>
31
 
#define foreach BOOST_FOREACH
32
 
 
33
 
#include <X11/Xlib.h>
34
 
#include <X11/Xatom.h>
35
 
#include <X11/extensions/shape.h>
36
 
#include <X11/extensions/Xrandr.h>
37
 
#include <X11/extensions/Xfixes.h>
38
 
 
39
 
#include <core/core.h>
40
 
#include <core/atoms.h>
41
 
#include "privatescreen.h"
42
 
#include "privatewindow.h"
43
 
 
44
 
static Window xdndWindow = None;
45
 
static Window edgeWindow = None;
46
 
 
47
 
 
48
 
 
49
 
bool
50
 
PrivateWindow::handleSyncAlarm ()
51
 
{
52
 
    if (priv->syncWait)
53
 
    {
54
 
        priv->syncWait = false;
55
 
 
56
 
        if (window->resize (priv->syncGeometry))
57
 
        {
58
 
            window->windowNotify (CompWindowNotifySyncAlarm);
59
 
        }
60
 
        else
61
 
        {
62
 
            /* resizeWindow failing means that there is another pending
63
 
               resize and we must send a new sync request to the client */
64
 
            window->sendSyncRequest ();
65
 
        }
66
 
    }
67
 
 
68
 
    return false;
69
 
}
70
 
 
71
 
 
72
 
static bool
73
 
autoRaiseTimeout (CompScreen *screen)
74
 
{
75
 
    CompWindow  *w = screen->findWindow (screen->activeWindow ());
76
 
 
77
 
    if (screen->autoRaiseWindow () == screen->activeWindow () ||
78
 
        (w && (screen->autoRaiseWindow () == w->transientFor ())))
79
 
    {
80
 
        w = screen->findWindow (screen->autoRaiseWindow ());
81
 
        if (w)
82
 
            w->updateAttributes (CompStackingUpdateModeNormal);
83
 
    }
84
 
 
85
 
    return false;
86
 
}
87
 
 
88
 
#define REAL_MOD_MASK (ShiftMask | ControlMask | Mod1Mask | Mod2Mask | \
89
 
                       Mod3Mask | Mod4Mask | Mod5Mask | CompNoMask)
90
 
 
91
 
static bool
92
 
isCallBackBinding (CompOption              &option,
93
 
                   CompAction::BindingType type,
94
 
                   CompAction::State       state)
95
 
{
96
 
    if (!option.isAction ())
97
 
        return false;
98
 
 
99
 
    if (!(option.value ().action ().type () & type))
100
 
        return false;
101
 
 
102
 
    if (!(option.value ().action ().state () & state))
103
 
        return false;
104
 
 
105
 
    return true;
106
 
}
107
 
 
108
 
static bool
109
 
isInitiateBinding (CompOption              &option,
110
 
                   CompAction::BindingType type,
111
 
                   CompAction::State       state,
112
 
                   CompAction              **action)
113
 
{
114
 
    if (!isCallBackBinding (option, type, state))
115
 
        return false;
116
 
 
117
 
    if (option.value ().action ().initiate ().empty ())
118
 
        return false;
119
 
 
120
 
    *action = &option.value ().action ();
121
 
 
122
 
    return true;
123
 
}
124
 
 
125
 
static bool
126
 
isTerminateBinding (CompOption              &option,
127
 
                    CompAction::BindingType type,
128
 
                    CompAction::State       state,
129
 
                    CompAction              **action)
130
 
{
131
 
    if (!isCallBackBinding (option, type, state))
132
 
        return false;
133
 
 
134
 
    if (option.value ().action ().terminate ().empty ())
135
 
        return false;
136
 
 
137
 
    *action = &option.value ().action ();
138
 
 
139
 
    return true;
140
 
}
141
 
 
142
 
bool
143
 
PrivateScreen::triggerButtonPressBindings (CompOption::Vector &options,
144
 
                                           XButtonEvent       *event,
145
 
                                           CompOption::Vector &arguments)
146
 
{
147
 
    CompAction::State state = CompAction::StateInitButton;
148
 
    CompAction        *action;
149
 
    unsigned int      ignored = modHandler->ignoredModMask ();
150
 
    unsigned int      modMask = REAL_MOD_MASK & ~ignored;
151
 
    unsigned int      bindMods;
152
 
    unsigned int      edge = 0;
153
 
 
154
 
    if (edgeWindow)
155
 
    {
156
 
        unsigned int i;
157
 
 
158
 
        if (event->root != root)
159
 
            return false;
160
 
 
161
 
        if (event->window != edgeWindow)
162
 
        {
163
 
            if (grabs.empty () || event->window != root)
164
 
                return false;
165
 
        }
166
 
 
167
 
        for (i = 0; i < SCREEN_EDGE_NUM; i++)
168
 
        {
169
 
            if (edgeWindow == screenEdge[i].id)
170
 
            {
171
 
                edge = 1 << i;
172
 
                arguments[1].value ().set ((int) activeWindow);
173
 
                break;
174
 
            }
175
 
        }
176
 
    }
177
 
 
178
 
    foreach (CompOption &option, options)
179
 
    {
180
 
        if (isInitiateBinding (option, CompAction::BindingTypeButton, state,
181
 
                               &action))
182
 
        {
183
 
            if (action->button ().button () == (int) event->button)
184
 
            {
185
 
                bindMods = modHandler->virtualToRealModMask (
186
 
                    action->button ().modifiers ());
187
 
 
188
 
                if ((bindMods & modMask) == (event->state & modMask))
189
 
                    if (action->initiate () (action, state, arguments))
190
 
                        return true;
191
 
            }
192
 
        }
193
 
 
194
 
        if (edge)
195
 
        {
196
 
            if (isInitiateBinding (option, CompAction::BindingTypeEdgeButton,
197
 
                                   state | CompAction::StateInitEdge, &action))
198
 
            {
199
 
                if ((action->button ().button () == (int) event->button) &&
200
 
                    (action->edgeMask () & edge))
201
 
                {
202
 
                    bindMods = modHandler->virtualToRealModMask (
203
 
                        action->button ().modifiers ());
204
 
 
205
 
                    if ((bindMods & modMask) == (event->state & modMask))
206
 
                        if (action->initiate () (action, state |
207
 
                                                 CompAction::StateInitEdge,
208
 
                                                 arguments))
209
 
                            return true;
210
 
                }
211
 
            }
212
 
        }
213
 
    }
214
 
 
215
 
    return false;
216
 
}
217
 
 
218
 
bool
219
 
PrivateScreen::triggerButtonReleaseBindings (CompOption::Vector &options,
220
 
                                             XButtonEvent       *event,
221
 
                                             CompOption::Vector &arguments)
222
 
{
223
 
    CompAction::State       state = CompAction::StateTermButton;
224
 
    CompAction::BindingType type  = CompAction::BindingTypeButton |
225
 
                                    CompAction::BindingTypeEdgeButton;
226
 
    CompAction              *action;
227
 
 
228
 
    foreach (CompOption &option, options)
229
 
    {
230
 
        if (isTerminateBinding (option, type, state, &action))
231
 
        {
232
 
            if (action->button ().button () == (int) event->button)
233
 
            {
234
 
                if (action->terminate () (action, state, arguments))
235
 
                    return true;
236
 
            }
237
 
        }
238
 
    }
239
 
 
240
 
    return false;
241
 
}
242
 
 
243
 
bool
244
 
PrivateScreen::triggerKeyPressBindings (CompOption::Vector &options,
245
 
                                        XKeyEvent          *event,
246
 
                                        CompOption::Vector &arguments)
247
 
{
248
 
    CompAction::State state = 0;
249
 
    CompAction        *action;
250
 
    unsigned int      modMask = REAL_MOD_MASK & ~modHandler->ignoredModMask ();
251
 
    unsigned int      bindMods;
252
 
 
253
 
    if (event->keycode == escapeKeyCode)
254
 
        state = CompAction::StateCancel;
255
 
    else if (event->keycode == returnKeyCode)
256
 
        state = CompAction::StateCommit;
257
 
 
258
 
    if (state)
259
 
    {
260
 
        foreach (CompOption &o, options)
261
 
        {
262
 
            if (o.isAction ())
263
 
            {
264
 
                if (!o.value ().action ().terminate ().empty ())
265
 
                    o.value ().action ().terminate () (&o.value ().action (),
266
 
                                                       state, noOptions);
267
 
            }
268
 
        }
269
 
 
270
 
        if (state == CompAction::StateCancel)
271
 
            return false;
272
 
    }
273
 
 
274
 
    state = CompAction::StateInitKey;
275
 
    foreach (CompOption &option, options)
276
 
    {
277
 
        if (isInitiateBinding (option, CompAction::BindingTypeKey,
278
 
                               state, &action))
279
 
        {
280
 
            bindMods = modHandler->virtualToRealModMask (
281
 
                action->key ().modifiers ());
282
 
 
283
 
            if (action->key ().keycode () == (int) event->keycode)
284
 
            {
285
 
                if ((bindMods & modMask) == (event->state & modMask))
286
 
                    if (action->initiate () (action, state, arguments))
287
 
                        return true;
288
 
            }
289
 
            else if (!xkbEvent && action->key ().keycode () == 0)
290
 
            {
291
 
                if (bindMods == (event->state & modMask))
292
 
                    if (action->initiate () (action, state, arguments))
293
 
                        return true;
294
 
            }
295
 
        }
296
 
    }
297
 
 
298
 
    return false;
299
 
}
300
 
 
301
 
bool
302
 
PrivateScreen::triggerKeyReleaseBindings (CompOption::Vector &options,
303
 
                                          XKeyEvent          *event,
304
 
                                          CompOption::Vector &arguments)
305
 
{
306
 
    CompAction::State state = CompAction::StateTermKey;
307
 
    CompAction        *action;
308
 
    unsigned int      ignored = modHandler->ignoredModMask ();
309
 
    unsigned int      modMask = REAL_MOD_MASK & ~ignored;
310
 
    unsigned int      bindMods;
311
 
    unsigned int      mods;
312
 
 
313
 
    mods = modHandler->keycodeToModifiers (event->keycode);
314
 
    if (!xkbEvent && !mods)
315
 
        return false;
316
 
 
317
 
    foreach (CompOption &option, options)
318
 
    {
319
 
        if (isTerminateBinding (option, CompAction::BindingTypeKey,
320
 
                                state, &action))
321
 
        {
322
 
            bindMods = modHandler->virtualToRealModMask (action->key ().modifiers ());
323
 
 
324
 
            if ((bindMods & modMask) == 0)
325
 
            {
326
 
                if ((unsigned int) action->key ().keycode () ==
327
 
                                                  (unsigned int) event->keycode)
328
 
                {
329
 
                    if (action->terminate () (action, state, arguments))
330
 
                        return true;
331
 
                }
332
 
            }
333
 
            else if (!xkbEvent && ((mods & modMask & bindMods) != bindMods))
334
 
            {
335
 
                if (action->terminate () (action, state, arguments))
336
 
                    return true;
337
 
            }
338
 
        }
339
 
    }
340
 
 
341
 
    return false;
342
 
}
343
 
 
344
 
bool
345
 
PrivateScreen::triggerStateNotifyBindings (CompOption::Vector  &options,
346
 
                                           XkbStateNotifyEvent *event,
347
 
                                           CompOption::Vector  &arguments)
348
 
{
349
 
    CompAction::State state;
350
 
    CompAction        *action;
351
 
    unsigned int      ignored = modHandler->ignoredModMask ();
352
 
    unsigned int      modMask = REAL_MOD_MASK & ~ignored;
353
 
    unsigned int      bindMods;
354
 
 
355
 
    if (event->event_type == KeyPress)
356
 
    {
357
 
        state = CompAction::StateInitKey;
358
 
 
359
 
        foreach (CompOption &option, options)
360
 
        {
361
 
            if (isInitiateBinding (option, CompAction::BindingTypeKey,
362
 
                                   state, &action))
363
 
            {
364
 
                if (action->key ().keycode () == 0)
365
 
                {
366
 
                    bindMods =
367
 
                        modHandler->virtualToRealModMask (action->key ().modifiers ());
368
 
 
369
 
                    if ((event->mods & modMask & bindMods) == bindMods)
370
 
                    {
371
 
                        if (action->initiate () (action, state, arguments))
372
 
                            return true;
373
 
                    }
374
 
                }
375
 
            }
376
 
        }
377
 
    }
378
 
    else
379
 
    {
380
 
        state = CompAction::StateTermKey;
381
 
 
382
 
        foreach (CompOption &option, options)
383
 
        {
384
 
            if (isTerminateBinding (option, CompAction::BindingTypeKey,
385
 
                                    state, &action))
386
 
            {
387
 
                bindMods = modHandler->virtualToRealModMask (action->key ().modifiers ());
388
 
 
389
 
                if ((event->mods & modMask & bindMods) != bindMods)
390
 
                {
391
 
                    if (action->terminate () (action, state, arguments))
392
 
                        return true;
393
 
                }
394
 
            }
395
 
        }
396
 
    }
397
 
 
398
 
    return false;
399
 
}
400
 
 
401
 
static bool
402
 
isBellAction (CompOption        &option,
403
 
              CompAction::State state,
404
 
              CompAction        **action)
405
 
{
406
 
    if (option.type () != CompOption::TypeAction &&
407
 
        option.type () != CompOption::TypeBell)
408
 
        return false;
409
 
 
410
 
    if (!option.value ().action ().bell ())
411
 
        return false;
412
 
 
413
 
    if (!(option.value ().action ().state () & state))
414
 
        return false;
415
 
 
416
 
    if (option.value ().action ().initiate ().empty ())
417
 
        return false;
418
 
 
419
 
    *action = &option.value ().action ();
420
 
 
421
 
    return true;
422
 
}
423
 
 
424
 
static bool
425
 
triggerBellNotifyBindings (CompOption::Vector &options,
426
 
                           CompOption::Vector &arguments)
427
 
{
428
 
    CompAction::State state = CompAction::StateInitBell;
429
 
    CompAction        *action;
430
 
 
431
 
    foreach (CompOption &option, options)
432
 
    {
433
 
        if (isBellAction (option, state, &action))
434
 
        {
435
 
            if (action->initiate () (action, state, arguments))
436
 
                return true;
437
 
        }
438
 
    }
439
 
 
440
 
    return false;
441
 
}
442
 
 
443
 
static bool
444
 
isEdgeAction (CompOption        &option,
445
 
              CompAction::State state,
446
 
              unsigned int      edge)
447
 
{
448
 
    if (option.type () != CompOption::TypeAction &&
449
 
        option.type () != CompOption::TypeButton &&
450
 
        option.type () != CompOption::TypeEdge)
451
 
        return false;
452
 
 
453
 
    if (!(option.value ().action ().edgeMask () & edge))
454
 
        return false;
455
 
 
456
 
    if (!(option.value ().action ().state () & state))
457
 
        return false;
458
 
 
459
 
    return true;
460
 
}
461
 
 
462
 
static bool
463
 
isEdgeEnterAction (CompOption        &option,
464
 
                   CompAction::State state,
465
 
                   CompAction::State delayState,
466
 
                   unsigned int      edge,
467
 
                   CompAction        **action)
468
 
{
469
 
    if (!isEdgeAction (option, state, edge))
470
 
        return false;
471
 
 
472
 
    if (option.value ().action ().type () & CompAction::BindingTypeEdgeButton)
473
 
        return false;
474
 
 
475
 
    if (option.value ().action ().initiate ().empty ())
476
 
        return false;
477
 
 
478
 
    if (delayState)
479
 
    {
480
 
        if ((option.value ().action ().state () &
481
 
             CompAction::StateNoEdgeDelay) !=
482
 
            (delayState & CompAction::StateNoEdgeDelay))
483
 
        {
484
 
            /* ignore edge actions which shouldn't be delayed when invoking
485
 
               undelayed edges (or vice versa) */
486
 
            return false;
487
 
        }
488
 
    }
489
 
 
490
 
 
491
 
    *action = &option.value ().action ();
492
 
 
493
 
    return true;
494
 
}
495
 
 
496
 
static bool
497
 
isEdgeLeaveAction (CompOption        &option,
498
 
                   CompAction::State state,
499
 
                   unsigned int      edge,
500
 
                   CompAction        **action)
501
 
{
502
 
    if (!isEdgeAction (option, state, edge))
503
 
        return false;
504
 
 
505
 
    if (option.value ().action ().terminate ().empty ())
506
 
        return false;
507
 
 
508
 
    *action = &option.value ().action ();
509
 
 
510
 
    return true;
511
 
}
512
 
 
513
 
static bool
514
 
triggerEdgeEnterBindings (CompOption::Vector &options,
515
 
                          CompAction::State  state,
516
 
                          CompAction::State  delayState,
517
 
                          unsigned int       edge,
518
 
                          CompOption::Vector &arguments)
519
 
{
520
 
    CompAction *action;
521
 
 
522
 
    foreach (CompOption &option, options)
523
 
    {
524
 
        if (isEdgeEnterAction (option, state, delayState, edge, &action))
525
 
        {
526
 
            if (action->initiate () (action, state, arguments))
527
 
                return true;
528
 
        }
529
 
    }
530
 
 
531
 
    return false;
532
 
}
533
 
 
534
 
static bool
535
 
triggerEdgeLeaveBindings (CompOption::Vector &options,
536
 
                          CompAction::State  state,
537
 
                          unsigned int       edge,
538
 
                          CompOption::Vector &arguments)
539
 
{
540
 
    CompAction *action;
541
 
 
542
 
    foreach (CompOption &option, options)
543
 
    {
544
 
        if (isEdgeLeaveAction (option, state, edge, &action))
545
 
        {
546
 
            if (action->terminate () (action, state, arguments))
547
 
                return true;
548
 
        }
549
 
    }
550
 
 
551
 
    return false;
552
 
}
553
 
 
554
 
static bool
555
 
triggerAllEdgeEnterBindings (CompAction::State  state,
556
 
                             CompAction::State  delayState,
557
 
                             unsigned int       edge,
558
 
                             CompOption::Vector &arguments)
559
 
{
560
 
    foreach (CompPlugin *p, CompPlugin::getPlugins ())
561
 
    {
562
 
        CompOption::Vector &options = p->vTable->getOptions ();
563
 
        if (triggerEdgeEnterBindings (options, state, delayState, edge,
564
 
                                      arguments))
565
 
        {
566
 
            return true;
567
 
        }
568
 
    }
569
 
    return false;
570
 
}
571
 
 
572
 
static bool
573
 
delayedEdgeTimeout (CompDelayedEdgeSettings *settings)
574
 
{
575
 
    triggerAllEdgeEnterBindings (settings->state,
576
 
                                 ~CompAction::StateNoEdgeDelay,
577
 
                                 settings->edge,
578
 
                                 settings->options);
579
 
 
580
 
    return false;
581
 
}
582
 
 
583
 
bool
584
 
PrivateScreen::triggerEdgeEnter (unsigned int       edge,
585
 
                                 CompAction::State  state,
586
 
                                 CompOption::Vector &arguments)
587
 
{
588
 
    int                     delay;
589
 
 
590
 
    delay = optionGetEdgeDelay ();
591
 
 
592
 
    if (delay > 0)
593
 
    {
594
 
        CompAction::State delayState;
595
 
        edgeDelaySettings.edge    = edge;
596
 
        edgeDelaySettings.state   = state;
597
 
        edgeDelaySettings.options = arguments;
598
 
 
599
 
        edgeDelayTimer.start  (
600
 
            boost::bind (delayedEdgeTimeout, &edgeDelaySettings),
601
 
                         delay, (unsigned int) ((float) delay * 1.2));
602
 
 
603
 
        delayState = CompAction::StateNoEdgeDelay;
604
 
        if (triggerAllEdgeEnterBindings (state, delayState, edge, arguments))
605
 
            return true;
606
 
    }
607
 
    else
608
 
    {
609
 
        if (triggerAllEdgeEnterBindings (state, 0, edge, arguments))
610
 
            return true;
611
 
    }
612
 
 
613
 
    return false;
614
 
}
615
 
 
616
 
bool
617
 
PrivateScreen::handleActionEvent (XEvent *event)
618
 
{
619
 
    static CompOption::Vector o (8);
620
 
    Window xid;
621
 
 
622
 
    o[0].setName ("event_window", CompOption::TypeInt);
623
 
    o[1].setName ("window", CompOption::TypeInt);
624
 
    o[2].setName ("modifiers", CompOption::TypeInt);
625
 
    o[3].setName ("x", CompOption::TypeInt);
626
 
    o[4].setName ("y", CompOption::TypeInt);
627
 
    o[5].setName ("root", CompOption::TypeInt);
628
 
    o[6].reset ();
629
 
    o[7].reset ();
630
 
 
631
 
    switch (event->type) {
632
 
    case ButtonPress:
633
 
        /* We need to determine if we clicked on a parent frame
634
 
         * window, if so, pass the appropriate child window as
635
 
         * "window" and the frame as "event_window"
636
 
         */
637
 
 
638
 
        xid = event->xbutton.window;
639
 
 
640
 
        foreach (CompWindow *w, screen->windows ())
641
 
        {
642
 
            if (w->frame () == xid)
643
 
                xid = w->id ();
644
 
        }
645
 
 
646
 
        o[0].value ().set ((int) event->xbutton.window);
647
 
        o[1].value ().set ((int) xid);
648
 
        o[2].value ().set ((int) event->xbutton.state);
649
 
        o[3].value ().set ((int) event->xbutton.x_root);
650
 
        o[4].value ().set ((int) event->xbutton.y_root);
651
 
        o[5].value ().set ((int) event->xbutton.root);
652
 
 
653
 
        o[6].setName ("button", CompOption::TypeInt);
654
 
        o[7].setName ("time", CompOption::TypeInt);
655
 
 
656
 
        o[6].value ().set ((int) event->xbutton.button);
657
 
        o[7].value ().set ((int) event->xbutton.time);
658
 
 
659
 
        foreach (CompPlugin *p, CompPlugin::getPlugins ())
660
 
        {
661
 
            CompOption::Vector &options = p->vTable->getOptions ();
662
 
            if (triggerButtonPressBindings (options, &event->xbutton, o))
663
 
                return true;
664
 
        }
665
 
        break;
666
 
    case ButtonRelease:
667
 
        o[0].value ().set ((int) event->xbutton.window);
668
 
        o[1].value ().set ((int) event->xbutton.window);
669
 
        o[2].value ().set ((int) event->xbutton.state);
670
 
        o[3].value ().set ((int) event->xbutton.x_root);
671
 
        o[4].value ().set ((int) event->xbutton.y_root);
672
 
        o[5].value ().set ((int) event->xbutton.root);
673
 
 
674
 
        o[6].setName ("button", CompOption::TypeInt);
675
 
        o[7].setName ("time", CompOption::TypeInt);
676
 
 
677
 
        o[6].value ().set ((int) event->xbutton.button);
678
 
        o[7].value ().set ((int) event->xbutton.time);
679
 
 
680
 
        foreach (CompPlugin *p, CompPlugin::getPlugins ())
681
 
        {
682
 
            CompOption::Vector &options = p->vTable->getOptions ();
683
 
            if (triggerButtonReleaseBindings (options, &event->xbutton, o))
684
 
                return true;
685
 
        }
686
 
        break;
687
 
    case KeyPress:
688
 
        o[0].value ().set ((int) event->xkey.window);
689
 
        o[1].value ().set ((int) activeWindow);
690
 
        o[2].value ().set ((int) event->xkey.state);
691
 
        o[3].value ().set ((int) event->xkey.x_root);
692
 
        o[4].value ().set ((int) event->xkey.y_root);
693
 
        o[5].value ().set ((int) event->xkey.root);
694
 
 
695
 
        o[6].setName ("keycode", CompOption::TypeInt);
696
 
        o[7].setName ("time", CompOption::TypeInt);
697
 
 
698
 
        o[6].value ().set ((int) event->xkey.keycode);
699
 
        o[7].value ().set ((int) event->xkey.time);
700
 
 
701
 
        foreach (CompPlugin *p, CompPlugin::getPlugins ())
702
 
        {
703
 
            CompOption::Vector &options = p->vTable->getOptions ();
704
 
            if (triggerKeyPressBindings (options, &event->xkey, o))
705
 
                return true;
706
 
        }
707
 
        break;
708
 
    case KeyRelease:
709
 
        o[0].value ().set ((int) event->xkey.window);
710
 
        o[1].value ().set ((int) activeWindow);
711
 
        o[2].value ().set ((int) event->xkey.state);
712
 
        o[3].value ().set ((int) event->xkey.x_root);
713
 
        o[4].value ().set ((int) event->xkey.y_root);
714
 
        o[5].value ().set ((int) event->xkey.root);
715
 
 
716
 
        o[6].setName ("keycode", CompOption::TypeInt);
717
 
        o[7].setName ("time", CompOption::TypeInt);
718
 
 
719
 
        o[6].value ().set ((int) event->xkey.keycode);
720
 
        o[7].value ().set ((int) event->xkey.time);
721
 
 
722
 
        foreach (CompPlugin *p, CompPlugin::getPlugins ())
723
 
        {
724
 
            CompOption::Vector &options = p->vTable->getOptions ();
725
 
            if (triggerKeyReleaseBindings (options, &event->xkey, o))
726
 
                return true;
727
 
        }
728
 
        break;
729
 
    case EnterNotify:
730
 
        if (event->xcrossing.mode   != NotifyGrab   &&
731
 
            event->xcrossing.mode   != NotifyUngrab &&
732
 
            event->xcrossing.detail != NotifyInferior)
733
 
        {
734
 
            unsigned int      edge, i;
735
 
            CompAction::State state;
736
 
 
737
 
            if (event->xcrossing.root != root)
738
 
                return false;
739
 
 
740
 
            if (edgeDelayTimer.active ())
741
 
                edgeDelayTimer.stop ();
742
 
 
743
 
            if (edgeWindow && edgeWindow != event->xcrossing.window)
744
 
            {
745
 
                state = CompAction::StateTermEdge;
746
 
                edge  = 0;
747
 
 
748
 
                for (i = 0; i < SCREEN_EDGE_NUM; i++)
749
 
                {
750
 
                    if (edgeWindow == screenEdge[i].id)
751
 
                    {
752
 
                        edge = 1 << i;
753
 
                        break;
754
 
                    }
755
 
                }
756
 
 
757
 
                edgeWindow = None;
758
 
 
759
 
                o[0].value ().set ((int) event->xcrossing.window);
760
 
                o[1].value ().set ((int) activeWindow);
761
 
                o[2].value ().set ((int) event->xcrossing.state);
762
 
                o[3].value ().set ((int) event->xcrossing.x_root);
763
 
                o[4].value ().set ((int) event->xcrossing.y_root);
764
 
                o[5].value ().set ((int) event->xcrossing.root);
765
 
 
766
 
                o[6].setName ("time", CompOption::TypeInt);
767
 
                o[6].value ().set ((int) event->xcrossing.time);
768
 
 
769
 
                foreach (CompPlugin *p, CompPlugin::getPlugins ())
770
 
                {
771
 
                    CompOption::Vector &options = p->vTable->getOptions ();
772
 
                    if (triggerEdgeLeaveBindings (options, state, edge, o))
773
 
                        return true;
774
 
                }
775
 
            }
776
 
 
777
 
            edge = 0;
778
 
 
779
 
            for (i = 0; i < SCREEN_EDGE_NUM; i++)
780
 
            {
781
 
                if (event->xcrossing.window == screenEdge[i].id)
782
 
                {
783
 
                    edge = 1 << i;
784
 
                    break;
785
 
                }
786
 
            }
787
 
 
788
 
            if (edge)
789
 
            {
790
 
                state = CompAction::StateInitEdge;
791
 
 
792
 
                edgeWindow = event->xcrossing.window;
793
 
 
794
 
                o[0].value ().set ((int) event->xcrossing.window);
795
 
                o[1].value ().set ((int) activeWindow);
796
 
                o[2].value ().set ((int) event->xcrossing.state);
797
 
                o[3].value ().set ((int) event->xcrossing.x_root);
798
 
                o[4].value ().set ((int) event->xcrossing.y_root);
799
 
                o[5].value ().set ((int) event->xcrossing.root);
800
 
 
801
 
                o[6].setName ("time", CompOption::TypeInt);
802
 
                o[6].value ().set ((int) event->xcrossing.time);
803
 
 
804
 
                if (triggerEdgeEnter (edge, state, o))
805
 
                    return true;
806
 
            }
807
 
        }
808
 
        break;
809
 
    case ClientMessage:
810
 
        if (event->xclient.message_type == Atoms::xdndEnter)
811
 
        {
812
 
            xdndWindow = event->xclient.window;
813
 
        }
814
 
        else if (event->xclient.message_type == Atoms::xdndLeave)
815
 
        {
816
 
            unsigned int      edge = 0;
817
 
            CompAction::State state;
818
 
 
819
 
            if (!xdndWindow)
820
 
            {
821
 
                CompWindow *w;
822
 
 
823
 
                w = screen->findWindow (event->xclient.window);
824
 
                if (w)
825
 
                {
826
 
                    unsigned int i;
827
 
 
828
 
                    for (i = 0; i < SCREEN_EDGE_NUM; i++)
829
 
                    {
830
 
                        if (event->xclient.window == screenEdge[i].id)
831
 
                        {
832
 
                            edge = 1 << i;
833
 
                            break;
834
 
                        }
835
 
                    }
836
 
                }
837
 
            }
838
 
 
839
 
            if (edge)
840
 
            {
841
 
                state = CompAction::StateTermEdgeDnd;
842
 
 
843
 
                o[0].value ().set ((int) event->xclient.window);
844
 
                o[1].value ().set ((int) activeWindow);
845
 
                o[2].value ().set ((int) 0); /* fixme */
846
 
                o[3].value ().set ((int) 0); /* fixme */
847
 
                o[4].value ().set ((int) 0); /* fixme */
848
 
                o[5].value ().set ((int) root);
849
 
 
850
 
                foreach (CompPlugin *p, CompPlugin::getPlugins ())
851
 
                {
852
 
                    CompOption::Vector &options = p->vTable->getOptions ();
853
 
                    if (triggerEdgeLeaveBindings (options, state, edge, o))
854
 
                        return true;
855
 
                }
856
 
            }
857
 
        }
858
 
        else if (event->xclient.message_type == Atoms::xdndPosition)
859
 
        {
860
 
            unsigned int      edge = 0;
861
 
            CompAction::State state;
862
 
 
863
 
            if (xdndWindow == event->xclient.window)
864
 
            {
865
 
                CompWindow *w;
866
 
 
867
 
                w = screen->findWindow (event->xclient.window);
868
 
                if (w)
869
 
                {
870
 
                    unsigned int i;
871
 
 
872
 
                    for (i = 0; i < SCREEN_EDGE_NUM; i++)
873
 
                    {
874
 
                        if (xdndWindow == screenEdge[i].id)
875
 
                        {
876
 
                            edge = 1 << i;
877
 
                            break;
878
 
                        }
879
 
                    }
880
 
                }
881
 
            }
882
 
 
883
 
            if (edge)
884
 
            {
885
 
                state = CompAction::StateInitEdgeDnd;
886
 
 
887
 
                o[0].value ().set ((int) event->xclient.window);
888
 
                o[1].value ().set ((int) activeWindow);
889
 
                o[2].value ().set ((int) 0); /* fixme */
890
 
                o[3].value ().set ((int) event->xclient.data.l[2] >> 16);
891
 
                o[4].value ().set ((int) event->xclient.data.l[2] & 0xffff);
892
 
                o[5].value ().set ((int) root);
893
 
 
894
 
                if (triggerEdgeEnter (edge, state, o))
895
 
                    return true;
896
 
            }
897
 
 
898
 
            xdndWindow = None;
899
 
        }
900
 
        break;
901
 
    default:
902
 
        if (event->type == xkbEvent)
903
 
        {
904
 
            XkbAnyEvent *xkbEvent = (XkbAnyEvent *) event;
905
 
 
906
 
            if (xkbEvent->xkb_type == XkbStateNotify)
907
 
            {
908
 
                XkbStateNotifyEvent *stateEvent = (XkbStateNotifyEvent *) event;
909
 
 
910
 
                o[0].value ().set ((int) activeWindow);
911
 
                o[1].value ().set ((int) activeWindow);
912
 
                o[2].value ().set ((int) stateEvent->mods);
913
 
 
914
 
                o[3].setName ("time", CompOption::TypeInt);
915
 
                o[3].value ().set ((int) xkbEvent->time);
916
 
                o[4].reset ();
917
 
                o[5].reset ();
918
 
 
919
 
                foreach (CompPlugin *p, CompPlugin::getPlugins ())
920
 
                {
921
 
                    CompOption::Vector &options = p->vTable->getOptions ();
922
 
                    if (triggerStateNotifyBindings (options, stateEvent, o))
923
 
                        return true;
924
 
                }
925
 
            }
926
 
            else if (xkbEvent->xkb_type == XkbBellNotify)
927
 
            {
928
 
                o[0].value ().set ((int) activeWindow);
929
 
                o[1].value ().set ((int) activeWindow);
930
 
 
931
 
                o[2].setName ("time", CompOption::TypeInt);
932
 
                o[2].value ().set ((int) xkbEvent->time);
933
 
                o[3].reset ();
934
 
                o[4].reset ();
935
 
                o[5].reset ();
936
 
 
937
 
 
938
 
                foreach (CompPlugin *p, CompPlugin::getPlugins ())
939
 
                {
940
 
                    CompOption::Vector &options = p->vTable->getOptions ();
941
 
                    if (triggerBellNotifyBindings (options, o))
942
 
                        return true;
943
 
                }
944
 
            }
945
 
        }
946
 
        break;
947
 
    }
948
 
 
949
 
    return false;
950
 
}
951
 
 
952
 
void
953
 
PrivateScreen::setDefaultWindowAttributes (XWindowAttributes *wa)
954
 
{
955
 
    wa->x                     = 0;
956
 
    wa->y                     = 0;
957
 
    wa->width                 = 1;
958
 
    wa->height                = 1;
959
 
    wa->border_width          = 0;
960
 
    wa->depth                 = 0;
961
 
    wa->visual                = NULL;
962
 
    wa->root                  = None;
963
 
    wa->c_class               = InputOnly;
964
 
    wa->bit_gravity           = NorthWestGravity;
965
 
    wa->win_gravity           = NorthWestGravity;
966
 
    wa->backing_store         = NotUseful;
967
 
    wa->backing_planes        = 0;
968
 
    wa->backing_pixel         = 0;
969
 
    wa->save_under            = false;
970
 
    wa->colormap              = None;
971
 
    wa->map_installed         = false;
972
 
    wa->map_state             = IsUnviewable;
973
 
    wa->all_event_masks       = 0;
974
 
    wa->your_event_mask       = 0;
975
 
    wa->do_not_propagate_mask = 0;
976
 
    wa->override_redirect     = true;
977
 
    wa->screen                = NULL;
978
 
}
979
 
 
980
 
void
981
 
CompScreen::handleCompizEvent (const char         *plugin,
982
 
                               const char         *event,
983
 
                               CompOption::Vector &options)
984
 
    WRAPABLE_HND_FUNC (7, handleCompizEvent, plugin, event, options)
985
 
 
986
 
void
987
 
CompScreen::handleEvent (XEvent *event)
988
 
{
989
 
    WRAPABLE_HND_FUNC (6, handleEvent, event)
990
 
 
991
 
    CompWindow *w = NULL;
992
 
    XWindowAttributes wa;
993
 
 
994
 
    switch (event->type) {
995
 
    case ButtonPress:
996
 
        if (event->xbutton.root == priv->root)
997
 
            priv->setCurrentOutput (
998
 
                outputDeviceForPoint (event->xbutton.x_root,
999
 
                                                 event->xbutton.y_root));
1000
 
        break;
1001
 
    case MotionNotify:
1002
 
        if (event->xmotion.root == priv->root)
1003
 
            priv->setCurrentOutput (
1004
 
                outputDeviceForPoint (event->xmotion.x_root,
1005
 
                                      event->xmotion.y_root));
1006
 
        break;
1007
 
    case KeyPress:
1008
 
        w = findWindow (priv->activeWindow);
1009
 
        if (w)
1010
 
            priv->setCurrentOutput (w->outputDevice ());
1011
 
        break;
1012
 
    default:
1013
 
        break;
1014
 
    }
1015
 
 
1016
 
    if (priv->handleActionEvent (event))
1017
 
    {
1018
 
        if (priv->grabs.empty ())
1019
 
            XAllowEvents (priv->dpy, AsyncPointer, event->xbutton.time);
1020
 
 
1021
 
        return;
1022
 
    }
1023
 
 
1024
 
    switch (event->type) {
1025
 
    case SelectionRequest:
1026
 
        priv->handleSelectionRequest (event);
1027
 
        break;
1028
 
    case SelectionClear:
1029
 
        priv->handleSelectionClear (event);
1030
 
        break;
1031
 
    case ConfigureNotify:
1032
 
        w = findWindow (event->xconfigure.window);
1033
 
        if (w && !w->frame ())
1034
 
        {
1035
 
            w->priv->configure (&event->xconfigure);
1036
 
        }
1037
 
        else
1038
 
        {
1039
 
            w = findTopLevelWindow (event->xconfigure.window);
1040
 
 
1041
 
            if (w && w->frame () == event->xconfigure.window)
1042
 
            {
1043
 
                w->priv->configureFrame (&event->xconfigure);
1044
 
            }
1045
 
            else
1046
 
            {
1047
 
                if (event->xconfigure.window == priv->root)
1048
 
                    priv->configure (&event->xconfigure);
1049
 
            }
1050
 
        }
1051
 
        break;
1052
 
    case CreateNotify:
1053
 
    {
1054
 
        bool failure = false;
1055
 
 
1056
 
        /* Failure means that window has been destroyed. We still have to add 
1057
 
         * the window to the window list as we might get configure requests
1058
 
         * which require us to stack other windows relative to it. Setting
1059
 
         * some default values if this is the case. */
1060
 
        if ((failure = !XGetWindowAttributes (priv->dpy, event->xcreatewindow.window, &wa)))
1061
 
            priv->setDefaultWindowAttributes (&wa);
1062
 
 
1063
 
        w = findTopLevelWindow (event->xcreatewindow.window, true);
1064
 
 
1065
 
        if ((event->xcreatewindow.parent == wa.root || failure) &&
1066
 
            (!w || w->frame () != event->xcreatewindow.window))
1067
 
        {
1068
 
            /* Track the window if it was created on this
1069
 
             * screen, otherwise we still need to register
1070
 
             * for FocusChangeMask. Also, we don't want to
1071
 
             * manage it straight away - in reality we want
1072
 
             * that to wait until the map request */
1073
 
            if (failure || (wa.root == priv->root))
1074
 
            {
1075
 
                /* Our SubstructureRedirectMask doesn't work on OverrideRedirect
1076
 
                 * windows so we need to track them directly here */
1077
 
                if (!event->xcreatewindow.override_redirect)
1078
 
                    new CoreWindow (event->xcreatewindow.window, wa);
1079
 
                else
1080
 
                {
1081
 
                    CoreWindow *cw = 
1082
 
                        new CoreWindow (event->xcreatewindow.window, wa);
1083
 
                    
1084
 
                    if (cw)
1085
 
                    {
1086
 
                        w = cw->manage (priv->getTopWindow ());
1087
 
                        delete cw;
1088
 
                    }
1089
 
                }
1090
 
            }
1091
 
            else
1092
 
                XSelectInput (priv->dpy, event->xcreatewindow.window,
1093
 
                              FocusChangeMask);
1094
 
        }
1095
 
        break;
1096
 
    }
1097
 
    case DestroyNotify:
1098
 
        w = findWindow (event->xdestroywindow.window);
1099
 
        if (w)
1100
 
        {
1101
 
            w->moveInputFocusToOtherWindow ();
1102
 
            w->destroy ();
1103
 
        }
1104
 
        break;
1105
 
    case MapNotify:
1106
 
 
1107
 
        /* Some broken applications and toolkits (eg QT) will lie to
1108
 
         * us about their override-redirect mask - not setting it on
1109
 
         * the initial CreateNotify and then setting it later on
1110
 
         * just after creation. Unfortunately, this means that QT
1111
 
         * has successfully bypassed both of our window tracking
1112
 
         * mechanisms (eg, not override-redirect at CreateNotify time
1113
 
         * and then bypassing MapRequest because it *is* override-redirect
1114
 
         * at XMapWindow time, so we need to catch this case and make
1115
 
         * sure that windows are tracked here */
1116
 
        
1117
 
        foreach (CoreWindow *cw, priv->createdWindows)
1118
 
        {
1119
 
            if (cw->priv->id == event->xmap.window)
1120
 
            {
1121
 
                w = cw->manage (priv->getTopWindow ());
1122
 
                delete cw;
1123
 
                break;
1124
 
            }
1125
 
        }
1126
 
 
1127
 
        /* Search in already-created windows for this window */
1128
 
        if (!w)
1129
 
            w = findWindow (event->xmap.window);
1130
 
 
1131
 
        if (w)
1132
 
        {
1133
 
            if (w->priv->pendingMaps)
1134
 
            {
1135
 
                /* The only case where this happens
1136
 
                 * is where the window unmaps itself
1137
 
                 * but doesn't get destroyed so when
1138
 
                 * it re-maps we need to reparent it */
1139
 
 
1140
 
                if (!w->priv->frame)
1141
 
                    w->priv->reparent ();
1142
 
                w->priv->managed = true;
1143
 
            }
1144
 
 
1145
 
            /* been shaded */
1146
 
            if (w->priv->height == 0)
1147
 
            {
1148
 
                if (w->id () == priv->activeWindow)
1149
 
                    w->moveInputFocusTo ();
1150
 
            }
1151
 
 
1152
 
            w->map ();
1153
 
        }
1154
 
 
1155
 
        break;
1156
 
    case UnmapNotify:
1157
 
        w = findWindow (event->xunmap.window);
1158
 
        if (w)
1159
 
        {
1160
 
            /* Normal -> Iconic */
1161
 
            if (w->pendingUnmaps ())
1162
 
            {
1163
 
                priv->setWmState (IconicState, w->id ());
1164
 
                w->priv->pendingUnmaps--;
1165
 
            }
1166
 
            else /* X -> Withdrawn */
1167
 
            {
1168
 
                /* Iconic -> Withdrawn */
1169
 
                if (w->state () & CompWindowStateHiddenMask)
1170
 
                {
1171
 
                    w->priv->minimized = false;
1172
 
 
1173
 
                    w->changeState (w->state () & ~CompWindowStateHiddenMask);
1174
 
 
1175
 
                    priv->updateClientList ();
1176
 
                }
1177
 
                else /* Closing */
1178
 
                    w->windowNotify (CompWindowNotifyClose);
1179
 
 
1180
 
                if (!w->overrideRedirect ())
1181
 
                    priv->setWmState (WithdrawnState, w->id ());
1182
 
 
1183
 
                w->priv->placed     = false;
1184
 
                w->priv->managed    = false;
1185
 
                w->priv->unmanaging = true;
1186
 
 
1187
 
                if (w->priv->frame)
1188
 
                {
1189
 
                    w->priv->unreparent ();
1190
 
                }
1191
 
            }
1192
 
 
1193
 
            w->unmap ();
1194
 
 
1195
 
            if (!w->shaded () && !w->priv->pendingMaps)
1196
 
                w->moveInputFocusToOtherWindow ();
1197
 
        }
1198
 
        break;
1199
 
    case ReparentNotify:
1200
 
        w = findWindow (event->xreparent.window);
1201
 
        if (!w && event->xreparent.parent == priv->root)
1202
 
        {
1203
 
            /* Failure means that window has been destroyed. We still have to add 
1204
 
             * the window to the window list as we might get configure requests
1205
 
             * which require us to stack other windows relative to it. Setting
1206
 
             * some default values if this is the case. */
1207
 
            if (!XGetWindowAttributes (priv->dpy, event->xcreatewindow.window, &wa))
1208
 
                priv->setDefaultWindowAttributes (&wa);
1209
 
 
1210
 
            CoreWindow *cw = new CoreWindow (event->xreparent.window, wa);
1211
 
 
1212
 
            if (cw)
1213
 
            {
1214
 
                cw->manage (priv->getTopWindow ());
1215
 
                delete cw;
1216
 
            }
1217
 
        }
1218
 
        else if (w && !(event->xreparent.parent == w->priv->wrapper ||
1219
 
                 event->xreparent.parent == priv->root))
1220
 
        {
1221
 
            /* This is the only case where a window is removed but not
1222
 
               destroyed. We must remove our event mask and all passive
1223
 
               grabs. */
1224
 
            XSelectInput (priv->dpy, w->id (), NoEventMask);
1225
 
            XShapeSelectInput (priv->dpy, w->id (), NoEventMask);
1226
 
            XUngrabButton (priv->dpy, AnyButton, AnyModifier, w->id ());
1227
 
 
1228
 
            w->moveInputFocusToOtherWindow ();
1229
 
 
1230
 
            w->destroy ();
1231
 
        }
1232
 
        break;
1233
 
    case CirculateNotify:
1234
 
        w = findWindow (event->xcirculate.window);
1235
 
        if (w)
1236
 
            w->priv->circulate (&event->xcirculate);
1237
 
        break;
1238
 
    case ButtonPress:
1239
 
        if (event->xbutton.button == Button1 ||
1240
 
            event->xbutton.button == Button2 ||
1241
 
            event->xbutton.button == Button3)
1242
 
        {
1243
 
            w = findTopLevelWindow (event->xbutton.window);
1244
 
            if (w)
1245
 
            {
1246
 
                if (priv->optionGetRaiseOnClick ())
1247
 
                    w->updateAttributes (CompStackingUpdateModeAboveFullscreen);
1248
 
 
1249
 
                if (w->id () != priv->activeWindow)
1250
 
                    if (!(w->type () & CompWindowTypeDockMask))
1251
 
                        if (w->focus ())
1252
 
                            w->moveInputFocusTo ();
1253
 
            }
1254
 
        }
1255
 
 
1256
 
        if (priv->grabs.empty ())
1257
 
            XAllowEvents (priv->dpy, ReplayPointer, event->xbutton.time);
1258
 
 
1259
 
        break;
1260
 
    case PropertyNotify:
1261
 
        if (event->xproperty.atom == Atoms::winType)
1262
 
        {
1263
 
            w = findWindow (event->xproperty.window);
1264
 
            if (w)
1265
 
            {
1266
 
                unsigned int type;
1267
 
 
1268
 
                type = priv->getWindowType (w->id ());
1269
 
 
1270
 
                if (type != w->wmType ())
1271
 
                {
1272
 
                    if (w->isViewable ())
1273
 
                    {
1274
 
                        if (w->type () == CompWindowTypeDesktopMask)
1275
 
                            priv->desktopWindowCount--;
1276
 
                        else if (type == CompWindowTypeDesktopMask)
1277
 
                            priv->desktopWindowCount++;
1278
 
                    }
1279
 
 
1280
 
                    w->wmType () = type;
1281
 
 
1282
 
                    w->recalcType ();
1283
 
                    w->recalcActions ();
1284
 
 
1285
 
                    if (type & (CompWindowTypeDockMask |
1286
 
                                CompWindowTypeDesktopMask))
1287
 
                        w->setDesktop (0xffffffff);
1288
 
 
1289
 
                    priv->updateClientList ();
1290
 
 
1291
 
                    matchPropertyChanged (w);
1292
 
                }
1293
 
            }
1294
 
        }
1295
 
        else if (event->xproperty.atom == Atoms::winState)
1296
 
        {
1297
 
            w = findWindow (event->xproperty.window);
1298
 
            if (w && !w->managed ())
1299
 
            {
1300
 
                unsigned int state;
1301
 
 
1302
 
                state = priv->getWindowState (w->id ());
1303
 
                state = CompWindow::constrainWindowState (state, w->actions ());
1304
 
 
1305
 
                /* EWMH suggests that we ignore changes
1306
 
                   to _NET_WM_STATE_HIDDEN */
1307
 
                if (w->state () & CompWindowStateHiddenMask)
1308
 
                    state |= CompWindowStateHiddenMask;
1309
 
                else
1310
 
                    state &= ~CompWindowStateHiddenMask;
1311
 
 
1312
 
                w->changeState (state);
1313
 
            }
1314
 
        }
1315
 
        else if (event->xproperty.atom == XA_WM_NORMAL_HINTS)
1316
 
        {
1317
 
            w = findWindow (event->xproperty.window);
1318
 
            if (w)
1319
 
            {
1320
 
                w->priv->updateNormalHints ();
1321
 
                w->recalcActions ();
1322
 
            }
1323
 
        }
1324
 
        else if (event->xproperty.atom == XA_WM_HINTS)
1325
 
        {
1326
 
            w = findWindow (event->xproperty.window);
1327
 
            if (w)
1328
 
                w->priv->updateWmHints ();
1329
 
        }
1330
 
        else if (event->xproperty.atom == XA_WM_TRANSIENT_FOR)
1331
 
        {
1332
 
            w = findWindow (event->xproperty.window);
1333
 
            if (w)
1334
 
            {
1335
 
                w->priv->updateTransientHint ();
1336
 
                w->recalcActions ();
1337
 
            }
1338
 
        }
1339
 
        else if (event->xproperty.atom == Atoms::wmClientLeader)
1340
 
        {
1341
 
            w = findWindow (event->xproperty.window);
1342
 
            if (w)
1343
 
                w->priv->clientLeader = w->priv->getClientLeader ();
1344
 
        }
1345
 
        else if (event->xproperty.atom == Atoms::wmIconGeometry)
1346
 
        {
1347
 
            w = findWindow (event->xproperty.window);
1348
 
            if (w)
1349
 
                w->priv->updateIconGeometry ();
1350
 
        }
1351
 
        else if (event->xproperty.atom == Atoms::wmStrut ||
1352
 
                 event->xproperty.atom == Atoms::wmStrutPartial)
1353
 
        {
1354
 
            w = findWindow (event->xproperty.window);
1355
 
            if (w)
1356
 
            {
1357
 
                if (w->updateStruts ())
1358
 
                    updateWorkarea ();
1359
 
            }
1360
 
        }
1361
 
        else if (event->xproperty.atom == Atoms::mwmHints)
1362
 
        {
1363
 
            w = findWindow (event->xproperty.window);
1364
 
            if (w)
1365
 
                w->priv->updateMwmHints ();
1366
 
        }
1367
 
        else if (event->xproperty.atom == Atoms::wmProtocols)
1368
 
        {
1369
 
            w = findWindow (event->xproperty.window);
1370
 
            if (w)
1371
 
                w->priv->protocols = priv->getProtocols (w->id ());
1372
 
        }
1373
 
        else if (event->xproperty.atom == Atoms::wmIcon)
1374
 
        {
1375
 
            w = findWindow (event->xproperty.window);
1376
 
            if (w)
1377
 
                w->priv->freeIcons ();
1378
 
        }
1379
 
        else if (event->xproperty.atom == Atoms::startupId)
1380
 
        {
1381
 
            w = findWindow (event->xproperty.window);
1382
 
            if (w)
1383
 
                w->priv->updateStartupId ();
1384
 
        }
1385
 
        else if (event->xproperty.atom == XA_WM_CLASS)
1386
 
        {
1387
 
            w = findWindow (event->xproperty.window);
1388
 
            if (w)
1389
 
                w->priv->updateClassHints ();
1390
 
        }
1391
 
        break;
1392
 
    case MotionNotify:
1393
 
        break;
1394
 
    case ClientMessage:
1395
 
        if (event->xclient.message_type == Atoms::winActive)
1396
 
        {
1397
 
            w = findWindow (event->xclient.window);
1398
 
            if (w)
1399
 
            {
1400
 
                /* use focus stealing prevention if request came
1401
 
                   from an application  */
1402
 
                if (event->xclient.data.l[0] != ClientTypeApplication ||
1403
 
                    w->priv->allowWindowFocus (0, event->xclient.data.l[1]))
1404
 
                {
1405
 
                    w->activate ();
1406
 
                }
1407
 
            }
1408
 
        }
1409
 
        else if (event->xclient.message_type == Atoms::winState)
1410
 
        {
1411
 
            w = findWindow (event->xclient.window);
1412
 
            if (w)
1413
 
            {
1414
 
                unsigned long wState, state;
1415
 
                int           i;
1416
 
 
1417
 
                wState = w->state ();
1418
 
 
1419
 
                for (i = 1; i < 3; i++)
1420
 
                {
1421
 
                    state = priv->windowStateMask (event->xclient.data.l[i]);
1422
 
                    if (state & ~CompWindowStateHiddenMask)
1423
 
                    {
1424
 
 
1425
 
#define _NET_WM_STATE_REMOVE 0
1426
 
#define _NET_WM_STATE_ADD    1
1427
 
#define _NET_WM_STATE_TOGGLE 2
1428
 
 
1429
 
                        switch (event->xclient.data.l[0]) {
1430
 
                        case _NET_WM_STATE_REMOVE:
1431
 
                            wState &= ~state;
1432
 
                            break;
1433
 
                        case _NET_WM_STATE_ADD:
1434
 
                            wState |= state;
1435
 
                            break;
1436
 
                        case _NET_WM_STATE_TOGGLE:
1437
 
                            wState ^= state;
1438
 
                            break;
1439
 
                        }
1440
 
                    }
1441
 
                }
1442
 
 
1443
 
                wState = CompWindow::constrainWindowState (wState,
1444
 
                                                           w->actions ());
1445
 
                if (w->id () == priv->activeWindow)
1446
 
                    wState &= ~CompWindowStateDemandsAttentionMask;
1447
 
 
1448
 
                if (wState != w->state ())
1449
 
                {
1450
 
                    CompStackingUpdateMode stackingUpdateMode;
1451
 
                    unsigned long          dState = wState ^ w->state ();
1452
 
 
1453
 
                    stackingUpdateMode = CompStackingUpdateModeNone;
1454
 
 
1455
 
                    /* raise the window whenever its fullscreen state,
1456
 
                       above/below state or maximization state changed */
1457
 
                    if (dState & (CompWindowStateFullscreenMask |
1458
 
                                  CompWindowStateAboveMask |
1459
 
                                  CompWindowStateBelowMask |
1460
 
                                  CompWindowStateMaximizedHorzMask |
1461
 
                                  CompWindowStateMaximizedVertMask))
1462
 
                        stackingUpdateMode = CompStackingUpdateModeNormal;
1463
 
 
1464
 
                    w->changeState (wState);
1465
 
 
1466
 
                    w->updateAttributes (stackingUpdateMode);
1467
 
                }
1468
 
            }
1469
 
        }
1470
 
        else if (event->xclient.message_type == Atoms::wmProtocols)
1471
 
        {
1472
 
            if ((unsigned long) event->xclient.data.l[0] == Atoms::wmPing)
1473
 
            {
1474
 
                w = findWindow (event->xclient.data.l[2]);
1475
 
                if (w)
1476
 
                    w->priv->handlePing (priv->lastPing);
1477
 
            }
1478
 
        }
1479
 
        else if (event->xclient.message_type == Atoms::closeWindow)
1480
 
        {
1481
 
            w = findWindow (event->xclient.window);
1482
 
            if (w)
1483
 
                w->close (event->xclient.data.l[0]);
1484
 
        }
1485
 
        else if (event->xclient.message_type == Atoms::desktopGeometry)
1486
 
        {
1487
 
            if (event->xclient.window == priv->root)
1488
 
            {
1489
 
                CompOption::Value value;
1490
 
 
1491
 
                value.set ((int) (event->xclient.data.l[0] /
1492
 
                           width ()));
1493
 
 
1494
 
                setOptionForPlugin ("core", "hsize", value);
1495
 
 
1496
 
                value.set ((int) (event->xclient.data.l[1] /
1497
 
                           height ()));
1498
 
 
1499
 
                setOptionForPlugin ("core", "vsize", value);
1500
 
            }
1501
 
        }
1502
 
        else if (event->xclient.message_type == Atoms::moveResizeWindow)
1503
 
        {
1504
 
            w = findWindow (event->xclient.window);
1505
 
            if (w)
1506
 
            {
1507
 
                unsigned int   xwcm = 0;
1508
 
                XWindowChanges xwc;
1509
 
                int            gravity;
1510
 
                int            value_mask;
1511
 
                unsigned int   source;
1512
 
 
1513
 
                gravity = (event->xclient.data.l[0] & 0xFF);            
1514
 
                value_mask = (event->xclient.data.l[0] & 0xF00) >> 8;
1515
 
                source = (event->xclient.data.l[0] & 0xF000) >> 12;
1516
 
 
1517
 
                memset (&xwc, 0, sizeof (xwc));
1518
 
 
1519
 
                if (value_mask & CWX)
1520
 
                {
1521
 
                    xwcm |= CWX;
1522
 
                    xwc.x = event->xclient.data.l[1];
1523
 
                }
1524
 
 
1525
 
                if (value_mask & CWY)
1526
 
                {
1527
 
                    xwcm |= CWY;
1528
 
                    xwc.y = event->xclient.data.l[2];
1529
 
                }
1530
 
 
1531
 
                if (value_mask & CWWidth)
1532
 
                {
1533
 
                    xwcm |= CWWidth;
1534
 
                    xwc.width = event->xclient.data.l[3];
1535
 
                }
1536
 
 
1537
 
                if (value_mask & CWHeight)
1538
 
                {
1539
 
                    xwcm |= CWHeight;
1540
 
                    xwc.height = event->xclient.data.l[4];
1541
 
                }
1542
 
 
1543
 
                w->moveResize (&xwc, xwcm, gravity, source);
1544
 
            }
1545
 
        }
1546
 
        else if (event->xclient.message_type == Atoms::restackWindow)
1547
 
        {
1548
 
            w = findWindow (event->xclient.window);
1549
 
            if (w)
1550
 
            {
1551
 
                /* TODO: other stack modes than Above and Below */
1552
 
                if (event->xclient.data.l[1])
1553
 
                {
1554
 
                    CompWindow *sibling;
1555
 
 
1556
 
                    sibling = findWindow (event->xclient.data.l[1]);
1557
 
                    if (sibling)
1558
 
                    {
1559
 
                        if (event->xclient.data.l[2] == Above)
1560
 
                            w->restackAbove (sibling);
1561
 
                        else if (event->xclient.data.l[2] == Below)
1562
 
                            w->restackBelow (sibling);
1563
 
                    }
1564
 
                }
1565
 
                else
1566
 
                {
1567
 
                    if (event->xclient.data.l[2] == Above)
1568
 
                        w->raise ();
1569
 
                    else if (event->xclient.data.l[2] == Below)
1570
 
                        w->lower ();
1571
 
                }
1572
 
            }
1573
 
        }
1574
 
        else if (event->xclient.message_type == Atoms::wmChangeState)
1575
 
        {
1576
 
            w = findWindow (event->xclient.window);
1577
 
            if (w)
1578
 
            {
1579
 
                if (event->xclient.data.l[0] == IconicState)
1580
 
                {
1581
 
                    if (w->actions () & CompWindowActionMinimizeMask)
1582
 
                        w->minimize ();
1583
 
                }
1584
 
                else if (event->xclient.data.l[0] == NormalState)
1585
 
                {
1586
 
                    w->unminimize ();
1587
 
                }
1588
 
            }
1589
 
        }
1590
 
        else if (event->xclient.message_type == Atoms::showingDesktop)
1591
 
        {
1592
 
            if (event->xclient.window == priv->root ||
1593
 
                event->xclient.window == None)
1594
 
            {
1595
 
                if (event->xclient.data.l[0])
1596
 
                    enterShowDesktopMode ();
1597
 
                else
1598
 
                    leaveShowDesktopMode (NULL);
1599
 
            }
1600
 
        }
1601
 
        else if (event->xclient.message_type == Atoms::numberOfDesktops)
1602
 
        {
1603
 
            if (event->xclient.window == priv->root)
1604
 
            {
1605
 
                CompOption::Value value;
1606
 
 
1607
 
                value.set ((int) event->xclient.data.l[0]);
1608
 
 
1609
 
                setOptionForPlugin ("core", "number_of_desktops", value);
1610
 
            }
1611
 
        }
1612
 
        else if (event->xclient.message_type == Atoms::currentDesktop)
1613
 
        {
1614
 
            if (event->xclient.window == priv->root)
1615
 
                priv->setCurrentDesktop (event->xclient.data.l[0]);
1616
 
        }
1617
 
        else if (event->xclient.message_type == Atoms::winDesktop)
1618
 
        {
1619
 
            w = findWindow (event->xclient.window);
1620
 
            if (w)
1621
 
                w->setDesktop (event->xclient.data.l[0]);
1622
 
        }
1623
 
        else if (event->xclient.message_type == Atoms::wmFullscreenMonitors)
1624
 
        {
1625
 
            w = findWindow (event->xclient.window);
1626
 
            if (w)
1627
 
            {
1628
 
                CompFullscreenMonitorSet monitors;
1629
 
 
1630
 
                monitors.top    = event->xclient.data.l[0];
1631
 
                monitors.bottom = event->xclient.data.l[1];
1632
 
                monitors.left   = event->xclient.data.l[2];
1633
 
                monitors.right  = event->xclient.data.l[3];
1634
 
 
1635
 
                w->priv->setFullscreenMonitors (&monitors);
1636
 
            }
1637
 
        }
1638
 
        break;
1639
 
    case MappingNotify:
1640
 
        modHandler->updateModifierMappings ();
1641
 
        break;
1642
 
    case MapRequest:
1643
 
        /* Create the CompWindow structure here */
1644
 
        w = NULL;
1645
 
 
1646
 
        foreach (CoreWindow *cw, priv->createdWindows)
1647
 
        {
1648
 
            if (cw->priv->id == event->xmaprequest.window)
1649
 
            {
1650
 
                w = cw->manage (priv->getTopWindow ());
1651
 
                delete cw;
1652
 
                break;
1653
 
            }
1654
 
        }
1655
 
 
1656
 
        if (!w)
1657
 
            w = screen->findWindow (event->xmaprequest.window);
1658
 
 
1659
 
        if (w)
1660
 
        {
1661
 
            XWindowAttributes attr;
1662
 
            bool              doMapProcessing = true;
1663
 
 
1664
 
            /* We should check the override_redirect flag here, because the
1665
 
               client might have changed it while being unmapped. */
1666
 
            if (XGetWindowAttributes (priv->dpy, w->id (), &attr))
1667
 
                w->priv->setOverrideRedirect (attr.override_redirect != 0);
1668
 
 
1669
 
            if (w->state () & CompWindowStateHiddenMask)
1670
 
                if (!w->minimized () && !w->inShowDesktopMode ())
1671
 
                    doMapProcessing = false;
1672
 
 
1673
 
            if (doMapProcessing)
1674
 
                w->priv->processMap ();
1675
 
 
1676
 
            w->priv->managed = true;
1677
 
 
1678
 
            setWindowProp (w->id (), Atoms::winDesktop, w->desktop ());
1679
 
        }
1680
 
        else
1681
 
        {
1682
 
            XMapWindow (priv->dpy, event->xmaprequest.window);
1683
 
        }
1684
 
        break;
1685
 
    case ConfigureRequest:
1686
 
        w = findWindow (event->xconfigurerequest.window);
1687
 
        if (w && w->managed ())
1688
 
        {
1689
 
            XWindowChanges xwc;
1690
 
 
1691
 
            memset (&xwc, 0, sizeof (xwc));
1692
 
 
1693
 
            xwc.x            = event->xconfigurerequest.x;
1694
 
            xwc.y            = event->xconfigurerequest.y;
1695
 
            xwc.width        = event->xconfigurerequest.width;
1696
 
            xwc.height       = event->xconfigurerequest.height;
1697
 
            xwc.border_width = event->xconfigurerequest.border_width;
1698
 
 
1699
 
            w->moveResize (&xwc, event->xconfigurerequest.value_mask,
1700
 
                           0, ClientTypeUnknown);
1701
 
 
1702
 
            if (event->xconfigurerequest.value_mask & CWStackMode)
1703
 
            {
1704
 
                Window     above    = None;
1705
 
                CompWindow *sibling = NULL;
1706
 
 
1707
 
                if (event->xconfigurerequest.value_mask & CWSibling)
1708
 
                {
1709
 
                    above   = event->xconfigurerequest.above;
1710
 
                    sibling = findTopLevelWindow (above);
1711
 
                }
1712
 
 
1713
 
                switch (event->xconfigurerequest.detail) {
1714
 
                case Above:
1715
 
                    if (w->priv->allowWindowFocus (NO_FOCUS_MASK, 0))
1716
 
                    {
1717
 
                        if (above)
1718
 
                        {
1719
 
                            if (sibling)
1720
 
                                w->restackAbove (sibling);
1721
 
                        }
1722
 
                        else
1723
 
                            w->raise ();
1724
 
                    }
1725
 
                    break;
1726
 
                case Below:
1727
 
                    if (above)
1728
 
                    {
1729
 
                        if (sibling)
1730
 
                            w->restackBelow (sibling);
1731
 
                    }
1732
 
                    else
1733
 
                        w->lower ();
1734
 
                    break;
1735
 
                default:
1736
 
                    /* no handling of the TopIf, BottomIf, Opposite cases -
1737
 
                       there will hardly be any client using that */
1738
 
                    break;
1739
 
                }
1740
 
            }
1741
 
        }
1742
 
        else
1743
 
        {
1744
 
            XWindowChanges xwc;
1745
 
            unsigned int   xwcm;
1746
 
 
1747
 
            xwcm = event->xconfigurerequest.value_mask &
1748
 
                (CWX | CWY | CWWidth | CWHeight | CWBorderWidth);
1749
 
 
1750
 
            xwc.x            = event->xconfigurerequest.x;
1751
 
            xwc.y            = event->xconfigurerequest.y;
1752
 
            xwc.width        = event->xconfigurerequest.width;
1753
 
            xwc.height       = event->xconfigurerequest.height;
1754
 
            xwc.border_width = event->xconfigurerequest.border_width;
1755
 
 
1756
 
            if (w)
1757
 
                w->configureXWindow (xwcm, &xwc);
1758
 
            else
1759
 
                XConfigureWindow (priv->dpy, event->xconfigurerequest.window,
1760
 
                                  xwcm, &xwc);
1761
 
        }
1762
 
        break;
1763
 
    case CirculateRequest:
1764
 
        break;
1765
 
    case FocusIn:
1766
 
        XGetWindowAttributes (priv->dpy, event->xfocus.window, &wa);
1767
 
 
1768
 
        if (wa.root == priv->root)
1769
 
        {
1770
 
            if (event->xfocus.mode != NotifyGrab)
1771
 
            {
1772
 
                w = findTopLevelWindow (event->xfocus.window);
1773
 
                if (w && w->managed ())
1774
 
                {
1775
 
                    unsigned int state = w->state ();
1776
 
 
1777
 
                    if (w->id () != priv->activeWindow)
1778
 
                    {
1779
 
                        CompWindow *active = screen->findWindow (priv->activeWindow);
1780
 
                        w->windowNotify (CompWindowNotifyFocusChange);
1781
 
 
1782
 
                        priv->activeWindow = w->id ();
1783
 
                        w->priv->activeNum = priv->activeNum++;
1784
 
 
1785
 
                        if (active)
1786
 
                            active->priv->updatePassiveButtonGrabs ();
1787
 
 
1788
 
                        w->priv->updatePassiveButtonGrabs ();
1789
 
 
1790
 
                        priv->addToCurrentActiveWindowHistory (w->id ());
1791
 
 
1792
 
                        XChangeProperty (priv->dpy , priv->root,
1793
 
                                         Atoms::winActive,
1794
 
                                         XA_WINDOW, 32, PropModeReplace,
1795
 
                                         (unsigned char *) &priv->activeWindow, 1);
1796
 
                    }
1797
 
 
1798
 
                    state &= ~CompWindowStateDemandsAttentionMask;
1799
 
                    w->changeState (state);
1800
 
 
1801
 
                    if (priv->nextActiveWindow == event->xfocus.window)
1802
 
                        priv->nextActiveWindow = None;
1803
 
                }
1804
 
            }
1805
 
            else
1806
 
                priv->grabbed = true;
1807
 
        }
1808
 
        else
1809
 
        {
1810
 
            CompWindow *w;
1811
 
 
1812
 
            w = screen->findWindow (priv->activeWindow);
1813
 
 
1814
 
            priv->nextActiveWindow = None;
1815
 
            priv->activeWindow = None;
1816
 
 
1817
 
            if (w)
1818
 
                w->priv->updatePassiveButtonGrabs ();
1819
 
        }
1820
 
 
1821
 
        break;
1822
 
    case FocusOut:
1823
 
        if (event->xfocus.mode == NotifyUngrab)
1824
 
            priv->grabbed = false;
1825
 
        break;
1826
 
    case EnterNotify:
1827
 
        if (event->xcrossing.root == priv->root)
1828
 
            w = findTopLevelWindow (event->xcrossing.window);
1829
 
        else
1830
 
            w = NULL;
1831
 
 
1832
 
        if (w && w->id () != priv->below)
1833
 
        {
1834
 
            priv->below = w->id ();
1835
 
 
1836
 
            if (!priv->optionGetClickToFocus () &&
1837
 
                priv->grabs.empty ()                                 &&
1838
 
                event->xcrossing.mode   != NotifyGrab                &&
1839
 
                event->xcrossing.detail != NotifyInferior)
1840
 
            {
1841
 
                bool raise;
1842
 
                int  delay;
1843
 
 
1844
 
                raise = priv->optionGetAutoraise ();
1845
 
                delay = priv->optionGetAutoraiseDelay ();
1846
 
 
1847
 
                if (priv->autoRaiseTimer.active () &&
1848
 
                    priv->autoRaiseWindow != w->id ())
1849
 
                {
1850
 
                    priv->autoRaiseTimer.stop ();
1851
 
                }
1852
 
 
1853
 
                if (w->type () & ~(CompWindowTypeDockMask |
1854
 
                                   CompWindowTypeDesktopMask))
1855
 
                {
1856
 
                    w->moveInputFocusTo ();
1857
 
 
1858
 
                    if (raise)
1859
 
                    {
1860
 
                        if (delay > 0)
1861
 
                        {
1862
 
                            priv->autoRaiseWindow = w->id ();
1863
 
                            priv->autoRaiseTimer.start (
1864
 
                                boost::bind (autoRaiseTimeout, this),
1865
 
                                delay, (unsigned int) ((float) delay * 1.2));
1866
 
                        }
1867
 
                        else
1868
 
                        {
1869
 
                            CompStackingUpdateMode mode =
1870
 
                                CompStackingUpdateModeNormal;
1871
 
 
1872
 
                            w->updateAttributes (mode);
1873
 
                        }
1874
 
                    }
1875
 
                }
1876
 
            }
1877
 
        }
1878
 
        break;
1879
 
    case LeaveNotify:
1880
 
        if (event->xcrossing.detail != NotifyInferior)
1881
 
        {
1882
 
            if (event->xcrossing.window == priv->below)
1883
 
                priv->below = None;
1884
 
        }
1885
 
        break;
1886
 
    default:
1887
 
        if (priv->shapeExtension &&
1888
 
                 event->type == priv->shapeEvent + ShapeNotify)
1889
 
        {
1890
 
            w = findWindow (((XShapeEvent *) event)->window);
1891
 
            if (w)
1892
 
            {
1893
 
                if (w->mapNum ())
1894
 
                    w->priv->updateRegion ();
1895
 
            }
1896
 
        }
1897
 
        else if (event->type == priv->syncEvent + XSyncAlarmNotify)
1898
 
        {
1899
 
            XSyncAlarmNotifyEvent *sa;
1900
 
 
1901
 
            sa = (XSyncAlarmNotifyEvent *) event;
1902
 
 
1903
 
 
1904
 
            foreach (w, priv->windows)
1905
 
            {
1906
 
                if (w->priv->syncAlarm == sa->alarm)
1907
 
                {
1908
 
                    w->priv->handleSyncAlarm ();
1909
 
                    break;
1910
 
                }
1911
 
            }
1912
 
        }
1913
 
        break;
1914
 
    }
1915
 
}