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 + 1 file changed, 1 insertion(+) (limited to 'src/plugins/platforms') 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); } -- 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 (limited to 'src/plugins/platforms') 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(-) (limited to 'src/plugins/platforms') 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 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(-) (limited to 'src/plugins/platforms') 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 --- .../platforms/windows/accessible/iaccessible2.cpp | 9 +++--- .../platforms/windows/accessible/iaccessible2.h | 34 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') 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; -- 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(-) (limited to 'src/plugins/platforms') 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 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(-) (limited to 'src/plugins/platforms') 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 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(-) (limited to 'src/plugins/platforms') 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 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/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 ++++ 6 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms') 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(-) (limited to 'src/plugins/platforms') 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(+) (limited to 'src/plugins/platforms') 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 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(+) (limited to 'src/plugins/platforms') 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 (limited to 'src/plugins/platforms') 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 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(+) (limited to 'src/plugins/platforms') 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 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 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') 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]; } -- 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(-) (limited to 'src/plugins/platforms') 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(-) (limited to 'src/plugins/platforms') 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/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 - 5 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') 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(-) (limited to 'src/plugins/platforms') 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 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(+) (limited to 'src/plugins/platforms') 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