summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2012-04-24 11:45:46 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-05-14 09:51:19 (GMT)
commitc3eb2e63425c47b8e3eeb7416e225fab10c5c15a (patch)
tree7461733238e94076f0bef7311271984e4724c8b0 /src
parenta93b7025c71f8c4f81ba3b516a65ee41e6ef419c (diff)
downloadQt-c3eb2e63425c47b8e3eeb7416e225fab10c5c15a.zip
Qt-c3eb2e63425c47b8e3eeb7416e225fab10c5c15a.tar.gz
Qt-c3eb2e63425c47b8e3eeb7416e225fab10c5c15a.tar.bz2
XShaping drag and drop fixes
No shaping rectangles means no interaction with the window The shaping rectangles are based on the window coords, so need to substract the window coords when checking for the point And some tests to prove this change is needed Backport from commit 07f3c1e26aa6dcd07a9705e7b2ea02ace9ea7c5d from qtbase Change-Id: I6dd6c75c2bd70463561445b4f4a3894c80981d26 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qdnd_x11.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
index b312d7e..e3d5391 100644
--- a/src/gui/kernel/qdnd_x11.cpp
+++ b/src/gui/kernel/qdnd_x11.cpp
@@ -1427,9 +1427,8 @@ bool windowInteractsWithPosition(const QPoint & pos, Window w, int shapeType)
{
int nrectanglesRet, dummyOrdering;
XRectangle *rectangles = XShapeGetRectangles(QX11Info::display(), w, shapeType, &nrectanglesRet, &dummyOrdering);
- bool interacts = true;
+ bool interacts = false;
if (rectangles) {
- interacts = false;
for (int i = 0; !interacts && i < nrectanglesRet; ++i)
interacts = QRect(rectangles[i].x, rectangles[i].y, rectangles[i].width, rectangles[i].height).contains(pos);
XFree(rectangles);
@@ -1438,7 +1437,7 @@ bool windowInteractsWithPosition(const QPoint & pos, Window w, int shapeType)
}
static
-Window findRealWindow(const QPoint & pos, Window w, int md)
+Window findRealWindow(const QPoint & pos, Window w, int md, bool ignoreNonXdndAwareWindows)
{
if (xdnd_data.deco && w == xdnd_data.deco->effectiveWinId())
return 0;
@@ -1452,7 +1451,7 @@ Window findRealWindow(const QPoint & pos, Window w, int md)
if (attr.map_state == IsViewable
&& QRect(attr.x,attr.y,attr.width,attr.height).contains(pos)) {
- bool windowContainsMouse = true;
+ bool windowContainsMouse = !ignoreNonXdndAwareWindows;
{
Atom type = XNone;
int f;
@@ -1463,12 +1462,15 @@ Window findRealWindow(const QPoint & pos, Window w, int md)
AnyPropertyType, &type, &f,&n,&a,&data);
if (data) XFree(data);
if (type) {
+ const QPoint relPos = pos - QPoint(attr.x,attr.y);
// When ShapeInput and ShapeBounding are not set they return a single rectangle with the geometry of the window, this is why we
// need an && here so that in the case one is set and the other is not we still get the correct result.
#if defined(ShapeInput) && defined(ShapeBounding)
- windowContainsMouse = windowInteractsWithPosition(pos, w, ShapeInput) && windowInteractsWithPosition(pos, w, ShapeBounding);
+ windowContainsMouse = windowInteractsWithPosition(relPos, w, ShapeInput) && windowInteractsWithPosition(relPos, w, ShapeBounding);
#elif defined(ShapeBounding)
- windowContainsMouse = windowInteractsWithPosition(pos, w, ShapeBounding);
+ windowContainsMouse = windowInteractsWithPosition(relPos, w, ShapeBounding);
+#else
+ windowContainsMouse = true;
#endif
if (windowContainsMouse)
return w;
@@ -1482,7 +1484,7 @@ Window findRealWindow(const QPoint & pos, Window w, int md)
r=0;
for (uint i=nc; !r && i--;) {
r = findRealWindow(pos-QPoint(attr.x,attr.y),
- c[i], md-1);
+ c[i], md-1, ignoreNonXdndAwareWindows);
}
XFree(c);
if (r)
@@ -1579,7 +1581,9 @@ void QDragManager::move(const QPoint & globalPos)
}
if (xdnd_data.deco && (!target || target == xdnd_data.deco->effectiveWinId())) {
DNDDEBUG << "need to find real window";
- target = findRealWindow(globalPos, rootwin, 6);
+ target = findRealWindow(globalPos, rootwin, 6, true);
+ if (target == 0)
+ target = findRealWindow(globalPos, rootwin, 6, false);
DNDDEBUG << "real window found" << QWidget::find(target) << target;
}
}