From b78e355fe5d786710727b89ee5931bea470167d5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 22 Mar 2012 15:51:16 +0100 Subject: Only create cmake files if MODULE is set. WinMain does not set MODULE, though it uses qt_module_config and generates incomplete cmake files in the wrong locations as a result. Change-Id: I5081a13a19469ab8cd01970a55684b8451bc79d7 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_module_config.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/qt_module_config.prf b/mkspecs/features/qt_module_config.prf index cae5f47387..75156a1f44 100644 --- a/mkspecs/features/qt_module_config.prf +++ b/mkspecs/features/qt_module_config.prf @@ -42,7 +42,7 @@ CONFIG -= fix_output_dirs win32|mac:!macx-xcode:CONFIG += debug_and_release linux*:QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF -CONFIG += create_cmake +!isEmpty(MODULE):CONFIG += create_cmake contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions -- cgit v1.2.3 From 3c3ea9a869086ebb02a5d0c475754f6a184a50ab Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 22 Mar 2012 15:10:26 +0000 Subject: Fix performance problem with NTLM auth in http POST A combination of other fixes resulted in authentication credentials with a blank username & password being incorrectly added to the cache only for NTLM. This caused authentication to be attempted with blank credentials first (which would fail), before the authenticationRequired signal was emitted. It caused a performance issue because of the extra 2 requests to the server (and possibly delays inserted by the server following a failed login) Change-Id: Ic588a20cfe7c24d5e60cd384caff0673a587e484 Reviewed-by: Martin Petersson --- src/network/kernel/qauthenticator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index eef2a7fa76..43b3618ea2 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -380,6 +380,8 @@ void QAuthenticatorPrivate::parseHttpResponse(const QListoptions[QLatin1String("realm")] = realm = QString::fromLatin1(options.value("realm")); -- cgit v1.2.3 From 1fe7e557d75962c9c79cc344037a02ed50369430 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 23 Mar 2012 05:24:09 +0000 Subject: Remove #if 0 sections from QRegExp autotest Use QEXPECT_FAIL instead (QRegExp is bugged w.r.t. the specific test data). Task-number: QTBUG-22466 Change-Id: Id5af01fa0d5c0536845fd4db19d4264498a8675b Reviewed-by: hjk Reviewed-by: Jason McDonald --- tests/auto/corelib/tools/qregexp/tst_qregexp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index 5470de76ee..4e1fba5fcb 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -137,12 +137,10 @@ void tst_QRegExp::indexIn_data() << QStringList(); QTest::newRow(qPrintable(stri + "anc09")) << QString("a(?:(?!)|b)z") << QString("abz") << 0 << 3 << QStringList(); -#if 0 - QTest::newRow(qPrintable(stri + "anc10")) << QString("a?(?=^b$)") << QString("ab") << 0 << 1 + QTest::newRow(qPrintable(stri + "anc10")) << QString("a?(?=^b$)") << QString("ab") << -1 << -1 << QStringList(); QTest::newRow(qPrintable(stri + "anc11")) << QString("a?(?=^b$)") << QString("b") << 0 << 0 << QStringList(); -#endif // back-references QTest::newRow(qPrintable(stri + "bref00")) << QString("(a*)(\\1)") << QString("aaaaa") << 0 << 4 @@ -573,6 +571,7 @@ void tst_QRegExp::indexIn() int mylen = rx.matchedLength(); QStringList mycaps = rx.capturedTexts(); + QEXPECT_FAIL("anc11", "QRegExp has bugs with anchors inside lookaheads", Abort); QCOMPARE( mypos, pos ); QCOMPARE( mylen, len ); if ( caps.size() > 1 && caps[1] != "IGNORE ME" ) { @@ -626,6 +625,7 @@ void tst_QRegExp::lastIndexIn() QStringList mycaps = rx.capturedTexts(); if ( mypos <= pos || pos == -1 ) { + QEXPECT_FAIL("anc11", "QRegExp has bugs with anchors inside lookaheads", Abort); QCOMPARE( mypos, pos ); QCOMPARE( mylen, len ); -- cgit v1.2.3 From 3b69fa6bc70efe6f14cb67546812f611b891709c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 9 Mar 2012 11:38:55 +0100 Subject: Implement QSystemTrayIcon for X11. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reimplement using a QWidget. Use X Change-Id: I7f8326598fb7210d59bc1d682cdada4526d5b6dd Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbwindow.cpp | 1 + src/widgets/util/qsystemtrayicon_p.h | 56 ---- src/widgets/util/qsystemtrayicon_x11.cpp | 367 +++++++++------------ src/widgets/util/util.pri | 3 + .../util/qsystemtrayicon/tst_qsystemtrayicon.cpp | 7 +- 5 files changed, 159 insertions(+), 275 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 4de3734c22..02bfb87d6e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1298,6 +1298,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even connection()->drag()->handleLeave(window(), event); } else if (event->type == atom(QXcbAtom::XdndDrop)) { connection()->drag()->handleDrop(window(), event); + } else if (event->type == atom(QXcbAtom::_XEMBED)) { // QSystemTrayIcon } else { qWarning() << "QXcbWindow: Unhandled client message:" << connection()->atomName(event->type); } diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h index cf7d794696..f7344df19c 100644 --- a/src/widgets/util/qsystemtrayicon_p.h +++ b/src/widgets/util/qsystemtrayicon_p.h @@ -122,62 +122,6 @@ private: int timerId; }; -#if defined(Q_WS_X11) -QT_BEGIN_INCLUDE_NAMESPACE -#include -#include -#include -#include -QT_END_INCLUDE_NAMESPACE - -class QSystemTrayIconSys : public QWidget -{ - friend class QSystemTrayIconPrivate; - -public: - QSystemTrayIconSys(QSystemTrayIcon *q); - ~QSystemTrayIconSys(); - enum { - SYSTEM_TRAY_REQUEST_DOCK = 0, - SYSTEM_TRAY_BEGIN_MESSAGE = 1, - SYSTEM_TRAY_CANCEL_MESSAGE =2 - }; - - void addToTray(); - void updateIcon(); - XVisualInfo* getSysTrayVisualInfo(); - - // QObject::event is public but QWidget's ::event() re-implementation - // is protected ;( - inline bool deliverToolTipEvent(QEvent *e) - { return QWidget::event(e); } - - static Window sysTrayWindow; - static QList trayIcons; - static QCoreApplication::EventFilter oldEventFilter; - static bool sysTrayTracker(void *message, long *result); - static Window locateSystemTray(); - static Atom sysTraySelection; - static XVisualInfo sysTrayVisual; - -protected: - void paintEvent(QPaintEvent *pe); - void resizeEvent(QResizeEvent *re); - bool x11Event(XEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); -#ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *event); -#endif - bool event(QEvent *e); - -private: - QPixmap background; - QSystemTrayIcon *q; - Colormap colormap; -}; -#endif // Q_WS_X11 - QT_END_NAMESPACE #endif // QT_NO_SYSTEMTRAYICON diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index c5071b339d..174c39d1f6 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -39,9 +39,7 @@ ** ****************************************************************************/ -#include "private/qt_x11_p.h" #include "qlabel.h" -#include "qx11info_x11.h" #include "qpainter.h" #include "qpixmap.h" #include "qbitmap.h" @@ -52,236 +50,165 @@ #include "qtimer.h" #include "qsystemtrayicon_p.h" #include "qpaintengine.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include #ifndef QT_NO_SYSTEMTRAYICON QT_BEGIN_NAMESPACE -Window QSystemTrayIconSys::sysTrayWindow = XNone; -QList QSystemTrayIconSys::trayIcons; -QCoreApplication::EventFilter QSystemTrayIconSys::oldEventFilter = 0; -Atom QSystemTrayIconSys::sysTraySelection = XNone; -XVisualInfo QSystemTrayIconSys::sysTrayVisual = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +enum { + SYSTEM_TRAY_REQUEST_DOCK = 0, + SYSTEM_TRAY_BEGIN_MESSAGE = 1, + SYSTEM_TRAY_CANCEL_MESSAGE =2 +}; -// Locate the system tray -Window QSystemTrayIconSys::locateSystemTray() +// ### fixme (15.3.2012): The following issues need to be resolved: +// - Tracking of the actual tray window for DestroyNotify and re-creation +// of the icons on the new window should it change (see Qt 4.X). + +// Global context for the X11 system tray containing a display for the primary +// screen and a selection atom from which the tray window can be determined. +class QX11SystemTrayContext { - Display *display = QX11Info::display(); - if (sysTraySelection == XNone) { - int screen = QX11Info::appScreen(); - QString net_sys_tray = QString::fromLatin1("_NET_SYSTEM_TRAY_S%1").arg(screen); - sysTraySelection = XInternAtom(display, net_sys_tray.toLatin1(), False); - } +public: + QX11SystemTrayContext(); + ~QX11SystemTrayContext(); - return XGetSelectionOwner(QX11Info::display(), sysTraySelection); -} + bool isValid() const { return m_systemTraySelection != 0; } -XVisualInfo* QSystemTrayIconSys::getSysTrayVisualInfo() -{ - Display *display = QX11Info::display(); - - if (!sysTrayVisual.visual) { - Window win = locateSystemTray(); - if (win != XNone) { - Atom actual_type; - int actual_format; - ulong nitems, bytes_remaining; - uchar *data = 0; - int result = XGetWindowProperty(display, win, ATOM(_NET_SYSTEM_TRAY_VISUAL), 0, 1, - False, XA_VISUALID, &actual_type, - &actual_format, &nitems, &bytes_remaining, &data); - VisualID vid = 0; - if (result == Success && data && actual_type == XA_VISUALID && actual_format == 32 && - nitems == 1 && bytes_remaining == 0) - vid = *(VisualID*)data; - if (data) - XFree(data); - if (vid == 0) - return 0; - - uint mask = VisualIDMask; - XVisualInfo *vi, rvi; - int count; - rvi.visualid = vid; - vi = XGetVisualInfo(display, mask, &rvi, &count); - if (vi) { - sysTrayVisual = vi[0]; - XFree((char*)vi); - } - if (sysTrayVisual.depth != 32) - memset(&sysTrayVisual, 0, sizeof(sysTrayVisual)); - } - } + inline Display *display() const { return m_display; } + inline int screenNumber() const { return m_screenNumber; } + Window locateSystemTray() const; - return sysTrayVisual.visual ? &sysTrayVisual : 0; -} +private: + Display *m_display; + int m_screenNumber; + Atom m_systemTraySelection; +}; -bool QSystemTrayIconSys::sysTrayTracker(void *message, long *result) +QX11SystemTrayContext::QX11SystemTrayContext() : m_display(0), m_screenNumber(0), m_systemTraySelection(0) { - bool retval = false; - if (QSystemTrayIconSys::oldEventFilter) - retval = QSystemTrayIconSys::oldEventFilter(message, result); - - if (trayIcons.isEmpty()) - return retval; - - Display *display = QX11Info::display(); - XEvent *ev = (XEvent *)message; - if (ev->type == DestroyNotify && ev->xany.window == sysTrayWindow) { - sysTrayWindow = locateSystemTray(); - memset(&sysTrayVisual, 0, sizeof(sysTrayVisual)); - for (int i = 0; i < trayIcons.count(); i++) { - if (sysTrayWindow == XNone) { - QBalloonTip::hideBalloon(); - trayIcons[i]->hide(); // still no luck - trayIcons[i]->destroy(); - trayIcons[i]->create(); - } else - trayIcons[i]->addToTray(); // add it to the new tray - } - retval = true; - } else if (ev->type == ClientMessage && sysTrayWindow == XNone) { - static Atom manager_atom = XInternAtom(display, "MANAGER", False); - XClientMessageEvent *cm = (XClientMessageEvent *)message; - if ((cm->message_type == manager_atom) && ((Atom)cm->data.l[1] == sysTraySelection)) { - sysTrayWindow = cm->data.l[2]; - memset(&sysTrayVisual, 0, sizeof(sysTrayVisual)); - XSelectInput(display, sysTrayWindow, StructureNotifyMask); - for (int i = 0; i < trayIcons.count(); i++) { - trayIcons[i]->addToTray(); - } - retval = true; - } - } else if (ev->type == PropertyNotify && ev->xproperty.atom == ATOM(_NET_SYSTEM_TRAY_VISUAL) && - ev->xproperty.window == sysTrayWindow) { - memset(&sysTrayVisual, 0, sizeof(sysTrayVisual)); - for (int i = 0; i < trayIcons.count(); i++) { - trayIcons[i]->addToTray(); - } + QScreen *screen = QGuiApplication::primaryScreen(); + if (!screen) { + qWarning("%s: No screen.", Q_FUNC_INFO); + return; + } + // Open display using screen name and retrieve screen number from "hostname:0.0" + const QByteArray name = screen->name().toLocal8Bit(); + const int dotPos = name.lastIndexOf('.'); + if (dotPos != -1) { + bool ok; + const int n = name.mid(dotPos + 1).toInt(&ok); + if (ok) + m_screenNumber = n; + } + m_display = XOpenDisplay(name.constData()); + if (!m_display) { + qWarning("%s: Cannot open display '%s'.", Q_FUNC_INFO, name.constData()); + return; } - return retval; + const QByteArray netSysTray = "_NET_SYSTEM_TRAY_S" + QByteArray::number(m_screenNumber); + m_systemTraySelection = XInternAtom(m_display, netSysTray.constData(), False); + if (!m_systemTraySelection) { + qWarning("%s: Unable to retrieve atom '%s'.", Q_FUNC_INFO, netSysTray.constData()); + return; + } } -QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *q) - : QWidget(0, Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint), - q(q), colormap(0) +Window QX11SystemTrayContext::locateSystemTray() const { - setAttribute(Qt::WA_AlwaysShowToolTips); - setAttribute(Qt::WA_QuitOnClose, false); - setAttribute(Qt::WA_NoSystemBackground, true); - setAttribute(Qt::WA_PaintOnScreen); - - static bool eventFilterAdded = false; - Display *display = QX11Info::display(); - if (!eventFilterAdded) { - oldEventFilter = qApp->setEventFilter(sysTrayTracker); - eventFilterAdded = true; - Window root = QX11Info::appRootWindow(); - XWindowAttributes attr; - XGetWindowAttributes(display, root, &attr); - if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) { - (void) QApplication::desktop(); // lame trick to ensure our event mask is not overridden - XSelectInput(display, root, attr.your_event_mask | StructureNotifyMask); // for MANAGER selection - } - } - if (trayIcons.isEmpty()) { - sysTrayWindow = locateSystemTray(); - if (sysTrayWindow != XNone) - XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events - } - trayIcons.append(this); - setMouseTracking(true); -#ifndef QT_NO_TOOLTIP - setToolTip(q->toolTip()); -#endif - if (sysTrayWindow != XNone) - addToTray(); + if (isValid()) + return XGetSelectionOwner(m_display, m_systemTraySelection); + return 0; } -QSystemTrayIconSys::~QSystemTrayIconSys() +QX11SystemTrayContext::~QX11SystemTrayContext() { - trayIcons.removeAt(trayIcons.indexOf(this)); - Display *display = QX11Info::display(); - if (trayIcons.isEmpty()) { - if (sysTrayWindow == XNone) - return; - if (display) - XSelectInput(display, sysTrayWindow, 0); // stop tracking the tray - sysTrayWindow = XNone; - } - if (colormap) - XFreeColormap(display, colormap); + if (m_display) + XCloseDisplay(m_display); } -void QSystemTrayIconSys::addToTray() +Q_GLOBAL_STATIC(QX11SystemTrayContext, qX11SystemTrayContext) + +// System tray widget. Could be replaced by a QWindow with +// a backing store if it did not need tooltip handling. +class QSystemTrayIconSys : public QWidget { - Q_ASSERT(sysTrayWindow != XNone); - Display *display = QX11Info::display(); - - XVisualInfo *vi = getSysTrayVisualInfo(); - if (vi && vi->visual) { - Window root = RootWindow(display, vi->screen); - Window p = root; - if (QWidget *pw = parentWidget()) - p = pw->effectiveWinId(); - colormap = XCreateColormap(display, root, vi->visual, AllocNone); - XSetWindowAttributes wsa; - wsa.background_pixmap = 0; - wsa.colormap = colormap; - wsa.background_pixel = 0; - wsa.border_pixel = 0; - Window wid = XCreateWindow(display, p, -1, -1, 1, 1, - 0, vi->depth, InputOutput, vi->visual, - CWBackPixmap|CWBackPixel|CWBorderPixel|CWColormap, &wsa); - create(wid); - } else { - XSetWindowBackgroundPixmap(display, winId(), ParentRelative); - } +public: + explicit QSystemTrayIconSys(QSystemTrayIcon *q); + + inline void updateIcon() { update(); } + inline QSystemTrayIcon *systemTrayIcon() const { return q; } + + QRect globalGeometry() const; + +protected: + virtual void mousePressEvent(QMouseEvent *ev); + virtual void mouseDoubleClickEvent(QMouseEvent *ev); + virtual bool event(QEvent *); + virtual void paintEvent(QPaintEvent *); - // GNOME, NET WM Specification +private: + QSystemTrayIcon *q; +}; + +QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) : + q(qIn) +{ + setToolTip(q->toolTip()); + QX11SystemTrayContext *context = qX11SystemTrayContext(); + Q_ASSERT(context->isValid()); + setAttribute(Qt::WA_AlwaysShowToolTips, true); + setAttribute(Qt::WA_TranslucentBackground, true); + setAttribute(Qt::WA_QuitOnClose, false); + setWindowFlags(Qt::Window | Qt::FramelessWindowHint); + const QSize size(22, 22); // Gnome, standard size + setGeometry(QRect(QPoint(0, 0), size)); + setMinimumSize(size); + createWinId(); + setMouseTracking(true); + + Display *display = context->display(); + + // Request to be a tray window according to GNOME, NET WM Specification static Atom netwm_tray_atom = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", False); long l[5] = { CurrentTime, SYSTEM_TRAY_REQUEST_DOCK, winId(), 0, 0 }; XEvent ev; memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; - ev.xclient.window = sysTrayWindow; + ev.xclient.window = context->locateSystemTray(); ev.xclient.message_type = netwm_tray_atom; ev.xclient.format = 32; memcpy((char *)&ev.xclient.data, (const char *) l, sizeof(l)); - XSendEvent(display, sysTrayWindow, False, 0, &ev); - setMinimumSize(22, 22); // required at least on GNOME -} - -void QSystemTrayIconSys::updateIcon() -{ - update(); + XSendEvent(display, ev.xclient.window, False, 0, &ev); + XSync(display, False); + show(); } -void QSystemTrayIconSys::resizeEvent(QResizeEvent *re) +QRect QSystemTrayIconSys::globalGeometry() const { - QWidget::resizeEvent(re); - updateIcon(); + QX11SystemTrayContext *context = qX11SystemTrayContext(); + ::Window dummy; + int x, y, rootX, rootY; + unsigned int width, height, border, depth; + // Use X11 API since we are parented on the tray, about which the QWindow does not know. + XGetGeometry(context->display(), winId(), &dummy, &x, &y, &width, &height, &border, &depth); + XTranslateCoordinates(context->display(), winId(), + XRootWindow(context->display(), context->screenNumber()), + x, y, &rootX, &rootY, &dummy); + return QRect(QPoint(rootX, rootY), QSize(width, height)); } -void QSystemTrayIconSys::paintEvent(QPaintEvent*) -{ - QPainter p(this); - if (!getSysTrayVisualInfo()) { - const QRegion oldSystemClip = p.paintEngine()->systemClip(); - const QRect clearedRect = oldSystemClip.boundingRect(); - XClearArea(QX11Info::display(), winId(), clearedRect.x(), clearedRect.y(), - clearedRect.width(), clearedRect.height(), False); - QPaintEngine *pe = p.paintEngine(); - pe->setSystemClip(clearedRect); - q->icon().paint(&p, rect()); - pe->setSystemClip(oldSystemClip); - } else { - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(rect(), Qt::transparent); - p.setCompositionMode(QPainter::CompositionMode_SourceOver); - q->icon().paint(&p, rect()); - } -} void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev) { @@ -308,41 +235,45 @@ void QSystemTrayIconSys::mouseDoubleClickEvent(QMouseEvent *ev) emit q->activated(QSystemTrayIcon::DoubleClick); } -#ifndef QT_NO_WHEELEVENT -void QSystemTrayIconSys::wheelEvent(QWheelEvent *e) -{ - QApplication::sendEvent(q, e); -} -#endif - bool QSystemTrayIconSys::event(QEvent *e) { - if (e->type() == QEvent::ToolTip) { + switch (e->type()) { +#ifndef QT_NO_WHEELEVENT + case QEvent::Wheel: return QApplication::sendEvent(q, e); +#endif + default: + break; } return QWidget::event(e); } -bool QSystemTrayIconSys::x11Event(XEvent *event) +void QSystemTrayIconSys::paintEvent(QPaintEvent *) { - if (event->type == ReparentNotify) - show(); - return QWidget::x11Event(event); + // Note: Transparent pixels require a particular Visual which XCB + // currently does not support yet. + const QRect rect(QPoint(0, 0), geometry().size()); + QPainter painter(this); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(rect, Qt::transparent); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + q->icon().paint(&painter, rect); } //////////////////////////////////////////////////////////////////////////// + void QSystemTrayIconPrivate::install_sys() { Q_Q(QSystemTrayIcon); - if (!sys) + if (!sys && qX11SystemTrayContext()->isValid()) sys = new QSystemTrayIconSys(q); } QRect QSystemTrayIconPrivate::geometry_sys() const { if (!sys) - return QRect(); - return QRect(sys->mapToGlobal(QPoint(0, 0)), sys->size()); + return QRect(); + return sys->globalGeometry(); } void QSystemTrayIconPrivate::remove_sys() @@ -357,9 +288,8 @@ void QSystemTrayIconPrivate::remove_sys() void QSystemTrayIconPrivate::updateIcon_sys() { - if (!sys) - return; - sys->updateIcon(); + if (sys) + sys->updateIcon(); } void QSystemTrayIconPrivate::updateMenu_sys() @@ -378,7 +308,10 @@ void QSystemTrayIconPrivate::updateToolTip_sys() bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() { - return QSystemTrayIconSys::locateSystemTray() != XNone; + const QString platform = QGuiApplication::platformName(); + if (platform.compare(QStringLiteral("xcb"), Qt::CaseInsensitive) == 0) + return qX11SystemTrayContext()->locateSystemTray() != None; + return false; } bool QSystemTrayIconPrivate::supportsMessages_sys() @@ -391,8 +324,8 @@ void QSystemTrayIconPrivate::showMessage_sys(const QString &message, const QStri { if (!sys) return; - QPoint g = sys->mapToGlobal(QPoint(0, 0)); - QBalloonTip::showBalloon(icon, message, title, sys->q, + const QPoint g = sys->globalGeometry().topLeft(); + QBalloonTip::showBalloon(icon, message, title, sys->systemTrayIcon(), QPoint(g.x() + sys->width()/2, g.y() + sys->height()/2), msecs); } diff --git a/src/widgets/util/util.pri b/src/widgets/util/util.pri index 16765558f6..958958f469 100644 --- a/src/widgets/util/util.pri +++ b/src/widgets/util/util.pri @@ -29,6 +29,9 @@ SOURCES += \ win32:!wince* { SOURCES += util/qsystemtrayicon_win.cpp +} else:contains(QT_CONFIG, xcb) { + SOURCES += util/qsystemtrayicon_x11.cpp + CONFIG += x11 } else { SOURCES += util/qsystemtrayicon_qpa.cpp } diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp index 1f717727b0..9a09af0282 100644 --- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp +++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp @@ -42,7 +42,7 @@ #include -#include +#include #include #include #include @@ -125,7 +125,10 @@ void tst_QSystemTrayIcon::supportsMessages() #elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QCOMPARE(QSystemTrayIcon::supportsMessages(), true); #else - QEXPECT_FAIL("", "QTBUG-20978 QSystemTrayIcon is unimplemented for qpa", Abort); + const QString platform = QGuiApplication::platformName(); + if (platform.compare(QStringLiteral("xcb"), Qt::CaseInsensitive)) { + QEXPECT_FAIL("", "QTBUG-20978 QSystemTrayIcon is unimplemented for qpa", Abort); + } QCOMPARE(QSystemTrayIcon::supportsMessages(), true); #endif } -- cgit v1.2.3 From 400e59201bf93dc9519cc4cf58286863330dc4eb Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Mon, 19 Mar 2012 17:13:13 +0100 Subject: Initial implementation of QQnxServices Extends platform services for QNX devices. Change-Id: I1eb685cdb38591cd73eaaf40ffb5691db0142953 Reviewed-by: Jeff Kehres Reviewed-by: Sean Harmer Reviewed-by: Kevin Krammer Reviewed-by: Robin Burchell --- src/plugins/platforms/qnx/qnx.pro | 10 ++++ src/plugins/platforms/qnx/qqnxintegration.cpp | 17 ++++++ src/plugins/platforms/qnx/qqnxintegration.h | 4 ++ src/plugins/platforms/qnx/qqnxservices.cpp | 81 +++++++++++++++++++++++++++ src/plugins/platforms/qnx/qqnxservices.h | 64 +++++++++++++++++++++ 5 files changed, 176 insertions(+) create mode 100644 src/plugins/platforms/qnx/qqnxservices.cpp create mode 100644 src/plugins/platforms/qnx/qqnxservices.h diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro index cf82084de0..588464fc47 100644 --- a/src/plugins/platforms/qnx/qnx.pro +++ b/src/plugins/platforms/qnx/qnx.pro @@ -37,6 +37,7 @@ SOURCES = main.cpp \ qqnxclipboard.cpp \ qqnxrootwindow.cpp + HEADERS = qqnxbuffer.h \ qqnxeventthread.h \ qqnxkeytranslator.h \ @@ -51,6 +52,11 @@ HEADERS = qqnxbuffer.h \ qqnxclipboard.h \ qqnxrootwindow.h +CONFIG(blackberry) { + SOURCES += qqnxservices.cpp + HEADERS += qqnxservices.h +} + CONFIG(qqnx_imf) { DEFINES += QQNX_IMF HEADERS += qqnxinputcontext_imf.h @@ -64,6 +70,10 @@ QMAKE_CXXFLAGS += -I./private LIBS += -lpps -lscreen -lEGL -lclipboard +CONFIG(blackberry) { + LIBS += -lbps +} + include (../../../platformsupport/eglconvenience/eglconvenience.pri) include (../../../platformsupport/fontdatabases/fontdatabases.pri) diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index cb7f14f963..5ef34f3aea 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -50,6 +50,7 @@ #include "qqnxvirtualkeyboard.h" #include "qqnxclipboard.h" #include "qqnxglcontext.h" +#include "qqnxservices.h" #if defined(QQnx_IMF) #include "qqnxinputcontext_imf.h" @@ -82,6 +83,7 @@ QQnxIntegration::QQnxIntegration() , m_fontDatabase(new QGenericUnixFontDatabase()) , m_paintUsingOpenGL(false) , m_eventDispatcher(createUnixEventDispatcher()) + , m_services(0) #ifndef QT_NO_CLIPBOARD , m_clipboard(0) #endif @@ -124,6 +126,11 @@ QQnxIntegration::QQnxIntegration() // Set up the input context m_inputContext = new QQnxInputContext; + + // Create services handling class +#ifdef Q_OS_BLACKBERRY + m_services = new QQnxServices; +#endif } QQnxIntegration::~QQnxIntegration() @@ -154,6 +161,11 @@ QQnxIntegration::~QQnxIntegration() // Cleanup global OpenGL resources QQnxGLContext::shutdown(); + // Destroy services class +#ifdef Q_OS_BLACKBERRY + delete m_services; +#endif + #if defined(QQNXINTEGRATION_DEBUG) qDebug() << "QQnx: platform plugin shutdown end"; #endif @@ -266,6 +278,11 @@ QVariant QQnxIntegration::styleHint(QPlatformIntegration::StyleHint hint) const return QPlatformIntegration::styleHint(hint); } +QPlatformServices * QQnxIntegration::services() const +{ + return m_services; +} + QWindow *QQnxIntegration::window(screen_window_t qnxWindow) { #if defined(QQNXINTEGRATION_DEBUG) diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index 892bb6e16f..6aa16100ad 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -54,6 +54,7 @@ class QQnxEventThread; class QQnxInputContext; class QQnxNavigatorEventHandler; class QQnxWindow; +class QQnxServices; #ifndef QT_NO_CLIPBOARD class QQnxClipboard; @@ -91,6 +92,8 @@ public: bool paintUsingOpenGL() const { return m_paintUsingOpenGL; } + virtual QPlatformServices *services() const; + static QWindow *window(screen_window_t qnxWindow); private: @@ -104,6 +107,7 @@ private: QPlatformFontDatabase *m_fontDatabase; bool m_paintUsingOpenGL; QAbstractEventDispatcher *m_eventDispatcher; + QQnxServices *m_services; #ifndef QT_NO_CLIPBOARD mutable QQnxClipboard* m_clipboard; #endif diff --git a/src/plugins/platforms/qnx/qqnxservices.cpp b/src/plugins/platforms/qnx/qqnxservices.cpp new file mode 100644 index 0000000000..a1a27906ae --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxservices.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** +** +** Copyright (C) 2011 - 2012 Research In Motion +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqnxservices.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QQnxServices::QQnxServices() +{ + bps_initialize(); +} + +QQnxServices::~QQnxServices() +{ + bps_shutdown(); +} + +bool QQnxServices::openUrl(const QUrl &url) +{ + return navigatorInvoke(url); +} + +bool QQnxServices::openDocument(const QUrl &url) +{ + return navigatorInvoke(url); +} + +bool QQnxServices::navigatorInvoke(const QUrl &url) +{ + if (!url.isValid() || url.isRelative()) + return false; + + int ret = navigator_invoke(url.toString().toUtf8(), 0); + + return (ret == BPS_SUCCESS); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxservices.h b/src/plugins/platforms/qnx/qqnxservices.h new file mode 100644 index 0000000000..36eb8edf65 --- /dev/null +++ b/src/plugins/platforms/qnx/qqnxservices.h @@ -0,0 +1,64 @@ +/*************************************************************************** +** +** Copyright (C) 2011 - 2012 Research In Motion +** Contact: http://www.qt-project.org/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQNXSERVICES_H +#define QQNXSERVICES_H + +#include + +QT_BEGIN_NAMESPACE + +class QQnxServices : public QPlatformServices +{ +public: + QQnxServices(); + ~QQnxServices(); + + bool openUrl(const QUrl &url); + bool openDocument(const QUrl &url); + +private: + bool navigatorInvoke(const QUrl &url); +}; + +QT_END_NAMESPACE + +#endif // QQNXSERVICES_H -- cgit v1.2.3 From 4a79b52bde74ed7332d92543b8cf1ac810e19c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 23 Mar 2012 08:51:15 +0100 Subject: Make QEglFSBackingStore use QtGui-only APIs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now have better replacements for QGLPaintDevice etc. Change-Id: I3ac563f0ac26a563b3c788d16c77e0237d9d96d9 Reviewed-by: Donald Carr Reviewed-by: Jørgen Lind Reviewed-by: Andy Nichols --- src/plugins/platforms/eglfs/eglfs.pro | 4 -- src/plugins/platforms/eglfs/qeglfsbackingstore.cpp | 77 +++++++++------------- src/plugins/platforms/eglfs/qeglfsbackingstore.h | 17 +++-- 3 files changed, 43 insertions(+), 55 deletions(-) diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index 86a1b8239c..c12d612c98 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -3,10 +3,6 @@ load(qt_plugin) QT += core-private gui-private platformsupport-private -!contains(QT_CONFIG, no-widgets) { - QT += opengl opengl-private widgets-private -} - DESTDIR = $$QT.gui.plugins/platforms #DEFINES += QEGL_EXTRA_DEBUG diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp index d2e4a47e56..8e9e5f76e0 100644 --- a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp +++ b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp @@ -41,67 +41,54 @@ #include "qeglfsbackingstore.h" -#ifndef QT_NO_WIDGETS -#include -#include -#endif //QT_NO_WIDGETS - -#include -#include +#include +#include QT_BEGIN_NAMESPACE -#ifndef QT_NO_WIDGETS -class QEglFSPaintDevice : public QGLPaintDevice +QEglFSBackingStore::QEglFSBackingStore(QWindow *window) + : QPlatformBackingStore(window) + , m_context(new QOpenGLContext) { -public: - QEglFSPaintDevice(QEglFSScreen *screen) - :QGLPaintDevice(), m_screen(screen) - { - #ifdef QEGL_EXTRA_DEBUG - qWarning("QEglPaintDevice %p, %p",this, screen); - #endif - } - - QSize size() const { return m_screen->geometry().size(); } - QGLContext* context() const { return QGLContext::fromOpenGLContext(m_screen->platformContext()->context()); } - - QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); } + m_context->setFormat(window->requestedFormat()); + m_context->setScreen(window->screen()); + m_context->create(); +} - void beginPaint(){ - QGLPaintDevice::beginPaint(); - } -private: - QEglFSScreen *m_screen; - QGLContext *m_context; -}; -#endif //QT_NO_WIDGETS +QEglFSBackingStore::~QEglFSBackingStore() +{ + delete m_context; +} -QEglFSBackingStore::QEglFSBackingStore(QWindow *window) - : QPlatformBackingStore(window), - m_paintDevice(0) +QPaintDevice *QEglFSBackingStore::paintDevice() { -#ifdef QEGL_EXTRA_DEBUG - qWarning("QEglBackingStore %p, %p", window, window->screen()); -#endif -#ifdef QT_NO_WIDGETS - m_paintDevice = new QImage(0,0); -#else - m_paintDevice = new QEglFSPaintDevice(static_cast(window->screen()->handle())); -#endif //QT_NO_WIDGETS + return m_device; } void QEglFSBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { - Q_UNUSED(window); Q_UNUSED(region); Q_UNUSED(offset); + #ifdef QEGL_EXTRA_DEBUG qWarning("QEglBackingStore::flush %p", window); #endif -#ifndef QT_NO_WIDGETS - static_cast(m_paintDevice)->context()->swapBuffers(); -#endif //QT_NO_WIDGETS + + m_context->swapBuffers(window); +} + +void QEglFSBackingStore::beginPaint(const QRegion &) +{ + // needed to prevent QOpenGLContext::makeCurrent() from failing + window()->setSurfaceType(QSurface::OpenGLSurface); + + m_context->makeCurrent(window()); + m_device = new QOpenGLPaintDevice(window()->size()); +} + +void QEglFSBackingStore::endPaint() +{ + delete m_device; } void QEglFSBackingStore::resize(const QSize &size, const QRegion &staticContents) diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.h b/src/plugins/platforms/eglfs/qeglfsbackingstore.h index 1ae3ecdc61..1eb4d8d79a 100644 --- a/src/plugins/platforms/eglfs/qeglfsbackingstore.h +++ b/src/plugins/platforms/eglfs/qeglfsbackingstore.h @@ -42,25 +42,30 @@ #ifndef QEGLWINDOWSURFACE_H #define QEGLWINDOWSURFACE_H -#include "qeglfsintegration.h" -#include "qeglfswindow.h" - #include QT_BEGIN_NAMESPACE +class QOpenGLContext; +class QOpenGLPaintDevice; + class QEglFSBackingStore : public QPlatformBackingStore { public: QEglFSBackingStore(QWindow *window); - ~QEglFSBackingStore() { delete m_paintDevice; } + ~QEglFSBackingStore(); + + QPaintDevice *paintDevice(); + + void beginPaint(const QRegion &); + void endPaint(); - QPaintDevice *paintDevice() { return m_paintDevice; } void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size, const QRegion &staticContents); private: - QPaintDevice *m_paintDevice; + QOpenGLContext *m_context; + QOpenGLPaintDevice *m_device; }; QT_END_NAMESPACE -- cgit v1.2.3 From 7df980031ba77fc8089700e163db5805faf1d615 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 23 Mar 2012 13:30:40 +0100 Subject: configure: Fix x86_64 arch detection (part 2) This is a follow-up to comit 70a88331519e6e6439ff23a9cc91b2e3f607acb6. The regular expression for CFG_HOST_ARCH was not updated in the above commit. Change-Id: I2baf0b42d851f1df096c2f6ad54aeec57940e661 Reviewed-by: Oswald Buddenhagen Reviewed-by: Girish Ramakrishnan --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index b24787a613..54c80b0ba0 100755 --- a/configure +++ b/configure @@ -3938,7 +3938,7 @@ CFG_ARCH=`"$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config [ -z "$CFG_ARCH" ] && CFG_ARCH="unknown" if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then # Do the same test again, using the host compiler - CFG_HOST_ARCH=`"$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9]*\).*,\1,p'` + CFG_HOST_ARCH=`"$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'` [ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown" else # not cross compiling, host == target -- cgit v1.2.3 From b895dfd641e512dfbeb9b9a141614f5b5d12dbd0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Mar 2012 11:34:17 +0100 Subject: Fix warnings in qtbase. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I981e08872440e35eb9bfad32b20543cfce8439c9 Reviewed-by: Samuel Rødal --- src/gui/kernel/qwindow.cpp | 3 --- src/printsupport/kernel/qprinterinfo_unix.cpp | 2 ++ src/widgets/itemviews/qdirmodel.cpp | 1 - src/widgets/kernel/qwidget.cpp | 1 + 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 18fd72cfa2..b9a3d3ac8c 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -736,9 +736,6 @@ void QWindow::setWindowState(Qt::WindowState state) void QWindow::setTransientParent(QWindow *parent) { Q_D(QWindow); - - QWindow *previousParent = d->transientParent; - d->transientParent = parent; } diff --git a/src/printsupport/kernel/qprinterinfo_unix.cpp b/src/printsupport/kernel/qprinterinfo_unix.cpp index ae0885c0f4..241986d9e8 100644 --- a/src/printsupport/kernel/qprinterinfo_unix.cpp +++ b/src/printsupport/kernel/qprinterinfo_unix.cpp @@ -847,6 +847,8 @@ QList qt_getCupsPrinterPaperSizes(int cupsPrinterIndex) for (int j = 0; j < size->num_choices; ++j) result.append(string2PaperSize(size->choices[j].choice)); } +#else + Q_UNUSED(cupsPrinterIndex) #endif return result; } diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 490c272e39..6ecf3c75aa 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1162,7 +1162,6 @@ QFileInfo QDirModel::fileInfo(const QModelIndex &index) const void QDirModelPrivate::init() { - Q_Q(QDirModel); filters = QDir::AllEntries | QDir::NoDotAndDotDot; sort = QDir::Name; nameFilters << QLatin1String("*"); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 63eb2540ff..9a32d952f9 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -8441,6 +8441,7 @@ void QWidget::mouseReleaseEvent(QMouseEvent *event) void QWidget::mouseDoubleClickEvent(QMouseEvent *event) { + Q_UNUSED(event) } #ifndef QT_NO_WHEELEVENT -- cgit v1.2.3 From 9c6c7038ac7c492ec644f687612d780d3222bc56 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 23 Mar 2012 14:39:08 +0100 Subject: Compile fix for MinGW. Change-Id: Id8099668dd1a4b137b6f9451be8617d07bc9d0c3 Reviewed-by: Friedemann Kleint --- src/plugins/printsupport/windows/qwindowsprintersupport.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/printsupport/windows/qwindowsprintersupport.cpp b/src/plugins/printsupport/windows/qwindowsprintersupport.cpp index c5c60ae5cc..476889890d 100644 --- a/src/plugins/printsupport/windows/qwindowsprintersupport.cpp +++ b/src/plugins/printsupport/windows/qwindowsprintersupport.cpp @@ -59,7 +59,9 @@ QWindowsPrinterSupport::QWindowsPrinterSupport() if (EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, buffer, needed, &needed, &returned)) { PPRINTER_INFO_4 infoList = reinterpret_cast(buffer); QString defaultPrinterName; - QWin32PrintEngine::queryDefaultPrinter(defaultPrinterName, QString(), QString()); + QString program; + QString port; + QWin32PrintEngine::queryDefaultPrinter(defaultPrinterName, program, port); for (uint i = 0; i < returned; ++i) { QString printerName(QString::fromWCharArray(infoList[i].pPrinterName)); -- cgit v1.2.3 From d86e101d1bbee6865aa78f131a072e732e2136ae Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 22 Mar 2012 17:31:57 +0100 Subject: xcb: fix (negative) coordinate handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason, XCB accepts positions as unsigned integers, even though the X protocol explicitly allows negative values (windows overlapping the left/top screen border). After discussion with Samuel and Laszlo, use a reinterpret_cast to convert from the signed representation to the unsigned one. I also extended the clipping of the extents to the position. I guess if X can't handle widths beyond XCOORD_MAX, it won't be happy with x-coordinates exceeding that limit, either. Change-Id: I2fa0e61f823b6cd45dad6471eaa55f38bb3c3e52 Reviewed-by: Samuel Rødal Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbwindow.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 02bfb87d6e..91337adb4e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -396,12 +396,14 @@ void QXcbWindow::setGeometry(const QRect &rect) propagateSizeHints(); const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; - const quint32 values[] = { rect.x(), - rect.y(), - qBound(1, rect.width(), XCOORD_MAX), - qBound(1, rect.height(), XCOORD_MAX) }; + const qint32 values[] = { + qBound(-XCOORD_MAX, rect.x(), XCOORD_MAX), + qBound(-XCOORD_MAX, rect.y(), XCOORD_MAX), + qBound(1, rect.width(), XCOORD_MAX), + qBound(1, rect.height(), XCOORD_MAX), + }; - Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); + Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast(values))); xcb_flush(xcb_connection()); } -- cgit v1.2.3 From 015bc43da010456460dd594d35118ce35d006469 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Thu, 8 Mar 2012 10:18:58 +0100 Subject: API cleanup: remove CoordinateType enum The bridge can do the mapping to and from screen position. This is now done in the windows bridge. Change-Id: I5ca5df0fbeeb58202539f55a0f62717fb1685092 Reviewed-by: Frederik Gladhorn --- src/gui/accessible/qaccessible2.h | 12 ++------ .../accessible/widgets/qaccessiblewidgets.cpp | 17 +++-------- .../accessible/widgets/qaccessiblewidgets.h | 4 +-- src/plugins/accessible/widgets/simplewidgets.cpp | 19 ++++-------- src/plugins/accessible/widgets/simplewidgets.h | 6 ++-- .../platforms/windows/accessible/iaccessible2.cpp | 9 +++--- .../platforms/windows/accessible/iaccessible2.h | 34 ++++++++++++++++++++++ .../other/qaccessibility/tst_qaccessibility.cpp | 9 +++--- 8 files changed, 61 insertions(+), 49 deletions(-) diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h index af7dea5a6a..8497d35e2a 100644 --- a/src/gui/accessible/qaccessible2.h +++ b/src/gui/accessible/qaccessible2.h @@ -56,12 +56,6 @@ class QModelIndex; namespace QAccessible2 { - enum CoordinateType - { - RelativeToScreen = 0, - RelativeToParent = 1 - }; - enum BoundaryType { CharBoundary, WordBoundary, @@ -80,9 +74,9 @@ public: virtual void addSelection(int startOffset, int endOffset) = 0; virtual QString attributes(int offset, int *startOffset, int *endOffset) const = 0; virtual int cursorPosition() const = 0; - virtual QRect characterRect(int offset, QAccessible2::CoordinateType coordType) const = 0; + virtual QRect characterRect(int offset) const = 0; virtual int selectionCount() const = 0; - virtual int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const = 0; + virtual int offsetAtPoint(const QPoint &point) const = 0; virtual void selection(int selectionIndex, int *startOffset, int *endOffset) const = 0; virtual QString text(int startOffset, int endOffset) const = 0; virtual QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType, @@ -249,7 +243,7 @@ public: virtual QString imageDescription() const = 0; virtual QSize imageSize() const = 0; - virtual QRect imagePosition(QAccessible2::CoordinateType coordType) const = 0; + virtual QRect imagePosition() const = 0; }; #endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp index 140848a559..f406cf3236 100644 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp +++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp @@ -272,7 +272,7 @@ int QAccessibleTextEdit::cursorPosition() const return textEdit()->textCursor().position(); } -QRect QAccessibleTextEdit::characterRect(int offset, CoordinateType coordType) const +QRect QAccessibleTextEdit::characterRect(int offset) const { QTextEdit *edit = textEdit(); QTextCursor cursor(edit->document()); @@ -293,14 +293,7 @@ QRect QAccessibleTextEdit::characterRect(int offset, CoordinateType coordType) c r.setWidth(averageCharWidth); } - switch (coordType) { - case RelativeToScreen: - r.moveTo(edit->viewport()->mapToGlobal(r.topLeft())); - break; - case RelativeToParent: - break; - } - + r.moveTo(edit->viewport()->mapToGlobal(r.topLeft())); return r; } @@ -309,13 +302,11 @@ int QAccessibleTextEdit::selectionCount() const return textEdit()->textCursor().hasSelection() ? 1 : 0; } -int QAccessibleTextEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType) const +int QAccessibleTextEdit::offsetAtPoint(const QPoint &point) const { QTextEdit *edit = textEdit(); - QPoint p = point; - if (coordType == RelativeToScreen) - p = edit->viewport()->mapFromGlobal(p); + QPoint p = edit->viewport()->mapFromGlobal(point); // convert to document coordinates p += QPoint(edit->horizontalScrollBar()->value(), edit->verticalScrollBar()->value()); diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h index 147ea91a41..8a4277128d 100644 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.h +++ b/src/plugins/accessible/widgets/qaccessiblewidgets.h @@ -81,9 +81,9 @@ public: void addSelection(int startOffset, int endOffset); QString attributes(int offset, int *startOffset, int *endOffset) const; int cursorPosition() const; - QRect characterRect(int offset, QAccessible2::CoordinateType coordType) const; + QRect characterRect(int offset) const; int selectionCount() const; - int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const; + int offsetAtPoint(const QPoint &point) const; void selection(int selectionIndex, int *startOffset, int *endOffset) const; QString text(int startOffset, int endOffset) const; QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType, diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 39d7e03a1b..4e1fe34b8e 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -490,7 +490,7 @@ QSize QAccessibleDisplay::imageSize() const } /*! \internal */ -QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType) const +QRect QAccessibleDisplay::imagePosition() const { QLabel *label = qobject_cast(widget()); if (!label) @@ -499,14 +499,7 @@ QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType) if (!pixmap) return QRect(); - switch (coordType) { - case QAccessible2::RelativeToScreen: - return QRect(label->mapToGlobal(label->pos()), label->size()); - case QAccessible2::RelativeToParent: - return label->geometry(); - } - - return QRect(); + return QRect(label->mapToGlobal(label->pos()), label->size()); } #ifndef QT_NO_LINEEDIT @@ -613,7 +606,7 @@ int QAccessibleLineEdit::cursorPosition() const return lineEdit()->cursorPosition(); } -QRect QAccessibleLineEdit::characterRect(int /*offset*/, CoordinateType /*coordType*/) const +QRect QAccessibleLineEdit::characterRect(int /*offset*/) const { // QLineEdit doesn't hand out character rects return QRect(); @@ -624,11 +617,9 @@ int QAccessibleLineEdit::selectionCount() const return lineEdit()->hasSelectedText() ? 1 : 0; } -int QAccessibleLineEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType) const +int QAccessibleLineEdit::offsetAtPoint(const QPoint &point) const { - QPoint p = point; - if (coordType == RelativeToScreen) - p = lineEdit()->mapFromGlobal(p); + QPoint p = lineEdit()->mapFromGlobal(point); return lineEdit()->cursorPositionAt(p); } diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h index c228775421..e2847dd2db 100644 --- a/src/plugins/accessible/widgets/simplewidgets.h +++ b/src/plugins/accessible/widgets/simplewidgets.h @@ -110,7 +110,7 @@ public: // QAccessibleImageInterface QString imageDescription() const; QSize imageSize() const; - QRect imagePosition(QAccessible2::CoordinateType coordType) const; + QRect imagePosition() const; }; #ifndef QT_NO_LINEEDIT @@ -129,9 +129,9 @@ public: void addSelection(int startOffset, int endOffset); QString attributes(int offset, int *startOffset, int *endOffset) const; int cursorPosition() const; - QRect characterRect(int offset, QAccessible2::CoordinateType coordType) const; + QRect characterRect(int offset) const; int selectionCount() const; - int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const; + int offsetAtPoint(const QPoint &point) const; void selection(int selectionIndex, int *startOffset, int *endOffset) const; QString text(int startOffset, int endOffset) const; QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType, diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index f22349714f..719169f78f 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -1028,6 +1028,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_caretOffset(long *offset) return E_FAIL; } + HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_characterExtents(long offset, enum IA2CoordinateType coordType, long *x, @@ -1037,9 +1038,8 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_characterExtents(long offse { accessibleDebugClientCalls(accessible); if (QAccessibleTextInterface *text = textInterface()) { - const QRect rect = text->characterRect(offset, (QAccessible2::CoordinateType)coordType); - *x = rect.x(); - *y = rect.y(); + QRect rect = text->characterRect(offset); + mapFromScreenPos(coordType, rect.topLeft(), x, y); *width = rect.width(); *height = rect.height(); return S_OK; @@ -1064,7 +1064,8 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_offsetAtPoint(long x, { accessibleDebugClientCalls(accessible); if (QAccessibleTextInterface *text = textInterface()) { - *offset = text->offsetAtPoint(QPoint(x,y), (QAccessible2::CoordinateType)coordType); + QPoint screenPos = mapToScreenPos(coordType, x, y); + *offset = text->offsetAtPoint(screenPos); return (*offset >=0 ? S_OK : S_FALSE); } return E_FAIL; diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.h b/src/plugins/platforms/windows/accessible/iaccessible2.h index a59263fba1..1af3041a79 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.h +++ b/src/plugins/platforms/windows/accessible/iaccessible2.h @@ -229,6 +229,40 @@ private: return accessible->tableCellInterface(); } + /*! + \internal + \a screenPos is in screen relative position + \a x and \y (out) is in parent relative position if coordType == IA2_COORDTYPE_PARENT_RELATIVE + */ + void mapFromScreenPos(enum IA2CoordinateType coordType, const QPoint &screenPos, long *x, long *y) const { + if (coordType == IA2_COORDTYPE_PARENT_RELATIVE) { + // caller wants relative to parent + if (QAccessibleInterface *parent = accessible->parent()) { + const QRect parentScreenRect = parent->rect(); + *x = parentScreenRect.x() - screenPos.x(); + *y = parentScreenRect.y() - screenPos.y(); + return; + } + } + *x = screenPos.x(); + *y = screenPos.y(); + } + + /*! + \internal + \a x and \y is in parent relative position if coordType == IA2_COORDTYPE_PARENT_RELATIVE + \return a screen relative position + */ + QPoint mapToScreenPos(enum IA2CoordinateType coordType, long x, long y) const { + if (coordType == IA2_COORDTYPE_PARENT_RELATIVE) { + if (QAccessibleInterface *parent = accessible->parent()) { + const QRect parentScreenRect = parent->rect(); + return QPoint(parentScreenRect.x() + x, parentScreenRect.y() + y); + } + } + return QPoint(x,y); + } + HRESULT getRelationsHelper(IAccessibleRelation **relations, int startIndex, long maxRelations, long *nRelations = 0); HRESULT wrapListOfCells(const QList &inputCells, IUnknown ***outputAccessibles, long *nCellCount); uint uniqueID() const; diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index b71594edae..4d46ae43cf 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1527,9 +1527,9 @@ void tst_QAccessibility::textEditTest() QCOMPARE(endOffset, 30); QCOMPARE(iface->textInterface()->characterCount(), 31); QFontMetrics fm(edit.font()); - QCOMPARE(iface->textInterface()->characterRect(0, QAccessible2::RelativeToParent).size(), QSize(fm.width("h"), fm.height())); - QCOMPARE(iface->textInterface()->characterRect(5, QAccessible2::RelativeToParent).size(), QSize(fm.width(" "), fm.height())); - QCOMPARE(iface->textInterface()->characterRect(6, QAccessible2::RelativeToParent).size(), QSize(fm.width("w"), fm.height())); + QCOMPARE(iface->textInterface()->characterRect(0).size(), QSize(fm.width("h"), fm.height())); + QCOMPARE(iface->textInterface()->characterRect(5).size(), QSize(fm.width(" "), fm.height())); + QCOMPARE(iface->textInterface()->characterRect(6).size(), QSize(fm.width("w"), fm.height())); iface->editableTextInterface()->copyText(6, 11); QCOMPARE(QApplication::clipboard()->text(), QLatin1String("world")); @@ -2760,7 +2760,8 @@ void tst_QAccessibility::labelTest() QCOMPARE(imageInterface->imageSize(), testPixmap.size()); QCOMPARE(imageInterface->imageDescription(), QString::fromLatin1("Test Description")); - QCOMPARE(imageInterface->imagePosition(QAccessible2::RelativeToParent), imageLabel.geometry()); + const QPoint labelPos = imageLabel.mapToGlobal(QPoint(0,0)); + QCOMPARE(imageInterface->imagePosition().topLeft(), labelPos); delete acc_label; -- cgit v1.2.3 From 5e9089135bfe7db7d7a43c9ee4d4c24ab8f6458d Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Fri, 23 Mar 2012 11:11:53 +0100 Subject: Enable IAccessible for MinGW32, keep IAccessible2 disabled for MinGW No surprise, the files generated by midl contains code that only the MS compiler will understand. However, since the generated files are only needed for IA2, we can still compile the old IAccessible/MSAA implementation for mingw (like it was before the introduction of IA2) I used mingw 4.6.1 to test this. Change-Id: Iad581f2fee087bd7b796ac5a01548f2fcacbd595 Reviewed-by: Friedemann Kleint --- .../platforms/windows/accessible/accessible.pri | 25 ++--- .../platforms/windows/accessible/iaccessible2.cpp | 114 +++++++++------------ .../platforms/windows/accessible/iaccessible2.h | 7 +- .../windows/accessible/qwindowsaccessibility.cpp | 14 ++- .../windows/accessible/qwindowsmsaaaccessible.cpp | 58 +++++++++++ .../windows/accessible/qwindowsmsaaaccessible.h | 29 +++++- 6 files changed, 154 insertions(+), 93 deletions(-) diff --git a/src/plugins/platforms/windows/accessible/accessible.pri b/src/plugins/platforms/windows/accessible/accessible.pri index 1671c67d17..3069c2dda3 100644 --- a/src/plugins/platforms/windows/accessible/accessible.pri +++ b/src/plugins/platforms/windows/accessible/accessible.pri @@ -1,19 +1,16 @@ SOURCES += \ - $$PWD/qwindowsaccessibility.cpp + $$PWD/qwindowsmsaaaccessible.cpp \ + $$PWD/qwindowsaccessibility.cpp \ + $$PWD/comutils.cpp HEADERS += \ - $$PWD/qwindowsaccessibility.h - -!*g++* { - SOURCES += \ - $$PWD/qwindowsmsaaaccessible.cpp \ - $$PWD/iaccessible2.cpp \ - $$PWD/comutils.cpp - - HEADERS += \ - $$PWD/qwindowsmsaaaccessible.h \ - $$PWD/iaccessible2.h \ - $$PWD/comutils.h + $$PWD/qwindowsmsaaaccessible.h \ + $$PWD/qwindowsaccessibility.h \ + $$PWD/comutils.h +!*g++: { + SOURCES += $$PWD/iaccessible2.cpp + HEADERS += $$PWD/iaccessible2.h include(../../../../3rdparty/iaccessible2/iaccessible2.pri) -} # !g++ +} + diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index 719169f78f..c3d5c543cf 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -167,81 +167,62 @@ HRESULT STDMETHODCALLTYPE AccessibleRelation::get_targets( **************************************************************/ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryInterface(REFIID id, LPVOID *iface) { - *iface = 0; - - QByteArray strIID = IIDToString(id); - if (!strIID.isEmpty()) { - QString ss; QDebug dbg(&ss); dbg << accessible; - accessibleDebug("QWindowsIA2Accessible::QI() - IID:%s, iface:%s ", strIID.constData(), qPrintable(ss)); - } - if (id == IID_IUnknown) { - *iface = (IUnknown*)(IDispatch*)this; - } else if (id == IID_IDispatch) { - *iface = (IDispatch*)this; - } else if (id == IID_IAccessible) { - *iface = (IAccessible*)this; - } else if (id == IID_IOleWindow) { - *iface = (IOleWindow*)this; - } else if (id == IID_IServiceProvider) { - *iface = (IServiceProvider*)this; - } else if (id == IID_IAccessible2) { - *iface = (IAccessible2*)this; - } else if (id == IID_IAccessibleAction) { - if (accessible->actionInterface()) - *iface = (IAccessibleAction*)this; - } else if (id == IID_IAccessibleComponent) { - *iface = (IAccessibleComponent*)this; - } else if (id == IID_IAccessibleEditableText) { - //if (accessible->editableTextInterface()) { - //*iface = (IAccessibleEditableText*)this; - //} - } else if (id == IID_IAccessibleHyperlink) { - //*iface = (IAccessibleHyperlink*)this; - } else if (id == IID_IAccessibleHypertext) { - //*iface = (IAccessibleHypertext*)this; - } else if (id == IID_IAccessibleImage) { - //*iface = (IAccessibleImage*)this; - } else if (id == IID_IAccessibleRelation) { - *iface = (IAccessibleRelation*)this; - } else if (id == IID_IAccessibleTable) { - //*iface = (IAccessibleTable*)this; // not supported - } else if (id == IID_IAccessibleTable2) { - if (accessible->tableInterface()) - *iface = (IAccessibleTable2*)this; - } else if (id == IID_IAccessibleTableCell) { - if (accessible->tableCellInterface()) - *iface = (IAccessibleTableCell*)this; - } else if (id == IID_IAccessibleText) { - if (accessible->textInterface()) - *iface = (IAccessibleText*)this; - } else if (id == IID_IAccessibleValue) { - if (accessible->valueInterface()) - *iface = (IAccessibleValue*)this; - } - if (*iface) { - AddRef(); - return S_OK; + HRESULT hr = QWindowsMsaaAccessible::QueryInterface(id, iface); + if (!SUCCEEDED(hr)) { + if (id == IID_IAccessible2) { + *iface = (IAccessible2*)this; + } else if (id == IID_IAccessibleAction) { + if (accessible->actionInterface()) + *iface = (IAccessibleAction*)this; + } else if (id == IID_IAccessibleComponent) { + *iface = (IAccessibleComponent*)this; + } else if (id == IID_IAccessibleEditableText) { + //if (accessible->editableTextInterface()) { + //*iface = (IAccessibleEditableText*)this; + //} + } else if (id == IID_IAccessibleHyperlink) { + //*iface = (IAccessibleHyperlink*)this; + } else if (id == IID_IAccessibleHypertext) { + //*iface = (IAccessibleHypertext*)this; + } else if (id == IID_IAccessibleImage) { + //*iface = (IAccessibleImage*)this; + } else if (id == IID_IAccessibleRelation) { + *iface = (IAccessibleRelation*)this; + } else if (id == IID_IAccessibleTable) { + //*iface = (IAccessibleTable*)this; // not supported + } else if (id == IID_IAccessibleTable2) { + if (accessible->tableInterface()) + *iface = (IAccessibleTable2*)this; + } else if (id == IID_IAccessibleTableCell) { + if (accessible->tableCellInterface()) + *iface = (IAccessibleTableCell*)this; + } else if (id == IID_IAccessibleText) { + if (accessible->textInterface()) + *iface = (IAccessibleText*)this; + } else if (id == IID_IAccessibleValue) { + if (accessible->valueInterface()) + *iface = (IAccessibleValue*)this; + } + if (*iface) { + AddRef(); + hr = S_OK; + } else { + hr = E_NOINTERFACE; + } } - - return E_NOINTERFACE; + return hr; } ULONG STDMETHODCALLTYPE QWindowsIA2Accessible::AddRef() { - return ++ref; + return QWindowsMsaaAccessible::AddRef(); } ULONG STDMETHODCALLTYPE QWindowsIA2Accessible::Release() { - if (!--ref) { - delete this; - return 0; - } - return ref; + return QWindowsMsaaAccessible::Release(); } - - /**************************************************************\ * * * IAccessible2 * @@ -1430,6 +1411,10 @@ uint QWindowsIA2Accessible::uniqueID() const QByteArray QWindowsIA2Accessible::IIDToString(REFIID id) { + QByteArray strGuid = QWindowsMsaaAccessible::IIDToString(id); + if (!strGuid.isEmpty()) + return strGuid; + IF_EQUAL_RETURN_IIDSTRING(id, IID_IUnknown); IF_EQUAL_RETURN_IIDSTRING(id, IID_IDispatch); IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessible); @@ -1451,7 +1436,6 @@ QByteArray QWindowsIA2Accessible::IIDToString(REFIID id) IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessibleValue); // else... - QByteArray strGuid; #if 0 // Can be useful for debugging, but normally we'd like to reduce the noise a bit... OLECHAR szGuid[39]={0}; ::StringFromGUID2(id, szGuid, 39); diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.h b/src/plugins/platforms/windows/accessible/iaccessible2.h index 1af3041a79..9b8a1ad3a6 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.h +++ b/src/plugins/platforms/windows/accessible/iaccessible2.h @@ -66,9 +66,7 @@ #include "AccessibleRole.h" #include "AccessibleStates.h" -#ifdef Q_CC_MINGW -# include -#endif +#include QT_BEGIN_NAMESPACE @@ -268,9 +266,6 @@ private: uint uniqueID() const; QByteArray IIDToString(REFIID id); -private: - ULONG ref; - }; /**************************************************************\ diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index 4f92b910b2..bd928399c8 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -56,11 +56,11 @@ #include #include "qwindowsaccessibility.h" - -#ifndef Q_CC_MINGW -# include "iaccessible2.h" -#endif // !Q_CC_MINGW - +#ifdef Q_CC_MINGW +# include "qwindowsmsaaaccessible.h" +#else +# include "iaccessible2.h" +#endif #include "comutils.h" #include @@ -237,7 +237,11 @@ IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc) #else if (!acc) return 0; +#ifdef Q_CC_MINGW + QWindowsMsaaAccessible *wacc = new QWindowsMsaaAccessible(acc); +#else QWindowsIA2Accessible *wacc = new QWindowsIA2Accessible(acc); +#endif IAccessible *iacc = 0; wacc->QueryInterface(IID_IAccessible, (void**)&iacc); return iacc; diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 8791bbdcfb..6c4d217cb4 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -224,6 +224,53 @@ void accessibleDebugClientCalls_helper(const char* funcName, const QAccessibleIn } #endif +/**************************************************************\ + * * + * IUnknown * + * * + **************************************************************/ +HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::QueryInterface(REFIID id, LPVOID *iface) +{ + *iface = 0; + + QByteArray strIID = IIDToString(id); + if (!strIID.isEmpty()) { + QString ss; QDebug dbg(&ss); dbg << accessible; + accessibleDebug("QWindowsIA2Accessible::QI() - IID:%s, iface:%s ", strIID.constData(), qPrintable(ss)); + } + if (id == IID_IUnknown) { + *iface = (IUnknown*)(IDispatch*)this; + } else if (id == IID_IDispatch) { + *iface = (IDispatch*)this; + } else if (id == IID_IAccessible) { + *iface = (IAccessible*)this; + } else if (id == IID_IOleWindow) { + *iface = (IOleWindow*)this; + } + + if (*iface) { + AddRef(); + return S_OK; + } + + return E_NOINTERFACE; +} + +ULONG STDMETHODCALLTYPE QWindowsMsaaAccessible::AddRef() +{ + return ++ref; +} + +ULONG STDMETHODCALLTYPE QWindowsMsaaAccessible::Release() +{ + if (!--ref) { + delete this; + return 0; + } + return ref; +} + + /* IDispatch */ @@ -1208,6 +1255,17 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::ContextSensitiveHelp(BOOL) return S_OK; } +#define IF_EQUAL_RETURN_IIDSTRING(id, iid) if (id == iid) return QByteArray(#iid) +QByteArray QWindowsMsaaAccessible::IIDToString(REFIID id) +{ + IF_EQUAL_RETURN_IIDSTRING(id, IID_IUnknown); + IF_EQUAL_RETURN_IIDSTRING(id, IID_IDispatch); + IF_EQUAL_RETURN_IIDSTRING(id, IID_IAccessible); + IF_EQUAL_RETURN_IIDSTRING(id, IID_IOleWindow); + + return QByteArray(); +} + QT_END_NAMESPACE #endif //QT_NO_ACCESSIBILITY diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h index 9cb56c954c..d7dda6b3e2 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h @@ -43,12 +43,19 @@ #include #ifndef QT_NO_ACCESSIBILITY +#include #include "../qtwindows_additional.h" -#include -#include "Accessible2.h" #include #include +#ifndef Q_CC_MINGW +# include +# include "Accessible2.h" // IAccessible2 inherits from IAccessible +#else + // MinGW +# include +# include +#endif QT_BEGIN_NAMESPACE @@ -74,7 +81,13 @@ QWindow *window_helper(const QAccessibleInterface *iface); /**************************************************************\ * QWindowsAccessible * **************************************************************/ -class QWindowsMsaaAccessible : public IAccessible2, public IOleWindow +class QWindowsMsaaAccessible : public +#ifdef Q_CC_MINGW + IAccessible +#else + IAccessible2 +#endif + , public IOleWindow { public: QWindowsMsaaAccessible(QAccessibleInterface *a) @@ -87,6 +100,10 @@ public: delete accessible; } + /* IUnknown */ + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID *); + ULONG STDMETHODCALLTYPE AddRef(); + ULONG STDMETHODCALLTYPE Release(); /* IDispatch */ HRESULT STDMETHODCALLTYPE GetTypeInfoCount(unsigned int *); @@ -124,12 +141,18 @@ public: HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode); protected: + virtual QByteArray IIDToString(REFIID id); + QAccessibleInterface *accessible; QAIPointer childPointer(VARIANT varID) { return QAIPointer(accessible->child(varID.lVal - 1)); } + +private: + ULONG ref; + }; QT_END_NAMESPACE -- cgit v1.2.3 From 7efda762dabb7bc8dd8aa7744d9933f22d070555 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 22 Mar 2012 15:01:50 +0100 Subject: Fix loading of the ICU dynamic libraries on Windows. - Account for differing library name on Windows. - Improve error messages. Acked-by: John Layt Change-Id: Ib567f8c79ab4b5655cdb2fe050f91013e9305263 Reviewed-by: Friedemann Kleint Reviewed-by: Denis Dzyubenko --- src/corelib/tools/qlocale_icu.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qlocale_icu.cpp b/src/corelib/tools/qlocale_icu.cpp index ee2e5f436a..b3b8836f11 100644 --- a/src/corelib/tools/qlocale_icu.cpp +++ b/src/corelib/tools/qlocale_icu.cpp @@ -81,9 +81,19 @@ bool qt_initIcu(const QString &localeString) if (status == NotLoaded) { // resolve libicui18n - QLibrary lib(QLatin1String("icui18n"), QLatin1String(U_ICU_VERSION_SHORT)); + const QString version = QString::fromLatin1(U_ICU_VERSION_SHORT); +#ifdef Q_OS_WIN + // QLibrary on Windows does not use the version number, the libraries + // are named "icuin.dll", though. + QString libName = QStringLiteral("icuin") + version; +#else + QString libName = QStringLiteral("icui18n"); +#endif + QLibrary lib(libName, version); if (!lib.load()) { - qWarning() << "Unable to load library icui18n" << lib.errorString(); + qWarning("Unable to load library '%s' version %s: %s", + qPrintable(libName), qPrintable(version), + qPrintable(lib.errorString())); status = ErrorLoading; return false; } @@ -104,15 +114,22 @@ bool qt_initIcu(const QString &localeString) ptr_ucol_close = 0; ptr_ucol_strcoll = 0; - qWarning("Unable to find symbols in icui18n"); + qWarning("Unable to find symbols in '%s'.", qPrintable(libName)); status = ErrorLoading; return false; } // resolve libicuuc - QLibrary ucLib(QLatin1String("icuuc"), QLatin1String(U_ICU_VERSION_SHORT)); +#ifdef Q_OS_WIN + libName = QStringLiteral("icuuc") + version; +#else + libName = QStringLiteral("icuuc"); +#endif + QLibrary ucLib(libName, version); if (!ucLib.load()) { - qWarning() << "Unable to load library icuuc" << ucLib.errorString(); + qWarning("Unable to load library '%s' version %s: %s", + qPrintable(libName), qPrintable(version), + qPrintable(ucLib.errorString())); status = ErrorLoading; return false; } @@ -129,7 +146,7 @@ bool qt_initIcu(const QString &localeString) ptr_u_strToUpper = 0; ptr_u_strToLower = 0; - qWarning("Unable to find symbols in icuuc"); + qWarning("Unable to find symbols in '%s'", qPrintable(libName)); status = ErrorLoading; return false; } -- cgit v1.2.3 From 94cc945aa806aaf12e11ee047b9d749047032588 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 1 Mar 2012 17:18:17 +0100 Subject: Fix deprecation warning about QPlatformWindow::visible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The proper getter name of a boolean property is prefixed with is-. Change-Id: Id1fae9ccd11db3e92903c51012bbe75d52726a5a Reviewed-by: Samuel Rødal --- src/gui/kernel/qplatformwindow_qpa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp index e12228d7bd..973c641ad1 100644 --- a/src/gui/kernel/qplatformwindow_qpa.cpp +++ b/src/gui/kernel/qplatformwindow_qpa.cpp @@ -168,7 +168,7 @@ Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags) bool QPlatformWindow::isExposed() const { Q_D(const QPlatformWindow); - return d->window->visible(); + return d->window->isVisible(); } /*! -- cgit v1.2.3 From a8d4e6d04ed33dd777632f01a0ba548e7ab6137c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 27 Dec 2011 12:30:20 -0200 Subject: Fix building the XCB platform plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dlxxx functions are in libdl and the xcb_shm functions are in libxcb-shm. Change-Id: I412e1df4dc2939b7dac4f6b244c46e23c79da630 Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/xcb.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index d220766be0..0f059341e4 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -91,10 +91,11 @@ contains(DEFINES, XCB_USE_DRI2) { DEFINES += XCB_USE_GLX HEADERS += qglxintegration.h SOURCES += qglxintegration.cpp + LIBS += $$QMAKE_LIBS_DYNLOAD } } -LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shape +LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shape -lxcb-shm DEFINES += $$QMAKE_DEFINES_XCB LIBS += $$QMAKE_LIBS_XCB -- cgit v1.2.3 From ce9d760d59c3cd0c5de0325366f50cd1ec7cc5a0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 30 Dec 2011 14:54:11 -0200 Subject: Fix warnings about commas at the end of enums It's non-standard to accept them, so remove them and silence the warnings. Change-Id: I51c5afe99eac408f326ab9fcf40435b60e953b54 Reviewed-by: Stephen Kelly --- src/gui/painting/qblittable_p.h | 2 +- src/gui/painting/qcosmeticstroker_p.h | 2 +- src/gui/text/qtextengine_p.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h index 0d2f6983d4..c36de8fa08 100644 --- a/src/gui/painting/qblittable_p.h +++ b/src/gui/painting/qblittable_p.h @@ -64,7 +64,7 @@ public: SourceOverScaledPixmapCapability = 0x0008, // Internal ones - OutlineCapability = 0x0001000, + OutlineCapability = 0x0001000 }; Q_DECLARE_FLAGS (Capabilities, Capability); diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index 86e811c5f6..7a1221c1a7 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -72,7 +72,7 @@ public: enum Caps { NoCaps = 0, CapBegin = 0x1, - CapEnd = 0x2, + CapEnd = 0x2 }; // used to avoid drop outs or duplicated points diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 03581eb6a2..aac2390943 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -425,7 +425,7 @@ public: enum LayoutState { LayoutEmpty, InLayout, - LayoutFailed, + LayoutFailed }; struct Q_GUI_EXPORT LayoutData { LayoutData(const QString &str, void **stack_memory, int mem_size); -- cgit v1.2.3 From 1ba5796d0903afed48f2ca179e75786c1786c707 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 11 Nov 2011 00:18:40 -0200 Subject: Silence warnings about GCC #pragma in ICC Change-Id: I7659ce312f3777ae68190979681656d12306d33c Reviewed-by: Bradley T. Hughes --- src/corelib/thread/qatomic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index 94cef790db..a8e321b46a 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -51,7 +51,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && !defined(Q_CC_INTEL) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wextra" #endif @@ -157,7 +157,7 @@ public: #endif }; -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && !defined(Q_CC_INTEL) # pragma GCC diagnostic pop #endif -- cgit v1.2.3 From acc97163316133f88dc06f39239776b025dbe34e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 24 Jan 2012 13:49:26 -0200 Subject: Add the missing 'itt eq' instructions to the ARM atomics. This affected the 16- and 64-bit sizes only. Must have been a C&P failure. Change-Id: If7b1e534a61d812226a6e4970909b53b0cc5a9a6 Reviewed-by: Bradley T. Hughes --- src/corelib/arch/qatomic_armv6.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h index 41f145ad0d..b290a6a008 100644 --- a/src/corelib/arch/qatomic_armv6.h +++ b/src/corelib/arch/qatomic_armv6.h @@ -387,6 +387,7 @@ bool QBasicAtomicOps<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa asm volatile("0:\n" "ldrexh %[result], [%[_q_value]]\n" "eors %[result], %[result], %[expectedValue]\n" + "itt eq\n" "strexheq %[result], %[newValue], [%[_q_value]]\n" "teqeq %[result], #1\n" "beq 0b\n" @@ -497,6 +498,7 @@ bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa "eor %[result], %[result], %[expectedValue]\n" "eor %H[result], %H[result], %H[expectedValue]\n" "orrs %[result], %[result], %H[result]\n" + "itt eq\n" "strexdeq %[result], %[newValue], %H[newValue], [%[_q_value]]\n" "teqeq %[result], #1\n" "beq 0b\n" -- cgit v1.2.3 From 14cae3a705219e53ceaf8e2304b0d1e83bad1d20 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 27 Feb 2012 15:02:00 +0100 Subject: Remove support for Mac OS X compilers without the -Xarch flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was necessary in order to support Universal builds when this flag wasn't present. This flag can be considered present in all builds now. What's more, Apple doesn't support PowerPC builds anymore anyway, so we won't either. Change-Id: I79c45a450ddf7d58cd4b7da03d6bbf7d3feb0d9a Reviewed-by: Morten Johan Sørvig --- src/corelib/tools/qsimd_p.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 44428b7284..b53df00b65 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -44,24 +44,8 @@ #include - QT_BEGIN_HEADER - -#if defined(QT_NO_MAC_XARCH) || (defined(Q_OS_DARWIN) && (defined(__ppc__) || defined(__ppc64__))) -// Disable MMX and SSE on Mac/PPC builds, or if the compiler -// does not support -Xarch argument passing -#undef QT_HAVE_SSE -#undef QT_HAVE_SSE2 -#undef QT_HAVE_SSE3 -#undef QT_HAVE_SSSE3 -#undef QT_HAVE_SSE4_1 -#undef QT_HAVE_SSE4_2 -#undef QT_HAVE_AVX -#undef QT_HAVE_3DNOW -#undef QT_HAVE_MMX -#endif - #ifdef __MINGW64_VERSION_MAJOR #include #endif -- cgit v1.2.3 From b8625fd70e4ff194a52d52144bf77aff05b9b093 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Feb 2012 14:56:22 +0100 Subject: Update the header list for the QtDBus module qdbusintrospection_p.h was missing from the header list. And this module has the public headers in a separate variable. Change-Id: I9fd85a2930af71d081b7cabd04eb29d94c285382 Reviewed-by: Stephen Kelly --- src/dbus/dbus.pro | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index 6fd48de48d..100736252e 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -51,7 +51,9 @@ PUB_HEADERS = qdbusargument.h \ qdbuspendingcall.h \ qdbuspendingreply.h \ qdbuscontext.h \ - qdbusvirtualobject.h + qdbusvirtualobject.h \ + qdbusservicewatcher.h \ + qdbusunixfiledescriptor.h HEADERS += $$PUB_HEADERS \ qdbusconnection_p.h \ qdbusmessage_p.h \ @@ -66,8 +68,7 @@ HEADERS += $$PUB_HEADERS \ qdbusintegrator_p.h \ qdbuspendingcall_p.h \ qdbus_symbols_p.h \ - qdbusservicewatcher.h \ - qdbusunixfiledescriptor.h + qdbusintrospection_p.h SOURCES += qdbusconnection.cpp \ qdbusconnectioninterface.cpp \ qdbuserror.cpp \ -- cgit v1.2.3 From f49f94434e082657f2227292c15cad20493f112c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 30 Dec 2011 14:54:43 -0200 Subject: Silence a warning about a change of sign. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GLuint is, like the name says, unsigned. To store -1 in it, a change of sign happens. Silence the warning by casting the -1 to GLuint first. Change-Id: I165a32c486358a60f7c5fd0c439204ed2f9f7f16 Reviewed-by: Samuel Rødal --- src/gui/opengl/qopenglpaintengine_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h index 1b3dfbae28..8b49ec250f 100644 --- a/src/gui/opengl/qopenglpaintengine_p.h +++ b/src/gui/opengl/qopenglpaintengine_p.h @@ -199,7 +199,7 @@ public: void updateBrushUniforms(); void updateMatrix(); void updateCompositionMode(); - void updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id = -1); + void updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id = GLuint(-1)); void resetGLState(); -- cgit v1.2.3 From f195a8e2b69eba0e3c44f2dece222b0da9e06026 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 13 Feb 2012 14:05:51 +0100 Subject: Added QAccessibleGroupBox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a new accessible interface for QGroupBox, as QAccessibleDisplay is not good enough when the QGroupBox is checkable. AccessibleFactory was modified to return a QAccessibleGroupBox when the accessible interface of a QGroupBox is requested. Created tst_QAccessibility::groupBoxTest Port to Qt5 of the patch by José Millán Soto Change-Id: I6c23dcf5562b3ea269b04102e78463b65827188a Reviewed-by: Jan-Arve Sæther (cherry picked from commit c03ceb203c65d9e3485fad848bfc0c4b6ee3e9aa) --- src/plugins/accessible/widgets/main.cpp | 4 +- src/plugins/accessible/widgets/simplewidgets.cpp | 94 +++++++++++++++++++--- src/plugins/accessible/widgets/simplewidgets.h | 23 ++++++ src/widgets/widgets/qgroupbox.cpp | 6 ++ .../other/qaccessibility/tst_qaccessibility.cpp | 67 +++++++++++++++ 5 files changed, 180 insertions(+), 14 deletions(-) diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp index ca8bf816b6..4709069d39 100644 --- a/src/plugins/accessible/widgets/main.cpp +++ b/src/plugins/accessible/widgets/main.cpp @@ -236,8 +236,10 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec #endif } else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) { iface = new QAccessibleDisplay(widget); +#ifndef QT_NO_GROUPBOX } else if (classname == QLatin1String("QGroupBox")) { - iface = new QAccessibleDisplay(widget, QAccessible::Grouping); + iface = new QAccessibleGroupBox(widget); +#endif } else if (classname == QLatin1String("QStatusBar")) { iface = new QAccessibleWidget(widget, QAccessible::StatusBar); #ifndef QT_NO_PROGRESSBAR diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 4e1fe34b8e..af0c211cca 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -399,10 +399,6 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const if (str.isEmpty()) { if (qobject_cast(object())) { str = qobject_cast(object())->text(); -#ifndef QT_NO_GROUPBOX - } else if (qobject_cast(object())) { - str = qobject_cast(object())->title(); -#endif #ifndef QT_NO_LCDNUMBER } else if (qobject_cast(object())) { QLCDNumber *l = qobject_cast(object()); @@ -439,15 +435,6 @@ QAccessibleDisplay::relations(QAccessible::Relation match /*= QAccessible::AllRe #ifndef QT_NO_SHORTCUT if (QLabel *label = qobject_cast(object())) { relatedObjects.append(label->buddy()); -#endif -#ifndef QT_NO_GROUPBOX - } else if (QGroupBox *groupbox = qobject_cast(object())) { - if (!groupbox->title().isEmpty()) { - const QList kids = childWidgets(widget()); - for (int i = 0; i < kids.count(); ++i) { - relatedObjects.append(kids.at(i)); - } - } #endif } for (int i = 0; i < relatedObjects.count(); ++i) { @@ -502,6 +489,87 @@ QRect QAccessibleDisplay::imagePosition() const return QRect(label->mapToGlobal(label->pos()), label->size()); } +#ifndef QT_NO_GROUPBOX +QAccessibleGroupBox::QAccessibleGroupBox(QWidget *w) +: QAccessibleWidget(w) +{ +} + +QGroupBox* QAccessibleGroupBox::groupBox() const +{ + return static_cast(widget()); +} + +QString QAccessibleGroupBox::text(QAccessible::Text t) const +{ + QString txt = QAccessibleWidget::text(t); + + if (txt.isEmpty()) { + switch (t) { + case QAccessible::Name: + txt = qt_accStripAmp(groupBox()->title()); + case QAccessible::Description: + txt = qt_accStripAmp(groupBox()->title()); + default: + break; + } + } + + return txt; +} + +QAccessible::State QAccessibleGroupBox::state() const +{ + QAccessible::State st = QAccessibleWidget::state(); + st.checkable = groupBox()->isCheckable(); + st.checked = groupBox()->isChecked(); + return st; +} + +QAccessible::Role QAccessibleGroupBox::role() const +{ + return groupBox()->isCheckable() ? QAccessible::CheckBox : QAccessible::Grouping; +} + +QVector > +QAccessibleGroupBox::relations(QAccessible::Relation match /*= QAccessible::AllRelations*/) const +{ + QVector > rels = QAccessibleWidget::relations(match); + + if ((match & QAccessible::Labelled) && (!groupBox()->title().isEmpty())) { + const QList kids = childWidgets(widget()); + for (int i = 0; i < kids.count(); ++i) { + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(kids.at(i)); + if (iface) + rels.append(qMakePair(iface, QAccessible::Relation(QAccessible::Labelled))); + } + } + return rels; +} + +QStringList QAccessibleGroupBox::actionNames() const +{ + QStringList actions = QAccessibleWidget::actionNames(); + + if (groupBox()->isCheckable()) { + actions.prepend(QAccessibleActionInterface::checkAction()); + } + return actions; +} + +void QAccessibleGroupBox::doAction(const QString &actionName) +{ + if (actionName == QAccessibleActionInterface::checkAction()) + groupBox()->setChecked(!groupBox()->isChecked()); +} + +QStringList QAccessibleGroupBox::keyBindingsForAction(const QString &) const +{ + return QStringList(); +} + +#endif + #ifndef QT_NO_LINEEDIT /*! \class QAccessibleLineEdit diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h index e2847dd2db..74c1da405d 100644 --- a/src/plugins/accessible/widgets/simplewidgets.h +++ b/src/plugins/accessible/widgets/simplewidgets.h @@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE class QAbstractButton; class QLineEdit; class QToolButton; +class QGroupBox; class QProgressBar; class QAccessibleButton : public QAccessibleWidget @@ -113,6 +114,28 @@ public: QRect imagePosition() const; }; +#ifndef QT_NO_GROUPBOX +class QAccessibleGroupBox : public QAccessibleWidget +{ +public: + explicit QAccessibleGroupBox(QWidget *w); + + QAccessible::State state() const; + QAccessible::Role role() const; + QString text(QAccessible::Text t) const; + + QVector >relations(QAccessible::Relation match = QAccessible::AllRelations) const; + + //QAccessibleActionInterface + QStringList actionNames() const; + void doAction(const QString &actionName); + QStringList keyBindingsForAction(const QString &) const; + +private: + QGroupBox *groupBox() const; +}; +#endif + #ifndef QT_NO_LINEEDIT class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInterface, public QAccessibleSimpleEditableTextInterface diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index e9edea286f..d8ad04cd84 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -643,6 +643,12 @@ void QGroupBox::setChecked(bool b) update(); d->checked = b; d->_q_setChildrenEnabled(b); +#ifndef QT_NO_ACCESSIBILITY + QAccessible::State st; + st.checked = true; + QAccessibleStateChangeEvent *ev = new QAccessibleStateChangeEvent(this, st); + QAccessible::updateAccessibility(ev); +#endif emit toggled(b); } } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 4d46ae43cf..be7cb7dd15 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -252,6 +252,7 @@ private slots: void mdiAreaTest(); void mdiSubWindowTest(); void lineEditTest(); + void groupBoxTest(); void workspaceTest(); void dialogButtonBoxTest(); void dialTest(); @@ -1894,6 +1895,72 @@ void tst_QAccessibility::lineEditTest() QTestAccessibility::clearEvents(); } +void tst_QAccessibility::groupBoxTest() +{ + { + QGroupBox *groupBox = new QGroupBox(); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupBox); + + groupBox->setTitle(QLatin1String("Test QGroupBox")); + + QAccessibleEvent ev(groupBox, QAccessible::NameChanged); + QVERIFY_EVENT(&ev); + + groupBox->setToolTip(QLatin1String("This group box will be used to test accessibility")); + QVBoxLayout *layout = new QVBoxLayout(); + QRadioButton *rbutton = new QRadioButton(); + layout->addWidget(rbutton); + groupBox->setLayout(layout); + QAccessibleInterface *rButtonIface = QAccessible::queryAccessibleInterface(rbutton); + + QCOMPARE(iface->childCount(), 1); + QCOMPARE(iface->role(), QAccessible::Grouping); + QCOMPARE(iface->text(QAccessible::Name), QLatin1String("Test QGroupBox")); + QCOMPARE(iface->text(QAccessible::Description), QLatin1String("This group box will be used to test accessibility")); + QVector > relations = rButtonIface->relations(); + QVERIFY(relations.size() == 1); + QPair relation = relations.first(); + QCOMPARE(relation.first->object(), groupBox); + QCOMPARE(relation.second, QAccessible::Label); + + delete relation.first; + + delete rButtonIface; + delete iface; + delete groupBox; + } + + { + QGroupBox *groupBox = new QGroupBox(); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupBox); + QVERIFY(!iface->state().checkable); + groupBox->setCheckable(true); + + groupBox->setChecked(false); + QAccessible::State st; + st.checked = true; + QAccessibleStateChangeEvent ev(groupBox, st); + QVERIFY_EVENT(&ev); + + QCOMPARE(iface->role(), QAccessible::CheckBox); + QAccessibleActionInterface *actionIface = iface->actionInterface(); + QVERIFY(actionIface); + QAccessible::State state = iface->state(); + QVERIFY(state.checkable); + QVERIFY(!state.checked); + QVERIFY(actionIface->actionNames().contains(QAccessibleActionInterface::checkAction())); + actionIface->doAction(QAccessibleActionInterface::checkAction()); + QVERIFY(groupBox->isChecked()); + state = iface->state(); + QVERIFY(state.checked); + QAccessibleStateChangeEvent ev2(groupBox, st); + QVERIFY_EVENT(&ev2); + + delete iface; + delete groupBox; + } +} + void tst_QAccessibility::workspaceTest() { { -- cgit v1.2.3 From cea1a6bcd51a43bad6426e4de81fda117f094932 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 13 Mar 2012 20:25:12 +0100 Subject: Make sure windows send accessibility activated updates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both QWindow and QWidgetWindow should update with the active state signal. Change-Id: I0219f803aa0fb109765f0faa0aedb120c2a439f0 Reviewed-by: Jan-Arve Sæther --- src/gui/kernel/qwindow.cpp | 21 ++++++++-- src/widgets/accessible/qaccessiblewidget.cpp | 2 + src/widgets/kernel/qwidgetwindow_qpa.cpp | 10 ++++- .../other/qaccessibility/tst_qaccessibility.cpp | 48 ++++++++++++++++++++-- 4 files changed, 71 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b9a3d3ac8c..7248a990d7 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -52,6 +52,7 @@ #include "qwindow_p.h" #include "qguiapplication_p.h" +#include "qaccessible.h" #include @@ -1427,13 +1428,25 @@ bool QWindow::event(QEvent *ev) keyReleaseEvent(static_cast(ev)); break; - case QEvent::FocusIn: + case QEvent::FocusIn: { focusInEvent(static_cast(ev)); - break; +#ifndef QT_NO_ACCESSIBILITY + QAccessible::State state; + state.active = true; + QAccessibleStateChangeEvent event(this, state); + QAccessible::updateAccessibility(&event); +#endif + break; } - case QEvent::FocusOut: + case QEvent::FocusOut: { focusOutEvent(static_cast(ev)); - break; +#ifndef QT_NO_ACCESSIBILITY + QAccessible::State state; + state.active = true; + QAccessibleStateChangeEvent event(this, state); + QAccessible::updateAccessibility(&event); +#endif + break; } #ifndef QT_NO_WHEELEVENT case QEvent::Wheel: diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 790b51102c..ae050ac643 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -557,6 +557,8 @@ QAccessible::State QAccessibleWidget::state() const state.movable = true; if (w->minimumSize() != w->maximumSize()) state.sizeable = true; + if (w->isActiveWindow()) + state.active = true; } return state; diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index 7a13e2032e..ed7371a9bd 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -96,8 +96,14 @@ bool QWidgetWindow::event(QEvent *event) // these should not be sent to QWidget, the corresponding events // are sent by QApplicationPrivate::notifyActiveWindowChange() case QEvent::FocusIn: - case QEvent::FocusOut: - return false; + case QEvent::FocusOut: { +#ifndef QT_NO_ACCESSIBILITY + QAccessible::State state; + state.active = true; + QAccessibleStateChangeEvent ev(widget(), state); + QAccessible::updateAccessibility(&ev); +#endif + return false; } case QEvent::FocusAboutToChange: if (QApplicationPrivate::focus_widget) { diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index be7cb7dd15..a01589d9d5 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -777,6 +777,7 @@ void tst_QAccessibility::applicationTest() void tst_QAccessibility::mainWindowTest() { + { QMainWindow *mw = new QMainWindow; mw->resize(300, 200); mw->show(); // triggers layout @@ -787,12 +788,51 @@ void tst_QAccessibility::mainWindowTest() QAccessibleEvent show(mw, QAccessible::ObjectShow); QVERIFY_EVENT(&show); - QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(mw); - QCOMPARE(interface->text(QAccessible::Name), name); - QCOMPARE(interface->role(), QAccessible::Window); - delete interface; + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(mw); + QCOMPARE(iface->text(QAccessible::Name), name); + QCOMPARE(iface->role(), QAccessible::Window); + QVERIFY(iface->state().active); + + QAccessible::State activeState; + activeState.active = true; + QAccessibleStateChangeEvent active(mw, activeState); + QVERIFY_EVENT(&active); + + delete iface; delete mw; + } QTestAccessibility::clearEvents(); + + { + QWindow window; + window.setGeometry(80, 80, 40, 40); + window.show(); + QTRY_VERIFY(QGuiApplication::focusWindow() == &window); + +// We currently don't have an accessible interface for QWindow +// the active state is either in the QMainWindow or QQuickView +// QAIPtr windowIface(QAccessible::queryAccessibleInterface(&window)); +// QVERIFY(windowIface->state().active); + + QAccessible::State activeState; + activeState.active = true; + QAccessibleStateChangeEvent active(&window, activeState); + QVERIFY_EVENT(&active); + + QWindow child; + child.setParent(&window); + child.setGeometry(10, 10, 20, 20); + child.show(); + + child.requestActivateWindow(); + QTRY_VERIFY(QGuiApplication::focusWindow() == &child); + + QAccessibleStateChangeEvent deactivate(&window, activeState); + QVERIFY_EVENT(&deactivate); // deactivation of parent + + QAccessibleStateChangeEvent activeChild(&child, activeState); + QVERIFY_EVENT(&activeChild); + } } class CounterButton : public QPushButton { -- cgit v1.2.3 From 387ec9c2a35b2b181e2b2ca29079ecb44eac87e9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 19 Oct 2011 23:42:11 +0200 Subject: Fix compilation of tst_QSqlThread: no need to use QBasicAtomicInt here Change-Id: Ib474fe62501ee1ee5e3d7008c3b561f8db79265c Reviewed-by: Mark Brand Reviewed-by: Thiago Macieira --- tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp index 66f6cd2999..2432548039 100644 --- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp @@ -101,7 +101,7 @@ private: int threadFinishedCount; }; -static QBasicAtomicInt counter; +static QAtomicInt counter; class QtTestSqlThread : public QThread { -- cgit v1.2.3 From e22a6108fda7cac78f5597247ce7b0628b6ba3e2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Nov 2011 14:47:11 -0200 Subject: Use QVector instead of QList for storing metatypes in QtDBus Change I00020eed fixed a bug present in 64-bit machines because it tried to access QList's internal array data, assuming it was a vector of ints. That worked in 32-bit, but not 64-bit. The fix involves a conversion between QList and QVector. Now fix it properly by changing everything to be QVector. The benefit is that on 64-bit, they are real vectors, not the 50%-overhead pointer array that QList is. Change-Id: I989ad279d0d8b2c9ab262a1eed413ab2365b5461 Reviewed-by: Stephen Kelly --- src/dbus/qdbusabstractadaptor.cpp | 2 +- src/dbus/qdbusconnection_p.h | 10 +++++----- src/dbus/qdbusintegrator.cpp | 8 ++++---- src/dbus/qdbusintegrator_p.h | 6 +++--- src/dbus/qdbusmisc.cpp | 2 +- src/dbus/qdbuspendingcall.cpp | 7 +------ src/dbus/qdbuspendingcall_p.h | 4 ++-- src/dbus/qdbusxmlgenerator.cpp | 2 +- 8 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp index 7bdd947a37..e8c56eb990 100644 --- a/src/dbus/qdbusabstractadaptor.cpp +++ b/src/dbus/qdbusabstractadaptor.cpp @@ -296,7 +296,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void ** realObject = realObject->parent(); // break down the parameter list - QList types; + QVector types; int inputCount = qDBusParametersForMethod(mm, types); if (inputCount == -1) // invalid signal signature diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 41a1341e40..5f58b2cf68 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -124,7 +124,7 @@ public: QString service, path, signature; QObject* obj; int midx; - QList params; + QVector params; QStringList argumentMatch; QByteArray matchRule; }; @@ -241,7 +241,7 @@ private: void sendError(const QDBusMessage &msg, QDBusError::ErrorType code); void deliverCall(QObject *object, int flags, const QDBusMessage &msg, - const QList &metaTypes, int slotIdx); + const QVector &metaTypes, int slotIdx); bool isServiceRegisteredByThread(const QString &serviceName) const; @@ -309,7 +309,7 @@ public: public: // static methods - static int findSlot(QObject *obj, const QByteArray &normalizedName, QList& params); + static int findSlot(QObject *obj, const QByteArray &normalizedName, QVector ¶ms); static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key, const QString &service, const QString &path, const QString &interface, const QString &name, @@ -321,7 +321,7 @@ public: int idx, const QList &metaTypes, const QDBusMessage &msg); static QDBusCallDeliveryEvent *prepareReply(QDBusConnectionPrivate *target, QObject *object, - int idx, const QList &metaTypes, + int idx, const QVector &metaTypes, const QDBusMessage &msg); static void processFinishedCall(QDBusPendingCallPrivate *call); @@ -335,7 +335,7 @@ public: }; // in qdbusmisc.cpp -extern int qDBusParametersForMethod(const QMetaMethod &mm, QList& metaTypes); +extern int qDBusParametersForMethod(const QMetaMethod &mm, QVector &metaTypes); extern bool qDBusCheckAsyncTag(const char *tag); extern bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name); extern QString qDBusInterfaceFromMetaObject(const QMetaObject *mo); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index f0c8224be2..cb91601753 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -624,7 +624,7 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg, } static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags, - const QString &signature_, QList& metaTypes) + const QString &signature_, QVector &metaTypes) { QByteArray msgSignature = signature_.toLatin1(); @@ -724,7 +724,7 @@ static QDBusCallDeliveryEvent * const DIRECT_DELIVERY = (QDBusCallDeliveryEvent QDBusCallDeliveryEvent* QDBusConnectionPrivate::prepareReply(QDBusConnectionPrivate *target, QObject *object, int idx, - const QList &metaTypes, + const QVector &metaTypes, const QDBusMessage &msg) { Q_ASSERT(object); @@ -862,7 +862,7 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu } void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const QDBusMessage &msg, - const QList &metaTypes, int slotIdx) + const QVector &metaTypes, int slotIdx) { Q_ASSERT_X(!object || QThread::currentThread() == object->thread(), "QDBusConnection: internal threading error", @@ -1238,7 +1238,7 @@ void QDBusConnectionPrivate::serviceOwnerChangedNoLock(const QString &name, } int QDBusConnectionPrivate::findSlot(QObject* obj, const QByteArray &normalizedName, - QList ¶ms) + QVector ¶ms) { int midx = obj->metaObject()->indexOfMethod(normalizedName); if (midx == -1) diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index c9a2efc57d..f910d2d009 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -84,7 +84,7 @@ struct QDBusSlotCache { int flags; int slotIdx; - QList metaTypes; + QVector metaTypes; }; typedef QMultiHash Hash; Hash hash; @@ -94,7 +94,7 @@ class QDBusCallDeliveryEvent: public QMetaCallEvent { public: QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender, - const QDBusMessage &msg, const QList &types, int f = 0) + const QDBusMessage &msg, const QVector &types, int f = 0) : QMetaCallEvent(0, id, 0, sender, -1), connection(c), message(msg), metaTypes(types), flags(f) { } @@ -106,7 +106,7 @@ public: private: QDBusConnection connection; // just for refcounting QDBusMessage message; - QList metaTypes; + QVector metaTypes; int flags; }; diff --git a/src/dbus/qdbusmisc.cpp b/src/dbus/qdbusmisc.cpp index 7d68bf1185..8a0778f216 100644 --- a/src/dbus/qdbusmisc.cpp +++ b/src/dbus/qdbusmisc.cpp @@ -126,7 +126,7 @@ bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name) // metaTypes.count() >= retval + 1 in all cases // // sig must be the normalised signature for the method -int qDBusParametersForMethod(const QMetaMethod &mm, QList& metaTypes) +int qDBusParametersForMethod(const QMetaMethod &mm, QVector &metaTypes) { QDBusMetaTypeId::init(); diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 65d4b5533b..8e74ecbdde 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -180,12 +180,7 @@ bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *memb if (metaTypes.at(count) == QDBusMetaTypeId::message) --count; - if (count == 0) { - setMetaTypes(count, 0); - } else { - QVector types = QVector::fromList(metaTypes); - setMetaTypes(count, types.constData() + 1); - } + setMetaTypes(count, count ? metaTypes.constData() + 1 : 0); return true; } diff --git a/src/dbus/qdbuspendingcall_p.h b/src/dbus/qdbuspendingcall_p.h index 2aaae7b494..ca3b782a75 100644 --- a/src/dbus/qdbuspendingcall_p.h +++ b/src/dbus/qdbuspendingcall_p.h @@ -56,7 +56,7 @@ #include #include -#include +#include #include #include @@ -82,7 +82,7 @@ public: // for the callback mechanism (see setReplyCallback and QDBusConnectionPrivate::sendWithReplyAsync) QPointer receiver; - QList metaTypes; + QVector metaTypes; int methodIdx; bool autoDelete; diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index a6572b2c86..99edf49868 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -168,7 +168,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method continue; // wasn't a valid type QList names = mm.parameterNames(); - QList types; + QVector types; int inputCount = qDBusParametersForMethod(mm, types); if (inputCount == -1) continue; // invalid form -- cgit v1.2.3 From 7e1aec215d0f494c0dff583fa0f2084320f3083e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 28 Dec 2011 17:00:27 -0200 Subject: QPrinterInfo: remove a test that is too early If we want to have any chance of getting the missing printers reported, we cannot check the size beforehand. Change-Id: I450897fe53c04aeb1a4b217bd0c1f548c455a428 Reviewed-by: John Layt --- tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index 2323dc8df3..48d38a8146 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -275,7 +275,7 @@ void tst_QPrinterInfo::testForPrinters() # endif QList printers = QPrinterInfo::availablePrinters(); - QCOMPARE(printers.size(), sysPrinters.size()); +// QCOMPARE(printers.size(), sysPrinters.size()); QHash qtPrinters; -- cgit v1.2.3 From 4131c323a36ee8680a3b4d66a2a03a00544751c2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 31 Dec 2011 00:14:50 -0200 Subject: Update the C++11 support macros Move them all to a central place and document each macro, so we don't give typo names by accident Change-Id: Ia863ac3f7ca82e4d2f8388b3e691a12c7e482283 Reviewed-by: Stephen Kelly --- src/corelib/global/qcompilerdetection.h | 156 +++++++++++++++++++++++--------- src/corelib/global/qglobal.h | 4 + 2 files changed, 115 insertions(+), 45 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index b3787261be..f3f0302072 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Intel Corporation ** Contact: http://www.qt-project.org/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -140,11 +141,13 @@ # if defined(__INTEL_COMPILER) /* Intel C++ also masquerades as GCC */ # define Q_CC_INTEL -# endif -# if defined(__clang__) +# elif defined(__clang__) /* Clang also masquerades as GCC */ # define Q_CC_CLANG +# else +/* Plain GCC */ # endif + # define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) @@ -157,44 +160,8 @@ # define QT_NO_ARM_EABI # endif # endif -# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 && !defined(Q_CC_CLANG) # define Q_ALLOC_SIZE(x) __attribute__((alloc_size(x))) -# endif -# if defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(__clang__) /* clang C++11 enablers are found below, don't do them here */ -# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 - /* C++0x features supported in GCC 4.3: */ -# define Q_COMPILER_VARIADIC_MACROS -# define Q_COMPILER_RVALUE_REFS -# define Q_COMPILER_DECLTYPE -# define Q_COMPILER_STATIC_ASSERT -# endif -# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 - /* C++0x features supported in GCC 4.4: */ -# define Q_COMPILER_UNICODE_STRINGS -# define Q_COMPILER_VARIADIC_TEMPLATES -# define Q_COMPILER_AUTO_TYPE -# define Q_COMPILER_EXTERN_TEMPLATES -# define Q_COMPILER_DEFAULT_DELETE_MEMBERS -# define Q_COMPILER_CLASS_ENUM -# define Q_COMPILER_INITIALIZER_LISTS -# define Q_COMPILER_ATOMICS -# endif -# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 - /* C++0x features supported in GCC 4.5: */ -# define Q_COMPILER_LAMBDA -# endif -# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 - /* C++0x features supported in GCC 4.6: */ -# define Q_COMPILER_NULLPTR -# define Q_COMPILER_CONSTEXPR -# define Q_COMPILER_UNRESTRICTED_UNIONS -# define Q_COMPILER_RANGE_FOR -# endif -# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 - /* C++0x features supported in GCC 4.7: */ -# define Q_COMPILER_EXPLICIT_OVERRIDES -# endif - # endif /* IBM compiler versions are a bit messy. There are actually two products: @@ -420,22 +387,66 @@ # error "Qt has not been tested with this compiler - see http://www.qt-project.org/" #endif +/* + * C++11 support + * + * Paper Macro + * N2341 Q_COMPILER_ALIGNAS + * N2341 Q_COMPILER_ALIGNOF + * N2427 Q_COMPILER_ATOMICS + * N2761 Q_COMPILER_ATTRIBUTES + * N2541 Q_COMPILER_AUTO_FUNCTION + * N1984 N2546 Q_COMPILER_AUTO_TYPE + * N2437 Q_COMPILER_CLASS_ENUM + * N2235 N3276 Q_COMPILER_DECLTYPE + * N2346 Q_COMPILER_DEFAULT_DELETE_MEMBERS + * N1986 Q_COMPILER_DELEGATING_CONSTRUCTORS + * N3206 N3272 Q_COMPILER_EXPLICIT_OVERRIDES (v0.9 and above only) + * N1987 Q_COMPILER_EXTERN_TEMPLATES + * N2540 Q_COMPILER_INHERITING_CONSTRUCTORS + * N2672 Q_COMPILER_INITIALIZER_LISTS + * N2658 N2927 Q_COMPILER_LAMBDA (v1.0 and above only) + * N2756 Q_COMPILER_NONSTATIC_MEMBER_INIT + * N2431 Q_COMPILER_NULLPTR + * N2930 Q_COMPILER_RANGE_FOR + * N2442 Q_COMPILER_RAW_STRINGS + * N2439 Q_COMPILER_REF_QUALIFIERS + * N2118 N2844 N3053 Q_COMPILER_RVALUE_REFS (Note: GCC 4.3 implements only the oldest) + * N1720 Q_COMPILER_STATIC_ASSERT + * N2258 Q_COMPILER_TEMPLATE_ALIAS + * N2659 Q_COMPILER_THREAD_LOCAL + * N2756 Q_COMPILER_UDL + * N2442 Q_COMPILER_UNICODE_STRINGS + * N2544 Q_COMPILER_UNRESTRICTED_UNIONS + * N1653 Q_COMPILER_VARIADIC_MACROS + * N2242 N2555 Q_COMPILER_VARIADIC_TEMPLATES + */ #ifdef Q_CC_INTEL # if __INTEL_COMPILER < 1200 # define Q_NO_TEMPLATE_FRIENDS # endif -# if defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__) +# if defined(_CHAR16T) || __cplusplus >= 201103L +# define Q_COMPILER_VARIADIC_MACROS # if __INTEL_COMPILER >= 1200 -# define Q_COMPILER_RVALUE_REFS -# define Q_COMPILER_EXTERN_TEMPLATES -# define Q_COMPILER_DECLTYPE -# define Q_COMPILER_VARIADIC_TEMPLATES # define Q_COMPILER_AUTO_TYPE -# define Q_COMPILER_DEFAULT_DELETE_MEMBERS # define Q_COMPILER_CLASS_ENUM +# define Q_COMPILER_DECLTYPE +# define Q_COMPILER_DEFAULT_DELETE_MEMBERS +# define Q_COMPILER_EXTERN_TEMPLATES # define Q_COMPILER_LAMBDA +# define Q_COMPILER_RVALUE_REFS # define Q_COMPILER_STATIC_ASSERT +# define Q_COMPILER_THREAD_LOCAL +# define Q_COMPILER_VARIADIC_MACROS +# endif +# if __INTEL_COMPILER >= 1210 +# define Q_COMPILER_ATTRIBUTES +# define Q_COMPILER_AUTO_FUNCTION +# define Q_COMPILER_NULLPTR +# define Q_COMPILER_TEMPLATE_ALIAS +# define Q_COMPILER_UNICODE_STRINGS +# define Q_COMPILER_VARIADIC_TEMPLATES # endif # endif #endif @@ -463,6 +474,7 @@ # define Q_COMPILER_CLASS_ENUM /* defaulted members in 3.0, deleted members in 2.9 */ # define Q_COMPILER_DEFAULT_DELETE_MEMBERS +# define Q_COMPILER_DELEGATING_CONSTRUCTORS # define Q_COMPILER_EXPLICIT_OVERRIDES # define Q_COMPILER_NULLPTR # define Q_COMPILER_RANGE_FOR @@ -487,6 +499,60 @@ # endif #endif // Q_CC_CLANG +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG) +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 + /* C++11 features supported in GCC 4.3: */ +# define Q_COMPILER_DECLTYPE +# define Q_COMPILER_RVALUE_REFS +# define Q_COMPILER_STATIC_ASSERT +# define Q_COMPILER_VARIADIC_MACROS +# endif +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 + /* C++11 features supported in GCC 4.4: */ +# define Q_COMPILER_ATOMICS +# define Q_COMPILER_AUTO_FUNCTION +# define Q_COMPILER_AUTO_TYPE +# define Q_COMPILER_CLASS_ENUM +# define Q_COMPILER_DEFAULT_DELETE_MEMBERS +# define Q_COMPILER_EXTERN_TEMPLATES +# define Q_COMPILER_INITIALIZER_LISTS +# define Q_COMPILER_UNICODE_STRINGS +# define Q_COMPILER_VARIADIC_TEMPLATES +# endif +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 + /* C++11 features supported in GCC 4.5: */ +# define Q_COMPILER_LAMBDA +# define Q_COMPILER_RAW_STRINGS +# endif +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 + /* C++11 features supported in GCC 4.6: */ +# define Q_COMPILER_CONSTEXPR +# define Q_COMPILER_NULLPTR +# define Q_COMPILER_UNRESTRICTED_UNIONS +# define Q_COMPILER_RANGE_FOR +# endif +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 + /* C++11 features supported in GCC 4.7: */ +# define Q_COMPILER_NONSTATIC_MEMBER_INIT +# define Q_COMPILER_DELEGATING_CONSTRUCTORS +# define Q_COMPILER_EXPLICIT_OVERRIDES +# define Q_COMPILER_TEMPLATE_ALIAS +# define Q_COMPILER_UDL +# endif +# endif +#endif + +#if defined(Q_CC_MSVC) && _MSC_VER >= 1600 && !defined(Q_CC_INTEL) +# define Q_COMPILER_AUTO_TYPE +# define Q_COMPILER_LAMBDA +# define Q_COMPILER_DECLTYPE +# define Q_COMPILER_RVALUE_REFS +# define Q_COMPILER_STATIC_ASSERT +// MSVC has std::initilizer_list, but does not support the braces initialization +//# define Q_COMPILER_INITIALIZER_LISTS +#endif + #ifndef Q_COMPILER_MANGLES_RETURN_TYPE # if defined(Q_CC_MSVC) # define Q_COMPILER_MANGLES_RETURN_TYPE diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 99328d52ac..734177638c 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -420,6 +420,10 @@ QT_END_INCLUDE_NAMESPACE # define Q_DECL_FINAL #endif +#if defined(Q_COMPILER_ALIGNOF) && !defined(Q_ALIGNOF) +# define Q_ALIGNOF(x) alignof(x) +#endif + //defines the type for the WNDPROC on windows //the alignment needs to be forced for sse2 to not crash with mingw #if defined(Q_OS_WIN) -- cgit v1.2.3 From ad81f75429f6c5586d667880f90f4a425f1ce968 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 31 Dec 2011 00:15:06 -0200 Subject: Add macros for assuming and unreachable code Use these macros to tell the compiler about conditions that may happen, so it will generate better code. But do not assume that they will do anything special. Change-Id: I89ec4f65f48a9340ccf5ffc4ae4b8c3d8897c8b1 Reviewed-by: Oswald Buddenhagen Reviewed-by: Olivier Goffart --- .../snippets/code/src_corelib_global_qglobal.cpp | 23 +++++++++ src/corelib/global/qcompilerdetection.h | 8 +++ src/corelib/global/qglobal.cpp | 57 ++++++++++++++++++++++ src/corelib/global/qglobal.h | 6 +++ 4 files changed, 94 insertions(+) diff --git a/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/doc/src/snippets/code/src_corelib_global_qglobal.cpp index 21bea7aef8..16f6783a52 100644 --- a/doc/src/snippets/code/src_corelib_global_qglobal.cpp +++ b/doc/src/snippets/code/src_corelib_global_qglobal.cpp @@ -560,3 +560,26 @@ bool readConfiguration(const QFile &file) return true; } //! [qunlikely] + +//! [qunreachable-enum] + enum Shapes { + Rectangle, + Triangle, + Circle, + NumShapes + }; +//! [qunreachable-enum] + +//! [qunreachable-switch] + switch (shape) { + case Rectangle: + return rectangle(); + case Triangle: + return triangle(); + case Circle: + return circle(); + case NumShapes: + Q_UNREACHABLE(); + break; + } +//! [qunreachable-switch] diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index f3f0302072..c9f59454b2 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -88,6 +88,8 @@ # define Q_NO_TEMPLATE_FRIENDS # define Q_ALIGNOF(type) __alignof(type) # define Q_DECL_ALIGN(n) __declspec(align(n)) +# define Q_ASSUME(expr) __assume(expr) +# define Q_UNREACHABLE() __assume(0) /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ # if defined(__INTEL_COMPILER) # define Q_CC_INTEL @@ -141,11 +143,17 @@ # if defined(__INTEL_COMPILER) /* Intel C++ also masquerades as GCC */ # define Q_CC_INTEL +# define Q_ASSUME(expr) __assume(expr) +# define Q_UNREACHABLE() __assume(0) # elif defined(__clang__) /* Clang also masquerades as GCC */ # define Q_CC_CLANG +# define Q_ASSUME(expr) if (expr){} else __builtin_unreachable() +# define Q_UNREACHABLE() __builtin_unreachable() # else /* Plain GCC */ +# define Q_ASSUME(expr) if (expr){} else __builtin_unreachable() +# define Q_UNREACHABLE() __builtin_unreachable() # endif # define Q_ALIGNOF(type) __alignof__(type) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 09d178639d..f89b0b3421 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1798,6 +1798,63 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion() \sa Q_ASSERT(), qFatal(), {Debugging Techniques} */ +/*! + \macro void Q_ASSUME(bool expr) + \relates + \since 5.0 + + Causes the compiler to assume that \a expr is true. This macro is useful + for improving code generation, by providing the compiler with hints about + conditions that it would not otherwise know about. However, there is no + guarantee that the compiler will actually use those hints. + + This macro could be considered a "lighter" version of \ref Q_ASSERT. While + Q_ASSERT will abort the program's execution if the condition is false, + Q_ASSUME will tell the compiler not to generate code for those conditions. + Therefore, it is important that the assumptions always hold, otherwise + undefined behaviour may occur. + + If \a expr is a constantly false condition, Q_ASSUME will tell the compiler + that the current code execution cannot be reached. That is, Q_ASSUME(false) + is equivalent to Q_UNREACHABLE(). + + \note Q_LIKELY() tells the compiler that the expression is likely, but not + the only possibility. Q_ASSUME tells the compiler that it is the only + possibility. + + \sa Q_ASSERT(), Q_UNREACHABLE(), Q_LIKELY() +*/ + +/*! + \macro void Q_UNREACHABLE() + \relates + \since 5.0 + + Tells the compiler that the current point cannot be reached by any + execution, so it may optimise any code paths leading here as dead code, as + well as code continuing from here. + + This macro is useful to mark impossible conditions. For example, given the + following enum: + + \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qunreachable-enum + + One can write a switch table like so: + + \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qunreachable-switch + + The advantage of inserting Q_UNREACHABLE() at that point is that the + compiler is told not to generate code for a shape variable containing that + value. If the macro is missing, the compiler will still generate the + necessary comparisons for that value. If the case label were removed, some + compilers could produce a warning that some enum values were not checked. + + By using this macro in impossible conditions, code coverage may be improved + as dead code paths may be eliminated. + + \sa Q_ASSERT(), Q_ASSUME(), qFatal() +*/ + /*! \macro void Q_CHECK_PTR(void *pointer) \relates diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 734177638c..7d91fa3ca9 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -163,6 +163,12 @@ namespace QT_NAMESPACE {} #ifndef Q_UNLIKELY # define Q_UNLIKELY(x) (x) #endif +#ifndef Q_ASSUME +# define Q_ASSUME(expr) +#endif +#ifndef Q_UNREACHABLE +# define Q_UNREACHABLE() +#endif #ifndef Q_ALLOC_SIZE # define Q_ALLOC_SIZE(x) -- cgit v1.2.3 From 518a4cb5abdca788c4bb59e570e97c01e44587c8 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 24 Mar 2012 09:23:25 +0100 Subject: Restore Qt4 compat in QDesktopServices::DataLocation "/data/" was appended to the base directory. Change-Id: I220f2ce74c36b795bc49c7c84106feb0709d1547 Reviewed-by: Thiago Macieira --- src/gui/util/qdesktopservices.cpp | 18 +++++++++++ src/gui/util/qdesktopservices.h | 4 ++- .../util/qdesktopservices/tst_qdesktopservices.cpp | 35 ++++++++++++++++++++-- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 25fb08f532..1a6661440c 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -54,6 +54,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -283,6 +284,23 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme) Use QStandardPaths::displayName() */ + +QString QDesktopServices::storageLocationImpl(StandardLocation type) +{ +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) + if (type == DataLocation) { + QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME")); + if (xdgDataHome.isEmpty()) + xdgDataHome = QDir::homePath() + QLatin1String("/.local/share"); + xdgDataHome += QLatin1String("/data/") + + QCoreApplication::organizationName() + QLatin1Char('/') + + QCoreApplication::applicationName(); + return xdgDataHome; + } +#endif + return QStandardPaths::writableLocation(static_cast(type)); +} + QT_END_NAMESPACE #include "qdesktopservices.moc" diff --git a/src/gui/util/qdesktopservices.h b/src/gui/util/qdesktopservices.h index 04a639437e..280acaf277 100644 --- a/src/gui/util/qdesktopservices.h +++ b/src/gui/util/qdesktopservices.h @@ -79,12 +79,14 @@ public: }; QT_DEPRECATED static QString storageLocation(StandardLocation type) { - return QStandardPaths::writableLocation(static_cast(type)); + return storageLocationImpl(type); } QT_DEPRECATED static QString displayName(StandardLocation type) { return QStandardPaths::displayName(static_cast(type)); } #endif +private: + static QString storageLocationImpl(StandardLocation type); }; #endif // QT_NO_DESKTOPSERVICES diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp index 0ad37c21e8..618587356b 100644 --- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp @@ -57,12 +57,11 @@ private slots: void cleanup(); void openUrl(); void handlers(); + void testDataLocation(); }; tst_qdesktopservices::tst_qdesktopservices() { - QCoreApplication::setOrganizationName("Nokia"); - QCoreApplication::setApplicationName("tst_qdesktopservices"); } tst_qdesktopservices::~tst_qdesktopservices() @@ -117,5 +116,37 @@ void tst_qdesktopservices::handlers() QCOMPARE(barHandler.lastHandledUrl.toString(), barUrl.toString()); } +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) +#define Q_XDG_PLATFORM +#endif + +void tst_qdesktopservices::testDataLocation() +{ + // This is the one point where QDesktopServices and QStandardPaths differ. + // QDesktopServices on unix returns "data"/orgname/appname for DataLocation, for Qt4 compat. + // And the appname in qt4 defaulted to empty, not to argv[0]. + { + const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); + const QString app = QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#ifdef Q_XDG_PLATFORM + QCOMPARE(app, base + "/data//"); // as ugly as in Qt4 +#else + QCOMPARE(app, base); +#endif + } + QCoreApplication::instance()->setOrganizationName("Qt"); + QCoreApplication::instance()->setApplicationName("QtTest"); + { + const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); + const QString app = QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#ifdef Q_XDG_PLATFORM + QCOMPARE(app, base + "/data/Qt/QtTest"); +#else + QCOMPARE(app, base + "/Qt/QtTest"); +#endif + } +} + QTEST_MAIN(tst_qdesktopservices) + #include "tst_qdesktopservices.moc" -- cgit v1.2.3 From efa0f1f0a7c7e76f58b802b06629ca1799a89f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 23 Mar 2012 08:00:11 +0100 Subject: Use XCB_TIME_CURRENT_TIME instead of CurrentTime from X.h in xcb plugin. The less X header dependencies the better, we might at some time in the future be able to do without the XCB_USE_XLIB define as well. Change-Id: Ib45986036febef70798851ee8455e054eafc9d22 Reviewed-by: Marc Mutz Reviewed-by: Jan Arne Petersen Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 91337adb4e..ba4a6f7c5e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -551,7 +551,7 @@ void QXcbWindow::show() updateNetWmStateBeforeMap(); } - if (connection()->time() != CurrentTime) + if (connection()->time() != XCB_TIME_CURRENT_TIME) updateNetWmUserTime(connection()->time()); Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); -- cgit v1.2.3 From c192e6496269528341320aa556e41b3553ad9357 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Feb 2012 14:55:22 +0100 Subject: Use private futexes for QMutex on Linux if they're available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Futexes on Linux can be used across processes, for inter-process synchronisation. The private flag tells the kernel that this futex is not used with other processes, so it does not need to check for waiters outside the current process. This feature had been proposed in Merge Request 25, but was lost. Change-Id: Ieafa8b8df0949bd9ae73709b3ec63f7709b0b2a6 Reviewed-by: João Abecasis --- src/corelib/thread/qmutex_linux.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index b1618f7fc9..1bb5e77e77 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -45,15 +45,47 @@ #ifndef QT_NO_THREAD #include "qatomic.h" #include "qmutex_p.h" -# include "qelapsedtimer.h" +#include "qelapsedtimer.h" #include #include #include #include +#ifndef QT_LINUX_FUTEX +# error "Qt build is broken: qmutex_linux.cpp is being built but futex support is not wanted" +#endif + QT_BEGIN_NAMESPACE +static inline int futexFlags() +{ + int value = 0; +#if defined(FUTEX_PRIVATE_FLAG) + // check if the kernel supports extra futex flags + // FUTEX_PRIVATE_FLAG appeared in v2.6.22 + static QBasicAtomicInt futexFlagSupport = Q_BASIC_ATOMIC_INITIALIZER(-1); + + value = futexFlagSupport.load(); + if (value == -1) { + // try an operation that has no side-effects: wake up 42 threads + // futex will return -1 (errno==ENOSYS) if the flag isn't supported + // there should be no other error conditions + value = syscall(SYS_futex, &futexFlagSupport, + FUTEX_WAKE | FUTEX_PRIVATE_FLAG, + 42, 0, 0, 0); + if (value != -1) { + value = FUTEX_PRIVATE_FLAG; + futexFlagSupport.store(value); + return value; + } + value = 0; + futexFlagSupport.store(value); + } +#endif + return value; +} + static inline int _q_futex(void *addr, int op, int val, const struct timespec *timeout) { volatile int *int_addr = reinterpret_cast(addr); @@ -62,7 +94,8 @@ static inline int _q_futex(void *addr, int op, int val, const struct timespec *t #endif int *addr2 = 0; int val2 = 0; - return syscall(SYS_futex, int_addr, op, val, timeout, addr2, val2); + + return syscall(SYS_futex, int_addr, op | futexFlags(), val, timeout, addr2, val2); } static inline QMutexData *dummyFutexValue() -- cgit v1.2.3 From b4ec690bbdb4e56d33cfe979f2d54de9a714e4fd Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 14 Mar 2012 14:01:54 +0100 Subject: Improve accessibility test to handle more text events. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I67ece6c9bb755e84c786b32e8e3396eaf634fda1 Reviewed-by: Jan-Arve Sæther --- .../other/qaccessibility/tst_qaccessibility.cpp | 45 +++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index a01589d9d5..5f0539a5af 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1921,15 +1921,42 @@ void tst_QAccessibility::lineEditTest() QAccessibleTextUpdateEvent update(lineEdit, 0, "foo", "bar"); QVERIFY(QTestAccessibility::containsEvent(&update)); -// QTestEventList keys; -// keys.addKeyClick('D'); -// keys.addKeyClick('E'); -// keys.addKeyClick(Qt::Key_Left); -// keys.addKeyClick(Qt::Key_Left); -// keys.addKeyClick('C'); -// keys.addKeyClick('O'); -// keys.simulate(lineEdit); -// FIXME: Test key press events... + // FIXME check what extra events are around and get rid of them + QTestAccessibility::clearEvents(); + + QTestEventList keys; + keys.addKeyClick('D'); + keys.simulate(lineEdit); + + QAccessibleTextInsertEvent insertD(lineEdit, 3, "D"); + QVERIFY_EVENT(&insertD); + keys.clear(); + keys.addKeyClick('E'); + keys.simulate(lineEdit); + + QAccessibleTextInsertEvent insertE(lineEdit, 4, "E"); + QVERIFY(QTestAccessibility::containsEvent(&insertE)); + keys.clear(); + keys.addKeyClick(Qt::Key_Left); + keys.addKeyClick(Qt::Key_Left); + keys.simulate(lineEdit); + cursorEvent.setCursorPosition(4); + QVERIFY(QTestAccessibility::containsEvent(&cursorEvent)); + cursorEvent.setCursorPosition(3); + QVERIFY(QTestAccessibility::containsEvent(&cursorEvent)); + + keys.clear(); + keys.addKeyClick('C'); + keys.simulate(lineEdit); + + QAccessibleTextInsertEvent insertC(lineEdit, 3, "C"); + QVERIFY(QTestAccessibility::containsEvent(&insertC)); + + keys.clear(); + keys.addKeyClick('O'); + keys.simulate(lineEdit); + QAccessibleTextInsertEvent insertO(lineEdit, 4, "O"); + QVERIFY(QTestAccessibility::containsEvent(&insertO)); } delete toplevel; QTestAccessibility::clearEvents(); -- cgit v1.2.3 From 1904970dad788f62a09648cc21008e5cb0393539 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 19 Oct 2011 23:41:17 +0200 Subject: Work around what apparently is a GCC 4.6.0 bug The QFlags::operator int() isn't being called, so GCC complains that this isn't an integer expression. Change-Id: I537d06fd4a52ecbcddf0ef67807b298c42d3e911 Reviewed-by: Olivier Goffart --- tests/auto/corelib/global/qflags/tst_qflags.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 2794c174ba..7f67f3a612 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -106,7 +106,7 @@ void tst_QFlags::constExpr() switch (btn) { case Qt::LeftButton: QVERIFY(false); break; case Qt::RightButton: QVERIFY(false); break; - case Qt::LeftButton | Qt::RightButton: QVERIFY(true); break; + case int(Qt::LeftButton | Qt::RightButton): QVERIFY(true); break; default: QVERIFY(false); } -- cgit v1.2.3 From d3951a5b0f4fe9731d1512668b43f51bd98bd84e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 11 Nov 2011 17:55:46 -0200 Subject: Remove the use of a template qUnused function for ICC ICC 12 does not seem to need this. Change-Id: I98e9d530e767c4d24424f0c2b5d763f863e85fe4 Reviewed-by: Stephen Kelly Reviewed-by: Bradley T. Hughes --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7d91fa3ca9..cc0e6a17fd 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -820,7 +820,7 @@ Q_CORE_EXPORT bool qSharedBuild(); Avoid "unused parameter" warnings */ -#if defined(Q_CC_INTEL) && !defined(Q_OS_WIN) || defined(Q_CC_RVCT) +#if defined(Q_CC_RVCT) template inline void qUnused(T &x) { (void)x; } # define Q_UNUSED(x) qUnused(x); -- cgit v1.2.3 From 38f33e035fef3e649662c838b85528eeb23b79fe Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Dec 2011 19:53:30 -0200 Subject: Remove the Q_STATIC_TEMPLATE_SPECIALIZATION macro This was necessary only for older MS Visual Studio versions, which are no longer supported anyway. Change-Id: I6c96fb2340296c34b480716303c93b892419229b Reviewed-by: Stephen Kelly --- src/gui/painting/qdrawhelper.cpp | 2 -- src/gui/painting/qdrawhelper_p.h | 6 ------ src/gui/painting/qmemrotate.cpp | 1 - 3 files changed, 9 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 035f56b35e..7571d81a36 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -814,7 +814,6 @@ template void fetchTransformedBilinear_pixelBounds(int max, int l1, int l2, int &v1, int &v2); template<> -Q_STATIC_TEMPLATE_SPECIALIZATION inline void fetchTransformedBilinear_pixelBounds(int max, int, int, int &v1, int &v2) { v1 %= max; @@ -828,7 +827,6 @@ inline void fetchTransformedBilinear_pixelBounds( } template<> -Q_STATIC_TEMPLATE_SPECIALIZATION inline void fetchTransformedBilinear_pixelBounds(int, int l1, int l2, int &v1, int &v2) { if (v1 < l1) diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 2e88fe718a..442fd8bcd7 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -67,12 +67,6 @@ QT_BEGIN_NAMESPACE -#if defined(Q_CC_MSVC) && _MSCVER <= 1300 && !defined(Q_CC_INTEL) -#define Q_STATIC_TEMPLATE_SPECIALIZATION static -#else -#define Q_STATIC_TEMPLATE_SPECIALIZATION -#endif - #if defined(Q_CC_RVCT) // RVCT doesn't like static template functions # define Q_STATIC_TEMPLATE_FUNCTION diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp index e6fcc3e5dd..6f4dc5b358 100644 --- a/src/gui/painting/qmemrotate.cpp +++ b/src/gui/painting/qmemrotate.cpp @@ -423,7 +423,6 @@ inline void qt_memrotate270_template(const T *src, int srcWidth, int srcHeight, } template <> -Q_STATIC_TEMPLATE_SPECIALIZATION inline void qt_memrotate90_template(const quint24 *src, int srcWidth, int srcHeight, int srcStride, quint24 *dest, int dstStride) { -- cgit v1.2.3 From 1dc7aed0e9632c4da7aa1b182cd5198b913b912f Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 22 Mar 2012 13:12:21 +1000 Subject: Fixed qthreadstorage unittest to work from install directory - Added install of crashonexit sub program Change-Id: I2cc3043d5c1b879665930552487b4fe54407fd25 Reviewed-by: Rohan McGovern --- tests/auto/corelib/thread/qthreadstorage/test/test.pro | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro index a7d8eb0106..cfbf5bf5a4 100644 --- a/tests/auto/corelib/thread/qthreadstorage/test/test.pro +++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro @@ -4,3 +4,7 @@ CONFIG -= app_bundle CONFIG += console QT = core testlib SOURCES = ../tst_qthreadstorage.cpp + +load(testcase) # for installTestHelperApp() +installTestHelperApp("../crashonexit/crashonexit",crashonexit,crashonexit) + -- cgit v1.2.3 From a760289038f3775cc399a8f47c36b9bce525c1a1 Mon Sep 17 00:00:00 2001 From: Sarah Smith Date: Wed, 21 Mar 2012 16:45:32 +1000 Subject: Fix qtnamespace compile break on Mac. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Appears as though the QT_NAMESPACE macros are incorrect here. In fact in qisenum.h because the #define is no respecter of a namespace in most of these conditional compile cases they will be ignored effectively. The QT_HEADER also - if qtypetraits.h conditional compile occurs then it will result in adding extern "C" { twice. For the macros invoking them will not cause the extern "C" { to be used anyway, so just remove this altogether. Task-number: QTBUG-24903 Change-Id: I710dc330f58357f395241a0cf3172e41a5864576 Reviewed-by: Morten Johan Sørvig Reviewed-by: Glenn Watson Reviewed-by: Sarah Jane Smith --- src/corelib/global/qisenum.h | 6 ------ src/plugins/platforms/cocoa/qcocoanativeinterface.h | 4 ++++ src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 4 ++++ src/plugins/platforms/cocoa/qcocoawindow.h | 4 ++-- src/plugins/platforms/cocoa/qmacclipboard.h | 4 ++++ src/plugins/platforms/cocoa/qmacclipboard.mm | 4 ---- src/plugins/platforms/cocoa/qmacmime.h | 4 ++++ 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/corelib/global/qisenum.h b/src/corelib/global/qisenum.h index c9b6ec6695..40b576e831 100644 --- a/src/corelib/global/qisenum.h +++ b/src/corelib/global/qisenum.h @@ -44,9 +44,6 @@ #ifndef QISENUM_H #define QISENUM_H -QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - #ifndef Q_IS_ENUM # if defined(Q_CC_GNU) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) # define Q_IS_ENUM(x) __is_enum(x) @@ -58,7 +55,4 @@ QT_BEGIN_NAMESPACE # endif #endif -QT_END_HEADER -QT_END_NAMESPACE - #endif // QISENUM_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 8856e90cf3..bb4d0f9f6c 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -45,6 +45,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QWidget; class QCocoaNativeInterface : public QPlatformNativeInterface @@ -74,3 +76,5 @@ private: }; #endif // QCOCOANATIVEINTERFACE_H + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 29c2e58959..ca15b6bbfb 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -54,6 +54,8 @@ #include "qprintengine_mac_p.h" +QT_BEGIN_NAMESPACE + void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { if (!window->handle()) { @@ -81,3 +83,5 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine QMacPrintEngine *macPrintEngine = static_cast(printEngine); return macPrintEngine->d_func()->printInfo; } + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 90c5a050d0..2358f7554f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -49,7 +49,7 @@ #include "qcocoaglcontext.h" #include "qnsview.h" -class QCocoaWindow; +class QT_PREPEND_NAMESPACE(QCocoaWindow); @interface QNSWindow : NSWindow { @public QCocoaWindow *m_cocoaPlatformWindow; @@ -59,7 +59,7 @@ class QCocoaWindow; @end @interface QNSPanel : NSPanel { - @public QCocoaWindow *m_cocoaPlatformWindow; + @public QT_PREPEND_NAMESPACE(QCocoaWindow) *m_cocoaPlatformWindow; } - (BOOL)canBecomeKeyWindow; @end diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h index 9371aca459..634d29a60f 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.h +++ b/src/plugins/platforms/cocoa/qmacclipboard.h @@ -49,6 +49,8 @@ #import +QT_BEGIN_NAMESPACE + class QMacPasteboard { struct Promise { @@ -90,4 +92,6 @@ public: QString qt_mac_get_pasteboardString(PasteboardRef paste); +QT_END_NAMESPACE + #endif diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index eff2c5b07a..73abd8945c 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -56,8 +56,6 @@ QT_BEGIN_NAMESPACE -QT_USE_NAMESPACE - /***************************************************************************** QClipboard debug facilities *****************************************************************************/ @@ -548,6 +546,4 @@ QString qt_mac_get_pasteboardString(PasteboardRef paste) return QString(); } - - QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qmacmime.h b/src/plugins/platforms/cocoa/qmacmime.h index 7226caef28..12c9aff039 100644 --- a/src/plugins/platforms/cocoa/qmacmime.h +++ b/src/plugins/platforms/cocoa/qmacmime.h @@ -46,6 +46,8 @@ #include +QT_BEGIN_NAMESPACE + class Q_GUI_EXPORT QMacPasteboardMime { char type; public: @@ -74,5 +76,7 @@ public: virtual QList convertFromMime(const QString &mime, QVariant data, QString flav) = 0; }; +QT_END_NAMESPACE + #endif -- cgit v1.2.3 From 595021e0f7a2bfed37750cc41d6c4564e69297c8 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Mar 2012 10:38:32 +0100 Subject: Cocoa: keep a NSWindow pointer in QCocoaWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NSWindow we create could either be a QNSWindow (our NSWindow subclass) or a QNSPanel (our NSPanel subclass). Change-Id: I6e5c18328bf0fd1786a042d1fddc5b3e8be17f89 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 2358f7554f..94d166b7a5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -133,7 +133,7 @@ public: // for QNSView friend class QCocoaNativeInterface; QNSView *m_contentView; - QNSWindow *m_nsWindow; + NSWindow *m_nsWindow; Qt::WindowFlags m_windowFlags; QPointer m_activePopupWindow; -- cgit v1.2.3 From 37010812a273c98272ae5d960c46b3e909c3a36a Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 22 Mar 2012 17:39:30 +0100 Subject: Cocoa: send key events for modifier keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement -flagsChanged: in QNSView so that we can calculate the necessary modifier key events to send. Change-Id: I3de89537d6e22b4a6d69ae646a71d9722dd9f82a Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qnsview.mm | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index d249158db3..2b384a28ec 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -638,6 +638,43 @@ static QTouchDevice *touchDevice = 0; [self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)]; } +- (void)flagsChanged:(NSEvent *)nsevent +{ + ulong timestamp = [nsevent timestamp] * 1000; + ulong modifiers = [nsevent modifierFlags]; + Qt::KeyboardModifiers qmodifiers = [self convertKeyModifiers:modifiers]; + + // calculate the delta and remember the current modifiers for next time + static ulong m_lastKnownModifiers; + ulong lastKnownModifiers = m_lastKnownModifiers; + ulong delta = lastKnownModifiers ^ modifiers; + m_lastKnownModifiers = modifiers; + + struct qt_mac_enum_mapper + { + ulong mac_mask; + Qt::Key qt_code; + }; + static qt_mac_enum_mapper modifier_key_symbols[] = { + { NSShiftKeyMask, Qt::Key_Shift }, + { NSControlKeyMask, Qt::Key_Meta }, + { NSCommandKeyMask, Qt::Key_Control }, + { NSAlternateKeyMask, Qt::Key_Alt }, + { NSAlphaShiftKeyMask, Qt::Key_CapsLock }, + { 0ul, Qt::Key_unknown } }; + for (int i = 0; modifier_key_symbols[i].mac_mask != 0u; ++i) { + uint mac_mask = modifier_key_symbols[i].mac_mask; + if ((delta & mac_mask) == 0u) + continue; + + QWindowSystemInterface::handleKeyEvent(m_window, + timestamp, + (lastKnownModifiers & mac_mask) ? QEvent::KeyRelease : QEvent::KeyPress, + modifier_key_symbols[i].qt_code, + qmodifiers); + } +} + - (void) doCommandBySelector:(SEL)aSelector { [self tryToPerform:aSelector with:self]; -- cgit v1.2.3 From b2363a935c8dac2c332c79d4c10c99be89656047 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 22 Mar 2012 17:43:25 +0100 Subject: Fix QGuiApplication::keyboardModifiers() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that the keybaord modifiers are maintained properly when handling window system events. Change-Id: Ie75cbe5eb509c29e3d2291694f2de509fbf3098a Reviewed-by: Morten Johan Sørvig Reviewed-by: Friedemann Kleint --- src/gui/kernel/qguiapplication.cpp | 4 ++ src/gui/kernel/qwindowsysteminterface_qpa.cpp | 4 ++ src/widgets/kernel/qapplication.cpp | 22 +------ .../kernel/qguiapplication/tst_qguiapplication.cpp | 75 ++++++++++++++++++++++ 4 files changed, 84 insertions(+), 21 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index e12183869a..5a95ebe848 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1005,6 +1005,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo } QWindow *window = e->window.data(); + modifier_buttons = e->modifiers; if (!window) window = QGuiApplication::topLevelAt(e->globalPos.toPoint()); @@ -1107,6 +1108,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh QPointF globalPoint = e->globalPos; QGuiApplicationPrivate::lastCursorPosition = globalPoint; + modifier_buttons = e->modifiers; QWindow *window = e->window.data(); @@ -1123,6 +1125,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e) { QWindow *window = e->window.data(); + modifier_buttons = e->modifiers; if (e->nullWindow) window = QGuiApplication::activeWindow(); if (!window) @@ -1280,6 +1283,7 @@ Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e) { QGuiApplicationPrivate *d = self; + modifier_buttons = e->modifiers; if (e->touchType == QEvent::TouchCancel) { // The touch sequence has been canceled (e.g. by the compositor). diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index 1953ce47bb..0aa9251642 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -158,6 +158,8 @@ bool QWindowSystemInterface::tryHandleSynchronousShortcutEvent(QWindow *w, int k bool QWindowSystemInterface::tryHandleSynchronousShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) { + QGuiApplicationPrivate::modifier_buttons = mods; + QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, text, autorep, count); qevent.setTimestamp(timestamp); return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent); @@ -175,6 +177,8 @@ bool QWindowSystemInterface::tryHandleSynchronousExtendedShortcutEvent(QWindow * quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text, bool autorep, ushort count) { + QGuiApplicationPrivate::modifier_buttons = mods; + QKeyEventEx qevent(QEvent::ShortcutOverride, k, mods, text, autorep, count, nativeScanCode, nativeVirtualKey, nativeModifiers); qevent.setTimestamp(timestamp); return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ce57e2868d..2615ac891d 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3014,34 +3014,14 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // capture the current mouse/keyboard state if(e->spontaneous()) { - if (e->type() == QEvent::KeyPress - || e->type() == QEvent::KeyRelease) { - QKeyEvent *ke = static_cast(e); - QApplicationPrivate::modifier_buttons = ke->modifiers(); - } else if(e->type() == QEvent::MouseButtonPress + if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease) { QMouseEvent *me = static_cast(e); - QApplicationPrivate::modifier_buttons = me->modifiers(); if(me->type() == QEvent::MouseButtonPress) QApplicationPrivate::mouse_buttons |= me->button(); else QApplicationPrivate::mouse_buttons &= ~me->button(); } -#if !defined(QT_NO_WHEELEVENT) || !defined(QT_NO_TABLETEVENT) - else if (false -# ifndef QT_NO_WHEELEVENT - || e->type() == QEvent::Wheel -# endif -# ifndef QT_NO_TABLETEVENT - || e->type() == QEvent::TabletMove - || e->type() == QEvent::TabletPress - || e->type() == QEvent::TabletRelease -# endif - ) { - QInputEvent *ie = static_cast(e); - QApplicationPrivate::modifier_buttons = ie->modifiers(); - } -#endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT } #ifndef QT_NO_GESTURES diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 0c009ec155..1dc2e551b4 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -55,6 +55,7 @@ private slots: void topLevelWindows(); void abortQuitOnShow(); void changeFocusWindow(); + void keyboardModifiers(); }; class DummyWindow : public QWindow @@ -239,6 +240,80 @@ void tst_QGuiApplication::changeFocusWindow() QCOMPARE(window1.windowDuringFocusOut, &window2); } +void tst_QGuiApplication::keyboardModifiers() +{ + int argc = 0; + QGuiApplication app(argc, 0); + + QWindow *window = new QWindow; + window->show(); + QTest::qWaitForWindowShown(window); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + + // mouse events + QPoint center = window->geometry().center(); + QTest::mouseEvent(QTest::MousePress, window, Qt::LeftButton, Qt::NoModifier, center); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + QTest::mouseEvent(QTest::MouseRelease, window, Qt::LeftButton, Qt::NoModifier, center); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + QTest::mouseEvent(QTest::MousePress, window, Qt::RightButton, Qt::ControlModifier, center); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); + QTest::mouseEvent(QTest::MouseRelease, window, Qt::RightButton, Qt::ControlModifier, center); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); + + // shortcut events + QWindowSystemInterface::tryHandleSynchronousShortcutEvent(window, Qt::Key_5, Qt::MetaModifier); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::MetaModifier); + QWindowSystemInterface::tryHandleSynchronousShortcutEvent(window, Qt::Key_Period, Qt::NoModifier); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + QWindowSystemInterface::tryHandleSynchronousShortcutEvent(window, Qt::Key_0, Qt::ControlModifier); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); + + // key events + QTest::keyEvent(QTest::Press, window, Qt::Key_C); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + QTest::keyEvent(QTest::Release, window, Qt::Key_C); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + + QTest::keyEvent(QTest::Press, window, Qt::Key_U, Qt::ControlModifier); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); + QTest::keyEvent(QTest::Release, window, Qt::Key_U, Qt::ControlModifier); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); + + QTest::keyEvent(QTest::Press, window, Qt::Key_T); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + QTest::keyEvent(QTest::Release, window, Qt::Key_T); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + + QTest::keyEvent(QTest::Press, window, Qt::Key_E, Qt::ControlModifier); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); + QTest::keyEvent(QTest::Release, window, Qt::Key_E, Qt::ControlModifier); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); + + // wheel events + QPoint global = window->mapToGlobal(center); + QPoint delta(0, 1); + QWindowSystemInterface::handleWheelEvent(window, center, global, delta, delta, Qt::NoModifier); + QWindowSystemInterface::sendWindowSystemEvents(app.eventDispatcher(), QEventLoop::AllEvents); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + QWindowSystemInterface::handleWheelEvent(window, center, global, delta, delta, Qt::AltModifier); + QWindowSystemInterface::sendWindowSystemEvents(app.eventDispatcher(), QEventLoop::AllEvents); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::AltModifier); + QWindowSystemInterface::handleWheelEvent(window, center, global, delta, delta, Qt::ControlModifier); + QWindowSystemInterface::sendWindowSystemEvents(app.eventDispatcher(), QEventLoop::AllEvents); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); + + // touch events + QList touchDevices = QTouchDevice::devices(); + if (!touchDevices.isEmpty()) { + QTouchDevice *touchDevice = const_cast(touchDevices.first()); + QTest::touchEvent(window, touchDevice).press(1, center).release(1, center); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); + } + + window->close(); + delete window; +} QTEST_APPLESS_MAIN(tst_QGuiApplication) #include "tst_qguiapplication.moc" -- cgit v1.2.3 From eac97c58308a04f0a1a23d02ea7a7289dfc9ebe9 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 20 Mar 2012 13:27:07 +0100 Subject: Cocoa: reimplement QPlatformBackingStore::scroll() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use qt_scrollImageInRect() from QtGui to accelerate scrolling in the Cocoa plugin. Change-Id: I8ad1377ed3307345f72d17c72049cec5472c97d3 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoabackingstore.h | 1 + src/plugins/platforms/cocoa/qcocoabackingstore.mm | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h index 794693627b..489938c4b3 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -60,6 +60,7 @@ public: QPaintDevice *paintDevice(); void flush(QWindow *widget, const QRegion ®ion, const QPoint &offset); void resize (const QSize &size, const QRegion &); + bool scroll(const QRegion &area, int dx, int dy); private: QCocoaWindow *m_cocoaWindow; diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 5e221ffd8b..3a55e00c48 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -97,4 +97,16 @@ void QCocoaBackingStore::resize(const QSize &size, const QRegion &) [static_cast(m_cocoaWindow->m_contentView) setImage:m_image]; } +bool QCocoaBackingStore::scroll(const QRegion &area, int dx, int dy) +{ + extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset); + QPoint qpoint(dx, dy); + const QVector qrects = area.rects(); + for (int i = 0; i < qrects.count(); ++i) { + const QRect &qrect = qrects.at(i); + qt_scrollRectInImage(*m_image, qrect, qpoint); + } + return true; +} + QT_END_NAMESPACE -- cgit v1.2.3 From cb33c3b2b64db43b81d81cf56fe1b2b0155a2839 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 23 Mar 2012 14:45:51 +0100 Subject: Remove dummy impl. of shared graphics cache in XCB plugin This implementation was disabled and didn't really work properly, so it doesn't make sense to update or do bug fixes to it. Removing it completely instead. Change-Id: I62abe35f0f9a91bb207b87296d25c3c62d58228e Reviewed-by: Jiang Jiang --- src/plugins/platforms/xcb/qxcbintegration.cpp | 29 - src/plugins/platforms/xcb/qxcbintegration.h | 8 - .../platforms/xcb/qxcbsharedbuffermanager.cpp | 640 --------------------- .../platforms/xcb/qxcbsharedbuffermanager.h | 215 ------- .../platforms/xcb/qxcbsharedgraphicscache.cpp | 290 ---------- .../platforms/xcb/qxcbsharedgraphicscache.h | 91 --- src/plugins/platforms/xcb/xcb.pro | 8 +- 7 files changed, 2 insertions(+), 1279 deletions(-) delete mode 100644 src/plugins/platforms/xcb/qxcbsharedbuffermanager.cpp delete mode 100644 src/plugins/platforms/xcb/qxcbsharedbuffermanager.h delete mode 100644 src/plugins/platforms/xcb/qxcbsharedgraphicscache.cpp delete mode 100644 src/plugins/platforms/xcb/qxcbsharedgraphicscache.h diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 50d3c4f1b5..255c49fb46 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -47,7 +47,6 @@ #include "qxcbnativeinterface.h" #include "qxcbclipboard.h" #include "qxcbdrag.h" -#include "qxcbsharedgraphicscache.h" #include @@ -118,10 +117,6 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters) #ifndef QT_NO_ACCESSIBILITY m_accessibility.reset(new QPlatformAccessibility()); #endif - -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) - m_sharedGraphicsCache.reset(new QXcbSharedGraphicsCache); -#endif } QXcbIntegration::~QXcbIntegration() @@ -203,10 +198,6 @@ QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *wind bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) - case SharedGraphicsCache: return true; -#endif - case ThreadedPixmaps: return true; case OpenGL: return true; case ThreadedOpenGL: return false; @@ -257,26 +248,6 @@ QPlatformAccessibility *QXcbIntegration::accessibility() const } #endif -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) -static bool sharedGraphicsCacheDisabled() -{ - static const char *environmentVariable = "QT_DISABLE_SHARED_CACHE"; - static bool cacheDisabled = !qgetenv(environmentVariable).isEmpty() - && qgetenv(environmentVariable).toInt() != 0; - return cacheDisabled; -} - -QPlatformSharedGraphicsCache *QXcbIntegration::createPlatformSharedGraphicsCache(const char *cacheId) const -{ - Q_UNUSED(cacheId); - - if (sharedGraphicsCacheDisabled()) - return 0; - - return m_sharedGraphicsCache.data(); -} -#endif - QPlatformServices *QXcbIntegration::services() const { return m_services.data(); diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index 58eebfe716..6170232d1e 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -81,10 +81,6 @@ public: QPlatformAccessibility *accessibility() const; #endif -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) - QPlatformSharedGraphicsCache *createPlatformSharedGraphicsCache(const char *cacheId) const; -#endif - QPlatformServices *services() const; QStringList themeNames() const; @@ -103,10 +99,6 @@ private: QScopedPointer m_accessibility; #endif -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) - QScopedPointer m_sharedGraphicsCache; -#endif - QScopedPointer m_services; }; diff --git a/src/plugins/platforms/xcb/qxcbsharedbuffermanager.cpp b/src/plugins/platforms/xcb/qxcbsharedbuffermanager.cpp deleted file mode 100644 index 8bd3aea259..0000000000 --- a/src/plugins/platforms/xcb/qxcbsharedbuffermanager.cpp +++ /dev/null @@ -1,640 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) - -#include "qxcbsharedbuffermanager.h" - -#include -#include - -#include - -#if !defined(SHAREDGRAPHICSCACHE_MAX_MEMORY_USED) -# define SHAREDGRAPHICSCACHE_MAX_MEMORY_USED 16 * 1024 * 1024 // 16 MB limit -#endif - -#if !defined(SHAREDGRAPHICSCACHE_MAX_TEXTURES_PER_CACHE) -# define SHAREDGRAPHICSCACHE_MAX_TEXTURES_PER_CACHE 1 -#endif - -#if !defined(SHAREDGRAPHICSCACHE_TEXTURE_SIZE) -# define SHAREDGRAPHICSCACHE_TEXTURE_SIZE 2048 -#endif - -#define SHAREDBUFFERMANAGER_DEBUG 1 - -QT_BEGIN_NAMESPACE - -QXcbSharedBufferManager::QXcbSharedBufferManager() - : m_memoryUsed(0) - , m_mostRecentlyUsed(0) - , m_leastRecentlyUsed(0) -{ -} - -QXcbSharedBufferManager::~QXcbSharedBufferManager() -{ - { - QHash::const_iterator it = m_buffers.constBegin(); - while (it != m_buffers.constEnd()) { - Buffer *buffer = it.value(); - delete buffer; - ++it; - } - } - - { - QHash::const_iterator it = m_items.constBegin(); - while (it != m_items.constEnd()) { - Items *items = it.value(); - QHash::const_iterator itemIt = items->items.constBegin(); - while (itemIt != items->items.constEnd()) { - delete itemIt.value(); - ++itemIt; - } - delete it.value(); - ++it; - } - } -} - -void QXcbSharedBufferManager::getBufferForItem(const QByteArray &cacheId, quint32 itemId, - Buffer **buffer, int *x, int *y) const -{ - Q_ASSERT_X(m_currentCacheId.isEmpty(), Q_FUNC_INFO, - "Call endSharedBufferAction before accessing data"); - - Q_ASSERT(buffer != 0); - Q_ASSERT(x != 0); - Q_ASSERT(y != 0); - - Items *items = itemsForCache(cacheId); - Item *item = items->items.value(itemId); - if (item != 0) { - *buffer = item->buffer; - *x = item->x; - *y = item->y; - } else { - *buffer = 0; - *x = -1; - *y = -1; - } -} - -QPair QXcbSharedBufferManager::serializeBuffer(QSharedMemory *buffer) const -{ - Q_ASSERT_X(m_currentCacheId.isEmpty(), Q_FUNC_INFO, - "Call endSharedBufferAction before accessing data"); - - return qMakePair(buffer->key().toLatin1(), 0); -} - -void QXcbSharedBufferManager::beginSharedBufferAction(const QByteArray &cacheId) -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::beginSharedBufferAction() called for %s", cacheId.constData()); -#endif - - Q_ASSERT(m_currentCacheId.isEmpty()); - Q_ASSERT(!cacheId.isEmpty()); - - m_pendingInvalidatedItems.clear(); - m_pendingReadyItems.clear(); - m_pendingMissingItems.clear(); - - m_currentCacheId = cacheId; -} - -void QXcbSharedBufferManager::requestItems(const QSet &itemIds) -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::requestItems for %d items", itemIds.size()); -#endif - - Q_ASSERT_X(!m_currentCacheId.isEmpty(), Q_FUNC_INFO, - "Call beginSharedBufferAction before requesting items"); - Items *items = itemsForCache(m_currentCacheId); - - QSet::const_iterator it = itemIds.constBegin(); - while (it != itemIds.constEnd()) { - if (items->items.contains(*it)) - m_pendingReadyItems[m_currentCacheId].insert(*it); - else - m_pendingMissingItems[m_currentCacheId].insert(*it); - ++it; - } -} - -void QXcbSharedBufferManager::releaseItems(const QSet &itemIds) -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::releaseItems for %d items", itemIds.size()); -#endif - - Items *items = itemsForCache(m_currentCacheId); - - QSet::const_iterator it; - for (it = itemIds.constBegin(); it != itemIds.constEnd(); ++it) { - Item *item = items->items.value(*it); - if (item != 0) - pushItemToBack(items, item); - - m_pendingReadyItems[m_currentCacheId].remove(*it); - m_pendingMissingItems[m_currentCacheId].remove(*it); - } -} - -void QXcbSharedBufferManager::insertItem(quint32 itemId, uchar *data, - int itemWidth, int itemHeight) -{ - Q_ASSERT_X(!m_currentCacheId.isEmpty(), Q_FUNC_INFO, - "Call beginSharedBufferAction before inserting items"); - Items *items = itemsForCache(m_currentCacheId); - - if (!items->items.contains(itemId)) { - Buffer *sharedBuffer = 0; - int x = 0; - int y = 0; - - findAvailableBuffer(itemWidth, itemHeight, &sharedBuffer, &x, &y); - copyIntoBuffer(sharedBuffer, x, y, itemWidth, itemHeight, data); - -// static int counter=0; -// QString fileName = QString::fromLatin1("buffer%1.png").arg(counter++); -// saveBuffer(sharedBuffer, fileName); - - Item *item = new Item; - item->itemId = itemId; - item->buffer = sharedBuffer; - item->x = x; - item->y = y; - - items->items[itemId] = item; - - touchItem(items, item); - } -} - -void QXcbSharedBufferManager::endSharedBufferAction() -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::endSharedBufferAction() called for %s", - m_currentCacheId.constData()); -#endif - - Q_ASSERT(!m_currentCacheId.isEmpty()); - - // Do an extra validation pass on the invalidated items since they may have been re-inserted - // after they were invalidated - if (m_pendingInvalidatedItems.contains(m_currentCacheId)) { - QSet &invalidatedItems = m_pendingInvalidatedItems[m_currentCacheId]; - QSet::iterator it = invalidatedItems.begin(); - while (it != invalidatedItems.end()) { - Items *items = m_items.value(m_currentCacheId); - - if (items->items.contains(*it)) { - m_pendingReadyItems[m_currentCacheId].insert(*it); - it = invalidatedItems.erase(it); - } else { - ++it; - } - } - } - - m_currentCacheId.clear(); -} - -void QXcbSharedBufferManager::pushItemToBack(Items *items, Item *item) -{ - if (items->leastRecentlyUsed == item) - return; - - if (item->next != 0) - item->next->prev = item->prev; - if (item->prev != 0) - item->prev->next = item->next; - - if (items->mostRecentlyUsed == item) - items->mostRecentlyUsed = item->prev; - - if (items->leastRecentlyUsed != 0) - items->leastRecentlyUsed->prev = item; - - item->prev = 0; - item->next = items->leastRecentlyUsed; - items->leastRecentlyUsed = item; - if (items->mostRecentlyUsed == 0) - items->mostRecentlyUsed = item; -} - -void QXcbSharedBufferManager::touchItem(Items *items, Item *item) -{ - if (items->mostRecentlyUsed == item) - return; - - if (item->next != 0) - item->next->prev = item->prev; - if (item->prev != 0) - item->prev->next = item->next; - - if (items->leastRecentlyUsed == item) - items->leastRecentlyUsed = item->next; - - if (items->mostRecentlyUsed != 0) - items->mostRecentlyUsed->next = item; - - item->next = 0; - item->prev = items->mostRecentlyUsed; - items->mostRecentlyUsed = item; - if (items->leastRecentlyUsed == 0) - items->leastRecentlyUsed = item; -} - -void QXcbSharedBufferManager::deleteItem(Items *items, Item *item) -{ - Q_ASSERT(items != 0); - Q_ASSERT(item != 0); - - if (items->mostRecentlyUsed == item) - items->mostRecentlyUsed = item->prev; - if (items->leastRecentlyUsed == item) - items->leastRecentlyUsed = item->next; - - if (item->next != 0) - item->next->prev = item->prev; - if (item->prev != 0) - item->prev->next = item->next; - - m_pendingInvalidatedItems[items->cacheId].insert(item->itemId); - - { - QHash::iterator it = items->items.find(item->itemId); - while (it != items->items.end() && it.value()->itemId == item->itemId) - it = items->items.erase(it); - } - - delete item; -} - -void QXcbSharedBufferManager::recycleItem(Buffer **sharedBuffer, int *glyphX, int *glyphY) -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::recycleItem() called for %s", m_currentCacheId.constData()); -#endif - - Items *items = itemsForCache(m_currentCacheId); - - Item *recycledItem = items->leastRecentlyUsed; - Q_ASSERT(recycledItem != 0); - - *sharedBuffer = recycledItem->buffer; - *glyphX = recycledItem->x; - *glyphY = recycledItem->y; - - deleteItem(items, recycledItem); -} - -void QXcbSharedBufferManager::touchBuffer(Buffer *buffer) -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::touchBuffer() called for %s", buffer->cacheId.constData()); -#endif - - if (buffer == m_mostRecentlyUsed) - return; - - if (buffer->next != 0) - buffer->next->prev = buffer->prev; - if (buffer->prev != 0) - buffer->prev->next = buffer->next; - - if (m_leastRecentlyUsed == buffer) - m_leastRecentlyUsed = buffer->next; - - buffer->next = 0; - buffer->prev = m_mostRecentlyUsed; - if (m_mostRecentlyUsed != 0) - m_mostRecentlyUsed->next = buffer; - if (m_leastRecentlyUsed == 0) - m_leastRecentlyUsed = buffer; - m_mostRecentlyUsed = buffer; -} - -void QXcbSharedBufferManager::deleteLeastRecentlyUsed() -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::deleteLeastRecentlyUsed() called"); -#endif - - if (m_leastRecentlyUsed == 0) - return; - - Buffer *old = m_leastRecentlyUsed; - m_leastRecentlyUsed = old->next; - m_leastRecentlyUsed->prev = 0; - - QByteArray cacheId = old->cacheId; - Items *items = itemsForCache(cacheId); - - QHash::iterator it = items->items.begin(); - while (it != items->items.end()) { - Item *item = it.value(); - if (item->buffer == old) { - deleteItem(items, item); - it = items->items.erase(it); - } else { - ++it; - } - } - - m_buffers.remove(cacheId, old); - m_memoryUsed -= old->width * old->height * old->bytesPerPixel; - -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::deleteLeastRecentlyUsed: Memory used: %d / %d (%6.2f %%)", - m_memoryUsed, SHAREDGRAPHICSCACHE_MAX_MEMORY_USED, - 100.0f * float(m_memoryUsed) / float(SHAREDGRAPHICSCACHE_MAX_MEMORY_USED)); -#endif - - delete old; -} - -QXcbSharedBufferManager::Buffer *QXcbSharedBufferManager::createNewBuffer(const QByteArray &cacheId, - int heightRequired) -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::createNewBuffer() called for %s", cacheId.constData()); -#endif - - // ### - // if (bufferCount of cacheId == SHAREDGRAPHICACHE_MAX_TEXTURES_PER_CACHE) - // deleteLeastRecentlyUsedBufferForCache(cacheId); - - // ### Take pixel format into account - while (m_memoryUsed + SHAREDGRAPHICSCACHE_TEXTURE_SIZE * heightRequired >= SHAREDGRAPHICSCACHE_MAX_MEMORY_USED) - deleteLeastRecentlyUsed(); - - Buffer *buffer = allocateBuffer(SHAREDGRAPHICSCACHE_TEXTURE_SIZE, heightRequired); - buffer->cacheId = cacheId; - - buffer->currentLineMaxHeight = 0; - m_buffers.insert(cacheId, buffer); - - return buffer; -} - -static inline int qt_next_power_of_two(int v) -{ - v--; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - ++v; - return v; -} - -QXcbSharedBufferManager::Buffer *QXcbSharedBufferManager::resizeBuffer(Buffer *oldBuffer, const QSize &newSize) -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::resizeBuffer() called for %s (current size: %dx%d, new size: %dx%d)", - oldBuffer->cacheId.constData(), oldBuffer->width, oldBuffer->height, - newSize.width(), newSize.height()); -#endif - - // Remove old buffer from lists to avoid deleting it under our feet - if (m_leastRecentlyUsed == oldBuffer) - m_leastRecentlyUsed = oldBuffer->next; - if (m_mostRecentlyUsed == oldBuffer) - m_mostRecentlyUsed = oldBuffer->prev; - - if (oldBuffer->prev != 0) - oldBuffer->prev->next = oldBuffer->next; - if (oldBuffer->next != 0) - oldBuffer->next->prev = oldBuffer->prev; - - m_memoryUsed -= oldBuffer->width * oldBuffer->height * oldBuffer->bytesPerPixel; - m_buffers.remove(oldBuffer->cacheId, oldBuffer); - -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::resizeBuffer: Memory used: %d / %d (%6.2f %%)", - m_memoryUsed, SHAREDGRAPHICSCACHE_MAX_MEMORY_USED, - 100.0f * float(m_memoryUsed) / float(SHAREDGRAPHICSCACHE_MAX_MEMORY_USED)); -#endif - - Buffer *resizedBuffer = createNewBuffer(oldBuffer->cacheId, newSize.height()); - copyIntoBuffer(resizedBuffer, 0, 0, oldBuffer->width, oldBuffer->height, - reinterpret_cast(oldBuffer->buffer->data())); - - resizedBuffer->currentLineMaxHeight = oldBuffer->currentLineMaxHeight; - - Items *items = itemsForCache(oldBuffer->cacheId); - QHash::const_iterator it = items->items.constBegin(); - while (it != items->items.constEnd()) { - Item *item = it.value(); - if (item->buffer == oldBuffer) { - m_pendingReadyItems[oldBuffer->cacheId].insert(item->itemId); - item->buffer = resizedBuffer; - } - ++it; - } - - resizedBuffer->nextX = oldBuffer->nextX; - resizedBuffer->nextY = oldBuffer->nextY; - resizedBuffer->currentLineMaxHeight = oldBuffer->currentLineMaxHeight; - - delete oldBuffer; - return resizedBuffer; -} - -void QXcbSharedBufferManager::findAvailableBuffer(int itemWidth, int itemHeight, - Buffer **sharedBuffer, int *glyphX, int *glyphY) -{ - Q_ASSERT(sharedBuffer != 0); - Q_ASSERT(glyphX != 0); - Q_ASSERT(glyphY != 0); - - QMultiHash::iterator it = m_buffers.find(m_currentCacheId); - - int bufferCount = 0; - while (it != m_buffers.end() && it.key() == m_currentCacheId) { - Buffer *buffer = it.value(); - - int x = buffer->nextX; - int y = buffer->nextY; - int width = buffer->width; - int height = buffer->height; - - if (x + itemWidth <= width && y + itemHeight <= height) { - // There is space on the current line, put the item there - buffer->currentLineMaxHeight = qMax(buffer->currentLineMaxHeight, itemHeight); - *sharedBuffer = buffer; - *glyphX = x; - *glyphY = y; - - buffer->nextX += itemWidth; - - return; - } else if (itemWidth <= width && y + buffer->currentLineMaxHeight + itemHeight <= height) { - // There is space for a new line, put the item on the new line - buffer->nextX = 0; - buffer->nextY += buffer->currentLineMaxHeight; - buffer->currentLineMaxHeight = 0; - - *sharedBuffer = buffer; - *glyphX = buffer->nextX; - *glyphY = buffer->nextY; - - buffer->nextX += itemWidth; - - return; - } else if (y + buffer->currentLineMaxHeight + itemHeight <= SHAREDGRAPHICSCACHE_TEXTURE_SIZE) { - // There is space if we resize the buffer, so we do that - int newHeight = qt_next_power_of_two(y + buffer->currentLineMaxHeight + itemHeight); - buffer = resizeBuffer(buffer, QSize(width, newHeight)); - - buffer->nextX = 0; - buffer->nextY += buffer->currentLineMaxHeight; - buffer->currentLineMaxHeight = 0; - - *sharedBuffer = buffer; - *glyphX = buffer->nextX; - *glyphY = buffer->nextY; - - buffer->nextX += itemWidth; - return; - } - - bufferCount++; - ++it; - } - - if (bufferCount == SHAREDGRAPHICSCACHE_MAX_TEXTURES_PER_CACHE) { - // There is no space in any buffer, and there is no space for a new buffer - // recycle an old item - recycleItem(sharedBuffer, glyphX, glyphY); - } else { - // Create a new buffer for the item - *sharedBuffer = createNewBuffer(m_currentCacheId, qt_next_power_of_two(itemHeight)); - if (*sharedBuffer == 0) { - Q_ASSERT(false); - return; - } - - *glyphX = (*sharedBuffer)->nextX; - *glyphY = (*sharedBuffer)->nextY; - - (*sharedBuffer)->nextX += itemWidth; - } -} - -QXcbSharedBufferManager::Buffer *QXcbSharedBufferManager::allocateBuffer(int width, int height) -{ - Buffer *buffer = new Buffer; - buffer->nextX = 0; - buffer->nextY = 0; - buffer->width = width; - buffer->height = height; - buffer->bytesPerPixel = 1; // ### Use pixel format here - - buffer->buffer = new QSharedMemory(QUuid::createUuid().toString()); - bool ok = buffer->buffer->create(buffer->width * buffer->height * buffer->bytesPerPixel, - QSharedMemory::ReadWrite); - if (!ok) { - qWarning("QXcbSharedBufferManager::findAvailableBuffer: Can't create new buffer (%s)", - qPrintable(buffer->buffer->errorString())); - delete buffer; - return 0; - } - qMemSet(buffer->buffer->data(), 0, buffer->buffer->size()); - - m_memoryUsed += buffer->width * buffer->height * buffer->bytesPerPixel; - -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::allocateBuffer: Memory used: %d / %d (%6.2f %%)", - int(m_memoryUsed), int(SHAREDGRAPHICSCACHE_MAX_MEMORY_USED), - 100.0f * float(m_memoryUsed) / float(SHAREDGRAPHICSCACHE_MAX_MEMORY_USED)); -#endif - - return buffer; -} - -void QXcbSharedBufferManager::copyIntoBuffer(Buffer *buffer, - int bufferX, int bufferY, int width, int height, - uchar *data) -{ -#if defined(SHAREDBUFFERMANAGER_DEBUG) - qDebug("QXcbSharedBufferManager::copyIntoBuffer() called for %s (coords: %d, %d)", - buffer->cacheId.constData(), bufferX, bufferY); -#endif - - Q_ASSERT(bufferX >= 0); - Q_ASSERT(bufferX + width <= buffer->width); - Q_ASSERT(bufferY >= 0); - Q_ASSERT(bufferY + height <= buffer->height); - - uchar *dest = reinterpret_cast(buffer->buffer->data()); - dest += bufferX + bufferY * buffer->width; - for (int y=0; ywidth; - } -} - -QXcbSharedBufferManager::Items *QXcbSharedBufferManager::itemsForCache(const QByteArray &cacheId) const -{ - Items *items = m_items.value(cacheId); - if (items == 0) { - items = new Items; - items->cacheId = cacheId; - m_items[cacheId] = items; - } - - return items; -} - -QT_END_NAMESPACE - -#endif // QT_USE_XCB_SHARED_GRAPHICS_CACHE diff --git a/src/plugins/platforms/xcb/qxcbsharedbuffermanager.h b/src/plugins/platforms/xcb/qxcbsharedbuffermanager.h deleted file mode 100644 index ca79b502c2..0000000000 --- a/src/plugins/platforms/xcb/qxcbsharedbuffermanager.h +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCBSHAREDBUFFERMANAGER_H -#define XCBSHAREDBUFFERMANAGER_H - -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) - -#include -#include -#include - -#include - -#include - -#include - -class wl_resource; - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QXcbSharedBufferManager -{ -public: - struct Buffer { - Buffer() - : width(-1) - , height(-1) - , bytesPerPixel(1) - , nextX(-1) - , nextY(-1) - , currentLineMaxHeight(0) - , next(0) - , prev(0) - , buffer(0) - , textureId(0) - { - } - - ~Buffer() - { - delete buffer; - - if (textureId != 0) - glDeleteTextures(1, &textureId); - } - - QByteArray cacheId; - int width; - int height; - int bytesPerPixel; - int nextX; - int nextY; - int currentLineMaxHeight; - - Buffer *next; - Buffer *prev; - - QSharedMemory *buffer; - - GLuint textureId; - - QAtomicInt ref; - }; - - typedef QHash > PendingItemIds; - - QXcbSharedBufferManager(); - ~QXcbSharedBufferManager(); - - void beginSharedBufferAction(const QByteArray &cacheId); - void insertItem(quint32 itemId, uchar *data, int itemWidth, int itemHeight); - void requestItems(const QSet &itemIds); - void releaseItems(const QSet &itemIds); - void endSharedBufferAction(); - - void getBufferForItem(const QByteArray &cacheId, quint32 itemId, Buffer **buffer, - int *x, int *y) const; - QPair serializeBuffer(QSharedMemory *buffer) const; - - PendingItemIds pendingItemsInvalidated() const - { - Q_ASSERT_X(m_currentCacheId.isEmpty(), Q_FUNC_INFO, - "Call endSharedBufferAction() before accessing data"); - return m_pendingInvalidatedItems; - } - - PendingItemIds pendingItemsReady() const - { - Q_ASSERT_X(m_currentCacheId.isEmpty(), Q_FUNC_INFO, - "Call endSharedBufferAction() before accessing data"); - return m_pendingReadyItems; - } - - PendingItemIds pendingItemsMissing() const - { - Q_ASSERT_X(m_currentCacheId.isEmpty(), Q_FUNC_INFO, - "Call endSharedBufferAction() before accessing data"); - return m_pendingMissingItems; - } - -private: - struct Item { - Item() - : next(0) - , prev(0) - , buffer(0) - , itemId(0) - , x(-1) - , y(-1) - , width(-1) - , height(-1) - { - } - - Item *next; - Item *prev; - - Buffer *buffer; - quint32 itemId; - int x; - int y; - int width; - int height; - }; - - struct Items - { - Items() : leastRecentlyUsed(0), mostRecentlyUsed(0) {} - - Item *leastRecentlyUsed; - Item *mostRecentlyUsed; - - QByteArray cacheId; - QHash items; - }; - - void findAvailableBuffer(int itemWidth, int itemHeight, Buffer **buffer, int *x, int *y); - void recycleItem(Buffer **buffer, int *x, int *y); - void copyIntoBuffer(Buffer *buffer, int x, int y, int itemWidth, int itemHeight, uchar *data); - void touchBuffer(Buffer *buffer); - void deleteLeastRecentlyUsed(); - - Buffer *createNewBuffer(const QByteArray &cacheId, int heightRequired); - Buffer *resizeBuffer(Buffer *buffer, const QSize &newSize); - Buffer *allocateBuffer(int width, int height); - - Items *itemsForCache(const QByteArray &cacheId) const; - void pushItemToBack(Items *items, Item *item); - void touchItem(Items *items, Item *item); - void deleteItem(Items *items, Item *item); - void recycleItem(const QByteArray &cacheId, Buffer **sharedBuffer, int *glyphX, int *glyphY); - - QByteArray m_currentCacheId; - - quint32 m_memoryUsed; - Buffer *m_mostRecentlyUsed; - Buffer *m_leastRecentlyUsed; - - mutable QHash m_items; - QMultiHash m_buffers; - - PendingItemIds m_pendingInvalidatedItems; - PendingItemIds m_pendingReadyItems; - PendingItemIds m_pendingMissingItems; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QT_USE_XCB_SHARED_GRAPHICS_CACHE - -#endif // XCBSHAREDBUFFERMANAGER_H diff --git a/src/plugins/platforms/xcb/qxcbsharedgraphicscache.cpp b/src/plugins/platforms/xcb/qxcbsharedgraphicscache.cpp deleted file mode 100644 index fa937504ad..0000000000 --- a/src/plugins/platforms/xcb/qxcbsharedgraphicscache.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) - -#include "qxcbsharedgraphicscache.h" -#include "qxcbsharedbuffermanager.h" - -#include - -#include -#include - -#define GL_GLEXT_PROTOTYPES -#include - -#define SHAREDGRAPHICSCACHE_DEBUG 1 - -QT_BEGIN_NAMESPACE - -QXcbSharedGraphicsCache::QXcbSharedGraphicsCache(QObject *parent) - : QPlatformSharedGraphicsCache(parent) - , m_bufferManager(new QXcbSharedBufferManager) -{ -} - -void QXcbSharedGraphicsCache::requestItems(const QByteArray &cacheId, - const QVector &itemIds) -{ - m_bufferManager->beginSharedBufferAction(cacheId); - - QSet itemsForRequest; - for (int i=0; irequestItems(itemsForRequest); - m_bufferManager->endSharedBufferAction(); - - processPendingItems(); -} - -void QXcbSharedGraphicsCache::insertItems(const QByteArray &cacheId, - const QVector &itemIds, - const QVector &items) -{ - m_bufferManager->beginSharedBufferAction(cacheId); - - QSet itemsForRequest; - for (int i=0; iinsertItem(itemIds.at(i), image.bits(), image.width(), image.height()); - itemsForRequest.insert(itemIds.at(i)); - } - - // ### To avoid loops, we could check missing items here and notify the client - m_bufferManager->requestItems(itemsForRequest); - - m_bufferManager->endSharedBufferAction(); - - processPendingItems(); -} - -void QXcbSharedGraphicsCache::ensureCacheInitialized(const QByteArray &cacheId, - BufferType bufferType, - PixelFormat pixelFormat) -{ - Q_UNUSED(cacheId); - Q_UNUSED(bufferType); - Q_UNUSED(pixelFormat); -} - - -void QXcbSharedGraphicsCache::releaseItems(const QByteArray &cacheId, - const QVector &itemIds) -{ - m_bufferManager->beginSharedBufferAction(cacheId); - - QSet itemsToRelease; - for (int i=0; ireleaseItems(itemsToRelease); - - m_bufferManager->endSharedBufferAction(); - - processPendingItems(); -} - -void QXcbSharedGraphicsCache::serializeBuffer(void *bufferId, - QByteArray *serializedData, - int *fileDescriptor) const -{ - QXcbSharedBufferManager::Buffer *buffer = - reinterpret_cast(bufferId); - - QPair bufferName = m_bufferManager->serializeBuffer(buffer->buffer); - - *serializedData = bufferName.first; - *fileDescriptor = bufferName.second; -} - -GLuint QXcbSharedGraphicsCache::textureIdForBuffer(void *bufferId) -{ -# if defined(SHAREDGRAPHICSCACHE_DEBUG) - qDebug("QXcbSharedGraphicsCache::textureIdForBuffer"); -# endif - - QXcbSharedBufferManager::Buffer *buffer = - reinterpret_cast(bufferId); - - if (buffer->textureId == 0) { - glGenTextures(1, &buffer->textureId); - if (buffer->textureId == 0) { - qWarning("QXcbSharedGraphicsCache::textureIdForBuffer: Failed to generate texture (gl error: 0x%x)", - glGetError()); - return 0; - } - - glBindTexture(GL_TEXTURE_2D, buffer->textureId); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - - glBindTexture(GL_TEXTURE_2D, buffer->textureId); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, buffer->width, buffer->height, 0, GL_ALPHA, - GL_UNSIGNED_BYTE, buffer->buffer->data()); - glBindTexture(GL_TEXTURE_2D, 0); - - return buffer->textureId; -} - -void QXcbSharedGraphicsCache::referenceBuffer(void *bufferId) -{ - QXcbSharedBufferManager::Buffer *buffer = - reinterpret_cast(bufferId); - - buffer->ref.ref(); -} - -bool QXcbSharedGraphicsCache::dereferenceBuffer(void *bufferId) -{ - QXcbSharedBufferManager::Buffer *buffer = - reinterpret_cast(bufferId); - - if (buffer->ref.deref()) - return true; - - if (buffer->textureId != 0) { - glDeleteTextures(1, &buffer->textureId); - buffer->textureId = 0; - } - - return false; -} - -void QXcbSharedGraphicsCache::processPendingItems() -{ -# if defined(SHAREDGRAPHICSCACHE_DEBUG) - qDebug("QXcbSharedGraphicsCache::processPendingItems"); -# endif - - { - QXcbSharedBufferManager::PendingItemIds pendingMissingItems = m_bufferManager->pendingItemsMissing(); - QXcbSharedBufferManager::PendingItemIds::const_iterator it; - - - for (it = pendingMissingItems.constBegin(); it != pendingMissingItems.constEnd(); ++it) { - QVector missingItems; - - const QSet &items = it.value(); - QSet::const_iterator itemIt; - for (itemIt = items.constBegin(); itemIt != items.constEnd(); ++itemIt) - missingItems.append(*itemIt); - -# if defined(SHAREDGRAPHICSCACHE_DEBUG) - qDebug("QXcbSharedGraphicsCache::processPendingItems: %d missing items", - missingItems.size()); -# endif - - if (!missingItems.isEmpty()) - emit itemsMissing(it.key(), missingItems); - } - } - - { - QXcbSharedBufferManager::PendingItemIds pendingInvalidatedItems = m_bufferManager->pendingItemsInvalidated(); - QXcbSharedBufferManager::PendingItemIds::const_iterator it; - - for (it = pendingInvalidatedItems.constBegin(); it != pendingInvalidatedItems.constEnd(); ++it) { - QVector invalidatedItems; - - const QSet &items = it.value(); - QSet::const_iterator itemIt; - for (itemIt = items.constBegin(); itemIt != items.constEnd(); ++itemIt) - invalidatedItems.append(*itemIt); - -# if defined(SHAREDGRAPHICSCACHE_DEBUG) - qDebug("QXcbSharedGraphicsCache::processPendingItems: %d invalidated items", - invalidatedItems.size()); -# endif - - if (!invalidatedItems.isEmpty()) - emit itemsInvalidated(it.key(), invalidatedItems); - } - } - - { - QXcbSharedBufferManager::PendingItemIds pendingReadyItems = m_bufferManager->pendingItemsReady(); - QXcbSharedBufferManager::PendingItemIds::const_iterator it; - - for (it = pendingReadyItems.constBegin(); it != pendingReadyItems.constEnd(); ++it) { - QHash readyItemsForBuffer; - const QSet &items = it.value(); - - QByteArray cacheId = it.key(); - - QSet::const_iterator itemIt; - for (itemIt = items.constBegin(); itemIt != items.constEnd(); ++itemIt) { - QXcbSharedBufferManager::Buffer *buffer; - int x = -1; - int y = -1; - - m_bufferManager->getBufferForItem(cacheId, *itemIt, &buffer, &x, &y); - - readyItemsForBuffer[buffer].itemIds.append(*itemIt); - readyItemsForBuffer[buffer].positions.append(QPoint(x, y)); - } - - QHash::iterator readyItemIt - = readyItemsForBuffer.begin(); - while (readyItemIt != readyItemsForBuffer.end()) { - QXcbSharedBufferManager::Buffer *buffer = readyItemIt.key(); - if (!readyItemIt.value().itemIds.isEmpty()) { -# if defined(SHAREDGRAPHICSCACHE_DEBUG) - qDebug("QXcbSharedGraphicsCache::processPendingItems: %d ready items", - readyItemIt.value().itemIds.size()); -# endif - - emit itemsAvailable(cacheId, buffer, QSize(buffer->width, buffer->height), - readyItemIt.value().itemIds, readyItemIt.value().positions); - } - ++readyItemIt; - } - } - } -} - -QT_END_NAMESPACE - -#endif // QT_USE_XCB_SHARED_GRAPHICS_CACHE diff --git a/src/plugins/platforms/xcb/qxcbsharedgraphicscache.h b/src/plugins/platforms/xcb/qxcbsharedgraphicscache.h deleted file mode 100644 index e565556463..0000000000 --- a/src/plugins/platforms/xcb/qxcbsharedgraphicscache.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QXCBSHAREDGRAPHICSCACHE -#define QXCBSHAREDGRAPHICSCACHE - -#if defined(QT_USE_XCB_SHARED_GRAPHICS_CACHE) - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QXcbSharedBufferManager; -class QXcbSharedGraphicsCache : public QPlatformSharedGraphicsCache -{ - Q_OBJECT -public: - explicit QXcbSharedGraphicsCache(QObject *parent = 0); - - virtual void ensureCacheInitialized(const QByteArray &cacheId, BufferType bufferType, - PixelFormat pixelFormat); - - virtual void requestItems(const QByteArray &cacheId, const QVector &itemIds); - virtual void insertItems(const QByteArray &cacheId, - const QVector &itemIds, - const QVector &items); - virtual void releaseItems(const QByteArray &cacheId, const QVector &itemIds); - - virtual void serializeBuffer(void *bufferId, QByteArray *serializedData, int *fileDescriptor) const; - virtual uint textureIdForBuffer(void *bufferId); - virtual void referenceBuffer(void *bufferId); - virtual bool dereferenceBuffer(void *bufferId); - -private: - struct ReadyItem { - QVector itemIds; - QVector positions; - }; - - void processPendingItems(); - - QXcbSharedBufferManager *m_bufferManager; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QT_USE_XCB_SHARED_GRAPHICS_CACHE - -#endif // QXCBSHAREDGRAPHICSCACHE diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 0f059341e4..0da5fb1674 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -20,9 +20,7 @@ SOURCES = \ main.cpp \ qxcbnativeinterface.cpp \ qxcbcursor.cpp \ - qxcbimage.cpp \ - qxcbsharedbuffermanager.cpp \ - qxcbsharedgraphicscache.cpp + qxcbimage.cpp HEADERS = \ qxcbclipboard.h \ @@ -38,9 +36,7 @@ HEADERS = \ qxcbwmsupport.h \ qxcbnativeinterface.h \ qxcbcursor.h \ - qxcbimage.h \ - qxcbsharedbuffermanager.h \ - qxcbsharedgraphicscache.h + qxcbimage.h contains(QT_CONFIG, xcb-poll-for-queued-event) { DEFINES += XCB_POLL_FOR_QUEUED_EVENT -- cgit v1.2.3 From 3c3c445dafc2e0d6ef2af1b9af17a66484131cbc Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 22 Mar 2012 13:14:24 +0100 Subject: Fix for fontconfig 2.9 behavior change Start from 2.9, fontconfig will reset the result to FcResultNoMatch at the beginning of FcFontSort(). According to http://lists.freedesktop.org/archives/fontconfig/2012-March/003857.html the result value of FcFontSort() can be ignored, checking the nfont value of the fontset returned is sufficient. The fix works for pre-2.9 versions as well, since those versions don't touch the result at all. Change-Id: Iba6c1157e314088a90867292a4bd970bb873e284 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/fontconfig/qfontconfigdatabase.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 279a1fbc22..bf05433b22 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -641,17 +641,15 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const FcPatternDestroy(pattern); if (fontSet) { - if (result == FcResultMatch) { - for (int i = 0; i < fontSet->nfont; i++) { - FcChar8 *value = 0; - if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch) - continue; - // capitalize(value); - QString familyName = QString::fromUtf8((const char *)value); - if (!fallbackFamilies.contains(familyName,Qt::CaseInsensitive) && - familyName.compare(family, Qt::CaseInsensitive)) { - fallbackFamilies << familyName; - } + for (int i = 0; i < fontSet->nfont; i++) { + FcChar8 *value = 0; + if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch) + continue; + // capitalize(value); + QString familyName = QString::fromUtf8((const char *)value); + if (!fallbackFamilies.contains(familyName,Qt::CaseInsensitive) && + familyName.compare(family, Qt::CaseInsensitive)) { + fallbackFamilies << familyName; } } FcFontSetDestroy(fontSet); -- cgit v1.2.3 From 8dac4d367fb53abc95b1054a7b5baa49c9af7a75 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Mar 2012 10:49:39 +0100 Subject: Cocoa: reimplement QPlatformWindow::setOpacity() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt and Cocoa opacity levels are compatible, so we just need to forward the setOpacity() argument to [NSWindow setAlphaValue] Change-Id: I5fd5678894fd6949811ad1c4b493e592561f01f6 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 94d166b7a5..184422a04a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -99,6 +99,7 @@ public: void raise(); void lower(); void propagateSizeHints(); + void setOpacity(qreal level); bool setKeyboardGrabEnabled(bool grab); bool setMouseGrabEnabled(bool grab); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index b5e8ff2246..7282a8d776 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -233,6 +233,12 @@ void QCocoaWindow::propagateSizeHints() } } +void QCocoaWindow::setOpacity(qreal level) +{ + if (m_nsWindow) + [m_nsWindow setAlphaValue:level]; +} + bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) { if (!m_nsWindow) -- cgit v1.2.3 From 083052933fefacbc91930bc2cb6505ecf592adaa Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 24 Mar 2012 10:48:12 +0200 Subject: Test mouse events more thoroughly in QWindow autotest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently there are still issues here and there (e.g. in declarative) with properly recognizing more complex event sequences (like triple clicks). The behavior of qtbase is correct but we need a test case that makes sure the functionality will not regress. Change-Id: I08c558fcfdde0dd06e194b4f0affc6f6896573bf Reviewed-by: Samuel Rødal --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 123 ++++++++++++++++++++++++-- 1 file changed, 118 insertions(+), 5 deletions(-) diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index f4556f7e32..dc17ec653c 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -44,6 +44,7 @@ #include #include +#include // For QSignalSpy slot connections. Q_DECLARE_METATYPE(Qt::ScreenOrientation) @@ -65,6 +66,7 @@ private slots: void orientation(); void close(); void activateAndClose(); + void mouseEventSequence(); void initTestCase() { @@ -258,15 +260,20 @@ public: if (ignoreMouse) { event->ignore(); } else { + ++mousePressedCount; + mouseSequenceSignature += 'p'; mousePressButton = event->button(); mousePressScreenPos = event->screenPos(); } } void mouseReleaseEvent(QMouseEvent *event) { - if (ignoreMouse) + if (ignoreMouse) { event->ignore(); - else + } else { + ++mouseReleasedCount; + mouseSequenceSignature += 'r'; mouseReleaseButton = event->button(); + } } void mouseMoveEvent(QMouseEvent *event) { if (ignoreMouse) { @@ -276,6 +283,14 @@ public: mouseMoveScreenPos = event->screenPos(); } } + void mouseDoubleClickEvent(QMouseEvent *event) { + if (ignoreMouse) { + event->ignore(); + } else { + ++mouseDoubleClickedCount; + mouseSequenceSignature += 'd'; + } + } void touchEvent(QTouchEvent *event) { if (ignoreTouch) { event->ignore(); @@ -299,16 +314,23 @@ public: } } } + void resetCounters() { + mousePressedCount = mouseReleasedCount = mouseDoubleClickedCount = 0; + mouseSequenceSignature = QString(); + touchPressedCount = touchReleasedCount = touchMovedCount = 0; + } InputTestWindow() { keyPressCode = keyReleaseCode = 0; - mousePressButton = mouseReleaseButton = 0; - touchPressedCount = touchReleasedCount = touchMovedCount = 0; + mousePressButton = mouseReleaseButton = mouseMoveButton = 0; ignoreMouse = ignoreTouch = false; + resetCounters(); } int keyPressCode, keyReleaseCode; int mousePressButton, mouseReleaseButton, mouseMoveButton; + int mousePressedCount, mouseReleasedCount, mouseDoubleClickedCount; + QString mouseSequenceSignature; QPointF mousePressScreenPos, mouseMoveScreenPos; int touchPressedCount, touchReleasedCount, touchMovedCount; QEvent::Type touchEventType; @@ -645,5 +667,96 @@ void tst_QWindow::activateAndClose() } } +void tst_QWindow::mouseEventSequence() +{ + int doubleClickInterval = qGuiApp->styleHints()->mouseDoubleClickInterval(); + + InputTestWindow window; + window.setGeometry(80, 80, 40, 40); + window.show(); + QTest::qWaitForWindowShown(&window); + + ulong timestamp = 0; + QPointF local(12, 34); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QCoreApplication::processEvents(); + QCOMPARE(window.mousePressedCount, 1); + QCOMPARE(window.mouseReleasedCount, 1); + QCOMPARE(window.mouseDoubleClickedCount, 0); + QCOMPARE(window.mouseSequenceSignature, QLatin1String("pr")); + + window.resetCounters(); + timestamp += doubleClickInterval; + + // A double click must result in press, release, press, doubleclick, release. + // Check that no unexpected event suppression occurs and that the order is correct. + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QCoreApplication::processEvents(); + QCOMPARE(window.mousePressedCount, 2); + QCOMPARE(window.mouseReleasedCount, 2); + QCOMPARE(window.mouseDoubleClickedCount, 1); + QCOMPARE(window.mouseSequenceSignature, QLatin1String("prpdr")); + + timestamp += doubleClickInterval; + window.resetCounters(); + + // Triple click = double + single click + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QCoreApplication::processEvents(); + QCOMPARE(window.mousePressedCount, 3); + QCOMPARE(window.mouseReleasedCount, 3); + QCOMPARE(window.mouseDoubleClickedCount, 1); + QCOMPARE(window.mouseSequenceSignature, QLatin1String("prpdrpr")); + + timestamp += doubleClickInterval; + window.resetCounters(); + + // Two double clicks. + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + QCoreApplication::processEvents(); + QCOMPARE(window.mousePressedCount, 4); + QCOMPARE(window.mouseReleasedCount, 4); + QCOMPARE(window.mouseDoubleClickedCount, 2); + QCOMPARE(window.mouseSequenceSignature, QLatin1String("prpdrprpdr")); + + timestamp += doubleClickInterval; + window.resetCounters(); + + // Four clicks, none of which qualifies as a double click. + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + timestamp += doubleClickInterval; + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + timestamp += doubleClickInterval; + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + timestamp += doubleClickInterval; + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + timestamp += doubleClickInterval; + QCoreApplication::processEvents(); + QCOMPARE(window.mousePressedCount, 4); + QCOMPARE(window.mouseReleasedCount, 4); + QCOMPARE(window.mouseDoubleClickedCount, 0); + QCOMPARE(window.mouseSequenceSignature, QLatin1String("prprprpr")); +} + #include -QTEST_MAIN(tst_QWindow); +QTEST_MAIN(tst_QWindow) -- cgit v1.2.3 From bc0b37d6b61fc8ab83026d6a5e515666e58d7938 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Fri, 16 Mar 2012 14:08:13 +0200 Subject: Password editor mask delay stylable by platform plugin Replaced hard coding as QT_GUI_PASSWORD_ECHO_DELAY with a style hint. Change-Id: I0b78ebad723dbe19d9b9496583203e31545874e2 Reviewed-by: Andrew den Exter Reviewed-by: Lars Knoll --- src/gui/kernel/qplatformintegration_qpa.cpp | 2 ++ src/gui/kernel/qplatformintegration_qpa.h | 3 ++- src/gui/kernel/qstylehints.cpp | 5 +++++ src/gui/kernel/qstylehints.h | 2 ++ src/widgets/widgets/qwidgetlinecontrol.cpp | 26 ++++------------------ src/widgets/widgets/qwidgetlinecontrol_p.h | 8 ------- .../widgets/widgets/qlineedit/tst_qlineedit.cpp | 10 ++++----- 7 files changed, 19 insertions(+), 37 deletions(-) diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp index 786e915a19..6879f0517e 100644 --- a/src/gui/kernel/qplatformintegration_qpa.cpp +++ b/src/gui/kernel/qplatformintegration_qpa.cpp @@ -291,6 +291,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return 500; case ShowIsFullScreen: return false; + case PasswordMaskDelay: + return 0; } return 0; diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 632b3af613..68dfc21833 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -121,7 +121,8 @@ public: StartDragDistance, StartDragTime, KeyboardAutoRepeatRate, - ShowIsFullScreen + ShowIsFullScreen, + PasswordMaskDelay }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 15fcec21d8..4970f6a26b 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -96,4 +96,9 @@ bool QStyleHints::showIsFullScreen() const return hint(QPlatformIntegration::ShowIsFullScreen).toBool(); } +int QStyleHints::passwordMaskDelay() const +{ + return hint(QPlatformIntegration::PasswordMaskDelay).toInt(); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index 0fc7e776b5..ae51ebc052 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -62,6 +62,8 @@ public: int keyboardAutoRepeatRate() const; int cursorFlashTime() const; bool showIsFullScreen() const; + int passwordMaskDelay() const; + private: friend class QGuiApplication; QStyleHints(); diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index ca30c7eef8..b4a7007190 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -47,6 +47,7 @@ #include "qclipboard.h" #include #include +#include #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif @@ -58,21 +59,6 @@ QT_BEGIN_NAMESPACE -#ifdef QT_GUI_PASSWORD_ECHO_DELAY -static const int qt_passwordEchoDelay = QT_GUI_PASSWORD_ECHO_DELAY; -#endif - -/*! - \macro QT_GUI_PASSWORD_ECHO_DELAY - - \internal - - Defines the amount of time in milliseconds the last entered character - should be displayed unmasked in the Password echo mode. - - If not defined in qplatformdefs.h there will be no delay in masking - password characters. -*/ /*! \internal @@ -113,7 +99,6 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) if (m_echoMode == QLineEdit::Password) { str.fill(m_passwordCharacter); -#ifdef QT_GUI_PASSWORD_ECHO_DELAY if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.length()) { int cursor = m_cursor - 1; QChar uc = m_text.at(cursor); @@ -126,7 +111,6 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) str[cursor - 1] = uc; } } -#endif } else if (m_echoMode == QLineEdit::PasswordEchoOnEdit && !m_passwordEchoEditing) { str.fill(m_passwordCharacter); } @@ -818,13 +802,13 @@ void QWidgetLineControl::addCommand(const Command &cmd) */ void QWidgetLineControl::internalInsert(const QString &s) { -#ifdef QT_GUI_PASSWORD_ECHO_DELAY if (m_echoMode == QLineEdit::Password) { if (m_passwordEchoTimer != 0) killTimer(m_passwordEchoTimer); - m_passwordEchoTimer = startTimer(qt_passwordEchoDelay); + int delay = qGuiApp->styleHints()->passwordMaskDelay(); + if (delay > 0) + m_passwordEchoTimer = startTimer(delay); } -#endif if (hasSelectedText()) addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); if (m_maskData) { @@ -1517,12 +1501,10 @@ void QWidgetLineControl::timerEvent(QTimerEvent *event) } else if (event->timerId() == m_tripleClickTimer) { killTimer(m_tripleClickTimer); m_tripleClickTimer = 0; -#ifdef QT_GUI_PASSWORD_ECHO_DELAY } else if (event->timerId() == m_passwordEchoTimer) { killTimer(m_passwordEchoTimer); m_passwordEchoTimer = 0; updateDisplayText(); -#endif } } diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 72f25e9068..62184a27bb 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -93,9 +93,7 @@ public: m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1), m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0), m_selstart(0), m_selend(0), m_passwordEchoEditing(false) -#ifdef QT_GUI_PASSWORD_ECHO_DELAY , m_passwordEchoTimer(0) -#endif #if defined(Q_WS_MAC) , m_threadChecks(false) , m_textLayoutThread(0) @@ -306,10 +304,8 @@ public: void updatePasswordEchoEditing(bool editing); bool passwordEchoEditing() const { -#ifdef QT_GUI_PASSWORD_ECHO_DELAY if (m_passwordEchoTimer != 0) return true; -#endif return m_passwordEchoEditing ; } @@ -484,17 +480,13 @@ private: bool m_passwordEchoEditing; QChar m_passwordCharacter; -#ifdef QT_GUI_PASSWORD_ECHO_DELAY int m_passwordEchoTimer; -#endif void cancelPasswordEchoTimer() { -#ifdef QT_GUI_PASSWORD_ECHO_DELAY if (m_passwordEchoTimer != 0) { killTimer(m_passwordEchoTimer); m_passwordEchoTimer = 0; } -#endif } int redoTextLayout() const; diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index f67f7ce1e8..a6860006c2 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -49,6 +49,7 @@ #include "qcompleter.h" #include "qstandarditemmodel.h" #include "qplatformtheme_qpa.h" +#include "qstylehints.h" #include #ifndef QT_NO_CLIPBOARD @@ -174,10 +175,7 @@ private slots: void displayText_data(); void displayText(); void passwordEchoOnEdit(); - -#ifdef QT_GUI_PASSWORD_ECHO_DELAY void passwordEchoDelay(); -#endif void maxLength_mask_data(); void maxLength_mask(); @@ -1664,9 +1662,10 @@ void tst_QLineEdit::passwordEchoOnEdit() testWidget->setEchoMode(QLineEdit::Normal); } -#ifdef QT_GUI_PASSWORD_ECHO_DELAY void tst_QLineEdit::passwordEchoDelay() { + if (qGuiApp->styleHints()->passwordMaskDelay() <= 0) + QSKIP("No mask delay in use"); QStyleOptionFrameV2 opt; QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget); @@ -1686,7 +1685,7 @@ void tst_QLineEdit::passwordEchoDelay() QCOMPARE(testWidget->displayText(), QString(4, fillChar)); QTest::keyPress(testWidget, '4'); QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY); + QTest::qWait(qGuiApp->styleHints()->passwordMaskDelay()); QTRY_COMPARE(testWidget->displayText(), QString(5, fillChar)); QTest::keyPress(testWidget, '5'); QCOMPARE(testWidget->displayText(), QString(5, fillChar) + QLatin1Char('5')); @@ -1714,7 +1713,6 @@ void tst_QLineEdit::passwordEchoDelay() // restore clean state testWidget->setEchoMode(QLineEdit::Normal); } -#endif void tst_QLineEdit::maxLength_mask_data() { -- cgit v1.2.3 From 8660f6e385b2070db1b33dab85b5686a00fec06b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 22 Mar 2012 10:53:45 +0100 Subject: Fix measurement system for the UK THe UK still uses the Imperial system at least for distances and many other things. Change-Id: I99379de35620114328ad6a7fc9b226a46692bedd Reviewed-by: Denis Dzyubenko --- src/corelib/tools/qlocale.cpp | 2 +- src/corelib/tools/qlocale.h | 7 ++++++- src/corelib/tools/qlocale.qdoc | 8 +++++--- src/corelib/tools/qlocale_data_p.h | 10 ++++++---- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 17 +++++++++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index e40917c5d8..2d1444c315 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2080,7 +2080,7 @@ QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const for (int i = 0; i < ImperialMeasurementSystemsCount; ++i) { if (ImperialMeasurementSystems[i].languageId == m_language_id && ImperialMeasurementSystems[i].countryId == m_country_id) { - return QLocale::ImperialSystem; + return ImperialMeasurementSystems[i].system; } } return QLocale::MetricSystem; diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index c029f627b2..6c97a05ba8 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -565,7 +565,12 @@ public: }; // GENERATED PART ENDS HERE - enum MeasurementSystem { MetricSystem, ImperialSystem }; + enum MeasurementSystem { + MetricSystem, + ImperialUSSystem, + ImperialUKSystem, + ImperialSystem = ImperialUSSystem // Qt 4 compatibility + }; enum FormatType { LongFormat, ShortFormat, NarrowFormat }; enum NumberOption { diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc index 8e90d7d94e..02a6ef1c6d 100644 --- a/src/corelib/tools/qlocale.qdoc +++ b/src/corelib/tools/qlocale.qdoc @@ -672,9 +672,11 @@ \value MetricSystem This value indicates metric units, such as meters, centimeters and millimeters. - \value ImperialSystem This value indicates imperial units, such as inches and - miles. There are several distinct imperial systems in the world; this - value stands for the official United States imperial units. + \value ImperialUSSystem This value indicates imperial units, such as inches and + miles as they are used in the United States. + \value ImperialUKSystem This value indicates imperial units, such as inches and + miles as they are used in the United Kingdom. + \value ImperialSystem Provided for compatibility. Same as ImperialUSSystem \since 4.4 */ diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h index 1508b982f1..db19e5bcd6 100644 --- a/src/corelib/tools/qlocale_data_p.h +++ b/src/corelib/tools/qlocale_data_p.h @@ -62,12 +62,14 @@ struct CountryLanguage { quint16 languageId; quint16 countryId; + QLocale::MeasurementSystem system; }; static const CountryLanguage ImperialMeasurementSystems[] = { - { 31, 225 }, - { 31, 226 }, - { 111, 225 }, - { 163, 225 } + { QLocale::English, QLocale::UnitedStates, QLocale::ImperialUSSystem }, + { QLocale::English, QLocale::UnitedStatesMinorOutlyingIslands, QLocale::ImperialUSSystem }, + { QLocale::Spanish, QLocale::UnitedStates, QLocale::ImperialUSSystem }, + { QLocale::Hawaiian, QLocale::UnitedStates, QLocale::ImperialUSSystem }, + { QLocale::English, QLocale::UnitedKingdom, QLocale::ImperialUKSystem } }; static const int ImperialMeasurementSystemsCount = sizeof(ImperialMeasurementSystems)/sizeof(ImperialMeasurementSystems[0]); diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index b3b573c64b..f9de2f0c05 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -133,6 +133,8 @@ private slots: void weekendDays(); void listPatterns(); + void measurementSystems(); + private: QString m_decimal, m_thousand, m_sdate, m_ldate, m_time; QString m_sysapp; @@ -2034,5 +2036,20 @@ void tst_QLocale::listPatterns() QCOMPARE(zh_CN.createSeparatedList(sl5), QString::fromUtf8("aaa" "\xe3\x80\x81" "bbb" "\xe3\x80\x81" "ccc" "\xe5\x92\x8c" "ddd")); } +void tst_QLocale::measurementSystems() +{ + QLocale locale(QLocale::English, QLocale::UnitedStates); + QCOMPARE(locale.measurementSystem(), QLocale::ImperialUSSystem); + + locale = QLocale(QLocale::English, QLocale::UnitedKingdom); + QCOMPARE(locale.measurementSystem(), QLocale::ImperialUKSystem); + + locale = QLocale(QLocale::English, QLocale::Australia); + QCOMPARE(locale.measurementSystem(), QLocale::MetricSystem); + + locale = QLocale(QLocale::German); + QCOMPARE(locale.measurementSystem(), QLocale::MetricSystem); +} + QTEST_MAIN(tst_QLocale) #include "tst_qlocale.moc" -- cgit v1.2.3 From 9581e5895a89f9a4f28449ade4e2590e99903eeb Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Mar 2012 09:43:45 +0100 Subject: Cocoa: don't show window when calling raise() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling raise() on a hidden window should not show it. The setVisible() function will ensure that the window is raised (since we use orderFront or makeKeyAndOrderFront). This fixes the failing tst_QDockWidget::task169808_setFloating() test as well. Task-number: QTBUG-24774 Change-Id: If34472ebbcd615c10654efafd54c84c03d10bc8c Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 8 ++++++-- tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp | 3 --- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 7282a8d776..46c100649f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -198,13 +198,17 @@ void QCocoaWindow::raise() { //qDebug() << "raise" << this; // ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm) - if (m_nsWindow) + if (!m_nsWindow) + return; + if ([m_nsWindow isVisible]) [m_nsWindow orderFront: m_nsWindow]; } void QCocoaWindow::lower() { - if (m_nsWindow) + if (!m_nsWindow) + return; + if ([m_nsWindow isVisible]) [m_nsWindow orderBack: m_nsWindow]; } diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index 7e7b049166..43c0022c25 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -764,9 +764,6 @@ void tst_QDockWidget::task169808_setFloating() qt_x11_wait_for_window_manager(&mw); #endif -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "Window handling: QTBUG-24774", Abort); -#endif QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint()); //and now we try to test if the contents margin is taken into account -- cgit v1.2.3 From d8508b813950cad79600acb49ef5bef837f04934 Mon Sep 17 00:00:00 2001 From: Donald Carr Date: Fri, 23 Mar 2012 21:29:34 +0000 Subject: Reunite NAS support in configure with QSound RIP Change-Id: I7c47052ce4962f10dbcbbb8d48f05b3158d4a69a Reviewed-by: Oswald Buddenhagen --- configure | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/configure b/configure index 54c80b0ba0..32caa653a9 100755 --- a/configure +++ b/configure @@ -735,7 +735,6 @@ CFG_SSE4_1=auto CFG_SSE4_2=auto CFG_AVX=auto CFG_REDUCE_RELOCATIONS=auto -CFG_NAS=no CFG_ACCESSIBILITY=auto CFG_IWMMXT=no CFG_NEON=auto @@ -1598,13 +1597,6 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; - nas-sound) - if [ "$VAL" = "system" ] || [ "$VAL" = "no" ]; then - CFG_NAS="$VAL" - else - UNKNOWN_OPT=yes - fi - ;; xcursor) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "runtime" ]; then CFG_XCURSOR="$VAL" @@ -5705,7 +5697,6 @@ fi [ "$CFG_GSTREAMER" = "yes" ] && QT_CONFIG="$QT_CONFIG gstreamer" [ "$CFG_DBUS" = "yes" ] && QT_CONFIG="$QT_CONFIG dbus" [ "$CFG_DBUS" = "linked" ] && QT_CONFIG="$QT_CONFIG dbus dbus-linked" -[ "$CFG_NAS" = "system" ] && QT_CONFIG="$QT_CONFIG nas" [ "$CFG_OPENSSL" = "yes" ] && QT_CONFIG="$QT_CONFIG openssl" [ "$CFG_OPENSSL" = "linked" ] && QT_CONFIG="$QT_CONFIG openssl-linked" [ "$CFG_MAC_HARFBUZZ" = "yes" ] && QT_CONFIG="$QT_CONFIG harfbuzz" @@ -6188,7 +6179,6 @@ QMakeVar set sql-plugins "$SQL_PLUGINS" [ "$CFG_IPV6IFNAME" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IPV6IFNAME" [ "$CFG_GETIFADDRS" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GETIFADDRS" [ "$CFG_INOTIFY" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_INOTIFY" -[ "$CFG_NAS" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_NAS" [ "$CFG_NIS" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_NIS" [ "$CFG_OPENSSL" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_OPENSSL QT_NO_SSL" [ "$CFG_OPENSSL" = "linked" ]&& QCONFIG_FLAGS="$QCONFIG_FLAGS QT_LINKED_OPENSSL" -- cgit v1.2.3 From a9c49816a7008cf6e181fe66d7644a64c10faf17 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 23 Mar 2012 12:53:35 +0100 Subject: Cocoa: QCocoaWindow::clearNSWindow() needs to cleanup properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clearNSWindow() should also clear the delegate and remove the contentView from the window, since we are no longer using that window. Make sure the QCocoaWindow::~QCocoaWindow() doesn't release the m_contentView until after clearNSWindow(), to avoid crashes while trying to cleanup the window and view. Change-Id: Ia081488f629a4fd4cf10fb1053fb8183b1914d35 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 46c100649f..4f95489798 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -111,8 +111,8 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) QCocoaWindow::~QCocoaWindow() { - [m_contentView release]; clearNSWindow(m_nsWindow); + [m_contentView release]; [m_nsWindow release]; } @@ -449,7 +449,9 @@ void QCocoaWindow::setNSWindow(NSWindow *window) void QCocoaWindow::clearNSWindow(NSWindow *window) { + [window setDelegate:nil]; [[NSNotificationCenter defaultCenter] removeObserver:m_contentView]; + [m_contentView removeFromSuperviewWithoutNeedingDisplay]; } // Returns the current global screen geometry for the nswindow associated with this window. -- cgit v1.2.3 From f6b25fa213c9e44df29613ca32e8c1fa536637fb Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 20 Mar 2012 13:30:10 +0100 Subject: Cocoa: silence warnings from QCocoaBackingStore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unused (and misspelled) flipedRect() function, as well as several unused variables. Change-Id: I48a5bf2eaad67686f60523a5c22262cad5314128 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 3a55e00c48..f0ff7ba0d6 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -47,23 +47,10 @@ QT_BEGIN_NAMESPACE -QRect flipedRect(const QRect &sourceRect,int height) -{ - if (!sourceRect.isValid()) - return QRect(); - QRect flippedRect = sourceRect; - flippedRect.moveTop(height - sourceRect.y()); - return flippedRect; -} - QCocoaBackingStore::QCocoaBackingStore(QWindow *window) : QPlatformBackingStore(window) { m_cocoaWindow = static_cast(window->handle()); - - const QRect geo = window->geometry(); - NSRect rect = NSMakeRect(geo.x(),geo.y(),geo.width(),geo.height()); - m_image = new QImage(window->geometry().size(),QImage::Format_ARGB32_Premultiplied); } @@ -84,7 +71,6 @@ void QCocoaBackingStore::flush(QWindow *widget, const QRegion ®ion, const QPo QCocoaAutoReleasePool pool; QRect geo = region.boundingRect(); - NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); [m_cocoaWindow->m_contentView displayRect:rect]; } @@ -92,8 +78,7 @@ void QCocoaBackingStore::flush(QWindow *widget, const QRegion ®ion, const QPo void QCocoaBackingStore::resize(const QSize &size, const QRegion &) { delete m_image; - m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied); - NSSize newSize = NSMakeSize(size.width(),size.height()); + m_image = new QImage(size, QImage::Format_ARGB32_Premultiplied); [static_cast(m_cocoaWindow->m_contentView) setImage:m_image]; } -- cgit v1.2.3 From 155d5ecf34891a0dfbc7afcf9a8a866b8331e3dd Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Mar 2012 10:29:24 +0100 Subject: Cocoa: silence warnings about unused variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Silence warnings about unused function parameters and local variables while building the Cocoa platform plugin. Change-Id: I6aedc4cb21c5fb48d2d6e501561473d3f7112aed Reviewed-by: Morten Johan Sørvig --- src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h | 2 +- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 2 +- src/plugins/platforms/cocoa/qcocoaclipboard.mm | 1 + src/plugins/platforms/cocoa/qcocoacursor.mm | 2 ++ src/plugins/platforms/cocoa/qnsview.mm | 1 + src/plugins/platforms/cocoa/qnsviewaccessibility.mm | 1 - 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index 02c8d926fd..3d286c8625 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -98,7 +98,7 @@ public: virtual QFixed emSquareSize() const; virtual QFontEngine *cloneWithSize(qreal pixelSize) const; - virtual int glyphMargin(QFontEngineGlyphCache::Type type) { return 0; } + virtual int glyphMargin(QFontEngineGlyphCache::Type type) { Q_UNUSED(type); return 0; } static int antialiasingThreshold; static QFontEngineGlyphCache::Type defaultGlyphFormat; diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index e405c81726..947d91005d 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -172,8 +172,8 @@ static void cleanupCocoaApplicationDelegate() // QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { -/* Q_UNUSED(sender); +/* // The reflection delegate gets precedence if (reflectionDelegate && [reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) { diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm index 87c085457f..f76174e085 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm @@ -81,6 +81,7 @@ bool QCocoaClipboard::supportsMode(QClipboard::Mode mode) const bool QCocoaClipboard::ownsMode(QClipboard::Mode mode) const { + Q_UNUSED(mode); return false; } diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index 56f0dcf72e..bd8d32b07e 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -59,6 +59,8 @@ QCocoaCursor::QCocoaCursor() void QCocoaCursor::changeCursor(QCursor *cursor, QWindow *window) { + Q_UNUSED(window); + // Check for a suitable built-in NSCursor first: switch (cursor->shape()) { case Qt::ArrowCursor: diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 2b384a28ec..e76c02704f 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -238,6 +238,7 @@ static QTouchDevice *touchDevice = 0; - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { + Q_UNUSED(theEvent); return YES; } diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index d20246d292..205a52c204 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -87,7 +87,6 @@ - (id)accessibilityHitTest:(NSPoint)point { if (!m_accessibleRoot) return [super accessibilityHitTest:point]; - NSPoint windowPoint = [[self window] convertScreenToBase:point]; QAccessibleInterface *childInterface = m_accessibleRoot->childAt(point.x, qt_mac_flipYCoordinate(point.y)); // No child found, meaning we hit the NSView -- cgit v1.2.3 From 1f61980a0fdc4168002b468543c598257cc50436 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Mar 2012 10:30:53 +0100 Subject: Cocoa: Remove unused qt_mac_is_sheet() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The static qt_mac_is_sheet() function in qcocoafiledialoghelper.mm was not called anywhere, remove it. Change-Id: I88785e15aa17ae9c9ffbc33eba30433c8834b798 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index ecb732c9da..c333e3ac1f 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -504,17 +504,6 @@ typedef QSharedPointer SharedPointerFileDialogOptions; QT_BEGIN_NAMESPACE -static bool qt_mac_is_macsheet(const QWidget *w) -{ - if (!w) - return false; - - Qt::WindowModality modality = w->windowModality(); - if (modality == Qt::ApplicationModal) - return false; - return w->parentWidget() && (modality == Qt::WindowModal || w->windowType() == Qt::Sheet); -} - QCocoaFileDialogHelper::QCocoaFileDialogHelper() :mDelegate(0) { -- cgit v1.2.3 From e1c22d426f8c5cdd9ad0e119d54cfa516d45f8c1 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Mon, 19 Mar 2012 17:30:28 +0100 Subject: Blackberry mkspecs Unlike QNX mkspecs, these mkspecs target more specific, BlackBerry-only devices. So far, the only difference is the definition of Q_OS_BLACKBERRY and linking with -lbps, but this will likely change with time. It will also allow conditional compilation to distinguish between qnx and blackberry devices. Change-Id: Ia44e9b4059f720c308240e9dac7e90f7ae7920d0 Reviewed-by: Sean Harmer Reviewed-by: Oswald Buddenhagen --- .../unsupported/blackberry-armv7le-qcc/qmake.conf | 9 +++++ .../blackberry-armv7le-qcc/qplatformdefs.h | 42 ++++++++++++++++++++++ mkspecs/unsupported/blackberry-x86-qcc/qmake.conf | 9 +++++ .../unsupported/blackberry-x86-qcc/qplatformdefs.h | 42 ++++++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 mkspecs/unsupported/blackberry-armv7le-qcc/qmake.conf create mode 100644 mkspecs/unsupported/blackberry-armv7le-qcc/qplatformdefs.h create mode 100644 mkspecs/unsupported/blackberry-x86-qcc/qmake.conf create mode 100644 mkspecs/unsupported/blackberry-x86-qcc/qplatformdefs.h diff --git a/mkspecs/unsupported/blackberry-armv7le-qcc/qmake.conf b/mkspecs/unsupported/blackberry-armv7le-qcc/qmake.conf new file mode 100644 index 0000000000..df9961b107 --- /dev/null +++ b/mkspecs/unsupported/blackberry-armv7le-qcc/qmake.conf @@ -0,0 +1,9 @@ +# +# qmake configuration for blackberry x86 systems +# + +DEFINES += Q_OS_BLACKBERRY +CONFIG += blackberry +LIBS += -lbps + +include(../qnx-armv7le-qcc/qmake.conf) diff --git a/mkspecs/unsupported/blackberry-armv7le-qcc/qplatformdefs.h b/mkspecs/unsupported/blackberry-armv7le-qcc/qplatformdefs.h new file mode 100644 index 0000000000..964c34bb99 --- /dev/null +++ b/mkspecs/unsupported/blackberry-armv7le-qcc/qplatformdefs.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Research In Motion Limited. +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../qnx-armv7le-qcc/qplatformdefs.h" diff --git a/mkspecs/unsupported/blackberry-x86-qcc/qmake.conf b/mkspecs/unsupported/blackberry-x86-qcc/qmake.conf new file mode 100644 index 0000000000..2cb405cd51 --- /dev/null +++ b/mkspecs/unsupported/blackberry-x86-qcc/qmake.conf @@ -0,0 +1,9 @@ +# +# qmake configuration for blackberry x86 systems +# + +DEFINES += Q_OS_BLACKBERRY +CONFIG += blackberry +LIBS += -lbps + +include(../qnx-x86-qcc/qmake.conf) diff --git a/mkspecs/unsupported/blackberry-x86-qcc/qplatformdefs.h b/mkspecs/unsupported/blackberry-x86-qcc/qplatformdefs.h new file mode 100644 index 0000000000..f134e76665 --- /dev/null +++ b/mkspecs/unsupported/blackberry-x86-qcc/qplatformdefs.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Research In Motion Limited. +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../qnx-x86-qcc/qplatformdefs.h" -- cgit v1.2.3 From de37821c56b2579a3088aef1c391cdf345deb190 Mon Sep 17 00:00:00 2001 From: Bai Jing Date: Mon, 26 Mar 2012 11:32:52 +0200 Subject: let qtPrepareTool give right path for app_bundle Change-Id: Ieb4979244d741c9d9d0c11a035c18ced87ea28f5 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_functions.prf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 474a414003..ee1647f481 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -180,7 +180,13 @@ defineTest(qtPrepareTool) { } else { $$1 = $$eval($$1).exe } + } else:contains(QMAKE_HOST.os, Darwin) { + BUNDLENAME = $$eval($$1).app/Contents/MacOS/$$2 + exists($$BUNDLENAME) { + $$1 = $$BUNDLENAME + } } + export($$1) } -- cgit v1.2.3 From c28e61a0f430b4789adf3155559f6a3734b88e0c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 1 Mar 2012 17:44:34 +0100 Subject: Fix annoying deprecation warning about QImageTextKeyLang If we deprecate the entire class, then we get the warning for every use of it with GCC, including the three operators defined inside the class. So instead, mark as only the constructors as deprecated, which should reduce the warnings to the places where the class was instantiated. That should be enough to poison the code enough: to fix the warning, you need to stop using the class there and/or stop calling one of the deprecated functions that deal with it. Unfortunately, we still get one more warning inside the inline code, in QImage::textList. To remove that warning, we disable all deprecation warnings around that code block. Change-Id: If3c11647a9d2cab055e15810d7cfe0d8f5e7042f Reviewed-by: Olivier Goffart Reviewed-by: Lars Knoll --- src/gui/image/qimage.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index e9192f1031..6acc03f4bd 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -70,10 +70,10 @@ struct QImageData; class QImageDataMisc; // internal #ifndef QT_NO_IMAGE_TEXT #if QT_DEPRECATED_SINCE(5, 0) -class QT_DEPRECATED QImageTextKeyLang { +class QImageTextKeyLang { public: - QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { } - QImageTextKeyLang() { } + QT_DEPRECATED QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { } + QT_DEPRECATED QImageTextKeyLang() { } QByteArray key; QByteArray lang; @@ -315,6 +315,14 @@ Q_GUI_EXPORT_INLINE void QImage::setPixel(const QPoint &pt, uint index_or_rgb) { #if QT_DEPRECATED_SINCE(5, 0) #ifndef QT_NO_IMAGE_TEXT + +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined(Q_CC_MSVC) +# pragma warning(disable: 4996) +#endif + inline QString QImage::text(const char* key, const char* lang) const { if (!d) @@ -384,6 +392,13 @@ inline void QImage::setText(const char* key, const char* lang, const QString &s) k += QLatin1Char('/') + QString::fromAscii(lang); setText(k, s); } + +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) +# pragma GCC diagnostic pop +#elif defined(Q_CC_MSVC) +# pragma warning(default: 4996) +#endif + #endif inline int QImage::numColors() const -- cgit v1.2.3 From aad02f130cd73e8ce8f6e3b80be44524ba0fe406 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 23 Mar 2012 19:16:23 -0300 Subject: Remove old code that was for the MIPSpro compiler That compiler is no longer supported Change-Id: I6ff9003a8b986478850ad2e6e6662a44264236d7 Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qglobal.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index cc0e6a17fd..0efcdf8c4a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1309,20 +1309,7 @@ template inline const QForeachContainer *qForeachContainer(const QForeachContainerBase *base, const T *) { return static_cast *>(base); } -#if defined(Q_CC_MIPS) -/* - Proper for-scoping in MIPSpro CC -*/ -# define Q_FOREACH(variable,container) \ - if(0){}else \ - for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \ - qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \ - ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \ - for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \ - qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \ - --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk) - -#elif defined(Q_CC_DIAB) +#if defined(Q_CC_DIAB) // VxWorks DIAB generates unresolvable symbols, if container is a function call # define Q_FOREACH(variable,container) \ if(0){}else \ -- cgit v1.2.3 From d24873c4f2d327f335ddce67cc1dca35c03bf02f Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 26 Mar 2012 11:58:01 +0200 Subject: Cocoa: initialize QCocoaEventDispacherPrivate::lastSerial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This silences warnings from valgrind about a conditional depending on an uninitialized value. Change-Id: I819a44ed5dc02e163c00849811870c94f66b6651 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 305a8ddc95..77cccac0b4 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -895,6 +895,7 @@ QCocoaEventDispatcherPrivate::QCocoaEventDispatcherPrivate() nsAppRunCalledByQt(false), cleanupModalSessionsNeeded(false), currentModalSessionCached(0), + lastSerial(-1), interrupt(false) { } -- cgit v1.2.3 From b9a498bf514255b2a6298f44801d3d43c958044c Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 21 Mar 2012 11:09:59 +0100 Subject: Sync configure with Unix version (-make/-nomake) Move previous -make feature to -make-tool Change-Id: I1cbc87e60e2588fd8b2a11c11178988003cac7c1 Reviewed-by: Lars Knoll --- tools/configure/configureapp.cpp | 30 ++++++++++++++++++++++-------- tools/configure/configureapp.h | 4 +++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index f47cff6fdd..8624285387 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -176,6 +176,7 @@ Configure::Configure(int& argc, char** argv) } } + defaultBuildParts << QStringLiteral("libs") << QStringLiteral("examples") << QStringLiteral("tests"); dictionary[ "QT_SOURCE_TREE" ] = fixSeparators(sourcePath); dictionary[ "QT_BUILD_TREE" ] = fixSeparators(buildPath); dictionary[ "QT_INSTALL_PREFIX" ] = fixSeparators(installPath); @@ -948,11 +949,16 @@ void Configure::parseCmdLine() dictionary["LICENSE_CONFIRMED"] = "yes"; } - else if (configCmdLine.at(i) == "-nomake") { + else if (configCmdLine.at(i) == "-make") { + ++i; + if (i == argCount) + break; + buildParts += configCmdLine.at(i); + } else if (configCmdLine.at(i) == "-nomake") { ++i; if (i == argCount) break; - disabledBuildParts += configCmdLine.at(i); + nobuildParts.removeAll(configCmdLine.at(i)); } // Directories ---------------------------------------------- @@ -1061,7 +1067,7 @@ void Configure::parseCmdLine() dictionary[ "QT_HOST_DATA" ] = configCmdLine.at(i); } - else if (configCmdLine.at(i) == "-make") { + else if (configCmdLine.at(i) == "-make-tool") { ++i; if (i == argCount) break; @@ -1507,6 +1513,11 @@ bool Configure::displayHelp() "subdirectory targets. All other Makefiles are created as wrappers " "which will in turn run qmake\n"); + desc( "-make ", "Add part to the list of parts to be built at make time."); + for (int i=0; i", "Exclude part from the list of parts to be built.\n"); + desc("EXCEPTIONS", "no", "-no-exceptions", "Disable exceptions on platforms that support it."); desc("EXCEPTIONS", "yes","-exceptions", "Enable exceptions on platforms that support it.\n"); @@ -2249,6 +2260,14 @@ void Configure::generateOutputVars() qmakeConfig += dictionary[ "BUILD" ]; dictionary[ "QMAKE_OUTDIR" ] = dictionary[ "BUILD" ]; + if (buildParts.isEmpty()) + buildParts = defaultBuildParts; + while (!nobuildParts.isEmpty()) + buildParts.removeAll(nobuildParts.takeFirst()); + if (!buildParts.contains("libs")) + buildParts += "libs"; + buildParts.removeDuplicates(); + if (dictionary["MSVC_MP"] == "yes") qmakeConfig += "msvc_mp"; @@ -2483,11 +2502,6 @@ void Configure::generateCachefile() moduleStream << "#paths" << endl; moduleStream << "QT_BUILD_TREE = " << fixSeparators(dictionary[ "QT_BUILD_TREE" ], true) << endl; moduleStream << "QT_SOURCE_TREE = " << fixSeparators(dictionary[ "QT_SOURCE_TREE" ], true) << endl; - QStringList buildParts; - buildParts << QStringLiteral("libs") << QStringLiteral("examples") << QStringLiteral("tests"); - foreach (const QString &item, disabledBuildParts) { - buildParts.removeAll(item); - } moduleStream << "QT_BUILD_PARTS = " << buildParts.join(" ") << endl << endl; //so that we can build without an install first (which would be impossible) diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h index 65aa0cbed9..42068e77b4 100644 --- a/tools/configure/configureapp.h +++ b/tools/configure/configureapp.h @@ -107,13 +107,15 @@ public: private: // Our variable dictionaries QMap dictionary; + QStringList defaultBuildParts; + QStringList buildParts; + QStringList nobuildParts; QStringList licensedModules; QStringList allSqlDrivers; QStringList allConfigs; QStringList disabledModules; QStringList enabledModules; QStringList modules; - QStringList disabledBuildParts; // QStringList sqlDrivers; QStringList configCmdLine; QStringList qmakeConfig; -- cgit v1.2.3 From 4c655bef5e21814e7a848feb7d8702258f9cf9dd Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 27 Mar 2012 09:34:48 +1000 Subject: Mark tst_qdialog as insignificant on mac. This autotest gives different results on consecutive runs, and is therefore insignificant for the purpose of detecting regressions. Task-number: QTBUG-24977 Change-Id: I5c4dfd663ce5df6b60ae47a29d332c06e3c0585f Reviewed-by: Kalle Lehtonen --- tests/auto/widgets/dialogs/qdialog/qdialog.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/widgets/dialogs/qdialog/qdialog.pro b/tests/auto/widgets/dialogs/qdialog/qdialog.pro index 2c4d10dd0b..779c10ed66 100644 --- a/tests/auto/widgets/dialogs/qdialog/qdialog.pro +++ b/tests/auto/widgets/dialogs/qdialog/qdialog.pro @@ -2,3 +2,4 @@ CONFIG += testcase TARGET = tst_qdialog QT += widgets testlib SOURCES += tst_qdialog.cpp +mac:CONFIG += insignificant_test # QTBUG-24977 -- cgit v1.2.3 From 84e98fd9d2594637e928096c8fcb19d52e5e2676 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 20 Mar 2012 14:02:21 -0700 Subject: device: Add -device and -device-option to configure For some reference platforms and SDKs we will need to pass in extra paths. Currently users have to modify the mkspec to adjust paths or set environment variables that will be picked up. This change introduces the -device and -device-option option. The key value pairs will be written to a qdevice.pri and can be used by the qmake.conf of the device spec. The reason to not save the key value pairs in qconfig.pri is becase of the fact that the device spec loads the qdevice.pri earlier than the qconfig.pri. qdevice.pri allows the mkspec to set the compiler flags and qconfig.pri allows configure to add to those compiler flags. Done-with: Holger Freyther Change-Id: I931a197b8be72397e1eedfee09502eefc01c9d4f Reviewed-by: Oswald Buddenhagen Reviewed-by: Girish Ramakrishnan Reviewed-by: Johannes Zellner Reviewed-by: Donald Carr --- .gitignore | 1 + config.tests/unix/compile.test | 2 +- configure | 47 +++++++++++++++++++++++++++++++++++--- mkspecs/features/device_config.prf | 27 ++++++++++++++++++++++ qtbase.pro | 4 +++- 5 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 mkspecs/features/device_config.prf diff --git a/.gitignore b/.gitignore index f4013fd98a..7c98265f57 100644 --- a/.gitignore +++ b/.gitignore @@ -97,6 +97,7 @@ configure.cache config.status mkspecs/default mkspecs/qconfig.pri +mkspecs/qdevice.pri moc_*.cpp qmake/qmake.exe qmake/Makefile.bak diff --git a/config.tests/unix/compile.test b/config.tests/unix/compile.test index f4a7f29b1a..f82fbf9024 100755 --- a/config.tests/unix/compile.test +++ b/config.tests/unix/compile.test @@ -68,7 +68,7 @@ test -r Makefile && $MAKE distclean >/dev/null 2>&1 # Make sure output from possible previous tests is gone rm -f "$EXE" "${EXE}.exe" -"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG-=debug_and_release" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "QT_BUILD_TREE=$OUTDIR" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile" +OUTDIR=$OUTDIR "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG-=debug_and_release" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "QT_BUILD_TREE=$OUTDIR" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile" if [ "$VERBOSE" = "yes" ]; then $MAKE diff --git a/configure b/configure index 32caa653a9..fbd6b35b6d 100755 --- a/configure +++ b/configure @@ -71,8 +71,10 @@ QTCONFIG_CONFIG= QT_CONFIG= SUPPORTED= QMAKE_VARS_FILE=.qmake.vars +DEVICE_VARS_FILE=.device.vars :> "$QMAKE_VARS_FILE" +:> "$DEVICE_VARS_FILE" #------------------------------------------------------------------------------- # utility functions @@ -223,6 +225,23 @@ linkerSupportsFlag() compilerSupportsFlag "$lflags" >/dev/null 2>&1 } +#------------------------------------------------------------------------------- +# device options +#------------------------------------------------------------------------------- +DeviceVar() +{ + case "$1" in + set) + eq="=" + ;; + *) + echo >&2 "BUG: wrong command to QMakeVar: $1" + ;; + esac + + echo "$2" "$eq" "$3" >> "$DEVICE_VARS_FILE" +} + #------------------------------------------------------------------------------- # operating system detection #------------------------------------------------------------------------------- @@ -910,7 +929,7 @@ while [ "$#" -gt 0 ]; do shift VAL=$1 ;; - -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir) + -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-device|-device-option|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` shift VAL="$1" @@ -1306,6 +1325,14 @@ while [ "$#" -gt 0 ]; do XPLATFORM="$VAL" case `basename "$XPLATFORM"` in win32-g++*) XPLATFORM_MINGW=yes;; esac ;; + device) + XPLATFORM="devices/$VAL" + ;; + device-option) + DEV_VAR=`echo $VAL | sed "s,^\(.*\)=.*,\1,"` + DEV_VAL=`echo $VAL | sed "s,^.*=\(.*\),\1,"` + DeviceVar set $DEV_VAR $DEV_VAL + ;; debug-and-release) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_DEBUG_RELEASE="$VAL" @@ -2456,6 +2483,15 @@ if [ "$CFG_RTOS_ENABLED" = "no" ]; then esac fi +#------------------------------------------------------------------------------- +# write out device config before we run the test. +#------------------------------------------------------------------------------- +if cmp -s "$DEVICE_VARS_FILE" "$outpath/mkspecs/qdevice.pri"; then + rm -f "$DEVICE_VARS_FILE" +else + mv -f $DEVICE_VARS_FILE "$outpath/mkspecs/qdevice.pri" +fi + #------------------------------------------------------------------------------- # tests that don't need qmake (must be run before displaying help) #------------------------------------------------------------------------------- @@ -2929,6 +2965,7 @@ Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir [-no-openssl] [-openssl] [-openssl-linked] [-no-gtkstyle] [-gtkstyle] [-qt-pcre] [-system-pcre] + [-device ] [-device-option ] [additional platform specific options (see below)] @@ -3192,6 +3229,10 @@ Additional options: -force-asserts ........ Force Q_ASSERT to be enabled even in release builds. + -device ............... Cross-compile for device (experimental) + -device-option ... Add device specific options for the device mkspec + (experimental) + EOF if [ "$CFG_SEPARATE_DEBUG_INFO" = "auto" ]; then @@ -3925,12 +3966,12 @@ fi # Build qmake #------------------------------------------------------------------------------- # Use config.tests/arch/arch.pro to has the compiler tell us what the target architecture is -CFG_ARCH=`"$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'` +CFG_ARCH=`OUTDIR="$outpath" "$outpath/bin/qmake" -spec "$XQMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'` [ -z "$CFG_ARCH" ] && CFG_ARCH="unknown" if [ "$QMAKESPEC" != "$XQMAKESPEC" ]; then # Do the same test again, using the host compiler - CFG_HOST_ARCH=`"$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'` + CFG_HOST_ARCH=`OUTDIR="$outpath" "$outpath/bin/qmake" -spec "$QMAKESPEC" -o /dev/null "$relpath/config.tests/arch/arch.pro" 2>&1 | sed -n -e 's,^Project MESSAGE:.*Architecture: \([a-zA-Z0-9_]*\).*,\1,p'` [ -z "$CFG_HOST_ARCH" ] && CFG_HOST_ARCH="unknown" else # not cross compiling, host == target diff --git a/mkspecs/features/device_config.prf b/mkspecs/features/device_config.prf new file mode 100644 index 0000000000..56059e13cf --- /dev/null +++ b/mkspecs/features/device_config.prf @@ -0,0 +1,27 @@ +# Load generated qdevice.pri +exists($$_QMAKE_CACHE_) { + # set in default_pre, so it's the first place to check for qdevice.pri + DIR = $$fromfile($$_QMAKE_CACHE_, QT_BUILD_TREE) + !isEmpty(DIR):DEVICE_PRI = $$DIR/mkspecs/qdevice.pri +} + +isEmpty(DEVICE_PRI) { + # OUTDIR environ is set by configure (arch detection) and compile.test + DIR = $$(OUTDIR) + !isEmpty(DIR):DEVICE_PRI = $$DIR/mkspecs/qdevice.pri +} + +isEmpty(DEVICE_PRI) { + DIR = $$[QT_HOST_DATA] + !isEmpty(DIR):DEVICE_PRI = $$DIR/mkspecs/qdevice.pri +} + +isEmpty(DEVICE_PRI) { + error(Could not locate qdevice.pri) +} + +exists($$DEVICE_PRI):include($$DEVICE_PRI) + +unset(DEVICE_PRI) +unset(DIR) + diff --git a/qtbase.pro b/qtbase.pro index 7648a63826..ec3b0b2e9f 100644 --- a/qtbase.pro +++ b/qtbase.pro @@ -72,6 +72,7 @@ unix { $(DEL_FILE) src/corelib/global/qconfig.h; \ $(DEL_FILE) src/corelib/global/qconfig.cpp; \ $(DEL_FILE) mkspecs/qconfig.pri; \ + $(DEL_FILE) mkspecs/qdevice.pri; \ $(DEL_FILE) mkspecs/qmodule.pri; \ $(DEL_FILE) .qmake.cache; \ (cd qmake && $(MAKE) distclean); @@ -80,6 +81,7 @@ win32 { confclean.commands += -$(DEL_FILE) src\\corelib\\global\\qconfig.h $$escape_expand(\\n\\t) \ -$(DEL_FILE) src\\corelib\\global\\qconfig.cpp $$escape_expand(\\n\\t) \ -$(DEL_FILE) mkspecs\\qconfig.pri $$escape_expand(\\n\\t) \ + -$(DEL_FILE) mkspecs\\qdevice.pri $$escape_expand(\\n\\t) \ -$(DEL_FILE) mkspecs\\qmodule.pri $$escape_expand(\\n\\t) \ -$(DEL_FILE) .qmake.cache $$escape_expand(\\n\\t) \ (cd qmake && $(MAKE) distclean) @@ -115,7 +117,7 @@ INSTALLS += configtests #mkspecs mkspecs.path = $$[QT_HOST_DATA]/mkspecs -mkspecs.files = $$OUT_PWD/mkspecs/qconfig.pri $$OUT_PWD/mkspecs/qmodule.pri $$files($$PWD/mkspecs/*) +mkspecs.files = $$OUT_PWD/mkspecs/qconfig.pri $$OUT_PWD/mkspecs/qmodule.pri $$OUT_PWD/mkspecs/qdevice.pri $$files($$PWD/mkspecs/*) mkspecs.files -= $$PWD/mkspecs/modules unix { DEFAULT_QMAKESPEC = $$QMAKESPEC -- cgit v1.2.3 From cbc883da6910b3357a4e03d0e2dfa841da1a03e8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Mar 2012 10:37:06 -0300 Subject: Disable ICC diagnostic 2261 about __assume with side-effects The warning is presented now that we use __assume in every Q_ASSERT. It presents itself in code that calls functions, like: tools/qbitarray.h(128): warning #2261: __assume expression with side effects discarded { Q_ASSERT(i >= 0 && i < size()); ^ Change-Id: I5851b3c35b56c00b9c541c2489233121ef621e04 Reviewed-by: Oswald Buddenhagen --- mkspecs/linux-icc/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf index 36c3d5611b..90c5f41e92 100644 --- a/mkspecs/linux-icc/qmake.conf +++ b/mkspecs/linux-icc/qmake.conf @@ -15,7 +15,7 @@ QMAKE_YACC = yacc QMAKE_YACCFLAGS = -d QMAKE_CFLAGS = -falign-stack=maintain-16-byte QMAKE_CFLAGS_DEPS = -M -QMAKE_CFLAGS_WARN_ON = -w1 -Wcheck -wd654,1572,411,873,1125,2259 +QMAKE_CFLAGS_WARN_ON = -w1 -Wcheck -wd654,1572,411,873,1125,2259,2261 QMAKE_CFLAGS_WARN_OFF = -w QMAKE_CFLAGS_RELEASE = -O2 -falign-functions=16 -ansi-alias -fstrict-aliasing QMAKE_CFLAGS_DEBUG = -O0 -g -- cgit v1.2.3