From 15163d1939d86cfdcebd64ed2fb2cbc0cd56808a Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 17 Dec 2015 16:11:25 -0800 Subject: QHeaderView and others: Fix font lookup name It should the the actual class name, without any suffix. This also allows us to use the painter font when rendering CE_HeaderLabel and, as a consequence, change QHeaderView's font through the usual methods. Change-Id: I0b13ee349f5fa505be66a9c884c26885f5fc468f Task-number: QTBUG-33855 Task-number: QTBUG-37153 Reviewed-by: Timur Pocheptsov Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/kernel/qapplication.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 4f13c06c15..e20e820f12 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -740,15 +740,15 @@ void QApplicationPrivate::initializeWidgetFontHash() if (const QFont *font = theme->font(QPlatformTheme::ItemViewFont)) fontHash->insert(QByteArrayLiteral("QAbstractItemView"), *font); if (const QFont *font = theme->font(QPlatformTheme::ListViewFont)) - fontHash->insert(QByteArrayLiteral("QListViewFont"), *font); + fontHash->insert(QByteArrayLiteral("QListView"), *font); if (const QFont *font = theme->font(QPlatformTheme::HeaderViewFont)) - fontHash->insert(QByteArrayLiteral("QHeaderViewFont"), *font); + fontHash->insert(QByteArrayLiteral("QHeaderView"), *font); if (const QFont *font = theme->font(QPlatformTheme::ListBoxFont)) fontHash->insert(QByteArrayLiteral("QListBox"), *font); if (const QFont *font = theme->font(QPlatformTheme::ComboMenuItemFont)) - fontHash->insert(QByteArrayLiteral("QComboMenuItemFont"), *font); + fontHash->insert(QByteArrayLiteral("QComboMenuItem"), *font); if (const QFont *font = theme->font(QPlatformTheme::ComboLineEditFont)) - fontHash->insert(QByteArrayLiteral("QComboLineEditFont"), *font); + fontHash->insert(QByteArrayLiteral("QComboLineEdit"), *font); if (const QFont *font = theme->font(QPlatformTheme::SmallFont)) fontHash->insert(QByteArrayLiteral("QSmallFont"), *font); if (const QFont *font = theme->font(QPlatformTheme::MiniFont)) -- cgit v1.2.3 From a6b2a4642f07cd6e52b447e1e441b257990a8d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Sun, 25 Oct 2015 01:11:28 +0200 Subject: Fix incorrect screen number reported by QDesktopWidget Screens connected to separate graphics cards are detected as separate screens which don't have offset. This patch fixes obtaining the screen number by QWidget: it uses the screen assigned to the root widget. The patch also assigns a proper QScreen to each QDesktopWidget screen(). It also fixes closing a popup menu by clicking on another screen. Task-number: QTBUG-48545 Change-Id: I3d76261c0c067293d39949c4428b2d8dfd085dc7 Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qdesktopwidget.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index b88b3cc61d..d21e60198e 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -36,6 +36,7 @@ #include "qdesktopwidget_p.h" #include "qscreen.h" #include "qwidget_p.h" +#include "qwindow.h" QT_BEGIN_NAMESPACE @@ -99,13 +100,18 @@ void QDesktopWidgetPrivate::_q_updateScreens() QRegion virtualGeometry; - // update the geometry of each screen widget, determine virtual geometry - // and emit change signals afterwards. + // update the geometry of each screen widget, determine virtual geometry, + // set the new screen for window handle and emit change signals afterwards. QList changedScreens; for (int i = 0; i < screens.length(); i++) { - const QRect screenGeometry = screenList.at(i)->geometry(); - if (screenGeometry != screens.at(i)->geometry()) { - screens.at(i)->setGeometry(screenGeometry); + QDesktopScreenWidget *screenWidget = screens.at(i); + QScreen *qScreen = screenList.at(i); + QWindow *winHandle = screenWidget->windowHandle(); + if (winHandle && winHandle->screen() != qScreen) + winHandle->setScreen(qScreen); + const QRect screenGeometry = qScreen->geometry(); + if (screenGeometry != screenWidget->geometry()) { + screenWidget->setGeometry(screenGeometry); changedScreens.push_back(i); } virtualGeometry += screenGeometry; @@ -191,6 +197,21 @@ int QDesktopWidget::screenNumber(const QWidget *w) const if (!w) return 0; + // Find the root widget, get a QScreen pointer from it and find + // the screen number. + const QWidget *root = w; + const QWidget *tmp = w; + while ((tmp = tmp->parentWidget())) + root = tmp; + QWindow *winHandle = root->windowHandle(); + if (winHandle) { + int screenIdx = QGuiApplication::screens().indexOf(winHandle->screen()); + if (screenIdx > -1) + return screenIdx; + } + + // If the screen number cannot be obtained using QScreen pointer, + // get it from window position using screen geometry. QRect frame = w->frameGeometry(); if (!w->isWindow()) frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); -- cgit v1.2.3 From 60c333cabaf7514790c35f382a9f7f074fb7c20c Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 4 Jan 2016 16:10:03 +0100 Subject: QMacPanGestureRecognizer - stop timer on 'reset' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _panTimer has a target - for example, widget. 'reset' should stop this timer. The problem (quite subtle and difficult to reproduce) found in tst_QTouchEvent: widgets created/destoryed by different tests but we still can have a timer waiting for event dispatcher to 'processEvents', firing with now-invalid dangling pointer - 'target'. Change-Id: Iccaf3368a8ee6a0a2f60e9dcdf5d40fb7392ca21 Task-number: QTBUG-49844 Reviewed-by: Morten Johan Sørvig --- src/widgets/kernel/qmacgesturerecognizer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qmacgesturerecognizer.cpp b/src/widgets/kernel/qmacgesturerecognizer.cpp index 47003f5866..9f55e23cee 100644 --- a/src/widgets/kernel/qmacgesturerecognizer.cpp +++ b/src/widgets/kernel/qmacgesturerecognizer.cpp @@ -256,6 +256,7 @@ void QMacPanGestureRecognizer::reset(QGesture *gesture) QPanGesture *g = static_cast(gesture); _startPos = QPointF(); _panCanceled = true; + _panTimer.stop(); g->setOffset(QPointF(0, 0)); g->setLastOffset(QPointF(0, 0)); g->setAcceleration(qreal(1)); -- cgit v1.2.3 From 1606a0e508b8ecdcbdff953ef55136c8ff59ba79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Thu, 31 Dec 2015 21:47:41 +0100 Subject: QDesktopWidget::screenNumber(QWidget*): check virtual sibling screens Find the root widget only when more than one virtual desktop exists and find the screen index using virtual siblings from this root widget. Use intersecting rects instead of middle point to obtain the screen. This can help to get the screen index when the middle point is outside the screen geometry, but part of the window is still on the screen. If the widget is completely outside the screen geometry, -1 is returned. This commit amends: a6b2a4642f07cd6e52b447e1e441b257990a8d03 Change-Id: I80247fc1956a82c487ee6f728d1576bf48b28748 Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qdesktopwidget.cpp | 52 +++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index d21e60198e..e586be206e 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -195,28 +195,46 @@ const QRect QDesktopWidget::screenGeometry(int screenNo) const int QDesktopWidget::screenNumber(const QWidget *w) const { if (!w) - return 0; - - // Find the root widget, get a QScreen pointer from it and find - // the screen number. - const QWidget *root = w; - const QWidget *tmp = w; - while ((tmp = tmp->parentWidget())) - root = tmp; - QWindow *winHandle = root->windowHandle(); - if (winHandle) { - int screenIdx = QGuiApplication::screens().indexOf(winHandle->screen()); - if (screenIdx > -1) - return screenIdx; + return primaryScreen(); + + const QList allScreens = QGuiApplication::screens(); + QList screens = allScreens; + if (screens.isEmpty()) // This should never happen + return primaryScreen(); + + // If there is more than one virtual desktop + if (screens.count() != screens.first()->virtualSiblings().count()) { + // Find the root widget, get a QScreen from it and use the + // virtual siblings for checking the window position. + const QWidget *root = w; + const QWidget *tmp = w; + while ((tmp = tmp->parentWidget())) + root = tmp; + const QWindow *winHandle = root->windowHandle(); + if (winHandle) { + const QScreen *winScreen = winHandle->screen(); + if (winScreen) + screens = winScreen->virtualSiblings(); + } } - // If the screen number cannot be obtained using QScreen pointer, - // get it from window position using screen geometry. + // Get the screen number from window position using screen geometry + // and proper screens. QRect frame = w->frameGeometry(); if (!w->isWindow()) frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); - const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2; - return screenNumber(midpoint); + + QScreen *widgetScreen = Q_NULLPTR; + int largestArea = 0; + foreach (QScreen *screen, screens) { + QRect intersected = screen->geometry().intersected(frame); + int area = intersected.width() * intersected.height(); + if (largestArea < area) { + widgetScreen = screen; + largestArea = area; + } + } + return allScreens.indexOf(widgetScreen); } int QDesktopWidget::screenNumber(const QPoint &p) const -- cgit v1.2.3 From b50f0244c8f1b8e229a71018f39ac373d0ba6a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Fri, 1 Jan 2016 13:56:04 +0100 Subject: QDesktopWidget::screenNumber(QPoint): fix handling of virtual desktops On X11, QXcbVirtualDesktop represents an X11 screen while QScreen represents an X11 output. In the case that there are multiple screens (possibly with multiple outputs), calculate the screen number correctly: Find the screen index on the primary virtual desktop first to avoid obtaining a screen index which doesn't belong to the primary virtual desktop when screen geometry is similar. Change-Id: I4cbb29b7aa7cd2125759ffbbbe3db4e934feaeae Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qdesktopwidget.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index e586be206e..a1c2aebbe6 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -239,12 +239,25 @@ int QDesktopWidget::screenNumber(const QWidget *w) const int QDesktopWidget::screenNumber(const QPoint &p) const { - QList screens = QGuiApplication::screens(); - - for (int i = 0; i < screens.size(); ++i) - if (screens.at(i)->geometry().contains(p)) - return i; - + const QList screens = QGuiApplication::screens(); + if (!screens.isEmpty()) { + const QList primaryScreens = screens.first()->virtualSiblings(); + // Find the screen index on the primary virtual desktop first + foreach (QScreen *screen, primaryScreens) { + if (screen->geometry().contains(p)) + return screens.indexOf(screen); + } + // If the screen index is not found on primary virtual desktop, find + // the screen index on all screens except the first which was for + // sure in the previous loop. Some other screens may repeat. Find + // only when there is more than one virtual desktop. + if (screens.count() != primaryScreens.count()) { + for (int i = 1; i < screens.size(); ++i) { + if (screens[i]->geometry().contains(p)) + return i; + } + } + } return primaryScreen(); //even better would be closest screen } -- cgit v1.2.3