Send the globals to new listeners

Change-Id: I8d2a74cdc305fb086f3b5c63d0abe4c46c40bbde
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
This commit is contained in:
Laszlo Agocs 2014-01-15 14:18:50 +01:00 committed by The Qt Project
parent 3a2ece17c3
commit cb09f9a7fa
2 changed files with 32 additions and 8 deletions

View File

@ -175,12 +175,6 @@ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
return 0; return 0;
} }
void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
{
Listener l = { listener, data };
mRegistryListeners.append(l);
}
void QWaylandDisplay::waitForScreens() void QWaylandDisplay::waitForScreens()
{ {
flushRequests(); flushRequests();
@ -234,13 +228,33 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
} else if (interface == QStringLiteral("wl_text_input_manager")) { } else if (interface == QStringLiteral("wl_text_input_manager")) {
mTextInputManager.reset(new QtWayland::wl_text_input_manager(registry, id)); mTextInputManager.reset(new QtWayland::wl_text_input_manager(registry, id));
} else if (interface == QStringLiteral("qt_hardware_integration")) { } else if (interface == QStringLiteral("qt_hardware_integration")) {
mHardwareIntegration.reset(new QWaylandHardwareIntegration(registry, id)); mHardwareIntegration.reset(new QWaylandHardwareIntegration(registry, id));
} }
mGlobals.append(RegistryGlobal(id, interface, version, registry));
foreach (Listener l, mRegistryListeners) foreach (Listener l, mRegistryListeners)
(*l.listener)(l.data, registry, id, interface, version); (*l.listener)(l.data, registry, id, interface, version);
} }
void QWaylandDisplay::registry_global_remove(uint32_t id)
{
for (int i = 0, ie = mGlobals.count(); i != ie; ++i) {
if (mGlobals[i].id == id) {
mGlobals.removeAt(i);
break;
}
}
}
void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
{
Listener l = { listener, data };
mRegistryListeners.append(l);
for (int i = 0, ie = mGlobals.count(); i != ie; ++i)
(*l.listener)(l.data, mGlobals[i].registry, mGlobals[i].id, mGlobals[i].interface, mGlobals[i].version);
}
uint32_t QWaylandDisplay::currentTimeMillisec() uint32_t QWaylandDisplay::currentTimeMillisec()
{ {
//### we throw away the time information //### we throw away the time information

View File

@ -130,6 +130,15 @@ public:
QtWayland::wl_text_input_manager *textInputManager() const { return mTextInputManager.data(); } QtWayland::wl_text_input_manager *textInputManager() const { return mTextInputManager.data(); }
QWaylandHardwareIntegration *hardwareIntegration() const { return mHardwareIntegration.data(); } QWaylandHardwareIntegration *hardwareIntegration() const { return mHardwareIntegration.data(); }
struct RegistryGlobal {
uint32_t id;
QString interface;
uint32_t version;
struct ::wl_registry *registry;
RegistryGlobal(uint32_t id_, const QString &interface_, uint32_t version_, struct ::wl_registry *registry_)
: id(id_), interface(interface_), version(version_), registry(registry_) { }
};
/* wl_registry_add_listener does not add but rather sets a listener, so this function is used /* wl_registry_add_listener does not add but rather sets a listener, so this function is used
* to enable many listeners at once. */ * to enable many listeners at once. */
void addRegistryListener(RegistryListener listener, void *data); void addRegistryListener(RegistryListener listener, void *data);
@ -173,13 +182,14 @@ private:
QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration; QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration;
QScopedPointer<QtWayland::wl_text_input_manager> mTextInputManager; QScopedPointer<QtWayland::wl_text_input_manager> mTextInputManager;
QScopedPointer<QWaylandHardwareIntegration> mHardwareIntegration; QScopedPointer<QWaylandHardwareIntegration> mHardwareIntegration;
QSocketNotifier *mReadNotifier; QSocketNotifier *mReadNotifier;
int mFd; int mFd;
int mWritableNotificationFd; int mWritableNotificationFd;
bool mScreensInitialized; bool mScreensInitialized;
QList<RegistryGlobal> mGlobals;
void registry_global(uint32_t id, const QString &interface, uint32_t version) Q_DECL_OVERRIDE; void registry_global(uint32_t id, const QString &interface, uint32_t version) Q_DECL_OVERRIDE;
void registry_global_remove(uint32_t id) Q_DECL_OVERRIDE;
static void shellHandleConfigure(void *data, struct wl_shell *shell, static void shellHandleConfigure(void *data, struct wl_shell *shell,
uint32_t time, uint32_t edges, uint32_t time, uint32_t edges,