From 30cab17748937dd56fce336ab1be9508c84855c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Tue, 14 Jun 2005 15:35:44 +0000 Subject: [PATCH] Another final attempt at sorting out the shaded geometry problems. This time at least the code should detect properly all attempts to use shaded geometry when the normal one is needed. BUG: 96602 svn path=/trunk/KDE/kdebase/kwin/; revision=425377 --- client.h | 1 + geometry.cpp | 25 +++++++++++++++++++------ rules.cpp | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/client.h b/client.h index b955fcb0cd..525e62a377 100644 --- a/client.h +++ b/client.h @@ -102,6 +102,7 @@ class Client : public QObject, public KDecorationDefines SizemodeMax // try not to make it larger in either direction }; QSize adjustedSize( const QSize&, Sizemode mode = SizemodeAny ) const; + QSize adjustedSize() const; QPixmap icon() const; QPixmap miniIcon() const; diff --git a/geometry.cpp b/geometry.cpp index c8f7664499..ac57a5bfb6 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1010,6 +1010,13 @@ QSize Client::adjustedSize( const QSize& frame, Sizemode mode ) const return sizeForClientSize( wsize, mode, false ); } +// this helper returns proper size even if the window is shaded +// see also the comment in Client::setGeometry() +QSize Client::adjustedSize() const + { + return sizeForClientSize( clientSize()); + } + /*! Calculate the appropriate frame size for the given client size \a wsize. @@ -1022,6 +1029,11 @@ QSize Client::sizeForClientSize( const QSize& wsize, Sizemode mode, bool noframe { int w = wsize.width(); int h = wsize.height(); + if( w < 1 || h < 1 ) + { + kdWarning() << "sizeForClientSize() with empty size!" << endl; + kdWarning() << kdBacktrace() << endl; + } if (w<1) w = 1; if (h<1) h = 1; @@ -1247,7 +1259,7 @@ void Client::getWmNormalHints() xSizeHint.win_gravity = NorthWestGravity; if( isManaged()) { // update to match restrictions - QSize new_size = adjustedSize( size()); + QSize new_size = adjustedSize(); if( new_size != size() && !isFullScreen()) resizeWithChecks( new_size ); } @@ -1447,8 +1459,8 @@ void Client::resizeWithChecks( int w, int h, ForceGeometry_t force ) { if( h == border_top + border_bottom ) { - kdDebug() << "Shaded geometry passed for size:" << endl; - kdDebug() << kdBacktrace() << endl; + kdWarning() << "Shaded geometry passed for size:" << endl; + kdWarning() << kdBacktrace() << endl; } } int newx = x(); @@ -1614,7 +1626,8 @@ void Client::setGeometry( int x, int y, int w, int h, ForceGeometry_t force ) // shading. Then the frame geometry is adjusted for the shaded geometry. // This gets more complicated in the case the code does only something like // setGeometry( geometry()) - geometry() will return the shaded frame geometry. - // Such code is wrong and should be changed to handle the case when the window is shaded. + // Such code is wrong and should be changed to handle the case when the window is shaded, + // for example using Client::clientSize(). if( shade_geometry_change ) ; // nothing else if( isShade()) @@ -1664,7 +1677,7 @@ void Client::setGeometry( int x, int y, int w, int h, ForceGeometry_t force ) void Client::plainResize( int w, int h, ForceGeometry_t force ) { - // this code is also duplicated in Client::setGeometry() + // this code is also duplicated in Client::setGeometry(), and it's also commented there if( shade_geometry_change ) ; // nothing else if( isShade()) @@ -1752,7 +1765,7 @@ void Client::postponeGeometryUpdates( bool postpone ) if( pending_geometry_update ) { if( isShade()) - setGeometry( QRect( pos(), sizeForClientSize( clientSize())), ForceGeometrySet ); + setGeometry( QRect( pos(), adjustedSize()), ForceGeometrySet ); else setGeometry( geometry(), ForceGeometrySet ); pending_geometry_update = false; diff --git a/rules.cpp b/rules.cpp index 91fcea17dc..41768509fd 100644 --- a/rules.cpp +++ b/rules.cpp @@ -828,7 +828,7 @@ void Client::applyWindowRules() workspace()->activateNextClient( this ); // MoveResizeMode // Closeable - QSize s = adjustedSize( sizeForClientSize( clientSize())); // handle shading + QSize s = adjustedSize(); if( s != size()) resizeWithChecks( s ); setShortcut( rules()->checkShortcut( shortcut().toString()));