summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2012-02-20 15:38:02 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-02-21 16:56:26 (GMT)
commit33bb996c83e541c26df632b3e8883a1190cc97f0 (patch)
tree59f85c438c9ef0573cb33495ca1557c38e3be67d
parentba5d7d608cc31fc63354fd74d85a1bad7780fc45 (diff)
downloadQt-33bb996c83e541c26df632b3e8883a1190cc97f0.zip
Qt-33bb996c83e541c26df632b3e8883a1190cc97f0.tar.gz
Qt-33bb996c83e541c26df632b3e8883a1190cc97f0.tar.bz2
Take into account input shaping in findRealWindow
In previous commits we took into account bound shaping, but X also supports input shaping, so make sure it's inside both input and bounding shaping to consider the position as inside a window My tests show that when unset Bound Shaping and Input Shaping return the rectangle of the window itself, so we need to be inside both of the rectangle sets to consider the position as a dragabble position for the window Change-Id: Icb2204a50a97e4a5e02e75301c67287525b290ba Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--src/gui/kernel/qapplication_x11.cpp6
-rw-r--r--src/gui/kernel/qdnd_x11.cpp36
-rw-r--r--src/gui/kernel/qt_x11_p.h3
3 files changed, 19 insertions, 26 deletions
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 4d642a9..7460fa0 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -2062,9 +2062,6 @@ void qt_init(QApplicationPrivate *priv, int,
X11->ptrXFixesQueryVersion = XFIXES_LOAD_V1(XFixesQueryVersion);
X11->ptrXFixesSetCursorName = XFIXES_LOAD_V2(XFixesSetCursorName);
X11->ptrXFixesSelectSelectionInput = XFIXES_LOAD_V2(XFixesSelectSelectionInput);
- X11->ptrXFixesCreateRegionFromWindow = XFIXES_LOAD_V2(XFixesCreateRegionFromWindow);
- X11->ptrXFixesFetchRegion = XFIXES_LOAD_V2(XFixesFetchRegion);
- X11->ptrXFixesDestroyRegion = XFIXES_LOAD_V2(XFixesDestroyRegion);
if(X11->ptrXFixesQueryExtension && X11->ptrXFixesQueryVersion
&& X11->ptrXFixesQueryExtension(X11->display, &X11->xfixes_eventbase,
@@ -2087,9 +2084,6 @@ void qt_init(QApplicationPrivate *priv, int,
X11->ptrXFixesQueryVersion = 0;
X11->ptrXFixesSetCursorName = 0;
X11->ptrXFixesSelectSelectionInput = 0;
- X11->ptrXFixesCreateRegionFromWindow = 0;
- X11->ptrXFixesFetchRegion = 0;
- X11->ptrXFixesDestroyRegion = 0;
}
#endif // QT_NO_XFIXES
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
index d2050d1..c4d2469 100644
--- a/src/gui/kernel/qdnd_x11.cpp
+++ b/src/gui/kernel/qdnd_x11.cpp
@@ -1423,6 +1423,21 @@ void QDragManager::cancel(bool deleteSource)
}
static
+bool windowInteractsWithPosition(const QPoint & pos, Window w, int shapeType)
+{
+ int nrectanglesRet, dummyOrdering;
+ XRectangle *rectangles = XShapeGetRectangles(QX11Info::display(), w, shapeType, &nrectanglesRet, &dummyOrdering);
+ bool interacts = true;
+ 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);
+ }
+ return interacts;
+}
+
+static
Window findRealWindow(const QPoint & pos, Window w, int md)
{
if (xdnd_data.deco && w == xdnd_data.deco->effectiveWinId())
@@ -1448,23 +1463,10 @@ Window findRealWindow(const QPoint & pos, Window w, int md)
AnyPropertyType, &type, &f,&n,&a,&data);
if (data) XFree(data);
if (type) {
-#ifndef QT_NO_XFIXES
- if (X11->use_xfixes && X11->ptrXFixesCreateRegionFromWindow && X11->ptrXFixesFetchRegion && X11->ptrXFixesDestroyRegion) {
- XserverRegion region = X11->ptrXFixesCreateRegionFromWindow(X11->display, w, WindowRegionBounding);
- int nrectanglesRet;
- XRectangle *rectangles = X11->ptrXFixesFetchRegion(X11->display, region, &nrectanglesRet);
- if (rectangles) {
- windowContainsMouse = false;
- for (int i = 0; !windowContainsMouse && i < nrectanglesRet; ++i)
- windowContainsMouse = QRect(rectangles[i].x, rectangles[i].y, rectangles[i].width, rectangles[i].height).contains(pos);
- XFree(rectangles);
- }
- X11->ptrXFixesDestroyRegion(X11->display, region);
-
- if (windowContainsMouse)
- return w;
- } else
-#endif
+ // 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.
+ windowContainsMouse = windowInteractsWithPosition(pos, w, ShapeInput) && windowInteractsWithPosition(pos, w, ShapeBounding);
+ if (windowContainsMouse)
return w;
}
}
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 579a2b3..13dc90a 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -422,9 +422,6 @@ struct QX11Data
PtrXFixesQueryVersion ptrXFixesQueryVersion;
PtrXFixesSetCursorName ptrXFixesSetCursorName;
PtrXFixesSelectSelectionInput ptrXFixesSelectSelectionInput;
- PtrXFixesDestroyRegion ptrXFixesDestroyRegion;
- PtrXFixesCreateRegionFromWindow ptrXFixesCreateRegionFromWindow;
- PtrXFixesFetchRegion ptrXFixesFetchRegion;
#endif
#ifndef QT_NO_XINPUT