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
This commit is contained in:
Luboš Luňák 2004-03-18 16:56:11 +00:00
parent 30faf2c53e
commit dd81cc4c6e

View file

@ -26,6 +26,7 @@ DEALINGS IN THE SOFTWARE.
#include <kdebug.h> #include <kdebug.h>
#include <qapplication.h> #include <qapplication.h>
#include <kglobal.h>
#include <assert.h> #include <assert.h>
#if defined Q_WS_X11 && ! defined K_WS_QTONLY #if defined Q_WS_X11 && ! defined K_WS_QTONLY
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -310,30 +311,32 @@ void KDecoration::ungrabXServer()
KDecoration::Position KDecoration::mousePosition( const QPoint& p ) const KDecoration::Position KDecoration::mousePosition( const QPoint& p ) const
{ {
const int range = 16; 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; Position m = PositionCenter;
if ( ( p.x() > bleft && p.x() < widget()->width() - bright )
if ( ( p.x() > border && p.x() < widget()->width() - border ) && ( p.y() > btop && p.y() < widget()->height() - bbottom ) )
&& ( p.y() > border && p.y() < widget()->height() - border ) )
return PositionCenter; return PositionCenter;
if ( p.y() <= range && p.x() <= range) if ( p.y() <= KMAX( range, btop ) && p.x() <= KMAX( range, bleft ))
m = PositionTopLeft; 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; 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; 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; m = PositionTopRight;
else if ( p.y() <= border ) else if ( p.y() <= btop )
m = PositionTop; m = PositionTop;
else if ( p.y() >= widget()->height()-border ) else if ( p.y() >= widget()->height()-bbottom )
m = PositionBottom; m = PositionBottom;
else if ( p.x() <= border ) else if ( p.x() <= bleft )
m = PositionLeft; m = PositionLeft;
else if ( p.x() >= widget()->width()-border ) else if ( p.x() >= widget()->width()-bright )
m = PositionRight; m = PositionRight;
else else
m = PositionCenter; m = PositionCenter;