From 86aae9eac30cda7757ee7a4eb1946985342553e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B8rgen=20Lind?= Date: Tue, 10 Jan 2012 12:28:32 +0100 Subject: [PATCH] Add global x and y coordinates to our mouse events MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Qt applications don't need global x and y, but the protocol dictates it, so someone else might need it. We still keep the api to just use the local coordinates Change-Id: I4b34df935a6692a8d72946c16603d3d600514161 Sanity-Review: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/compositor/wayland_wrapper/wlcompositor.cpp | 8 +++++-- src/compositor/wayland_wrapper/wlcompositor.h | 2 +- src/compositor/wayland_wrapper/wlsurface.cpp | 31 +++++++++++++++++++------ src/compositor/wayland_wrapper/wlsurface.h | 4 ++++ wayland_sha1.txt | 2 +- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp index 98a9625..806a5f7 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/compositor/wayland_wrapper/wlcompositor.cpp @@ -285,9 +285,13 @@ Surface *Compositor::keyFocus() const return wayland_cast(m_input->base()->keyboard_focus); } -void Compositor::setPointerFocus(Surface *surface, const QPoint &pos) +void Compositor::setPointerFocus(Surface *surface, const QPoint &globalPos, const QPoint &localPos) { - wl_input_device_set_pointer_focus(m_input->base(), surface ? surface->base() : 0, currentTimeMsecs(), pos.x(), pos.y(), pos.x(), pos.y()); + wl_input_device_set_pointer_focus(m_input->base(), + surface ? surface->base() : 0, + currentTimeMsecs(), + globalPos.x(), globalPos.y(), + localPos.x(), localPos.y()); } Surface *Compositor::pointerFocus() const diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h index 3ca4fd2..b3afe86 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.h +++ b/src/compositor/wayland_wrapper/wlcompositor.h @@ -78,7 +78,7 @@ public: void setInputFocus(Surface *surface); void setKeyFocus(Surface *surface); Surface *keyFocus() const; - void setPointerFocus(Surface *surface, const QPoint &point = QPoint()); + void setPointerFocus(Surface *surface, const QPoint &globalPos = QPoint(), const QPoint &localPos = QPoint()); Surface *pointerFocus() const; Surface *getSurfaceFromWinId(uint winId) const; diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index 324b94a..c81f746 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -345,7 +345,8 @@ public: QByteArray authenticationToken; QVariantMap windowProperties; - QPoint lastMousePos; + QPoint lastLocalMousePos; + QPoint lastGlobalMousePos; struct wl_list frame_callback_list; @@ -624,7 +625,7 @@ uint32_t BTN_MIDDLE = 0x112; QPoint Surface::lastMousePos() const { Q_D(const Surface); - return d->lastMousePos; + return d->lastLocalMousePos; } void Surface::setExtendedSurface(ExtendedSurface *extendedSurface) @@ -665,8 +666,13 @@ ShellSurface *Surface::shellSurface() const void Surface::sendMousePressEvent(int x, int y, Qt::MouseButton button) { + sendMousePressEvent(x,y,x,y,button); +} + +void Surface::sendMousePressEvent(int global_x, int global_y, int local_x, int local_y, Qt::MouseButton button) +{ Q_D(Surface); - sendMouseMoveEvent(x, y); + sendMouseMoveEvent(global_x,global_y,local_x,local_y); uint32_t time = d->compositor->currentTimeMsecs(); struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; if (pointer_focus_resource) { @@ -677,8 +683,13 @@ void Surface::sendMousePressEvent(int x, int y, Qt::MouseButton button) void Surface::sendMouseReleaseEvent(int x, int y, Qt::MouseButton button) { + sendMouseReleaseEvent(x,y,x,y,button); +} + +void Surface::sendMouseReleaseEvent(int global_x, int global_y, int local_x, int local_y, Qt::MouseButton button) +{ Q_D(Surface); - sendMouseMoveEvent(x, y); + sendMouseMoveEvent(global_x,global_y,local_x, local_y); uint32_t time = d->compositor->currentTimeMsecs(); struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; if (pointer_focus_resource) { @@ -689,14 +700,20 @@ void Surface::sendMouseReleaseEvent(int x, int y, Qt::MouseButton button) void Surface::sendMouseMoveEvent(int x, int y) { + sendMouseMoveEvent(x,y,x,y); +} + +void Surface::sendMouseMoveEvent(int global_x, int global_y, int local_x, int local_y) +{ Q_D(Surface); - d->lastMousePos = QPoint(x, y); + d->lastLocalMousePos = QPoint(local_x, local_y); + d->lastGlobalMousePos = QPoint(global_x, global_y); uint32_t time = d->compositor->currentTimeMsecs(); - d->compositor->setPointerFocus(this, QPoint(x, y)); + d->compositor->setPointerFocus(this, d->lastGlobalMousePos, d->lastLocalMousePos); struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; if (pointer_focus_resource) { wl_resource_post_event(pointer_focus_resource, - WL_INPUT_DEVICE_MOTION, time, x, y, x, y); + WL_INPUT_DEVICE_MOTION, time, global_x, global_y, local_x, local_y); } } diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index 1edf1e7..06dd3bd 100644 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ b/src/compositor/wayland_wrapper/wlsurface.h @@ -98,8 +98,12 @@ public: #endif void sendMousePressEvent(int x, int y, Qt::MouseButton button); + void sendMousePressEvent(int global_x, int global_y, int local_x, int local_y, Qt::MouseButton button); void sendMouseReleaseEvent(int x, int y, Qt::MouseButton button); + void sendMouseReleaseEvent(int global_x, int global_y, int local_x, int local_y, Qt::MouseButton button); void sendMouseMoveEvent(int x, int y); + void sendMouseMoveEvent(int global_x, int global_y, int local_x, int local_y); + void sendKeyPressEvent(uint code); void sendKeyReleaseEvent(uint code); diff --git a/wayland_sha1.txt b/wayland_sha1.txt index 36934ab..4b6c19a 100644 --- a/wayland_sha1.txt +++ b/wayland_sha1.txt @@ -1,3 +1,3 @@ This version of Qt-Compositor is checked against the following sha1 from the Wayland repository: -1f58d155da09f66dc1eaaafafddae3312e71704f +b2e619c7409a98936233b5f8afb8797f5ac457e9 -- 2.7.4