From 98f0b4668999d677d8bf91d57ac095d96e7a661c Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 18 Nov 2013 10:31:42 +0200 Subject: Android: Use native platform menus. This is an Android only patch, a proper implementation will be pushed soon to stable branch. Task-number: QTBUG-29462 Task-number: QTBUG-33588 Change-Id: I3447c523b4533a768d7f95e4ae60541b09a7944f Reviewed-by: Christoph Schleifenbaum Reviewed-by: Marc Mutz Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/widgets/qmenu.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 3a4fd449c8..0cbd1c720c 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1834,6 +1834,14 @@ QSize QMenu::sizeHint() const void QMenu::popup(const QPoint &p, QAction *atAction) { Q_D(QMenu); + +#ifdef Q_OS_ANDROID + if (!d->platformMenu.isNull() && !testAttribute(Qt::WA_SetStyle)) { + d->platformMenu->showPopup(window()->windowHandle(), p, 0); + return; + } +#endif + if (d->scroll) { // reset scroll state from last popup if (d->scroll->scrollOffset) d->itemsDirty = 1; // sizeHint will be incorrect if there is previous scroll -- cgit v1.2.3 From 829b1d13b225e87b8a385397e2b53c7a9f8cda9e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 28 Oct 2013 14:11:50 +0100 Subject: Ensure Qt::WA_Mapped is set in case of obscured native windows. Task-number: QTBUG-33520 Change-Id: I51f9b4634be29fd32f4ad9cc8b5d3e10b19ea2f5 Reviewed-by: Oliver Wolff Reviewed-by: Joerg Bornemann Reviewed-by: Gunnar Sletta --- src/widgets/kernel/qwidget_qpa.cpp | 2 +- src/widgets/kernel/qwidgetwindow.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index ae8a0b25b9..18045e3b09 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -506,9 +506,9 @@ void QWidgetPrivate::show_sys() QWindow *window = q->windowHandle(); + q->setAttribute(Qt::WA_Mapped); if (q->testAttribute(Qt::WA_DontShowOnScreen)) { invalidateBuffer(q->rect()); - q->setAttribute(Qt::WA_Mapped); if (q->isWindow() && q->windowModality() != Qt::NonModal && window) { // add our window to the modal window list QGuiApplicationPrivate::showModalWindow(window); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index e977ab3d6f..22e15e23fe 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -713,6 +713,10 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event break; } + // Note that widgetState == m_widget->data->window_state when triggered by QWidget::setWindowState(). + if (!(widgetState & Qt::WindowMinimized)) + m_widget->setAttribute(Qt::WA_Mapped); + // Sent event if the state changed (that is, it is not triggered by // QWidget::setWindowState(), which also sends an event to the widget). if (widgetState != int(m_widget->data->window_state)) { -- cgit v1.2.3 From 54b8c27e03d04c1e5cd35f75d5c0a8111240eb74 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 15 Nov 2013 11:26:38 +0100 Subject: Fix crash when windowcontainer is used in a dockwidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dockwidget's toplevel window would be a parent of the container's window when floating. When plugged back into the mainwindow the dockwidget's window is destroyed and the container's window along with it. Added a function toplevelAboutToBeDestroyed to unparent the containers window before this happens so parentWasChanged will work correctly. Change-Id: I06679cfb3a8fa3834c0db0be5973c012b8277275 Reviewed-by: Ulf Hermann Reviewed-by: Jørgen Lind --- src/widgets/kernel/qwidget_qpa.cpp | 6 +++++- src/widgets/kernel/qwindowcontainer.cpp | 19 ++++++++++++++++--- src/widgets/kernel/qwindowcontainer_p.h | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 18045e3b09..3c4985591e 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -53,6 +53,7 @@ #include #include "QtGui/private/qwindow_p.h" #include "QtGui/private/qguiapplication_p.h" +#include #include #include @@ -267,8 +268,11 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); // Reparenting toplevel to child - if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) + if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) { + if (extra && extra->hasWindowContainer) + QWindowContainer::toplevelAboutToBeDestroyed(q); q->destroy(); + } adjustFlags(f, q); data.window_flags = f; diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 6914f64f8e..7c319c5095 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -300,15 +300,28 @@ static void qwindowcontainer_traverse(QWidget *parent, qwindowcontainer_traverse } } +void QWindowContainer::toplevelAboutToBeDestroyed(QWidget *parent) +{ + if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)) { + d->window->setParent(&d->fakeParent); + } + qwindowcontainer_traverse(parent, toplevelAboutToBeDestroyed); +} + void QWindowContainer::parentWasChanged(QWidget *parent) { if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)) { if (d->window->parent()) { d->updateUsesNativeWidgets(); d->markParentChain(); - d->window->setParent(d->usesNativeWidgets - ? parent->windowHandle() - : parent->window()->windowHandle()); + QWidget *toplevel = d->usesNativeWidgets ? parent : parent->window(); + if (!toplevel->windowHandle()) { + QWidgetPrivate *tld = static_cast(QWidgetPrivate::get(toplevel)); + tld->createTLExtra(); + tld->createTLSysExtra(); + Q_ASSERT(toplevel->windowHandle()); + } + d->window->setParent(toplevel->windowHandle()); d->updateGeometry(); } } diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h index e2446bef42..a21f9bd35a 100644 --- a/src/widgets/kernel/qwindowcontainer_p.h +++ b/src/widgets/kernel/qwindowcontainer_p.h @@ -57,6 +57,7 @@ public: explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = 0, Qt::WindowFlags f = 0); ~QWindowContainer(); + static void toplevelAboutToBeDestroyed(QWidget *parent); static void parentWasChanged(QWidget *parent); static void parentWasMoved(QWidget *parent); static void parentWasRaised(QWidget *parent); -- cgit v1.2.3