[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.4/kdebase/runtime/kstyles/oxygen
From:       Hugo Pereira Da Costa <hugo.pereira () free ! fr>
Date:       2010-05-16 15:32:06
Message-ID: 20100516153206.41475AC8B5 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1127437 by hpereiradacosta:

Backport r1127429
Check QX11Info::depth() to decide whether alphachannel can be use to paint widgets like 
QMenu, ComboBox containers, detached toolbars and detached 
dockpanels.
CCBUG: 237772


 M  +37 -35    oxygen.cpp  
 M  +3 -0      oxygen.h  


--- branches/KDE/4.4/kdebase/runtime/kstyles/oxygen/oxygen.cpp #1127436:1127437
@@ -52,6 +52,7 @@
 #include <QtGui/QToolBox>
 #include <QtGui/QToolButton>
 #include <QtGui/QDial>
+#include <QtGui/QX11Info>
 
 #include <QtDBus/QtDBus>
 
@@ -5494,18 +5495,16 @@
         {
 
             // mask should be returned only if composite in disabled
-            if( !( compositingActive() ) )
+            if( !hasAlphaChannel( widget ) )
             {
                 if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData))
                 { mask->region = _helper.roundedMask( option->rect ); }
-                return true;
 
-            } else {
+            }
 
-                return KStyle::styleHint(hint, option, widget, returnData);
+            return true;
 
             }
-        }
 
         case SH_ItemView_ArrowKeysNavigateIntoChildren:
         return true;
@@ -6144,7 +6143,7 @@
             case QEvent::Resize:
             {
                 // make sure mask appropriate
-                if( !compositingActive() )
+                if( !hasAlphaChannel(t) )
                 {
 
                     QRegion mask( _helper.roundedMask( t->rect() ) );
@@ -6181,7 +6180,8 @@
 
                 }
 
-                if( compositingActive() )
+                bool hasAlpha( hasAlphaChannel(t) );
+                if( hasAlpha )
                 {
                     p.setCompositionMode(QPainter::CompositionMode_Source );
                     TileSet *tileSet( _helper.roundCorner(color) );
@@ -6212,7 +6212,7 @@
                 }
 
                 // frame
-                if( compositingActive() ) p.setClipping( false );
+                if( hasAlpha ) p.setClipping( false );
                 _helper.drawFloatFrame( &p, r, color );
 
                 return true;
@@ -6226,26 +6226,7 @@
     if (QMenu *m = qobject_cast<QMenu*>(obj))
     {
         switch(ev->type()) {
-            case QEvent::Show:
-            case QEvent::Resize:
-            {
 
-                // make sure mask is appropriate
-                if( compositingActive() )
-                {
-                    if( m->mask() != QRegion() )
-                    { m->clearMask(); }
-
-                } else if( m->mask() == QRegion() ) {
-
-                    m->setMask( _helper.roundedMask( m->rect() ) );
-
-                }
-
-                return false;
-
-            }
-
             case QEvent::Paint:
             {
 
@@ -6256,7 +6237,8 @@
                 QRect r = m->rect();
                 QColor color = m->palette().window().color();
 
-                if( compositingActive() )
+                bool hasAlpha( hasAlphaChannel( m ) );
+                if( hasAlpha )
                 {
 
                     p.setCompositionMode(QPainter::CompositionMode_Source );
@@ -6279,7 +6261,7 @@
                 p.fillRect(lowerRect, _helper.backgroundBottomColor(color));
 
                 // frame
-                if( compositingActive() ) p.setClipping( false );
+                if( hasAlpha ) p.setClipping( false );
                 _helper.drawFloatFrame( &p, r, color );
 
                 return false;
@@ -6324,7 +6306,7 @@
             {
 
                 // make sure mask is appropriate
-                if( compositingActive() )
+                if( hasAlphaChannel( widget ) )
                 {
                     if( widget->mask() != QRegion() )
                     { widget->clearMask(); }
@@ -6348,7 +6330,8 @@
                 QRect r = widget->rect();
                 QColor color = widget->palette().window().color();
 
-                if( compositingActive() )
+                bool hasAlpha( hasAlphaChannel( widget ) );
+                if( hasAlpha )
                 {
                     p.setCompositionMode(QPainter::CompositionMode_Source );
                     TileSet *tileSet( _helper.roundCorner(color) );
@@ -6371,7 +6354,7 @@
                 p.fillRect(lowerRect, _helper.backgroundBottomColor(color));
 
                 // frame
-                if( compositingActive() ) p.setClipping( false );
+                if( hasAlpha ) p.setClipping( false );
                 _helper.drawFloatFrame( &p, r, color );
                 return false;
 
@@ -6436,7 +6419,7 @@
             case QEvent::Resize:
             {
 
-                if( dw->isFloating() && !compositingActive() )
+                if( dw->isFloating() && !hasAlphaChannel( dw ) )
                 {
 
                     QRegion mask( _helper.roundedMask( dw->rect() ) );
@@ -6465,7 +6448,8 @@
                     QColor color = dw->palette().window().color();
 
 #ifndef Q_WS_WIN
-                    if( compositingActive() )
+                    bool hasAlpha( hasAlphaChannel( dw ) );
+                    if( hasAlpha )
                     {
                         p.setCompositionMode(QPainter::CompositionMode_Source );
                         TileSet *tileSet( _helper.roundCorner(color) );
@@ -6479,7 +6463,7 @@
                     _helper.renderWindowBackground(&p, r, dw, color);
 
 #ifndef Q_WS_WIN
-                    if( compositingActive() ) p.setClipping( false );
+                    if( hasAlpha ) p.setClipping( false );
 #endif
 
                     _helper.drawFloatFrame(&p, r, color);
@@ -6560,6 +6544,24 @@
 }
 
 //____________________________________________________________________
+bool OxygenStyle::hasAlphaChannel( const QWidget* widget ) const
+{
+    #ifdef Q_WS_X11
+    if( compositingActive() )
+    {
+
+        if( widget ) return widget->x11Info().depth() == 32;
+        else return QX11Info().appDepth() == 32;
+
+    } else return false;
+
+    #else
+    return compositingActive();
+    #endif
+
+}
+
+//____________________________________________________________________
 const QWidget* OxygenStyle::checkAutoFillBackground( const QWidget* w ) const
 {
     if( !w ) return NULL;
--- branches/KDE/4.4/kdebase/runtime/kstyles/oxygen/oxygen.h #1127436:1127437
@@ -304,6 +304,9 @@
     //! returns true if compositing is active
     bool compositingActive( void ) const;
 
+    //! returns true if a given widget supports alpha channel
+    bool hasAlphaChannel( const QWidget* ) const;
+
     /*!
     returns first widget in parent chain that sets autoFillBackground to true,
     or NULL if none
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic