~mc-return/compiz/compiz0.9.9.merge-plugin-startup

« back to all changes in this revision

Viewing changes to src/window.cpp

MergedĀ latestĀ lp:compiz

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <math.h>
38
38
 
39
39
#include <boost/bind.hpp>
 
40
#include <boost/make_shared.hpp>
40
41
 
41
42
#include <core/icon.h>
42
43
#include <core/atoms.h>
45
46
#include "privatescreen.h"
46
47
#include "privatestackdebugger.h"
47
48
 
 
49
#include "configurerequestbuffer-impl.h"
 
50
 
48
51
#include <boost/scoped_array.hpp>
49
52
 
 
53
namespace crb = compiz::window::configure_buffers;
 
54
namespace cw = compiz::window;
 
55
 
50
56
template class WrapableInterface<CompWindow, WindowInterface>;
51
57
 
52
58
PluginClassStorage::Indices windowPluginClassIndices (0);
3028
3034
    return pc->matchRequest (xwc, valueMask);
3029
3035
}
3030
3036
 
 
3037
bool
 
3038
PrivateWindow::queryAttributes (XWindowAttributes &attrib)
 
3039
{
 
3040
    return configureBuffer->queryAttributes (attrib);
 
3041
}
 
3042
 
 
3043
bool
 
3044
PrivateWindow::queryFrameAttributes (XWindowAttributes &attrib)
 
3045
{
 
3046
    return configureBuffer->queryFrameAttributes (attrib);
 
3047
}
 
3048
 
 
3049
XRectangle *
 
3050
PrivateWindow::queryShapeRectangles (int kind, int *count, int *ordering)
 
3051
{
 
3052
    return configureBuffer->queryShapeRectangles (kind, count, ordering);
 
3053
}
 
3054
 
 
3055
int
 
3056
PrivateWindow::requestConfigureOnClient (const XWindowChanges &xwc,
 
3057
                                         unsigned int valueMask)
 
3058
{
 
3059
    return XConfigureWindow (screen->dpy (),
 
3060
                             id,
 
3061
                             valueMask,
 
3062
                             const_cast <XWindowChanges *> (&xwc));
 
3063
}
 
3064
 
 
3065
int
 
3066
PrivateWindow::requestConfigureOnWrapper (const XWindowChanges &xwc,
 
3067
                                          unsigned int valueMask)
 
3068
{
 
3069
    return XConfigureWindow (screen->dpy (),
 
3070
                             wrapper,
 
3071
                             valueMask,
 
3072
                             const_cast <XWindowChanges *> (&xwc));
 
3073
}
 
3074
 
 
3075
int
 
3076
PrivateWindow::requestConfigureOnFrame (const XWindowChanges &xwc,
 
3077
                                        unsigned int frameValueMask)
 
3078
{
 
3079
    XWindowChanges wc = xwc;
 
3080
 
 
3081
    wc.x      = serverFrameGeometry.x ();
 
3082
    wc.y      = serverFrameGeometry.y ();
 
3083
    wc.width  = serverFrameGeometry.width ();
 
3084
    wc.height = serverFrameGeometry.height ();
 
3085
 
 
3086
    compiz::X11::PendingEvent::Ptr pc (
 
3087
        new compiz::X11::PendingConfigureEvent (
 
3088
            screen->dpy (),
 
3089
            priv->serverFrame,
 
3090
            frameValueMask, &wc));
 
3091
 
 
3092
    pendingConfigures.add (pc);
 
3093
 
 
3094
    return XConfigureWindow (screen->dpy (), serverFrame, frameValueMask, &wc);
 
3095
}
 
3096
 
 
3097
void
 
3098
PrivateWindow::sendSyntheticConfigureNotify ()
 
3099
{
 
3100
    window->sendConfigureNotify ();
 
3101
}
 
3102
 
 
3103
bool
 
3104
PrivateWindow::hasCustomShape () const
 
3105
{
 
3106
    return false;
 
3107
}
 
3108
 
3031
3109
void
3032
3110
PrivateWindow::reconfigureXWindow (unsigned int   valueMask,
3033
3111
                                   XWindowChanges *xwc)
3240
3318
    if (serverFrame)
3241
3319
    {
3242
3320
        if (frameValueMask)
3243
 
        {
3244
 
            XWindowChanges wc = *xwc;
3245
 
 
3246
 
            wc.x      = serverFrameGeometry.x ();
3247
 
            wc.y      = serverFrameGeometry.y ();
3248
 
            wc.width  = serverFrameGeometry.width ();
3249
 
            wc.height = serverFrameGeometry.height ();
3250
 
 
3251
 
            compiz::X11::PendingEvent::Ptr pc =
3252
 
                    boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr (
3253
 
                                                                              new compiz::X11::PendingConfigureEvent (
3254
 
                                                                                  screen->dpy (), priv->serverFrame, frameValueMask, &wc)));
3255
 
 
3256
 
            pendingConfigures.add (pc);
3257
 
 
3258
 
            XConfigureWindow (screen->dpy (), serverFrame, frameValueMask, &wc);
3259
 
        }
3260
 
 
3261
 
        valueMask &= ~(CWSibling | CWStackMode);
 
3321
            priv->configureBuffer->pushFrameRequest (*xwc, frameValueMask);
 
3322
 
 
3323
        valueMask = frameValueMask & (CWWidth | CWHeight);
3262
3324
 
3263
3325
        /* If the frame has changed position (eg, serverInput.top
3264
3326
         * or serverInput.left have changed) then we also need to
3265
3327
         * update the client and wrapper position */
3266
 
        if (!(valueMask & CWX))
3267
 
            valueMask |= frameValueMask & CWX;
3268
 
        if (!(valueMask & CWY))
3269
 
            valueMask |= frameValueMask & CWY;
 
3328
        if (lastServerInput.left != serverInput.left)
 
3329
            valueMask |= CWX;
 
3330
        if (lastServerInput.top != serverInput.top)
 
3331
            valueMask |= CWY;
 
3332
 
 
3333
        if (lastServerInput.right - lastServerInput.left !=
 
3334
            serverInput.right - serverInput.left)
 
3335
            valueMask |= CWWidth;
 
3336
        if (lastServerInput.bottom - lastServerInput.top !=
 
3337
            serverInput.bottom - serverInput.top)
 
3338
            valueMask |= CWHeight;
3270
3339
 
3271
3340
        if (valueMask)
3272
3341
        {
3273
3342
            xwc->x = serverInput.left;
3274
3343
            xwc->y = serverInput.top;
3275
 
            XConfigureWindow (screen->dpy (), wrapper, valueMask, xwc);
3276
3344
 
3277
 
            xwc->x = 0;
3278
 
            xwc->y = 0;
 
3345
            priv->configureBuffer->pushWrapperRequest (*xwc, valueMask);
3279
3346
        }
3280
3347
    }
3281
3348
 
 
3349
    /* Client is reparented, the only things that can change
 
3350
     * are the width, height and border width */
 
3351
    if (serverFrame)
 
3352
        valueMask &= (CWWidth | CWHeight | CWBorderWidth);
 
3353
 
3282
3354
    if (valueMask)
3283
 
        XConfigureWindow (screen->dpy (), id, valueMask, xwc);
 
3355
        priv->configureBuffer->pushClientRequest (*xwc, valueMask);
3284
3356
 
3285
3357
    /* Send the synthetic configure notify
3286
3358
     * after the real configure notify arrives
4163
4235
    using ::compiz::private_screen::WindowManager;
4164
4236
 
4165
4237
    CompWindow  *focus = NULL;
4166
 
    WindowManager::reverse_iterator it = windowManager.rbegin ();
 
4238
    WindowManager::reverse_iterator it = windowManager.rserverBegin ();
4167
4239
 
4168
 
    for (; it != windowManager.rend (); ++it)
 
4240
    for (; it != windowManager.rserverEnd (); ++it)
4169
4241
    {
4170
4242
        CompWindow *w = *it;
4171
4243
 
5811
5883
    return priv->struts;
5812
5884
}
5813
5885
 
 
5886
bool
 
5887
CompWindow::queryAttributes (XWindowAttributes &attrib)
 
5888
{
 
5889
    return priv->queryAttributes (attrib);
 
5890
}
 
5891
 
 
5892
bool
 
5893
CompWindow::queryFrameAttributes (XWindowAttributes &attrib)
 
5894
{
 
5895
    return priv->queryFrameAttributes (attrib);
 
5896
}
 
5897
 
 
5898
crb::Releasable::Ptr
 
5899
CompWindow::obtainLockOnConfigureRequests ()
 
5900
{
 
5901
    return priv->configureBuffer->obtainLock ();
 
5902
}
 
5903
 
5814
5904
int &
5815
5905
CompWindow::saveMask () const
5816
5906
{
6349
6439
    delete priv;
6350
6440
}
6351
6441
 
 
6442
X11SyncServerWindow::X11SyncServerWindow (Display      *dpy,
 
6443
                                          const Window *w,
 
6444
                                          const Window *frame) :
 
6445
    mDpy (dpy),
 
6446
    mWindow (w),
 
6447
    mFrame (frame)
 
6448
{
 
6449
}
 
6450
 
 
6451
bool
 
6452
X11SyncServerWindow::queryAttributes (XWindowAttributes &attrib)
 
6453
{
 
6454
    if (XGetWindowAttributes (mDpy, *mWindow, &attrib))
 
6455
        return true;
 
6456
 
 
6457
    return false;
 
6458
}
 
6459
 
 
6460
bool
 
6461
X11SyncServerWindow::queryFrameAttributes (XWindowAttributes &attrib)
 
6462
{
 
6463
    Window w = *mFrame ? *mFrame : *mWindow;
 
6464
 
 
6465
    if (XGetWindowAttributes (mDpy, w, &attrib))
 
6466
        return true;
 
6467
 
 
6468
    return false;
 
6469
}
 
6470
 
 
6471
XRectangle *
 
6472
X11SyncServerWindow::queryShapeRectangles (int kind,
 
6473
                                           int *count,
 
6474
                                           int *ordering)
 
6475
{
 
6476
    return XShapeGetRectangles (mDpy, *mWindow,
 
6477
                                kind,
 
6478
                                count,
 
6479
                                ordering);
 
6480
}
 
6481
 
 
6482
namespace
 
6483
{
 
6484
crb::BufferLock::Ptr
 
6485
createConfigureBufferLock (crb::CountedFreeze *cf)
 
6486
{
 
6487
    return boost::make_shared <crb::ConfigureBufferLock> (cf);
 
6488
}
 
6489
}
 
6490
 
6352
6491
PrivateWindow::PrivateWindow () :
6353
6492
    priv (this),
6354
6493
    refcnt (1),
6420
6559
 
6421
6560
    syncWait (false),
6422
6561
    closeRequests (false),
6423
 
    lastCloseRequestTime (0)
 
6562
    lastCloseRequestTime (0),
 
6563
 
 
6564
    syncServerWindow (screen->dpy (),
 
6565
                      &id,
 
6566
                      &serverFrame),
 
6567
    configureBuffer (
 
6568
        crb::ConfigureRequestBuffer::Create (
 
6569
            this,
 
6570
            &syncServerWindow,
 
6571
            boost::bind (createConfigureBufferLock, _1)))
6424
6572
{
6425
6573
    input.left   = 0;
6426
6574
    input.right  = 0;
6427
6575
    input.top    = 0;
6428
6576
    input.bottom = 0;
6429
6577
 
6430
 
    serverInput.left   = 0;
6431
 
    serverInput.right  = 0;
6432
 
    serverInput.top    = 0;
6433
 
    serverInput.bottom = 0;
6434
 
 
6435
 
    border.top    = 0;
6436
 
    border.bottom = 0;
6437
 
    border.left   = 0;
6438
 
    border.right  = 0;
6439
 
 
6440
 
    output.left   = 0;
6441
 
    output.right  = 0;
6442
 
    output.top    = 0;
6443
 
    output.bottom = 0;
 
6578
    /* Zero initialize */
 
6579
    serverInput = input;
 
6580
    lastServerInput = input;
 
6581
    border = input;
 
6582
    output = input;
6444
6583
 
6445
6584
    syncWaitTimer.setTimes (1000, 1200);
6446
6585
    syncWaitTimer.setCallback (boost::bind (&PrivateWindow::handleSyncAlarm,
6648
6787
         * whenever the frame extents update
6649
6788
         * so that plugins can re-position appropriately */
6650
6789
        moveNotify (0, 0, true);
 
6790
 
 
6791
        /* Once we have updated everything, re-set lastServerInput */
 
6792
        priv->lastServerInput = priv->serverInput;
6651
6793
    }
6652
6794
 
6653
6795
    /* Use b for _NET_WM_FRAME_EXTENTS here because
6710
6852
    XSync (dpy, false);
6711
6853
    XGrabServer (dpy);
6712
6854
 
6713
 
    if (!XGetWindowAttributes (dpy, id, &wa))
 
6855
    /* We need to flush all queued up requests */
 
6856
    foreach (CompWindow *w, screen->windows ())
 
6857
        w->priv->configureBuffer->forceRelease ();
 
6858
 
 
6859
    if (!window->priv->queryAttributes (wa))
6714
6860
    {
6715
6861
        XUngrabServer (dpy);
6716
6862
        XSync (dpy, false);
6997
7143
         * a DestroyNotify for it yet, it is possible that restacking
6998
7144
         * operations could occurr relative to it so we need to hold it
6999
7145
         * in the stack for now. Ensure that it is marked override redirect */
7000
 
        XGetWindowAttributes (screen->dpy (), serverFrame, &attrib);
 
7146
        window->priv->queryFrameAttributes (attrib);
7001
7147
 
7002
7148
        /* Put the frame window "above" the client window
7003
7149
         * in the stack */