~linaro-graphics-wg/compiz-core/linaro-gles2-debianpatches

« back to all changes in this revision

Viewing changes to plugins/decor/src/decor.cpp

  • Committer: Alexandros Frantzis
  • Date: 2012-04-10 15:07:37 UTC
  • mfrom: (2753.36.294 trunk)
  • Revision ID: alexandros.frantzis@linaro.org-20120410150737-eld6kdbzwjgtivgc
Sync with lp:compiz-core.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
COMPIZ_PLUGIN_20090315 (decor, DecorPluginVTable)
44
44
 
 
45
MatchedDecorClipGroup::MatchedDecorClipGroup (const CompMatch &match) :
 
46
    mMatch (match)
 
47
{
 
48
}
 
49
 
 
50
bool
 
51
MatchedDecorClipGroup::doPushClippable (DecorClippableInterface *dc)
 
52
{
 
53
    if (dc->matches (mMatch))
 
54
        return mClipGroupImpl.pushClippable (dc);
 
55
 
 
56
    return false;
 
57
}
 
58
 
 
59
void
 
60
DecorWindow::doUpdateShadow (const CompRegion &reg)
 
61
{
 
62
    shadowRegion = outputRegion () - (reg - inputRegion ());
 
63
}
 
64
 
 
65
void
 
66
DecorWindow::doSetOwner (DecorClipGroupInterface *i)
 
67
{
 
68
    mClipGroup = i;
 
69
}
 
70
 
 
71
bool
 
72
DecorWindow::doMatches (const CompMatch &m)
 
73
{
 
74
    return const_cast <CompMatch &> (m).evaluate (window) && !window->invisible ();
 
75
}
 
76
 
 
77
const CompRegion &
 
78
DecorWindow::getOutputRegion ()
 
79
{
 
80
    return mOutputRegion;
 
81
}
 
82
 
 
83
const CompRegion &
 
84
DecorWindow::getInputRegion ()
 
85
{
 
86
    return mInputRegion;
 
87
}
 
88
 
 
89
void
 
90
DecorWindow::doUpdateGroupShadows ()
 
91
{
 
92
    if (mClipGroup)
 
93
        mClipGroup->updateAllShadows ();
 
94
}
 
95
 
45
96
/* From core */
46
97
 
47
98
/*
69
120
    return false;
70
121
}
71
122
 
72
 
/* 
73
 
 * DecorWindow::computeShadowRegion
74
 
 *
75
 
 * This function computes the current clip region for the
76
 
 * shadow that should be draw on glDraw. 
77
 
 *
78
 
 * Make shadows look nice, don't paint shadows on top of
79
 
 * things they don't make sense on top of, eg, menus
80
 
 * need shadows but they don't need to be painted when
81
 
 * another menu is adjacent and covering the shadow
82
 
 * region. Also panel shadows are nice, but not
83
 
 * when they obscure client window shadows
84
 
 *
85
 
 * We need to use the current clip region here
86
 
 * and take an intersection of that to ensure
87
 
 * that we don't unintentionally expand the clip
88
 
 * region that core already reduced by doing
89
 
 * occlusion detection
90
 
 */
91
 
void
92
 
DecorWindow::computeShadowRegion ()
93
 
{
94
 
    shadowRegion = CompRegion (window->outputRect ());
95
 
 
96
 
    if (window->type () == CompWindowTypeDropdownMenuMask ||
97
 
        window->type () == CompWindowTypePopupMenuMask)
98
 
    {
99
 
        /* Other transient menus should clip
100
 
         * this menu's shadows, also the panel
101
 
         * which is a transient parent should
102
 
         * too */
103
 
 
104
 
        CompWindowList::iterator it = std::find (screen->windows ().begin (),
105
 
                                                 screen->windows ().end (),
106
 
                                                 window);
107
 
 
108
 
        for (it--; it != screen->windows ().end (); it--)
109
 
        {
110
 
            if (!(*it)->isViewable ())
111
 
                continue;
112
 
 
113
 
            if (!((*it)->type () == CompWindowTypeDropdownMenuMask ||
114
 
                  (*it)->type () == CompWindowTypePopupMenuMask ||
115
 
                  (*it)->type () == CompWindowTypeDockMask))
116
 
                continue;
117
 
 
118
 
            /* window needs to be a transient parent */
119
 
            if (!isAncestorTo (window, (*it)))
120
 
                continue;
121
 
 
122
 
            CompRegion inter (shadowRegion);
123
 
            inter &= (*it)->borderRect ();
124
 
 
125
 
            if (!inter.isEmpty ())
126
 
                shadowRegion -= inter;
127
 
        }
128
 
 
129
 
        /* If the region didn't change, then it is safe to
130
 
         * say that that this window was probably the first
131
 
         * menu in the "chain" of dropdown menus that comes
132
 
         * from a menu-bar - in that case there isn't any
133
 
         * window that the shadow would necessarily occlude
134
 
         * here so clip the shadow to the top of the input
135
 
         * rect.
136
 
         *
137
 
         * FIXME: We need a better way to detect exactly
138
 
         * where the menubar is for the dropdown menu,
139
 
         * that will look a lot better.
140
 
         */
141
 
        if (window->type () == CompWindowTypeDropdownMenuMask &&
142
 
            shadowRegion == CompRegionRef (window->outputRect ().region ()))
143
 
        {
144
 
            CompRect area (window->outputRect ().x1 (),
145
 
                           window->outputRect ().y1 (),
146
 
                           window->outputRect ().width (),
147
 
                           window->inputRect ().y1 () -
148
 
                           window->outputRect ().y1 ());
149
 
 
150
 
            shadowRegion -= area;
151
 
        }
152
 
    }
153
 
}
154
 
 
155
123
/*
156
124
 * DecorWindow::glDraw
157
125
 *
1521
1489
    if (dScreen->cmActive)
1522
1490
    {
1523
1491
        cWindow->damageOutputExtents ();
1524
 
        computeShadowRegion ();
 
1492
        updateGroupShadows ();
1525
1493
    }
1526
1494
 
1527
1495
    /* Determine how much we moved the window for the old
1565
1533
        if (decorate)
1566
1534
            updateFrame ();
1567
1535
        window->updateWindowOutputExtents ();
 
1536
        mOutputRegion = CompRegion (window->outputRect ());
 
1537
        updateGroupShadows ();
1568
1538
        if (dScreen->cmActive)
1569
1539
            cWindow->damageOutputExtents ();
1570
1540
        updateDecorationScale ();
2196
2166
                break;
2197
2167
            }
2198
2168
 
 
2169
            /* For non-switcher windows we need to update the decoration
 
2170
             * anyways, since the window is unmapped. Also need to
 
2171
             * update the shadow clip regions for panels and other windows */
 
2172
            update (true);
 
2173
            if (dScreen->mMenusClipGroup.pushClippable (this))
 
2174
                updateGroupShadows ();
 
2175
 
 
2176
            break;
 
2177
 
2199
2178
        case CompWindowNotifyUnmap:
 
2179
        {
2200
2180
 
2201
2181
            /* When the switcher is unmapped, it has no frame window
2202
2182
             * so the frame window for it needs to unmapped manually */
2211
2191
             * anyways, since the window is unmapped. Also need to
2212
2192
             * update the shadow clip regions for panels and other windows */
2213
2193
            update (true);
2214
 
            if (dScreen->cmActive)
2215
 
            {
2216
 
                foreach (CompWindow *cw, DecorScreen::get (screen)->cScreen->getWindowPaintList ())
2217
 
                {
2218
 
                    DecorWindow::get (cw)->computeShadowRegion ();
2219
 
                }
2220
 
            }
 
2194
 
 
2195
            /* Preserve the group shadow update ptr */
 
2196
            DecorClipGroupInterface *clipGroup = mClipGroup;
 
2197
 
 
2198
            if (dScreen->mMenusClipGroup.popClippable (this))
 
2199
                if (clipGroup)
 
2200
                    clipGroup->updateAllShadows ();
2221
2201
            break;
 
2202
        }
2222
2203
        case CompWindowNotifyUnreparent:
2223
2204
        {
2224
2205
            /* Compiz detaches the frame window from
2410
2391
                if (w)
2411
2392
                    DecorWindow::get (w)->update (true);
2412
2393
            }
2413
 
            /* On a transient change, we need to recompute shadow regions
2414
 
             * for eg, menus */
2415
 
            else if (event->xproperty.atom == XA_WM_TRANSIENT_FOR)
2416
 
            {
2417
 
                if (cmActive)
2418
 
                {
2419
 
                    foreach (CompWindow *cw, cScreen->getWindowPaintList ())
2420
 
                    {
2421
 
                        DecorWindow::get (cw)->computeShadowRegion ();
2422
 
                    }
2423
 
                }
2424
 
            }
2425
2394
            else
2426
2395
            {
2427
2396
                if (event->xproperty.window == screen->root ())
2749
2718
    }
2750
2719
    updateReg = true;
2751
2720
 
2752
 
    if (dScreen->cmActive)
2753
 
    {
2754
 
        foreach (CompWindow *cw,
2755
 
                 DecorScreen::get (screen)->cScreen->getWindowPaintList ())
2756
 
        {
2757
 
            DecorWindow::get (cw)->computeShadowRegion ();
2758
 
        }
2759
 
    }
 
2721
    mInputRegion.translate (dx, dy);
 
2722
    mOutputRegion.translate (dx, dy);
 
2723
 
 
2724
    if (dScreen->cmActive && mClipGroup)
 
2725
        updateGroupShadows ();
2760
2726
 
2761
2727
    window->moveNotify (dx, dy, immediate);
2762
2728
}
2809
2775
    updateDecorationScale ();
2810
2776
    updateReg = true;
2811
2777
 
2812
 
    if (dScreen->cmActive)
2813
 
    {
2814
 
        foreach (CompWindow *cw,
2815
 
                 DecorScreen::get (screen)->cScreen->getWindowPaintList ())
2816
 
        {
2817
 
            DecorWindow::get (cw)->computeShadowRegion ();
2818
 
        }
2819
 
    }
 
2778
    mInputRegion = CompRegion (window->inputRect ());
 
2779
    mOutputRegion = CompRegion (window->outputRect ());
 
2780
    if (dScreen->cmActive && mClipGroup)
 
2781
        updateGroupShadows ();
2820
2782
 
2821
2783
    window->resizeNotify (dx, dy, dwidth, dheight);
2822
2784
}
2984
2946
                                   0,
2985
2947
                                   None,
2986
2948
                                   boost::shared_array <decor_quad_t> (NULL),
2987
 
                                   0))
 
2949
                                   0)),
 
2950
    mMenusClipGroup (CompMatch ("type=Dock | type=DropdownMenu | type=PopupMenu"))
2988
2951
{
2989
2952
    supportingDmCheckAtom =
2990
2953
        XInternAtom (s->dpy (), DECOR_SUPPORTING_DM_CHECK_ATOM_NAME, 0);
3058
3021
    unshading (false),
3059
3022
    shading (false),
3060
3023
    isSwitcher (false),
3061
 
    frameExtentsRequested (false)
 
3024
    frameExtentsRequested (false),
 
3025
    mClipGroup (NULL),
 
3026
    mOutputRegion (window->outputRect ()),
 
3027
    mInputRegion (window->inputRect ())
3062
3028
{
3063
3029
    WindowInterface::setHandler (window);
3064
3030
 
3087
3053
    }
3088
3054
 
3089
3055
    window->resizeNotifySetEnabled (this, true);
 
3056
 
 
3057
    if (!window->invisible ())
 
3058
        if (dScreen->mMenusClipGroup.pushClippable (this))
 
3059
            updateGroupShadows ();
3090
3060
}
3091
3061
 
3092
3062
/* 
3103
3073
    if (wd)
3104
3074
        WindowDecoration::destroy (wd);
3105
3075
 
 
3076
    if (mClipGroup)
 
3077
        mClipGroup->popClippable (this);
 
3078
 
3106
3079
    decor.mList.clear ();
3107
3080
}
3108
3081