From da82afb33090ba215e34c49dfcbc99d5e24d64c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Samuel=20R=C3=B8dal?= Date: Wed, 28 Mar 2012 12:18:14 +0200 Subject: [PATCH] Enable the qtkey extension regardless. Now the clients get qtkey events if they register themselves against that interface, otherwise they get regular key events. This handles both qt clients and pure wayland clients being connected at the same time, sending qtkey events to the former and regular key events to the latter. Change-Id: Iebd9d78b57758b45098b99a94414ee428e41636b Reviewed-by: Laszlo Agocs --- src/compositor/compositor_api/waylandcompositor.cpp | 5 ----- src/compositor/compositor_api/waylandcompositor.h | 1 - src/compositor/wayland_wrapper/wlcompositor.cpp | 8 +------- src/compositor/wayland_wrapper/wlcompositor.h | 1 - src/compositor/wayland_wrapper/wlinputdevice.cpp | 4 +--- src/compositor/wayland_wrapper/wlqtkey.cpp | 6 +++++- src/compositor/wayland_wrapper/wlqtkey.h | 2 +- 7 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/compositor/compositor_api/waylandcompositor.cpp b/src/compositor/compositor_api/waylandcompositor.cpp index 63cd58f..301d422 100644 --- a/src/compositor/compositor_api/waylandcompositor.cpp +++ b/src/compositor/compositor_api/waylandcompositor.cpp @@ -206,11 +206,6 @@ void WaylandCompositor::enableSubSurfaceExtension() m_compositor->enableSubSurfaceExtension(); } -void WaylandCompositor::enableQtKeyExtension() -{ - m_compositor->enableQtKeyExtension(); -} - void WaylandCompositor::enableTouchExtension() { m_compositor->enableTouchExtension(); diff --git a/src/compositor/compositor_api/waylandcompositor.h b/src/compositor/compositor_api/waylandcompositor.h index 069163d..c68cd6c 100644 --- a/src/compositor/compositor_api/waylandcompositor.h +++ b/src/compositor/compositor_api/waylandcompositor.h @@ -98,7 +98,6 @@ public: virtual void changeCursor(const QImage &image, int hotspotX, int hotspotY); void enableSubSurfaceExtension(); - void enableQtKeyExtension(); void enableTouchExtension(); enum TouchExtensionFlag { diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp index 2488fd7..23d6c2a 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/compositor/wayland_wrapper/wlcompositor.cpp @@ -133,7 +133,6 @@ Compositor::Compositor(WaylandCompositor *qt_compositor) , m_surfaceExtension(0) , m_subSurfaceExtension(0) , m_touchExtension(0) - , m_qtkeyExtension(0) , m_retainNotify(0) { compositor = this; @@ -156,6 +155,7 @@ Compositor::Compositor(WaylandCompositor *qt_compositor) m_outputExtension = new OutputExtensionGlobal(this); m_surfaceExtension = new SurfaceExtensionGlobal(this); + m_qtkeyExtension = new QtKeyExtensionGlobal(this); if (wl_display_add_socket(m_display->handle(), qt_compositor->socketName())) { fprintf(stderr, "Fatal: Failed to open server socket\n"); @@ -418,12 +418,6 @@ void Compositor::enableTouchExtension() } } -void Compositor::enableQtKeyExtension() -{ - if (!m_qtkeyExtension) - m_qtkeyExtension = new QtKeyExtensionGlobal(this); -} - void Compositor::configureTouchExtension(int flags) { if (m_touchExtension) diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h index 9a65888..1710619 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.h +++ b/src/compositor/wayland_wrapper/wlcompositor.h @@ -131,7 +131,6 @@ public: TouchExtensionGlobal *touchExtension() { return m_touchExtension; } void configureTouchExtension(int flags); - void enableQtKeyExtension(); QtKeyExtensionGlobal *qtkeyExtension() { return m_qtkeyExtension; } bool isDragging() const; diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp index 9b20edd..3c23d48 100644 --- a/src/compositor/wayland_wrapper/wlinputdevice.cpp +++ b/src/compositor/wayland_wrapper/wlinputdevice.cpp @@ -177,10 +177,8 @@ void InputDevice::sendFullKeyEvent(QKeyEvent *event) } QtKeyExtensionGlobal *ext = m_compositor->qtkeyExtension(); - if (ext) { - ext->postQtKeyEvent(event, keyboardFocus()); + if (ext && ext->postQtKeyEvent(event, keyboardFocus())) return; - } if (event->type() == QEvent::KeyPress) sendKeyPressEvent(event->nativeScanCode()); diff --git a/src/compositor/wayland_wrapper/wlqtkey.cpp b/src/compositor/wayland_wrapper/wlqtkey.cpp index b8381a2..ce881b3 100644 --- a/src/compositor/wayland_wrapper/wlqtkey.cpp +++ b/src/compositor/wayland_wrapper/wlqtkey.cpp @@ -82,7 +82,7 @@ void QtKeyExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t ver self->m_resources.append(resource); } -void QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) +bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) { wl_client *surfaceClient = surface->base()->resource.client; uint32_t time = m_compositor->currentTimeMsecs(); @@ -103,7 +103,11 @@ void QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) textUtf8.constData(), event->isAutoRepeat(), event->count()); + + return true; } + + return false; } } diff --git a/src/compositor/wayland_wrapper/wlqtkey.h b/src/compositor/wayland_wrapper/wlqtkey.h index ed718dc..bb41f57 100644 --- a/src/compositor/wayland_wrapper/wlqtkey.h +++ b/src/compositor/wayland_wrapper/wlqtkey.h @@ -57,7 +57,7 @@ public: QtKeyExtensionGlobal(Compositor *compositor); ~QtKeyExtensionGlobal(); - void postQtKeyEvent(QKeyEvent *event, Surface *surface); + bool postQtKeyEvent(QKeyEvent *event, Surface *surface); private: static void bind_func(struct wl_client *client, void *data, -- 2.7.4