diff --git a/client.cpp b/client.cpp index 46b10e25b5..988675c895 100644 --- a/client.cpp +++ b/client.cpp @@ -625,7 +625,7 @@ bool Client::manage( bool isMapped, bool doNotShow, bool isInitial ) if ( session ) geom = session->geometry; - QRect area = workspace()->clientArea(); + QRect area = workspace()->clientArea( geom.center() ); if ( geom == workspace()->geometry() && inherits( "KWinInternal::NoBorderClient" ) ) { if ( !stays_on_top ) @@ -1567,7 +1567,7 @@ void Client::mouseMoveEvent( QMouseEvent * e) break; } - QRect desktopArea = workspace()->clientArea(); + QRect desktopArea = workspace()->clientArea(e->globalPos()); int marge = 5; if ( isResize() && geom.size() != size() ) { @@ -1880,7 +1880,7 @@ void Client::maximize( MaximizeMode m) if ( !isMaximizable() ) return; - QRect clientArea = workspace()->clientArea(); + QRect clientArea = workspace()->clientArea(geometry().center()); if (isShade()) setShade( FALSE ); diff --git a/workspace.cpp b/workspace.cpp index bb2d2883e1..9b145403fd 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -3170,7 +3170,7 @@ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos ) if (options->windowSnapZone || options->borderSnapZone ) { bool sOWO=options->snapOnlyWhenOverlapping; - QRect maxRect = clientArea(MovementArea); + QRect maxRect = clientArea(MovementArea, pos+c->rect().center()); int xmin = maxRect.left(); int xmax = maxRect.right()+1; //desk size int ymin = maxRect.top(); @@ -3970,39 +3970,41 @@ void Workspace::updateClientArea() \sa geometry() */ -QRect Workspace::clientArea(clientAreaOption opt) +QRect Workspace::clientArea(clientAreaOption opt, const QPoint& p) { QRect rect = QApplication::desktop()->geometry(); -#if QT_VERSION < 300 - KDesktopWidget *desktop = KApplication::desktop(); -#else QDesktopWidget *desktop = KApplication::desktop(); -#endif switch (opt) { case MaximizeArea: if (options->xineramaMaximizeEnabled) - rect = desktop->screenGeometry(desktop->screenNumber(QCursor::pos())); + rect = desktop->screenGeometry(desktop->screenNumber(p)); break; case PlacementArea: if (options->xineramaPlacementEnabled) - rect = desktop->screenGeometry(desktop->screenNumber(QCursor::pos())); + rect = desktop->screenGeometry(desktop->screenNumber(p)); break; case MovementArea: if (options->xineramaMovementEnabled) - rect = desktop->screenGeometry(desktop->screenNumber(QCursor::pos())); + rect = desktop->screenGeometry(desktop->screenNumber(p)); break; } - if (area.isNull()) { + + if (area.isNull()) return rect; - } + return area.intersect(rect); } -// ### KDE3: remove me! -QRect Workspace::clientArea() +QRect Workspace::clientArea(const QPoint& p) { - return clientArea( MaximizeArea ); + int screenNum = QApplication::desktop()->screenNumber(p); + QRect rect = QApplication::desktop()->screenGeometry(screenNum); + + if (area.isNull()) + return rect; + + return area.intersect(rect); } void Workspace::loadDesktopSettings() diff --git a/workspace.h b/workspace.h index 7524b02dfc..665d597ce0 100644 --- a/workspace.h +++ b/workspace.h @@ -17,6 +17,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich #include "options.h" #include "KWinInterface.h" #include +#include #include #ifdef HAVE_XINERAMA @@ -124,8 +125,9 @@ public: // default is MaximizeArea - QRect clientArea(); // ### KDE3: remove me! - QRect clientArea(clientAreaOption); + QRect clientArea(clientAreaOption, const QPoint& p); + QRect clientArea(const QPoint& p); + inline QRect clientArea(clientAreaOption opt) { return clientArea(opt, QCursor::pos()); } void removeClient( Client* );