diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2012-10-18 00:47:16 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2012-10-18 00:47:16 +0200 |
| commit | 7eae4aebef3ca70b908f28c50722facf4f530724 (patch) | |
| tree | c05551c9774de208b7eaf59c7354af7c7fae66b2 /plugins/unityshell/src | |
| parent | cd5b8210769c9ad0f8585c68631eb7e3384dc00a (diff) | |
UnityWindow: use the window glow to round the switcher selected window
(bzr r2846.1.4)
Diffstat (limited to 'plugins/unityshell/src')
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 79 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 5 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell_glow.cpp | 5 |
3 files changed, 48 insertions, 41 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 3bccc2011..eb8a5146e 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -113,7 +113,7 @@ namespace decoration const unsigned CLOSE_SIZE = 19; const unsigned ITEMS_PADDING = 5; const unsigned RADIUS = 8; -const unsigned GLOW = 30; +const unsigned GLOW = 35; const nux::Color GLOW_COLOR(221, 72, 20); } // decoration namespace } // scale namespace @@ -777,18 +777,21 @@ void UnityScreen::paintDisplay() } } - if (switcher_controller_->Visible ()) + if (switcher_controller_->Visible()) { - LayoutWindowList targets = switcher_controller_->ExternalRenderTargets (); + LayoutWindowList const& targets = switcher_controller_->ExternalRenderTargets(); - for (LayoutWindow::Ptr target : targets) + if (!targets.empty()) { - CompWindow* window = screen->findWindow(target->xid); - if (window) - { - UnityWindow *unity_window = UnityWindow::get (window); + UnityWindow::SetupSharedTextures(); - unity_window->paintThumbnail (target->result, target->alpha); + for (LayoutWindow::Ptr const& target : targets) + { + if (CompWindow* window = screen->findWindow(target->xid)) + { + UnityWindow *unity_window = UnityWindow::get (window); + unity_window->paintThumbnail(target->result, target->alpha); + } } } } @@ -852,28 +855,6 @@ bool UnityScreen::forcePaintOnTop () && !fullscreen_windows_.empty () && (!(screen->grabbed () && !screen->otherGrabExist (NULL)))); } -void UnityWindow::paintThumbnail (nux::Geometry const& bounding, float alpha) -{ - GLMatrix matrix; - matrix.toScreenSpace (UnityScreen::get (screen)->_last_output, -DEFAULT_Z_CAMERA); - - nux::Geometry geo = bounding; - last_bound = geo; - - GLWindowPaintAttrib attrib = gWindow->lastPaintAttrib (); - attrib.opacity = (GLushort) (alpha * G_MAXUSHORT); - - paintThumb (attrib, - matrix, - 0, - geo.x, - geo.y, - geo.width, - geo.height, - geo.width, - geo.height); -} - void UnityScreen::EnableCancelAction(CancelActionTarget target, bool enabled, int modifiers) { if (enabled) @@ -2478,11 +2459,8 @@ bool UnityWindow::glPaint(const GLWindowPaintAttrib& attrib, if (WindowManager::Default().IsScaleActive() && ScaleScreen::get(screen)->getSelectedWindow() == window->id()) { - nux::Geometry scaled_geo = GetScaledGeometry(); - int inside_glow = scale::decoration::RADIUS/4; - scaled_geo.Expand(-inside_glow, -inside_glow); - glow::Quads const& quads = computeGlowQuads(scaled_geo, glow_texture_, scale::decoration::GLOW); - paintGlow(matrix, attrib, region, quads, glow_texture_, scale::decoration::GLOW_COLOR, mask); + nux::Geometry const& scaled_geo = GetScaledGeometry(); + paintInnerGlow(scaled_geo, matrix, attrib, mask); } return gWindow->glPaint(wAttrib, matrix, region, mask); @@ -3943,6 +3921,35 @@ void UnityWindow::OnTerminateSpread() CleanupCachedTextures(); } +void UnityWindow::paintInnerGlow(nux::Geometry glow_geo, GLMatrix const& matrix, GLWindowPaintAttrib const& attrib, unsigned mask) +{ + // We paint the glow below the window edges to correctly glow the rounded corners + int inside_glow = scale::decoration::RADIUS/4; + glow_geo.Expand(-inside_glow, -inside_glow); + glow::Quads const& quads = computeGlowQuads(glow_geo, glow_texture_, scale::decoration::GLOW); + paintGlow(matrix, attrib, quads, glow_texture_, scale::decoration::GLOW_COLOR, mask); +} + +void UnityWindow::paintThumbnail(nux::Geometry const& bounding, float alpha) +{ + GLMatrix matrix; + matrix.toScreenSpace(UnityScreen::get(screen)->_last_output, -DEFAULT_Z_CAMERA); + last_bound = bounding; + + GLWindowPaintAttrib attrib = gWindow->lastPaintAttrib(); + attrib.opacity = (GLushort) (alpha * G_MAXUSHORT); + unsigned mask = 0; + + if (alpha >= 1.0f) + { + // The fully opaque window, is the selected one by contract. + paintInnerGlow(bounding, matrix, attrib, mask); + } + + nux::Geometry const& g = bounding; + paintThumb(attrib, matrix, mask, g.x, g.y, g.width, g.height, g.width, g.height); +} + UnityWindow::~UnityWindow() { UnityScreen* us = UnityScreen::get(screen); diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 48e2d2f53..e44201d10 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -450,9 +450,10 @@ private: void DrawTexture(GLTexture::List const& textures, GLWindowPaintAttrib const&, GLMatrix const&, unsigned mask, int x, int y, double aspect = 1.0f); + void paintInnerGlow(nux::Geometry glow_geo, GLMatrix const&, GLWindowPaintAttrib const&, unsigned mask); glow::Quads computeGlowQuads(nux::Geometry const& geo, GLTexture::List const& texture, int glow_size); - void paintGlow(GLMatrix const&, GLWindowPaintAttrib const&, CompRegion const&, - glow::Quads const&, GLTexture::List const&, nux::Color const&, unsigned mask); + void paintGlow(GLMatrix const&, GLWindowPaintAttrib const&, glow::Quads const&, + GLTexture::List const&, nux::Color const&, unsigned mask); void BuildDecorationTexture(); void CleanupCachedTextures(); diff --git a/plugins/unityshell/src/unityshell_glow.cpp b/plugins/unityshell/src/unityshell_glow.cpp index 004ac54b0..2730a8195 100644 --- a/plugins/unityshell/src/unityshell_glow.cpp +++ b/plugins/unityshell/src/unityshell_glow.cpp @@ -39,9 +39,8 @@ namespace unity void UnityWindow::paintGlow(GLMatrix const& transform, GLWindowPaintAttrib const& attrib, - CompRegion const& paintRegion, glow::Quads const& glow_quads, - GLTexture::List const& outline_texture, nux::Color const& color, - unsigned mask) + glow::Quads const& glow_quads, GLTexture::List const& outline_texture, + nux::Color const& color, unsigned mask) { GLushort colorData[4]; colorData[0] = color.red * 0xffff; |
