Replace the temporary MousePosition enum naming with something that

doesn't look so silly and doesn't conflict with Qt.

svn path=/trunk/kdebase/kwin/; revision=273144
This commit is contained in:
Luboš Luňák 2003-12-15 15:10:17 +00:00
parent c26c55787f
commit 569224d117
23 changed files with 201 additions and 181 deletions

View file

@ -99,7 +99,7 @@ Client::Client( Workspace *ws )
mapping_state = WithdrawnState;
desk = 0; // no desktop yet
mode = Nowhere;
mode = PositionCenter;
buttonDown = FALSE;
moveResizeMode = FALSE;
@ -1538,7 +1538,7 @@ NET::WindowType Client::windowType( bool strict, int supported_types ) const
Sets an appropriate cursor shape for the logical mouse position \a m
*/
void Client::setCursor( MousePosition m )
void Client::setCursor( Position m )
{
if ( !isResizable() || isShade() || noBorder())
{
@ -1547,20 +1547,20 @@ void Client::setCursor( MousePosition m )
}
switch ( m )
{
case TopLeft2:
case BottomRight2:
case PositionTopLeft:
case PositionBottomRight:
setCursor( sizeFDiagCursor );
break;
case BottomLeft2:
case TopRight2:
case PositionBottomLeft:
case PositionTopRight:
setCursor( sizeBDiagCursor );
break;
case Top:
case Bottom:
case PositionTop:
case PositionBottom:
setCursor( sizeVerCursor );
break;
case Left:
case Right:
case PositionLeft:
case PositionRight:
setCursor( sizeHorCursor );
break;
default:
@ -1580,11 +1580,11 @@ void Client::setCursor( const QCursor& c )
XDefineCursor( qt_xdisplay(), frameId(), cursor.handle());
}
Client::MousePosition Client::mousePosition( const QPoint& p ) const
Client::Position Client::mousePosition( const QPoint& p ) const
{
if( decoration != NULL )
return decoration->mousePosition( p );
return Center;
return PositionCenter;
}
void Client::updateAllowedActions( bool force )

View file

@ -284,8 +284,8 @@ class Client : public QObject, public KDecorationDefines
// use Workspace::createClient()
virtual ~Client(); // use destroyClient() or releaseWindow()
MousePosition mousePosition( const QPoint& ) const;
void setCursor( MousePosition m );
Position mousePosition( const QPoint& ) const;
void setCursor( Position m );
void setCursor( const QCursor& c );
void animateMinimizeOrUnminimize( bool minimize );
@ -384,14 +384,14 @@ class Client : public QObject, public KDecorationDefines
bool unrestrictedMoveResize;
bool isMove() const
{
return moveResizeMode && mode == Center;
return moveResizeMode && mode == PositionCenter;
}
bool isResize() const
{
return moveResizeMode && !isMove();
return moveResizeMode && mode != PositionCenter;
}
MousePosition mode;
Position mode;
QPoint moveOffset;
QPoint invertedMoveOffset;
QRect moveResizeGeom;

View file

@ -619,7 +619,7 @@ void B2Client::showEvent(QShowEvent *)
titlebar->repaint(false);
}
KDecoration::MousePosition B2Client::mousePosition( const QPoint& p ) const
KDecoration::Position B2Client::mousePosition( const QPoint& p ) const
{
const int range = 16;
QRect t = titlebar->geometry();
@ -630,36 +630,36 @@ KDecoration::MousePosition B2Client::mousePosition( const QPoint& p ) const
if ( p.x() > t.right() ) {
if ( p.y() <= ly + range && p.x() >= width()-range)
return TopRight2;
return PositionTopRight;
else if ( p.y() <= ly + thickness )
return Top;
return PositionTop;
} else if ( p.x() < bar_x_ofs ) {
if ( p.y() <= ly + range && p.x() <= range )
return TopLeft2;
return PositionTopLeft;
else if ( p.y() <= ly + thickness )
return Top;
return PositionTop;
} else if ( p.y() < ly ) {
if (p.x() > bar_x_ofs + thickness &&
p.x() < lx - thickness && p.y() > thickness)
return KDecoration::mousePosition(p);
if (p.x() > bar_x_ofs + range && p.x() < lx - range)
return Top;
return PositionTop;
if ( p.y() <= range ) {
if ( p.x() <= bar_x_ofs + range )
return TopLeft2;
else return TopRight2;
return PositionTopLeft;
else return PositionTopRight;
} else {
if ( p.x() <= bar_x_ofs + range )
return Left;
else return Right;
return PositionLeft;
else return PositionRight;
}
}
if (p.y() >= height() - 8 + bb) {
/* the normal Client:: only wants border of 4 pixels */
if (p.x() <= range) return BottomLeft2;
if (p.x() >= width() - range) return BottomRight2;
return Bottom;
if (p.x() <= range) return PositionBottomLeft;
if (p.x() >= width() - range) return PositionBottomRight;
return PositionBottom;
}
return KDecoration::mousePosition(p);

View file

@ -110,7 +110,7 @@ protected:
void maximizeChange();
void iconChange();
void doShape();
MousePosition mousePosition( const QPoint& p ) const;
Position mousePosition( const QPoint& p ) const;
void resize(const QSize&);
void borders(int &, int &, int &, int &) const;
QSize minimumSize() const;

View file

@ -1215,9 +1215,9 @@ void KDEDefaultClient::calcHiddenButtons()
}
KDecoration::MousePosition KDEDefaultClient::mousePosition( const QPoint& p ) const
KDecoration::Position KDEDefaultClient::mousePosition( const QPoint& p ) const
{
MousePosition m = Nowhere;
Position m = PositionCenter;
int bottomSize = (showGrabBar && isResizable()) ? grabBorderWidth : borderWidth;
@ -1225,36 +1225,36 @@ KDecoration::MousePosition KDEDefaultClient::mousePosition( const QPoint& p ) co
if ( ( p.x() > borderWidth && p.x() < width() - borderWidth )
&& ( p.y() > 4 && p.y() < height() - bottomSize ) )
m = Center;
m = PositionCenter;
else if ( p.y() <= range && p.x() <= range)
m = TopLeft2;
m = PositionTopLeft;
else if ( p.y() >= height()-range && p.x() >= width()-range)
m = BottomRight2;
m = PositionBottomRight;
else if ( p.y() >= height()-range && p.x() <= range)
m = BottomLeft2;
m = PositionBottomLeft;
else if ( p.y() <= range && p.x() >= width()-range)
m = TopRight2;
m = PositionTopRight;
else if ( p.y() <= 4 )
m = Top;
m = PositionTop;
else if ( p.y() >= height()-bottomSize )
m = Bottom;
m = PositionBottom;
else if ( p.x() <= borderWidth )
m = Left;
m = PositionLeft;
else if ( p.x() >= width()-borderWidth )
m = Right;
m = PositionRight;
else
m = Center;
m = PositionCenter;
// Modify the mouse position if we are using a grab bar.
if (showGrabBar && isResizable())
if (p.y() >= (height() - grabBorderWidth))
{
if (p.x() >= (width() - 2*borderWidth - 12))
m = BottomRight2;
m = PositionBottomRight;
else if (p.x() <= 2*borderWidth + 12)
m = BottomLeft2;
m = PositionBottomLeft;
else
m = Bottom;
m = PositionBottom;
}
return m;

View file

@ -105,7 +105,7 @@ class KDEDefaultClient : public KDecoration
void iconChange();
void desktopChange();
void shadeChange();
MousePosition mousePosition(const QPoint &) const;
Position mousePosition(const QPoint &) const;
protected slots:
void slotMaximize();

View file

@ -1507,7 +1507,7 @@ void KeramikClient::mouseDoubleClickEvent( QMouseEvent *e )
}
KeramikClient::MousePosition KeramikClient::mousePosition( const QPoint &p ) const
KeramikClient::Position KeramikClient::mousePosition( const QPoint &p ) const
{
int titleBaseY = (largeTitlebar ? 3 : 0);
@ -1523,7 +1523,7 @@ KeramikClient::MousePosition KeramikClient::mousePosition( const QPoint &p ) con
if ( (p.y() < titleBaseY + 3 && p.x() < leftBorder + 11) ||
(p.y() < titleBaseY + 6 && p.x() < leftBorder + 6) ||
(p.y() < titleBaseY + 11 && p.x() < leftBorder + 3) )
return TopLeft2;
return PositionTopLeft;
}
// Test for the top right corner
@ -1531,16 +1531,16 @@ KeramikClient::MousePosition KeramikClient::mousePosition( const QPoint &p ) con
if ( (p.y() < titleBaseY + 3 && p.x() > rightBorder - 11) ||
(p.y() < titleBaseY + 6 && p.x() > rightBorder - 6) ||
(p.y() < titleBaseY + 11 && p.x() > rightBorder - 3) )
return TopRight2;
return PositionTopRight;
}
// Test for the top border
if ( p.y() <= 3 || (p.y() <= titleBaseY+3 &&
(p.x() < captionRect.left() || p.x() > captionRect.right()) ) )
return Top;
return PositionTop;
// The cursor must be over the center of the titlebar.
return Center;
return PositionCenter;
}
// Test the sides
@ -1548,39 +1548,39 @@ KeramikClient::MousePosition KeramikClient::mousePosition( const QPoint &p ) con
// Test for the left side
if ( p.x() < leftBorder ) {
if ( p.y() < height() - bottomCornerSize )
return Left;
return PositionLeft;
else
return BottomLeft2;
return PositionBottomLeft;
}
// Test for the right side
else if ( p.x() > rightBorder ) {
if ( p.y() < height() - bottomCornerSize )
return Right;
return PositionRight;
else
return BottomRight2;
return PositionBottomRight;
}
// The cursor must be over the center of the window
return Center;
return PositionCenter;
}
// Test the grab bar / bottom border
else {
// Test for the bottom left corner
if ( p.x() < bottomCornerSize )
return BottomLeft2;
return PositionBottomLeft;
// Test for the bottom right corner
else if ( p.x() > width() - bottomCornerSize - 1 )
return BottomRight2;
return PositionBottomRight;
// The cursor must be over the bottom border
return Bottom;
return PositionBottom;
}
// We should never get here
return Nowhere;
return PositionCenter;
}

View file

@ -144,7 +144,7 @@ namespace Keramik {
~KeramikClient();
virtual void init();
virtual void reset( unsigned long changed );
virtual MousePosition mousePosition( const QPoint& p ) const;
virtual Position mousePosition( const QPoint& p ) const;
virtual void borders( int& left, int& right, int& top, int& bottom ) const;
virtual void resize( const QSize& s );
virtual QSize minimumSize() const;

View file

@ -727,9 +727,9 @@ void LaptopClient::updateActiveBuffer( )
p.end();
}
LaptopClient::MousePosition LaptopClient::mousePosition(const QPoint & p) const
LaptopClient::Position LaptopClient::mousePosition(const QPoint & p) const
{
MousePosition m = Nowhere;
Position m = PositionCenter;
int range = 8 + 3*handleSize/2;
if (p.y() < (height() - handleSize + 1))
@ -737,11 +737,11 @@ LaptopClient::MousePosition LaptopClient::mousePosition(const QPoint & p) const
else {
if (p.x() >= (width() - range))
m = BottomRight2;
m = PositionBottomRight;
else if (p.x() <= range)
m = BottomLeft2;
m = PositionBottomLeft;
else
m = Bottom;
m = PositionBottom;
}
return m;

View file

@ -70,7 +70,7 @@ protected:
void maximizeChange();
void doShape();
void activeChange();
MousePosition mousePosition(const QPoint &) const;
Position mousePosition(const QPoint &) const;
void desktopChange();
void shadeChange();
void iconChange();

View file

@ -660,9 +660,9 @@ void ModernSys::activeChange()
}
ModernSys::MousePosition ModernSys::mousePosition( const QPoint& p) const
ModernSys::Position ModernSys::mousePosition( const QPoint& p) const
{
MousePosition m = KDecoration::mousePosition( p );
Position m = KDecoration::mousePosition( p );
const int range = 14 + 3*border_width/2;
const int border = show_handle ? handle_width + border_width : border_width;
@ -671,25 +671,25 @@ ModernSys::MousePosition ModernSys::mousePosition( const QPoint& p) const
if ( ( p.x() > border_width && p.x() < width() - border )
&& ( p.y() > 4 && p.y() < height() - border ) )
m = Center;
m = PositionCenter;
else if ( p.y() <= range && p.x() <= range)
m = TopLeft2;
m = PositionTopLeft;
else if ( p.y() >= height()-range2 && p.x() >= width()-range2)
m = BottomRight2;
m = PositionBottomRight;
else if ( p.y() >= height()-range3 && p.x() <= range)
m = BottomLeft2;
m = PositionBottomLeft;
else if ( p.y() <= range && p.x() >= width()-range3)
m = TopRight2;
m = PositionTopRight;
else if ( p.y() <= 4 )
m = Top;
m = PositionTop;
else if ( p.y() >= height()-border )
m = Bottom;
m = PositionBottom;
else if ( p.x() <= border_width )
m = Left;
m = PositionLeft;
else if ( p.x() >= width()-border )
m = Right;
m = PositionRight;
else
m = Center;
m = PositionCenter;
return m;
}

View file

@ -59,7 +59,7 @@ protected:
void doShape();
void recalcTitleBuffer();
void activeChange();
MousePosition mousePosition( const QPoint& ) const;
Position mousePosition( const QPoint& ) const;
void desktopChange();
void shadeChange();
void iconChange();

View file

@ -872,29 +872,29 @@ void QuartzClient::activeChange()
}
QuartzClient::MousePosition QuartzClient::mousePosition(const QPoint &point) const
QuartzClient::Position QuartzClient::mousePosition(const QPoint &point) const
{
const int corner = 3*borderSize/2 + 18;
MousePosition pos = Center;
Position pos = PositionCenter;
QRect r(widget()->rect());
if(point.y() < (borderSize-1)) {
if(point.x() < corner) return TopLeft2;
else if(point.x() > (r.right()-corner)) return TopRight2;
else return Top;
if(point.x() < corner) return PositionTopLeft;
else if(point.x() > (r.right()-corner)) return PositionTopRight;
else return PositionTop;
} else if(point.y() > (r.bottom()-borderSize)) {
if(point.x() < corner) return BottomLeft2;
else if(point.x() > (r.right()-corner)) return BottomRight2;
else return Bottom;
if(point.x() < corner) return PositionBottomLeft;
else if(point.x() > (r.right()-corner)) return PositionBottomRight;
else return PositionBottom;
} else if(point.x() < borderSize) {
if(point.y() < corner) return TopLeft2;
else if(point.y() > (r.bottom()-corner)) return BottomLeft2;
else return Left;
if(point.y() < corner) return PositionTopLeft;
else if(point.y() > (r.bottom()-corner)) return PositionBottomLeft;
else return PositionLeft;
} else if(point.x() > (r.right()-borderSize)) {
if(point.y() < corner) return TopRight2;
else if(point.y() > (r.bottom()-corner)) return BottomRight2;
else return Right;
if(point.y() < corner) return PositionTopRight;
else if(point.y() > (r.bottom()-corner)) return PositionBottomRight;
else return PositionRight;
}
return pos;

View file

@ -102,7 +102,7 @@ class QuartzClient : public KDecoration
virtual void activeChange();
virtual void iconChange();
virtual void desktopChange();
virtual QuartzClient::MousePosition mousePosition(const QPoint &point) const;
virtual QuartzClient::Position mousePosition(const QPoint &point) const;
virtual void borders(int&, int&, int&, int&) const;
virtual QSize minimumSize() const;

View file

@ -720,33 +720,33 @@ void RedmondDeco::calcHiddenButtons()
}
}
RedmondDeco::MousePosition RedmondDeco::mousePosition(const QPoint &p) const
RedmondDeco::Position RedmondDeco::mousePosition(const QPoint &p) const
{
MousePosition m = Nowhere;
Position m = PositionCenter;
const int range = 14 + 3*borderWidth/2;
if ( ( p.x() > borderWidth && p.x() < width() - borderWidth )
&& ( p.y() > borderWidth && p.y() < height() - borderWidth ) )
m = Center;
m = PositionCenter;
else if ( p.y() <= range && p.x() <= range)
m = TopLeft2;
m = PositionTopLeft;
else if ( p.y() >= height()-range && p.x() >= width()-range)
m = BottomRight2;
m = PositionBottomRight;
else if ( p.y() >= height()-range && p.x() <= range)
m = BottomLeft2;
m = PositionBottomLeft;
else if ( p.y() <= range && p.x() >= width()-range)
m = TopRight2;
m = PositionTopRight;
else if ( p.y() <= borderWidth )
m = Top;
m = PositionTop;
else if ( p.y() >= height()-borderWidth )
m = Bottom;
m = PositionBottom;
else if ( p.x() <= borderWidth )
m = Left;
m = PositionLeft;
else if ( p.x() >= width()-borderWidth )
m = Right;
m = PositionRight;
else
m = Center;
m = PositionCenter;
return m;
}

View file

@ -87,7 +87,7 @@ protected:
void calcHiddenButtons();
// New stuff.
MousePosition mousePosition(const QPoint &) const;
Position mousePosition(const QPoint &) const;
void borders(int &, int &, int &, int &) const;
void resize(const QSize &);
QSize minimumSize() const;

View file

@ -294,7 +294,7 @@ WebClient::activeChange()
widget()->repaint();
}
WebClient::MousePosition
WebClient::Position
WebClient::mousePosition(const QPoint & p) const
{
int x = p.x();
@ -314,27 +314,27 @@ WebClient::mousePosition(const QPoint & p) const
return Client::Top;
else
#endif
return KDecoration::Center;
return KDecoration::PositionCenter;
}
else if (y < height() - borderSize_)
{
if (x < borderSize_)
return KDecoration::Left;
return KDecoration::PositionLeft;
else
if (x > width() - borderSize_)
return KDecoration::Right;
return KDecoration::PositionRight;
else
return KDecoration::Center;
return KDecoration::PositionCenter;
}
else
{
if (x < 12 + corner)
return KDecoration::BottomLeft2;
return KDecoration::PositionBottomLeft;
else
if (x > width() - corner)
return KDecoration::BottomRight2;
return KDecoration::PositionBottomRight;
else
return KDecoration::Bottom;
return KDecoration::PositionBottom;
}
return KDecoration::mousePosition(p);

View file

@ -65,7 +65,7 @@ namespace Web
virtual void activeChange();
virtual void iconChange();
virtual void doShape();
virtual MousePosition mousePosition(const QPoint &) const;
virtual Position mousePosition(const QPoint &) const;
virtual void borders(int&, int&, int&, int&) const;
virtual QSize minimumSize() const;

View file

@ -825,7 +825,7 @@ void Client::leaveNotifyEvent( XCrossingEvent* e )
{
if ( !buttonDown )
{
mode = Nowhere;
mode = PositionCenter;
setCursor( arrowCursor );
}
bool lostMouse = !rect().contains( QPoint( e->x, e->y ) );
@ -1230,7 +1230,7 @@ bool Client::motionNotifyEvent( Window w, int /*state*/, int x, int y, int x_roo
return true; // care only about the whole frame
if ( !buttonDown )
{
MousePosition newmode = mousePosition( QPoint( x, y ));
Position newmode = mousePosition( QPoint( x, y ));
if( newmode != mode )
setCursor( newmode );
mode = newmode;
@ -1344,16 +1344,16 @@ void Client::NETMoveResize( int x_root, int y_root, NET::Direction direction )
performMouseCommand( Options::MouseMove, QPoint( x_root, y_root ));
else if( direction >= NET::TopLeft && direction <= NET::Left )
{
static const MousePosition convert[] =
static const Position convert[] =
{
TopLeft2,
Top,
TopRight2,
Right,
BottomRight2,
Bottom,
BottomLeft2,
Left
PositionTopLeft,
PositionTop,
PositionTopRight,
PositionRight,
PositionBottomRight,
PositionBottom,
PositionBottomLeft,
PositionLeft
};
if(!isResizable() || isShade())
return;

View file

@ -1496,7 +1496,7 @@ bool Client::startMoveResize()
if( QApplication::activePopupWidget() != NULL )
return false; // popups have grab
bool has_grab = false;
if( mode == Center )
if( mode == PositionCenter )
setCursor( sizeAllCursor ); // change from arrow cursor if moving
if( XGrabPointer( qt_xdisplay(), frameId(), False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync, None, cursor.handle(), qt_x_time ) == Success )
@ -1563,8 +1563,8 @@ void Client::leaveMoveResize()
void Client::handleMoveResize( int x, int y, int x_root, int y_root )
{
if(( mode == Center && !isMovable())
|| ( mode != Center && ( isShade() || !isResizable())))
if(( mode == PositionCenter && !isMovable())
|| ( mode != PositionCenter && ( isShade() || !isResizable())))
return;
if ( !moveResizeMode )
@ -1583,7 +1583,7 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root )
}
// ShadeHover or ShadeActive, ShadeNormal was already avoided above
if ( mode != Center && shade_mode != ShadeNone ) // SHADE
if ( mode != PositionCenter && shade_mode != ShadeNone ) // SHADE
setShade( ShadeNone );
QPoint globalPos( x_root, y_root );
@ -1619,35 +1619,35 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root )
Sizemode sizemode = SizemodeAny;
switch ( mode )
{
case TopLeft2:
case PositionTopLeft:
moveResizeGeom = QRect( topleft, orig.bottomRight() ) ;
break;
case BottomRight2:
case PositionBottomRight:
moveResizeGeom = QRect( orig.topLeft(), bottomright ) ;
break;
case BottomLeft2:
case PositionBottomLeft:
moveResizeGeom = QRect( QPoint( topleft.x(), orig.y() ), QPoint( orig.right(), bottomright.y()) ) ;
break;
case TopRight2:
case PositionTopRight:
moveResizeGeom = QRect( QPoint( orig.x(), topleft.y() ), QPoint( bottomright.x(), orig.bottom()) ) ;
break;
case Top:
case PositionTop:
moveResizeGeom = QRect( QPoint( orig.left(), topleft.y() ), orig.bottomRight() ) ;
sizemode = SizemodeFixedH; // try not to affect height
break;
case Bottom:
case PositionBottom:
moveResizeGeom = QRect( orig.topLeft(), QPoint( orig.right(), bottomright.y() ) ) ;
sizemode = SizemodeFixedH;
break;
case Left:
case PositionLeft:
moveResizeGeom = QRect( QPoint( topleft.x(), orig.top() ), orig.bottomRight() ) ;
sizemode = SizemodeFixedW;
break;
case Right:
case PositionRight:
moveResizeGeom = QRect( orig.topLeft(), QPoint( bottomright.x(), orig.bottom() ) ) ;
sizemode = SizemodeFixedW;
break;
case Center:
case PositionCenter:
default:
assert( false );
break;
@ -1671,34 +1671,34 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root )
orig = moveResizeGeom;
switch ( mode )
{ // these 4 corners ones are copied from above
case TopLeft2:
case PositionTopLeft:
moveResizeGeom = QRect( topleft, orig.bottomRight() ) ;
break;
case BottomRight2:
case PositionBottomRight:
moveResizeGeom = QRect( orig.topLeft(), bottomright ) ;
break;
case BottomLeft2:
case PositionBottomLeft:
moveResizeGeom = QRect( QPoint( topleft.x(), orig.y() ), QPoint( orig.right(), bottomright.y()) ) ;
break;
case TopRight2:
case PositionTopRight:
moveResizeGeom = QRect( QPoint( orig.x(), topleft.y() ), QPoint( bottomright.x(), orig.bottom()) ) ;
break;
// The side ones can't be copied exactly - if aspect ratios are specified, both dimensions may change.
// Therefore grow to the right/bottom if needed.
// TODO it should probably obey gravity rather than always using right/bottom ?
case Top:
case PositionTop:
moveResizeGeom = QRect( QPoint( orig.left(), topleft.y() ), QPoint( bottomright.x(), orig.bottom()) ) ;
break;
case Bottom:
case PositionBottom:
moveResizeGeom = QRect( orig.topLeft(), QPoint( bottomright.x(), bottomright.y() ) ) ;
break;
case Left:
case PositionLeft:
moveResizeGeom = QRect( QPoint( topleft.x(), orig.top() ), QPoint( orig.right(), bottomright.y()));
break;
case Right:
case PositionRight:
moveResizeGeom = QRect( orig.topLeft(), QPoint( bottomright.x(), bottomright.y() ) ) ;
break;
case Center:
case PositionCenter:
default:
assert( false );
break;
@ -1708,7 +1708,7 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root )
}
else if( isMove())
{
assert( mode == Center );
assert( mode == PositionCenter );
// first move, then snap, then check bounds
moveResizeGeom.moveTopLeft( topleft );
moveResizeGeom.moveTopLeft( workspace()->adjustClientPosition( this, moveResizeGeom.topLeft() ) );

View file

@ -300,36 +300,36 @@ void KDecoration::ungrabXServer()
bridge_->grabXServer( false );
}
KDecoration::MousePosition KDecoration::mousePosition( const QPoint& p ) const
KDecoration::Position KDecoration::mousePosition( const QPoint& p ) const
{
const int range = 16;
const int border = 4;
MousePosition m = Nowhere;
Position m = PositionCenter;
if ( ( p.x() > border && p.x() < widget()->width() - border )
&& ( p.y() > border && p.y() < widget()->height() - border ) )
return Center;
return PositionCenter;
if ( p.y() <= range && p.x() <= range)
m = TopLeft2;
m = PositionTopLeft;
else if ( p.y() >= widget()->height()-range && p.x() >= widget()->width()-range)
m = BottomRight2;
m = PositionBottomRight;
else if ( p.y() >= widget()->height()-range && p.x() <= range)
m = BottomLeft2;
m = PositionBottomLeft;
else if ( p.y() <= range && p.x() >= widget()->width()-range)
m = TopRight2;
m = PositionTopRight;
else if ( p.y() <= border )
m = Top;
m = PositionTop;
else if ( p.y() >= widget()->height()-border )
m = Bottom;
m = PositionBottom;
else if ( p.x() <= border )
m = Left;
m = PositionLeft;
else if ( p.x() >= widget()->width()-border )
m = Right;
m = PositionRight;
else
m = Center;
m = PositionCenter;
return m;
}

View file

@ -43,22 +43,36 @@ class KDecorationFactory;
class KDecorationDefines
{
public:
enum MousePosition { // FRAME nejake lepsi pojmenovani
Nowhere, TopLeft2 , BottomRight2, BottomLeft2, TopRight2, Top, Bottom, Left, Right, Center
};
/**
* These values represent positions inside an area
*/
enum Position
{ // without prefix, they'd conflict with Qt::TopLeft etc. :(
PositionCenter = 0x00,
PositionLeft = 0x01,
PositionRight = 0x02,
PositionTop = 0x04,
PositionBottom = 0x08,
PositionTopLeft = PositionLeft | PositionTop,
PositionTopRight = PositionRight | PositionTop,
PositionBottomLeft = PositionLeft | PositionBottom,
PositionBottomRight = PositionRight | PositionBottom
};
/**
* Maximize mode. These values specify how a window is maximized.
*/
// these values are written to session files, don't change the order
enum MaximizeMode {
MaximizeRestore = 0, ///< The window is not maximized in any direction.
MaximizeVertical = 1, ///< The window is maximized vertically.
MaximizeHorizontal = 2, ///< The window is maximized horizontally.
/// Equal to @p MaximizeVertical | @p MaximizeHorizontal
MaximizeFull = MaximizeVertical | MaximizeHorizontal
};
enum MaximizeMode
{
MaximizeRestore = 0, ///< The window is not maximized in any direction.
MaximizeVertical = 1, ///< The window is maximized vertically.
MaximizeHorizontal = 2, ///< The window is maximized horizontally.
/// Equal to @p MaximizeVertical | @p MaximizeHorizontal
MaximizeFull = MaximizeVertical | MaximizeHorizontal
};
enum WindowOperation{
enum WindowOperation
{
MaximizeOp = 5000,
RestoreOp,
MinimizeOp,
@ -79,7 +93,7 @@ public:
FullScreenOp,
NoBorderOp,
NoOp
};
};
/**
* Basic color types that should be recognized by all decoration styles.
* Decorations are not required to implement all the colors, but for the ones that
@ -476,7 +490,13 @@ class KDecoration
*/
virtual void init() = 0; // called once right after created
virtual MousePosition mousePosition( const QPoint& p ) const = 0;
/**
* This function should return mouse cursor position in the decoration.
* Positions at the edge will result in window resizing with mouse button
* pressed, center position will result in moving.
*/
virtual Position mousePosition( const QPoint& p ) const = 0;
/**
* This function should return the distance from each window side to the inner
* window. The sizes may depend on the state of the decorated window, such as

View file

@ -348,7 +348,7 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
break;
if( moveResizeMode )
finishMoveResize( false );
mode = Center;
mode = PositionCenter;
buttonDown = TRUE;
moveOffset = QPoint( globalPos.x() - x(), globalPos.y() - y()); // map from global
invertedMoveOffset = rect().bottomRight() - moveOffset;
@ -373,11 +373,11 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
bool top = y < height() / 3;
bool bot = y >= 2 * height() / 3;
if (top)
mode = left ? TopLeft2 : (right ? TopRight2 : Top);
mode = left ? PositionTopLeft : (right ? PositionTopRight : PositionTop);
else if (bot)
mode = left ? BottomLeft2 : (right ? BottomRight2 : Bottom);
mode = left ? PositionBottomLeft : (right ? PositionBottomRight : PositionBottom);
else
mode = (x < width() / 2) ? Left : Right;
mode = (x < width() / 2) ? PositionLeft : PositionRight;
invertedMoveOffset = rect().bottomRight() - moveOffset;
unrestrictedMoveResize = ( command == Options::MouseUnrestrictedResize );
setCursor( mode );