void QQuickPopupWindow::mousePressEvent(QMouseEvent *e)
{
    QRect rect = QRect(QPoint(), size());
    if (rect.contains(e->pos()))
        QQuickWindow::mousePressEvent(e);
    else
        forwardEventToTransientParent(e);
}
void popupWindow::mouseMoveEvent(QMouseEvent *e) {
    QRect rect = QRect(QPoint(), size());
    m_mouseMoved = true;
    if (rect.contains(e->pos())) {
        QQuickWindow::mouseMoveEvent(e);
    } else {
        forwardEventToTransientParent(e);
    }
}
void popupWindow::mouseReleaseEvent(QMouseEvent *e) {
    QRect rect = QRect(QPoint(), size());
    if (rect.contains(e->pos())) {
        if(m_mouseMoved) {
            QMouseEvent pe = QMouseEvent(QEvent::MouseButtonPress, e->pos(), e->button(),
                                         e->buttons(), e->modifiers());
            QQuickWindow::mousePressEvent(&pe);
            QQuickWindow::mouseReleaseEvent(e);
        }
        m_mouseMoved = true; // Initial mouse release counts as move.
    } else {
        forwardEventToTransientParent(e);
    }
}