~ubuntu-branches/ubuntu/precise/qt4-x11/precise-proposed

« back to all changes in this revision

Viewing changes to src/gui/kernel/qdnd_x11.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-02-22 10:39:17 UTC
  • Revision ID: package-import@ubuntu.com-20120222103917-3i81oqz0m01v8vnu
Tags: 4:4.8.0-1ubuntu7
Update kubuntu_29_window_shaping_fix.diff
with improved patch now upstream
http://qt.gitorious.org/qt/qt/commit/29ec5ba68a14b8c75876ce129dd7b3204f8ba503/diffs

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
#include "qwidget_p.h"
72
72
#include "qcursor_p.h"
73
73
 
74
 
#ifndef QT_NO_XFIXES
75
 
#include <X11/extensions/Xfixes.h>
76
 
#endif
77
 
 
78
74
QT_BEGIN_NAMESPACE
79
75
 
80
76
// #define DND_DEBUG
1426
1422
}
1427
1423
 
1428
1424
static
 
1425
bool windowInteractsWithPosition(const QPoint & pos, Window w, int shapeType)
 
1426
{
 
1427
    int nrectanglesRet, dummyOrdering;
 
1428
    XRectangle *rectangles = XShapeGetRectangles(QX11Info::display(), w, shapeType, &nrectanglesRet, &dummyOrdering);
 
1429
    bool interacts = true;
 
1430
    if (rectangles) {
 
1431
        interacts = false;
 
1432
        for (int i = 0; !interacts && i < nrectanglesRet; ++i)
 
1433
            interacts = QRect(rectangles[i].x, rectangles[i].y, rectangles[i].width, rectangles[i].height).contains(pos);
 
1434
        XFree(rectangles);
 
1435
    }
 
1436
    return interacts;
 
1437
}
 
1438
 
 
1439
static
1429
1440
Window findRealWindow(const QPoint & pos, Window w, int md)
1430
1441
{
1431
1442
    if (xdnd_data.deco && w == xdnd_data.deco->effectiveWinId())
1451
1462
                                   AnyPropertyType, &type, &f,&n,&a,&data);
1452
1463
                if (data) XFree(data);
1453
1464
                if (type) {
1454
 
#ifndef QT_NO_XFIXES
1455
 
                    if (X11->use_xfixes && X11->ptrXFixesCreateRegionFromWindow && X11->ptrXFixesFetchRegion && X11->ptrXFixesDestroyRegion) {
1456
 
                        XserverRegion region = X11->ptrXFixesCreateRegionFromWindow(X11->display, w, WindowRegionBounding);
1457
 
                        int nrectanglesRet;
1458
 
                        XRectangle *rectangles = X11->ptrXFixesFetchRegion(X11->display, region, &nrectanglesRet);
1459
 
                        if (rectangles) {
1460
 
                            windowContainsMouse = false;
1461
 
                            for (int i = 0; !windowContainsMouse && i < nrectanglesRet; ++i)
1462
 
                                windowContainsMouse = QRect(rectangles[i].x, rectangles[i].y, rectangles[i].width, rectangles[i].height).contains(pos);
1463
 
                            XFree(rectangles);
1464
 
                        }
1465
 
                        X11->ptrXFixesDestroyRegion(X11->display, region);
1466
 
 
1467
 
                        if (windowContainsMouse)
1468
 
                            return w;
1469
 
                    } else
1470
 
#endif
 
1465
                    // When ShapeInput and ShapeBounding are not set they return a single rectangle with the geometry of the window, this is why we
 
1466
                    // need an && here so that in the case one is set and the other is not we still get the correct result.
 
1467
                    windowContainsMouse = windowInteractsWithPosition(pos, w, ShapeInput) && windowInteractsWithPosition(pos, w, ShapeBounding);
 
1468
                    if (windowContainsMouse)
1471
1469
                        return w;
1472
1470
                }
1473
1471
            }