createPlatformIntegration();
if (!eventDispatcher) {
- QAbstractEventDispatcher *eventDispatcher = platform_integration->createEventDispatcher();
+ QAbstractEventDispatcher *eventDispatcher = platform_integration->guiThreadEventDispatcher();
setEventDispatcher(eventDispatcher);
}
}
{
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;
}
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;
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;
};
QCocoaIntegration::QCocoaIntegration()
: mFontDb(new QBasicUnixFontDatabase())
+ , mEventDispatcher(new QCocoaEventDispatcher())
{
mPool = new QCocoaAutoReleasePool;
return new QCocoaBackingStore(window);
}
-QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const
+QAbstractEventDispatcher *QCocoaIntegration::guiThreadEventDispatcher() const
{
- return new QCocoaEventDispatcher();
+ return mEventDispatcher;
}
QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const
}
}
- 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;
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];
return new QOpenWFDBackingStore(window);
}
-QAbstractEventDispatcher *QOpenWFDIntegration::createEventDispatcher() const
+QAbstractEventDispatcher *QOpenWFDIntegration::guiThreadEventDispatcher() const
{
- QAbstractEventDispatcher *eventDispatcher = createUnixEventDispatcher();
- return eventDispatcher;
+ return mEventDispatcher;
}
QPlatformFontDatabase *QOpenWFDIntegration::fontDatabase() const
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;
QPlatformFontDatabase *mFontDatabase;
QPlatformNativeInterface *mNativeInterface;
QPlatformPrinterSupport *mPrinterSupport;
+ QAbstractEventDispatcher *mEventDispatcher;
};
QT_END_NAMESPACE
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
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();
}
QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
- void eventDispatcherCreated(QAbstractEventDispatcher *dispatcher);
-
public slots:
void createNewScreen(struct wl_output *output, QRect geometry);
void readEvents();
#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>
QWaylandIntegration::QWaylandIntegration()
: mFontDb(new QGenericUnixFontDatabase())
- , mDisplay(new QWaylandDisplay())
+ , mEventDispatcher(createUnixEventDispatcher())
, mNativeInterface(new QWaylandNativeInterface)
{
+ QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher);
+ mDisplay = new QWaylandDisplay();
}
QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const
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
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;
private:
QPlatformFontDatabase *mFontDb;
+ QAbstractEventDispatcher *mEventDispatcher;
QWaylandDisplay *mDisplay;
QPlatformNativeInterface *mNativeInterface;
};
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());
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);
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; }
#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
QXcbIntegration::QXcbIntegration(const QStringList ¶meters)
: 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) {
m_fontDatabase = new QGenericUnixFontDatabase();
m_nativeInterface = new QXcbNativeInterface;
- m_inputContext = 0;
+ m_inputContext = new QIBusPlatformInputContext;
}
QXcbIntegration::~QXcbIntegration()
}
}
-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)
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
bool hasCapability(Capability cap) const;
- QAbstractEventDispatcher *createEventDispatcher() const;
+ QAbstractEventDispatcher *guiThreadEventDispatcher() const;
void moveToScreen(QWindow *window, int screen);
QPlatformPrinterSupport *m_printerSupport;
QPlatformInputContext *m_inputContext;
+ QAbstractEventDispatcher *m_eventDispatcher;
};
QT_END_NAMESPACE