From 69ad089958c6063afe5df15b4fa33b226875b452 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Wed, 4 Jul 2007 18:24:54 +0000 Subject: [PATCH] Give the shadow a minimum size (otherwise rounded corners will break) svn path=/trunk/KDE/kdebase/workspace/; revision=683444 --- effects/shadow.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/effects/shadow.cpp b/effects/shadow.cpp index c257d02a2e..f49b44101b 100644 --- a/effects/shadow.cpp +++ b/effects/shadow.cpp @@ -78,17 +78,19 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, W glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + int fuzzy = shadowFuzzyness; + // Shadow's size must be a least 2*fuzzy in both directions (or the corners will be broken) + int w = qMax(fuzzy*2, window->width()); + int h = qMax(fuzzy*2, window->height()); + glPushMatrix(); if( mask & PAINT_WINDOW_TRANSFORMED ) glTranslatef( data.xTranslate, data.yTranslate, 0 ); - glTranslatef( window->x() + shadowXOffset, window->y() + shadowYOffset, 0 ); + glTranslatef( window->x() + shadowXOffset - qMax(0, w - window->width()) / 2.0, + window->y() + shadowYOffset - qMax(0, h - window->height()) / 2.0, 0 ); if(( mask & PAINT_WINDOW_TRANSFORMED ) && ( data.xScale != 1 || data.yScale != 1 )) glScalef( data.xScale, data.yScale, 1 ); - int w = window->width(); - int h = window->height(); - int fuzzy = shadowFuzzyness; - QVector verts, texcoords; // center addQuadVertices(verts, 0 + fuzzy, 0 + fuzzy, w - fuzzy, h - fuzzy); @@ -121,7 +123,9 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, W addQuadVertices(texcoords, 0.5, 0.5, 1.0, 1.0); mShadowTexture->bind(); - glColor4f(0, 0, 0, shadowOpacity * data.opacity); + // Take the transparency settings and window's transparency into account. + // Also make the shadow more transparent if we've made it bigger + glColor4f(0, 0, 0, shadowOpacity * data.opacity * (window->width() / (float)w) * (window->height() / (float)h)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // We have two elements per vertex in the verts array int verticesCount = verts.count() / 2;