Make QPlatformIntegration not have a factory for eventdispatcher

but rather an accessor for the guiThreadEventDispatcher

Change-Id: I1b9ba14efc9f338c5a67e3e24ddb0caf76c07413
Reviewed-on: http://codereview.qt.nokia.com/2321
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
bb10
Jørgen Lind 2011-07-27 16:54:53 +02:00 committed by Samuel Rødal
parent b6b853b1b6
commit dfd72c6e6c
15 changed files with 54 additions and 57 deletions

View File

@ -318,7 +318,7 @@ void QGuiApplicationPrivate::createEventDispatcher()
createPlatformIntegration();
if (!eventDispatcher) {
QAbstractEventDispatcher *eventDispatcher = platform_integration->createEventDispatcher();
QAbstractEventDispatcher *eventDispatcher = platform_integration->guiThreadEventDispatcher();
setEventDispatcher(eventDispatcher);
}
}
@ -327,9 +327,9 @@ void QGuiApplicationPrivate::setEventDispatcher(QAbstractEventDispatcher *eventD
{
Q_Q(QGuiApplication);
if (!this->eventDispatcher) {
this->eventDispatcher = eventDispatcher;
this->eventDispatcher->setParent(q);
if (!QCoreApplicationPrivate::eventDispatcher) {
QCoreApplicationPrivate::eventDispatcher = eventDispatcher;
QCoreApplicationPrivate::eventDispatcher->setParent(q);
threadData->eventDispatcher = eventDispatcher;
}

View File

@ -83,7 +83,7 @@ public:
virtual QPlatformGLContext *createPlatformGLContext(QGuiGLContext *context) const;
// Event dispatcher:
virtual QAbstractEventDispatcher *createEventDispatcher() const = 0;
virtual QAbstractEventDispatcher *guiThreadEventDispatcher() const = 0;
//Deeper window system integrations
virtual QPlatformFontDatabase *fontDatabase() const;

View File

@ -79,13 +79,15 @@ public:
QPlatformWindow *createPlatformWindow(QWindow *window) const;
QPlatformGLContext *createPlatformGLContext(QGuiGLContext *context) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *widget) const;
QAbstractEventDispatcher *createEventDispatcher() const;
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
QPlatformFontDatabase *fontDatabase() const;
QPlatformNativeInterface *nativeInterface() const;
private:
QPlatformFontDatabase *mFontDb;
QAbstractEventDispatcher *mEventDispatcher;
QCocoaAutoReleasePool *mPool;
};

View File

@ -72,6 +72,7 @@ QCocoaScreen::~QCocoaScreen()
QCocoaIntegration::QCocoaIntegration()
: mFontDb(new QBasicUnixFontDatabase())
, mEventDispatcher(new QCocoaEventDispatcher())
{
mPool = new QCocoaAutoReleasePool;
@ -117,9 +118,9 @@ QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *wi
return new QCocoaBackingStore(window);
}
QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const
QAbstractEventDispatcher *QCocoaIntegration::guiThreadEventDispatcher() const
{
return new QCocoaEventDispatcher();
return mEventDispatcher;
}
QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const

View File

@ -83,8 +83,8 @@ QOpenWFDDevice::QOpenWFDDevice(QOpenWFDIntegration *integration, WFDint device_e
}
}
int copyFd = wfdDeviceEventGetFD(mDevice,mEvent);
mEventSocketNotifier = new QSocketNotifier(copyFd,QSocketNotifier::Read,this);
int fd = wfdDeviceEventGetFD(mDevice,mEvent);
mEventSocketNotifier = new QSocketNotifier(fd,QSocketNotifier::Read,this);
connect(mEventSocketNotifier,SIGNAL(activated(int)),SLOT(readEvents()));
mCommitedDevice = true;

View File

@ -63,8 +63,9 @@
QOpenWFDIntegration::QOpenWFDIntegration()
: QPlatformIntegration()
, mPrinterSupport(new QGenericUnixPrinterSupport)
, mEventDispatcher(createUnixEventDispatcher())
{
QGuiApplicationPrivate::instance()->setEventDispatcher(createEventDispatcher());
QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher);
int numberOfDevices = wfdEnumerateDevices(0,0,0);
WFDint devices[numberOfDevices];
@ -118,10 +119,9 @@ QPlatformBackingStore *QOpenWFDIntegration::createPlatformBackingStore(QWindow *
return new QOpenWFDBackingStore(window);
}
QAbstractEventDispatcher *QOpenWFDIntegration::createEventDispatcher() const
QAbstractEventDispatcher *QOpenWFDIntegration::guiThreadEventDispatcher() const
{
QAbstractEventDispatcher *eventDispatcher = createUnixEventDispatcher();
return eventDispatcher;
return mEventDispatcher;
}
QPlatformFontDatabase *QOpenWFDIntegration::fontDatabase() const

View File

@ -62,7 +62,7 @@ public:
QPlatformGLContext *createPlatformGLContext(QGuiGLContext *context) const;
//This should not be a factory interface, but rather a accessor
QAbstractEventDispatcher *createEventDispatcher() const;
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
QPlatformFontDatabase *fontDatabase() const;
@ -78,6 +78,7 @@ private:
QPlatformFontDatabase *mFontDatabase;
QPlatformNativeInterface *mNativeInterface;
QPlatformPrinterSupport *mPrinterSupport;
QAbstractEventDispatcher *mEventDispatcher;
};
QT_END_NAMESPACE

View File

@ -142,6 +142,13 @@ QWaylandDisplay::QWaylandDisplay(void)
wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this);
mFd = wl_display_get_fd(mDisplay, sourceUpdate, this);
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this);
connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readEvents()));
#ifdef QT_WAYLAND_GL_SUPPORT
mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
#endif
@ -156,16 +163,6 @@ QWaylandDisplay::QWaylandDisplay(void)
mEglIntegration->initialize();
#endif
mFd = wl_display_get_fd(mDisplay, sourceUpdate, this);
}
void QWaylandDisplay::eventDispatcherCreated(QAbstractEventDispatcher *dispatcher)
{
connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this);
connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readEvents()));
waitForScreens();
}

View File

@ -92,8 +92,6 @@ public:
QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
void eventDispatcherCreated(QAbstractEventDispatcher *dispatcher);
public slots:
void createNewScreen(struct wl_output *output, QRect geometry);
void readEvents();

View File

@ -51,6 +51,8 @@
#include "QtPlatformSupport/private/qgenericunixfontdatabase_p.h"
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QWindowSystemInterface>
#include <QtGui/QPlatformCursor>
#include <QtGui/QSurfaceFormat>
@ -61,9 +63,11 @@
QWaylandIntegration::QWaylandIntegration()
: mFontDb(new QGenericUnixFontDatabase())
, mDisplay(new QWaylandDisplay())
, mEventDispatcher(createUnixEventDispatcher())
, mNativeInterface(new QWaylandNativeInterface)
{
QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher);
mDisplay = new QWaylandDisplay();
}
QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const
@ -116,11 +120,9 @@ QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow *
return new QWaylandShmBackingStore(window);
}
QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
QAbstractEventDispatcher *QWaylandIntegration::guiThreadEventDispatcher() const
{
QAbstractEventDispatcher *dispatcher = createUnixEventDispatcher();
mDisplay->eventDispatcherCreated(dispatcher);
return dispatcher;
return mEventDispatcher;
}
QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const

View File

@ -59,7 +59,8 @@ public:
QPlatformWindow *createPlatformWindow(QWindow *window) const;
QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
QAbstractEventDispatcher *createEventDispatcher() const;
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
QList<QPlatformScreen *> screens() const;
@ -73,6 +74,7 @@ public:
private:
QPlatformFontDatabase *mFontDb;
QAbstractEventDispatcher *mEventDispatcher;
QWaylandDisplay *mDisplay;
QPlatformNativeInterface *mNativeInterface;
};

View File

@ -114,6 +114,13 @@ QXcbConnection::QXcbConnection(const char *displayName)
if (m_connection)
printf("Successfully connected to display %s\n", m_displayName.constData());
QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents()));
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents()));
connect(dispatcher, SIGNAL(awake()), this, SLOT(processXcbEvents()));
xcb_prefetch_extension_data (m_connection, &xcb_xfixes_id);
m_setup = xcb_get_setup(xcb_connection());
@ -159,15 +166,6 @@ QXcbConnection::~QXcbConnection()
delete m_keyboard;
}
void QXcbConnection::setEventDispatcher(QAbstractEventDispatcher *dispatcher)
{
QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents()));
connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents()));
connect(dispatcher, SIGNAL(awake()), this, SLOT(processXcbEvents()));
}
void QXcbConnection::addWindow(xcb_window_t id, QXcbWindow *window)
{
m_mapper.insert(id, window);

View File

@ -232,8 +232,6 @@ public:
QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); }
void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
const QList<QXcbScreen *> &screens() const { return m_screens; }
int primaryScreen() const { return m_primaryScreen; }

View File

@ -57,6 +57,9 @@
#include <stdio.h>
//this has to be included before egl, since egl pulls in X headers
#include <QtGui/private/qguiapplication_p.h>
#ifdef XCB_USE_EGL
#include <EGL/egl.h>
#endif
@ -78,7 +81,10 @@
QXcbIntegration::QXcbIntegration(const QStringList &parameters)
: m_printerSupport(new QGenericUnixPrinterSupport)
, m_eventDispatcher(createUnixEventDispatcher())
{
QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher);
m_connections << new QXcbConnection;
for (int i = 0; i < parameters.size() - 1; i += 2) {
@ -94,7 +100,7 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters)
m_fontDatabase = new QGenericUnixFontDatabase();
m_nativeInterface = new QXcbNativeInterface;
m_inputContext = 0;
m_inputContext = new QIBusPlatformInputContext;
}
QXcbIntegration::~QXcbIntegration()
@ -149,18 +155,9 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
}
}
QAbstractEventDispatcher *QXcbIntegration::createEventDispatcher() const
QAbstractEventDispatcher *QXcbIntegration::guiThreadEventDispatcher() const
{
QAbstractEventDispatcher *eventDispatcher = createUnixEventDispatcher();
foreach (QXcbConnection *connection, m_connections)
connection->setEventDispatcher(eventDispatcher);
#ifdef XCB_USE_IBUS
// A bit hacky to do this here, but we need an eventloop before we can instantiate
// the input context.
const_cast<QXcbIntegration *>(this)->m_inputContext = new QIBusPlatformInputContext;
#endif
return eventDispatcher;
return m_eventDispatcher;
}
void QXcbIntegration::moveToScreen(QWindow *window, int screen)

View File

@ -61,7 +61,7 @@ public:
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
bool hasCapability(Capability cap) const;
QAbstractEventDispatcher *createEventDispatcher() const;
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
void moveToScreen(QWindow *window, int screen);
@ -83,6 +83,7 @@ private:
QPlatformPrinterSupport *m_printerSupport;
QPlatformInputContext *m_inputContext;
QAbstractEventDispatcher *m_eventDispatcher;
};
QT_END_NAMESPACE