From 56358efc188ae1804efde40fb390ce65af94a8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 24 Feb 2014 19:21:09 +0100 Subject: UnityWindow: take care of window dpi scale when drawing fake decorations Fixes LP: #1283453 (bzr r3680.1.18) --- plugins/unityshell/src/unityshell.cpp | 43 +++++++++++++++++------------------ plugins/unityshell/src/unityshell.h | 2 +- 2 files changed, 22 insertions(+), 23 deletions(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index fdb619d44..19ce5409d 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -3817,8 +3817,7 @@ void UnityWindow::DrawTexture(GLTexture::List const& textures, if (texture->width() && texture->height()) { - GLTexture::MatrixList ml(1); - ml[0] = texture->matrix(); + GLTexture::MatrixList ml({texture->matrix()}); CompRegion texture_region(0, 0, texture->width(), texture->height()); gWindow->glAddGeometry(ml, texture_region, texture_region); } @@ -3841,16 +3840,13 @@ void UnityWindow::RenderDecoration(compiz_utils::CairoContext const& ctx, double using namespace decoration; - // We need to scale the cairo matrix in order to get the properly scaled - cairo_save(ctx); - cairo_scale(ctx, aspect, aspect); - int w = std::round(ctx.width() / aspect); - int h = std::round(ctx.height() / aspect); + aspect *= deco_win_->dpi_scale(); + double w = ctx.width() / aspect; + double h = ctx.height() / aspect; Style::Get()->DrawSide(Side::TOP, WidgetState::NORMAL, ctx, w, h); - cairo_restore(ctx); } -void UnityWindow::RenderTitle(compiz_utils::CairoContext const& ctx, int x, int y, int width, int height) +void UnityWindow::RenderTitle(compiz_utils::CairoContext const& ctx, int x, int y, int width, int height, double aspect) { using namespace decoration; auto const& style = Style::Get(); @@ -3860,6 +3856,7 @@ void UnityWindow::RenderTitle(compiz_utils::CairoContext const& ctx, int x, int y += (height - text_size.height)/2; cairo_save(ctx); + cairo_scale(ctx, 1.0f/aspect, 1.0f/aspect); cairo_translate(ctx, x, y); style->DrawTitle(title, WidgetState::NORMAL, ctx, width - x, height); cairo_restore(ctx); @@ -3867,14 +3864,12 @@ void UnityWindow::RenderTitle(compiz_utils::CairoContext const& ctx, int x, int void UnityWindow::BuildDecorationTexture() { - if (decoration_tex_) - return; - auto const& border = decoration::Style::Get()->Border(); if (border.top) { - compiz_utils::CairoContext context(window->borderRect().width(), border.top); + double dpi_scale = deco_win_->dpi_scale(); + compiz_utils::CairoContext context(window->borderRect().width(), border.top * dpi_scale, dpi_scale); RenderDecoration(context); decoration_tex_ = context; } @@ -3896,7 +3891,8 @@ void UnityWindow::paintFakeDecoration(nux::Geometry const& geo, GLWindowPaintAtt if (!compiz_utils::IsWindowFullyDecorable(window)) return; - BuildDecorationTexture(); + if (!decoration_tex_) + BuildDecorationTexture(); if (decoration_tex_) DrawTexture(*decoration_tex_, attrib, transform, mask, geo.x, geo.y, scale); @@ -3906,8 +3902,9 @@ void UnityWindow::paintFakeDecoration(nux::Geometry const& geo, GLWindowPaintAtt else { auto const& style = decoration::Style::Get(); + double dpi_scale = deco_win_->dpi_scale(); int width = geo.width; - int height = style->Border().top; + int height = style->Border().top * dpi_scale; auto const& padding = style->Padding(decoration::Side::TOP); bool redraw_decoration = true; compiz_utils::SimpleTexture::Ptr close_texture; @@ -3932,12 +3929,12 @@ void UnityWindow::paintFakeDecoration(nux::Geometry const& geo, GLWindowPaintAtt { if (width != 0 && height != 0) { - compiz_utils::CairoContext context(width, height); + compiz_utils::CairoContext context(width, height, scale * dpi_scale); RenderDecoration(context, scale); // Draw window title int text_x = padding.left + (close_texture ? close_texture->width() : 0); - RenderTitle(context, text_x, padding.top, width - padding.right, height); + RenderTitle(context, text_x, padding.top, (width - padding.right) / dpi_scale, height / dpi_scale, scale); decoration_selected_tex_ = context; uScreen->damageRegion(CompRegionFromNuxGeo(geo)); } @@ -3953,11 +3950,13 @@ void UnityWindow::paintFakeDecoration(nux::Geometry const& geo, GLWindowPaintAtt if (close_texture) { - int x = geo.x + padding.left; - int y = geo.y + padding.top + (height - close_texture->height()) / 2.0f; + int w = close_texture->width() * dpi_scale; + int h = close_texture->height() * dpi_scale; + int x = geo.x + padding.left * dpi_scale; + int y = geo.y + padding.top * dpi_scale + (height - w) / 2.0f; - close_button_geo_.Set(x, y, close_texture->width(), close_texture->height()); - DrawTexture(*close_texture, attrib, transform, mask, x, y); + close_button_geo_.Set(x, y, w, h); + DrawTexture(*close_texture, attrib, transform, mask, x, y, dpi_scale); } else { @@ -4054,7 +4053,7 @@ void UnityWindow::paintInnerGlow(nux::Geometry glow_geo, GLMatrix const& matrix, { // We paint the glow below the window edges to correctly // render the rounded corners - int inside_glow = decoration_radius / 4; + int inside_glow = decoration_radius * deco_win_->dpi_scale() / 4; glow_size += inside_glow; glow_geo.Expand(-inside_glow, -inside_glow); } diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index ce7890168..5a8e22b91 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -519,7 +519,7 @@ private: compiz::WindowInputRemoverLock::Ptr GetInputRemover (); void RenderDecoration(compiz_utils::CairoContext const&, double aspect = 1.0f); - void RenderTitle(compiz_utils::CairoContext const&, int x, int y, int width, int height); + void RenderTitle(compiz_utils::CairoContext const&, int x, int y, int width, int height, double aspect = 1.0f); void DrawTexture(GLTexture::List const& textures, GLWindowPaintAttrib const&, GLMatrix const&, unsigned mask, int x, int y, double aspect = 1.0f); -- cgit v1.2.3 From 2ae61696d54e4d6d15b718e316fc04fdca592f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Feb 2014 00:18:47 +0100 Subject: UnityScreen: draw panel under dash using the proper panel size (bzr r3680.1.21) --- plugins/unityshell/src/unityshell.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 19ce5409d..7e0a7b901 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -890,10 +890,12 @@ void UnityScreen::paintDisplay() void UnityScreen::DrawPanelUnderDash() { - if (!paint_panel_under_dash_ || !launcher_controller_->IsOverlayOpen()) + if (!paint_panel_under_dash_ || (!dash_controller_->IsVisible() && !hud_controller_->IsVisible())) return; - if (_last_output->id() != screen->currentOutputDev().id()) + auto const& output_dev = screen->currentOutputDev(); + + if (_last_output->id() != output_dev.id()) return; auto graphics_engine = nux::GetGraphicsDisplay()->GetGraphicsEngine(); @@ -904,18 +906,17 @@ void UnityScreen::DrawPanelUnderDash() graphics_engine->ResetModelViewMatrixStack(); graphics_engine->Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f); graphics_engine->ResetProjectionMatrix(); - graphics_engine->SetOrthographicProjectionMatrix(screen->width(), screen->height()); + graphics_engine->SetOrthographicProjectionMatrix(output_dev.width(), output_dev.height()); nux::TexCoordXForm texxform; texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP); - // FIXME Change to paint per monitor vs all at once - int panel_height = panel_style_.PanelHeight(); - auto const& texture = panel_style_.GetBackground()->GetDeviceTexture(); - graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width(), panel_height, texture, texxform, nux::color::White); + int monitor = WindowManager::Default().MonitorGeometryIn(NuxGeometryFromCompRect(output_dev)); + auto const& texture = panel_style_.GetBackground(monitor)->GetDeviceTexture(); + graphics_engine->QRP_GLSL_1Tex(0, 0, output_dev.width(), texture->GetHeight(), texture, texxform, nux::color::White); } -bool UnityScreen::forcePaintOnTop () +bool UnityScreen::forcePaintOnTop() { return !allowWindowPaint || ((switcher_controller_->Visible() || -- cgit v1.2.3 From 7056e89f6e9bb9722b916fe743bf5eec691ba611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Feb 2014 20:25:49 +0100 Subject: UnityWindow: scale the glow size as well to match DPI (bzr r3680.1.45) --- plugins/unityshell/src/unityshell.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 7e0a7b901..67cfd1cbc 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -4041,7 +4041,8 @@ void UnityWindow::paintInnerGlow(nux::Geometry glow_geo, GLMatrix const& matrix, { using namespace decoration; auto const& style = Style::Get(); - unsigned glow_size = style->GlowSize(); + double dpi_scale = deco_win_->dpi_scale(); + unsigned glow_size = std::round(style->GlowSize() * dpi_scale); auto const& glow_texture = DataPool::Get()->GlowTexture(); if (!glow_size || !glow_texture) @@ -4054,7 +4055,7 @@ void UnityWindow::paintInnerGlow(nux::Geometry glow_geo, GLMatrix const& matrix, { // We paint the glow below the window edges to correctly // render the rounded corners - int inside_glow = decoration_radius * deco_win_->dpi_scale() / 4; + int inside_glow = decoration_radius * dpi_scale / 4; glow_size += inside_glow; glow_geo.Expand(-inside_glow, -inside_glow); } -- cgit v1.2.3 From 153bfcfe7b803638a34a62281375b22b49762c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 27 Feb 2014 00:21:34 +0100 Subject: UnityScreen: cache some functions results (bzr r3680.1.66) --- plugins/unityshell/src/unityshell.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 67cfd1cbc..c4f8c57db 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -2853,9 +2853,12 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, const CompRegion& region, unsigned int mask) { - if (uScreen->doShellRepaint && !uScreen->paint_panel_under_dash_ && window->type() == CompWindowTypeNormalMask) + auto window_state = window->state(); + auto window_type = window->type(); + + if (uScreen->doShellRepaint && !uScreen->paint_panel_under_dash_ && window_type == CompWindowTypeNormalMask) { - if ((window->state() & MAXIMIZE_STATE) && window->onCurrentDesktop() && !window->overrideRedirect() && window->managed()) + if ((window_state & MAXIMIZE_STATE) && window->onCurrentDesktop() && !window->overrideRedirect() && window->managed()) { CompPoint const& viewport = window->defaultViewport(); unsigned output = window->outputDevice(); @@ -2888,7 +2891,7 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, { Window active_window = screen->activeWindow(); - if (G_UNLIKELY(window->type() == CompWindowTypeDesktopMask)) + if (G_UNLIKELY(window_type == CompWindowTypeDesktopMask)) { uScreen->setPanelShadowMatrix(matrix); @@ -2908,9 +2911,9 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, draw_panel_shadow = DrawPanelShadow::BELOW_WINDOW; uScreen->is_desktop_active_ = false; - if (!(window->state() & CompWindowStateMaximizedVertMask) && - !(window->state() & CompWindowStateFullscreenMask) && - !(window->type() & CompWindowTypeFullscreenMask)) + if (!(window_state & CompWindowStateMaximizedVertMask) && + !(window_state & CompWindowStateFullscreenMask) && + !(window_type & CompWindowTypeFullscreenMask)) { WindowManager& wm = WindowManager::Default(); auto const& output = uScreen->screen->currentOutputDev(); -- cgit v1.2.3 From e8df89377f7cd2bcbce7bd7110cd83cb75c4c0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 27 Feb 2014 08:11:16 +0100 Subject: DecorationsWindowButton: use scaled Window Button textures, enjoy the visual quality! Well, better with SVGs ;) (bzr r3680.1.81) --- plugins/unityshell/src/unityshell.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index c4f8c57db..6eee23136 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -3926,7 +3926,7 @@ void UnityWindow::paintFakeDecoration(nux::Geometry const& geo, GLWindowPaintAtt if (window->actions() & CompWindowActionCloseMask) { using namespace decoration; - close_texture = DataPool::Get()->ButtonTexture(WindowButtonType::CLOSE, close_icon_state_); + close_texture = DataPool::Get()->ButtonTexture(dpi_scale, WindowButtonType::CLOSE, close_icon_state_); } if (redraw_decoration) @@ -3954,13 +3954,13 @@ void UnityWindow::paintFakeDecoration(nux::Geometry const& geo, GLWindowPaintAtt if (close_texture) { - int w = close_texture->width() * dpi_scale; - int h = close_texture->height() * dpi_scale; + int w = close_texture->width(); + int h = close_texture->height(); int x = geo.x + padding.left * dpi_scale; int y = geo.y + padding.top * dpi_scale + (height - w) / 2.0f; close_button_geo_.Set(x, y, w, h); - DrawTexture(*close_texture, attrib, transform, mask, x, y, dpi_scale); + DrawTexture(*close_texture, attrib, transform, mask, x, y); } else { -- cgit v1.2.3 From 70e15787d1b61b99d86cb8fbebc4cb0a732d8357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 27 Feb 2014 09:24:01 +0100 Subject: UnityWindow: fix text indentation on fake decorations now that we've scaled buttons (bzr r3680.1.85) --- plugins/unityshell/src/unityshell.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 6eee23136..1cd3e0bea 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -3937,7 +3937,7 @@ void UnityWindow::paintFakeDecoration(nux::Geometry const& geo, GLWindowPaintAtt RenderDecoration(context, scale); // Draw window title - int text_x = padding.left + (close_texture ? close_texture->width() : 0); + int text_x = padding.left + (close_texture ? close_texture->width() : 0) / dpi_scale; RenderTitle(context, text_x, padding.top, (width - padding.right) / dpi_scale, height / dpi_scale, scale); decoration_selected_tex_ = context; uScreen->damageRegion(CompRegionFromNuxGeo(geo)); -- cgit v1.2.3