From 1719127d3f142e57a31ff0287b3fde42c9154f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 5 Jul 2006 22:26:34 +0000 Subject: [PATCH] Make the opacity slider and wheel operations work again. svn path=/branches/work/kwin_composite/; revision=558740 --- client.cpp | 9 ++++++++- client.h | 3 ++- composite.cpp | 4 +--- effects.h | 4 ++-- toplevel.cpp | 4 ++-- toplevel.h | 2 +- unmanaged.cpp | 2 +- unmanaged.h | 2 +- useractions.cpp | 21 ++++++++++++--------- 9 files changed, 30 insertions(+), 21 deletions(-) diff --git a/client.cpp b/client.cpp index c5a7143ad4..6acf9ee17e 100644 --- a/client.cpp +++ b/client.cpp @@ -1793,13 +1793,20 @@ bool Client::hasShape( Window w ) return boundingShaped != 0; } -float Client::opacity() const +double Client::opacity() const { if( info->opacity() == 0xffffffff ) return 1.0; return info->opacity() * 1.0 / 0xffffffff; } +void Client::setOpacity( double opacity ) + { + opacity = qBound( 0.0, opacity, 1.0 ); + info->setOpacity( static_cast< unsigned long >( opacity * 0xffffffff )); + // we'll react on PropertyNotify + } + void Client::debug( kdbgstream& stream ) const { stream << "\'ID:" << window() << ";WMCLASS:" << resourceClass() << ":" << resourceName() << ";Caption:" << caption() << "\'"; diff --git a/client.h b/client.h index 8fa6434585..38b77802a6 100644 --- a/client.h +++ b/client.h @@ -192,7 +192,8 @@ class Client bool shape() const; void updateShape(); - virtual float opacity() const; + virtual double opacity() const; + void setOpacity( double opacity ); void setGeometry( int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet ); void setGeometry( const QRect& r, ForceGeometry_t force = NormalGeometrySet ); diff --git a/composite.cpp b/composite.cpp index 9bbb9c3066..16955d2b19 100644 --- a/composite.cpp +++ b/composite.cpp @@ -32,7 +32,6 @@ void Workspace::setupCompositing() return; if( scene != NULL ) return; - // TODO start tracking unmanaged windows compositeTimer.start( 20 ); XCompositeRedirectSubwindows( display(), rootWindow(), CompositeRedirectManual ); // scene = new SceneBasic( this ); @@ -54,7 +53,6 @@ void Workspace::finishCompositing() c->finishCompositing(); XCompositeUnredirectSubwindows( display(), rootWindow(), CompositeRedirectManual ); compositeTimer.stop(); - // TODO stop tracking unmanaged windows delete scene; scene = NULL; for( ClientList::ConstIterator it = clients.begin(); @@ -64,7 +62,7 @@ void Workspace::finishCompositing() if( (*it)->opacity() != 1.0 ) { NETWinInfo i( display(), (*it)->frameId(), rootWindow(), 0 ); - i.setOpacity( long((*it)->opacity() * 0xffffffff )); + i.setOpacity( static_cast< unsigned long >((*it)->opacity() * 0xffffffff )); } } } diff --git a/effects.h b/effects.h index 7d3123ad34..66d8ace60a 100644 --- a/effects.h +++ b/effects.h @@ -23,14 +23,14 @@ class Matrix { public: Matrix(); - float m[ 4 ][ 4 ]; + double m[ 4 ][ 4 ]; }; class EffectData { public: Matrix matrix; - float opacity; + double opacity; }; class Effect diff --git a/toplevel.cpp b/toplevel.cpp index 3cf5c902fe..334376acfc 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -16,11 +16,11 @@ namespace KWinInternal { Toplevel::Toplevel( Workspace* ws ) - : id( None ) + : vis( None ) + , id( None ) , wspace( ws ) , damage_handle( None ) , window_pixmap( None ) - , vis( None ) { } diff --git a/toplevel.h b/toplevel.h index dceaf55e4b..371cf2366b 100644 --- a/toplevel.h +++ b/toplevel.h @@ -41,7 +41,7 @@ class Toplevel int height() const; Pixmap windowPixmap() const; Visual* visual() const; - virtual float opacity() const = 0; + virtual double opacity() const = 0; void setupCompositing(); void finishCompositing(); protected: diff --git a/unmanaged.cpp b/unmanaged.cpp index b4a683c3db..e063cb45fc 100644 --- a/unmanaged.cpp +++ b/unmanaged.cpp @@ -63,7 +63,7 @@ void Unmanaged::deleteUnmanaged( Unmanaged* c, allowed_t ) delete c; } -float Unmanaged::opacity() const +double Unmanaged::opacity() const { if( info->opacity() == 0xffffffff ) return 1.0; diff --git a/unmanaged.h b/unmanaged.h index 19451f2d85..2d62417b16 100644 --- a/unmanaged.h +++ b/unmanaged.h @@ -29,7 +29,7 @@ class Unmanaged void release(); bool track( Window w ); static void deleteUnmanaged( Unmanaged* c, allowed_t ); - virtual float opacity() const; + virtual double opacity() const; protected: virtual void debug( kdbgstream& stream ) const; private: diff --git a/useractions.cpp b/useractions.cpp index 6848f6d768..9c3ce0f29f 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -164,10 +164,18 @@ QMenu* Workspace::clientPopup() return popup; } -//sets the transparency of the client to given value(given by slider) void Workspace::setPopupClientOpacity(int value) { - // TODO + if( active_popup_client == NULL ) + return; + active_popup_client->setOpacity( value / 100.0 ); + } + +void Workspace::resetClientOpacity() + { + if( active_popup_client == NULL ) + return; + active_popup_client->setOpacity( 1.0 ); } void Workspace::setTransButtonText(int value) @@ -183,11 +191,6 @@ void Workspace::setTransButtonText(int value) transButton->setText('0'+QString::number(value)+" %"); } -void Workspace::resetClientOpacity() - { - // TODO - } - /*! The client popup menu will become visible soon. @@ -641,10 +644,10 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo workspace()->windowToNextDesktop( this ); break; case Options::MouseOpacityMore: - // TODO + setOpacity( qMin( opacity() + 0.1, 1.0 )); break; case Options::MouseOpacityLess: - // TODO + setOpacity( qMax( opacity() - 0.1, 0.0 )); break; case Options::MouseNothing: replay = true;