summaryrefslogtreecommitdiff
path: root/plugins/unityshell
diff options
authorDaniel van Vugt <daniel.van.vugt@canonical.com>2012-09-07 17:23:29 +0800
committerDaniel van Vugt <daniel.van.vugt@canonical.com>2012-09-07 17:23:29 +0800
commit99eafd28707111445f1373152b7204080e4f66a7 (patch)
treec5e4f9858a83b1fdc9a8d86be245d7bf319b691d /plugins/unityshell
parent4776de183ecbcb38ea42bcd2d883136f00f3c981 (diff)
Restore the panel shadow, which has been missing since Unity 6.4.
(LP: #1045705) Unfortunately (or fortunately IMHO) this only draws the panel shadow on the desktop. So far I have only been able to make the shadow draw on all windows (including active) or just the desktop. This may be a restriction we have to accept until/unless panel shadow rendering is moved into compiz itself, or some nice person can find a way to make it work... ? Fixes LP: #1045705 (bzr r2668.3.1)
Diffstat (limited to 'plugins/unityshell')
-rw-r--r--plugins/unityshell/src/unityshell.cpp72
-rw-r--r--plugins/unityshell/src/unityshell.h2
2 files changed, 38 insertions, 36 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index 33e8e4e64..c54dc1756 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -573,7 +573,7 @@ void UnityScreen::setPanelShadowMatrix(const GLMatrix& matrix)
panel_shadow_matrix_ = matrix;
}
-void UnityScreen::paintPanelShadow(const GLMatrix& matrix)
+void UnityScreen::paintPanelShadow(const GLMatrix& matrix, const CompRegion &clip)
{
#ifndef USE_MODERN_COMPIZ_GL
if (sources_.GetSource(local::RELAYOUT_TIMEOUT))
@@ -653,7 +653,6 @@ void UnityScreen::paintPanelShadow(const GLMatrix& matrix)
}
glPopMatrix();
#else
- return;
if (sources_.GetSource(local::RELAYOUT_TIMEOUT))
return;
@@ -661,23 +660,36 @@ void UnityScreen::paintPanelShadow(const GLMatrix& matrix)
if (PluginAdapter::Default()->IsExpoActive())
return;
- nuxPrologue();
-
CompOutput* output = _last_output;
- float vc[4];
- float h = 20.0f;
- float w = 1.0f;
float panel_h = static_cast<float>(panel_style_.panel_height);
- float x1 = output->x();
- float y1 = output->y() + panel_h;
- float x2 = x1 + output->width();
- float y2 = y1 + h;
+ float shadowX = output->x();
+ float shadowY = output->y() + panel_h;
+ float shadowWidth = output->width();
+ float shadowHeight = _shadow_texture[0]->height();
+ CompRect shadowRect(shadowX, shadowY, shadowWidth, shadowHeight);
- vc[0] = x1;
- vc[1] = x2;
- vc[2] = y1;
- vc[3] = y2;
+ CompRegion redraw(clip);
+ redraw &= shadowRect;
+
+ if (redraw.isEmpty())
+ return;
+
+ CompRect bounds(redraw.boundingRect());
+
+ // Sub-rectangle of the shadow needing redrawing:
+ float x1 = bounds.x1();
+ float y1 = bounds.y1();
+ float x2 = bounds.x2();
+ float y2 = bounds.y2();
+
+ // Texture coordinates of the above rectangle:
+ float tx1 = (x1 - shadowX) / shadowWidth;
+ float ty1 = (y1 - shadowY) / shadowHeight;
+ float tx2 = (x2 - shadowX) / shadowWidth;
+ float ty2 = (y2 - shadowY) / shadowHeight;
+
+ nuxPrologue();
// compiz doesn't use the same method of tracking monitors as our toolkit
// we need to make sure we properly associate with the right monitor
@@ -718,17 +730,17 @@ void UnityScreen::paintPanelShadow(const GLMatrix& matrix)
};
vertexData = {
- vc[0], vc[2], 0,
- vc[0], vc[3], 0,
- vc[1], vc[2], 0,
- vc[1], vc[3], 0,
+ x1, y1, 0,
+ x1, y2, 0,
+ x2, y1, 0,
+ x2, y2, 0,
};
textureData = {
- COMP_TEX_COORD_X(tex->matrix(), 0), COMP_TEX_COORD_Y(tex->matrix(), 0),
- COMP_TEX_COORD_X(tex->matrix(), 0), COMP_TEX_COORD_Y(tex->matrix(), h),
- COMP_TEX_COORD_X(tex->matrix(), w), COMP_TEX_COORD_Y(tex->matrix(), 0),
- COMP_TEX_COORD_X(tex->matrix(), w), COMP_TEX_COORD_Y(tex->matrix(), h),
+ tx1, ty1,
+ tx1, ty2,
+ tx2, ty1,
+ tx2, ty2,
};
streamingBuffer->begin(GL_TRIANGLE_STRIP);
@@ -2610,20 +2622,10 @@ bool UnityWindow::glDraw(const GLMatrix& matrix,
if (window->type() == CompWindowTypeDesktopMask)
uScreen->setPanelShadowMatrix(matrix);
- Window active_window = screen->activeWindow();
- if (window->id() == active_window && window->type() != CompWindowTypeDesktopMask)
- {
- uScreen->paintPanelShadow(matrix);
- }
-
bool ret = gWindow->glDraw(matrix, attrib, region, mask);
- if ((active_window == 0 || active_window == window->id()) &&
- (window->type() == CompWindowTypeDesktopMask))
- {
- uScreen->paintPanelShadow(matrix);
- }
-
+ if (window->type() == CompWindowTypeDesktopMask)
+ uScreen->paintPanelShadow(matrix, region);
return ret;
}
diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h
index 21498f0cf..a63dde451 100644
--- a/plugins/unityshell/src/unityshell.h
+++ b/plugins/unityshell/src/unityshell.h
@@ -102,7 +102,7 @@ public:
#else
void paintDisplay(const CompRegion& region, const GLMatrix& transform, unsigned int mask);
#endif
- void paintPanelShadow(const GLMatrix& matrix);
+ void paintPanelShadow(const GLMatrix& matrix, const CompRegion &clip);
void setPanelShadowMatrix(const GLMatrix& matrix);
void preparePaint (int ms);