[wayland] Create event dispatcher in QPA plugin

We no longer need to have the event dispatcher created before starting
the QApplication, thus we can leave it to the QPA plugin to creat it.

Also we don't need to implement our own dispatcher any more but can
use one from Qt5PlatformSupport as we link it anyways. The special
need for dispatching the WaylandServer is no longer needed as we can
explicitly dispatch it from the QPA plugin if needed.
This commit is contained in:
Martin Gräßlin 2015-08-20 14:31:13 +02:00
parent a10be8a7d7
commit abb9bf1355
4 changed files with 3 additions and 40 deletions

View file

@ -555,8 +555,6 @@ install(TARGETS kwin ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELIN
install(TARGETS kdeinit_kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} ) install(TARGETS kdeinit_kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(TARGETS kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} ) install(TARGETS kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} )
include_directories(${Qt5Core_PRIVATE_INCLUDE_DIRS})
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
add_executable(kwin_wayland main_wayland.cpp) add_executable(kwin_wayland main_wayland.cpp)
target_link_libraries(kwin_wayland kwin) target_link_libraries(kwin_wayland kwin)

View file

@ -34,11 +34,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KPluginMetaData> #include <KPluginMetaData>
// Qt // Qt
#include <qplatformdefs.h> #include <qplatformdefs.h>
#include <QAbstractEventDispatcher>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QtConcurrentRun> #include <QtConcurrentRun>
#include <QFile> #include <QFile>
#include <QFutureWatcher> #include <QFutureWatcher>
#include <qpa/qwindowsysteminterface.h>
#include <QProcess> #include <QProcess>
#include <QSocketNotifier> #include <QSocketNotifier>
#include <QThread> #include <QThread>
@ -316,25 +316,6 @@ static void readDisplay(int pipe)
close(pipe); close(pipe);
} }
EventDispatcher::EventDispatcher(QObject *parent)
: QEventDispatcherUNIX(parent)
{
}
EventDispatcher::~EventDispatcher() = default;
bool EventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
{
waylandServer()->dispatch();
const bool didSendEvents = QEventDispatcherUNIX::processEvents(flags);
return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents;
}
bool EventDispatcher::hasPendingEvents()
{
return QEventDispatcherUNIX::hasPendingEvents() || QWindowSystemInterface::windowSystemEventsQueued();
}
static const QString s_waylandPlugin = QStringLiteral("KWinWaylandWaylandBackend"); static const QString s_waylandPlugin = QStringLiteral("KWinWaylandWaylandBackend");
static const QString s_x11Plugin = QStringLiteral("KWinWaylandX11Backend"); static const QString s_x11Plugin = QStringLiteral("KWinWaylandX11Backend");
static const QString s_fbdevPlugin = QStringLiteral("KWinWaylandFbdevBackend"); static const QString s_fbdevPlugin = QStringLiteral("KWinWaylandFbdevBackend");
@ -368,10 +349,6 @@ static QString automaticBackendSelection()
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
// set our own event dispatcher to be able to dispatch events before the event loop is started
QAbstractEventDispatcher *eventDispatcher = new KWin::EventDispatcher();
QCoreApplication::setEventDispatcher(eventDispatcher);
KWin::Application::setupMalloc(); KWin::Application::setupMalloc();
KWin::Application::setupLocalizedString(); KWin::Application::setupLocalizedString();

View file

@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_MAIN_WAYLAND_H #ifndef KWIN_MAIN_WAYLAND_H
#define KWIN_MAIN_WAYLAND_H #define KWIN_MAIN_WAYLAND_H
#include "main.h" #include "main.h"
#include <QtCore/private/qeventdispatcher_unix_p.h>
#include <QProcessEnvironment> #include <QProcessEnvironment>
class QProcess; class QProcess;
@ -70,17 +69,6 @@ private:
QProcessEnvironment m_environment; QProcessEnvironment m_environment;
}; };
class EventDispatcher : public QEventDispatcherUNIX
{
Q_OBJECT
public:
explicit EventDispatcher(QObject *parent = nullptr);
virtual ~EventDispatcher();
bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
bool hasPendingEvents() override;
};
} }
#endif #endif

View file

@ -43,6 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtCore/private/qeventdispatcher_unix_p.h> #include <QtCore/private/qeventdispatcher_unix_p.h>
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> #include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include <QtPlatformSupport/private/qgenericunixthemes_p.h> #include <QtPlatformSupport/private/qgenericunixthemes_p.h>
#include <QtPlatformSupport/private/qunixeventdispatcher_qpa_p.h>
namespace KWin namespace KWin
{ {
@ -90,8 +91,7 @@ void Integration::initialize()
QAbstractEventDispatcher *Integration::createEventDispatcher() const QAbstractEventDispatcher *Integration::createEventDispatcher() const
{ {
// TODO: add our own event dispatcher return new QUnixEventDispatcherQPA;
return new QEventDispatcherUNIX;
} }
QPlatformBackingStore *Integration::createPlatformBackingStore(QWindow *window) const QPlatformBackingStore *Integration::createPlatformBackingStore(QWindow *window) const