From dd81cc4c6e8bf3a8265a8272c936d94133ca0017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 18 Mar 2004 16:56:11 +0000 Subject: [PATCH] Use the actual border sizes instead of hardcoded 4 for mousePosition(), so that this is more flexible and decorations don't have to reimplement it completely. svn path=/trunk/kdebase/kwin/; revision=296910 --- lib/kdecoration.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/kdecoration.cpp b/lib/kdecoration.cpp index 64259117b1..b013d4e414 100644 --- a/lib/kdecoration.cpp +++ b/lib/kdecoration.cpp @@ -26,6 +26,7 @@ DEALINGS IN THE SOFTWARE. #include #include +#include #include #if defined Q_WS_X11 && ! defined K_WS_QTONLY #include @@ -310,30 +311,32 @@ void KDecoration::ungrabXServer() KDecoration::Position KDecoration::mousePosition( const QPoint& p ) const { const int range = 16; - const int border = 4; + int bleft, bright, btop, bbottom; + borders( bleft, bright, btop, bbottom ); + btop = KMIN( btop, 4 ); // otherwise whole titlebar would have resize cursor Position m = PositionCenter; - - if ( ( p.x() > border && p.x() < widget()->width() - border ) - && ( p.y() > border && p.y() < widget()->height() - border ) ) + if ( ( p.x() > bleft && p.x() < widget()->width() - bright ) + && ( p.y() > btop && p.y() < widget()->height() - bbottom ) ) return PositionCenter; - if ( p.y() <= range && p.x() <= range) + if ( p.y() <= KMAX( range, btop ) && p.x() <= KMAX( range, bleft )) m = PositionTopLeft; - else if ( p.y() >= widget()->height()-range && p.x() >= widget()->width()-range) + else if ( p.y() >= widget()->height()- KMAX( range, bbottom ) + && p.x() >= widget()->width()- KMAX( range, bright )) m = PositionBottomRight; - else if ( p.y() >= widget()->height()-range && p.x() <= range) + else if ( p.y() >= widget()->height()- KMAX( range, bbottom ) && p.x() <= KMAX( range, bleft )) m = PositionBottomLeft; - else if ( p.y() <= range && p.x() >= widget()->width()-range) + else if ( p.y() <= KMAX( range, btop ) && p.x() >= widget()->width()- KMAX( range, bright )) m = PositionTopRight; - else if ( p.y() <= border ) + else if ( p.y() <= btop ) m = PositionTop; - else if ( p.y() >= widget()->height()-border ) + else if ( p.y() >= widget()->height()-bbottom ) m = PositionBottom; - else if ( p.x() <= border ) + else if ( p.x() <= bleft ) m = PositionLeft; - else if ( p.x() >= widget()->width()-border ) + else if ( p.x() >= widget()->width()-bright ) m = PositionRight; else m = PositionCenter;